470,815 Members | 1,290 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,815 developers. It's quick & easy.

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 1036

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

29 posts views Thread by George Sakkis | last post: by
31 posts views Thread by Antoon Pardon | last post: by
3 posts views Thread by David | last post: by
reply views Thread by mihailmihai484 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.