Re: [Tutor] code review please

2005-12-28 Thread Brian van den Broek
Eakin, W said unto the world upon 27/12/05 09:59 AM: > Hello, > Although I've been coding in PHP and ASP and JavaScript for a couple of > years now, I'm relatively new to Python. For learning exercises, I'm writing > small Python programs that do limited things, but hopefully do them well. > >

Re: [Tutor] regex

2005-12-28 Thread Will Harris
Thanks, this helped out. I hadn't thought of trying to use strings for this, I will give that a shot. I removed the TYPE field from the regex thinking that might have been causing a problem and forgot to add it back to my regex.On 12/27/05, Kent Johnson <[EMAIL PROTECTED]> wrote:Danny Yoo wrote:

Re: [Tutor] How to call mysqlcommand in Python , "mysqldump for backup "

2005-12-28 Thread John Joseph
--- nephish <[EMAIL PROTECTED]> wrote: > ooh ooh, i know this one, i have python do this for > me every day ! > > target_dir = '/path/to/where/you/want/to/dump' > > os.system("mysqldump --add-drop-table -c -u user > -ppassword database > table > "+target_dir+"/table.bak.sql") > > dont forget t

[Tutor] threaded multipart FTP download

2005-12-28 Thread Justin Ezequiel
Greetings, Did not think I could post my code here as it's a bit long so I placed it in http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/465531 Can some of you have a look and post comments, suggestions, alternatives? Thanks. BTW, the recipe is sufficient for our needs at the moment but

Re: [Tutor] code review please

2005-12-28 Thread Kent Johnson
Brian van den Broek wrote: > def punctuation_split(sequence): > '''returns list of character sequences separating punctuation > characters''' > for mark in punctuation: > sequence = sequence.replace(mark, ' %s ' %mark) > return sequence.split(' ') You should look at re.spl

Re: [Tutor] code review please

2005-12-28 Thread Kent Johnson
Danny Yoo wrote: > Similarly, the try/except for IndexError seems too pervasive: rather than > wrap it around the whole program, we may want to limit its extent to just > around the sys.argv access. Otherwise, any other IndexError has the > potential of being misattributed. Much of the program do

Re: [Tutor] Printing

2005-12-28 Thread Ron Phillips
>>> "John Corry" < [EMAIL PROTECTED] > 12/24/2005 12:28 PM >>>Hi + Season's Greetings!I have put together a program that queries and modifies a Gadfly database.I have captured my output. I now want to print it to paper.I have written the output to a text file. I have searched the tutor mailinglist

Re: [Tutor] code review please

2005-12-28 Thread Kent Johnson
Kent Johnson wrote: > BTW thinking of writing this as a loop brings to mind some problems - > what will your program do with 'words' such as 555-1212 or "Ha!" ? Hmm, on reflection I don't thing "Ha!" will be a problem, but a 'word' with no letters will cause an IndexError. Your test for 4 lette

Re: [Tutor] How to call mysqlcommand in Python , "mysqldump for backup "

2005-12-28 Thread nephish
Glad to help, glad you got it working too.! shawn On Wed, 2005-12-28 at 09:03 +, John Joseph wrote: > --- nephish <[EMAIL PROTECTED]> wrote: > > > ooh ooh, i know this one, i have python do this for > > me every day ! > > > > target_dir = '/path/to/where/you/want/to/dump' > > > > os.syste

[Tutor] matching a file

2005-12-28 Thread jonasmg
Hi! I would to working with some files. But I have to using a regular expression with one of them: for file in [glob.glob('/etc/env.d/[0-9]*foo'), '/etc/bar']: glob returns a list so i'm supposed that i would that convert it into a string. Is it correct? Thanks for your help ___

Re: [Tutor] matching a file

2005-12-28 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > Hi! > > I would to working with some files. But I have to using a regular expression > with one of them: > > for file in [glob.glob('/etc/env.d/[0-9]*foo'), '/etc/bar']: > > glob returns a list so i'm supposed that i would that convert it into a > string. glob.g

[Tutor] Multi-Dimensional Dictionary that contains a 12 element list.

2005-12-28 Thread Paul Kraus
I am trying to build a data structure that would be a dictionary of a dictionary of a list. In Perl I would build the structure like so $dictionary{key1}{key2}[0] = X I would iterate like so ... foreach my $key1 ( sort keys %dictionary ) { foreach my $key2 ( sort keys %{$dictionary{$key1}

Re: [Tutor] Multi-Dimensional Dictionary that contains a 12 element list.

2005-12-28 Thread Paul Kraus
On Wednesday 28 December 2005 10:18 am, Paul Kraus wrote: > I am trying to build a data structure that would be a dictionary of a > dictionary of a list. > > In Perl I would build the structure like so $dictionary{key1}{key2}[0] = X > I would iterate like so ... > foreach my $key1 ( sort keys %dict

Re: [Tutor] Multi-Dimensional Dictionary that contains a 12 element list.

2005-12-28 Thread Kent Johnson
Paul Kraus wrote: > I am trying to build a data structure that would be a dictionary of a > dictionary of a list. > > In Perl I would build the structure like so $dictionary{key1}{key2}[0] = X > I would iterate like so ... > foreach my $key1 ( sort keys %dictionary ) { > foreach my $key2 (

Re: [Tutor] Multi-Dimensional Dictionary that contains a 12 element list.

2005-12-28 Thread Kent Johnson
Paul Kraus wrote: > Here is the code that I used. Its functional and it works but there has got > to > be some better ways to do a lot of this. Transversing the data structure > still seems like I have to be doing it the hard way. > > The input data file has fixed width fields that are delimite

[Tutor] Multiple Assignment from list.

2005-12-28 Thread Paul Kraus
How do I code this in python. Assuming fields is a list of 3 things. (myfielda, myfieldb, myfieldc) = fields When i try that I get ValueError: need more than 1 value to unpack. If i print fields it is in need printed as ['somestring','somestring','somestring'] TIA, -- Paul Kraus =-=-=-=-=-=-=-

Re: [Tutor] Multiple Assignment from list.

2005-12-28 Thread Paul Kraus
Never mind. i figured this out. the top line of a file i was reading in and splitting only had 1 char so "fields" on that line was not a list. I fixed this. On Wednesday 28 December 2005 3:12 pm, Paul Kraus wrote: > How do I code this in python. Assuming fields is a list of 3 things. > > (myfield

[Tutor] Extracting data from HTML files

2005-12-28 Thread motorolaguy
Hello, I`m very new to Python and programming in general.I`ve been reading Dive in to Python as an introduction to the language and I think I`m doing pretty well,but I`m stuck on this problem. I`m trying to make a python script for extracting certain data from HTML files.These files are from a temp

Re: [Tutor] Extracting data from HTML files

2005-12-28 Thread bob
At 01:26 PM 12/28/2005, [EMAIL PROTECTED] wrote: >[snip] >I`m trying to make a python script for extracting certain data from HTML >filesSay for example the HTML file has the following format: >Category:Category1 >[...] >Name:Filename.exe >[...] >Description:Description1. > >Taking in to accoun

Re: [Tutor] code review please

2005-12-28 Thread Brian van den Broek
Kent Johnson said unto the world upon 28/12/05 07:06 AM: > Brian van den Broek wrote: > >>def punctuation_split(sequence): >> '''returns list of character sequences separating punctuation >>characters''' >> for mark in punctuation: >> sequence = sequence.replace(mark, ' %s ' %mark

[Tutor] new to linux and I cannot find some python things

2005-12-28 Thread Brian van den Broek
Hi all, I'm a week or so into having switched from WinXP to linux (ubuntu breezy). There is a lot to learn about the differences in the OS'es and that's just fine. But, a couple of things have been in my way with Python. Most notably, I don't know how one browses the documentation. On Window

Re: [Tutor] new to linux and I cannot find some python things

2005-12-28 Thread Simon Gerber
> Hi all, > > I'm a week or so into having switched from WinXP to linux (ubuntu > breezy). There is a lot to learn about the differences in the OS'es > and that's just fine. Excellent! Another Ubuntu Breezy user here. If there's anything Ubuntu I can help you with, drop me an e-mail and I'll do wh

Re: [Tutor] new to linux and I cannot find some python things

2005-12-28 Thread Brian van den Broek
Simon Gerber said unto the world upon 28/12/05 05:12 PM: >>Hi all, >> >>I'm a week or so into having switched from WinXP to linux (ubuntu >>breezy). There is a lot to learn about the differences in the OS'es >>and that's just fine. > > > Excellent! Another Ubuntu Breezy user here. If there's anyt

[Tutor] [OT] A thanks for all the help since I've found tutor

2005-12-28 Thread Brian van den Broek
Hi all, I'd like to thank the tutor community, especially Alan, Danny, and Kent, but all the other posters, regular and occasional, tutor or tutee, too. I've recently been engaged in what, for pre-python and -tutor me, would have been some deeply black magic unrelated to python, and the tutor

Re: [Tutor] Extracting data from HTML files

2005-12-28 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > I`m trying to make a python script for extracting certain data from HTML > files.These files are from a template so they all have the same formatting.I > just want to extract the data from certain fields.It would also be nice to > insert it into a mysql database, but I`ll

Re: [Tutor] Extracting data from HTML files

2005-12-28 Thread motorolaguy
Hello, I was taking a look at BeautifulSoup as recommended by bob and from what I can tell it`s just what I`m looking for but it`s a bit over my current skills with python I`m afraid.I`ll still keep playing with it and see what I can come up with. I`ll also take a look at regexes as recommended by