Where’s toString?

Why don’t python integers have a smart toString method like java/javascript? It’s easy to convert strings into numbers using int(str_whatever) or float(str_whatever) but to convert them back you have only the decimal system (using str(number) or “%d” % number). In case you want to convert to binary, base32, base36, base64, you’re gonna have to write your own conversion function. Batteries included?

Use either:



I added a feature request, lets see if it gets completely shot down:


2 thoughts on “Where’s toString?

  1. The more common ones exist %x, %o. In newer pythons, %b for binaries as well. Bases like 32, 64 are a bit less useful… (unless you mean base64 encoding, which is something else entirely)

  2. I do mean bases like 32, 36, 62, 64 and user defined bases. Here’s a use case for representing numbers in different bases – shortening a number for exposing url’s on a website, like video id’s on youtube.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s