Re: [Tutor] How can I add my folder to pythonpath?

2006-06-26 Thread Emily Fortuna
> That is close but not quite right. The correct import will be
> from mymodules import mymodule1
> 
> Kent

My apologies for misleading instructions.
Emily

> 
>>
>>
>> Laszlo Antal wrote:
>>> Hi,
>>>
>>> This is how my directory looks
>>> myprogram(this is the main folder for my program)
>>> |
>>>   myprogram.py
>>>   mymodules  (this is where I store my modules)
>>>   |
>>> mymodule1.py
>>> mymodule2.py
>>>
>>> I would like to import from mymodules folder my modules1.py, 
>>> mymodules2.py into myprogram.py.
>>>
>>> How can I add mymodules folder to pythonpath
>>> from myprogram.py.?
>>> So if I copy myprogram folder into an other pc than   myprogram.py can 
>>> take care of adding mymodules folder to pythonpath.
>>>
>>> Thank you in advance
>>> Laszlo Antal
>>> ___
>>> Tutor maillist  -  Tutor@python.org
>>> http://mail.python.org/mailman/listinfo/tutor
>>>
>>>
>> ___
>> Tutor maillist  -  Tutor@python.org
>> http://mail.python.org/mailman/listinfo/tutor
>>
>>
> 
> 
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
> 
> 

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How can I add my folder to pythonpath?

2006-06-23 Thread Kent Johnson
Emily Fortuna wrote:
> If I understand what you're asking (forgive me if I misunderstood), you 
> need to create a file in the mymodules directory and call it __init__.py 
> (even if you don't put anything in this file).  This tells Python that 
> it is a package containing modules.  Then, in your program myprogram.py, 
> you can say import mymodule1
> mymodule1.function_name('foo')
> Then it shouldn't matter what computer you are on; the script should run.

That is close but not quite right. The correct import will be
from mymodules import mymodule1

Kent

> 
> 
> 
> Laszlo Antal wrote:
>> Hi,
>>
>> This is how my directory looks
>> myprogram(this is the main folder for my program)
>> |
>>   myprogram.py
>>   mymodules  (this is where I store my modules)
>>   |
>> mymodule1.py
>> mymodule2.py
>>
>> I would like to import from mymodules folder my modules1.py, 
>> mymodules2.py into myprogram.py.
>>
>> How can I add mymodules folder to pythonpath
>> from myprogram.py.?
>> So if I copy myprogram folder into an other pc than   myprogram.py can 
>> take care of adding mymodules folder to pythonpath.
>>
>> Thank you in advance
>> Laszlo Antal
>> ___
>> Tutor maillist  -  Tutor@python.org
>> http://mail.python.org/mailman/listinfo/tutor
>>
>>
> 
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
> 
> 


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How can I add my folder to pythonpath?

2006-06-23 Thread Andrew Robert
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

What you need to do is append your existing path.

for example:

import sys
sys.path.append(r'd:\python_modules')

You can then import any modules that reside in that path as if they
where part of the standard library.


Andy
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.2.1 (MingW32)
Comment: GnuPT 2.7.2

iD8DBQFEnF+aDvn/4H0LjDwRAl14AKDEfZc0TKEbfhtF+/4h7o56MnCeSACdG6y8
DwLC/UAbZMBHNCQDS/2A5jY=
=HmM2
-END PGP SIGNATURE-
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How can I add my folder to pythonpath?

2006-06-23 Thread Laszlo Antal
On 06/23/06 at  2:11 PM you wrote:
>  If I understand what you're asking (forgive me if I misunderstood), 
> you need to create a file in the mymodules directory and call it 
> __init__.py (even if you don't put anything in this file).  This tells 
> Python that it is a package containing modules.  Then, in your program 
> myprogram.py, you can say import mymodule1
>  mymodule1.function_name('foo')
>  Then it shouldn't matter what computer you are on; the script should 
> run.
>  HTH,
>  emily
>
>
>
>  Laszlo Antal wrote:
>  >Hi,
>  >This is how my directory looks
>  >myprogram(this is the main folder for my program)
>  >|
>  >  myprogram.py
>  >  mymodules  (this is where I store my modules)
>  >  |
>  >mymodule1.py
>  >mymodule2.py
>  >I would like to import from mymodules folder my modules1.py,
>  >mymodules2.py into myprogram.py.
>  >How can I add mymodules folder to pythonpath
>  >from myprogram.py.?
>  >So if I copy myprogram folder into an other pc than
>  >myprogram.py can take care of adding mymodules folder to
>  >pythonpath.
>  >Thank you in advance
>  >Laszlo Antal
>  >_
I tried your suggestion.
I created a file inside mymodules folder called __init__.py.
when i run myprogram.py i still get the same error.
Traceback (most recent call last):
   File "/home/laszlo/myprogram/myprogram.py", line 7, in ?
 import mymodule1
ImportError: No module named mymodule1#

What am I doing wrong?

>  >Tutor maillist  -  Tutor@python.org
>  >http://mail.python.org/mailman/listinfo/tutor

Laszlo Antal
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How can I add my folder to pythonpath?

2006-06-23 Thread Emily Fortuna
If I understand what you're asking (forgive me if I misunderstood), you 
need to create a file in the mymodules directory and call it __init__.py 
(even if you don't put anything in this file).  This tells Python that 
it is a package containing modules.  Then, in your program myprogram.py, 
you can say import mymodule1
mymodule1.function_name('foo')
Then it shouldn't matter what computer you are on; the script should run.
HTH,
emily



Laszlo Antal wrote:
> Hi,
> 
> This is how my directory looks
> myprogram(this is the main folder for my program)
> |
>   myprogram.py
>   mymodules  (this is where I store my modules)
>   |
> mymodule1.py
> mymodule2.py
> 
> I would like to import from mymodules folder my modules1.py, 
> mymodules2.py into myprogram.py.
> 
> How can I add mymodules folder to pythonpath
> from myprogram.py.?
> So if I copy myprogram folder into an other pc than   myprogram.py can 
> take care of adding mymodules folder to pythonpath.
> 
> Thank you in advance
> Laszlo Antal
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
> 
> 

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor