Python - decode('hex')

Steve D'Aprano steve+python at pearwood.info
Mon Feb 20 19:22:23 EST 2017


On Tue, 21 Feb 2017 06:43 am, Ganesh Pal wrote:

> How can I make my program 2 look like program 1

I don't understand the question. If you want program 2 to look like program
1, you can edit program 2 and change it to look like program 1. But why not
just use program 1? It already looks like program 1.


In an earlier post, you even pointed out that there is just a single, three
line difference between the two programs:

[quote]
1. The only difference between both the programs  the difference are just
the below lines.

newdata = '64000101057804'.decode('hex')

        and

newdata = ""
newdata = '64000101057804'
newdata.decode('hex')
[end quote]


So you select the three lines which don't work in your editor, hit DELETE,
then type the one line which does work.


If you want to understand WHY the three lines don't work, add "print
newdata" to the end:


newdata = ""
newdata = '64000101057804'
newdata.decode('hex')
print newdata


If you still don't understand what is going on, try this example instead:


x = 0
x = 999
x + 1
print x


versus:

x = 999
x = x + 1
print x


or even better:

x = 999 + 1
print x



-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.




More information about the Python-list mailing list