Is this just for readability to the developer? python

  • Thread starter David Stockwell
  • Start date
D

David Stockwell

Hi,

I was looking through some of our source code and I found this:

initModule( "$Revision: 3.1 $".split(" ")[1] )

In this example, it looks like only the '3.1' is actually passed to the
function. Which leads me to speculate that the rest of it is just there to
make it easier for the developer when looking at source code to see what
version of the module is being used.

The only thing I think i notice is its also passing a list of one element?

Is this a typical way to do this in python?

Thanks

David
-------
Tracfone: http://cellphone.duneram.com/index.html
bibor: http://www.duneram.com/cam/index.html
Tax: http://www.duneram.com/index.html

_________________________________________________________________
MSN 9 Dial-up Internet Access fights spam and pop-ups – now 3 months FREE!
http://join.msn.click-url.com/go/onm00200361ave/direct/01/
 
R

Richard Brodie

In this example, it looks like only the '3.1' is actually passed to the
function. Which leads me to speculate that the rest of it is just there to
make it easier for the developer when looking at source code to see what
version of the module is being used.

It looks like that it may be for the benefit of CVS; manually updated
version numbers are a pain.
The only thing I think i notice is its also passing a list of one element?

One element of a list; that's not quite the same thing.
 
M

Mel Wilson

I was looking through some of our source code and I found this:

initModule( "$Revision: 3.1 $".split(" ")[1] )

In this example, it looks like only the '3.1' is actually passed to the
function. Which leads me to speculate that the rest of it is just there to
make it easier for the developer when looking at source code to see what
version of the module is being used. [ ... ]

To amplify David Brodie's answer:

The string "$Revision: 3.1 $" is probably supplied by
CVS, the Concurrent Versioning System, and that literal in
that line of the program changes every time the Python
module is checked into change control. You're really
looking at a slick way to communicate between CVS and the
module user.

Regards. Mel.
 
P

Peter Hansen

David said:
I was looking through some of our source code and I found this:

initModule( "$Revision: 3.1 $".split(" ")[1] )

In this example, it looks like only the '3.1' is actually passed to the
function. Which leads me to speculate that the rest of it is just there
to make it easier for the developer when looking at source code to see
what version of the module is being used.

Revision control systems such as CVS and Subversion know how to
find and update information such as the revision tag when it is
formatted in that manner (leading/trailing $ etc). The programmer
also apparently thought it would be a good idea to use the revision
number programmatically, which explains the surrounding split()
and indexing operations, and the function call.

-Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top