Re: Importing modules with arguments

2021-07-30 Thread Chris Angelico
On Sat, Jul 31, 2021 at 5:11 AM Charles Smith wrote: > > First off, thanks for the answer. I don't see the cached module as a problem > here. If you provide arguments to a module, the goal is "most likely" to > alter/parameterize the behavior of the first import. Now, I agree that > behavior be

Re: Importing modules with arguments

2021-07-30 Thread Charles Smith
First off, thanks for the answer. I don't see the cached module as a problem here. If you provide arguments to a module, the goal is "most likely" to alter/parameterize the behavior of the first import. Now, I agree that behavior becomes unpredictable because passing different parameters on subs

Re: Importing modules with arguments

2021-07-30 Thread Chris Angelico
On Sat, Jul 31, 2021 at 3:48 AM Charles Smith wrote: > > I have found myself wanting to import module and provide arguments to them. > There's two main reason I could think of for this. First is to prevent a > circular import, though most of circular imports can be prevented by changing > the d

Importing modules with arguments

2021-07-30 Thread Charles Smith
I have found myself wanting to import module and provide arguments to them. There's two main reason I could think of for this. First is to prevent a circular import, though most of circular imports can be prevented by changing the design. The second reason is to invert dependencies between two m

Re: Style question: Importing modules from packages - 'from' vs 'as'

2014-12-04 Thread Chris Angelico
On Fri, Dec 5, 2014 at 9:10 AM, Wolfgang Maier wrote: > which I read as there has been a stepwise transition between 2.5 and 2.7 so > that 2.7 now behaves like Python 3 even without the __future__ statement. > OTOH, I believe you, of course, if you're saying implicit relative imports > are working

Re: Style question: Importing modules from packages - 'from' vs 'as'

2014-12-04 Thread Wolfgang Maier
On 04.12.2014 22:30, Chris Angelico wrote: On Fri, Dec 5, 2014 at 7:56 AM, Wolfgang Maier wrote: On 04.12.2014 19:05, Chris Angelico wrote: With os.path it definitely is. With the actual code in question, it's a Python 2.7 project that mostly uses relative imports - inside package.module1 is

Re: Style question: Importing modules from packages - 'from' vs 'as'

2014-12-04 Thread Chris Angelico
On Fri, Dec 5, 2014 at 7:56 AM, Wolfgang Maier wrote: > On 04.12.2014 19:05, Chris Angelico wrote: >> >> >> With os.path it definitely is. With the actual code in question, it's >> a Python 2.7 project that mostly uses relative imports - inside >> package.module1 is "import module2" etc - and I wa

Re: Style question: Importing modules from packages - 'from' vs 'as'

2014-12-04 Thread Wolfgang Maier
On 04.12.2014 19:05, Chris Angelico wrote: With os.path it definitely is. With the actual code in question, it's a Python 2.7 project that mostly uses relative imports - inside package.module1 is "import module2" etc - and I was writing an external script that calls on one of the modules. What

Re: Style question: Importing modules from packages - 'from' vs 'as'

2014-12-04 Thread Chris Angelico
On Fri, Dec 5, 2014 at 4:36 AM, Jean-Michel Pichavant wrote: > I know you specifically stated you didn't want to do this but > > import os > > os.path.isfile() > > is the best option imo, especially from the reader point of view ("Namespaces > are one honking great idea"). With os.path it defini

Re: Style question: Importing modules from packages - 'from' vs 'as'

2014-12-04 Thread Ethan Furman
On 12/03/2014 03:02 AM, Chris Angelico wrote: > > Throughout the code, I want to refer to "path.split()", > "path.isfile()", etc, without the "os." in front of them. I could do > either of these: > > import os.path as path > from os import path > > Which one would you recommend? Does it depend o

Re: Style question: Importing modules from packages - 'from' vs 'as'

2014-12-04 Thread Ethan Furman
On 12/04/2014 09:36 AM, Jean-Michel Pichavant wrote: > > I know you specifically stated you didn't want to do this but > > import os > > os.path.isfile() > > is the best option imo, especially from the reader point of view ("Namespaces > are one honking great idea"). But, "Flat is better

Re: Style question: Importing modules from packages - 'from' vs 'as'

2014-12-04 Thread Jean-Michel Pichavant
- Original Message - > From: "Chris Angelico" > To: python-list@python.org > Sent: Wednesday, 3 December, 2014 12:02:17 PM > Subject: Style question: Importing modules from packages - 'from' vs 'as' > > When importing a module from a subpac

Re: Style question: Importing modules from packages - 'from' vs 'as'

2014-12-04 Thread Wolfgang Maier
On 12/03/2014 12:02 PM, Chris Angelico wrote: When importing a module from a subpackage, it's sometimes convenient to refer to it throughout the code with a one-part name rather than two. I'm going to use 'os.path' for the examples, but my actual use-case is a custom package where the package nam

Re: Style question: Importing modules from packages - 'from' vs 'as'

2014-12-03 Thread Terry Reedy
On 12/3/2014 6:02 AM, Chris Angelico wrote: When importing a module from a subpackage, it's sometimes convenient to refer to it throughout the code with a one-part name rather than two. I'm going to use 'os.path' for the examples, but my actual use-case is a custom package where the package name

Re: Style question: Importing modules from packages - 'from' vs 'as'

2014-12-03 Thread Ian Kelly
#x27;s > raining as I type this...), and I won't be renaming in this, so the > from-import wins - but as Tim says, it's a close race. To offer a counterpoint, the from import is also less explicit. With "import os.path as path", path must be a module. With the from imp

Re: Style question: Importing modules from packages - 'from' vs 'as'

2014-12-03 Thread Chris Angelico
On Wed, Dec 3, 2014 at 10:27 PM, Peter Otten <__pete...@web.de> wrote: > Don't repeat yourself, so > > from os import path > > always. On the other hand I have never thought about actual renames, e. g. > > from os import path as stdpath > > versus > > import os.path as stdpath > > I think I'd use t

Re: Style question: Importing modules from packages - 'from' vs 'as'

2014-12-03 Thread Peter Otten
Chris Angelico wrote: > When importing a module from a subpackage, it's sometimes convenient > to refer to it throughout the code with a one-part name rather than > two. I'm going to use 'os.path' for the examples, but my actual > use-case is a custom package where the package name is, in the > ap

Re: Style question: Importing modules from packages - 'from' vs 'as'

2014-12-03 Thread Tim Delaney
On 3 December 2014 at 22:02, Chris Angelico wrote: > > import os.path as path > from os import path > Bah - deleted the list and sent directly to Chris ... time to go to bed. The advantage of the former is that if you want to use a different name, it's a smaller change. But the disadvantage of

Style question: Importing modules from packages - 'from' vs 'as'

2014-12-03 Thread Chris Angelico
When importing a module from a subpackage, it's sometimes convenient to refer to it throughout the code with a one-part name rather than two. I'm going to use 'os.path' for the examples, but my actual use-case is a custom package where the package name is, in the application, quite superfluous. Th

importing modules

2013-07-31 Thread syed khalid
I am attempting to import modules from Shogun to python from a non-standard python directory ie from my /home/xxx directory. is there a way on ubuntu to selectively some modules, scripts, data from one directory and others modules, scripts from another directory. In other words, is there a file(s)

Re: importing modules

2013-07-30 Thread Dave Angel
On 07/29/2013 05:57 PM, syed khalid wrote: I am attempting to import modules from Shogun to python from a non-standard python directory ie from my /home/xxx directory. is there a way on ubuntu to selectively some modules, scripts, data from one directory and others modules, scripts from another

Re: Importing modules into IronPython

2013-07-03 Thread Benjamin Kaplan
On Wed, Jul 3, 2013 at 3:05 PM, HighBeliever wrote: > Hi, I have to shift a Python 2.7 program to run in Windows. Doing that has > forced me to use IronPython because my program is dependent on a .dll file > that uses .NET framework. > > I moved all my code to Iron Python and modified it to work

Importing modules into IronPython

2013-07-03 Thread HighBeliever
Hi, I have to shift a Python 2.7 program to run in Windows. Doing that has forced me to use IronPython because my program is dependent on a .dll file that uses .NET framework. I moved all my code to Iron Python and modified it to work with the dll. But I cant import PyQt4 module into the proje

Re: error importing modules

2013-04-22 Thread MRAB
On 22/04/2013 15:54, Rodrick Brown wrote: I'm using the fabric api (fabfile.org ) I’m executing my fab script like the following: $ fab -H server set_nic_buffers -f set_nic_buffers.py Traceback (most recent call last): File "/usr/lib/python2.7/site-packages/fabric/main

error importing modules

2013-04-22 Thread Rodrick Brown
I'm using the fabric api (fabfile.org) I’m executing my fab script like the following: $ fab -H server set_nic_buffers -f set_nic_buffers.py Traceback (most recent call last): File "/usr/lib/python2.7/site-packages/fabric/main.py", line 739, in main *args, **kwargs File "/usr/lib/python

Re: order of importing modules

2011-01-12 Thread Ben Finney
(Please don't top-post replies. Instead, reply in-line with the quoted material, removing irrelevant material. An example is this message.) Catherine Moroney writes: > I've looked at my sys.path variable and I see that it has a whole > bunch of site-package directories, followed by the contents

Re: order of importing modules

2011-01-12 Thread Dan Stromberg
I don't know where the site-packages directories are coming from - maybe a site.py or sitecustomize.py? Sometimes you can strace with a very large -s to see where something like this is coming from. -o is your friend for saving the output to a file in, EG, /tmp. What I usually do is to put speci

Re: order of importing modules

2011-01-12 Thread Chris Rebert
> Dan Stromberg wrote: >> On Tue, Jan 11, 2011 at 4:30 PM, Catherine Moroney >> wrote: >>> >>> In what order does python import modules on a Linux system?  I have a >>> package that is both installed in /usr/lib64/python2.5/site-packages, >>> and a newer version of the same module in a working dir

Re: order of importing modules

2011-01-12 Thread Catherine Moroney
I've looked at my sys.path variable and I see that it has a whole bunch of site-package directories, followed by the contents of my $PYTHONPATH variable, followed by a list of misc site-package variables (see below). I've verified that if I manually reverse the order of sys.path I can then import

Re: order of importing modules

2011-01-12 Thread Catherine Moroney
I've looked at my sys.path variable and I see that it has a whole bunch of site-package directories, followed by the contents of my $PYTHONPATH variable, followed by a list of misc site-package variables (see below). I've verified that if I manually reverse the order of sys.path I can then import

Re: order of importing modules

2011-01-11 Thread Ben Finney
talled in > /usr/lib64/python2.5/site-packages, and a newer version of the same > module in a working directory. Ah, you're asking about the search path for importing modules. You would do well to work through the entire Python tutorial http://docs.python.org/tutorial/> to cover

Re: order of importing modules

2011-01-11 Thread Dan Stromberg
On Tue, Jan 11, 2011 at 4:30 PM, Catherine Moroney wrote: > In what order does python import modules on a Linux system?  I have a > package that is both installed in /usr/lib64/python2.5/site-packages, > and a newer version of the same module in a working directory. > > I want to import the versio

order of importing modules

2011-01-11 Thread Catherine Moroney
In what order does python import modules on a Linux system? I have a package that is both installed in /usr/lib64/python2.5/site-packages, and a newer version of the same module in a working directory. I want to import the version from the working directory, but when I print module.__file__ in

Asking for help with code? Post a minimal working example. (was: importing modules dynamicly)

2011-01-11 Thread Ben Finney
Jean-Michel Pichavant writes: > Your code is rather strange, 'modules' looks to be a list or some > iterable, and then you expect to have a 'modulename' attribute or > something... > My guess is that you pasted an approximative translation of your code > which makes it impossible de debug. To t

Re: importing modules dynamicly

2011-01-11 Thread Jean-Michel Pichavant
dubux wrote: I am trying to import modules dynamicly from a directory (modules/) in which i have __init__.py with the __all__ variable set. Everything imports correctly and I have verified this however I am stuck on actually using my classes in the dynamicly imported modules. this bit is in my m

Re: importing modules dynamicly

2011-01-10 Thread Steven D'Aprano
On Mon, 10 Jan 2011 20:42:17 -0800, dubux wrote: > After loading all the modules, i try to do something like: > > instance = modules.modulename.class() No you don't. class is a reserved word in Python, you would get a SyntaxError if you did that. Please post the error you get, including the co

importing modules dynamicly

2011-01-10 Thread dubux
I am trying to import modules dynamicly from a directory (modules/) in which i have __init__.py with the __all__ variable set. Everything imports correctly and I have verified this however I am stuck on actually using my classes in the dynamicly imported modules. this bit is in my main.py (or base

Re: Importing modules from miscellaneous folders

2011-01-05 Thread Benjamin Kaplan
On Wed, Jan 5, 2011 at 8:08 PM, Jshgwave wrote: > > On a Windows PC, I would like to be able to store modules in > topic-specific foldersinstead of in Python26/Lib/site-packages, > and then import into an IPython session those modules and the > functions in them. > > To test this, I have made a to

Importing modules from miscellaneous folders

2011-01-05 Thread Jshgwave
On a Windows PC, I would like to be able to store modules in topic-specific foldersinstead of in Python26/Lib/site-packages, and then import into an IPython session those modules and the functions in them. To test this, I have made a toy module: --- """  toy_module.py    This is for testing

Re: Newbie question about importing modules.

2010-12-22 Thread cronoklee
On Wed, Dec 22, 2010 at 7:57 PM, Tim Roberts wrote: cronoklee wrote: > > Thanks Tim - You've certainly shed some light. I presume the PIL > installer is setup.py and installation is simple a case of running it? Yes: python setup.py install That scheme is called "distutils". Since it became p

Re: Newbie question about importing modules.

2010-12-18 Thread Tim Roberts
cronoklee wrote: > >Hey thanks for the help fellas. The links were helpful and the pyExe >program looks great. I might well end up using this. > >I'm still a little confused as to how the directory structure works. PIL >(http://www.pythonware.com/products/pil/#pil117), for example comes packed >in

Re: Newbie question about importing modules.

2010-12-17 Thread cronoklee
Hey thanks for the help fellas. The links were helpful and the pyExe program looks great. I might well end up using this. I'm still a little confused as to how the directory structure works. PIL (http://www.pythonware.com/products/pil/#pil117), for example comes packed in a folder called Imagin

Re: Newbie question about importing modules.

2010-12-17 Thread shearichard
On Dec 17, 4:42 pm, cronoklee wrote: > Hi > I'm starting my first python project but I'm having trouble getting > off the ground. > I've read all I can find about relative and absolute import paths but > it's just not making sense to me... There seems to be around ten > different ways to import a

Re: Newbie question about importing modules.

2010-12-17 Thread Tim Roberts
cronoklee wrote: > >I'm starting my first python project but I'm having trouble getting >off the ground. >I've read all I can find about relative and absolute import paths but >it's just not making sense to me... There seems to be around ten >different ways to import a script. That's not really t

Re: Newbie question about importing modules.

2010-12-16 Thread Jony Zhu
Hi, cronoklee maybe you should check every module directory you want to import to see if there is a __init__.py in it? missing a __init__.py file would cause error when you try to import the directory as a module. 在 Fri, 17 Dec 2010 11:42:48 +0800,cronoklee 写道: Hi I'm starting my first p

Newbie question about importing modules.

2010-12-16 Thread cronoklee
Hi I'm starting my first python project but I'm having trouble getting off the ground. I've read all I can find about relative and absolute import paths but it's just not making sense to me... There seems to be around ten different ways to import a script. I need my project to be portable so I can

Re: importing modules from higher level directory

2010-06-26 Thread D'Arcy J.M. Cain
On Sat, 26 Jun 2010 11:10:06 +0200 Thomas Jollans wrote: > Also, please refrain from top posting. If you are going to berate people for bad netiquette you should learn it too. Please trim your included text. You included the entire rest of the OP's message including his signature after your res

Re: importing modules from higher level directory

2010-06-26 Thread Thomas Jollans
On 06/26/2010 01:35 AM, Tom Pacheco wrote: > from .. import module > or > from ..module import foo > > this is intended for use within packages. And it only works within nested packages. Also, please refrain from top posting. > > see > http://www.python.org/dev/peps/pep-0328/ > > also search

Re: importing modules from higher level directory

2010-06-25 Thread Tom Pacheco
from .. import module or from ..module import foo this is intended for use within packages. see http://www.python.org/dev/peps/pep-0328/ also search for python relative import - tom Nathan Huesken wrote: Hi, Is it somehow possible to import modules from *.py files in a higher level directo

Re: importing modules from higher level directory

2010-06-25 Thread Emile van Sebille
On 6/25/2010 2:20 PM Nathan Huesken said... Hi, Is it somehow possible to import modules from *.py files in a higher level directory? Intuitively I would do import ../module but that does not work. How does it work? IIRC, sys.path controls the search order. You could insert your preferred

Re: importing modules from higher level directory

2010-06-25 Thread Nathan Rice
Add the parent directory to your sys.path... On Fri, Jun 25, 2010 at 5:20 PM, Nathan Huesken wrote: > Hi, > > Is it somehow possible to import modules from *.py files in a higher > level directory? > Intuitively I would do > > import ../module > > but that does not work. > How does it work? > > T

importing modules from higher level directory

2010-06-25 Thread Nathan Huesken
Hi, Is it somehow possible to import modules from *.py files in a higher level directory? Intuitively I would do import ../module but that does not work. How does it work? Thanks! Nathan -- http://mail.python.org/mailman/listinfo/python-list

Re: Importing modules

2010-06-07 Thread Dan Stromberg
On Sun, Jun 6, 2010 at 8:16 PM, Ben Finney > wrote: > Anthony Papillion writes: > > > import os > > > > os.path.append('$HOME/gsutils/boto') > > > > thinking I could then successfully do the import boto statement. > > Nope. > > You'll need to give the literal path. Substitution of environment >

Re: Importing modules

2010-06-07 Thread Anthony Papillion
On Jun 6, 10:16 pm, Ben Finney wrote: > Anthony Papillion writes: > > import os > > > os.path.append('$HOME/gsutils/boto') > > > thinking I could then successfully do the import boto statement. > > Nope. > > You'll need to give the literal path. Substitution of environment > variables isn't perfo

Re: Importing modules

2010-06-06 Thread Chris Rebert
On Sun, Jun 6, 2010 at 10:25 PM, Anthony Papillion wrote: > On Jun 6, 10:33 pm, Chris Rebert wrote: >> On Sun, Jun 6, 2010 at 8:16 PM, Ben Finney >> wrote: >> > Anthony Papillion writes: >> >> >> import os >> >> >> os.path.append('$HOME/gsutils/boto') >> >> >> thinking I could then successfull

Re: Importing modules

2010-06-06 Thread Anthony Papillion
On Jun 6, 10:33 pm, Chris Rebert wrote: > On Sun, Jun 6, 2010 at 8:16 PM, Ben Finney wrote: > > Anthony Papillion writes: > > >> import os > > >> os.path.append('$HOME/gsutils/boto') > > >> thinking I could then successfully do the import boto statement. > >> Nope. > > > You'll need to give the

Re: Importing modules

2010-06-06 Thread Chris Rebert
On Sun, Jun 6, 2010 at 8:16 PM, Ben Finney wrote: > Anthony Papillion writes: > >> import os >> >> os.path.append('$HOME/gsutils/boto') >> >> thinking I could then successfully do the import boto statement. >> Nope. > > You'll need to give the literal path. Substitution of environment > variables

Re: Importing modules

2010-06-06 Thread Ben Finney
Anthony Papillion writes: > import os > > os.path.append('$HOME/gsutils/boto') > > thinking I could then successfully do the import boto statement. > Nope. You'll need to give the literal path. Substitution of environment variables isn't performed implicitly in strings. -- \ “When we

Importing modules

2010-06-06 Thread Anthony Papillion
Hello Everyone, I'm brand new to Python and have been finding it really easy to get into. But I've run into my very first problem that I'm hoping someone here might be able to help me with. I'm working with the Google Storage API and all of their Python library is under a directory called $HOME/g

Re: importing modules

2010-05-07 Thread Jean-Michel Pichavant
Richard Lamboj wrote: Am Friday 07 May 2010 13:50:15 schrieb Jean-Michel Pichavant: Richard Lamboj wrote: Hello, I have a question about importing python modules. I have modul package, with submodules. So how can a submodul access a modul that is on level upper? Is there something l

Re: importing modules

2010-05-07 Thread Richard Lamboj
Am Friday 07 May 2010 13:50:15 schrieb Jean-Michel Pichavant: > Richard Lamboj wrote: > > Hello, > > > > I have a question about importing python modules. > > > > I have modul package, with submodules. So how can a submodul access a > > modul that is on level upper? > > > > Is there something lik

Re: importing modules

2010-05-07 Thread Jean-Michel Pichavant
Richard Lamboj wrote: Hello, I have a question about importing python modules. I have modul package, with submodules. So how can a submodul access a modul that is on level upper? Is there something like "import ../../blah"? I don't mean something like this: "import bla.blub.moep" Kind Re

Re: importing modules

2010-05-07 Thread Andi Albrecht
Richard Lamboj schrieb: > > Hello, > > I have a question about importing python modules. > > I have modul package, with submodules. So how can a submodul access a modul > that is on level upper? > > Is there something like "import ../../blah"? I don't mean something like > this: "import bla.blu

Re: importing modules

2010-05-07 Thread Alex Hall
I have a main folder. Inside that I have a "modes" package (subfolder holding __init__.py) as well as a "misc" package. When modes has to import helpers.py from misc, I use this: from .misc import helpers The period makes Python look up one level for misc, then go into it to find helpers. On 5/7/1

importing modules

2010-05-07 Thread Richard Lamboj
Hello, I have a question about importing python modules. I have modul package, with submodules. So how can a submodul access a modul that is on level upper? Is there something like "import ../../blah"? I don't mean something like this: "import bla.blub.moep" Kind Regards, Richi -- http://

Re: Importing modules

2010-03-19 Thread Dave Angel
Peyman Askari wrote: I want to write a function which imports modules the first time, and reloads them afterwards, but I am running into problems with global variables and exec. I will include a full script, but let me elaborate first. Essentially what you need is def import_or_reload(): "

Importing modules

2010-03-19 Thread Peyman Askari
I want to write a function which imports modules the first time, and reloads them afterwards, but I am running into problems with global variables and exec. I will include a full script, but let me elaborate first. Essentially what you need is def import_or_reload():  """assume we want to load

Re: importing modules from subdirs

2010-03-11 Thread Alex Hall
Halfway there. It imports now, but it says that the module does not have functions which I know it does have. I will just leave it all in one folder for now and play with organization after I get the project working better. On 3/11/10, Steve Holden wrote: > Alex Hall wrote: >> Hi all, >> The manu

Re: importing modules from subdirs

2010-03-11 Thread Steve Holden
Alex Hall wrote: > Hi all, > The manual says, for modules in a project stored in subdirectories, you can > do: > import folderName.module > > I have a couple questions, though: > 1. Do I then have to call functions from module like > folder.module.function, or can I still use the normal module.fu

Re: importing modules from subdirs

2010-03-11 Thread Gary Herron
Alex Hall wrote: Hi all, The manual says, for modules in a project stored in subdirectories, you can do: import folderName.module I have a couple questions, though: 1. Do I then have to call functions from module like folder.module.function, or can I still use the normal module.function? Ei

importing modules from subdirs

2010-03-11 Thread Alex Hall
Hi all, The manual says, for modules in a project stored in subdirectories, you can do: import folderName.module I have a couple questions, though: 1. Do I then have to call functions from module like folder.module.function, or can I still use the normal module.function? 2. When I try to do this,

Re: Importing Modules

2010-03-10 Thread Gabriel Genellina
En Wed, 10 Mar 2010 09:19:29 -0300, PEYMAN ASKARI escribió: I wanted to know if imported classes are treated differently than internal classes. If by 'internal classes' you mean 'classes defined in the main module', no, they're absolutely the same. class A(): __init__(self): pass and c

Re: Importing Modules

2010-03-10 Thread Terry Reedy
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. E

Importing Modules

2010-03-10 Thread PEYMAN ASKARI
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(

Re: Importing modules

2009-05-01 Thread Terry Reedy
norseman wrote: OH - something you mentioned that didn't seem to be addressed. import - load a complete library from - obtain specific 'function'(s) from a library from can also be used to get a specific module from a package If you 'import pack.mod', then you have to write 'pack.mod.ob' to

Re: Importing modules

2009-05-01 Thread norseman
Gabriel Genellina wrote: En Thu, 30 Apr 2009 14:33:38 -0300, Jim Carlock escribió: I'm messing around with a program right at the moment. It ends up as two applications, one runs as a server and one as a client which presents a Window. It almost works, so I need to work through it to work out i

Re: Importing modules

2009-04-30 Thread Gabriel Genellina
En Thu, 30 Apr 2009 14:33:38 -0300, Jim Carlock escribió: I'm messing around with a program right at the moment. It ends up as two applications, one runs as a server and one as a client which presents a Window. It almost works, so I need to work through it to work out it's bugs, and I'll be rewr

importing modules from alternate path

2009-03-24 Thread R. David Murray
=?UTF-8?Q?Alexandru__Mo=C8=99oi?= wrote: > I'm trying with no succes to load modules from an alternate path. When > installing to default location (no --home specifed) everything works > as expected. > > $ python setup.py install --home=~ > running install > running build > running build_ext > ru

importing modules from alternate path

2009-03-24 Thread Alexandru Moșoi
I'm trying with no succes to load modules from an alternate path. When installing to default location (no --home specifed) everything works as expected. $ python setup.py install --home=~ running install running build running build_ext running install_lib running install_egg_info Removing /home/vo

Re: Importing modules

2009-01-30 Thread rdmurray
Quoth Mudcat : > [attribution omitted by Mudcat] > > I think you've probably had issues with circular imports (i.e. mutual > > dependencies), unless you can precisely remember what you were doing and > > what went wrong. > > That's possible, but circular imports become more of a hazard if you > hav

Re: Importing modules

2009-01-30 Thread Aahz
In article <631e2879-6171-417e-8254-7f78c8cfc...@i24g2000prf.googlegroups.com>, alex23 wrote: > >If you're having to set up your imports in a specific order, odds are >you have either a circular dependency or are overusing 'from >import *'. You should -never- (IMO) do something like 'from librar

Re: Importing modules

2009-01-21 Thread Mudcat
On Jan 21, 11:29 am, alex23 wrote: > Well, you can always stick those imports into a 'common.py' and do > 'from common import *' in each file that uses them. But doing so can > be a pain to maintain and debug for anything more than the most simple > of applications. Being able to see a module's d

Re: Importing modules

2009-01-21 Thread Mudcat
> I think you've probably had issues with circular imports (i.e. mutual > dependencies), unless you can precisely remember what you were doing and > what went wrong. That's possible, but circular imports become more of a hazard if you have to import in several locations. Unify that to one file, an

Re: Importing modules

2009-01-21 Thread alex23
On Jan 22, 1:45 am, Mudcat wrote: > This is something I've wondered about for a while. I know that > theoretically Python is supposed to auto-recognize duplicate imports; > however I've run into problems in the past if I didn't arrange the > imports in a certain way across multiple files. As a res

Re: Importing modules

2009-01-21 Thread Marco Mariani
Mudcat wrote: This is something I've wondered about for a while. I know that theoretically Python is supposed to auto-recognize duplicate imports; however I've run into problems in the past if I didn't arrange the imports in a certain way across multiple files. I think you've probably had issu

Re: Importing modules

2009-01-21 Thread Mudcat
This is something I've wondered about for a while. I know that theoretically Python is supposed to auto-recognize duplicate imports; however I've run into problems in the past if I didn't arrange the imports in a certain way across multiple files. As a result, I worry about conflicts that arise bec

Re: Importing modules

2009-01-07 Thread Mel
Steve Holden wrote: > e4m...@gmail.com wrote: [ ... ] >> Could someone point me to some docs that explain the Python way of >> loading modules when breaking old, big (everything in one script) into >> more manageable modular scripts? >> > Import each module into every other module that requires i

Re: Importing modules

2009-01-07 Thread Paul McGuire
...and don't worry about a possible performance issue of importing os (or any other module) multiple times - the Python import manager is smart enough to recognize previously imported modules, and wont import them again. If a module uses the os module, then it should import it - that's just it. A

Re: Importing modules

2009-01-07 Thread Steve Holden
e4m...@gmail.com wrote: > Coming from a scripting background where we used to write everything > into one script, I'm now going modular with Python. I place related > functions in one module, and other functions in other modules. > > This all works OK, but I'm a bit

Re: Importing modules

2009-01-07 Thread Diez B. Roggisch
e4m...@gmail.com wrote: > Coming from a scripting background where we used to write everything > into one script, I'm now going modular with Python. I place related > functions in one module, and other functions in other modules. > > This all works OK, but I'm a bit

Importing modules

2009-01-07 Thread e4me4m
Coming from a scripting background where we used to write everything into one script, I'm now going modular with Python. I place related functions in one module, and other functions in other modules. This all works OK, but I'm a bit confused about importing modules from the standard li

Re: Trouble importing modules in IDLE (Win32)

2008-08-25 Thread [EMAIL PROTECTED]
On Aug 22, 10:43 pm, Terry Reedy <[EMAIL PROTECTED]> wrote: > Diez B. Roggisch wrote: > By shell, he means the IDLE shell. But this is the direction to look > first. In the IDLE shell (3.0) those two lines give me the Python > directory, the same as the command line interpreter. When in a file

Re: Trouble importing modules in IDLE (Win32)

2008-08-25 Thread [EMAIL PROTECTED]
On Aug 22, 2:45 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] schrieb: > > > > > Hello, > > > I wrote aprogram that imports odbc and dbi. Originally I used PyWin, > > but now I prefer IDLE for working in Windows. Anyway, when I start my > > program from IDLE, it can't import

Re: Trouble importing modules in IDLE (Win32)

2008-08-22 Thread Terry Reedy
Diez B. Roggisch wrote: [EMAIL PROTECTED] schrieb: Hello, In short: In a freshly (re)started shell, I can use "import odbc" by hand. I can't import odbc from within a script, or by hand after trying to start such a script. Screen capture follows. robert RE

Re: Trouble importing modules in IDLE (Win32)

2008-08-22 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: Hello, I wrote aprogram that imports odbc and dbi. Originally I used PyWin, but now I prefer IDLE for working in Windows. Anyway, when I start my program from IDLE, it can't import the odbc and dbi modules. However, when I restart the shell and type "import odbc" at th

Trouble importing modules in IDLE (Win32)

2008-08-22 Thread [EMAIL PROTECTED]
Hello, I wrote aprogram that imports odbc and dbi. Originally I used PyWin, but now I prefer IDLE for working in Windows. Anyway, when I start my program from IDLE, it can't import the odbc and dbi modules. However, when I restart the shell and type "import odbc" at the prompt by, I don't get an e

Re: Error importing modules with mod_python

2008-07-21 Thread Graham Dumpleton
On Jul 22, 3:30 am, Aaron Scott <[EMAIL PROTECTED]> wrote: > I've installedmod_python, and everything seems to be working, but it > fails when I try to import another file into the file that's actually > producing the output. I have these lines at the top of index.py: > > frommod_pythonimport apach

Re: Error importing modules with mod_python

2008-07-21 Thread Diez B. Roggisch
Aaron Scott wrote: > I've installed mod_python, and everything seems to be working, but it > fails when I try to import another file into the file that's actually > producing the output. I have these lines at the top of index.py: > > from mod_python import apache > from storylab import * > > ...

Error importing modules with mod_python

2008-07-21 Thread Aaron Scott
I've installed mod_python, and everything seems to be working, but it fails when I try to import another file into the file that's actually producing the output. I have these lines at the top of index.py: from mod_python import apache from storylab import * ... and in the directory where index.py

Re: Importing modules in embedded Python

2008-07-02 Thread Marcin Krol
OK I found the answer in yet another Google search, right after I gave up and posted here - turns out in order to import dynamically linked modules, one has to pass -E argument to the linker. Exception exceptions.ImportError: '/usr/lib/python2.4/lib-dynload/timemodule.so: undefined symbol: Py

  1   2   >