473,657 Members | 2,735 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Decoupling the version of the file from the name of the module.

I'm a newbie experimenting with Python. I want to incrementally develop
a module called 'circle'. The problem is now that the file name is used
for two purposes. To keep track of the version number and as the name
for the module. So when I develop the first version of my file I have
to call it circle_a.py. The name of the module then automatically
becomes circle_a. But when I develop the next increment and call my
file circle_b.py the module name changes as well.

Basically I want to decouple the version of my file from the name of
the module.

Is there a *simple* way out of this dilemma.

Jan 28 '06 #1
13 1607
bo*******@yahoo .com wrote:
I'm a newbie experimenting with Python. I want to incrementally develop
a module called 'circle'. The problem is now that the file name is used
for two purposes. To keep track of the version number and as the name
for the module. So when I develop the first version of my file I have
to call it circle_a.py. The name of the module then automatically
becomes circle_a. But when I develop the next increment and call my
file circle_b.py the module name changes as well.

Basically I want to decouple the version of my file from the name of
the module.

Is there a *simple* way out of this dilemma.


You have two choices:

1- Just get rid of the version number in the name (what's the point) and
define a __version__ attribute in the module, that's what is usually done.
2- create a wrapper module called "circle.py" whose content will be
something along the lines of "from your_current_mo dule_with_versi on
import *"

I'd strongly suggest the first choice, there is no point in giving the
version number into the file name of a module.
Jan 28 '06 #2
bo*******@yahoo .com wrote:
I'm a newbie experimenting with Python. I want to incrementally develop
a module called 'circle'. The problem is now that the file name is used
for two purposes. To keep track of the version number and as the name
for the module. So when I develop the first version of my file I have
to call it circle_a.py. The name of the module then automatically
becomes circle_a. But when I develop the next increment and call my
file circle_b.py the module name changes as well.

Basically I want to decouple the version of my file from the name of
the module.

Is there a *simple* way out of this dilemma.


I would recommend just naming the file circle.py, and defining something
like a variable named __version__ or maybe __revision__ at the top of
the module. Then you can, I don't know, back up your old versions to
other filenames or something.

Or, if you really want to do this right, you could install Subversion. :-)

-Kirk McDonald
Jan 28 '06 #3
bo*******@yahoo .com writes:
Basically I want to decouple the version of my file from the name of
the module.

Is there a *simple* way out of this dilemma.


Really, you should use a source control system. That's a program that
tracks the different versions of the files in your program. When one
of your files reaches a state of stability, you "check it in" to a
source repository which then remembers that version. You then go on
editing the file in place. Later, you can restore the old version
from the repository if you need to.

Source control is the only sane way to do what you're trying to do.
Messing around with renaming files to save old versions, as you're
doing, only works for very small, short-lived projects. That scheme
will drive you crazy in short order.

SubVersion (http://subversion.tigris.org) is a popular source control
system, maybe not the best, but compatible with some older widely used
ones. I'd personally choose this one because I have some experience
with it, but it's not ideal. Even if you don't choose to use it, you
might read its online docs, to get a sense of what kinds of problems
these programs try to solve.

There's a newer one called Codeville, written in Python, that I
haven't tried. There are numerous others I won't bother trying to
list. Which one is best is the topic of religious wars, like "the
best editor" or "the best language". Just pick one that you like and
stick with it.
Jan 28 '06 #4
Xavier Morel wrote:
Just get rid of the version number in the name (what's the point) and
define a __version__ attribute in the module, that's what is usually done.


Thanks Xavier, but as I said I'm newbie and I'm not sure how to do
that. Here's my module

# circle.py
from math import pi

__version__ = '1.0'

def disk(r):
"""Returns the area of the disk with radius r."""
return (pi * r**2)

def test():
print disk(1)
print disk(2)

# end of the module
Now suppose I have make a new version with __version__ = 1.1. What
shall I call this file and (I don't want to overwrite the old file if I
need to go back to it) how do I import it from the shell. Your advice
sounds nice, but I would appreciate if you could give me (or point me
to) a simple example.

Thanks

Jan 28 '06 #5
bo*******@yahoo .com wrote:
Now suppose I have make a new version with __version__ = 1.1. What
shall I call this file and (I don't want to overwrite the old file if I
need to go back to it) how do I import it from the shell. Your advice
sounds nice, but I would appreciate if you could give me (or point me
to) a simple example.

Thanks


Before you make a new version, rename circle.py to, e.g., circle-1.0.py,
and then create the new version as circle.py. Then you can access the
new version just like you accessed the old. If you make yet another new
version, then rename the current circle.py as circle-1.1.py, and lather,
rinse, repeat.

However, I'd still look into a version control system like Subversion.
It can do all of this for you.

-Kirk McDonald
Jan 28 '06 #6
In article <11************ **********@z14g 2000cwz.googleg roups.com>,
bo*******@yahoo .com wrote:
I'm a newbie experimenting with Python. I want to incrementally develop
a module called 'circle'. The problem is now that the file name is used
for two purposes. To keep track of the version number and as the name
for the module. So when I develop the first version of my file I have
to call it circle_a.py. The name of the module then automatically
becomes circle_a. But when I develop the next increment and call my
file circle_b.py the module name changes as well.

Basically I want to decouple the version of my file from the name of
the module.

Is there a *simple* way out of this dilemma.


Why do you have to change the name of the file each time you come out with
a new version? I think that's where you're going wrong. Put something
*inside* the file to indicated the version number, but keep the name of the
file the same.
Jan 29 '06 #7
On Sat, 28 Jan 2006 23:13:12 +0100, Xavier Morel wrote:
bo*******@yahoo .com wrote:
I'm a newbie experimenting with Python. I want to incrementally develop
a module called 'circle'. The problem is now that the file name is used
for two purposes. To keep track of the version number and as the name
for the module. So when I develop the first version of my file I have
to call it circle_a.py. The name of the module then automatically
becomes circle_a. But when I develop the next increment and call my
file circle_b.py the module name changes as well.

Basically I want to decouple the version of my file from the name of
the module.

Is there a *simple* way out of this dilemma.


You have two choices:

1- Just get rid of the version number in the name (what's the point) and
define a __version__ attribute in the module, that's what is usually done.
2- create a wrapper module called "circle.py" whose content will be
something along the lines of "from your_current_mo dule_with_versi on
import *"

I'd strongly suggest the first choice, there is no point in giving the
version number into the file name of a module.

Modules are conceptually like a shared code library, and remember the
awful problem of DLL hell on Windows? In Linux land, the convention is
that libraries have the version number in the file name, so that when you
install a library, it doesn't overwrite any pre-existing versions of the
library. This is a Good Thing.

I haven't been distributing a large number of Python applications to
outsiders, so I don't know how much of a practical problem it is for
Python, but if you have a rapidly changing module, with changes to the
API, this is certainly a theoretical problem, if not a practical one.

If it is not a problem in practice, why not? What do people do to avoid
this?
--
Steven.

Jan 29 '06 #8
bo*******@yahoo .com wrote:
Now suppose I have make a new version with __version__ = 1.1. What
shall I call this file and (I don't want to overwrite the old file if I
need to go back to it)?


Stop everything right now and get yourself some kind of version control
system. CVS (http://ximbiot.com/cvs/wiki/index.php?title=Main_Page) is a
popular one. Subversion (http://subversion.tigris.org/) is a bit newer,
and quickly gaining is popularity. If some other system (Perforce,
ClearCase, RCS, SCCS, etc) is already in use where you are, just use that.
Many IDEs come with something built-in. Which one you pick is a detail,
but it's essential that you use something.

If you don't use some kind of version control system, you end up mired in
thorny questions like the one you ask above. Learning something like cvs
may seem intimidating at first, but believe me, it's impossible to do any
kind of serious software development without one.
Jan 29 '06 #9
Roy Smith wrote:
bo*******@yahoo .com wrote:
Now suppose I have make a new version with __version__ = 1.1. What
shall I call this file and (I don't want to overwrite the old file if I
need to go back to it)?


Stop everything right now and get yourself some kind of version control
system. CVS (http://ximbiot.com/cvs/wiki/index.php?title=Main_Page) is a
popular one. Subversion (http://subversion.tigris.org/) is a bit newer,
and quickly gaining is popularity.


Listen to Roy. Get a source code control system. Use any one you want,
provided that if your choice is between CVS and Subversion, you use
Subversion. ;-)

-Peter

Jan 29 '06 #10

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

Similar topics

16
2745
by: Manlio Perillo | last post by:
Hi. I'm a new user of Python but I have noted a little problem. Python is a very good language but it is evolving, in particular its library is evolving. This can be a problem when, ad example, a module change its interface or its implementation in a fundamental way (an example: wxPython). This, I think, can be resolved by allowing an user to explicitly say what version of a module it wants (sush as version numbers in Linux shared...
0
1467
by: atulhi | last post by:
I've been having some problems with gyach, when trying to open the PyVoice chat portion of it. Following error is received ******************************************************************************* /usr/local/share/gyach/pyvoice/pytsp.py:2: RuntimeWarning: Python C API version mismatch for module pytspc: This Python has API version 1012, module pytspc has version 1011. import pytspc
2
3514
by: Thomas W | last post by:
I'm trying to wrap my head around the docs at python.org related to the gettext-module, but I'm having some problem getting it to work. Is there any really simple, step-by-step on how to use this module available? This is my script so far : import gettext gettext.install('test2', '.', unicode=1) lang1 = gettext.translation('test2', languages=)
7
7810
by: Sky | last post by:
I have been looking for a more powerful version of GetType(string) that will find the Type no matter what, and will work even if only supplied "{TypeName}", not the full "{TypeName},{AssemblyName}" As far as I know yet -- hence this question -- there is no 'one solution fits all', but instead there are several parts that have to be put together to check. What I have so far is, and would like as much feedback as possible to ensure I've...
0
1768
by: =?Utf-8?B?RHVja3dvbg==?= | last post by:
Hello everyone, I need to get the version number of a couple of DLLs (comctl32.dll and msxml4.dll). I don't have the full path because I don't want to assume they will be in the system32 folder. I have a function which first does... //get the current process p = Process.GetCurrentProcess(); //get all the dlls this class is using
3
4270
by: =?Utf-8?B?UGF1bA==?= | last post by:
in event log:.NET Runtime version 2.0.50727.312 - Fatal Execution Engine Error (7A062A61) (80131506) We have an application that seems to be throwing this error, but I can't seem to work out why it should throw it. It's normally thrown when writing to a stream, I can't say that I've ever seen it before but it seems to be occuring on various machines and doesn't seem to be reliably tracable as it occurs at different stages in the...
0
1036
by: Frank Aune | last post by:
Hello, I just recently found out that wx.lib.pubsub has finally moved away from wx, and now lives at: http://pubsub.wiki.sourceforge.net I'm trying to use pubsub3, which is the third version and now the default one, but I'm having a hard time creating topics and messages for sending:
3
13427
ram09
by: ram09 | last post by:
After deploying our site in the iis7 server, we encountered this error... ModuleName AspNetInitializationExceptionModule Notification 1 HttpStatus 500 HttpReason Internal Server Error HttpSubStatus 0 ErrorCode 0 ConfigExceptionInfo Notification BEGIN_REQUEST
20
5779
by: Nates | last post by:
I have a .bas file saved locally that I load into my Acces project to run a particular sub. I use the following code to load the module (which works fine): I use the following loop to remove the module: The above works fine (both adding the module and subsequantly removing it) provided I do not run any code within the module once it is loaded. The second I use code within the module the deletion loop does not seem to remove the...
0
8407
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8319
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8837
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8739
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8512
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8612
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7347
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5638
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2739
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.