Skip to content
This repository has been archived by the owner on Mar 7, 2021. It is now read-only.

undefined name '__path__' #7

Open
kisielk opened this issue Jan 6, 2011 · 1 comment
Open

undefined name '__path__' #7

kisielk opened this issue Jan 6, 2011 · 1 comment

Comments

@kisielk
Copy link

kisielk commented Jan 6, 2011

__path__ is a built-in attribute of all Python modules in a package so should not be flagged as undefined by pyflakes.

See http://docs.python.org/tutorial/modules.html#packages-in-multiple-directories

For example, create a directory called foo/ with __init__.py:

print __path__

Then run the python interpreter:

Python 2.6.4 (r264:75706, Jan 27 2010, 12:22:48) 
[GCC 4.3.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
 >>> import foo
['foo']
>>> 

I'm not sure if pyflakes can be made intelligent enough to not flag this only when working inside a package module, but it probably should just not flag it at all.

@saper
Copy link
Contributor

saper commented Jan 6, 2013

I cannot reproduce this anymore:

Script started, file is /tmp/m
$ mkdir module
$ echo 'print __path__' >> module/__init__.py
$ cp module/__init__.py module/other.py
$ python
Python 2.7.3 (default, Sep 17 2012, 21:25:11) 
[GCC 4.3.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import module
['module']
>>> from module import other
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "module/other.py", line 1, in <module>
    print __path__
NameError: name '__path__' is not defined
>>> 
$ pyflakes module/__init__.py
$ pyflakes module/other.py
module/other.py:1: undefined name '__path__'
$
Script done, file is /tmp/m

Looks to me that pyflakes behaviour is correct here (tried 06e149a).

resolve as WORKSFORME?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants