Re: Sorting dict keys

2007-07-21 Thread zacherates
>From ESR's "Why python?" b = a.keys(); b.sort() Two statements, one line. Doesn't create an incidental copy the way sorted does but I'm not sure how much you like to jam on one line. Cheers, Aaron -- http://mail.python.org/mailman/listinfo/python-list

Re: How to check if an item exist in a nested list

2007-07-19 Thread zacherates
> One way is to check the length of each dimension. Does any body > know a simpler way? No need to check the length of the list: """ >>> foo = [0, 1, 2, [3, 4, 5, 6, 7, [8, 9, 10]]] >>> isInNested(0, foo) True >>> isInNested(11, foo) False >>> isInNested(3, foo) True >>> isInNested(8, foo) True ""

Re: using subprocess for non-terminating command

2007-07-04 Thread zacherates
> Only when the program has executed and the output available, subprocess can > read through PIPE's stdout it seems ( not at any other time). > With killing, I loose the output. This is untrue. >>> process.stdout.read() # Blocks until end of stream. >>> process.stdout.read(1) # Reads one character

Re: using subprocess for non-terminating command

2007-07-04 Thread zacherates
> How should I handle these kind of commands (ping 127.0.0.1) with > subprocess module. I am using subprocess, instead of os.system because > at anypoint in time, I need access to stdout and stderr of execution. Ping, for one, allows you to set an upper bound on how long it runs (the -c option).

Re: possible to preserve subprocess.Popen objects for later?

2007-06-21 Thread zacherates
On Jun 21, 6:32 pm, Ratko <[EMAIL PROTECTED]> wrote: > Hi all, > > I have a python gui app that launches multiple applications using > subprocess.Popen class and prints their output in the gui (using > PIPEs, threads and wxPython). Everything works great but the problem > is that some applications

Re: How can I know the name of "caller"

2007-06-19 Thread zacherates
> ...(if it is possible) how can I get, from method "called", the name > of function/method that called it (in this case "caller")? The traceback module will give you access to the call stack. >>> import traceback >>> def foo(): ... return traceback.extract_stack() ... >>> def bar(): ...

Re: difference between urllib2.urlopen and firefox view 'page source'?

2007-03-19 Thread zacherates
On Mar 19, 10:30 pm, "cjl" <[EMAIL PROTECTED]> wrote: > Hi. > > I am trying to screen scrape some stock data from yahoo, so I am > trying to use urllib2 to retrieve the html and beautiful soup for the > parsing. > > Maybe (most likely) I am doing something wrong, but when I use > urllib2.urlopen to

Re: Passing arguments to a command line from a python script

2007-03-19 Thread zacherates
On Mar 19, 9:42 pm, "Luis M. González" <[EMAIL PROTECTED]> wrote: > On Mar 19, 9:25 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> > wrote: > > > > > En Mon, 19 Mar 2007 20:46:56 -0300, Luis M. González <[EMAIL PROTECTED]> > > escribió: > > > > What I want now is execute the script I just created. > >

Re: How to log only one level to a FileHandler using python logging module.

2006-05-16 Thread zacherates
Try looking into logging.Filters: http://docs.python.org/lib/node358.html An example: import logging class InfoFilter(logging.Filter): def filter(self, record): return record.levelno == 20 if __name__ == "__main__": logger = logging.getLogger() hdlr = log