Re: [Tutor] how to sort a dictionary by values

2007-08-08 Thread Luke Paireepinart
wormwood_3 wrote: You can use d.__getitem__ as the key function for a sort of the keys. __getitem__() is the special method that is called for indexing a dictionary (or a list). Just curious: Is there a reason to use __getitem__() over itemgetter (used in the example in my reply)?

Re: [Tutor] Checking for custom error codes

2007-08-08 Thread Alan Gauld
wormwood_3 [EMAIL PROTECTED] wrote def lookup(self): ... for potdomain in self.potdomains: try: who.whois(potdomain) self.availdomains.append(potdomain) except 'NoSuchDomain': pass This may, however, be

Re: [Tutor] Large Scale Python websites

2007-08-08 Thread OkaMthembo
On 8/7/07, Mike Hansen [EMAIL PROTECTED] wrote: Is anyone aware of any large scale web apps developed in Python? Please let me know of any that you know of... I think that reddit.com switched from LISP to Python a while back. Mike ___

Re: [Tutor] comparing two numpy arrays

2007-08-08 Thread Andy Cheesman
Thats a great solution, thanks! I've googled a bit for manipulation of sets into other data structure(lists, arrays) and not seen much. Is the only way of interconversion a brute force method? i.e a = set([1, 2, 3]) b = [] for thing in a: b.append(thing) Andy

Re: [Tutor] how to sort a dictionary by values

2007-08-08 Thread Kent Johnson
wormwood_3 wrote: You can use d.__getitem__ as the key function for a sort of the keys. __getitem__() is the special method that is called for indexing a dictionary (or a list). Just curious: Is there a reason to use __getitem__() over itemgetter (used in the example in my reply)? The

Re: [Tutor] how to sort a dictionary by values

2007-08-08 Thread Kent Johnson
Tiger12506 wrote: Just curious: Is there a reason to use __getitem__() over itemgetter (used in the example in my reply)? __getitem__ is a method builtin to a dict object. itemgetter 1) has to be imported 2) is more generically used, therefore probably using a more generic/slower

Re: [Tutor] comparing two numpy arrays

2007-08-08 Thread Kent Johnson
Andy Cheesman wrote: I've googled a bit for manipulation of sets into other data structure(lists, arrays) and not seen much. Is the only way of interconversion a brute force method? i.e a = set([1, 2, 3]) b = [] for thing in a: b.append(thing) No, a set is a

Re: [Tutor] how to sort a dictionary by values

2007-08-08 Thread shawn bright
sorry all, i did mean greatest to least, thanks for all the help here shawn On 8/8/07, Kent Johnson [EMAIL PROTECTED] wrote: Tiger12506 wrote: Just curious: Is there a reason to use __getitem__() over itemgetter (used in the example in my reply)? __getitem__ is a method builtin to a

[Tutor] from netcat to socket

2007-08-08 Thread János Juhász
Dear All, I made a small script to emulate a jetdirect device and capture the data sent from SAP to three separate barcode printers. I need it to make backup for the SAP printing, as I can place the captured files onto a local server and place a small batch file beside them, that can be used

[Tutor] Removing tags with BeautifulSoup

2007-08-08 Thread Sebastien
Hi, I'm in the process of cleaning some html files with BeautifulSoup and I want to remove all traces of the tables. Here is the bit of the code that deals with tables: def remove(soup, tagname): for tag in soup.findAll(tagname): contents = tag.contents parent = tag.parent

Re: [Tutor] comparing two numpy arrays

2007-08-08 Thread Alan Gauld
Andy Cheesman [EMAIL PROTECTED] wrote only way of interconversion a brute force method? i.e a = set([1, 2, 3]) b = [] for thing in a: b.append(thing) Which looks a lot like a list comprehension: b = [member for member in Set([1,2,3])] HTH, -- Alan Gauld Author of the Learn to Program

[Tutor] dial-up from Python

2007-08-08 Thread Diego Lindoso
-- Diego Lindoso. Fone: 3466-2387 Cel : 9634-5993 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] comparing two numpy arrays

2007-08-08 Thread Alan Gauld
Kent Johnson [EMAIL PROTECTED] wrote No, a set is a sequence, you can convert it to a list directly: b = list(a) But this is better than an LC obviously! :-) Alan G ___ Tutor maillist - Tutor@python.org

Re: [Tutor] dial-up from Python

2007-08-08 Thread Luke Paireepinart
Diego Lindoso wrote: -- Diego Lindoso. Fone: 3466-2387 Cel : 9634-5993 Beeep! Beep beep boop boop beep cs shhk shhk csh [connection timeout] -Luke ___ Tutor maillist - Tutor@python.org

[Tutor] httplib exceptions

2007-08-08 Thread Bob Larsen
I have written a script which checks all of my servers at predetermined intervals. code: try: page = urllib2.urlopen(url) soup= page.read() reex = re.compile(regex) test = re.findall(reex,soup) except

Re: [Tutor] httplib exceptions

2007-08-08 Thread Kent Johnson
Bob Larsen wrote: I have written a script which checks all of my servers at predetermined intervals. code: try: page = urllib2.urlopen(url) soup= page.read() reex = re.compile(regex) test =

Re: [Tutor] httplib exceptions

2007-08-08 Thread Alan Gauld
Bob Larsen [EMAIL PROTECTED] wrote It won't help with your problem but... try: page = urllib2.urlopen(url) soup= page.read() reex = re.compile(regex) test = re.findall(reex,soup) You could change this to

Re: [Tutor] httplib exceptions

2007-08-08 Thread Kent Johnson
Alan Gauld wrote: There is a python Bug: http://sourceforge.net/tracker/index.php?func=detailaid=1486335group_id=5470atid=105470 http://sourceforge.net/tracker/index.php?func=detailaid=1486335group_id=5470atid=105470 that states this is caused by a missing EOF, and is not a big deal Any

[Tutor] Shelve problem

2007-08-08 Thread TheSarge
I have five data files, that are used to build a database. 1.txt 2.txt 3.txt 4.text 5.txt I want to build a database using a persistent dictionary (shelve). The specifications are that the key for each dictionary keyword pair, is the lefthand side value of the # sign, and the corresponding

Re: [Tutor] Shelve problem

2007-08-08 Thread Terry Carroll
On Wed, 8 Aug 2007, TheSarge wrote: I have five data files, that are used to build a database. 1.txt 2.txt 3.txt 4.text 5.txt I want to build a database using a persistent dictionary (shelve). The specifications are that the key for each dictionary keyword pair, is the lefthand

[Tutor] Bookpool sale on Addison Wesley

2007-08-08 Thread Kent Johnson
Bookpool is having a sale on all books from Addison-Wesley and Prentice Hall. In my opinion these are two of the best publishers for top-notch computer titles. A few Python books on sale: Core Python Programming $27.25 http://www.bookpool.com/sm/0132269937 Rapid Web Applications with