Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #80101
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed1.swip.net!news.astraweb.com!border6.a.newsrouter.astraweb.com!cyclone01.ams2.highwinds-media.com!voer-me.highwinds-media.com!peer01.am1!peering.am1!peer01.fr7!news.highwinds-media.com!not-for-mail |
|---|---|
| X-Trace | DXC=2WH=I2241CM_Lgc?434\PKG^cGF?V7mID]G0e@Sk_WTB\KSWKcAGbbDOk0<7meNZoIeLXWOgPj9_M>_Ck;HVAoNA>F<09LUgVMN>aU8RETJ?X@ |
| X-Complaints-To | abuse@blocknews.net |
| Date | Sat, 01 Nov 2014 19:41:33 +0000 |
| From | duncan smith <buzzard@invalid.invalid> |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 |
| MIME-Version | 1.0 |
| Newsgroups | comp.lang.python |
| Subject | Re: __index__ |
| References | <545510c7$0$27750$862e30e2@ngroups.net> <m3347m$eop$1@ger.gmane.org> <mailman.15394.1414866549.18130.python-list@python.org> |
| In-Reply-To | <mailman.15394.1414866549.18130.python-list@python.org> |
| Content-Type | text/plain; charset=windows-1252 |
| Content-Transfer-Encoding | 7bit |
| Lines | 36 |
| Message-ID | <5455376e$0$27681$862e30e2@ngroups.net> (permalink) |
| NNTP-Posting-Host | 01a1e46b.ngroups.net |
| X-Received-Body-CRC | 964551835 |
| X-Received-Bytes | 2380 |
| Xref | csiph.com comp.lang.python:80101 |
Show key headers only | View raw
On 01/11/14 18:29, Ethan Furman wrote: > On 11/01/2014 10:11 AM, Ned Batchelder wrote: >> On 11/1/14 12:56 PM, duncan smith wrote: >>> >>> 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__, 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() and hex(), but in > Python 3 __index__ is used. > It was the doc for hex at https://docs.python.org/2/library/functions.html that led me to think I needed to implement the _index__ method. The doc for bin and oct seems to be right (I need __index__ for bin, but it doesn't work for oct). > But I agree with Net that using a separate method is probably better. > > -- > ~Ethan~ Possibly, I'm still tinkering with it. I use the Bloom filters to generate, and act as pseudonyms for token sets. I have another class that represents pseudonyms (of a different kind, but still bit strings) that is derived from long - so hex etc. just work. I should probably (at least) subclass my Bloom filter class before adding the relevant methods. Cheers. Duncan
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
__index__ duncan smith <buzzard@invalid.invalid> - 2014-11-01 16:56 +0000
Re: __index__ Ned Batchelder <ned@nedbatchelder.com> - 2014-11-01 13:11 -0400
Re: __index__ duncan smith <buzzard@invalid.invalid> - 2014-11-01 17:15 +0000
Re: __index__ Ethan Furman <ethan@stoneleaf.us> - 2014-11-01 11:29 -0700
Re: __index__ duncan smith <buzzard@invalid.invalid> - 2014-11-01 19:41 +0000
Re: __index__ Ethan Furman <ethan@stoneleaf.us> - 2014-11-01 13:00 -0700
csiph-web