Eric Walker wrote: > Sorry Kent, > In my haste to just simulate I did make the example with syntax errors. Let > me > try this again and I guess your teaching me how to use this mailing list the > correct way also.
Yes. > Ok this is the actual code. I am able to get it to run > from the command line. > > Thanks kent for your patience with this Python Newbie.... You're welcome. A few notes below. > > class TPROJ: > import re > import string Common usage is to put all the imports at the top of the module. There are circumstances where you will put them inside a function but not in this case. > def display(self):#display method > print self.BASENAME > print self.PROJECT > print self.REV > print self.DESIGNATOR > print self.TYPE It's your choice, but all caps for attribute values is unusual in Python. > > def __init__(self,value):#createMethod auto executes since it has __ > name = nameCheck(value) My guess is that nameCheck is the function that you moved out of the class. If you want it to be part of the class, you have to call it with self.nameCheck(value) > if name: > self.BASENAME = value > self.PROJECT = value.split(':')[0] > self.REV = value.split(':')[1] > self.DESIGNATOR = "NOVALUE" > self.TYPE = ('SW','TMOD','SWA','TMODA')#constant tuple > if not name: could be else: > print "found a bad name: %s" % value > > > > def nameCheck(value):#checks to see if filename is valid. Has a colon for > split To put this in the class you would declare it as def nameCheck(self, value): > import re > tempREG = re.match('.*:.*',value) > return str(tempREG) != 'None' Still a syntax error here! > > def getProjectNames(): > import os > currentDir=os.getcwd() > nameTable = {} > temp=currentDir + '/TEMP' > print temp > os.chdir(temp) > baseList=os.listdir(".") > baseObjectList = [] > for name in baseList: > baseObjectList.append(TPROJ(name)) > > os.chdir(currentDir) > for item in baseObjectList: > print item.BASENAME > > > try: > getProjectNames() > except: > print "Got an Error" Still recommend removing this try / except. Or you could wait until you actually get an exception and ask here for help ;-) cuz we will ask you for the traceback. Kent _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor