Re: Import module from a different subdirectory

2019-05-19 Thread Peter J. Holzer
On 2019-05-18 16:15:34 -0700, Rich Shepard wrote: > My apologies to all who patiently tried to get me to see what I kept > missing. I've certainly made similar mistakes in the past (and probably will in the future). And I didn't see it when I read your mail the first time. But then I read Piet's

Re: Import module from a different subdirectory

2019-05-18 Thread Rich Shepard
On Sun, 19 May 2019, Peter J. Holzer wrote: This won't help much if your directory named "business-tracker" (see above). Peter, et al.: Yep. User error. The directory is actually 'business_tracker' and I used the application name, 'bustrac', instead when I set PYTHONPATH. Discovered this a bi

Re: Import module from a different subdirectory

2019-05-18 Thread Peter J. Holzer
On 2019-05-18 09:43:34 -0700, Rich Shepard wrote: > The project layout, briefly, is: > > ~/development/business-tracker/ > classes/ > gui/ > > All subdirectories contain a __init__.py file to identify them as packages. > 'classes/' contains model.py; '

Re: Import module from a different subdirectory

2019-05-18 Thread Piet van Oostrum
Rich Shepard writes: > > $ python3 > Python 3.7.3 (default, Mar 26 2019, 06:40:28) [GCC 5.5.0] on linux > Type "help", "copyright", "credits" or "license" for more information. import sys sys.path > ['', '/home/rshepard/development/bustrac', '/usr/lib/python37.zip', > '/usr/lib/python3.

Re: Import module from a different subdirectory

2019-05-18 Thread Rich Shepard
On Sat, 18 May 2019, Peter J. Holzer wrote: "" is in sys.path, so "classes" and classes.model are found. Now lets go to a different subdirectory: This doesn't work, since there is no classes/model.py in "", only in "..". But if I add a PYTHONPATH, it works again: Peter, The project layout,

Re: Import module from a different subdirectory

2019-05-18 Thread Peter J. Holzer
On 2019-05-18 05:45:23 -0700, Rich Shepard wrote: > On Sat, 18 May 2019, dieter wrote: > > > > sys.path > ['', '/home/rshepard/development/bustrac', '/usr/lib/python37.zip', > '/usr/lib/python3.7', '/usr/lib/python3.7/lib-dynload', > '/usr/lib/python3.7/site-packages'] > > All directories are pres

Re: Import module from a different subdirectory

2019-05-18 Thread Rich Shepard
On Sat, 18 May 2019, dieter wrote: Test this by looking at "sys.path" instead: import sys sys.path It is "sys.path" which actually controls the import machinery. Dieter, Thank you. I missed this when researching PYTHONPATH. Here's what I get: sys.path ['', '/home/rshepard/development/bus

Re: Import module from a different subdirectory

2019-05-17 Thread dieter
Rich Shepard writes: >> The project directory contains subdirectories, including gui/ (with the >> tkinter views) and classes/ with the SQLAlchemy model.py. > ... > Second, in ~/.bash_profile I added two lines, the first is the project's > root directory: > > PYTHONPATH=$HOME/development/bustrac >

Re: Import module from a different subdirectory

2019-05-17 Thread Rich Shepard
On Thu, 16 May 2019, Rich Shepard wrote: The project directory contains subdirectories, including gui/ (with the tkinter views) and classes/ with the SQLAlchemy model.py. Getting closer, but still missing a piece of the solution. First, I added __init__.py to each module subdirectory to speci

Re: Import module from a different subdirectory

2019-05-17 Thread Rich Shepard
On Fri, 17 May 2019, Inada Naoki wrote: This is slightly off topic (not relating to your problem), but please don't think "Python 3 doesn't require __init__.py for packages". It is common misunderstanding. Inada, Actually, your response is on topic and probably the reason I have the import pr

Re: Import module from a different subdirectory

2019-05-16 Thread Inada Naoki
2019年5月17日(金) 9:25 Rich Shepard : > > My understanding is that Python3 does not require subdirectories to have an > __init__.py file, only Python2 does. If that's not correct I'll add the > blank file. > This is slightly off topic (not relating to your problem), but please don't think "Python 3 do

Re: Import module from a different subdirectory

2019-05-16 Thread dieter
Rich Shepard writes: > I'm developing a Python3 application using Python3-3.7.3 and > virtualenv-16.5.0 on a Slackware-14.2 host. > > The project directory contains subdirectories, including gui/ (with the > tkinter views) and classes/ with the SQLAlchemy model.py. > > Within the gui/ directory as

Re: Import module from a different subdirectory

2019-05-16 Thread Rich Shepard
On Fri, 17 May 2019, duncan smith wrote: You could make the subdirectories Python packages. Google (or better DuckDuckGo) is your friend. Duncan, My understanding is that Python3 does not require subdirectories to have an __init__.py file, only Python2 does. If that's not correct I'll add the

Re: Import module from a different subdirectory

2019-05-16 Thread duncan smith
On 16/05/2019 22:50, Rich Shepard wrote: > I'm developing a Python3 application using Python3-3.7.3 and > virtualenv-16.5.0 on a Slackware-14.2 host. > > The project directory contains subdirectories, including gui/ (with the > tkinter views) and classes/ with the SQLAlchemy model.py. > > Within

Import module from a different subdirectory

2019-05-16 Thread Rich Shepard
I'm developing a Python3 application using Python3-3.7.3 and virtualenv-16.5.0 on a Slackware-14.2 host. The project directory contains subdirectories, including gui/ (with the tkinter views) and classes/ with the SQLAlchemy model.py. Within the gui/ directory as the cwd testing the code for a v

Re: Import module from file path

2018-12-05 Thread Thomas Jollans
On 05/12/2018 02:30, Oscar Benjamin wrote: > Hi all, > > I'm looking to import a module given a string representing the path to > the .py file defining the module. For example given this setup > > mkdir -p a/b/c > touch a/__init__.py > touch a/b/__init__.py > touch a/b/c/__init__.py > touch a/b/c

Re: Import module from file path

2018-12-05 Thread Oscar Benjamin
On Wed, 5 Dec 2018 at 07:57, Peter Otten <__pete...@web.de> wrote: > > Oscar Benjamin wrote: > > > > I'm looking to import a module given a string representing the path to > > the .py file defining the module. > > I am not aware of a clean way. I have used > > def guess_modulename(filename): >

Re: Import module from file path

2018-12-04 Thread Peter Otten
Oscar Benjamin wrote: > Hi all, > > I'm looking to import a module given a string representing the path to > the .py file defining the module. For example given this setup > > mkdir -p a/b/c > touch a/__init__.py > touch a/b/__init__.py > touch a/b/c/__init__.py > touch a/b/c/stuff.py > > I hav

Import module from file path

2018-12-04 Thread Oscar Benjamin
Hi all, I'm looking to import a module given a string representing the path to the .py file defining the module. For example given this setup mkdir -p a/b/c touch a/__init__.py touch a/b/__init__.py touch a/b/c/__init__.py touch a/b/c/stuff.py I have a module a.b.c.stuff which is defined in the

Project tree and import module

2018-06-08 Thread ftg
Hello, here is my project hierarchy: myproject | |- django-project-name | |- django-project-name | | |-urls.py | | |-views.py | |- manage.py |- my-package Is my projet tree correct? Shouldn't I put my-package into my django-project-name folder? Because I am facing some questionning about

Re: Custom Python import module failed (protobuf)

2018-04-20 Thread Sankar Raman V
Error: ImportError: No module named google.protobuf -- https://mail.python.org/mailman/listinfo/python-list

Custom Python import module failed (protobuf)

2018-04-20 Thread sankarramanv
Hi, I need to use the google protobuf for my task. 1. Yum install protobuf worked for default python 2.7.5 in my VM. But I need to test with Python 2.7.14. I installed protobuf using yum on "/usr/lib64/python2.7/site-packages" I added the above path to PYTHONPATH and its not recognizing when

Re: "from module import data; print(data)" vs "import module; print(module.data)"

2016-02-25 Thread Ben Finney
Steven D'Aprano writes: > On Fri, 26 Feb 2016 10:38 am, Ben Finney wrote: > > > Gregory Ewing writes: > > > >> sohcahto...@gmail.com wrote: > >> > Now, I've noticed people talking about importing os.path. Is there any > >> > reason to use "import os.path" rather than "import os"? Both of them

Re: "from module import data; print(data)" vs "import module; print(module.data)"

2016-02-25 Thread Chris Angelico
On Fri, Feb 26, 2016 at 2:56 PM, Ian Kelly wrote: > On Thu, Feb 25, 2016 at 5:40 PM, Steven D'Aprano wrote: >> If you take "Special cases are not special enough" seriously, you will not >> use `import os.path` since os is not a package: >> >> py> os.__package__ >> '' >> >> and os.path is not part

Re: "from module import data; print(data)" vs "import module; print(module.data)"

2016-02-25 Thread Ian Kelly
On Thu, Feb 25, 2016 at 5:40 PM, Steven D'Aprano wrote: > If you take "Special cases are not special enough" seriously, you will not > use `import os.path` since os is not a package: > > py> os.__package__ > '' > > and os.path is not part of os, it's just a publicly exposed attribute which > merel

Re: "from module import data; print(data)" vs "import module; print(module.data)"

2016-02-25 Thread Steven D'Aprano
On Fri, 26 Feb 2016 10:38 am, Ben Finney wrote: > Gregory Ewing writes: > >> sohcahto...@gmail.com wrote: >> > Now, I've noticed people talking about importing os.path. Is there any >> > reason to use "import os.path" rather than "import os"? Both of them >> > will still put the "os" module in

Re: "from module import data; print(data)" vs "import module; print(module.data)"

2016-02-25 Thread Ben Finney
Gregory Ewing writes: > sohcahto...@gmail.com wrote: > > Now, I've noticed people talking about importing os.path. Is there any > > reason to use "import os.path" rather than "import os"? Both of them will > > still put the "os" module into the global namespace. > > In the case of os.path it do

Re: "from module import data; print(data)" vs "import module; print(module.data)"

2016-02-25 Thread Gregory Ewing
sohcahto...@gmail.com wrote: Now, I've noticed people talking about importing os.path. Is there any reason to use "import os.path" rather than "import os"? Both of them will still put the "os" module into the global namespace. In the case of os.path it doesn't matter, because the os module im

Re: "from module import data; print(data)" vs "import module; print(module.data)"

2016-02-25 Thread sohcahtoa82
On Wednesday, February 24, 2016 at 5:07:57 PM UTC-8, Dan Stromberg wrote: > Could people please compare and contrast the two ways of doing imports > in the Subject line? > > I've long favored the latter, but I'm working in a code base that > prefers the former. > > Is it fair to say that the form

Re: "from module import data; print(data)" vs "import module; print(module.data)"

2016-02-25 Thread Ethan Furman
On 02/25/2016 08:20 AM, Dan Stromberg wrote: My intuition is telling me that "module.data; module.data.mutate()" would be easier to monkey patch in a way that all modules will see. Is that fair to say? It is fair to say that if you need to monkey-patch a module, you should import the module.

Re: "from module import data; print(data)" vs "import module; print(module.data)"

2016-02-25 Thread Ethan Furman
On 02/24/2016 07:39 PM, Steven D'Aprano wrote: (2) import module (a) Mutation is no different from (1)(a) above. No change. (b) Rebinding `module.data = []` affects the imported module, and therefore everything that relies on it. More accurate: and therefore everything that has not al

Re: "from module import data; print(data)" vs "import module; print(module.data)"

2016-02-25 Thread Dan Stromberg
t; in the Subject line? >> >> from module import data; print(data) >> >> import module; print(module.data) > >>> Is it fair to say that the former increases the surface area of your >>> shared (sometimes mutable) state? >> >> No, I can't

Re: "from module import data; print(data)" vs "import module; print(module.data)"

2016-02-25 Thread Dan Stromberg
On Wed, Feb 24, 2016 at 7:39 PM, Steven D'Aprano wrote: > On Thursday 25 February 2016 12:07, Dan Stromberg wrote: > >> Could people please compare and contrast the two ways of doing imports >> in the Subject line? > > from module import data; print(data) > &g

Re: "from module import data; print(data)" vs "import module; print(module.data)"

2016-02-24 Thread Steven D'Aprano
On Thursday 25 February 2016 12:07, Dan Stromberg wrote: > Could people please compare and contrast the two ways of doing imports > in the Subject line? from module import data; print(data) import module; print(module.data) > I've long favored the latter, but I'm working

Re: "from module import data; print(data)" vs "import module; print(module.data)"

2016-02-24 Thread Cameron Simpson
h, join as joinpath and then using "joinpath(a, b)". Is it fair to say that the former increases the surface area of your shared (sometimes mutable) state? It can go the other way. Consider: import module module.data = 1 versus: from module import data data = 1 The former

"from module import data; print(data)" vs "import module; print(module.data)"

2016-02-24 Thread Dan Stromberg
Could people please compare and contrast the two ways of doing imports in the Subject line? I've long favored the latter, but I'm working in a code base that prefers the former. Is it fair to say that the former increases the surface area of your shared (sometimes mutable) state? It's clear that

Re: import module pyttsx in windows IDLE failed

2015-11-16 Thread input/ldompeling
Now I get this error: Traceback (most recent call last): File "C:\raspberrypi\recipe-578839-1.py", line 1, in import pyttsx File "C:\Users\loek\AppData\Local\Programs\Python\Python35\lib\site-packages\pyttsx\__init__.py", line 18, in from engine import Engine ImportError: No module

Re: import module pyttsx in windows IDLE failed

2015-11-16 Thread Terry Reedy
On 11/16/2015 12:45 PM, input/ldompel...@casema.nl wrote: In reply to "MRAB" who wrote the following: Have you installed pyttsx? No, I did not. Where can I find pyttsx to install ? Let pip find it (its on pypi). On a command line, enter 'pip install pyttsx' -- Terry Jan Reedy -- https://mail

Re: import module pyttsx in windows IDLE failed

2015-11-16 Thread MRAB
On 2015-11-16 17:45, input/ldompel...@casema.nl wrote: In reply to "MRAB" who wrote the following: Have you installed pyttsx? No, I did not. Where can I find pyttsx to install ? The first place to look is PyPI. It's here: https://pypi.python.org/pypi/pyttsx You might want to look at the link

Re: import module pyttsx in windows IDLE failed

2015-11-16 Thread input/ldompeling
In reply to "MRAB" who wrote the following: Have you installed pyttsx? No, I did not. Where can I find pyttsx to install ? Thanks - > On 2015-11-16 17:12, input/ldompel...@casema.nl wrote: > > When I try to run this module in Win

Re: import module pyttsx in windows IDLE failed

2015-11-16 Thread MRAB
On 2015-11-16 17:12, input/ldompel...@casema.nl wrote: When I try to run this module in Windows IDLE I get this message: How can I solve this problem. Thanks Traceback (most recent call last): File "C:\raspberrypi\recipe-578839-1.py", line 1, in import pyttsx ImportError: No module nam

import module pyttsx in windows IDLE failed

2015-11-16 Thread input/ldompeling
When I try to run this module in Windows IDLE I get this message: How can I solve this problem. Thanks Traceback (most recent call last): File "C:\raspberrypi\recipe-578839-1.py", line 1, in import pyttsx ImportError: No module named 'pyttsx' This is what I found on the internet:

Re: python import module question

2013-07-28 Thread Peter Otten
syed khalid wrote: > I am trying to do a "import shogun" in my python script. I can invoke > shogun with a command line with no problem. But I cannot with a python > import statement. > >>invoking python from a command line... > > Syedk@syedk-ThinkPad-T410:~/shogun-2.0.0/src/interfac

Re: python import module question

2013-07-27 Thread Chris Angelico
On Sun, Jul 28, 2013 at 12:15 AM, syed khalid wrote: > Syedk@syedk-ThinkPad-T410:~/shogun-2.0.0/src/interfaces/cmdline_static$ > shogun | more This implies that you have something called 'shogun', without an extension, in your $PATH. Where is the actual script? You may need to install it by a qu

python import module question

2013-07-27 Thread syed khalid
I am trying to do a "import shogun" in my python script. I can invoke shogun with a command line with no problem. But I cannot with a python import statement. >invoking python from a command line... Syedk@syedk-ThinkPad-T410:~/shogun-2.0.0/src/interfaces/cmdline_static$ shogun | mo

Re: Unittest fails to import module

2013-06-29 Thread Martin Schöön
On 2013-06-29, Steven D'Aprano wrote: > On Sat, 29 Jun 2013 19:13:47 +, Martin Schöön wrote: > >> $PYTHONPATH points at both the code and the test directories. >> >> When I run blablabla_test.py it fails to import blablabla.py > > What error message do you get? > > >> I have messed around f

Re: Unittest fails to import module

2013-06-29 Thread Steven D'Aprano
On Sat, 29 Jun 2013 19:13:47 +, Martin Schöön wrote: > $PYTHONPATH points at both the code and the test directories. > > When I run blablabla_test.py it fails to import blablabla.py What error message do you get? > I have messed around for oven an hour and get nowhere. I have done > unitt

Re: Unittest fails to import module

2013-06-29 Thread Roy Smith
In article , Martin Schöön wrote: > I know the answer to this must be trivial but I am stuck... > > I am starting on a not too complex Python project. Right now the > project file structure contains three subdirectories and two > files with Python code: > > code >blablabla.py > test >b

Unittest fails to import module

2013-06-29 Thread Martin Schöön
I know the answer to this must be trivial but I am stuck... I am starting on a not too complex Python project. Right now the project file structure contains three subdirectories and two files with Python code: code blablabla.py test blablabla_test.py doc (empty for now) blablabla_test.p

Re: How to import module whose filename starts number

2012-12-12 Thread Benjamin Kaplan
On Dec 12, 2012 9:47 AM, "Yong Hu" wrote: > > I have a few scripts whose file names start with numbers. For example, 01_step1.py, 02_step2.py > > I tried to import them in another script by "import 01_step1" or "from 01_step1 import *". Both failed, saying "SyntaxError: invalid syntax" > > Is ther

Re: How to import module whose filename starts number

2012-12-12 Thread Peter Otten
Yong Hu wrote: > I have a few scripts whose file names start with numbers. For example, > 01_step1.py, 02_step2.py > > I tried to import them in another script by "import 01_step1" or "from > 01_step1 import *". Both failed, saying "SyntaxError: invalid syntax" > > Is there anyway to import thos

Re: How to import module whose filename starts number

2012-12-12 Thread Dave Angel
On 12/12/2012 12:42 PM, Yong Hu wrote: > I have a few scripts whose file names start with numbers. For example, > 01_step1.py, 02_step2.py > > I tried to import them in another script by "import 01_step1" or "from > 01_step1 import *". Both failed, saying "SyntaxError: invalid syntax" > > Is ther

How to import module whose filename starts number

2012-12-12 Thread Yong Hu
I have a few scripts whose file names start with numbers. For example, 01_step1.py, 02_step2.py I tried to import them in another script by "import 01_step1" or "from 01_step1 import *". Both failed, saying "SyntaxError: invalid syntax" Is there anyway to import those files? The file name must

Re: import module doesn't work for new package

2010-12-04 Thread Peter Otten
goldtech wrote: > I tried install a Python - would the word be "package"? - on Ubuntu > 10.10. Could you tell me how to fix? I would be grateful, is it a path > problem? Thanks. Lee If you are talking about http://paul.giannaros.org/pykhtml/ , this package requires kde3 while you are /probably/

Re: import module doesn't work for new package

2010-12-03 Thread Steven D'Aprano
On Fri, 03 Dec 2010 12:27:04 -0800, goldtech wrote: > I tried install a Python - would the word be "package"? - on Ubuntu > 10.10. Could you tell me how to fix? I would be grateful, is it a path > problem? Thanks. Lee That looks to me like either a missing dependency, or a bug in the package. I

import module doesn't work for new package

2010-12-03 Thread goldtech
I tried install a Python - would the word be "package"? - on Ubuntu 10.10. Could you tell me how to fix? I would be grateful, is it a path problem? Thanks. Lee gi...@giga1:~/Desktop/pykhtml-0.2$ sudo python setup.py install [sudo] password for giga1: running install running build running build_py

Re: Import Module

2010-05-20 Thread Gary Herron
On 05/19/2010 09:40 AM, Harikrishnan R wrote: Hi , I have a file a.py contains from one.two import abc is there any way to find out "one.two" the import Path of abc. ? I don't want one.two.abc . Any function or attribute which directly

Import Module

2010-05-20 Thread Harikrishnan R
Hi , I have a file a.py contains from one.two import abc is there any way to find out "one.two" the import Path of abc. ? I don't want one.two.abc . Any function or attribute which directly give one.two ? -Regards -- Harikrishan R http:/

Re: Why 'import module' will not import module.py but the directory module?

2009-11-01 Thread Colin W.
Robert Kern wrote: On 2009-10-31 19:16 PM, Peng Yu wrote: On Sat, Oct 31, 2009 at 7:02 PM, Robert Kern wrote: On 2009-10-31 18:51 PM, Peng Yu wrote: If I have both the directory 'module' and the file 'module.py' in a directory in $PYTHONPATH, python will import

Re: Why 'import module' will not import module.py but the directory module?

2009-10-31 Thread Robert Kern
On 2009-10-31 19:16 PM, Peng Yu wrote: On Sat, Oct 31, 2009 at 7:02 PM, Robert Kern wrote: On 2009-10-31 18:51 PM, Peng Yu wrote: If I have both the directory 'module' and the file 'module.py' in a directory in $PYTHONPATH, python will import 'module' rather t

Re: Why 'import module' will not import module.py but the directory module?

2009-10-31 Thread Peng Yu
On Sat, Oct 31, 2009 at 7:02 PM, Robert Kern wrote: > On 2009-10-31 18:51 PM, Peng Yu wrote: >> >> If I have both the directory 'module' and the file 'module.py' in a >> directory in $PYTHONPATH, python will import 'module' rather than >> &

Re: Why 'import module' will not import module.py but the directory module?

2009-10-31 Thread Robert Kern
On 2009-10-31 18:51 PM, Peng Yu wrote: If I have both the directory 'module' and the file 'module.py' in a directory in $PYTHONPATH, python will import 'module' rather than 'module.py'. I'm wondering what is the design rationale of setting higher

Why 'import module' will not import module.py but the directory module?

2009-10-31 Thread Peng Yu
If I have both the directory 'module' and the file 'module.py' in a directory in $PYTHONPATH, python will import 'module' rather than 'module.py'. I'm wondering what is the design rationale of setting higher priorities to directories. Is

Re: import module unbelieveable behaviour

2009-07-15 Thread Peter Fodrek
On Thursday 16 July 2009 08:38:57 Peter Fodrek wrote: > On Thursday 16 July 2009 07:38:23 Carl Banks wrote: > > On Jul 15, 10:16 pm, Peter Fodrek wrote: > > > On Wednesday 15 July 2009 17:41:54 Diez B. Roggisch wrote: > sys.path.insert(0,'/usr/local/lib/heekscnc/') I was mentioned that this adds

Re: import module unbelieveable behaviour

2009-07-15 Thread Peter Fodrek
On Thursday 16 July 2009 07:38:23 Carl Banks wrote: > On Jul 15, 10:16 pm, Peter Fodrek wrote: > > On Wednesday 15 July 2009 17:41:54 Diez B. Roggisch wrote: > > > Peter Fodrek wrote: > > > > .. > > > > > What does > > > > > > import nc > > > print nc.__file__ > > > > python > > Python 2.6 (r2

Re: import module unbelieveable behaviour

2009-07-15 Thread Carl Banks
On Jul 15, 10:16 pm, Peter Fodrek wrote: > On Wednesday 15 July 2009 17:41:54 Diez B. Roggisch wrote: > > > Peter Fodrek wrote: > .. > > What does > > > import nc > > print nc.__file__ > > python > Python 2.6 (r26:66714, Feb  3 2009, 20:49:49) > [GCC 4.3.2 [gcc-4_3-branch revision 141291]] on

Re: import module unbelieveable behaviour

2009-07-15 Thread Peter Fodrek
On Thursday 16 July 2009 02:18:52 Carl Banks wrote: > On Jul 15, 6:12 am, Peter Fodrek wrote: > That's a tricky one, indeed. > > Here's my guess: test.py is a symlink to a file in another directory. It is not true guess ls -la test.py -rw-r--r-- 1 peto users 1990 2009-07-15 14:19 test.py But m

Re: import module unbelieveable behaviour

2009-07-15 Thread Peter Fodrek
On Wednesday 15 July 2009 17:41:54 Diez B. Roggisch wrote: > Peter Fodrek wrote: .. > What does > > import nc > print nc.__file__ python Python 2.6 (r26:66714, Feb 3 2009, 20:49:49) [GCC 4.3.2 [gcc-4_3-branch revision 141291]] on linux2 Type "help", "copyright", "credits" or "license" for mo

Re: import module unbelieveable behaviour

2009-07-15 Thread Carl Banks
On Jul 15, 6:12 am, Peter Fodrek wrote: > Dear conference! > > I have test Why python based script for HeeksCNC post-processing does not > work...  And I've got unbelievable behavior  When importing module module > manually it works, but same opertaion from script does not >  work as seen > > /opt

Re: import module unbelieveable behaviour

2009-07-15 Thread Diez B. Roggisch
Peter Fodrek wrote: > Dear conference! > > I have test Why python based script for HeeksCNC post-processing does not > work... And I've got unbelievable behavior When importing module module > manually it works, but same opertaion from script does not > work as seen > > /opt/HeeksCAD8/HeeksCN

Re: import module unbelieveable behaviour

2009-07-15 Thread Tycho Andersen
On Wed, Jul 15, 2009 at 8:12 AM, Peter Fodrek wrote: > > Would anyone be helpful for me to get more information about this problem > because  pydb does not show anything usable for me,please? What is the directory structure for the HeeksCNC module? Although I'm no expert, I suspect it looks someth

import module unbelieveable behaviour

2009-07-15 Thread Peter Fodrek
Dear conference! I have test Why python based script for HeeksCNC post-processing does not work... And I've got unbelievable behavior When importing module module manually it works, but same opertaion from script does not work as seen /opt/HeeksCAD8/HeeksCNC> python Python 2.6 (r26:66714, Fe

Re: Function to import module to namespace

2008-06-30 Thread bvdp
John Machin wrote: On Jun 30, 11:45 am, bvdp <[EMAIL PROTECTED]> wrote: John Machin wrote: Good questions. Short answer ... probably 'cause I've not thought the problem though completely :) > You are updating with *everything* in the 'more' module, not just the > functions. This includes s

Re: Function to import module to namespace

2008-06-30 Thread John Machin
On Jun 30, 11:45 am, bvdp <[EMAIL PROTECTED]> wrote: > John Machin wrote: > > > > Good questions. Short answer ... probably 'cause I've not thought the > problem though completely :) > > > You are updating with *everything* in the 'more' module, not just the > > functions. This includes such thi

Re: Function to import module to namespace

2008-06-29 Thread bvdp
John Machin wrote: Good questions. Short answer ... probably 'cause I've not thought the problem though completely :) > You are updating with *everything* in the 'more' module, not just the > functions. This includes such things as __name__, __doc__, __file__. > Could have interesting side-e

Re: Function to import module to namespace

2008-06-29 Thread John Machin
On Jun 30, 9:52 am, bvdp <[EMAIL PROTECTED]> wrote: > Terry Reedy wrote: > > > > > > > > > > Do you mean something like this? > > > > > >>> math.__dict__.update(string.__dict__) > > >>> dir(math) > > ['Formatter', 'Template', '_TemplateMetaclass', '__builtins__', > > > > I think t

Re: Function to import module to namespace

2008-06-29 Thread bvdp
Terry Reedy wrote: > > > Do you mean something like this? > >>> math.__dict__.update(string.__dict__) > >>> dir(math) > ['Formatter', 'Template', '_TemplateMetaclass', '__builtins__', I think this is working First off, 2 module files: funcs.py def func1(): print "I'm func1

Re: Function to import module to namespace

2008-06-29 Thread bvdp
Terry Reedy wrote: bvdp wrote: Is it possible to do this from a function: import a module and append the defs in that module to an existing module/namesapce. So, in my code I have something like: # main code import mods def loadmore(n): import_module(n, mods) # end of main this

Re: Function to import module to namespace

2008-06-29 Thread Terry Reedy
bvdp wrote: Is it possible to do this from a function: import a module and append the defs in that module to an existing module/namesapce. So, in my code I have something like: # main code import mods def loadmore(n): import_module(n, mods) # end of main this will permit the add

Re: Function to import module to namespace

2008-06-29 Thread Cédric Lucantis
Le Sunday 29 June 2008 21:08:36 bvdp, vous avez écrit : > Is it possible to do this from a function: import a module and append > the defs in that module to an existing module/namesapce. > > So, in my code I have something like: > > # main code > import mods > > def loadmore(n): > import_module

Function to import module to namespace

2008-06-29 Thread bvdp
Is it possible to do this from a function: import a module and append the defs in that module to an existing module/namesapce. So, in my code I have something like: # main code import mods def loadmore(n): import_module(n, mods) # end of main this will permit the addition of the th

Re: the problem of import module

2008-03-07 Thread Peter Otten
[EMAIL PROTECTED] wrote: > follow the dive into python > - import sys sys.path sys.path.append('E \achieve\book\diveintopython-pdfzh-cn-5.4b\diveintopythonzh-cn-5.4b\py') > --

the problem of import module

2008-03-06 Thread [EMAIL PROTECTED]
follow the dive into python - >>> import sys >>> sys.path >>> sys.path.append('E:\achieve\book\diveintopython-pdfzh-cn-5.4b\diveintopythonzh-cn-5.4b\py') - I append the fi

Re: Import module conflict

2008-01-10 Thread jatin patni
>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 from the stdlib. >Any idea? Try this: *from stdl

Re: How do I access a main frunction from an import module?

2006-11-24 Thread Jim
Steve wrote: > This is an interesting question. It almost looks like a case of > event-driven programming, where main is the plug-in and abc is the > framework. > http://eventdrivenpgm.sourceforge.net/ > > So how about something like this: > > ## abc.py > > #-

Re: How do I access a main frunction from an import module?

2006-11-24 Thread John Machin
Jim wrote: > John Machin wrote: > > Jim wrote: > > > Hi, > > > > > > I have created an import module. And would like to access a function > > > from the main script, e.g., > > > > > > file abc.py: > > >

Re: How do I access a main frunction from an import module?

2006-11-24 Thread Steve
This is an interesting question. It almost looks like a case of event-driven programming, where main is the plug-in and abc is the framework. http://eventdrivenpgm.sourceforge.net/ So how about something like this: ## abc.py #

Re: How do I access a main frunction from an import module?

2006-11-24 Thread Jim
John Machin wrote: > Jim wrote: > > Hi, > > > > I have created an import module. And would like to access a function > > from the main script, e.g., > > > > file abc.py: > > ### > > def a(): > > m() > >

Re: How do I access a main frunction from an import module?

2006-11-24 Thread Fredrik Lundh
Jim wrote: > Application abc is designed as a complete module. The user is to > script their own functions to work with application abc. so use execfile() with a prepared namespace: namespace = { ...stuff to export to the module ... } execfile("directory/module.py", namespace) --

Re: How do I access a main frunction from an import module?

2006-11-24 Thread John Machin
Jim wrote: > Hi, > > I have created an import module. And would like to access a function > from the main script, e.g., > > file abc.py: > ### > def a(): > m() > return None > > > file main.py: > ###

Re: How do I access a main frunction from an import module?

2006-11-24 Thread Jim
Bjoern Schliessmann wrote: > Jim wrote: > > > I have created an import module. And would like to access a > > function from the main script, e.g., > > May I ask why? This style violates "normal" module philosophy. > > Regards, > > > Björn > &g

Re: How do I access a main frunction from an import module?

2006-11-24 Thread Bjoern Schliessmann
Jim wrote: > I have created an import module. And would like to access a > function from the main script, e.g., May I ask why? This style violates "normal" module philosophy. Regards, Björn -- BOFH excuse #307: emissions from GSM-phones -- http://mail.python.org/mailman

Re: How do I access a main frunction from an import module?

2006-11-24 Thread Anton Vredegoor
Jim wrote: > I have created an import module. And would like to access a function > from the main script, e.g., > > file abc.py: > ### > def a(): > m() > return None > > > file main.py: > #

Re: How do I access a main frunction from an import module?

2006-11-24 Thread Carl Banks
Jim wrote: > I have created an import module. And would like to access a function > from the main script, e.g., > > file abc.py: > ### > def a(): > m() > return None > > > file main.py: > #

Re: How do I access a main frunction from an import module?

2006-11-24 Thread robert
Jim wrote: > Hi, > > I have created an import module. And would like to access a function > from the main script, e.g., > > file abc.py: > ### > def a(): > m() > return None > > > file main.py: > ###

How do I access a main frunction from an import module?

2006-11-24 Thread Jim
Hi, I have created an import module. And would like to access a function from the main script, e.g., file abc.py: ### def a(): m() return None file main.py: # from abc import * def m(): print 'something' retu

Re: Import module with non-standard file name

2006-08-17 Thread Ben Finney
"Martin v. Löwis" <[EMAIL PROTECTED]> writes: > Ben Finney schrieb: > > Question: I have Python modules named without '.py' as the extension, > > and I'd like to be able to import them. How can I do that? > > I recommend to use imp.load_module. I've tried this; as Patrick Maupin alludes to, it c

Re: Import module with non-standard file name

2006-08-08 Thread Martin v. Löwis
Ben Finney schrieb: > Question: I have Python modules named without '.py' as the extension, > and I'd like to be able to import them. How can I do that? I recommend to use imp.load_module. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list

Re: Import module with non-standard file name

2006-08-08 Thread Miki
Hello Ben, > Question: I have Python modules named without '.py' as the extension, > and I'd like to be able to import them. How can I do that? http://docs.python.org/lib/module-imp.html (hint: load_source :) HTH, Miki http://pythonwise.blogspot.com/ -- http://mail.python.org/mailman/listinfo/p

Re: Import module with non-standard file name

2006-08-07 Thread Ben Finney
"Patrick Maupin" <[EMAIL PROTECTED]> writes: > Ben Finney wrote: > > Question: I have Python modules named without '.py' as the extension, > > and I'd like to be able to import them. How can I do that? > > This is a piece of cake in Python. > > >>> from types import ModuleType > >>> x = ModuleTy

  1   2   >