Re: [Tutor] Omitting lines matching a list of strings from a file

2010-02-24 Thread Reed O'Brien
def main(): infile = open("list.txt", "r") for line in infile: state = line[146:148] omit_states = ['KS', 'KY', 'MA', 'ND', 'NE', 'NJ', 'PR', 'RI', 'SD', 'VI', 'VT', 'WI'] for n in omit_states: if state != n: print line infile.close() ma

Re: [Tutor] IP-range

2009-05-25 Thread Reed O'Brien
On May 24, 2009, at 11:18 PM, Paras K. wrote: Hello, I came across your answer / assistance on the IP range. I recommend looking at the ipaddr library: http://svn.python.org/projects/python/trunk/Lib/ipaddr.py There is some Sphinx documentation with the python 2.7 docs and some on the ori

Re: [Tutor] commands versus subprocess, I'm confused

2008-12-26 Thread Reed O'Brien
On Dec 26, 2008, at 8:57, "Emad Nawfal (عماد نوفل)" mail.com> wrote: 2008/12/26 Kent Johnson On Fri, Dec 26, 2008 at 8:09 AM, Emad Nawfal (عماد نوفل) wrote: > suppose I have an external program that prints "testing the subprocess > module" > I know I can run it through the commands module

Re: [Tutor] some string operations

2008-10-04 Thread Reed O'Brien
On Oct 4, 2008, at 4:03 AM, David wrote: Dear list, one of the exercises in Zelle's book is: given import string s1 = "spam" s2 = "ni!" show a Python expression that could construct the following result by performing string operations on s1 and s2: "Spam Ni! Spam Ni! Spam Ni!". I have t

Re: [Tutor] array of different datatypes

2008-09-23 Thread Reed O'Brien
On Sep 22, 2008, at 11:50 PM, Steve Willoughby wrote: Dinesh B Vadhia wrote: Thanks Steve. How do you sort on the second element of each list to get: a' = [[42, 'fish'], [1, 'hello'] [2, 'world'] ] something like this would do the trick: a_prime = sorted(a, key=(lambd

Re: [Tutor] stack class

2008-07-11 Thread Reed O'Brien
On Jul 11, 2008, at 7:54 PM, Christopher Spears wrote: For another Core Python Programming question, I created a stack class. I then put the class into a script to test it: I understand that this is an exercise; but I think it might be interesting for you to also look at collections.deque

Re: [Tutor] python + http authentication (with cherrypy)

2008-07-07 Thread Reed O'Brien
On Jul 7, 2008, at 9:10 PM, James wrote: Hi All, I'm writing a web application in CherryPy. What a beautiful thing it is to write Python code and get a simple yet powerful web output. :) The web application needs to have some decent level of security and authentication implemented. The big is

Re: [Tutor] Noob requesting help...

2008-02-18 Thread Reed O'Brien
On Feb 16, 2008, at 9:58 PM, bob gailer wrote: > Marc Tompkins wrote: >> John, Luke, Marc... can we get a Matthew to join this thread? > You thinking of Matthew Dixon Coles? > > But then wouldn't Paul want to get into the Act? For Pete's sake... ~ro __

Re: [Tutor] run in "deamon" mode?

2008-01-10 Thread Reed O'Brien
On Jan 10, 2008, at 12:41 AM, Allen Fowler wrote: > Hello, > > How can a make a python script run in "deamon mode"? (on a linux box) > > That is, I want to run the program via "python myfile.py" and have > it drop me back to the command line. The program should continue > running until I kill

Re: [Tutor] Spaces and tabs messing up code

2008-01-08 Thread Reed O'Brien
On Jan 8, 2008, at 7:49 PM, Bill Campbell wrote: > On Tue, Jan 08, 2008, [EMAIL PROTECTED] wrote: >> >> my friend uses vim Small editors for small minds;) >> >> and i use xemacs >> >> so our shared python code is a mix of tabs and spaces and it is >> hard >> for him to edit it in vim >

Re: [Tutor] Careful Dictionary Building

2007-12-29 Thread Reed O'Brien
On Dec 28, 2007, at 11:29 AM, doug shawhan wrote: *sigh* Ignore folks. I had forgotten about .has_key(). .has_key() is deprecated in 2.6 and goes away in 3.0 IIRC You should use record in D or D.get(record) On Dec 28, 2007 11:22 AM, doug shawhan <[EMAIL PROTECTED]> wrote: I'm building

Re: [Tutor] Telnet to Router/Switch

2007-12-24 Thread Reed O'Brien
On Dec 24, 2007, at 1:19 PM, Shahjehan Hakim wrote: Hi everyone.. I have to make Telnet session with Router/switch of Cisco. Anybody has idea how it can be done? from what i researched, i got most of the telnet session like client/servers. But what I have to do here is just to create a Te

Re: [Tutor] python image libray - source to Mac OS X

2007-10-29 Thread Reed O'Brien
On Oct 29, 2007, at 7:54 PM, elis aeris wrote: http://www.pythonware.com/products/pil/#pil116 has anyone been able to compile this on Mac os x? http://two.pairlist.net/pipermail/reportlab-users/2007-October/ 006262.html ___ Tutor maillist -

Re: [Tutor] Power Shells [WAS:] optimization: faster than for

2007-07-01 Thread Reed O'Brien
On Jul 1, 2007, at 6:38 PM, ALAN GAULD wrote: > Suddenly it seems like I have an embarassment of advanced > shells to choose from. At risk of starting a religious war, who > favours which and why? > > Alan, I have been using ipython for the last few months. I am barely touching teh surface o

Re: [Tutor] Fastest way to iterate through a file

2007-07-01 Thread Reed O'Brien
On Jul 1, 2007, at 7:13 PM, elis aeris wrote: might just end my quest for optimized python source code. ugh, what does it mean ? elias, We have two MAJOR rules regarding optimization. These rules really go beyond python, but this is a good place to learn them. The two rules of optimi

Re: [Tutor] Regular Expression help

2007-06-27 Thread Reed O'Brien
On Jun 27, 2007, at 10:24 AM, Mike Hansen wrote: > > >> -Original Message- >> From: [EMAIL PROTECTED] >> [mailto:[EMAIL PROTECTED] On Behalf Of Gardner, Dean >> Sent: Wednesday, June 27, 2007 3:59 AM >> To: tutor@python.org >> Subject: [Tutor] Regular Expression help >> >> Hi >> >> I have

Re: [Tutor] Bundle help!

2007-06-25 Thread Reed O'Brien
On Jun 25, 2007, at 9:56 PM, Sara Johnson wrote: I'm to use the bundle method to append some information to a list. I have no idea how to do that! I have Python for Dummies and I think I need Python for Complete Idiots because I am not seeing how to do this!! I have basic C+ knowledge a

Re: [Tutor] using shelve

2007-06-22 Thread Reed O'Brien
On Jun 22, 2007, at 7:26 AM, Kent Johnson wrote: > Reed O'Brien wrote: >> have a gander at: >> http://codeidol.com/python/python3/Databases-and-Persistence/ > > That URL points to a (presumably) stolen copy of the book > Programming Python by Mark Lutz. If you like

Re: [Tutor] using shelve

2007-06-21 Thread Reed O'Brien
On Jun 21, 2007, at 9:59 PM, [EMAIL PROTECTED] wrote: I created a shelf called 'myshelf' and put two objects in it, a string and a list. When I open the shelf I get: d=shelve.open('/Users/development/Desktop/myshelf') d.keys() ['dir1', 'dir2'] d {'dir2': '/Users/development/Desktop/RSSRea

Re: [Tutor] how can I compare a local directory or file with a remote one

2007-06-21 Thread Reed O'Brien
On Jun 21, 2007, at 9:06 AM, Lloyd Kvam wrote: > On Wed, 2007-06-20 at 23:51 -0400, Reed O'Brien wrote: >> On Jun 20, 2007, at 2:03 PM, Richard Querin wrote: >> >>> I'm interested in writing a quick script that would run a diff-type >>> command that woul

Re: [Tutor] how can I compare a local directory or file with a remote one

2007-06-20 Thread Reed O'Brien
On Jun 20, 2007, at 2:03 PM, Richard Querin wrote: > I'm interested in writing a quick script that would run a diff-type > command that would compare a local directory to a remote one to > identify the changes in the files within that directory. > > I was initially thinking that I would maybe use

Re: [Tutor] iterating over a sequence question..

2007-06-17 Thread Reed O'Brien
On Jun 17, 2007, at 3:44 AM, John Fouhy wrote: > On 17/06/07, Iyer <[EMAIL PROTECTED]> wrote: >> >> say, if I have a list l = [1,2,3,5] >> >> and another tuple t = ('r', 'g', 'b') >> >> Suppose I iterate over list l, and t at the same time, if I use >> the zip >> function as in zip(l,t) , I wil