Is there something wrong with the Python Shell (Google app)?

Python Shell - shell.appspot.com acting weird? or am I missing something?

Google App Engine/1.3.0
Python 2.5.2 (r252:60911, Apr  7 2009, 17:42:26) 
[GCC 4.1.0]

>>> mycolors = ['red','green','blue']
>>> mycolors.append('black')
>>> print mycolors
['red', 'green', 'blue']

But the expected result is expected.

['red', 'green', 'blue', 'black']

And also the same with the dictionary data type.

Thanks,

Abhinay

+5
source share
2 answers

Short answer

This is a known bug. Short answer:

  • Include all in one line: mycolors.append('black'); print mycolors
  • Use my free App Engine Console software tool . My code is obtained from the shell, and I fixed this error.

Long answer

, . - /; ( ) , Python.

:

  • ,
  • , . , __main__ .
  • .
  • , ...
    • ,
    • , . . , .
+4

, , .

>>> a = 2
>>> a += 3
>>> a
5
>>> b = [2]
>>> b += [3]
>>> b
[2]
>>> [2] + [3]
[2, 3]
>>> class Dave: pass
>>> d = Dave()
>>> d
<__main__.Dave instance at 0x6df2d063e08a98e8>
>>> d.a = 1
>>> d.a
Traceback (most recent call last):
  File "/base/data/home/apps/shell/1.335852500710379686/shell.py", line 267, in get
    exec compiled in statement_module.__dict__
  File "<string>", line 1, in <module>
AttributeError: Dave instance has no attribute 'a'

, : 29: Shell - . , .

+1

All Articles