Today, the Python group sees a problem.
python2.7:
'Hello']
Print L
Print x
python3.4:
'Hello'
Print (L) print (x)
Both can print out
L = ['h'e'l ' L ' ' o ']
But only python2.7 can print out the value of the variable x:
' o '
>>> L = [x forXinch 'Hello']>>>PrintL ['h','e','L','L','o']>>>Printx o>>>
python3.4 shows that the x variable is not defined
>>> L = [x forXinch 'Hello']>>>Print(L) ['h','e','L','L','o']>>>Print(x) Traceback (most recent): File"<pyshell#2>", Line 1,inch<module>Print(x) nameerror:name'x' is notdefined>>>
Is such a problem, I through pycharm single-step debugging, found that python2.7 after the completion of the list parsing statements, the variable x still exists.
In python3.4 , after performing the list parsing, the variable x disappears.
Below is the result that I use pycharm separately to debug in different environment
python2.7:
python3.4:
I think this might be a case of python3.4 based on security considerations to avoid variables taking up memory.
On the other hand, it also guarantees that the use of variables in the latter case does not occur in the event of a wrong variable.
2016-03-28 13:26:34
Python issue record