int <-> str asymmetric

  • Thread starter =?ISO-8859-1?Q?Sch=FCle_Daniel?=
  • Start date
?

=?ISO-8859-1?Q?Sch=FCle_Daniel?=

Hello

what I sometimes miss in Python is the possibility to
switch tha base of a number
for example this is how it's done in Ruby

irb(main):099:0* a = 10.to_s(2)
=> "1010"
irb(main):100:0> a.to_i(2)
=> 10
irb(main):101:0>
irb(main):102:0* a = 10.to_s(3)
=> "101"
irb(main):103:0> a.to_i(3)
=> 10

the Python int-Function behaves similar
however we lack the reverse functionality
the logical
Traceback (most recent call last):

fails

it would not break anything if str interface would be changed
what do you think?
Is this already proposed or maybe implemented in 2.5?

Regards, Daniel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top