Re: [Tutor] Expanding a Python script to include a zcat and awkpre-process

2010-01-08 Thread Mark Tolonen
wrote in message news:5dff81f3-a087-41f2-984b-914a08e2b...@gmail.com... I wrote a simple Python script to process a text file, but I had to run a shell one liner to get the text file primed for the script. I would much rather have the Python script handle the whole task without any pre-pr

Re: [Tutor] Greetings Pythonistas

2010-01-08 Thread spir
galaxywatc...@gmail.com dixit: > I often > wish that I had a private tutor or a Python guru that I could just ask > how to get past a certain wall. Perhaps this list has that person or > people on it. The list as a whole certainly _can_ be this, & more ;-) (depends on how _you_ deal with i

Re: [Tutor] Help with a Dictionary

2010-01-08 Thread spir
Garry Bettle dixit: [...series of data with same format...] > 2010-01-07 1437 Crayfd H3 380m > ... etc. > > The above are RaceDate + RaceTime + Fixture + RaceDetails, and are > output in RaceTime order. > > What I'd like to do, is output a transposed-like summary of just the > Fixture + RaceTime

Re: [Tutor] Help with a Dictionary

2010-01-08 Thread spir
Garry Bettle dixit: > for fixture in FixtureList: > print fixture.ljust(6), FixtureList[fixture] ... > for fixture, racetimes in FixtureList: > print fixture, racetimes > > Traceback (most recent call last): > File "", line 1, in > for fixture, racetimes in FixtureList: > ValueErro

Re: [Tutor] formatting*

2010-01-08 Thread spir
Lowell Tackett dixit: > An odd aside, however--I went into the Tutor Archives forum and pulled up the > Page Source (HTML formatting template) and lo and behold all my paragraphs > were correctly formatted (i.e. page-wrapped just as they had been when they > left my mail notepad) and displayed

Re: [Tutor] Expanding a Python script to include a zcat and awk pre-process

2010-01-08 Thread spir
galaxywatc...@gmail.com dixit: > I wrote a simple Python script to process a text file, but I had to > run a shell one liner to get the text file primed for the script. I > would much rather have the Python script handle the whole task without > any pre-processing at all. I will show 1) a sm

Re: [Tutor] manipulting CSV files

2010-01-08 Thread Kent Johnson
On Thu, Jan 7, 2010 at 1:26 PM, Lowell Tackett wrote: > I found the Python documentation (on line} and came > across--'csv.Dialect.skipinitialspace' which I believe is the answer to my > dilemma.  However, my effort to implement that detail, based on interpreting > the skimpy examples in the do

Re: [Tutor] (no subject)

2010-01-08 Thread Kent Johnson
On Thu, Jan 7, 2010 at 5:08 PM, kumar s wrote: > I want to take coordiates x and y from each row in file a, and check if they > are in range of zx and zy. If they are in range then I want to be able to > write both matched rows in a tab delim single row. > > > my code: > > f1 = open('fileA','r'

Re: [Tutor] Expanding a Python script to include a zcat and awk pre-process

2010-01-08 Thread Kent Johnson
On Fri, Jan 8, 2010 at 2:24 AM, wrote: > So how do I > uncompress zip and gzipped files in Python, zipfile and gzip > and how do I force split to only > evaluate the first two columns? Use the optional second argument to split(): line.split(',', 2) > Better yet, can I tell split to not evalu

Re: [Tutor] manipulting CSV files

2010-01-08 Thread Lowell Tackett
>From the virtual desk of Lowell Tackett --- On Fri, 1/8/10, Kent Johnson wrote: > From: Kent Johnson > Subject: Re: [Tutor] manipulting CSV files > To: "Lowell Tackett" > Cc: "tutor" > Date: Friday, January 8, 2010, 8:11 AM > On Thu, Jan 7, 2010 at 1:26 PM, > Lowell Tackett > wrote: >

Re: [Tutor] manipulting CSV files

2010-01-08 Thread Kent Johnson
On Fri, Jan 8, 2010 at 9:54 AM, Lowell Tackett wrote: > Now, perhaps you can you shed some light on this problem--I'm trying to do > some simple arithmetic with two of the retrieved values, and get this error: > coord = csv.reader(open('true_coord', 'rb'), skipinitialspace = True) for

Re: [Tutor] manipulting CSV files

2010-01-08 Thread Lowell Tackett
>From the virtual desk of Lowell Tackett --- On Fri, 1/8/10, Kent Johnson wrote: > From: Kent Johnson > Subject: Re: [Tutor] manipulting CSV files > To: "Lowell Tackett" > Cc: "tutor" > Date: Friday, January 8, 2010, 10:07 AM > > Well, it's right - that is not a valid integer. What do y

Re: [Tutor] manipulting CSV files

2010-01-08 Thread Wayne Werner
On Fri, Jan 8, 2010 at 9:56 AM, Lowell Tackett wrote: > and with all that I want to develop to where I can create some > pretty expansive scripts dealing with land surveying stuff--manipulating > coordinates, inversing, traversing, bearings, etc., etc. > Maybe you could even get into drawing the

Re: [Tutor] manipulting CSV files

2010-01-08 Thread Kent Johnson
On Fri, Jan 8, 2010 at 10:56 AM, Lowell Tackett wrote: > Please keep in mind, as I'd mentioned earlier, all of this is fairly new > concepts to me; from running an interpretive Python screen, to delving into > the zen of computing, [even] to pasting stuff from there to here--there's > about 4

Re: [Tutor] formatting*

2010-01-08 Thread Lowell Tackett
>From the virtual desk of Lowell Tackett --- On Fri, 1/8/10, spir wrote: > From: spir > Subject: Re: [Tutor] formatting* > To: tutor@python.org > Date: Friday, January 8, 2010, 7:27 AM > Lowell Tackett dixit: > > Yo, that's because you're viewing the source as plain text,... > > Denis >

[Tutor] Question on "import foobar" vs "from foobar import *"

2010-01-08 Thread Rob Cherry
Still trying to get the hang of some python intricacies, but this one has come up a few times. Beyond the obvious syntactic niceties what is the difference between importing with and without the "from" syntax? Its nice for example to do this - from socket import * googleip = gethostbyname("www.g

Re: [Tutor] Question on "import foobar" vs "from foobar import *"

2010-01-08 Thread Luke Paireepinart
The difference is a term called "namespace pollution". the "from socket import *" will place a whole lot of methods into your global namespace, possibly colliding with other methods / variables you've defined yourself. For example, if your file contained x = 5 from foobar import * and foobar co

Re: [Tutor] Question on "import foobar" vs "from foobar import *"

2010-01-08 Thread Rob Cherry
Extending on this advice somewhat - is it *ever* correct to "import foobar". There are countless examples of import os,sys etc,etc. Strictly speaking should we always be using "from" to only get what we know we need? Thanks, Rob ___ Tutor maillist

Re: [Tutor] Question on "import foobar" vs "from foobar import *"

2010-01-08 Thread Luke Paireepinart
Yes, it depends how the library was designed. Some are designed so that you can import some of the library into your global namespace. For example, in Pygame library, it's accepted to do import pygame from pygame.locals import * This keeps the methods like pygame.init() pygame.display.set_mode(

Re: [Tutor] Question on "import foobar" vs "from foobar import *"

2010-01-08 Thread Wayne Werner
On Fri, Jan 8, 2010 at 1:21 PM, Rob Cherry wrote: > Still trying to get the hang of some python intricacies, but this one > has come up a few times. Beyond the obvious syntactic niceties what > is the difference between importing with and without the "from" > syntax? > > Its nice for example to

Re: [Tutor] Question on "import foobar" vs "from foobar import *"

2010-01-08 Thread Kent Johnson
On Fri, Jan 8, 2010 at 2:39 PM, Rob Cherry wrote: > Extending on this advice somewhat - is it *ever* correct to "import foobar". > > There are countless examples of > > import os,sys > > etc,etc.  Strictly speaking should we always be using "from" to only > get what we know we need? No, the plain

[Tutor] $PYTHONSTARTUP

2010-01-08 Thread Lowell Tackett
I'm not certain if this is more correctly a bash issue, but it seems logical to at least start here.  What I hope to do is set some standard commands (whenever I open an interactive python shell) as are outlined in the Python.org tutorial: 2.2.4. The Interactive Startup File¶ When you use Python

Re: [Tutor] $PYTHONSTARTUP

2010-01-08 Thread Hugo Arts
On Sat, Jan 9, 2010 at 12:54 AM, Lowell Tackett wrote: > I'm not certain if this is more correctly a bash issue, but it seems > logical to at least start here. What I hope to do is set some standard > commands (whenever I open an interactive python shell) as are outlined in > the Python.org tuto

Re: [Tutor] Question on "import foobar" vs "from foobar import *"

2010-01-08 Thread Lie Ryan
On 1/9/2010 6:39 AM, Rob Cherry wrote: Extending on this advice somewhat - is it *ever* correct to "import foobar". There are countless examples of import os,sys The rule of thumb is: Use the "from module import something" if you're only going to use one or two functions from the module; onl