Re: Python CTypes translation of (pv != NULL)

2006-09-28 Thread p . lavarre
Where did you find that? Quoted in full from the gift: Subject: Re: Python CTypes translation of (pv != NULL) Date: Tue, 26 Sep 2006 11:48:52 +0200 Message-ID: [EMAIL PROTECTED] http://groups.google.com/group/comp.lang.python/msg/f9f13e731ea3cad7 Cached and pondered just slightly before

Re: Python CTypes translation of (pv != NULL)

2006-09-28 Thread p . lavarre
Future Googlers might like this thread to end with the Thomas Heller's brief conclusive review: /// Copied 2006-09-28 from /// http://starship.python.net/crew/theller/moin.cgi/CodeSnippets 1.2 Check for NULL ctypes pointers The truth value of any NULL ctypes pointer instance is False. So, this

Re: Python CTypes translation of (pv != NULL)

2006-09-27 Thread p . lavarre
http://starship.python.net/crew/theller/ctypes/tutorial.html ... direct discussion only of how to construct null pointers, no discussion of how to test for them ... ... could be read to mean try ... == ... is ... False ... None ... CTypes nulls fetched from a struct feel more like None

Re: Python CTypes translation of (pv != NULL)

2006-09-27 Thread p . lavarre
It says: NULL pointers have a False boolean value: null_ptr = POINTER(c_int)() print bool(null_ptr) False Yes. That means that NULL pointers are considered False in a boolean expression (and you could assume that non-NULL pointers are True, as any other object in general), I see

Re: Python CTypes translation of (pv != NULL)

2006-09-27 Thread Thomas Heller
[EMAIL PROTECTED] schrieb: It says: NULL pointers have a False boolean value: null_ptr = POINTER(c_int)() print bool(null_ptr) False Yes. That means that NULL pointers are considered False in a boolean expression (and you could assume that non-NULL pointers are True, as any other

Re: Python CTypes translation of (pv != NULL)

2006-09-27 Thread Gabriel Genellina
At Wednesday 27/9/2006 13:40, [EMAIL PROTECTED] wrote: That means that NULL pointers are considered False in a boolean expression (and you could assume that non-NULL pointers are True, as any other object in general), I see this now that you show the clueless newbie me, yes thank you.

Re: Python CTypes translation of (pv != NULL)

2006-09-27 Thread Gabriel Genellina
At Wednesday 27/9/2006 13:35, [EMAIL PROTECTED] wrote: http://starship.python.net/crew/theller/ctypes/tutorial.html ... direct discussion only of how to construct null pointers, no discussion of how to test for them ... ... could be read to mean try ... == ... is ... False ... None ...

Re: Python CTypes translation of (pv != NULL)

2006-09-26 Thread Gabriel Genellina
At Monday 25/9/2006 21:27, [EMAIL PROTECTED] wrote: Q: The C idea of (pv != NULL) is said most directly in Python ctypes how? Perhaps reading the ctypes tutorial? (both in the 2.5 docs and in http://starship.python.net/crew/theller/ctypes/tutorial.html) Gabriel Genellina Softlab SRL

Re: Python CTypes translation of (pv != NULL)

2006-09-26 Thread Thomas Heller
[EMAIL PROTECTED] schrieb: Q: The C idea of (pv != NULL) is said most directly in Python ctypes how? A: We are of course supposed to write something like: def c_not_null(pv): return (ctypes.cast(pv, ctypes.c_void_p).value != None) Yes? Working from the doc,

Re: Python CTypes translation of (pv != NULL)

2006-09-26 Thread p . lavarre
Q: The C idea of (pv != NULL) is said most directly in Python ctypes how? Perhaps reading the ctypes tutorial? (both in the 2.5 docs and in http://starship.python.net/crew/theller/ctypes/tutorial.html) Actually, no. I see three answers or zero, depending on how you like to count. Yes that

Re: Python CTypes translation of (pv != NULL)

2006-09-26 Thread p . lavarre
Q: The C idea of (pv != NULL) ... CTypes tutorial ... == False ... == None ... is None ... Generally ... 'if pv: ' ... should work. Except for c_void_p, c_char_p and c_wchar_p instances. Please can we give me an example of these exceptions? Indeed those types are the _p types I

Re: Python CTypes translation of (pv != NULL)

2006-09-26 Thread Gabriel Genellina
At Tuesday 26/9/2006 16:00, [EMAIL PROTECTED] wrote: Q: The C idea of (pv != NULL) is said most directly in Python ctypes how? Perhaps reading the ctypes tutorial? (both in the 2.5 docs and in http://starship.python.net/crew/theller/ctypes/tutorial.html) Actually, no. I see three answers

Python CTypes translation of (pv != NULL)

2006-09-25 Thread p . lavarre
Q: The C idea of (pv != NULL) is said most directly in Python ctypes how? A: We are of course supposed to write something like: def c_not_null(pv): return (ctypes.cast(pv, ctypes.c_void_p).value != None) Yes? Working from the doc, me the clueless newbie, I was slow to