473,326 Members | 2,113 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Re: Newbie question about import

En Fri, 25 Apr 2008 15:03:18 -0300, Luca <lu*****@gmail.comescribió:
Hi all. I'm trying to do something with python import but isn't working
for me.

Using python 2,5 I've a program structured like this:

* a main module called (for example) "mommy" with an __init__.py and a
file called "mommy.py"
* a __version__ var defined inside the main __init__.py
>From the mommy.py file I need to import the __version__ var, but I'm
really not able to do this! I fear this is a very stupid task to do...
my problem is that the file is called like the module.

Anyone can point me to the solution?
The short answer is: don't do that! __init__.py may import any module, but
other modules in the package should not import anything from __init__.py
The same rule applies to the main module in an application: it can import
any other required module, but no one should import main.
If you don't follow those rules you may encounter some surprises.
You *can* break the rules and actually do what you want, but I would not
reccomend it.
In this case, can't you switch the place where __version__ is defined? It
looks like a constant, so you could have it actually defined in mommy.py,
and inside __init__.py just import the value.

--
Gabriel Genellina

Jun 27 '08 #1
0 679

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: janetb | last post by:
Brand new to xml and I'm trying to get Scott Mitchell's rss aggregator example working locally. Basically, involves a frameset with the channels(feeds) in the left frame, a list of items in the...
1
by: sheephead86 | last post by:
Hi, I'm pretty new to java, and I have a small problem involving drawing a rectangle on a java applet.Firstly this is not a plea for someone to help me with this peice of work, I just need pointing...
0
by: Luca | last post by:
On Sat, Apr 26, 2008 at 4:14 AM, Gabriel Genellina <gagsl-py2@yahoo.com.arwrote: Ok, thanks all for helping. -- -- luca
7
by: idiolect | last post by:
Hi all - Sorry to plague you with another newbie question from a lurker. Hopefully, this will be simple. I have a list full of RGB pixel values read from an image. I want to test each RGB band...
1
by: Richard | last post by:
This is highly unusual. I do this only out of desperation. I am DB2 DBA on unix and recent had to take on Oracle admin as well. This question is really about Oracle export/import. Why I post here...
4
by: frankrentef | last post by:
Greetings all, I'm wanting to maintain what values in one file and call them in another. The purpose being to keep a single location where url's, login's and passwords can be maintained, then...
2
by: Ken D'Ambrosio | last post by:
First, apologies for such a newbie question; if there's a better forum (I've poked around, some) feel free to point it out to me. Anyway, a mere 25-odd years after first hearing about OOP, I've...
0
by: Albert-jan Roskam | last post by:
Hi John, Thanks! Using a higher xlrd version did the trick! Regarding your other remarks: -yep, input files with multiple sheets don't work yet. I kinda repressed that ;-) Spss outputs only...
0
by: Robert Kern | last post by:
Joe Hays wrote: You will want to ask numpy questions on the numpy mailing list (preferably with a subject line a bit more informative with respect to the actual problem). ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.