Re: import question

2021-11-19 Thread dn via Python-list
On 20/11/2021 03.38, lucas wrote: > ok. all good advice. thank you for that. and with all that I've decided > what to do. > > I'm going to close off any server-side python access so that I don't expose > my server or the file system to vulnerabilities and/or wonton attacks. I am > building

Re: import question

2021-11-19 Thread lucas
ok. all good advice. thank you for that. and with all that I've decided what to do. I'm going to close off any server-side python access so that I don't expose my server or the file system to vulnerabilities and/or wonton attacks. I am building a site for education and what I will

Re: import question

2021-11-19 Thread Mats Wichmann
On 11/18/21 21:00, Dan Stromberg wrote: On Thu, Nov 18, 2021 at 6:19 PM Chris Angelico wrote: On Fri, Nov 19, 2021 at 11:24 AM Dan Stromberg wrote: On Thu, Nov 18, 2021 at 12:21 PM Chris Angelico wrote: If you're trying to make a Python-in-Python sandbox, I recommend not. Instead, use

Re: import question

2021-11-18 Thread Chris Angelico
On Fri, Nov 19, 2021 at 3:00 PM Dan Stromberg wrote: > > > On Thu, Nov 18, 2021 at 6:19 PM Chris Angelico wrote: >> >> On Fri, Nov 19, 2021 at 11:24 AM Dan Stromberg wrote: >> > >> > >> > On Thu, Nov 18, 2021 at 12:21 PM Chris Angelico wrote: >> >> >> >> If you're trying to make a

Re: import question

2021-11-18 Thread Dan Stromberg
On Thu, Nov 18, 2021 at 6:19 PM Chris Angelico wrote: > On Fri, Nov 19, 2021 at 11:24 AM Dan Stromberg > wrote: > > > > > > On Thu, Nov 18, 2021 at 12:21 PM Chris Angelico > wrote: > >> > >> If you're trying to make a Python-in-Python sandbox, I recommend not. > >> Instead, use an OS-level

Re: import question

2021-11-18 Thread Chris Angelico
On Fri, Nov 19, 2021 at 11:24 AM Dan Stromberg wrote: > > > On Thu, Nov 18, 2021 at 12:21 PM Chris Angelico wrote: >> >> If you're trying to make a Python-in-Python sandbox, I recommend not. >> Instead, use an OS-level sandbox (a chroot, probably some sort of CPU >> usage limiting, etc), and use

Re: import question

2021-11-18 Thread Grant Edwards
On 2021-11-17, lucas wrote: > are there any other ways to import a module or package other then > the "import" or "from...import..." statements? i ask because i'm > allowing programming on my web2py website and i don't want any > accessing packages like os or sys. Safely allowing people to

Re: import question

2021-11-18 Thread Dan Stromberg
On Thu, Nov 18, 2021 at 12:21 PM Chris Angelico wrote: > If you're trying to make a Python-in-Python sandbox, I recommend not. > Instead, use an OS-level sandbox (a chroot, probably some sort of CPU > usage limiting, etc), and use that to guard the entire Python process. > Python-in-Python will

Re: import question

2021-11-18 Thread Chris Angelico
On Fri, Nov 19, 2021 at 7:09 AM lucas wrote: > > hello one and all, > > are there any other ways to import a module or package other then the > "import" or "from...import..." statements? i ask because i'm allowing > programming on my web2py website and i don't want any accessing packages like

import question

2021-11-18 Thread lucas
hello one and all, are there any other ways to import a module or package other then the "import" or "from...import..." statements? i ask because i'm allowing programming on my web2py website and i don't want any accessing packages like os or sys. thank you in advance and have a great day,

Re: Module import question

2020-08-09 Thread Bob Gailer
On Aug 9, 2020 11:41 AM, "Mats Wichmann" wrote: > > On 8/9/20 12:51 AM, Gabor Urban wrote: > > Hi guys, > > > > I have a quite simple question but I could not find the correct answer. > > > > I have twoo modules A and B. A imports B. If I import A in a script, Will > > be B imported

Re: Module import question

2020-08-09 Thread Gabor Urban
Hi guys, Thanks for the answers. IT is clear Noé. Gábor -- https://mail.python.org/mailman/listinfo/python-list

Re: Module import question

2020-08-09 Thread Mats Wichmann
On 8/9/20 12:51 AM, Gabor Urban wrote: > Hi guys, > > I have a quite simple question but I could not find the correct answer. > > I have twoo modules A and B. A imports B. If I import A in a script, Will > be B imported automatically? I guess not, but fő not know exactly. > > Thanks for your

Re: Module import question

2020-08-09 Thread 황병희
Gabor Urban writes: > Hi guys, > > I have a quite simple question but I could not find the correct answer. > > I have twoo modules A and B. A imports B. If I import A in a script, Will > be B imported automatically? I guess not, but fő not know exactly. > > Thanks for your answer ín advance,

Module import question

2020-08-09 Thread Gabor Urban
Hi guys, I have a quite simple question but I could not find the correct answer. I have twoo modules A and B. A imports B. If I import A in a script, Will be B imported automatically? I guess not, but fő not know exactly. Thanks for your answer ín advance, Gábor --

Re: trivial import question

2014-02-06 Thread John Ladasky
On Wednesday, February 5, 2014 9:52:33 AM UTC-8, nevets...@gmail.com wrote: The underscore relative to a prfixed abbb. Is to be noted Reviving a fourteen year-old thread? That has to be some kind of record. -- https://mail.python.org/mailman/listinfo/python-list

trivial import question

2014-02-05 Thread nevetsreleehw
The underscore relative to a prfixed abbb. Is to be noted -- https://mail.python.org/mailman/listinfo/python-list

Import Question

2013-02-20 Thread eli m
How long does it take for the program to import something? I am asking this because i have like 7 imports at the beginning of my program and i am thinking thats the reason why it is slow to start up. Thanks in advance. -- http://mail.python.org/mailman/listinfo/python-list

Re: Import Question

2013-02-20 Thread Matteo Boscolo
Il 20/02/2013 21:53, eli m ha scritto: How long does it take for the program to import something? I am asking this because i have like 7 imports at the beginning of my program and i am thinking thats the reason why it is slow to start up. Thanks in advance. It depend of your code module

Re: Import Question

2013-02-20 Thread Michael Herman
you can check each import as it varies in loading time: time python -c import [name of module] example: time python -c import flask On Wed, Feb 20, 2013 at 12:53 PM, eli m techgeek...@gmail.com wrote: How long does it take for the program to import something? I am asking this because i have

Re: Import Question

2013-02-20 Thread Dave Angel
On 02/20/2013 03:53 PM, eli m wrote: How long does it take for the program to import something? I am asking this because i have like 7 imports at the beginning of my program and i am thinking thats the reason why it is slow to start up. Thanks in advance. That would be easy to measure. If

Re: Import question

2010-02-08 Thread Andrew Degtiariov
2010/2/6 Gabriel Genellina gagsl-...@yahoo.com.ar En Fri, 05 Feb 2010 13:21:47 -0300, Andrew Degtiariov andrew.degtiar...@gmail.com escribió: Code of our project has split into several packages and we deploy the project using buildout. All worked fine until I need to dynamically inspect

Re: Import question

2010-02-08 Thread Gabriel Genellina
En Mon, 08 Feb 2010 06:37:53 -0300, Andrew Degtiariov andrew.degtiar...@gmail.com escribió: 2010/2/6 Gabriel Genellina gagsl-...@yahoo.com.ar En Fri, 05 Feb 2010 13:21:47 -0300, Andrew Degtiariov andrew.degtiar...@gmail.com escribió: Code of our project has split into several packages and we

Re: Import question

2010-02-08 Thread Andrew Degtiariov
Those are called namespace packages. Zope and Plone (ab)use them extensively. The intended usage is to break up a big, monolithic package [0] in parts that can be distributed independently. To implement a namespace package, you need an empty __init__.py file with only these lines [1]: from

Import question

2010-02-05 Thread Andrew Degtiariov
Code of our project has split into several packages and we deploy the project using buildout. All worked fine until I need to dynamically inspect python modules. Here is structure of our src directory ├───project.api.config │ ├───project │ │ └───api │ │ └───config │ │

Re: Import question

2010-02-05 Thread Gabriel Genellina
En Fri, 05 Feb 2010 13:21:47 -0300, Andrew Degtiariov andrew.degtiar...@gmail.com escribió: Code of our project has split into several packages and we deploy the project using buildout. All worked fine until I need to dynamically inspect python modules. Entirely by luck, I'd say :)

Re: A package import question

2008-06-15 Thread Gabriel Genellina
En Fri, 13 Jun 2008 22:38:24 -0300, Dan Yamins [EMAIL PROTECTED] escribió: Gabriel, thanks. I understood about the fact that import only loads the first time, but didn't realize that del only removes the bound reference to the object, not as I had hoped the thing from the namespace itself.

A package import question

2008-06-13 Thread Dan Yamins
I'm having a problem importing a package in python, deleting some of what's been imported, and then reimporting. (I'm the sure the problem is trivial, but I just don't understand it.) I have a directory of python modules called Operations. It contains a python module called archive.py.

Another (perhaps similar) import question

2008-06-13 Thread Dan Yamins
I also have noticed another (to me) strange thing about module imports. If anyone could explain this to me, that would be great (I apologize if it's too elementary for this list.) Suppose I have a module #file: testmodule.py a = 1 When importing this module, obviously 'a' becomes an

Re: Another (perhaps similar) import question

2008-06-13 Thread Gary Herron
Dan Yamins wrote: I also have noticed another (to me) strange thing about module imports. If anyone could explain this to me, that would be great (I apologize if it's too elementary for this list.) Suppose I have a module #file: testmodule.py a = 1 When importing this module,

Re: A package import question

2008-06-13 Thread Gabriel Genellina
En Fri, 13 Jun 2008 20:01:56 -0300, Dan Yamins [EMAIL PROTECTED] escribió: I'm having a problem importing a package in python, deleting some of what's been imported, and then reimporting. (I'm the sure the problem is trivial, but I just don't understand it.) I have a directory of python

Re: Another (perhaps similar) import question

2008-06-13 Thread Gary Herron
Dan Yamins wrote: What is the principle behind this? And, is there some simple way (other than restarting the interpreter) of reloading that wipes out the old attributes associated with a given name so that spurious attributes do not remain? No.

Re: A package import question

2008-06-13 Thread Dan Yamins
You have removed the archive attribute from the object to which the Operations name is referring to. import Operations.archive Python keeps a reference to all imported modules in sys.modules; if a module was already imported, any subsequent imports of the same module just return the

Re: Another (perhaps similar) import question

2008-06-13 Thread Dan Yamins
Please keep responses to python-list discussion on python-list, not my personal mail box. -- Thanks. Sorry. When I hit reply on gmail to your message, your personal email comes up as opposed to the python list address. My apologies for not looking for closely. I'd suggest using

Simple import question about mac osx

2008-04-29 Thread jmDesktop
Hi, I have this code (learning from Core Python, Chun's book), module named chap2.py. class FooClass(object): version=0.1 def __init__(self, nm='John Doe'): self.name=nm print 'Created a class instance for ', nm def showname(self):

Re: Simple import question about mac osx

2008-04-29 Thread jmDesktop
On Apr 29, 1:16 pm, jmDesktop [EMAIL PROTECTED] wrote: Hi, I have this code (learning from Core Python, Chun's book), module named chap2.py. class FooClass(object):         version=0.1         def __init__(self, nm='John Doe'):                 self.name=nm                 print 'Created a

Re: Simple import question about mac osx

2008-04-29 Thread s0suk3
On Apr 29, 12:46 pm, jmDesktop [EMAIL PROTECTED] wrote: On Apr 29, 1:16 pm, jmDesktop [EMAIL PROTECTED] wrote: Hi, I have this code (learning from Core Python, Chun's book), module named chap2.py. class FooClass(object): version=0.1 def __init__(self, nm='John

Re: Simple import question about mac osx

2008-04-29 Thread jmDesktop
On Apr 29, 1:54 pm, [EMAIL PROTECTED] wrote: On Apr 29, 12:46 pm, jmDesktop [EMAIL PROTECTED] wrote: On Apr 29, 1:16 pm, jmDesktop [EMAIL PROTECTED] wrote: Hi, I have this code (learning from Core Python, Chun's book), module named chap2.py. class FooClass(object):        

Re: Simple import question about mac osx

2008-04-29 Thread Jerry Hill
On Tue, Apr 29, 2008 at 2:14 PM, jmDesktop [EMAIL PROTECTED] wrote: Thanks. That worked on mac. But it does work like I said in Windows. Don't know why. Mr. Chun must also be using Windows because that is the way he does it in his book. It shouldn't work that way on windows either. Can

Re: Simple import question about mac osx

2008-04-29 Thread jmDesktop
On Apr 29, 2:37 pm, Jerry Hill [EMAIL PROTECTED] wrote: On Tue, Apr 29, 2008 at 2:14 PM, jmDesktop [EMAIL PROTECTED] wrote:  Thanks.  That worked on mac.  But it does work like I said in  Windows.  Don't know why.  Mr. Chun must also be using Windows because  that is the way he does it in

Re: Simple import question about mac osx

2008-04-29 Thread s0suk3
On Apr 29, 2:17 pm, jmDesktop [EMAIL PROTECTED] wrote: On Apr 29, 2:37 pm, Jerry Hill [EMAIL PROTECTED] wrote: On Tue, Apr 29, 2008 at 2:14 PM, jmDesktop [EMAIL PROTECTED] wrote: Thanks. That worked on mac. But it does work like I said in Windows. Don't know why. Mr. Chun must

Re: Simple import question about mac osx

2008-04-29 Thread Jerry Hill
On Tue, Apr 29, 2008 at 3:17 PM, jmDesktop [EMAIL PROTECTED] wrote: On Windows I took the text file I created on mac with vi and opened it in PythonWin. I ran it. It compiled. I run the import and call from the python interpreter. You're not doing what you think you're doing. I'm not

Re: Simple import question about mac osx

2008-04-29 Thread ivan
On Apr 29, 3:47 pm, Jerry Hill [EMAIL PROTECTED] wrote: When you run your code in pythonwin, it's just like calling 'python -i chap2.py'  It runs the code in chap2.py, then gives you an interpreter window to interact with your code.  In this case, that means that FooClass is visible with no

Library package import question

2007-11-05 Thread Frank Aune
Hello, I have a python library package 'Foo', which contains alot of submodules: Foo/: __init__.py module1.py: class Bar() class Hmm() module2.py class Bee() class Wax() module3.py etc

Re: Library package import question

2007-11-05 Thread Martin Marcher
2007/11/5, Frank Aune [EMAIL PROTECTED]: To prevent namespace pollution, I want to import and use this library in the following way: import Foo (...) t = Foo.module2.Bee() from x import y as z that has always worked for me to prevent pollution... -- http://noneisyours.marcher.name

Re: Library package import question

2007-11-05 Thread Gabriel Genellina
En Mon, 05 Nov 2007 10:34:26 -0300, Frank Aune [EMAIL PROTECTED] escribió: I have a python library package 'Foo', which contains alot of submodules: Foo/: __init__.py module1.py: class Bar() class Hmm() module2.py class Bee()

package import question

2007-10-22 Thread Phoe6
Hi all, I have the following directory structure: wallpaper/ -main.py -ng/ -- __init__.py -- setdesktop.py -yb/ -- __init__.py -- setdesktop.py From main.py, I would like to do: import

Re: package import question

2007-10-22 Thread Diez B. Roggisch
Phoe6 wrote: Hi all, I have the following directory structure: wallpaper/ -main.py -ng/ -- __init__.py -- setdesktop.py -yb/ -- __init__.py -- setdesktop.py From main.py, I

Re: package import question

2007-10-22 Thread Peter Otten
Phoe6 wrote: Hi all, I have the following directory structure: wallpaper/ -main.py -ng/ -- __init__.py -- setdesktop.py -yb/ -- __init__.py -- setdesktop.py From main.py, I

Re: package import question

2007-10-22 Thread Phoe6
On Oct 22, 1:24 pm, Peter Otten [EMAIL PROTECTED] wrote: Phoe6 wrote: Hi all, I have the following directory structure: wallpaper/ -main.py -ng/ -- __init__.py -- setdesktop.py -yb/ --

Import question

2007-08-22 Thread Lamonte Harris
can I import more then one modules like this: import module,module2 ? -- http://mail.python.org/mailman/listinfo/python-list

Re: Import question

2007-08-22 Thread Wildemar Wildenburger
Lamonte Harris wrote: can I import more then one modules like this: import module,module2 So your'e basically saying that you haven't tried it? /W -- http://mail.python.org/mailman/listinfo/python-list

Re: Import question

2007-08-22 Thread Wildemar Wildenburger
Lamonte Harris wrote: On 8/22/07, *Wildemar Wildenburger* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: So your'e basically saying that you haven't tried it? No I haven't. Thats why I asked? Common sense? Sorry. Excuse my sarcasm. The common way for answering easy questions like

relative import question: packaging scripts

2007-06-23 Thread Alan Isaac
What is the recommended packaging of demo scripts or test scripts for a package that has modules that use relative imports? Example: Suppose I have the package structure: package/ __init__.py subpackage1/ __init__.py moduleY.py subpackage2/ __init__.py

Re: Organizing code - import question

2007-05-04 Thread Carlos Hanson
On 5/3/07, Brian Blais [EMAIL PROTECTED] wrote: Carlos Hanson wrote: It looks like you need __init__.py in MyPackage. Then you can import starting with MyPackage. For example, you might use one of the following: import MyPackage from MyPackage.Common import * etc that

Organizing code - import question

2007-05-03 Thread Brian Blais
Hello, I am trying to organize some of my code, and am having a little trouble with the import logic. I find I often have something like: MyPackage/ Part1/ # wants to use functions in Common/ __init__.py # does from MyClass1 import MyClass1, etc,... MyClass1.py

Re: Organizing code - import question

2007-05-03 Thread Carlos Hanson
On May 3, 8:41 am, Brian Blais [EMAIL PROTECTED] wrote: Hello, I am trying to organize some of my code, and am having a little trouble with the import logic. I find I often have something like: MyPackage/ Part1/ # wants to use functions in Common/ __init__.py # does from

Re: Organizing code - import question

2007-05-03 Thread Brian Blais
Carlos Hanson wrote: It looks like you need __init__.py in MyPackage. Then you can import starting with MyPackage. For example, you might use one of the following: import MyPackage from MyPackage.Common import * etc that means that MyPackage must be in the sys path too? It

Re: Organizing code - import question

2007-05-03 Thread Gabriel Genellina
En Thu, 03 May 2007 12:41:00 -0300, Brian Blais [EMAIL PROTECTED] escribió: I am trying to organize some of my code, and am having a little trouble with the import logic. I find I often have something like: MyPackage/ Part1/ # wants to use functions in Common/ __init__.py #

import question on wx ?

2006-07-27 Thread diffuser78
I have installed wx and everything looks fine. I have written a small app that uses wx. When I run my program from the console like ubuntu $ python PROGRAM_NAME.py it gives error Traceback (most recent call last): File Project.py, line 6, in ? import wx ImportError: No module named wx

Re: import question on wx ?

2006-07-27 Thread John Salerno
[EMAIL PROTECTED] wrote: I have installed wx and everything looks fine. I have written a small app that uses wx. When I run my program from the console like ubuntu $ python PROGRAM_NAME.py it gives error Traceback (most recent call last): File Project.py, line 6, in ? import wx

Re: import question on wx ?

2006-07-27 Thread diffuser78
I think what you say makes perfect sense I am using 2.4.2 python (I typed pthon -V on console to get) How can I find what my SPE editor is using ? John Salerno wrote: [EMAIL PROTECTED] wrote: I have installed wx and everything looks fine. I have written a small app that uses wx.

Re: import question on wx ?

2006-07-27 Thread SPE - Stani's Python Editor
John Salerno wrote: [EMAIL PROTECTED] wrote: I have installed wx and everything looks fine. I have written a small app that uses wx. When I run my program from the console like ubuntu $ python PROGRAM_NAME.py it gives error Traceback (most recent call last): File Project.py,

Re: import question on wx ?

2006-07-27 Thread diffuser78
That right..on my console it shows python 2.4.2 and on SPE it shows 2.4.3. The wxPython is working fine in SPE i.e with Python 2.4.3. How can I make sure that when I type python on console I get the 2.4.3 ? Every help is greatly appreciated. Thanks John Salerno wrote: [EMAIL PROTECTED]

Re: import question on wx ?

2006-07-27 Thread Rob Williscroft
wrote in news:[EMAIL PROTECTED] in comp.lang.python: I think what you say makes perfect sense I am using 2.4.2 python (I typed pthon -V on console to get) How can I find what my SPE editor is using ? Wherever you can run python you can find the version by running the following bit

Re: noob import question

2006-05-20 Thread Carl Banks
PA wrote: On May 19, 2006, at 15:33, Diez B. Roggisch wrote: And it seems as if you have some JAVA-background, putting one class in one file called the same as the class. Don't do that, it's a stupid restriction in JAVA and should be avoided in PYTHON. Restrictive or not, what's so

noob import question

2006-05-19 Thread Brian Blazer
OK, I have a very simple class here: class Student: Defines the student class def __init__(self, lName, fName, mi): self.lName = lName self.fName = fName self.mi = mi Then I have a small script that I am using as a test: from Student import * s1 =

Re: noob import question

2006-05-19 Thread Iain King
Brian Blazer wrote: OK, I have a very simple class here: class Student: Defines the student class def __init__(self, lName, fName, mi): self.lName = lName self.fName = fName self.mi = mi Then I have a small script that I am using as a test: from

Re: noob import question

2006-05-19 Thread Diez B. Roggisch
I have tried to look up what is going on, but I have not found anything. Would it be possible for someone to take a minute and give an explanation? The from module import *|nameslist syntax imports some or all names found in module into the current modules namespace. Thus you can access

Re: noob import question

2006-05-19 Thread Brian Blazer
Thank you for your responses. I had a feeling is had something to do with a namespace issue but I wasn't sure. You are right, I do come from a Java background. If it is poor form to name your class file the same as your class, can I ask what the standard is? Thanks again, Brian On May

Re: noob import question

2006-05-19 Thread Diez B. Roggisch
Brian Blazer wrote: Thank you for your responses. I had a feeling is had something to do with a namespace issue but I wasn't sure. You are right, I do come from a Java background. If it is poor form to name your class file the same as your class, can I ask what the standard is? Consider

Re: noob import question

2006-05-19 Thread PA
On May 19, 2006, at 15:33, Diez B. Roggisch wrote: And it seems as if you have some JAVA-background, putting one class in one file called the same as the class. Don't do that, it's a stupid restriction in JAVA and should be avoided in PYTHON. Restrictive or not, what's so fundamentally

Re: noob import question

2006-05-19 Thread Fredrik Lundh
PA [EMAIL PROTECTED] wrote: Restrictive or not, what's so fundamentally devious in putting a class declaration in a separate file whose name is that of the declared class (class Queue - Queue.py)? nothing. Sounds like a handy way of organizing your code, no? sure, if you prefer to do

Re: noob import question

2006-05-19 Thread bruno at modulix
Brian Blazer wrote: OK, I have a very simple class here: class Student: class Student(object): Defines the student class def __init__(self, lName, fName, mi): self.lName = lName self.fName = fName self.mi = mi Do yourself a favour: use meaningful

Re: [OT] noob import question

2006-05-19 Thread bruno at modulix
Brian Blazer wrote: ot please, dont top-post, and edit out irrelevant material /ot You are right, I do come from a Java background. Then you may want to read this: http://dirtsimple.org/2004/12/python-is-not-java.html HTH -- bruno desthuilliers python -c print '@'.join(['.'.join([w[::-1]

Re: noob import question

2006-05-19 Thread bruno at modulix
PA wrote: On May 19, 2006, at 15:33, Diez B. Roggisch wrote: And it seems as if you have some JAVA-background, putting one class in one file called the same as the class. Don't do that, it's a stupid restriction in JAVA and should be avoided in PYTHON. Restrictive or not, what's so

Re: noob import question

2006-05-19 Thread Ben Finney
[Please don't top-post. Please don't indiscriminately quote the entire message you respond to. URL:http://en.wikipedia.org/wiki/Top_posting] Brian Blazer [EMAIL PROTECTED] writes: Thank you for your responses. I had a feeling is had something to do with a namespace issue but I wasn't sure.

Re: Silly import question (__file__ attribute)

2006-03-10 Thread Steven D'Aprano
On Thu, 09 Mar 2006 17:25:20 -0500, Jack Diederich wrote: It is a built-in module so it doesn't have a .so (dll) or .py file to mention. Wouldn't it make sense for module.__file__ to be set to None rather than completely missing in this case? -- Steven. --

Re: Silly import question (__file__ attribute)

2006-03-09 Thread Jack Diederich
On Thu, Mar 09, 2006 at 02:04:45PM -0800, mh wrote: So on most modules I import, I can access the .__file__ attribute to find the implementation. ie: import time time.__file__ '/data1/virtualpython/lib/python2.3/lib-dynload/timemodule.so' import socket socket.__file__

Re: Silly import question (__file__ attribute)

2006-03-09 Thread Fredrik Lundh
mh wrote: So on most modules I import, I can access the .__file__ attribute to find the implementation. ie: import time time.__file__ '/data1/virtualpython/lib/python2.3/lib-dynload/timemodule.so' import socket socket.__file__ '/data1/virtualpython/lib/python2.3/socket.pyc' This

Tricky import question.

2005-10-25 Thread David Poundall
importedfiles = {} for f in FileList f2 = f.split('.')[0] # strip the .py, .pyc __import__(f2) s2 = f2+'.main()' # main is the top file in each import c = compile(s2, '', 'eval') importedfiles[f2] = eval(c) 'importedfiles' should hold an object reference to the main()

Re: Tricky import question.

2005-10-25 Thread Fredrik Lundh
David Poundall wrote: importedfiles = {} for f in FileList f2 = f.split('.')[0] # strip the .py, .pyc __import__(f2) s2 = f2+'.main()' # main is the top file in each import c = compile(s2, '', 'eval') importedfiles[f2] = eval(c) 'importedfiles' should hold an object

Re: Tricky import question.

2005-10-25 Thread David Poundall
Sadly I get this reply when I try that. AttributeError: 'module' object has no attribute 'main' I am getting the impression that the value returned from the __import__() function is only a string reference NOT an object. I am going to have a go at trying this with the imp' module as that

Re: Tricky import question.

2005-10-25 Thread David Poundall
This worked ... def my_import(name): mod = __import__(name) components = name.split('.') for comp in components[1:]: mod = getattr(mod, comp) return mod for reasons given here... http://www.python.org/doc/2.3.5/lib/built-in-funcs.html --

Re: Tricky import question.

2005-10-25 Thread Bengt Richter
On 25 Oct 2005 06:39:15 -0700, David Poundall [EMAIL PROTECTED] wrote: importedfiles = {} for f in FileList f2 = f.split('.')[0] # strip the .py, .pyc importedfiles[f2] = __import__(f2).main # it sounds like all you want is the above (untested ;-), or # use __import__(f2).main()

Re: Tricky import question.

2005-10-25 Thread Bengt Richter
On 25 Oct 2005 08:51:08 -0700, David Poundall [EMAIL PROTECTED] wrote: This worked ... def my_import(name): mod = __import__(name) components = name.split('.') for comp in components[1:]: mod = getattr(mod, comp) return mod for reasons given here...

Re: Tricky import question.

2005-10-25 Thread David Poundall
All I was trying to do with my feeble code attempt, was to return a reference to the imported module so that I could do... result = instanceref.main() where main was a function within the import. Having glanced at the code in the import section of the help files all morning, when I actually sat

Re: Tricky import question.

2005-10-25 Thread David Poundall
repr() is a new one on me I am afraid, and I have yet to achieve any decent competance with global and local lists. As you probaly noticed earlier, I managed to bungle my way through this time. However, I will log this thread away for when I next get stuck with a bindings. Thank you Bengt :-)

Re: Import question

2005-08-09 Thread Lonnie Princehouse
Circular import issues can usually be resolved by moving import statements into the bodies of functions which aren't executed when the module itself is imported. Simple example: fileA.py -- import fileB as fb foo = 10# we're going to access foo from fileB

Re: Import question

2005-08-09 Thread Paul McNett
ncf wrote: In file A, I have an instance of a class and then I import file B (import fileB as fb). In file B, I need to access file A's class instance. Is there anyway I can do this? (I hope that was descriptive enough :\) Let's see... # -- fileA.py class Test(object): pass myInstance =

Re: Import question

2005-08-09 Thread ncf
Hmm...thanks for the replies. Judging by this, it looks like I might still be in a slight perdiciment with doing it all, but time will tell. I wish there were a way I could reference across multiple modules. Well, thanks for your help. Hopefully I'll be able to work out some *simple* solution for

Re: Import question

2005-08-09 Thread ncf
Crap. Forgot to mention that in some instances, I do want the class definitions to create new instances and such. Sorry :) -- http://mail.python.org/mailman/listinfo/python-list

module/import question

2005-02-28 Thread subopt
I'm trying to import Logilab's constraint module like this: from logilab.constraint import * from within a Python interactive session. The module is not installed correctly on our system, and it won't be, so i adjusted my PYTHONPATH, added an empty __init__.py file, then started up an

Re: Newbie: module structure and import question

2005-01-14 Thread Ziong
Thx Rob. yes i know it's related to search path, but i don't know how to set it in a practical way (beside hard coding). my concern is, if i want to create a custom module/library, i don't know what py file will import it and where the working directory should be. sometime like my example, even i

Newbie: module structure and import question

2005-01-12 Thread Ziong
hi all, i have question on how to design a module structure. for example, i have 3 files. [somewhere]/main.py [somewhere]/myLib/Base/BaseA.py [somewhere]/myLib/ClassA.py main.py === from myLib.ClassA import ClassA a = classA() dir(a) myLib/ClassA.py === from myLib.Base.BaseA