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: Whitespace ignored in relative imports: from.package import something is valid syntax
Type: behavior Stage: resolved
Components: Versions: Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: eric.smith, maligree
Priority: normal Keywords:

Created on 2014-01-13 11:33 by maligree, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (2)
msg208022 - (view) Author: Jacek Szpot (maligree) Date: 2014-01-13 11:33
Just wanted to let you know that missing whitespace between "from" and a dot-prefixed name is not considered invalid:

from.foo import bar 

.. does not raise an error. Perhaps it should?
msg208025 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2014-01-13 13:34
This is no different from other places in python where white space is optional. As long as the parser can tell the end of a token, there need not be white space before the next token.

For example:
>>> 1+2
3
>>> 1 + 2
3

However, if the parser cannot tell the end of a token, white space is required:
>>> 1.__add__
  File "<stdin>", line 1
    1.__add__
            ^
SyntaxError: invalid syntax
>>> 1 .__add__
<method-wrapper '__add__' of int object at 0x1300c68>

We're not likely to add "required white space" after the "from" token.

[I realize that in a "whitespace required" language, this is a slightly odd statement!]
History
Date User Action Args
2022-04-11 14:57:56adminsetgithub: 64439
2014-01-13 13:34:24eric.smithsetstatus: open -> closed

nosy: + eric.smith
messages: + msg208025

resolution: not a bug
stage: resolved
2014-01-13 11:33:32maligreecreate