473,385 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

deleting, but not getting, slices

>>> import sys
sys.version

'2.3.4 (#1, Feb 4 2005, 12:19:08) \n[GCC 3.2.3 20030502 (Red Hat Linux
3.2.3-42)]'
I'm implementing a type that supports a subset of the sequence
abstraction in which I want to allow the deletion of elements/slices,
but don't need/want to allow the fetching of a slice. So I filled
in the tp_as_sequence slot, filled in the sq_ass_slice slot, and
did not fill in sq_slice.

I was surprised to find that this did not work.

On further investigation, I found out that it was because in
assign_slice(), the call to PySequence_(Del|Set)Slice is inside
this test:

if (sq && sq->sq_slice && ISINT(v) && ISINT(w)) {
...

It baffles me why the test if for sq_slice, not sq_ass_slice,
when neither of PySequence_(Del|Set)Slice reference sq_slice,
but both reference sq_ass_slice.

My attempts to find an explanation in the docs/faqs/code have
been thusfar fruitless.

I'm able to work around it by defining a sq_slice that does
nothing but unconditionally raise an exception. But the check
for sq_slice in assign_slice() makes me wonder if this is the
right thing to do. (Seems ok so far.)

Any hints would be appreciated

phil
Jul 19 '05 #1
0 1071

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

29
by: George Sakkis | last post by:
Why does slicing a tuple returns a new tuple instead of a view of the existing one, given that tuples are immutable ? I ended up writing a custom ImmutableSequence class that does this, but I...
31
by: Antoon Pardon | last post by:
The following is part of the explanation on slices in the tutorial: The best way to remember how slices work is to think of the indices as pointing between characters, with the left edge of the...
5
by: NuberSteve | last post by:
I'm very new to using CSS and also the concept of slices for mouse-overs, and have made my first attempt at using ImageReady to generate slices of a world map. I basically wanted a map that would...
3
by: David | last post by:
That xpairs() generator is nice, but it's not the best possible code What do you mean by best possible? Most efficient? Most readable? And why don't you use islice? eg: def xpairs(seq):...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.