tracing openurl input and output?

2009-08-09 Thread mh
How can I watch the messages being sent back and for on urllib shttp requests? If it were simple http I would just watch the socket traffic but of course that won't work for https. Is there a debug flag I can set that will do this? context: I am dealing with a web service bug and I want to

parsing times like 5 minutes ago?

2009-07-06 Thread mh
I'm looking for something like Tcl's [clock scan] command which parses human-readable time strings such as: % clock scan 5 minutes ago 1246925569 % clock scan tomorrow 12:00 1246993200 % clock scan today + 1 fortnight 1248135628 Does any such package exist for Python?

Re: preferring [] or () in list of error codes?

2009-06-09 Thread mh
John Machin sjmac...@lexicon.net wrote: T=lambda x:x in(25401,25402,25408);import dis;dis.dis(L);dis.dis(T) I've learned a lot from this thread, but this is the niftiest bit I've picked up... thanks! -- Mark Harrison Pixar Animation Studios --

setting program name, like $0= in perl?

2009-06-09 Thread mh
I'm sure this is a FAQ, but I certainly haven't been able to find an answer. Is it possible to set the program name as seen by the operating system or lower-level libraries? I'm connecting to a database, and the runtime helpfully sends some information to the server, such as username, pid, and

preferring [] or () in list of error codes?

2009-06-08 Thread mh
Is there any reason to prefer one or the other of these statements? if e.message.code in [25401,25402,25408]: if e.message.code in (25401,25402,25408): I'm currently using [], but only coz I think it's prettier than (). context: these are database errors and e is database

#! to two different pythons?

2009-06-06 Thread mh
I've got a bunch of python programs on linux that start with: #!/usr/anim/menv/bin/pypix Now I'm moving some to the mac, where I'm changing that to: #!/Users/mh/py/bin/python What's the best way to handle this? I've got an install script that rewrites the first line, but if I could

Re: #! to two different pythons?

2009-06-06 Thread mh
Benjamin Peterson benja...@python.org wrote: #!/usr/bin/env python But how can I handle this with two differently named pythons? #!/usr/anim/menv/bin/pypix #!/Users/mh/py/bin/python Thanks! Mark -- Mark Harrison Pixar Animation Studios -- http://mail.python.org/mailman/listinfo

Re: #! to two different pythons?

2009-06-06 Thread mh
Cameron Simpson c...@zip.com.au wrote: - Keep the #!/usr/bin/env python and then: ln -s /usr/anim/menv/bin/pypix /usr/local/bin/python Ah, that's a good idea. The pypix is a company-wide maintained python, but ln -s python pypix on my local Mac laptop python install makes the env work

Re: best way to parse a function-call-like string?

2009-03-03 Thread mh
Paul McGuire pt...@austin.rr.com wrote: Pyparsing will easily carve up these function declarations, and will I didn't know about this module, it looks like what I was looking for... Thanks!!! -- Mark Harrison Pixar Animation Studios -- http://mail.python.org/mailman/listinfo/python-list

best way to parse a function-call-like string?

2009-02-26 Thread mh
I have some strings that look like function calls, e.g. junkpkg.f1 junkpkg.f1() junkpkg.f1('aaa') junkpkg.f1('aaa','bbb') junkpkg.f1('aaa','bbb','ccc') junkpkg.f1('aaa','with,comma') and I need to split them into the function name and list of

Re: best way to parse a function-call-like string?

2009-02-26 Thread mh
Robert Kern robert.k...@gmail.com wrote: On 2009-02-26 15:29, m...@pixar.com wrote: Use the compiler module to generate an AST and walk it. That's the real way. For me, that would also be the quick way because I am familiar with the API, but it may take you a little bit of time to get used

Re: var or inout parm?

2008-12-11 Thread mh
J. Clifford Dyer j...@sdf.lonestar.org wrote: Just google for call-by-object, and ignore the hell out of that thread. Now I've got to go read it! ;-) -- Mark Harrison Pixar Animation Studios -- http://mail.python.org/mailman/listinfo/python-list

Re: var or inout parm?

2008-12-10 Thread mh
Chris Rebert [EMAIL PROTECTED] wrote: Not directly possible or encouraged. You can emulate it by sticking the value in a container object (e.g. list) though: Thanks, that's just what I needed. I'm using this to monkeypatch a test driver into some code that I can't touch, otherwise I would

var or inout parm?

2008-12-07 Thread mh
How can I make a var parm, where the called function can modify the value of the parameter in the caller? def f(x): x = x + 1 n = 1 f(n) # n should now be 2 Many TIA!! Mark -- Mark Harrison Pixar Animation Studios -- http://mail.python.org/mailman/listinfo/python-list

who to thank for the new RST doc format?

2008-11-18 Thread mh
I am really loving the output, and have started using RST for some of my own docs as well. It's wonderful and I know it was a lot of work on somebody's part to think it through and make the changes. If it was you, Many Thanks!!! -- Mark Harrison Pixar Animation Studios --

Re: etymology of list comprehension?

2008-11-07 Thread mh
Martin v. Lowis [EMAIL PROTECTED] wrote: The definition in logic, in turn, matches my understanding of the English word to comprehend: If I know all attributes, marks, etc of an object, I understand it fully, i.e. I comprehend it. I think also that as was pointed out, comprehension meaning

best way to accelerate xmlrpc?

2008-11-07 Thread mh
I've got some python xmlrpc servers and clients. What's the best way to accelerate them? xmlrpclib.py attempts to import these modules: import _xmlrpclib import sgmlop from xml.parsers import expat and falls back to defining the SlowParser class. So, which of these modules is the

etymology of list comprehension?

2008-11-06 Thread mh
I googled and wiki'ed, but couldn't find a concise clear answer as to how python list comprehensions got their name. Who picked the name? What was the direct inspiration, another language? What language was the first to have such a construct? I get that it's based on set notation. Thanks!

Re: etymology of list comprehension?

2008-11-06 Thread mh
Chris Rebert [EMAIL PROTECTED] wrote: the term comprehension for the concept was first used in the NPL programming language (Wikipedia again). Ah, thanks... and does comprehension have any special computer science meaning? -- Mark Harrison Pixar Animation Studios --

wrapping a method function call?

2008-11-03 Thread mh
I am instantiating a class A (which I am importing from somebody else, so I can't modify it) into my class X. Is there a way I can intercept or wrape calls to methods in A? I.e., in the code below can I call x.a.p1() and get the output X.pre A.p1 X.post Many TIA! Mark class

Re: wrapping a method function call?

2008-11-03 Thread mh
Steven D'Aprano [EMAIL PROTECTED] wrote: Now you can monkey patch class A if you want. It's probably not a great idea to do this in production code, as it will effect class A everywhere. This is perfect for me. The code in question is basically a protocol translator... it receives requests

subdirectories for sys.path import?

2008-10-09 Thread mh
I'm currently sharing a directory on sys.path with another group. We don't have the option to modify sys.path. In order to reduce conflicts between the two group's code, installation procedures, etc, I'd like to make a subdirectory for each group, and have each group manage their own

Re: subdirectories for sys.path import?

2008-10-09 Thread mh
[EMAIL PROTECTED] wrote: Is there a way to import a module from one of these subdirectories? Any other more pythonic ways to approach the situation? ah, the magic of __init__.py. Thanks all! -- Mark Harrison Pixar Animation Studios -- http://mail.python.org/mailman/listinfo/python-list

Re: SimpleXMLRPCServer -- turning off request log?

2008-10-03 Thread mh
Vinay Sajip [EMAIL PROTECTED] wrote: Did you try setting logRequests to false? Perfect, that's just what I needed. Thanks Vinay!! Mark -- Mark Harrison Pixar Animation Studios -- http://mail.python.org/mailman/listinfo/python-list

SimpleXMLRPCServer -- turning off request log?

2008-09-25 Thread mh
My SimpleXMLRPCServer program prints to stderr a line like this for each request: ohm..pixar.com - - [25/Sep/2008 17:57:50] POST /RPC2 HTTP/1.0 200 - Is there a way to turn this logging off? I have RTFM and can't seem to find a way to do so. Many TIA! Mark -- Mark Harrison Pixar Animation

[1,2,3] exactly same as [1,2,3,] ?

2008-08-28 Thread mh
x=[1,2,3] and x=[1,2,3,] are exactly the same, right? I'm generating some python data, and it's less error prone to not treat the last element specially, but I want to be sure I'm generating an equivalent data structure. Many TIA! Mark -- Mark Harrison Pixar Animation Studios --

Re: [1,2,3] exactly same as [1,2,3,] ?

2008-08-28 Thread mh
Paul McNett [EMAIL PROTECTED] wrote: When confronted with this type of question, I ask the interpreter: [1,2,3] == [1,2,3,] True Well I guess that's a pretty authoritative answer... thanks! -- Mark Harrison Pixar Animation Studios -- http://mail.python.org/mailman/listinfo/python-list

iterating over two arrays in parallel?

2008-08-28 Thread mh
I want to interate over two arrays in parallel, something like this: a=[1,2,3] b=[4,5,6] for i,j in a,b: print i,j where i,j would be 1,4,2,5, 3,6 etc. Is this possible? Many TIA! Mark -- Mark Harrison Pixar Animation Studios --

Best idiom for looping over input?

2008-08-26 Thread mh
What's the best Python idiom for this C construct? while ((x = next()) != END) { } Now I'm doing x = next() while x != END: x = next() There's not an iterator for this function, or I would just use for x in ... Many TIA! Mark -- Mark

http server class that lets me open socket?

2008-07-22 Thread mh
I'm writing a select-based server, and some of the client connections will want to send an xml-rpc request. Is there a class in the http hierarchy that will allow me to manage a socket, and allow me to instantiate the class like myhttpserver = SomeHTTPServer(mysocket) and then let me call

best option for python lex/yacc?

2008-06-30 Thread mh
I'm porting a C lex/yacc based project, and would like to redo it in python. What's the best option for a python lex/yacc-like? I've googled a few things, but wanted to see the current concensus. Many TIA! Mark -- Mark Harrison Pixar Animation Studios --

getting dir(x), but not as list of strings?

2008-05-21 Thread mh
I want to iterate over members of a module, something like: for i in dir(x): if type(i) == types.FunctionType: ... but of course dir() returns a list of strings. If x is a module, how can I get the list of its members as their actual types? Many TIA! Mark -- Mark Harrison Pixar

call tree tool?

2008-05-15 Thread mh
I'm cleaning up some old code, and want to see what orphan functions might be sitting around. Is there a static call tree analyzer for python? Many TIA! Mark -- Mark Harrison Pixar Animation Studios -- http://mail.python.org/mailman/listinfo/python-list

best way to have enum-like identifiers?

2008-03-11 Thread mh
I currently have a 2-dim hash, indexed by two strings: template['py']['funcpre'] template['py']['funcpost'] ... but I would prefer to have these indexed by constants of some kind, since this seems a bit more natural: template[py][funcpre] template[py][funcpost] ...

Re: any chance regular expressions are cached?

2008-03-10 Thread mh
John Machin [EMAIL PROTECTED] wrote: Yes they will be cached. great. But do yourself a favour and check out the string methods. Nifty... thanks all! -- Mark Harrison Pixar Animation Studios -- http://mail.python.org/mailman/listinfo/python-list

any chance regular expressions are cached?

2008-03-09 Thread mh
I've got a bit of code in a function like this: s=re.sub(r'\n','\n'+spaces,s) s=re.sub(r'^',spaces,s) s=re.sub(r' *\n','\n',s) s=re.sub(r' *$','',s) s=re.sub(r'\n*$','',s) Is there any chance that these will be cached somewhere, and save me the trouble of having to declare

Re: nonblocking read of one xml element?

2008-02-05 Thread mh
Stefan Behnel [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: I'm parsing a log file that's being written out in real time. This is part of an event loop, so I want to have some code that looks like this: when logfile is readable: read one entry node, including children

nonblocking read of one xml element?

2008-02-04 Thread mh
So, I'm parsing a log file that's being written out in real time. logfile entrytimestamp123/timestampdetailsfoo/details /entry entrytimestamp456/timestampdetailsbar/details /entry --- no /logfile, coz the file hasn't yet been closed This is part of an event loop, so I want to have

compiling an extension for several versions of python

2007-09-12 Thread mh
I don't have access to site-packages, but I would like to provide versions of my c-language package compiled against python 2.4 and 2.5. I own a library directory which is included in our site's sys.path. Currently this is where the 2.4 shared libary is installed. What's the most canonical way

Determine if windows drive letter is hard drive or optical from python?

2005-05-27 Thread mh
Hi Folks- I'm trying to do a simple emulation of unix locate functionality in python for windows. Problem is I don't want to crawl/index optical drives. Do any of the windows people out there know how I can determine: 1. How many drives are on the system? (I could just iterate over the

[ANN] Spike Asset Manager release 0.13

2005-01-31 Thread mh
Spike Asset Manager (SAM) is an open-source cross-platform framework written in python for probing a system for components and reporting them. It includes a driver file that probes for components commonly found in a LAMPJ stack (Apache, MySQL, PHP, Tomcat, etc). Note that the L in LAMP could be

Re: [ANN] Spike Asset Manager release 0.13

2005-01-31 Thread mh
The idea is to have a framework to do this in a semi-crossplatform manner. The framework could be updated to know about apt, portage repositories as well as talk to to the windows registry. Not everyone is running redhat ;) -- http://mail.python.org/mailman/listinfo/python-list

Re: [ANN] Spike Asset Manager release 0.13

2005-01-31 Thread mh
Fredrik- This is a known issue. The tool currently only looks in certain locations or hints rather then spidering the whole hard drive (which could take a bit of time). If you have installed in a non-standard location (or are using a platform or version of software that hasn't been tested