Re: [Tutor] pychecker: x is None or x == None

2005-08-13 Thread Alan G
>if x == None: >do_something() > > but then someone thought that we should really change these to > >if x is None: >do_something() > > However. if you run pychecker on these two snippets of code, it > complains about the second, and not the first: Personally I'd use if

[Tutor] python and xml

2005-08-13 Thread David Holland
What is a good way of using xml and python ? I tried to install PyXML but I get this as an error message :- python setup.py Traceback (most recent call last): File "setup.py", line 127, in ? config_h_vars = parse_config_h(open(config_h)) IOError: [Errno 2] No such file or directory: '/usr/inc

[Tutor] Python and xml

2005-08-13 Thread David Holland
I forgot to say that I am using knoppix 3.9 ___ How much free photo storage do you get? Store your holiday snaps for FREE with Yahoo! Photos http://uk.photos.yahoo.com ___ Tutor

[Tutor] Invoking bash from within a python program

2005-08-13 Thread joe_schmoe
Hi Pythoneers I'm sure that somewhere in the dim and distant past this was asked, but I'll be b***ered if I can find reference to it, and google searches haven't been too illuminating yet. Anyway, how do I call bash to run a program - e.g. slocate - from within a python program. I believe that

Re: [Tutor] Invoking bash from within a python program

2005-08-13 Thread Vinay Reddy
> I'm sure that somewhere in the dim and distant past this was asked, but > I'll be b***ered if I can find reference to it, and google searches > haven't been too illuminating yet. Anyway, how do I call bash to run a > program - e.g. slocate - from within a python program. I believe that I > have t

[Tutor] iterating in the same line

2005-08-13 Thread Jonas Melian
I would check 3 words at the starting of a line s=['foo','bar','qwe'] if ln.startswith(s): (this is bad) what is the best way for making it? if max(map(ln.startswith,s)): or reduce(lambda m,n:m or n, map(ln.startswith, s)) Thanks! ___ Tutor maillis

Re: [Tutor] Invoking bash from within a python program

2005-08-13 Thread Danny Yoo
On Sat, 13 Aug 2005, Vinay Reddy wrote: > > Anyway, how do I call bash to run a program - e.g. slocate - from > > within a python program. I believe that I have to import the OS first > > (or do I?) and I was thinking something like: > > > > ... > > sh slocate file_name > python_defined_list > >

[Tutor] Sorting a list of lists aka nested lists

2005-08-13 Thread Jim Roush
I have a python script that creates a list of lists like so: Quant.append( [ db_ticker, stock_close, MTD, 0, QTD, 0, YTD, 0, 0, 0 ] ) After Quant is created, I want to sort it by MTD. If I use a simple Quant.sort(), I assume its going to sort by 'db_ticker' which is not what I want. I've

Re: [Tutor] iterating in the same line

2005-08-13 Thread Danny Yoo
On Sat, 13 Aug 2005, Jonas Melian wrote: > I would check 3 words at the starting of a line > > s=['foo','bar','qwe'] > > if ln.startswith(s): (this is bad) Hi Jonas, Just checking: is this similar to a question brought up a few days ago? http://mail.python.org/pipermail/tutor/2005-Augu

Re: [Tutor] Sorting a list of lists aka nested lists

2005-08-13 Thread Danny Yoo
On Sat, 13 Aug 2005, Jim Roush wrote: > I have a python script that creates a list of lists like so: > > Quant.append( [ db_ticker, stock_close, MTD, 0, QTD, 0, YTD, 0, 0, 0 ] ) > > After Quant is created, I want to sort it by MTD. If I use a simple > Quant.sort(), I assume its going to sor

Re: [Tutor] Sorting a list of lists aka nested lists

2005-08-13 Thread Jim Roush
Danny Yoo wrote: >On Sat, 13 Aug 2005, Jim Roush wrote: > > > >>I have a python script that creates a list of lists like so: >> >>Quant.append( [ db_ticker, stock_close, MTD, 0, QTD, 0, YTD, 0, 0, 0 ] ) >> >>After Quant is created, I want to sort it by MTD. If I use a simple >>Quant.sort(),

Re: [Tutor] iterating in the same line

2005-08-13 Thread Bob Gailer
At 12:20 PM 8/13/2005, Jonas Melian wrote: >I would check 3 words at the starting of a line > >s=['foo','bar','qwe'] > >if ln.startswith(s): (this is bad) > >what is the best way for making it? Iterations over a list of this nature are most succinctly done using list comprehensions. if [l for

[Tutor] re

2005-08-13 Thread Jesse Lands
I am trying to create a simple GUI that will track a network connection using ping. It's a starter project for me so I am sure there are other easier ways of doing it, but I am learning, so bare with me. I figured out the first part import os ping = os.popen('ping -c 4 10.0.8.200') ping_res

[Tutor] PyGTK, classes and return values?

2005-08-13 Thread Simon Gerber
Greetings, all. I've been stumbling my way through the PyGTK tutorial, with mixed success. So far I have been able to achieve everything I have set out to achieve, with one rather major exception. I have a class called 'AddAccountWindow' that creates a window asking for hostname, username, pas

Re: [Tutor] Sorting a list of lists aka nested lists

2005-08-13 Thread Danny Yoo
> >AMK has written a nice mini-tutorial on how to use a list's sort() > >effectively: > > > >http://www.amk.ca/python/howto/sorting/sorting.html > > > >Does his tutorial make sense, or are there parts in there that are > >baffling? Please feel free to ask questions on it, and we'll try to >

Re: [Tutor] python and xml

2005-08-13 Thread Luis N
On 8/13/05, David Holland <[EMAIL PROTECTED]> wrote: > What is a good way of using xml and python ? ElementTree? http://effbot.org/zone/element-index.htm or, lxml http://codespeak.net/lxml/ Luis. ___ Tutor maillist - Tutor@python.org http://mail.pyth