python 3.5 raiaing an error when import the class Manager in this module sayning name Manager is not define
Peter Otten
__peter__ at web.de
Wed Jul 12 09:26:28 EDT 2017
WoFy The 95s wrote:
> i tried from idle interpreter
>
> from person import Manager
>
>
>
>>>> from person import Manager
> Traceback (most recent call last):
> File "<pyshell#95>", line 1, in <module>
> from person import Manager
> ImportError: cannot import name 'Manager'
Enter
import person
person.__file__
in idle's shell. There may be another file called person.py which is
imported instead of the one you intended.
> and this also
>>>> import person
>
>>>> tom = Manager('parias lunkamaba', 'mgr', 500000)
>
> then i get this
>
>
> Traceback (most recent call last):
> File "<pyshell#92>", line 1, in <module>
> tom=Manager('Tome Jones', 'mgr', 50000)
> NameError: name 'Manager' is not defined
This is standard behaviour. If after
import person
you want to access a name in the person module you have to use the qualified
name, e. g.
tom = person.Manager('parias lunkamaba', 'mgr', 500000)
More information about the Python-list
mailing list