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/2006-January/059799.html below:

[Python-Dev] str with base

[Python-Dev] str with baseBarry Warsaw barry at python.org
Tue Jan 17 05:18:11 CET 2006
On Tue, 2006-01-17 at 15:08 +1100, Andrew Bennetts wrote:

> My reaction having read this far was "huh?".  It took some time (several
> seconds) before it occurred to me what you wanted str(5,2) to mean, and why it
> should give '101'.
> 
> If you'd proposed, say (5).as_binary() == '101', or "5".encode("base2"), I
> wouldn't have been as baffled.  Or perhaps even str(5, base=2), but frankly the
> idea of the string type doing numeric base conversions seems weird to me, rather
> than symmetric.
> 
> I wouldn't mind seeing arbitrary base encoding of integers included somewhere,
> but as a method of str -- let alone the constructor! -- it feels quite wrong.

Hear, hear.  I was similarly perplexed when I first read that!

-Barry

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 307 bytes
Desc: This is a digitally signed message part
Url : http://mail.python.org/pipermail/python-dev/attachments/20060116/ce26803a/attachment.pgp 
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