Re: Importing module from another subdirectory

2019-04-25 Thread Rich Shepard
On Thu, 25 Apr 2019, dieter wrote: The means that "test_act_de.py" has not extended "sys.path" appropriately. Dieter, That's what I thought. When Python starts a script ("gui/test_act_de.py" in your case), it automatically extends "sys.path" with the folder containing the script ("gui" in y

Re: Importing module from another subdirectory

2019-04-24 Thread dieter
Rich Shepard writes: >> bustrac/ >>README.rst >>bustrac.py* >>controller/ >>classes/ > model.py >>scripts/ >>gui/ > test_act_de.py > > test_act_de.py tries to import model.py from the classes package: > from classes import model as m > > Running in bustrac

Re: Importing module from another subdirectory

2019-04-24 Thread Rich Shepard
On Wed, 24 Apr 2019, Rich Shepard wrote: The current project's directory structure is: I changed package names so there are no duplicate names for packages and modules. bustrac/ README.rst bustrac.py* controller/ classes/ model.py scripts/ gui/ test_act

Re: Importing module from another subdirectory

2019-04-24 Thread Rich Shepard
On Wed, 24 Apr 2019, Rich Shepard wrote: If I correctly understand the process, in bustrac.py I'll add import sys.path sys.path.append(controller, model, scripts, views) Never mind. I've installed virtualenv and will work within it. Regards, Rich -- https://mail.python.org/mailman/listinfo/p

Re: Importing module from another subdirectory

2019-04-24 Thread Rich Shepard
On Wed, 24 Apr 2019, dieter wrote: With a "virtualenv", there is usually no need to tweak "sys.path" -- you simply install everything your project needs into the "virtualenv". Dieter, Okay. I just upgraded pip to 19.1 for python3 and virtualenv to version 16.5.0. Now I'll learn how to use it

Re: Importing module from another subdirectory

2019-04-24 Thread Rich Shepard
On Wed, 24 Apr 2019, dieter wrote: "sys.path" tweaks are typically employed with a "central" Python installation, to have it look at non-standard places for module/packages under specific circumstances. Almost all python packages installed here are built using the SlackBuilds.org scripts (I ru

Re: Importing module from another subdirectory

2019-04-23 Thread dieter
Rich Shepard writes: > On Tue, 23 Apr 2019, dieter wrote: > ... > One project is for my own use and I understand now that a virtualenv with > its own sys.path appendices would work. Those are two separate approaches: With a "virtualenv", there is usually no need to tweak "sys.path" -- you simply

Re: Importing module from another subdirectory

2019-04-23 Thread Rich Shepard
On Tue, 23 Apr 2019, dieter wrote: I use "virtualenv" (for "VIRTUAL ENVironmet") to separate projects. Dieter, I know about virtualenv and tried using them. Found conflicting information and didn't know if I really needed them. I'll re-learn how to activate and use them. One project is for m

Re: Importing module from another subdirectory

2019-04-22 Thread dieter
Rich Shepard writes: > On Thu, 18 Apr 2019, dieter wrote: > ... >> 2. extend "sys.path" in your scripts to contain the "bustrac" folder >> (before you try to import infrastructure modules/packages) > > I read the docs for sys and site and have insufficient experience with them > to know how best t

Re: Importing module from another subdirectory

2019-04-22 Thread Rich Shepard
On Thu, 18 Apr 2019, dieter wrote: I see two options for you: 1. put your scripts directly into "bustrac" (rather than a subdirectory) There are too many files; the directory is very cluttered. 2. extend "sys.path" in your scripts to contain the "bustrac" folder (before you try to import in

Re: Importing module from another subdirectory

2019-04-18 Thread Rich Shepard
On Thu, 18 Apr 2019, dieter wrote: Python knows about 2 kinds of "regular" imports: absolute ones and relative ones. "Absolute" imports are guided by "sys.path" -- in the simple case, a sequence of folders containing modules and/or pacakges. Relative imports are guided in a similar way by the cu

Re: Importing module from another subdirectory

2019-04-18 Thread Rich Shepard
On Wed, 17 Apr 2019, Sayth Renshaw wrote: Apologies I don't know the answer but went looking. This guide should answer the question. Didn't know it was so difficult to be honest. https://chrisyeh96.github.io/2017/08/08/definitive-guide-python-imports.html#example-directory-structure Then there

Re: Importing module from another subdirectory

2019-04-17 Thread dieter
Rich Shepard writes: > What is the proper syntax to import the model class in the model/ > subdirectory into a tkinter view module, e.g., activities.py? The syntax, > 'import model as m' fails because it is not in the same subdirectory as the > importing module. > > The program directory tree is:

Re: Importing module from another subdirectory

2019-04-17 Thread Sayth Renshaw
On Thursday, 18 April 2019 06:59:43 UTC+10, Rich Shepard wrote: > What is the proper syntax to import the model class in the model/ > subdirectory into a tkinter view module, e.g., activities.py? The syntax, > 'import model as m' fails because it is not in the same subdirectory as the > importing

Re: importing module versus using function?

2012-01-31 Thread Robert Kern
On 1/31/12 3:08 PM, gujax wrote: Hi, I am confused on this quite bad!! If I have this typed in interactive python: import numpy def dummy(): y=numpy.arange(1,2,0.1) return y and then s = dummy() s array[1. , 1.1, 1.2] it works. But if I have a module called example.p

Re: importing module

2010-09-09 Thread Peter Otten
Holzwarth, Dominique (Berne Branch) wrote: > Hi all > > Lets assume I have the following structure of directories and python > modules: > > Root-dir > |_dir1 > |_ script1.py > |_dir2 > |_ script2.py > |_sudir2 > |_ script3.py > > Is it possible to import script1 into script2 and scri

Re: importing module-performance

2009-02-02 Thread S.Selvam Siva
On Mon, Feb 2, 2009 at 3:11 PM, Chris Rebert wrote: > On Mon, Feb 2, 2009 at 1:29 AM, S.Selvam Siva > wrote: > > Hi all, > > I have a small query, > > Consider there is a task A which i want to perform. > > > > To perform it ,i have two option. > > 1)Writing a small piece of code(approx. 50 line

Re: importing module-performance

2009-02-02 Thread Chris Rebert
On Mon, Feb 2, 2009 at 1:29 AM, S.Selvam Siva wrote: > Hi all, > I have a small query, > Consider there is a task A which i want to perform. > > To perform it ,i have two option. > 1)Writing a small piece of code(approx. 50 lines) as efficient as possible. > 2)import a suitable module to perform t

Re: Importing module with name given as a variable

2008-08-30 Thread Bruno Desthuilliers
Sean Davis a écrit : What is the "best practice" for importing an arbitrary module given that the name is stored in a variable? The context is a simple web application with URL dispatching to a module and function. I know of __import__(), the imp module, and exec. For each of these, is there a

Re: Importing module with name given as a variable

2008-08-30 Thread Wojtek Walczak
On Sat, 30 Aug 2008 11:02:03 -0700 (PDT), Sean Davis wrote: > What is the "best practice" for importing an arbitrary module given > that the name is stored in a variable? The context is a simple web > application with URL dispatching to a module and function. I know of > __import__(), the imp mod

Re: Importing module PIL vs beautifulSoup.

2008-06-18 Thread bsagert
On Jun 18, 10:18 am, Duncan Booth <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > I downloaded BeautifulSoup.py from > >http://www.crummy.com/software/BeautifulSoup/and being a n00bie, I > > just placed it in my Windows c:\python25\lib\ file. When I type > > "import beautifulsoup" from th

Re: Importing module PIL vs beautifulSoup.

2008-06-18 Thread Duncan Booth
[EMAIL PROTECTED] wrote: > I downloaded BeautifulSoup.py from > http://www.crummy.com/software/BeautifulSoup/ and being a n00bie, I > just placed it in my Windows c:\python25\lib\ file. When I type > "import beautifulsoup" from the interactive prompt it works like a > charm. This seemed too easy i

Re: importing module conflict

2008-01-10 Thread Matias Surdi
Ben Finney escribió: > Matias Surdi <[EMAIL PROTECTED]> writes: > >> Suppose I've a module named "urllib" and from it I need to import >> the urllib module from the python standart library. > > What you want is the "absolute import" behaviour, described in PEP 328 > http://www.python.org/peps/pep

Re: importing module conflict

2008-01-10 Thread Ben Finney
Matias Surdi <[EMAIL PROTECTED]> writes: > Suppose I've a module named "urllib" and from it I need to import > the urllib module from the python standart library. What you want is the "absolute import" behaviour, described in PEP 328 http://www.python.org/peps/pep-0328.html> and implemented in Py

Re: importing module conflict

2008-01-10 Thread Bruno Desthuilliers
Matias Surdi a écrit : > Hi, > > Suppose I've a module named "urllib" and from it I need to import the > urllib module from the python standart library. > > ¿how can I do this? > > The problem I found is that when I do: > > > import urrlib > > The imported module is itself, and not the one f

Re: Importing Module To Use Variables In A Second Module

2007-09-28 Thread Calvin Spealman
Most problems like this are caused by trying to access the attributes of the module before that module is fully executed, and thus before they are defined. For example, if you have A.py: import B data = "TEST" And B.py: import A print A.data Now, if you run A,py, it will import B before

Re: Importing Module To Use Variables In A Second Module

2007-09-27 Thread Steve Holden
[EMAIL PROTECTED] wrote: > On 2007-09-27, Steve Holden <[EMAIL PROTECTED]> wrote: > >> Self-evidently you are *not* creating the variables you think you are in >> the variablePage module. Have you tried an interactive test? Try this at >> the interpreter prompt: >> > import variablePage >

Re: Importing Module To Use Variables In A Second Module

2007-09-27 Thread rshepard
On 2007-09-27, Steve Holden <[EMAIL PROTECTED]> wrote: > Self-evidently you are *not* creating the variables you think you are in > the variablePage module. Have you tried an interactive test? Try this at > the interpreter prompt: > > >>> import variablePage > >>> dir(variablePage) > > and you wil

Re: Importing Module To Use Variables In A Second Module

2007-09-27 Thread Steve Holden
[EMAIL PROTECTED] wrote: > I'm stymied by what should be a simple Python task: accessing the value of > a variable assigned in one module from within a second module. I wonder if > someone here can help clarify my thinking. I've re-read Chapter 16 (Module > Basics) in Lutz and Ascher's "Learning

Re: Importing module of data dicts and constants

2006-11-25 Thread Fredrik Lundh
Nathan Harmston wrote: > I ve got a single module which I m using to contain a lot of > dictionaries, constants, general information, which are used by > various other modules. However I can't seem to access them: > > in data.py > _SEQTYPE_DNA = 0 > _SEQTYPE_RNA = 1 > _SEQTYPE_PROT = 2 > _seqTy

Re: Importing module of data dicts and constants

2006-11-25 Thread Fuzzyman
Nathan Harmston wrote: > Hi All, > > I ve got a single module which I m using to contain a lot of > dictionaries, constants, general information, which are used by > various other modules. However I can't seem to access them: > > in data.py > _SEQTYPE_DNA = 0 > _SEQTYPE_RNA = 1 > _SEQTYPE_PROT = 2