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] Omitting lines matching a list of strings from a file

2010-02-24 Thread Christian Witts
galaxywatc...@gmail.com wrote: I am trying to output a list of addresses that do not match a list of State abbreviations. What I have so far is: def main(): infile = open("list.txt", "r") for line in infile: state = line[146:148] omit_states = ['KS', 'KY', 'MA', 'ND', 'N

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

2010-02-24 Thread galaxywatcher
I am trying to output a list of addresses that do not match a list of State abbreviations. What I have so far is: 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', '

Re: [Tutor] Strange list behaviour in classes

2010-02-24 Thread James Reynolds
Thank you! I think I have working in the right direction. I have one more question related to this module. I had to move everything to a single module, but what I would like to do is have this class in a file by itself so I can call this from other modules. when it was in separate modules it ran w

Re: [Tutor] Python-based address standardization script?

2010-02-24 Thread Serdar Tumgoren
> Sure, just send me a link when it's up. I don't have any experience with > git but I've wanted to learn so go ahead and use that. > > Okay - the git repo is here: http://github.com/zstumgoren/python-addressparser You can clone it with the following shell command (assuming you've installed git):

Re: [Tutor] Python-based address standardization script?

2010-02-24 Thread Luke Paireepinart
On Wed, Feb 24, 2010 at 6:15 PM, Serdar Tumgoren wrote: > > Hey folks, >>> Anyone know if there's a Python script floating out there to standardize >>> U.S. addresses? I couldn't find anything on ActiveState or by Googling...I'm >>> interested in something similar to this Perl module: >>> >>> http

Re: [Tutor] Strange list behaviour in classes

2010-02-24 Thread Alan Gauld
"James Reynolds" wrote I understand, but if self.value is any number other then 0, then the "for" will append to the square list, in which case square_list will always have some len greater than 0 when "value" is greater than 0? And if value does equal zero? Actually I'm confused by value

Re: [Tutor] Python-based address standardization script?

2010-02-24 Thread Serdar Tumgoren
> Hey folks, >> Anyone know if there's a Python script floating out there to standardize >> U.S. addresses? I couldn't find anything on ActiveState or by Googling...I'm >> interested in something similar to this Perl module: >> >> http://search.cpan.org/~sderle/Geo-StreetAddress-US-0.99/US.pm

Re: [Tutor] Python-based address standardization script?

2010-02-24 Thread Luke Paireepinart
On Wed, Feb 24, 2010 at 4:14 PM, Serdar Tumgoren wrote: > Hey folks, > Anyone know if there's a Python script floating out there to standardize > U.S. addresses? I couldn't find anything on ActiveState or by Googling...I'm > interested in something similar to this Perl module: > > http://search.cp

Re: [Tutor] Strange list behaviour in classes

2010-02-24 Thread James Reynolds
Thanks for the reply. I understand, but if self.value is any number other then 0, then the "for" will append to the square list, in which case square_list will always have some len greater than 0 when "value" is greater than 0? I'm just trying to understand the mechanics. I'm assuming that isn't

Re: [Tutor] Strange list behaviour in classes

2010-02-24 Thread ALAN GAULD
Forwarding to the list. Please alweays use Reply All so others can comment too. I made a few changes, but I'm getting the same error on variance (see below): Looks like a different error to me! It would seem to me that it should never evaluate if the denominator is zero because of the if statem

Re: [Tutor] strange bidi requirement

2010-02-24 Thread Steven D'Aprano
On Thu, 25 Feb 2010 03:34:02 am rick wrote: > I'm trying to write a math quiz program that replicates an old book > on arithmetic. > > when it comes to summing a long column, I need to read the answer > from the user, one digit at a time. > > so, if the answer should be something like > > 14238.83

Re: [Tutor] strange bidi requirement

2010-02-24 Thread Alan Gauld
"rick" wrote in message news:1267029242.9270.13.ca...@rick-desktop... 14238.83 I would need to read the .03, then the .8, and so on. I figure all strings, cast to int (well, for this example, float). Would this be easier if I learned some GUI programming? Can it be done at all in just con

Re: [Tutor] common (sub)attributes

2010-02-24 Thread Alan Gauld
"spir" wrote Classes are often used to hold common or default attribute. True Then, some of these attrs may get custom values for individual objects of a given type. Simply by overriding the attr on this object Yes, but then the arttribute becomes an instance attribute which masks the cla

Re: [Tutor] What Editori?

2010-02-24 Thread Alan Gauld
"Giorgio" wrote And, what about more powerful editors? I mean editors with features like SVN/GIT management and so on. THose aren't really editor features but IDE features. But thats probably splityting hairs. But emacs does that too and truly is a powerful editor. Certainly more so than

[Tutor] Python-based address standardization script?

2010-02-24 Thread Serdar Tumgoren
Hey folks, Anyone know if there's a Python script floating out there to standardize U.S. addresses? I couldn't find anything on ActiveState or by Googling...I'm interested in something similar to this Perl module: http://search.cpan.org/~sderle/Geo-StreetAddress-US-0.99/US.pm Just curious if anyo

Re: [Tutor] What Editori?

2010-02-24 Thread Mike
I use and love Pyscripter for Windows. I guess I am used to the Delphi IDE. Mike On Tue, Feb 23, 2010 at 11:24 AM, Giorgio wrote: > Hi All, > what text-editor do you use for python? > I've always used kate/nano on Linux and Notepad++/PSPad on Win. Today i've > installed portablepython to my pen

Re: [Tutor] strange bidi requirement

2010-02-24 Thread Benno Lang
On 25 February 2010 01:34, rick wrote: > I'm trying to write a math quiz program that replicates an old book on > arithmetic. > > when it comes to summing a long column, I need to read the answer from > the user, one digit at a time. > > so, if the answer should be something like > > 14238.83 > >

Re: [Tutor] What Editori?

2010-02-24 Thread Hansen, Mike
I'm surprised no one has mentioned ActiveState's KOMODO. I primarily use VIM, but I hop into KOMODO for doing little scripts and watching the output. KOMODO comes in two flavors, KOMODO Edit which is free and KOMODO IDE which costs about $300. I suspect that KOMODO Edit does most of what people

[Tutor] strange bidi requirement

2010-02-24 Thread rick
I'm trying to write a math quiz program that replicates an old book on arithmetic. when it comes to summing a long column, I need to read the answer from the user, one digit at a time. so, if the answer should be something like 14238.83 I would need to read the .03, then the .8, and so on. I

Re: [Tutor] What Editori?

2010-02-24 Thread Ricardo Aráoz
Lowell Tackett wrote: > The environment [OS} of choice can do a lot to expand/enhance the > capabilities of an editor. I fell upon Vim from the beginning, and > stayed with it for its' rich palate of features and adaptability (and > of course, the often...and exhilarating "oh, Vim can do that!").

Re: [Tutor] What Editori?

2010-02-24 Thread William Witteman
On Wed, Feb 24, 2010 at 04:40:07PM +0100, Giorgio wrote: >And, what about more powerful editors? I mean editors with features like SVN/ >GIT management and so on. I think you'll find that there is extensive version control integration in most/all of the "less powerful" editors. Certainly you wou

Re: [Tutor] What Editori?

2010-02-24 Thread Giorgio
And, what about more powerful editors? I mean editors with features like SVN/GIT management and so on. I use Netbeans, but also know Eclipse/Aptana. > -- -- AnotherNetFellow Email: anothernetfel...@gmail.com ___ Tutor maillist - Tutor@python.org T

[Tutor] Regular expression generator

2010-02-24 Thread Kent Johnson
Another interesting tool - you give it a sample string and it helps you build a regular expression to match the string. This is not a regex tester, it actually creates the regex for you as you click on elements of the string. http://txt2re.com/index-python.php3 Kent ___

Re: [Tutor] ask

2010-02-24 Thread Steven D'Aprano
On Wed, 24 Feb 2010 02:58:52 pm Shurui Liu (Aaron Liu) wrote: > This time is not my assignment, I promise. > > In python, when we want to list numbers, we use the command "range", > like, if we want to list integer from 0 to 9, we can write: > range(10); if we want to list integer from 10 to 29, we

Re: [Tutor] Using Matplotlib - program still running when graph window is closed

2010-02-24 Thread AG
Eike Welk wrote: On Wednesday February 24 2010 11:23:18 AG wrote: How does one ensure that once a graph has been produced by Matplotlib and that graph has been closed by the user that the program itself stops? What I am currently getting is that when I close the graph pop-up window and then

Re: [Tutor] Using Matplotlib - program still running when graph window is closed

2010-02-24 Thread Eike Welk
On Wednesday February 24 2010 11:23:18 AG wrote: > How does one ensure that once a graph has been produced by Matplotlib > and that graph has been closed by the user that the program itself stops? > > What I am currently getting is that when I close the graph pop-up window > and then close IDLE, I

Re: [Tutor] What Editori?

2010-02-24 Thread Giorgio
> The editors could be configured differently with respect to the "tab > button". > Some may insert tabs some may insert spaces. > Ok, found the problem. I'm inserting tabs, but the original file only has spaces. Do you think i can look for a function that automatically inserts a certain number o

Re: [Tutor] What Editori?

2010-02-24 Thread Eike Welk
On Wednesday February 24 2010 14:14:49 Giorgio wrote: > Yes i'm sure. I'm using the "tab button" and the same button works > perfectly in the IDLE editor. The editors could be configured differently with respect to the "tab button". Some may insert tabs some may insert spaces. EMACS can even

[Tutor] DreamPie - The Python shell you've always dreamed about!

2010-02-24 Thread Kent Johnson
This looks promising and probably of interest to some on this list. Kent -- Forwarded message -- From: Noam Yorav-Raphael To: python-announce-l...@python.org Date: Sun, 21 Feb 2010 11:39:02 +0200 Subject: DreamPie - The Python shell you've always dreamed about! I'm pleased to ann

Re: [Tutor] ask

2010-02-24 Thread Kent Johnson
On Tue, Feb 23, 2010 at 10:58 PM, Shurui Liu (Aaron Liu) wrote: > This time is not my assignment, I promise. > > In python, when we want to list numbers, we use the command "range", like, > if we want to list integer from 0 to 9, we can write: range(10); if we want > to list integer from 10 to 29,

Re: [Tutor] What Editori?

2010-02-24 Thread Giorgio
> > >> >> Are you sure you're not mixing spaces and tabs? > Yes i'm sure. I'm using the "tab button" and the same button works perfectly in the IDLE editor. -- -- AnotherNetFellow Email: anothernetfel...@gmail.com ___ Tutor maillist - Tutor@python.

[Tutor] distutils and the postinstallation script

2010-02-24 Thread Tim Brown
Hi, I've written an installation, for Windows, using distutils to produce a .exe setup file. When the setup.exe is run, can my postinstallation script can find out which folder the setup.exe is in ? Thanks Tim ___ Tutor maillist - Tutor@python.org T

Re: [Tutor] Cannot open SQLite database

2010-02-24 Thread spir
On Wed, 24 Feb 2010 09:38:56 +0100 Timo wrote: > Hello all, my program uses SQLite as database and everything worked fine > until now. > I have over 3000 downloads of my program, but I got 2 mails this week > from people who get this error: > > OperationalError: unable to open database file >

[Tutor] Using Matplotlib - program still running when graph window is closed

2010-02-24 Thread AG
How does one ensure that once a graph has been produced by Matplotlib and that graph has been closed by the user that the program itself stops? What I am currently getting is that when I close the graph pop-up window and then close IDLE, I get a message that the program is still running and am

[Tutor] common (sub)attributes

2010-02-24 Thread spir
Hello, Just a really basic note: Classes are often used to hold common or default attribute. Then, some of these attrs may get custom values for individual objects of a given type. Simply by overriding the attr on this object (see code below). But this will not only if the attr is a top-level o

Re: [Tutor] ask

2010-02-24 Thread Alan Gauld
"Shurui Liu (Aaron Liu)" wrote in message news:2b9003cf1002231958s34b701b6sc69408a0b855a...@mail.gmail.com... This time is not my assignment, I promise. In python, when we want to list numbers, we use the command "range", like, if we want to list integer from 0 to 9, we can write: range(10);

Re: [Tutor] Verifying My Troublesome Linkage Claim between Python andWin7

2010-02-24 Thread Alan Gauld
"Wayne Watson" wrote My claim is that if one creates a program in a folder that reads a file in the folder it and then copies it to another folder, it will read the data file in the first folder, and not a changed file in the new folder. Thats what I would expect in any OS. Unless you expl

Re: [Tutor] Cannot open SQLite database

2010-02-24 Thread Alan Gauld
"Timo" wrote OperationalError: unable to open database file Does the file actually exist where you say it does? # This will return: C:\Documents and Settings\user\Application Data\myapp PREFDIR = os.path.join(os.environ['APPDATA'], 'myapp') Do you check that APPDATA is actually set? #

Re: [Tutor] Strange list behaviour in classes

2010-02-24 Thread Alan Gauld
"James Reynolds" wrote This thread inspired me to start learning object oriented as well, but it seems I must be missing something fundamental. No, this has nothing to do with objects, its just a broken algorithm. median = Statistics.stats.median(*a) n = (self.value[m] + self.value[m

Re: [Tutor] Cannot open SQLite database

2010-02-24 Thread Christian Witts
Timo wrote: Hello all, my program uses SQLite as database and everything worked fine until now. I have over 3000 downloads of my program, but I got 2 mails this week from people who get this error: OperationalError: unable to open database file I searched the net, and all problems seem to be

[Tutor] Cannot open SQLite database

2010-02-24 Thread Timo
Hello all, my program uses SQLite as database and everything worked fine until now. I have over 3000 downloads of my program, but I got 2 mails this week from people who get this error: OperationalError: unable to open database file I searched the net, and all problems seem to be of a not writ