Importing Modules

Terry Reedy tjreedy at udel.edu
Wed Mar 10 15:32:03 CET 2010


On 3/10/2010 7:19 AM, PEYMAN ASKARI wrote:
> Hello
>
> I frequent the PyGtk mailing list all the time, but this is the first
> time I am posting here =)
>
> I wanted to know if imported classes are treated differently than
> internal classes.
>
> I have attached a minimal example which points out what I mean.
> Essentially, if I create a class:
>
> class A():
> __init__(self):
> pass
>
> and call A, or A() I get something to the effect of <__main__.A instance
> at 0xb7f088ac>
>
> but if I call from module_name import A and then call A or A() I get
> something to the effect of <module_4.module_4 instance at 0xb7f0882c>
>
> I was wondering if this would be a problem.

Only if you code cares about A.__module__ (3.x, not sure of 2.x) and the 
string returned by str or repr, which nearly always, it should not.

tjr




More information about the Python-list mailing list