This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: syntax error when pasting valid snippet into console without empty string after the function def
Type: Stage: resolved
Components: Versions:
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: eric.araujo, ezio.melotti, georg.brandl, meador.inge, techtonik
Priority: normal Keywords:

Created on 2011-09-19 14:21 by techtonik, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (6)
msg144278 - (view) Author: anatoly techtonik (techtonik) Date: 2011-09-19 14:21
This is self-explanative. Function definitions are identical. Syntax error caused by the absence of empty line after the function definition.

Python 2.7.1 (r271:86832, Apr 12 2011, 16:16:18) 
[GCC 4.6.0 20110331 (Red Hat 4.6.0-2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os

>>> def get_size(start_path = '.'):
...     total_size = 0
...     for dirpath, dirnames, filenames in os.walk(start_path):
...         for f in filenames:
...             fp = os.path.join(dirpath, f)
...             total_size += os.path.getsize(fp)
...     return total_size
... 
>>> print get_size()
1595969238
>>> def get_size(start_path = '.'):
...     total_size = 0
...     for dirpath, dirnames, filenames in os.walk(start_path):
...         for f in filenames:
...             fp = os.path.join(dirpath, f)
...             total_size += os.path.getsize(fp)
...     return total_size
... print get_size()
  File "<stdin>", line 8
    print get_size()
        ^
SyntaxError: invalid syntax
msg144280 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-09-19 14:29
If you point out the reST files with examples that don’t work when copy-pasted, we can fix them.  Changing the behavior of the interpreter itself is probably not possible.
msg144282 - (view) Author: anatoly techtonik (techtonik) Date: 2011-09-19 14:53
If changing behavior of console is not possible now, schedule it for python4.

http://stackoverflow.com/questions/1392413/calculating-a-directory-size-using-python/1392549#1392549
msg144462 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-09-23 16:58
The example is not in our documentation.  I don’t see a bug, closing.
msg144480 - (view) Author: anatoly techtonik (techtonik) Date: 2011-09-23 23:15
I understand your desire to keep the tracker clean, but I'd like that another person closes this issue. Maybe he will have another opinion.
msg144491 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2011-09-24 08:26
Closing as per python-dev discussion.
History
Date User Action Args
2022-04-11 14:57:21adminsetgithub: 57217
2011-09-24 08:26:26georg.brandlsetstatus: languishing -> closed
nosy: + georg.brandl
messages: + msg144491

2011-09-23 23:15:27techtoniksetstatus: closed -> languishing
resolution: not a bug ->
messages: + msg144480
2011-09-23 16:58:58eric.araujosetstatus: open -> closed
resolution: not a bug
messages: + msg144462

stage: resolved
2011-09-20 15:11:39ezio.melottisetnosy: + ezio.melotti

versions: - Python 2.7
2011-09-20 14:08:20meador.ingesetnosy: + meador.inge
2011-09-19 14:53:41techtoniksetmessages: + msg144282
2011-09-19 14:29:23eric.araujosetnosy: + eric.araujo
messages: + msg144280
2011-09-19 14:21:24techtonikcreate