Re: [Tutor] exit handler for C extension module

2010-01-18 Thread Shuying Wang
I found what I was after, right after I posted to this list. It's Py_AtExit. I'm accessing an old, unsupported database using it's C API. I've tried using Cython but found it hard to get my head around and I'm finding it somewhat easier to just write by hand. On Mon, Jan 18, 2010 at 6:40 PM, Stefa

[Tutor] exit handler for C extension module

2010-01-17 Thread Shuying Wang
Hi, What would be an atexit equivalent for a C extension module? When my extension module is unloaded, I would like some clean up functions to be called from an external c library. I've had a look at the C extension guide but I can't find anything like that, Thanks in advance, .S

[Tutor] self

2006-02-12 Thread Shuying Wang
Hi, I'm having problems understanding some code I came across: class Singleton: __single = None def __init__( self ): if Singleton.__single: raise Singleton.__single Singleton.__single = self What does passing self to Singleton.__single do? --Shuying

Re: [Tutor] putting instance variables into a dict

2006-01-30 Thread Shuying Wang
Hi, That's more or less what I want. Thanks! Now I just need to figure out metaclasses and poke around python's innards. :D --Shuying On 1/30/06, Danny Yoo <[EMAIL PROTECTED]> wrote: > It's an somewhat low-level detail that the attributes of a class instance > can be accessed through a special _

[Tutor] putting instance variables into a dict

2006-01-29 Thread Shuying Wang
Hi, So I've got a class X with instance variables a, b, c. Is there any way of creating a dictionary of these instance variables besides the no-brainer way of doing dictionary = {'a' : X.a, 'b' : X.b, 'c' : X.c} ? --Shuying ___ Tutor maillist - Tutor@

Re: [Tutor] I'm puzzled

2006-01-22 Thread Shuying Wang
I'm guessing when you did that, you got something like an IndexError. That's because you didn't check the length of "a" from raw_input and accessed a nonexistent array element (a string is an array of characters). So if you changed the line: elif a[0] == '-' and a[1:].isdigit(): to : elif len(a) >

Re: [Tutor] a class knowing its self

2006-01-18 Thread Shuying Wang
Ben, If you change example #b to: for s in SkillNames: skill = Skill() skill.setName(s) print skill.getName() You will find that the results are the same as #a. In your #b example, you are giving setName() the skill instance instead of the string you intended. --Shuying On 1/19/06, Be

Re: [Tutor] CGIXMLRPCRequestHandler doesn't actually work, does it?

2005-06-23 Thread Shuying Wang
I'm not sure what you're trying to do. But I run cgi scripts and make xmlrpc requests with xmlrpclib with a connection with xmlrpclib.Server(server_uri), though I'm only doing this client side. I'm not running the server as cgi. On 6/23/05, Ron Phillips <[EMAIL PROTECTED]> wrote: > > I believe I

[Tutor] not invoking the shell from python

2005-06-21 Thread Shuying Wang
Hi tutors, I've got an external program that I'm calling from python with os.popen. The problem is that I need to pass this program an arbitrary body of text. I've tried escaping characters before passing it as input but the shell still expands out certain characters. I noticed with python2.4. How

[Tutor] calling perl from python code

2005-06-20 Thread Shuying Wang
Hi, Can anyone recommend a library that will let me call perl functions from python? I have a python dictionary that I would like to convert to a perl hash for some function. cheers, Shuying ___ Tutor maillist - Tutor@python.org http://mail.python.org