d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Debug Problem With Python
Add Reply New Topic New Poll
Member
Posts: 10,812
Joined: Oct 15 2009
Gold: Locked
Warn: 20%
Apr 1 2014 09:00am
Code
c_text_list=[127, 86, 71, 71, 78, 23, 118, 71, 69, 94, 91, 23, 113, 88, 88, 91, 16, 68, 23, 115, 86, 78, 22, 22, 22]
p_text_string=""
for entry in c_text_list:
p_text_string += chr(entry^55)

print p_text_string
Member
Posts: 11,610
Joined: Oct 28 2008
Gold: 1,795.00
Apr 1 2014 12:36pm
print needs ()
Member
Posts: 21,211
Joined: May 22 2009
Gold: 9,036.90
Apr 1 2014 02:22pm
Quote (0n35 @ Apr 1 2014 01:36pm)
print needs ()


only if python3
Member
Posts: 11,610
Joined: Oct 28 2008
Gold: 1,795.00
Apr 1 2014 02:34pm
Quote (zeroRooter @ Apr 1 2014 02:22pm)
only if python3


no

I can import print to use it like in py2.x

from __future__ import print_function

But to pep3105 standards the statement has been removed
Member
Posts: 62,215
Joined: Jun 3 2007
Gold: 9,039.20
Apr 2 2014 03:43am
Don't even need to import from future, Print is already a function in 2.7.6

Code
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.

C:\Users\urafag>python
Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> print('dum')
dum
>>>

Member
Posts: 11,610
Joined: Oct 28 2008
Gold: 1,795.00
Apr 2 2014 04:06am
Quote (killgoreisleet @ Apr 2 2014 03:43am)
Don't even need to import from future, Print is already a function in 2.7.6

Code
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\urafag>python
Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> print('dum')
dum
>>>


In Python 2.x print is a special statement, not a function

This is why it can't be used like: lambda x: print x
Note that (expr) does not create a Tuple (it results in expr), but "," does.
Member
Posts: 62,215
Joined: Jun 3 2007
Gold: 9,039.20
Apr 2 2014 04:55am
Quote (0n35 @ Apr 2 2014 04:06am)
In Python 2.x print is a special statement, not a function

This is why it can't be used like: lambda x: print x
Note that (expr) does not create a Tuple (it results in expr), but "," does.


It seems to work like a function, in the way it works in Python 3+

Code
>>> a = range(0,4)
>>> a
[0, 1, 2, 3]
>>> for i in a:
... print(i+i)
...
0
2
4
6
>>>


You are right, I believe in Python the “,” determines if something is a Tuple more so than the “()”

I think there might be something wrong with lambda, the way it was made, but I am probably wrong.

The way Print is working currently in 2 may be a way to help ease the conversion to 3.



Go Back To Programming & Development Topic List
Add Reply New Topic New Poll