Re: Need help fixing this error please:NameError: global name is not defined

2012-09-06 Thread shaun
Hi Chris, I'm changing it into multiple classes because the script is going to get much larger its more for maintainability reasons rather than functionality reasons. Thanks so much man it was the "self" fix you stated above. I woe you a pint of Guinness :D Thanks again,

Setting up a class

2012-09-06 Thread shaun
this is to do with "self" but im not too sure?? Any help would be appreciated. Thanks, Shaun -- http://mail.python.org/mailman/listinfo/python-list

Re: Need help fixing this error please:NameError: global name is not defined

2012-09-06 Thread shaun
This is the code in the script im calling: batchObject=StringCall() batchObject.databasebatchcall(termid, batchid) batchObject.fetchbatchdata() batchObject.createbatchstrings() BatchHeaderPacket =batchObject.returnbatchheader() ParameterPacket =batchObject.returnparameterpacket() TrailerPacket =

Re: Need help fixing this error please:NameError: global name is not defined

2012-09-06 Thread shaun
Sorry guys here is the full code for the class: #!/usr/bin/python # Echo client program import cx_Oracle import socket import pprint from struct import * import sys from binascii import * import time import datetime class StringCall: results=[] def databasebatchcall(self,termid,

Need help fixing this error please:NameError: global name is not defined

2012-09-06 Thread shaun
ea about this any help would be appreciated // File "/home/dcroke/mdcFDACStringCall.py", line 21, in fetchbatchdata results = cur.fetchall() NameError: global name 'cur' is not defined ///////

Re: Objects in Python

2012-08-22 Thread shaun
cx_Oracle.connect('databaseInfo') cur = con.cursor() cur.execute("SELECT * FROM SOME_TABLE)) results = cur.fetchall() batchParam(results) Batch=batchParam.returnBatch print Batch cur.close() // Thanks, Shaun -- http://mail.python.org/mailman/listinfo/python-list

Re: Dictionary with Lists

2009-10-04 Thread Shaun
Okay that makes sense. I was assuming that list.append returned the new list. thanks -- http://mail.python.org/mailman/listinfo/python-list

Dictionary with Lists

2009-10-03 Thread Shaun
ict testDict [1] = testDict.get (1, []).append ("Test1") print testDict (Obviously I wouldn't normally write code like this.. but this is how it would unfold in a loop) However, the first printout gives {1: None} instead of the desired {1: ['test']}. What'

different behaviour for user defined exception with attribute args

2009-09-29 Thread Visco Shaun
Hi all For an exception defined as below class OptionError(Exception): def __init__(self, args): self.args = args def __str__(self): return repr(self.v) an iteration is happening when the exception is raised Meanwhile for almost the same structured exception replacing th

"TypeError: 'int' object is not callable"

2009-06-01 Thread Visco Shaun
when I was executing the below code I got "TypeError: 'int' object is not callable" exception. Why is it so? if type(c) == type(ERROR): c can be a string or an integer representing an error -- Thanks & Regards visco -- http://mail.python.org/mailman/listinfo/python-list

Any adv. in importing a module and some objects in the same module, into the same file?

2009-04-18 Thread Visco Shaun
http://docs.python.org/library/logging.html While going thr' the above link i came across import statements "import logging import logging.handlers" What is the use of second import as the first import will be enough(AFAIK) to access anything intended by the second import? Is there any kind of a

how to know the importing file name from an imported file?

2009-04-17 Thread Visco Shaun
Hi Is there a way to know the name of the script(say A), which is importing a module(say B), from B? ie in above situation i should be able to get name 'A' through some way in B, when A contains an 'import B' statement. -- Thanks & Regards visco -- http://mail.python.org/mailman/listinfo/python-

Re: to get name of file opened

2009-03-28 Thread Visco Shaun
First of all Thanks Dave for the reply On Sat, 2009-03-28 at 09:51 -0500, Dave Angel wrote: > First question is why you need os.open(), and not the open() function. > I'll guess that you need some of the access modes (e.g. for file > sharing) that you get from the low level functions. So assumi

difference between os.fdopen and builtin open

2009-03-28 Thread Visco Shaun
Hi I was wondering the difference between os.fdopen()(or os.open() not considering the difference in args) and builtin open(). Can anyone help me? -- Thanks & Regards visco -- http://mail.python.org/mailman/listinfo/python-list

to get name of file opened

2009-03-28 Thread Visco Shaun
Hi Is there any way to get the name of the file opened from the file object 'f' which i get through the code f = os.fdopen(os.open("trial', os.O_WRONLY|os.O_CREAT), "w") The situation will be like i can access only the above variable 'f'. f.name is having '' instead of filename 'trial' Or if n

subprocess module: execution of standard binaries without shell?

2009-02-26 Thread Visco Shaun
hi all while getting used to with subprocess module i failed in executuing a) but succeeded in running b). Can anyone explain me why as i am providing absolute path? Is this has to do anything with shared library.. which must be accessed based on system variables? a) pipe = subprocess.Popen("/bi

Re: overload builtin operator

2005-08-26 Thread Shaun
rsing the expression string myself and checking for divide by zero I can't find another way to solve the problem. Hopefully someone out there has some ideas. Thanks, Shaun. -- http://mail.python.org/mailman/listinfo/python-list

overload builtin operator

2005-08-25 Thread Shaun
rator operator.__div__ = safediv The operator.__dict__ seems to be updated OK but the '/' operator still calls buildin __div__ Does anyone know if this is possible and if I'm going along the correct path with my attempts above? Is it possible to do this using a C extent

Noobie Question: Using strings and paths in mkdir (os.mkdir("/test/"a))

2005-04-22 Thread Shaun
I also tried: os.mkdir("/test/",a), and trying to make b = 'test' and then os.mkdir(a b). Does someone have any ideas or a link they can give me, I looked under strings in the python tutorial and library manual but I guess not in the right spot. Thanks for your help! Shaun -- http://mail.python.org/mailman/listinfo/python-list