Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #84017 > unrolled thread

Re: How to change the number into the same expression's string and vice versa?

Started byMark Lawrence <breamoreboy@yahoo.co.uk>
First post2015-01-19 16:41 +0000
Last post2015-01-19 16:41 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: How to change the number into the same expression's string and vice versa? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-01-19 16:41 +0000

#84017 — Re: How to change the number into the same expression's string and vice versa?

FromMark Lawrence <breamoreboy@yahoo.co.uk>
Date2015-01-19 16:41 +0000
SubjectRe: How to change the number into the same expression's string and vice versa?
Message-ID<mailman.17854.1421685709.18130.python-list@python.org>
On 19/01/2015 09:01, contro opinion wrote:
>
> In the python3 console:
>
>      >>> a=18
>      >>> b='18'
>      >>> str(a) == b
>      True
>      >>> int(b) == a
>      True
>
>
> Now how to change a1,a2,a3  into b1,b2,b3 and vice versa?
> a1=0xf4
> a2=0o36
> a3=011
>
> b1='0xf4'
> b2='0o36'
> b3='011'
>
>

Giving a completely different take on previous answers how about.

a1, b1 = b1, a1
a2, b2 = b2, a2
a3, b3 = b3, a3

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web