A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2003-November/040019.html below:

[Python-Dev] test warnings for "%x"%id(foo) on 2.3 branch

[Python-Dev] test warnings for "%x"%id(foo) on 2.3 branch [Python-Dev] test warnings for "%x"%id(foo) on 2.3 branchMartin v. Löwis martin at v.loewis.de
Wed Nov 5 14:43:43 EST 2003
Anthony Baxter <anthony at interlink.com.au> writes:

> >>> Anthony Baxter wrote
> > Hm. "%x" % (id(o) & 2L*sys.maxint+1)
> > is considerably less obvious that "%x"%id(o)
> 
> The best I can come up with at this moment using the 'struct' module is
> ''.join(['%02x'%ord(x) for x in struct.pack('>i', id(o))]), which is also
> pretty grotesque. 

In what sense is this better - in particular if you would write mine as

MAX_UINT = 2L*sys.maxint+1
...
"%x" % (id(o) & MAX_UINT)

> Thinking about it further, the better fix might be to replace the test
> code that looks for an exact match with a regex-based match instead...

It's not just in test code, AFAIR - also in minidom __repr__ (or some
such).

Regards,
Martin


More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4