Importing Modules

PEYMAN ASKARI paskari007 at yahoo.ca
Wed Mar 10 07:19:29 EST 2010


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.

I have included the test_import.py file as well as 4 module files which it loads. Save the tes_import.py file to a folder, create another folder there, and save ONLY the 4 modules files to that new folder. In the code, update line 26 to reflect to path of the newly created directory

Thanks in advanced


Peyman

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100310/c92908b5/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_import.py
Type: text/x-python
Size: 2218 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20100310/c92908b5/attachment.py>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: module_1.py
Type: text/x-python
Size: 67 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20100310/c92908b5/attachment-0001.py>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: module_2.py
Type: text/x-python
Size: 67 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20100310/c92908b5/attachment-0002.py>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: module_3.py
Type: text/x-python
Size: 67 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20100310/c92908b5/attachment-0003.py>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: module_4.py
Type: text/x-python
Size: 67 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20100310/c92908b5/attachment-0004.py>


More information about the Python-list mailing list