Re: i want to know about python language

2013-11-06 Thread Kewl p
On Thursday, November 7, 2013 8:48:26 AM UTC+5:30, Kewl p wrote: > h thanks very much -- https://mail.python.org/mailman/listinfo/python-list

Re: i want to know about python language

2013-11-06 Thread Kewl p
On Thursday, November 7, 2013 8:48:26 AM UTC+5:30, Kewl p wrote: > h can i get link of a ide in which python can run,,...?? -- https://mail.python.org/mailman/listinfo/python-list

tarfile vs zipfile

2015-03-02 Thread Seth P
Is there a reason tarfile and zipfile don't use the same method/member names, where it makes sense? Consider the following six methods/members, which I would expect to be the same (with the possible exception of mtime vs date_time, which are of different types). It almost seems like someone we

Re: want to learn python

2015-04-24 Thread Tom P
On 04/21/2015 12:57 PM, pm05...@gmail.com wrote: Hello everyone, I am willing to learn Python from scratch.Please he me to learn.Although I hv knowledge of c and object oriented programming. Apart from the various tutorials you might want to look at the on-line courses offered by Coursera a

Classic OOP in Python

2015-06-17 Thread Jason P.
Hello Python community. I come from a classic background in what refers to OOP. Mostly Java and PHP (> 5.3). I'm used to abstract classes, interfaces, access modifiers and so on. Don't get me wrong. I know that despite the differences Python is fully object oriented. My point is, do you know an

Re: Classic OOP in Python

2015-06-18 Thread Jason P.
El miércoles, 17 de junio de 2015, 21:44:51 (UTC+2), Ned Batchelder escribió: > On Wednesday, June 17, 2015 at 3:21:32 PM UTC-4, Jason P. wrote: > > Hello Python community. > > > > I come from a classic background in what refers to OOP. Mostly Java and PHP > > (&

Re: Classic OOP in Python

2015-06-18 Thread Jason P.
El miércoles, 17 de junio de 2015, 21:44:51 (UTC+2), Ned Batchelder escribió: > On Wednesday, June 17, 2015 at 3:21:32 PM UTC-4, Jason P. wrote: > > Hello Python community. > > > > I come from a classic background in what refers to OOP. Mostly Java and PHP > > (&

Re: Classic OOP in Python

2015-06-18 Thread Jason P.
El miércoles, 17 de junio de 2015, 22:39:31 (UTC+2), Marko Rauhamaa escribió: > Ned Batchelder : > > > TDD is about writing tests as a way to design the best system, and > > putting testing at the center of your development workflow. It works > > great with Python even without interfaces. > > I

Noob in Python. Problem with fairly simple test case

2015-07-15 Thread Jason P.
Hi all! I'm working in a little Python exercise with testing since the beginning. So far I'm with my first end to end test (not even finished yet) trying to: 1) Launch a development web server linked to a demo app that just returns 'Hello World!' 2) Make a GET request successfully I can't un

Re: Noob in Python. Problem with fairly simple test case

2015-07-21 Thread Jason P.
El miércoles, 15 de julio de 2015, 14:12:08 (UTC+2), Chris Angelico escribió: > On Wed, Jul 15, 2015 at 9:44 PM, Jason P. wrote: > > I can't understand very well what's happening. It seems that the main > > thread gets blocked listening to the web server. My intent

problem with netCDF4 OpenDAP

2015-08-13 Thread Tom P
I'm having a problem trying to access OpenDAP files using netCDF4. The netCDF4 is installed from the Anaconda package. According to their changelog, openDAP is supposed to be supported. netCDF4.__version__ Out[7]: '1.1.8' Here's some code: url = 'http://www1.ncdc.noaa.gov/pub/data/cmb/ersst/

Re: problem with netCDF4 OpenDAP

2015-08-14 Thread Tom P
On 08/13/2015 05:55 PM, Jason Swails wrote: On Thu, Aug 13, 2015 at 6:32 AM, Tom P mailto:werot...@freent.dd>> wrote: I'm having a problem trying to access OpenDAP files using netCDF4. The netCDF4 is installed from the Anaconda package. According to their changelog,

Re: problem with netCDF4 OpenDAP

2015-08-14 Thread Tom P
On 08/14/2015 03:15 PM, Jason Swails wrote: On Aug 14, 2015, at 3:18 AM, Tom P wrote: Thanks for the reply but that is not what the documentation says. http://unidata.github.io/netcdf4-python/#section8 "Remote OPeNDAP-hosted datasets can be accessed for reading over http if a UR

Re: Nearest neighbours of points

2015-10-31 Thread Tom P
On 10/24/2015 10:05 PM, Poul Riis wrote: I have N points in 3D, organized in a list. I want to to point out the numbers of the two that have the smallest distance. With scipy.spatial.distance.pdist I can make a list of all the distances, and I can point out the number of the minimum value of th

Re: TextBlob on Windows

2014-07-04 Thread selvaperumal . p
On Saturday, 24 May 2014 04:45:14 UTC+5:30, subhaba...@gmail.com wrote: > Dear Group, > > > > It seems there is a nice language processing library named TextBlob, like > NLTK. > > But I am being unable to install it on my Windows(MS-Windows 7 machine. I am > using Python 2.7 > > > > If a

Reporting and data stats help

2014-07-31 Thread James P
I'm building a report builder for my Django app and could use a little advice. My reports are fairly simple where I accumulate scores of data (easy enough) but then I want to alter the report totals by varying dimensions (date ranges / split dates/weeks/months / owners / other metadata etc.). Si

Re: Python code in presentations

2014-09-30 Thread Tom P
On 30.09.2014 13:50, Jean-Michel Pichavant wrote: Hello list, I'm currently writing a presentation to help my co-workers ramp up on new features of our tool (written in python (2.7)). I have some difficulties presenting code in an efficient way (with some basic syntax highlights). I need to b

Re: Controlling number of zeros of exponent in scientific notation

2013-03-06 Thread Russ P.
One possibility is to form the string as usual, split on the "e", format each part separately, then rejoin with an "e". On Tuesday, March 5, 2013 12:09:10 PM UTC-8, fa...@squashclub.org wrote: > Instead of: > > > > 1.8e-04 > > > > I need: > > > > 1.8e-004 > > > > So two zeros before t

Re: The usage of -m option of python

2013-03-27 Thread Tom P
On 03/18/2013 10:17 PM, Peng Yu wrote: Hi, I don't quite understand how -m option is used. And it is difficult to search for -m in google. Could anybody provide me with an example on how to use this option? Thanks! -m module-name Searches sys.path for the named module and

HTTPserver: how to access variables of a higher class?

2013-04-05 Thread Tom P
First, here's a sample test program: import sys from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler class MyRequestHandler(BaseHTTPRequestHandler, object): def do_GET(self): top_self = super(MyRequestHandler, self) # try to access MyWebServer instance self.send_re

Re: HTTPserver: how to access variables of a higher class?

2013-04-05 Thread Tom P
On 04/05/2013 02:27 PM, Dylan Evans wrote: On 05/04/2013 9:09 PM, "Tom P" wrote: First, here's a sample test program: import sys from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler class MyRequestHandler(BaseHTTPRequestHandler, object): def do_GET(self):

Re: HTTPserver: how to access variables of a higher class?

2013-04-05 Thread Tom P
On 04/05/2013 01:54 PM, Dave Angel wrote: On 04/05/2013 07:02 AM, Tom P wrote: First, here's a sample test program: import sys from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler class MyRequestHandler(BaseHTTPRequestHandler, object): def do_GET(self): top_self =

Re: HTTPserver: how to access variables of a higher class?

2013-04-05 Thread Tom P
On 04/05/2013 01:54 PM, Dave Angel wrote: On 04/05/2013 07:02 AM, Tom P wrote: First, here's a sample test program: import sys from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler class MyRequestHandler(BaseHTTPRequestHandler, object): def do_GET(self): top_self =

Re: HTTPserver: how to access variables of a higher class?

2013-04-06 Thread Tom P
On 04/05/2013 02:27 PM, Dylan Evans wrote: On 05/04/2013 9:09 PM, "Tom P" wrote: First, here's a sample test program: import sys from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler class MyRequestHandler(BaseHTTPRequestHandler, object): def do_GET(self):

Re: The SOLUTION HTTPserver: how to access variables of a higher class

2013-04-06 Thread Tom P
On 04/05/2013 01:02 PM, Tom P wrote: ok, after much experimenting it looks like the solution is as follows: class MyWebServer(object): def __init__(self): # self.foo = "foo" delete these from self # self.bar = "bar" myServer = HTTPServer

HTTPServer again

2013-04-22 Thread Tom P
Hi, a few weeks back I posed a question about passing static data to a request server, and thanks to some useful suggestions, got it working. I see yesterday there is a suggestion to use a framework like Tornado rather than base classes. However I can't figure achieve the same effect using To

Re: Cool Ebooks Site

2006-07-13 Thread Michael P.
Hey, pretty impressive list. I downloaded a few myself. -- http://mail.python.org/mailman/listinfo/python-list

doctest quiet again before exit how

2006-10-16 Thread p . lavarre
Looks like every run of doctest after the first is verbose: $ python2.5 quiet-once.py (0, 0) *** DocTestRunner.merge: '__main__' in both testers; summing outcomes. (0, 0) *** DocTestRunner.merge: '__main__' in both testers; summing outcomes. (0, 0) $ $ cat quiet-once.py import doctest print doctes

Re: doctest quiet again before exit how

2006-10-18 Thread p . lavarre
> ... every run of doctest after the first is verbose ... > *** DocTestRunner.merge: '__main__' in both testers; summing outcomes. Another path to the same bug: import doctest print doctest.testfile(__file__, verbose=False) print doctest.testfile(__file__, verbose=False) Mystifiedly yours, rank

Re: Win32 python and excel macros

2006-10-18 Thread Mike P
Thanks for your advice on this matter, I'm actually using Excel 2003!! so it shows how much i know! i did manage to get the prog to run with the line xl.Application.Run("CTP.xla!sheet1.CTP") but it didn't do anything... i'm guessing it is along the lines of wht you were saying earlier about big

Re: Win32 python and excel macros

2006-10-18 Thread Mike P
After just running trying that update it hits the macro perfectly but hten i get an error message after i type in a couple of values.. as per below Traceback (most recent call last): File "", line 148, in ? File ">", line 14, in Run File "C:\Python24\Lib\site-packages\win32com\client\dynamic

call Mac gcc -framework from CTypes how

2006-10-18 Thread p . lavarre
gcc -dynamiclib -framework CoreFoundation builds C code for Mac OS X that I call from Py code. Can I somehow get rid of the C, such as: #include void const * kCFTypeDictionaryKeyCallBacks_p(void) { return &kCFTypeDictionaryKeyCallBacks; } ? Thanks in advance, Pat LaVarre P.S. In Windo

Re: call Mac gcc -framework from CTypes how

2006-10-25 Thread p . lavarre
> can I somehow call the IONotificationPortCreate in the > Framework that Apple built instead, $ cd /System/Library/Frameworks/ $ cd IOKit.framework/Versions/Current/ $ file IOKit ... Mach-O dynamically linked shared library ... $ nm -m IOKit | grep IONotificationPortCreate ... (__TEXT,__text) ext

FAQ - How do I declare that a CTypes function returns void?

2006-10-25 Thread p . lavarre
Now at http://pyfaq.infogami.com/suggest we have: FAQ: How do I declare that CTypes function returns void? A: c_void = None is not doc'ed, but is suggested by: >>> ctypes.POINTER(None) >>> Remembering c_void = c_int from K&R C often works, but if you say a restype is c_int, then doctest's of th

FAQ - How do I declare that a CTypes function returns unsigned char?

2006-10-25 Thread p . lavarre
Now at http://pyfaq.infogami.com/suggest we have: FAQ: How do I declare that a CTypes function returns unsigned char? A: c_uchar = ctypes.c_ubyte This irregularity actually is doc'ed, it's just pointlessly annoying. Hope this helps (and of course I trust you'll dispute if I'm nuts), -- http:/

Re: call Mac gcc -framework from CTypes how

2006-10-25 Thread p . lavarre
> > can I somehow call the IONotificationPortCreate in the > > Framework that Apple built instead, > > $ cd /System/Library/Frameworks/ > $ cd IOKit.framework/Versions/Current/ > $ file IOKit Also ctypes.util.find_library('CoreFoundation') -- http://mail.python.org/mailman/listinfo/python-list

pack a three byte int

2006-11-08 Thread p . lavarre
Can Python not express the idea of a three-byte int? For instance, in the working example below, can we somehow collapse the three calls of struct.pack into one? >>> import struct >>> >>> skip = 0x123456 ; count = 0x80 >>> >>> cdb = '' >>> cdb += struct.pack('>B', 0x08) >>> cdb += struct.pack('>I

Re: pack a three byte int

2006-11-09 Thread p . lavarre
> Not as concisely as a one-byte struct code Help, what do you mean? > you presumably... read... the manual ... Did I reread the wrong parts? I see I could define a ctypes.Structure since 2.5, but that would be neither concise, nor since 2.3. > when 24-bit machines become ... popular Indeed t

Re: pack a three byte int

2006-11-09 Thread p . lavarre
> > > cdb0 = '\x08' '\x01\x23\x45' '\x80' '\0' > > > > cdb = '' > > cdb += struct.pack('>B', 0x08) > > cdb += struct.pack('>I', skip)[-3:] > > cdb += struct.pack('>BB', count, 0) > > The change from [-3:] to [1:] is a minor cosmetic improvement, Ouch, [1:] works while sizeof I is 4, yes, but that'

Re: pack a three byte int

2006-11-09 Thread p . lavarre
> Help, what did you mean by the question? How does Python express the idea: i) Produce the six bytes '\x08' '\x01\x23\x45' '\x80' '\0' at run-time when given the tuple (0x08, 0x12345, 0x80, 0). ii) Produce the six bytes '\x12' '\0\0\0' '\x24' '\0' when given the tuple (0x12, 0, 0x24, 0). iii)

Re: pack a three byte int

2006-11-09 Thread p . lavarre
> "struct" == "Python struct module" > > Struct module has (concise) codes B, H, I, Q for unsigned integers of > lengths 1, 2, 4, 8, but does *not* have a code for 3-byte integers. I thought that's what the manual meant, but I was unsure, thank you. > > > 1. Not as concisely as a one-byte struct

Re: pack a three byte int

2006-11-09 Thread p . lavarre
> > when talking the 1960's lingo > > ... > > X12Inquiry = 0x12 > > xxs = [0] * 6 > > xxs[0] = X12Inquiry > > xxs[4] = allocationLength > > rq = ''.join([chr(xx) for xx in xxs]) > > It looks wrong (and a few other adjectives), Ah, we agree, thank you for saying. > Looks like little-endian 4-byte

Re: pack a three byte int

2006-11-09 Thread p . lavarre
Speaking as the OP, perhaps I should mention: > > [-3:] to [1:] is a minor cosmetic improvement To my eye, that's Not an improvement. '\x08' '\x01\x23\x45' '\x80' '\0' is the correct pack of (0x08, 0x12345, 0x80, 0) because '\x01\x23\x45' are the significant low three bytes of a big-endian x1234

Re: pack a three byte int

2006-11-09 Thread p . lavarre
Perhaps Python can't concisely say three-byte int ... But Python can say six-nybble hex: >>> import binascii >>> cdb = binascii.unhexlify('%02X%06X%02X%02X' % (0x08, 0x12345, 0x80, 0)) >>> binascii.hexlify(cdb) '080123458000' >>> Thanks again for patiently helping me find this. A shortcut is:

Re: pack a three byte int

2006-11-09 Thread p . lavarre
> > ... Python can say six-nybble hex: > > > > >>> import binascii > > >>> cdb = binascii.unhexlify('%02X%06X%02X%02X' % (0x08, 0x12345, 0x80, 0)) > > >>> binascii.hexlify(cdb) > >'080123458000' > > The only problem I can see is that this code is endianness-dependent; > the suggested versions using

to Doctest as SystemExit is to Python

2006-11-09 Thread p . lavarre
> From: http://docs.python.org/lib/doctest-soapbox.html ... > Regression testing is best confined to dedicated objects or files ... Can I somehow tell doctest that it's time to quit? I ask because not all doctest examples are created equal. Some failures are catastrophic, making all subsequent f

Re: how is python not the same as java?

2006-11-09 Thread p . lavarre
Jython exists. -- http://mail.python.org/mailman/listinfo/python-list

announce: FAQs suggested

2006-11-10 Thread p . lavarre
http://effbot.org/pyfaq/suggest.htm has new FAQ's: FAQ: How do I ask to exit from a doctest FAQ: How do I say unsigned char in ctypes? FAQ: How do I say returns void in ctypes? FAQ: How do I calculate what quoted strings and numbers mean? Enjoy, Pat LaVarre -- http://mail.python.org/mailman/lis

Re: announce: FAQs suggested

2006-11-10 Thread p . lavarre
> > > http://effbot.org/pyfaq/suggest.htm > > FAQ: How do I say returns void in ctypes? > That's in the ctypes documentation, where it belongs. Thank you, before I never had found "Use None for void a function not returning anything" at: http://starship.python.net/crew/theller/ctypes/reference.htm

FAQ: How do I calculate what quoted strings and numbers mean?

2006-11-10 Thread p . lavarre
> Subject: announce: FAQs suggested ... > http://effbot.org/pyfaq/suggest.htm has new FAQ's ... > FAQ: How do I calculate what quoted strings and numbers mean? > > A: eval(source, {'builtins': {}}) works, without also accidentally > accepting OS commands as input. > > Note: Eval might surprise you

Re: announce: FAQs suggested

2006-11-10 Thread p . lavarre
> > > > http://effbot.org/pyfaq/suggest.htm > > > FAQ: How do I say returns void in ctypes? > > That's in the ctypes documentation, where it belongs. > > Thank you, before I never had found "Use None for void a function not > returning anything" at: > http://starship.python.net/crew/theller/ctypes/

Re: announce: FAQs suggested

2006-11-10 Thread p . lavarre
Thanks again for making time to comment - insights into the perspective of the author are invaluable. But if by chance you have time to continue: > > > http://effbot.org/pyfaq/suggest.htm > > http://docs.python.org/dev/lib/ctypes-return-types.html > A note could probably be added to this section.

Re: to Doctest as SystemExit is to Python

2006-11-10 Thread p . lavarre
(((I thought I had sent this reply already, Google says No.))) > > Can I somehow tell doctest that it's time to quit? > > ... doctest redefines ... SystemExit ... > > Hit Ctrl-C. Or raise a KeyboardInterrupt: Yes! Thank you!!! I see now, Doctest exactly reverses the python -i experience:

Re: FAQ: How do I calculate what quoted strings and numbers mean?

2006-11-15 Thread p . lavarre
> A FAQ that discusses good ways to handle Python-like literals and > expressions would definitely be a useful addition to the FAQ. if nobody > else does anything about it, I'll get there sooner or later. Thank you. > > eval(source, {'builtins': {}}) works enough like an evaluator of > > liter

Tkinter Problems on MAC OS 10.3.9 & python2.5

2006-11-16 Thread Thomas P.
Hello folks, my name is Thomas, and I am new to this newsgroup. So first I want to say hello. :-) ...done! Now, I have a problem concerning my new python2.5 install. With python2.3 and 2.4, Tkinter was no problem. Now, when I try to import it, the folowing happens: iPimpG4:~/Python-Dev/example

shlex.split != shlex.shlex get_token til eof

2006-09-22 Thread p . lavarre
How can I instantiate shlex.shlex to behave like shlex.split does? I see shlex.split gives me what I want: import shlex print shlex.split("1.2e+3")[0] # 1.2e+3 But every doc'ed instantiation of shlex.shlex surprisingly gives me something else: s1 = shlex.shlex("1.2e+3", None, False) pr

Re: shlex.split != shlex.shlex get_token til eof

2006-09-22 Thread p . lavarre
> shlex.split gives me what I want ... > every doc'ed instantiation of shlex.shlex ... gives me something else ... Aye, the discrepancies are gross & legion - presumably astonishing only newbies like me. Here's a more dramatic example: >>> import shlex >>> shlex.split("//./PhysicalDrive9 //./Cdr

Re: help with debugging a ctypes problem

2006-09-23 Thread p . lavarre
> help figuring out how to debug ... ctypes ... > a commercial dll. A certain function takes five arguments, foo(a, b, c, d, > e). > Can I view the appropriate stack? ... Any other ideas or advice? etc? Did you call the foo of _cdecl ctypes.cdll or the foo of _stdcall = ctypes.windll? What is

Re: Reverse a String?

2006-09-23 Thread p . lavarre
That 'foo'[::-1] is the Python reverse string idiom I'll try here forward, thanks. Also '.h.e.l.l.o'[1::2] to pick out every second char, etc., thanks. Three footnotes: 1) Reverse string isn't yet in http://www.python.org/doc/faq/ 2) Google Groups searches here yesterday instead pushed me towar

Re: Reverse a String?

2006-09-24 Thread p . lavarre
> http://pyfaq.infogami.com/ Tell me more? Clueless newbie me, thru this door I'm at three deaths and counting. Does that Py Faq Wiki have a sandbox a la alt.test, and/or a tutorial? // Death One: http://pyfaq.infogami.com/_account/in?path=/ requires me to create a persisting ID "between 3 and

Re: ruby %w equivalent

2006-09-24 Thread p . lavarre
> is there a python equivalent for the ruby %w operator? > %w{a b c} creates an array with strings "a", "b", and "c" in ruby... The expression 'a b c'.split() creates the ['a', 'b', 'c'] list of str, if that helps. Also dir('a b c') briefly lists much of what http://docs.python.org/lib/string-met

Re: Reverse a String?

2006-09-25 Thread p . lavarre
> http://pyfaq.infogami.com/suggest > is the "right" place to submit new entries. Thanks for sharing the secret. Now there I have added: "Q: How can I reverse a string, an array, a list, etc." And to share our secret with future newbies, to http://pyfaq.infogami.com/ I've added the suggestion:

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 gu

Re: shlex.split != shlex.shlex get_token til eof

2006-09-25 Thread p . lavarre
> I see shlex.split gives me what I want ... > shlex.shlex surprisingly gives me something else ... > I can get closer ... by hacking ... > .wordchars += ".+-" Kindly offline I was told, Try patching .whitespace_split = True instead. Compare: shlex.split("//./PhysicalDrive9 //./Cdrom9 //./Tape9

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 > ) Actually, no. I see three answers or zero, depending on how you like to count. Y

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

Re: shlex.split != shlex.shlex get_token til eof

2006-09-26 Thread p . lavarre
Kindly offline the answer is: (a) Python installation usually includes source, and thus (b) UTSL: $ pwd C:\Python25\Lib\shlex.py $ ... $ pwd /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5 $ grep -A 5 "def split" shlex.py def split(s, comments=False): lex = shlex(s, posix=True

Re: shlex.split != shlex.shlex get_token til eof

2006-09-26 Thread p . lavarre
Correspondingly, to the Faq Wiki I added: /// http://pyfaq.infogami.com/installed-index Q: Where is Python installed on my machine? A: Binaries in bin/, source in lib/, doc somewhere else. Read the module source when you find its doc incomplete. On Linux, ... On the Mac, straight from Apple: /

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 No

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 gener

ctypes.c_void_p(-1) might not be C return (void *) -1

2006-09-28 Thread p . lavarre
> Subject: Python CTypes translation of (pv != NULL) And so then the next related Faq is: Q: How should I test for ((void *) -1)? A: (pv == 0x) works often. (ctypes.cast(pv, ctypes.c_void_p).value == 0x) works better. ((void *) -1) appears often in 32-bit Windows, behind the n

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 the

eval(source, {'builtins': {}}) archived as Faq

2006-09-28 Thread p . lavarre
Absent from http://www.python.org/doc/current/lib/built-in-funcs.html but now copied to the Faq list of http://pyfaq.infogami.com/suggest, from these clp archives: /// Q: How can I tell Python to calculate what quoted strings and numbers mean, without also accidentally accepting OS commands as in

Re: ctypes.c_void_p(-1) might not be C return (void *) -1

2006-09-28 Thread p . lavarre
> I've started a wiki page where I already added an entry about the above > question. > Do you think the entry would have answered your question? > http://starship.python.net/crew/theller/moin.cgi/CodeSnippets As concise as I now can imagine, yes thank you. I see the main point leads: "The truth

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

SAX2 Download

2006-11-28 Thread Mike P
Does anyone know where i can download acopy of the SAX2 module? Cheers Mike -- http://mail.python.org/mailman/listinfo/python-list

Re: SAX2 Download

2006-11-28 Thread Mike P
Fredrik Lundh wrote: > Mike P wrote: > > > Does anyone know where i can download acopy of the SAX2 module? > > the built-in xml.sax module implements the SAX 2 protocol, if that's > what you're looking for: > > http://docs.python.org/lib/module-xml.sax

win32 com problem

2006-12-05 Thread Mike P
I've got a slight problem when running an excel macro from python using the win32.com.client module, in that it says it can't load the DLL file (it doesn't say which one) and gives me the following error message Traceback (most recent call last): File "", line 93, in ? File ">", line 14, in R

Re: win32 com problem

2006-12-05 Thread Mike P
Thanks for the quick reply, the code i am running is the following import win32com.client xl = win32com.client.Dispatch("Excel.Application") ppt = win32com.client.Dispatch("PowerPoint.Application") ppt.Visible = 1 #open MS Powerpoint xl.Visible = 1 #open MS Excel xl.Workbooks.Open('%s/working_out

Re: win32 com problem

2006-12-05 Thread Mike P
No Problem, Thanks for your help so far, i've sent this problem off to SPSS as it seems it doesn't work on a work colleagues machine either Thanks for your time though Mike -- http://mail.python.org/mailman/listinfo/python-list

Need help in Python Wrapper for EWFAPI from XPe

2006-03-02 Thread P Boy
I am trying to build a wrapper for the EWFAPI running on XPe. My first attempt was to use SWIG, but run to trouble with all these windows types such as WCHAR, DWORD, LPWSTR, ... I then searched further and found out about the ctypes module. However, some functions returns pointer to struct in ewfa

Re: newbie question

2006-03-03 Thread P Boy
Since you are a Windows user, I strongly recommend that you install activestate python instead of the one you download from python.org. The PythonWin from active state is much more user friendly. It's basically an IDE (integrated development environment), which includes interactive shell, editor, d

Re: Question

2006-03-03 Thread P Boy
You may want to read up on http://python.org/doc/faq/installed.html -- http://mail.python.org/mailman/listinfo/python-list

Re: string stripping issues

2006-03-03 Thread P Boy
This seems like a web page parsing question. Another approach can be as follows if you know the limiting token strings: a.split('')[1].split('\r\n')[0] -- http://mail.python.org/mailman/listinfo/python-list

Re: slicing the end of a string in a list

2006-03-03 Thread P Boy
One liners are cool. Personally however, I would not promote one liners in Python. Python code is meant to be read. Cryptic coding is in perl's world. Code below is intuitive and almost a three year old would understand. for line in open('C:\\switches.txt'): print line.rstrip() BTW, if t

Re: slicing the end of a string in a list

2006-03-03 Thread P Boy
I had some issues while ago trying to open a large binary file. Anyway, from file() man page: If mode is omitted, it defaults to 'r'. When opening a binary file, you should append 'b' to the mode value for improved portability. (It's useful even on systems which don't treat binary and text files

FAQ: how to vary the byte offset of a field of a ctypes.Structure

2007-05-31 Thread p . lavarre
How do I vary the byte offset of a field of a ctypes.Structure? How do I "use the dynamic nature of Python, and (re-)define the data type after the required size is already known, on a case by case basis"? \\\ For example, suppose sometimes I receive the value '\x03hi' + \x04bye' for the struct:

Re: FAQ: how to vary the byte offset of a field of a ctypes.Structure

2007-05-31 Thread p . lavarre
ctypes.sizeof(a) is still zero, as if ctypes.Structure.__init__ fetches a.__class__._fields_ rather than a._fields_ -- http://mail.python.org/mailman/listinfo/python-list

Re: FAQ: how to vary the byte offset of a field of a ctypes.Structure

2007-05-31 Thread p . lavarre
""" Thomas, Ouch ouch I must have misunderstood what you meant by "use the dynamic nature of Python, and (re-)define the data type after the required size is already known, on a case by case basis". Do you have an example of what you meant? I searched but did not find. Are those your words? Yes,

Re: FAQ: how to vary the byte offset of a field of a ctypes.Structure

2007-05-31 Thread p . lavarre
I see that changing self._fields_ doesn't change ctypes.sizeof(self). I guess ctypes.Structure.__init__(self) fetches self.__class__._fields_ not self._fields_. -- http://mail.python.org/mailman/listinfo/python-list

Re: FAQ: how to vary the byte offset of a field of a ctypes.Structure

2007-06-01 Thread p . lavarre
> Often it helps to ask yourself the question: How would I do this in C? ... > > *Not* by using a structure. A structure is fine if the definition is fixed, > or at most has *one* variable sized field at the very end. http://docs.python.org/lib/module-pickle.html might be near where I'll find conc

Re: FAQ: how to vary the byte offset of a field of a ctypes.Structure

2007-06-04 Thread p . lavarre
> > http://docs.python.org/lib/module-pickle.html > > ... concise Python ways of pickling and unpickling > > the (0xFF ** N) possible ways of > > packing N strings of byte lengths of 0..xFE together ... Aye, looks like an exercise left open for the student to complete: >>> pickle.dumps("") "S''\n

Abort trap - Fatal Python error: GC object already tracked

2007-07-10 Thread p . lavarre
Is this interesting Python output? $ gc-object-already-tracked.py ** File "/Users/admin/Desktop/lxio/gc-object-already-tracked.py", line 770, in __main__.REDACTED Failed example: nqzhexes(self.send()) Expected: '... [reda

Re: Abort trap - Fatal Python error: GC object already tracked

2007-07-10 Thread p . lavarre
> Is this interesting Python output? ... > > Fatal Python error: GC object already tracked > Abort trap > > ... tell me I can help by solving it, and > I'll look more closely. Sorry, never mind, not interesting after all. Newbie me did somehow forget the fact that ctypes.memmove doesn't bounds-ch

CTypes FAQs - buffer memmove offsetof uchar ((void *) -1) etc.

2007-07-13 Thread p . lavarre
http://wiki.python.org/moin/ctypes now tries to answer: '''FAQ: How do I copy bytes to Python from a ctypes.Structure?''' '''FAQ: How do I copy bytes to a ctypes.Structure from Python?''' '''FAQ: Why should I fear using ctypes.memmove?''' '''FAQ: How do I change the byte length of a ctypes.Structu

Trees, Lists and Check Boxes

2007-04-24 Thread P-Cubed
I'm looking for some assistance extending the TreeListCtrl class to include the check box ability of the CustomTreeCtrl as well as 3-state check boxes. Main Column Column1 -- [o] Child1 |-[ ]Child1.1 |-[ ]Ch

Help with trees, lists and checkboxes

2007-04-24 Thread P-Cubed
I'm looking for some assistance extending the TreeListCtrl class to include the check box ability of the CustomTreeCtrl as well as 3-state check boxes. Main Column Column1 -- [o] Child1 |-[ ]Child1.1 |-[ ]C

Invalid pointer when accessing DB2 using python scripts

2007-05-21 Thread P. Adhia
ially supports only PHP, ruby and perl, does IBM have any plans to support python bindings for DB2? Thanks P Adhia Environment: Ubuntu : Fiesty Fawn Python 2.5.1c1 (release25-maint, Apr 12 2007, 21:00:25) DB2 9.1.2 Error: *** glibc detected *** python: free(): invalid pointer: 0xppp *** A s

Invalid pointer when accessing DB2 using python scripts

2007-05-21 Thread P. Adhia
ially supports only PHP, ruby and perl, does IBM have any plans to support python bindings for DB2? Thanks P Adhia Environment: Ubuntu : Fiesty Fawn Python 2.5.1c1 (release25-maint, Apr 12 2007, 21:00:25) DB2 9.1.2 Error: *** glibc detected *** python: free(): invalid pointer: 0xppp *** A s

Python 2.5 and WXPython demo's

2007-05-30 Thread Andrew P
Hello, I am new (very) to Python and have just down loaded the latest version of Python (2.5) and WXPython (2.8). For some reason I cannot get the WXPython demo to run at all. I run windows XP and it can't find a program to run the demo. Any advice? (apologies if this has been posted before). --

<    1   2   3   4   5   6   7   8   9   10   >