Re: [Tutor] Multiple regex replacements, lists and for.

2010-10-12 Thread Evert Rol
> I'm new to python and inexperienced in programming but I'm trying hard. > I have a shell script that I'm converting over to python. > Part of the script replaces some lines of text. > I can do this in python, and get the output I want, but so far only using sed. > Here's an example script: > > i

Re: [Tutor] list of dict question

2010-10-12 Thread Francesco Loffredo
On 11/10/2010 19.23, Alan Gauld wrote: ... HTH, Sure it did! Very enlightening, Alan. THANK YOU! Nessun virus nel messaggio in uscita. Controllato da AVG - www.avg.com Versione: 9.0.862 / Database dei virus: 271.1.1/3190 - Data di rilascio: 10/11/10 08:34:00 ___

[Tutor] SQLite3 DB Field Alphabetizing

2010-10-12 Thread David Hutto
When calling a sqlite3 db file in python 2.6 on Ubuntu, I get the following when the items are taken from the db tuple, lstripped('u'), and added to a list. ['.hjvkjgfkj/bdgfkjbg', 'uuz', 'jgkgyckghc', 'kfhhv ', 'khfhf', 'test', 'test10', 'test2', 'test3', 'test346w43', 'test4'

Re: [Tutor] SQLite3 DB Field Alphabetizing

2010-10-12 Thread bob gailer
On 10/12/2010 7:41 AM, David Hutto wrote: When calling a sqlite3 db file Calling? How did you do that? I presume a sql select statement. True? If so please post the statement. Else what do you mean by call? in python 2.6 on Ubuntu, I get the following when the items are taken from the db

[Tutor] urllib problem

2010-10-12 Thread Roelof Wobben
Hoi, I have this programm : import urllib import re f = urllib.urlopen("http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=6";) inhoud = f.read() f.close() nummer = re.search('[0-9]', inhoud) volgende = int(nummer.group()) teller = 1 while teller <= 3 : url = "http://www.py

Re: [Tutor] SQLite3 DB Field Alphabetizing

2010-10-12 Thread Steven D'Aprano
On Tue, 12 Oct 2010 10:41:36 pm David Hutto wrote: > When calling a sqlite3 db file in python 2.6 on Ubuntu, I get the > following when the items are taken from the db tuple, lstripped('u'), > and added to a list. > > ['.hjvkjgfkj/bdgfkjbg', 'uuz', 'jgkgyckghc', > 'kfhhv ', 'khf

Re: [Tutor] urllib problem

2010-10-12 Thread Evert Rol
> I have this program : > > import urllib > import re > f = > urllib.urlopen("http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=6";) > inhoud = f.read() > f.close() > nummer = re.search('[0-9]', inhoud) > volgende = int(nummer.group()) > teller = 1 > while teller <= 3 : > url = "

Re: [Tutor] urllib problem

2010-10-12 Thread Steven D'Aprano
On Tue, 12 Oct 2010 11:40:17 pm Roelof Wobben wrote: > Hoi, > > I have this programm : > > import urllib > import re > f = > urllib.urlopen("http://www.pythonchallenge.com/pc/def/linkedlist.php? >nothing=6") inhoud = f.read() > f.close() > nummer = re.search('[0-9]', inhoud) > volgende = int(nummer

Re: [Tutor] SQLite3 DB Field Alphabetizing

2010-10-12 Thread David Hutto
Sorry about that, I there might have been an obvious reason. *Note that the I invented the *.bob file before you replied. import sqlite3 as lite class db(object): def onNewProjSQLDB(self): self.con = lite.connect('/home/david/pythonfiles/pythonscripts/roughdraftapps/datapl

Re: [Tutor] SQLite3 DB Field Alphabetizing

2010-10-12 Thread David Hutto
No trickery, I've been adding entries at random all day(scout's honor ii||i). But the above shows the code I used, and the first shows the entries added at random while testing and retrieving, and it shows it alphabetically any other time. I thought it might have to do with a character or several i

Re: [Tutor] SQLite3 DB Field Alphabetizing

2010-10-12 Thread David Hutto
On Tue, Oct 12, 2010 at 9:02 AM, David Hutto wrote: > Sorry about that, I there might have been an obvious reason. > *Note that the I invented the *.bob file before you replied. Apparently, I am to .bob, what Al Gore is to the internet. > > import sqlite3 as lite > class db(object): >        def

Re: [Tutor] SQLite3 DB Field Alphabetizing

2010-10-12 Thread Alan Gauld
"David Hutto" wrote My question is, why is everything except [:-2] in alphabetical order? It doesn't really matter(at this point), for my purposes, but I'd like to know when they changed the abc's to xy;z's? Without seeing the SQL we can't be sure. By default SQL does not guarantee any ord

Re: [Tutor] SQLite3 DB Field Alphabetizing

2010-10-12 Thread David Hutto
> > Did you include an ORDER BY? See three posts above, line 6. > > > -- > Alan Gauld > Author of the Learn to Program web site > http://www.alan-g.me.uk/ > > > ___ > Tutor maillist  -  tu...@python.org > To unsubscribe or change subscription options: >

Re: [Tutor] SQLite3 DB Field Alphabetizing

2010-10-12 Thread Alan Gauld
"David Hutto" wrote > Did you include an ORDER BY? See three posts above, line 6. Looks like our posts crossed in transit :-) So you order by graphname, and you only have a single field of that name? But then when you put it into the list you only use part of graphname converted to a st

Re: [Tutor] urllib problem

2010-10-12 Thread Steven D'Aprano
On Tue, 12 Oct 2010 11:58:03 pm Steven D'Aprano wrote: > On Tue, 12 Oct 2010 11:40:17 pm Roelof Wobben wrote: > > Hoi, > > > > I have this programm : > > > > import urllib > > import re > > f = > > urllib.urlopen("http://www.pythonchallenge.com/pc/def/linkedlist.ph > >p? nothing=6") inhoud = f.read

Re: [Tutor] urllib problem

2010-10-12 Thread Roelof Wobben
> From: st...@pearwood.info > To: tutor@python.org > Date: Tue, 12 Oct 2010 23:58:03 +1100 > Subject: Re: [Tutor] urllib problem > > On Tue, 12 Oct 2010 11:40:17 pm Roelof Wobben wrote: >> Hoi, >> >> I have this programm : >> >> import urllib >> import re

Re: [Tutor] SQLite3 DB Field Alphabetizing

2010-10-12 Thread Joel Goldstick
On Tue, Oct 12, 2010 at 10:23 AM, Alan Gauld wrote: > > "David Hutto" wrote > > > Did you include an ORDER BY? >> >> See three posts above, line 6. >> > > > Just a guess. You strip the letter u from your list items. Is there a letter u in each of them? You are sorting on the item before you s

Re: [Tutor] urllib problem

2010-10-12 Thread Roelof Wobben
> From: st...@pearwood.info > To: tutor@python.org > Date: Wed, 13 Oct 2010 01:51:16 +1100 > Subject: Re: [Tutor] urllib problem > > On Tue, 12 Oct 2010 11:58:03 pm Steven D'Aprano wrote: > > On Tue, 12 Oct 2010 11:40:17 pm Roelof Wobben wrote: > > > Hoi,

[Tutor] pickle problem

2010-10-12 Thread Roelof Wobben
Hello, I have this code : import urllib import pickle image = urllib.URLopener() image.retrieve("http://www.pythonchallenge.com/pc/def/peak.html","banner.p"; ) plaatje = open("banner.p", "rb") plaatje2 = pickle.load(plaatje) But it gives this output : Traceback (most recent call last)

Re: [Tutor] Using contents of a document to change file names, (was Re: how to extract data only after a certain ...)

2010-10-12 Thread Josep M. Fontana
Thanks Chris and Alan, OK, I see. Now that I managed to build the dictionary, I did a print to confirm that indeed the dictionary was created and it had the intended contents and I was surprised to see that the order of the items in it was totally changed. So the text file from which the dictionar

Re: [Tutor] Using contents of a document to change file names, (was Re: how to extract data only after a certain ...)

2010-10-12 Thread Joel Goldstick
On Tue, Oct 12, 2010 at 1:52 PM, Josep M. Fontana wrote: > Thanks Chris and Alan, > > OK, I see. Now that I managed to build the dictionary, I did a print to > confirm that indeed the dictionary was created and it had the intended > contents and I was surprised to see that the order of the items

Re: [Tutor] Using contents of a document to change file names, (was Re: how to extract data only after a certain ...)

2010-10-12 Thread Joel Goldstick
On Tue, Oct 12, 2010 at 2:46 PM, Josep M. Fontana wrote: > > > On Tue, Oct 12, 2010 at 8:37 PM, Joel Goldstick > wrote: > >> >> >> On Tue, Oct 12, 2010 at 1:52 PM, Josep M. Fontana < >> josep.m.font...@gmail.com> wrote: >> >>> Thanks Chris and Alan, >>> >>> OK, I see. Now that I managed to build

Re: [Tutor] Using contents of a document to change file names, (was Re: how to extract data only after a certain ...)

2010-10-12 Thread Sander Sweers
On 12 October 2010 21:15, Joel Goldstick wrote: > When the dictionary is retrieved, its order depends on the hashed values > rather than the keys themself. If (big IF here) you really need an ordered dict you can use the OrderedDict from the collections module. However this will only guarantee *i

Re: [Tutor] Using contents of a document to change file names, (was Re: how to extract data only after a certain ...)

2010-10-12 Thread Joel Goldstick
On Tue, Oct 12, 2010 at 3:39 PM, Sander Sweers wrote: > On 12 October 2010 21:15, Joel Goldstick wrote: > > When the dictionary is retrieved, its order depends on the hashed values > > rather than the keys themself. > > If (big IF here) you really need an ordered dict you can use the > OrderedDic

[Tutor] Compiling python and SQlite3 prob on ubuntu 10.10

2010-10-12 Thread b vivek
Hi, I am using the recently released python10.10 and wanted to install python2.5.4 on my system to do some app engine development, and this is what I did:- 1.I downloaded Python-2.5.4.tgz.tar from the python site. 2.cd Downloads tar -xvzf Python-2.5.4.tgz.tar cd Python-2.5.4 ./configure --prefix=

Re: [Tutor] pickle problem

2010-10-12 Thread Knacktus
Am 12.10.2010 19:35, schrieb Roelof Wobben: Hello, I have this code : import urllib import pickle image = urllib.URLopener() image.retrieve("http://www.pythonchallenge.com/pc/def/peak.html","banner.p"; ) plaatje = open("banner.p", "rb") plaatje2 = pickle.load(plaatje) But it gives this outp

Re: [Tutor] pickle problem

2010-10-12 Thread Adam Bark
On 12/10/10 18:35, Roelof Wobben wrote: Hello, I have this code : import urllib import pickle image = urllib.URLopener() image.retrieve("http://www.pythonchallenge.com/pc/def/peak.html","banner.p"; ) plaatje = open("banner.p", "rb") plaatje2 = pickle.load(plaatje) But it gives this output :

Re: [Tutor] pickle problem

2010-10-12 Thread Joel Goldstick
On Tue, Oct 12, 2010 at 1:35 PM, Roelof Wobben wrote: > > > Hello, > > I have this code : > > import urllib > import pickle > > image = urllib.URLopener() > image.retrieve("http://www.pythonchallenge.com/pc/def/peak.html","banner.p"; > ) > plaatje = open("banner.p", "rb") > plaatje2 = pickle.load

Re: [Tutor] pickle problem

2010-10-12 Thread Walter Prins
On 12 October 2010 18:35, Roelof Wobben wrote: > image = urllib.URLopener() > image.retrieve("http://www.pythonchallenge.com/pc/def/peak.html","banner.p"; > ) > OK firstly, image is an URLopener, so whatever URL you specify, that's the file that it will download. (I would therefore suggest you

Re: [Tutor] urllib problem

2010-10-12 Thread Alan Gauld
"Roelof Wobben" wrote Finally solved this puzzle. Now the next one of the 33 puzzles. Don;t be surprised if you get stuck. Python Challenge is quite tricky and is deliberately designed to make you explore parts of the standard library you might not otherwise find. Expect to do a lot of readi

Re: [Tutor] pickle problem

2010-10-12 Thread Alan Gauld
"Roelof Wobben" wrote image = urllib.URLopener() image.retrieve("http://www.pythonchallenge.com/pc/def/peak.html","banner.p"; ) Roelof, Please do not post a series of request for help on each of the Python Challenge puzzles. They are intended to be challenging and to force you to consult t

Re: [Tutor] SQLite3 DB Field Alphabetizing

2010-10-12 Thread David Hutto
On Tue, Oct 12, 2010 at 10:23 AM, Alan Gauld wrote: > > "David Hutto" wrote > >> > Did you include an ORDER BY? >> >> See three posts above, line 6. > > Looks like our posts crossed in transit :-) > > So you order by graphname, and you only have a single field of that name? > But then when you pu

Re: [Tutor] SQLite3 DB Field Alphabetizing

2010-10-12 Thread David Hutto
Quick note: forgot to add that the initial db file is setup with the following: import sqlite3 as lite class db(object): def onNewProjSQLDB(self): self.con = lite.connect('/home/david/pythonfiles/pythonscripts/roughdraftapps/dataplot3/db/dpdb.db') self.cur