Re: [Tutor] where to look for python codes

2011-09-29 Thread Tommy Kaas
> -Oprindelig meddelelse- > Fra: tutor-bounces+tommy.kaas=kaasogmulvad...@python.org > [mailto:tutor-bounces+tommy.kaas=kaasogmulvad...@python.org] På > vegne af Alan Gauld > Sendt: 29. september 2011 10:48 > Til: tutor@python.org > Emne: Re: [Tutor] where to look for python codes > > On 2

Re: [Tutor] search-replace

2011-06-06 Thread Tommy Kaas
> -Oprindelig meddelelse- > Fra: tutor-bounces+tommy.kaas=kaasogmulvad...@python.org > [mailto:tutor-bounces+tommy.kaas=kaasogmulvad...@python.org] På vegne > af Alan Gauld > Sendt: 6. juni 2011 11:51 > Til: tutor@python.org > Emne: Re: [Tutor] search-replace >

[Tutor] search-replace

2011-06-06 Thread Tommy Kaas
Hi tutors If I need to clean a textfile (perhaps after web scraping), I have used this method - without problems - but I'm sure there must be smarter and better ways. I'm especially interested to know how I do more than just one search-replace without having to repeat the whole step below.

Re: [Tutor] Write new line(enter) in txt

2011-03-28 Thread Tommy Kaas
Fra: tutor-bounces+tommy.kaas=kaasogmulvad...@python.org [mailto:tutor-bounces+tommy.kaas=kaasogmulvad...@python.org] På vegne af Susana Iraiis Delgado Rodriguez Sendt: 28. marts 2011 17:12 Til: tutor@python.org Emne: [Tutor] Write new line(enter) in txt Hello list!! This is a very simpl

Re: [Tutor] Need Help in installing MySQLdb-Python

2011-02-01 Thread Tommy Kaas
Fra: tutor-bounces+tommy.kaas=kaasogmulvad...@python.org [mailto:tutor-bounces+tommy.kaas=kaasogmulvad...@python.org] På vegne af Victor Binns Sendt: 1. februar 2011 01:19 Til: Tutor python Emne: [Tutor] Need Help in installing MySQLdb-Python I have Python 2.6.3 I went to the following

Re: [Tutor] no luck with sqlinsert

2011-01-15 Thread Tommy Kaas
> >I get a invalid syntax error when I try to run this script - and it's > > con.commit() which is highlighted when I get the error. > > Aren't you one closing parenthesis short? > > Alan Gauld Yes, you're absolutely right. Thanks. Tommy ___ Tutor ma

[Tutor] no luck with sqlinsert

2011-01-14 Thread Tommy Kaas
int(cols[2]), int(cols[3]), int(cols[4]), int(cols[5]), int(cols[6]), int(cols[7])) con.commit() except: con.rollback() con.close() Tommy Kaas ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] how avoid writing a newline?

2011-01-12 Thread Tommy Kaas
Yes – you’re right! Thanks, Tommy Fra: Jason Staudenmayer [mailto:jas...@adventureaquarium.com] Sendt: 12. januar 2011 16:50 Til: Tommy Kaas; tutor@python.org Emne: RE: [Tutor] how avoid writing a newline? You should have a comma after the "#" in the highlighted print state

[Tutor] how avoid writing a newline?

2011-01-12 Thread Tommy Kaas
I'm using Activepython 2.6.6 on PC/Win7 I have made a small scraper script as an exercise for myself. It scrapes the name and some details of the first 25 billionaires on the Forbes list. It works and write the result in a text file, with the columns separated by "#" It takes the name from

Re: [Tutor] variabel from raw input into re.search?

2011-01-07 Thread Tommy Kaas
You have 3 options, string concatenation, and two styles of formatting: >>> name = 'Sir Arthur' >>> '.*' + name + '.*' '.*Sir Arthur.*' >>> '.*%s.*' % (name, ) '.*Sir Arthur.*' >>> '.*{0}.*'.format(name) '.*Sir Arthur.*' >>> '.*{name}.*'.format(name=name) '.*Sir Arthur.*' The last t

[Tutor] variabel from raw input into re.search?

2011-01-07 Thread Tommy Kaas
I try to write a program, where the user can write a word or a name and I will tell how many times the subject was mentioned in a text, I'm hosting. I guess it's possible but not this way it seems? The re is only searching for the word "name" and not the variable name I'm using Python 2.6.6. TI

[Tutor] more scraping and saving

2011-01-03 Thread Tommy Kaas
0'}): tds = row('td') output = ";".join(tds[i].string for i in (0, 1, 2, 3, 4)) f.write(output + '\n') f.close() Tommy Kaas Kaas & Mulvad Lykkesholms Alle 2A, 3. 1902 Frederiksberg C Mobil: 27268818 Mail: <

[Tutor] scraping and saving in file SOLVED

2010-12-29 Thread Tommy Kaas
on.org > [mailto:tutor-bounces+tommy.kaas=kaasogmulvad...@python.org] På > vegne af Peter Otten > Sendt: 29. december 2010 11:46 > Til: tutor@python.org > Emne: Re: [Tutor] scraping and saving in file > > Tommy Kaas wrote: > > > I’m trying to learn basic web scr

Re: [Tutor] scraping and saving in file

2010-12-29 Thread Tommy Kaas
Steven D'Aprano wrote: > But in your case, the best way is not to use print at all. You are writing to a > file -- write to the file directly, don't mess about with print. Untested: > > > f = open('tabeltest.txt', 'w') > url = 'http://www.kaasogmulvad.dk/unv/python/tabeltest.htm' > soup = Beautif

[Tutor] scraping and saving in file

2010-12-29 Thread Tommy Kaas
Kommunenr # Kommune # Region # Regionsnr 101 # København # Hovedstaden # 1084 147 # Frederiksberg # Hovedstaden # 1084 151 # Ballerup # Hovedstaden # 1084 153 # Brøndby # Hovedstaden # 1084 155 # Dragør # Hovedstaden # 1084 Thanks in advance Tommy Kaas Kaas & Mulvad

Re: [Tutor] Newbie question - syntax - BeautifulSoup

2010-07-29 Thread Tommy Kaas
Thanks for the explanation. It's clearer now. Tommy "Tommy Kaas" wrote > > > for row in soup('table', {'class' : 'spad'})[0].tbody('tr'): > > > >Do you understand the syntax from a Python point of view? > > No.

Re: [Tutor] Newbie question - syntax - BeautifulSoup

2010-07-28 Thread Tommy Kaas
-Oprindelig meddelelse- Fra: tutor-bounces+tommy.kaas=kaasogmulvad...@python.org [mailto:tutor-bounces+tommy.kaas=kaasogmulvad...@python.org] På vegne af Alan Gauld Sendt: 28. juli 2010 20:00 Til: tutor@python.org Emne: Re: [Tutor] Newbie question - syntax - BeautifulSoup "Tommy

[Tutor] Newbie question - syntax - BeautifulSoup

2010-07-28 Thread Tommy Kaas
n't understand how I am supposed to the fourth line - after "for row in soup". I can clearly see it defines the area I want to scrape, but how is the syntax build? And almost as important - where should I have found that information myself? I have tried to read the help-file of Bea