Re: [Tutor] assign all parameters of __init__ to class variables?

2011-11-03 Thread Steven D'Aprano
Alex Hall wrote: I'm sorry, I misspoke (well, mistyped anyway). I have a couple class-level variables, but most of them are set in the __init__ so that every instance gets a fresh copy of them. Thatnks for the responses. Ah I see, or at least I think I see. Possibly we're talking at cross-pur

Re: [Tutor] Paper Rock Scissors game - User's choice not returned properly

2011-11-03 Thread Alan Gauld
On 04/11/11 01:42, Steven D'Aprano wrote: Alan Gauld wrote: If you're worried about the screen space and/or keystrokes, you can do this: if direction.upper() in tuple('NSEW'): ... It's not so much the keystrokes that I don't like but it's the fact that I invariably miss out a quote or a co

Re: [Tutor] improve the code

2011-11-03 Thread Peter Camilleri
Not sure if that is what you are after since you are calling re.split() using items when Peter was using re.split() on a single item within items so instead of this parts = re.split(r"(\d+)", str(items)) try specifying just one item, like this parts = re.split(r"(\d+)", items[0]) On Fri, Nov 4, 2

Re: [Tutor] improve the code

2011-11-03 Thread Dave Angel
On 11/03/2011 10:39 PM, lina wrote: On Wed, Nov 2, 2011 at 12:14 AM, Peter Otten<__pete...@web.de> wrote: lina wrote: items [('83ILE', 1), ('84ALA', 2), ('8SER', 0), ('9GLY', 0)] parts = re.split(r"(\d+)",items) Traceback (most recent call last): File "", line 1, in parts = re.s

Re: [Tutor] improve the code

2011-11-03 Thread lina
On Fri, Nov 4, 2011 at 10:39 AM, lina wrote: > On Wed, Nov 2, 2011 at 12:14 AM, Peter Otten <__pete...@web.de> wrote: >> lina wrote: >> sorted(new_dictionary.items()) >>> >>> Thanks, it works, but there is still a minor question, >>> >>> can I sort based on the general numerical value? >>> >>

Re: [Tutor] improve the code

2011-11-03 Thread lina
On Wed, Nov 2, 2011 at 12:14 AM, Peter Otten <__pete...@web.de> wrote: > lina wrote: > >>> sorted(new_dictionary.items()) >> >> Thanks, it works, but there is still a minor question, >> >> can I sort based on the general numerical value? >> >> namely not: >> : >> : >> 83ILE 1 >> 84ALA 2 >> 8SER 0 >

Re: [Tutor] Paper Rock Scissors game - User's choice not returned properly

2011-11-03 Thread Steven D'Aprano
Alan Gauld wrote: Use the list form, even though it does involve a few more keystrokes and a lot more screen space. The extra typing to avoid the problems are not worth it! :-) If you're worried about the screen space and/or keystrokes, you can do this: if direction.upper() in tuple('NSEW'):

Re: [Tutor] Creating Android Apps w/ Python

2011-11-03 Thread Steven D'Aprano
Mike Nickey wrote: I'm currently taking a class on Android Development. The instructor says that the code needed has to be done through Java. Isn't there any way to create these same apps with Python? This is not really the place to be asking this sort of question. This list is focused on lear

Re: [Tutor] binding problem

2011-11-03 Thread Alan Gauld
On 03/11/11 13:01, Chris Hare wrote: Thanks for the advice. When I do that, I get this error Exception in Tkinter callback Traceback (most recent call last): File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/Tkinter.py", line 1410, in __call__ return

Re: [Tutor] how to separate the digital and the alphabeta

2011-11-03 Thread Dave Angel
On 11/03/2011 12:37 PM, lina wrote: I have another question, regarding the generator, def translate_process(dictionary,tobetranslatedfile): results=[] with open(tobetranslatedfile,"r") as f: results=(dictionary[line.split()[2]] for line in f) print(list(results))

Re: [Tutor] how to separate the digital and the alphabeta

2011-11-03 Thread Dave Angel
On 11/03/2011 12:30 PM, lina wrote: Hi, ['1AB','57GL', '76LE'] How can I extract 1, 57 , 76 out? except the one I tried as: for i in range(len(a)): print(a[i][:-2]) 1 57 76 are there some way to tell the difference between the [0-9] and [A-Z], In the last thread, somebod

Re: [Tutor] how to separate the digital and the alphabeta

2011-11-03 Thread lina
I have another question, regarding the generator, def translate_process(dictionary,tobetranslatedfile): results=[] with open(tobetranslatedfile,"r") as f: results=(dictionary[line.split()[2]] for line in f) print(list(results)) print(len(list(results))) Here the

[Tutor] how to separate the digital and the alphabeta

2011-11-03 Thread lina
Hi, ['1AB','57GL', '76LE'] How can I extract 1, 57 , 76 out? except the one I tried as: >>> for i in range(len(a)): print(a[i][:-2]) 1 57 76 are there some way to tell the difference between the [0-9] and [A-Z], Thanks for the help (you will give and you have given). Best r

Re: [Tutor] binding problem

2011-11-03 Thread Chris Hare
That helps Wayne - and was what I was referring to when I posted that I thought I had figured it out. Thanks for your help. Chris Hare ch...@labr.net http://www.labr.net On Nov 3, 2011, at 10:08 AM, Wayne Werner wrote: > On Thu, Nov 3, 2011 at 9:41 AM, Chris Hare wrote: > Thanks Peter. Actu

Re: [Tutor] binding problem

2011-11-03 Thread Wayne Werner
On Thu, Nov 3, 2011 at 9:41 AM, Chris Hare wrote: > Thanks Peter. Actually, I have read a bunch of stuff and looked at > example code. The problem in this case is I am using a defined method - > focus_set(), which is part of Tkinter and isn't part of my code. since I > am using it in the manne

Re: [Tutor] binding problem

2011-11-03 Thread Chris Hare
Thanks Peter. Actually, I have read a bunch of stuff and looked at example code. The problem in this case is I am using a defined method - focus_set(), which is part of Tkinter and isn't part of my code. since I am using it in the manner in which I have seen other examples, I am confused abou

Re: [Tutor] binding problem

2011-11-03 Thread Peter Otten
Chris Hare wrote: > Thanks for the advice. When I do that, I get this error > > Exception in Tkinter callback > Traceback (most recent call last): > File > "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib- tk/Tkinter.py", > line 1410, in __call__ > return se

Re: [Tutor] binding problem

2011-11-03 Thread Dave Angel
(You mistakenly top-posted, so now in order to keep this next message in order, I have to delete the out of order history) On 11/03/2011 09:01 AM, Chris Hare wrote: Thanks for the advice. When I do that, I get this error Exception in Tkinter callback Traceback (most recent call last): File

Re: [Tutor] binding problem

2011-11-03 Thread Chris Hare
Thanks for the advice. When I do that, I get this error Exception in Tkinter callback Traceback (most recent call last): File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/Tkinter.py", line 1410, in __call__ return self.func(*args) TypeError: focus_set() t

Re: [Tutor] frame destroy problem

2011-11-03 Thread Chris Hare
Dang it - sure is a typo! Thanks! Chris Hare ch...@labr.net http://www.labr.net On Nov 3, 2011, at 12:58 AM, Dipo Elegbede wrote: > There is nothing called franeButton it should be frameButton. I guess its a > typo. > > On 3 Nov 2011 05:52, "Chris Hare" wrote: > > > I have the foll

Re: [Tutor] binding problem

2011-11-03 Thread Alan Gauld
On 03/11/11 04:46, Chris Hare wrote: I have a Listbox defined self.list = Listbox(self.frame) What I want to do is when the user either single clicks, double clicks, presses tab or return, move the focus to the specified field self.list.bind("", self.login_userid.focus_set()

Re: [Tutor] Creating Android Apps w/ Python

2011-11-03 Thread Sander Sweers
On Thu,  3 Nov 2011, 06:12:58 CET, Mike Nickey wrote: > I am hoping that there is a Python ADK that will allow creation of > apps with Python but I haven't seen one and wanted to see what you know is > out there. Linux journal has an article on this [1]. I have no experience in this but it lo