Re: [Tutor] How to use a module when only import package

2011-04-08 Thread Karim
On 04/08/2011 11:13 AM, leechau wrote: Steven wrote: leechau wrote: I wrote module1 in package1, and want to use a method named 'method1' in module1, the caller(test.py) is like this: import package1 package1.module1.method1() [...] When i run test.py, the output is: AttributeError: 'module

Re: [Tutor] How to use a module when only import package

2011-04-08 Thread leechau
Steven wrote: leechau wrote: I wrote module1 in package1, and want to use a method named 'method1' in module1, the caller(test.py) is like this: import package1 package1.module1.method1() [...] When i run test.py, the output is: AttributeError: 'module' object has no attribute 'module1' File

Re: [Tutor] How to use a module when only import package

2011-04-07 Thread Steven D'Aprano
leechau wrote: > I wrote module1 in package1, and want to use a method named 'method1' in > module1, the caller(test.py) is like this: > > import package1 > package1.module1.method1() [...] > When i run test.py, the output is: > AttributeError: 'module' object has no attribute 'module1' > File "e:

[Tutor] How to use a module when only import package

2011-04-07 Thread leechau
I wrote module1 in package1, and want to use a method named 'method1' in module1, the caller(test.py) is like this: import package1 package1.module1.method1() module1.py is like this: def method1(): print 'method1 run!' The filesystem structure is: test.py package1 |__ __init__.py |__ m