Re: __index__

2014-11-01 Thread Ethan Furman
On 11/01/2014 11:29 AM, Ethan Furman wrote: But I agree with Net ... Oops, should have ben 'Ned' -- apologies! -- ~Ethan~ -- https://mail.python.org/mailman/listinfo/python-list

Re: __index__

2014-11-01 Thread duncan smith
mutable, so I can't >>> inherit from long. I thought I'd found the answer when I came across >>> __index__, it doesn't seem to work as I expected it to. >> >> Just above your link in the docs is __oct__ and __hex__, which are >> used to implement oct()

Re: __index__

2014-11-01 Thread Ethan Furman
ame across __index__, it doesn't seem to work as I expected it to. Just above your link in the docs is __oct__ and __hex__, which are used to implement oct() and hex(): https://docs.python.org/2/reference/datamodel.html#object.__oct__ In Python 2 __oct__ and __hex__ are used for oct() an

Re: __index__

2014-11-01 Thread duncan smith
On 01/11/14 16:56, duncan smith wrote: [snip] Sorry, forgot to add that I'm using Python 2.7.6 on Ubuntu 14.04. Cheers. Duncan -- https://mail.python.org/mailman/listinfo/python-list

Re: __index__

2014-11-01 Thread Ned Batchelder
On 11/1/14 12:56 PM, duncan smith wrote: Hello, I have a Bloom filter class and want to (partially) serialize instances using hex() or oct(). Instances are mutable, so I can't inherit from long. I thought I'd found the answer when I came across __index__, https://docs.py

__index__

2014-11-01 Thread duncan smith
Hello, I have a Bloom filter class and want to (partially) serialize instances using hex() or oct(). Instances are mutable, so I can't inherit from long. I thought I'd found the answer when I came across __index__, https://docs.python.org/2/reference/datamodel.html#object.__index

Re: Sequence iterators with __index__

2008-06-27 Thread yaipa
On Jun 24, 4:19 pm, schickb <[EMAIL PROTECTED]> wrote: > On Jun 24, 3:45 pm, Matimus <[EMAIL PROTECTED]> wrote: > > > > > > I think it would be useful if iterators on sequences had the __index__ > > > method so that they could be used to slice sequences.

Re: Sequence iterators with __index__

2008-06-25 Thread Matimus
On Jun 24, 4:19 pm, schickb <[EMAIL PROTECTED]> wrote: > On Jun 24, 3:45 pm, Matimus <[EMAIL PROTECTED]> wrote: > > > > > > I think it would be useful if iterators on sequences had the __index__ > > > method so that they could be used to slice sequences.

Re: Sequence iterators with __index__

2008-06-25 Thread schickb
On Jun 25, 12:11 am, schickb <[EMAIL PROTECTED]> wrote: > > But this isn't just about slicing. I'd like sequence iterators to be > usable as simple indexes as well; like a[it] (which __index__ would > also provide). It occurred to me that this wouldn't need to

Re: Sequence iterators with __index__

2008-06-25 Thread schickb
ers. There is no way for obj1 and obj2 to tell Python that they could be reasonably used as indexes into a sequence. This is an unnecessary limitation." But this isn't just about slicing. I'd like sequence iterators to be usable as simple indexes as well; like a[it] (which __index_

Re: Sequence iterators with __index__

2008-06-24 Thread Terry Reedy
schickb wrote: On Jun 24, 3:45 pm, Matimus <[EMAIL PROTECTED]> wrote: I think it would be useful if iterators on sequences had the __index__ method so that they could be used to slice sequences. I was writing a class and wanted to return a list iterator to callers. I then wanted

Re: Sequence iterators with __index__

2008-06-24 Thread schickb
On Jun 24, 3:45 pm, Matimus <[EMAIL PROTECTED]> wrote: > > > I think it would be useful if iterators on sequences had the __index__ > > method so that they could be used to slice sequences. I was writing a > > class and wanted to return a list iterator to callers.  I the

Re: Sequence iterators with __index__

2008-06-24 Thread Matimus
On Jun 24, 3:29 pm, schickb <[EMAIL PROTECTED]> wrote: > I think it would be useful if iterators on sequences had the __index__ > method so that they could be used to slice sequences. I was writing a > class and wanted to return a list iterator to callers.  I then wanted > to

Sequence iterators with __index__

2008-06-24 Thread schickb
I think it would be useful if iterators on sequences had the __index__ method so that they could be used to slice sequences. I was writing a class and wanted to return a list iterator to callers. I then wanted to let callers slice from an iterator's position, but that isn't support