Confused with module and .py files

Iyer, Prasad C prasad.c.iyer at capgemini.com
Wed Oct 5 07:18:18 EDT 2005


Sorry guys for that .py in import.
It was typing mistake.

Extremely sorry

regards
prasad chandrasekaran




















--- Cancer cures smoking

#-----Original Message-----
#From: Steve Holden [mailto:steve at holdenweb.com]
#Sent: Wednesday, October 05, 2005 2:43 PM
#To: python-list at python.org
#Subject: Re: Confused with module and .py files
#
#Iyer, Prasad C wrote:
#> Actually I am bit confused between the modules and .py file
#> How do I differentiate between the 2.
#>
#> For example
#> I have a file import1.py, import2.py file
#> Which has few functions and classes
#> And if I have a class with same name "BaseClass" in both the file
#>
#> How would I use it if I declare it as given below in my 3rd class
#>
#> from import1.py import *
#> from import2.py import *
#>
#You can't do that. The "from module import *" mechanism explicitly
#defines names in the importing module's namespace, so if you use this
#technique to import two modules that define the same name you will
#inevitably find that the second import overwrites the duplicate name
#imported by the first import.
#
#Note also that the ".py" should not be included in the import statement
#- the interpreter finds the appropriate code from the module name, so
#you should anyway be doing something like
#
#   from import2 import *
#   from import2 import *
#
#It would be much better, though, to write:
#
#   import import1
#   import import2
#
#Then you can refer to import1.BaseClass and import2.baseClass without
#getting any naming conflicts. In general the "from module import *"
form
#should only be used under specific conditions, which we needn't discuss
#here now.
#
#regards
#  Steve
#--
#Steve Holden       +44 150 684 7255  +1 800 494 3119
#Holden Web LLC                     www.holdenweb.com
#PyCon TX 2006                  www.python.org/pycon/
#


This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient,  you are not authorized to read, print, retain, copy, disseminate,  distribute, or use this message or any part thereof. If you receive this  message in error, please notify the sender immediately and delete all  copies of this message.




More information about the Python-list mailing list