Re: a new Perl/Python a day

2005-01-09 Thread Andy Gross
On Jan 10, 2005, at 12:11 AM, Scott Bryce wrote: No. Perl may have some interesting idiosyncrasies, especially for a programmer with little or no Unix experience, but I find it neither frustrating, inane nor incompetent. The more I use it, the more I like it. I don't see what UNIX experience has

Re: Embedding a restricted python interpreter

2005-01-05 Thread Andy Gross
Check out http://mail.python.org/pipermail/python-dev/2003-January/031851.html for a historical thread on rexec.py's vulnerabilities. Right now, the answer for people who want restricted execution is usually "wait for pypy", due to the number of tricks that can subvert the rexec model. There

Re: [SPAM] Re: Import a module without executing it?

2004-12-08 Thread Andy Gross
On Dec 8, 2004, at 5:44 AM, Kent Johnson wrote: Andy, this is a nice example. It prompted me to look at the docs for compiler.visitor. The docs are, um, pretty bad. I'm going to attempt to clean them up a little. Would you mind if I include this example? Be my guest! /arg -- http://mail.python.or

Re: Import a module without executing it?

2004-12-07 Thread Andy Gross
So, in Smalltalk, the way you find out about what's in the system is reflection...you ask the classes what methods they implement (if looking for 'implementors'), you ask the methods for the source and can string search the code (if looking for senders). There's no real way to get the source cod

Re: Import a module without executing it?

2004-12-07 Thread Andy Gross
On Dec 7, 2004, at 4:20 PM, Steven Bethard wrote: If you have source control over this file, you could write it with the more standard idiom... I should have mentioned this first. If you're just trying to avoid existing top-level code from being executed, use the if __name__ == "__main__" idiom

Re: Import a module without executing it?

2004-12-07 Thread Andy Gross
, [Name('app'), Keyword('state', Const('disabled'))], None, None)), Discard(CallFunc(Getattr(Name('t'), 'pack'), [], None, None)), Assign([AssName('info', 'OP_ASSIGN')], List([List([Const('Ali'), Const(18)]), List([Cons

Re: Import a module without executing it?

2004-12-07 Thread Andy Gross
You'll want to use the "compiler" package. compiler.parseFile will return an AST that you can inspect (which is not really 'reflection', btw). /arg On Dec 7, 2004, at 10:56 PM, Caleb Hattingh wrote: Hi You could just parse the model file. Off the top of my head *** f = open('ModuleYouWantToExa

Re: Help with super()

2004-12-07 Thread Andy Gross
Florian, See: http://www.python.org/doc/newstyle.html /arg On Dec 7, 2004, at 5:38 AM, Florian Lindner wrote: Steven Bethard schrieb: Christopher J. Bottaro wrote: Why don't this code work? import PRI class Poscdnld_PYIO(PRI.BasicBatch): def __init__(self, *argv): super(Poscdnld_PYIO, s

Re: better regular expression?

2004-12-06 Thread Andy Gross
Check out the 'urlparse' module, in the standard library, unless for some reason you *have* to use regular expressions. /arg On Dec 6, 2004, at 7:46 PM, Vivek wrote: Hi, I am trying to construct a regular expression using the re module that matches for 1. my hostname 2. absolute from the root UR

Re: xmlrpclib or twisted?

2004-12-06 Thread Andy Gross
If you're not concerned about interoperability with other languages and are already using Twisted, I'd go with PB. Especially if you are using complicated datatypes that have to be serialized and sent over the wire - PB has a nice Cacheable type that doesn't serialize the whole object. XMLRPC

Re: help using sockets, and OOP?

2004-12-06 Thread Andy Gross
On Dec 6, 2004, at 12:04 PM, Dfenestr8 wrote: Ok, so are there other types of sockets that aren't "blocking" ? Yes, sockets can be either blocking or non-blocking. An I/O operation on a 'blocking' socket will not return until the operation is complete. If you try to read more bytes than are cur