473,225 Members | 1,209 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,225 software developers and data experts.

cannot declare global vars!

Hi,
i had posted earlier for not being able to declare global vars. No i
followed the suggestions and created a class, but still the vars do not
seem to have a global scope. I have tried pretty much everything. Any
advice appreciated... Here:

================================================== ======
#!/usr/bin/env jython

#imports
....
class SVNLogs2DBParser:

#svnLogging_
#dbTable_
#cmterID_
#projID_
#fileIDNumber_
#Commiter_
#Commit_
#StoredProject_
#ProjectVersion_
#entryList_

def
__init__(self,svnLogging_=SVNLogging(SVN_REPOS),db Table_=DBTablesHandler(),cmterID_=0,projID_=0,

fileIDNumber_=0,Commiter_={},Commit_={},StoredProj ect_={},ProjectVersion_={},entryList_={}):
pass
#svnLogging_=SVNLogging(SVN_REPOS)
#print "Connection established to SVN repository..."
#dbTable_=DBTablesHandler()
#cmterID_=0
#projID_=0
#fileIDNumber_=0
#Commiter_={}
#Commit_={}
#StoredProject_={}
#ProjectVersion_={}
#entryList_={}

#reads all the revision logs (traversing them PIVOT at a time) and
#processes each log entry
def getLogsLoop(self):
while
svnLogging_.getCurrentRevisionNumber()!=svnLogging _.getLatestRevisionNumber():

entryList_=svnLogging_.getNextLogs(PIVOT);
#print "Attempting to go over the HEAD revision..."

for entry in self.entryList:
print "processing new SVN entry..."
processLogEntry(entry)

entryList_.clear()

#processes each log entry
#
#"entry" is of type SVNLogEntry. See SVNKit API
#"changedPaths" is returned as a java.util.HashMap
#with key strings (paths) and values SVNLogEntryPath objects
#"entry.getDates()" returns a java.util.Date object
def processLogEntry(self, entry):
revision = int(entry.getRevision())
commiter = str(entry.getAuthor())
datetime = getTimeStamp(entry.getDate())
message = str(entry.getMessage())
changedPaths = entry.getChangedPaths()

#array passed for updating the Commiter DB table
Commiter_[0] = cmterID_
Commiter_[1] = commiter
dbTable_.updateCommiterTable(Commiter_)

#array passed for updating the Commit DB table
Commit_[0] = projID_
Commit_[1] = datetime
Commit_[2] = cmterID_
Commit_[3] = 0.0
Commit_[4] = "" #properties
fileStats=getFileTypes(changedPaths)
Commit_[5] = fileStats[0]
Commit_[6] = fileStats[2]
Commit_[7] = fileStats[1]
Commit_[8] = fileStats[3]
Commit_[9] = fileStats[4]
dbTable_.updateCommitTable(self.Commit_)
ProjectVersion_[0]=projID_
ProjectVersion_[1]=0.0
dbTable_.updateProjectVersionTable(ProjectVersion_ )
Project[0]=projID_
Project[1]=""
Project[2]=""
Project[3]=""
Project[4]=""

dbTable_.updateProjectTable(Project_)

cmterID_+=1
projID_+=1

##############################HELPER##METHODS##### ##########################

....
##############################HELPER##METHODS##### ##########################

Sep 13 '07 #1
1 1263
Konstantinos Pachopoulos wrote:
i had posted earlier for not being able to declare global vars. No i
Post a followup in that thread then rather than starting a new one.
followed the suggestions and created a class, but still the vars do not
seem to have a global scope. I have tried pretty much everything. Any
advice appreciated... Here:
[snip mess]

What Guillaume C. meant is:

To make a variable that is assigned within a function global you have to
declare it global

def foo():
global x
x = 42
foo()
print x

but that having many of these globals is a bad design and you should
use instance attributes instead:

class A(object):
def foo(self):
self.x = 42
a = A()
a.foo()
print a.x

Personally, I often prefer

def foo():
return 42
x = foo()
print x

which is both explicit and concise.

These are basic considerations in Python, so I suggest that you read an
introductory text on the language before you proceed with your endeavours.

Peter
Sep 13 '07 #2

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

Similar topics

3
by: Sean Berry | last post by:
How do I rectify this? ------vars.py------ #!/usr/local/bin/python def setUserid(value): userid = value def getUserid():
13
by: David Rysdam | last post by:
Getting no answer yesterday, I've done some investigation and I obviously don't understand how python namespaces work. Here's a test program: #!/usr/bin/python b = 2 def sumWithGlobal(a):...
6
by: flamesrock | last post by:
ok, so to my knowledge, object oriented means splitting something into the simplest number of parts and going from there. But the question is- when is it enough? For example I have the following...
4
by: Kenny Ashton | last post by:
Hello gurus Can I ask you opions on the best compromise for storing Access Ado connection strings in a IIS4 standard ASP environment. For any method I use, there seems to be an article somewhere...
16
by: WaterBug | last post by:
When clicking on the following link from an email i.e - http://myserver/myapplication/myprogram.asp?urlvar1=some%20stuff&urlvar2=more%20stuff I get a server 500 error. With that same browser...
9
by: bettina | last post by:
I have the following piece of code (symplified) require("lang.{$lang}.inc.php"); // I include the inc. files .... function decodify($technique) { // functions that give me back the value in...
8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
4
by: pcaisse | last post by:
I'm having issues sharing global variables with Explorer. This problem probably has a simple answer (as with most newbie questions). The script.pl file: #!/usr/bin/perl -w use strict; use...
0
by: hadrien | last post by:
Hi! I'm working with Python and MySQL and I need two global vars for an entire module. These two vars would be the connector and the cursor of the current database and I need them to work...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.