Re: [Tutor] help with list permutations

2008-01-04 Thread Kent Johnson
Chris Fuller wrote: > This is a good case for recursion. My solution is in two steps. > Here is the code: > > def recursion_is_your_friend(l): >if len(l) == 1: > return l >else: > return [ (i, recursion_is_your_friend(l[1:])) for i in l[0] ] > > l = recursion_is_your_friend([[

Re: [Tutor] how to compare elements of 2 lists

2008-01-04 Thread Remco Gerlich
Hi, a = [4,3,2,6,7,9] b = [8,6,3,3,2,7] You can turn this into a list of two element tuples with zip(): >>> zip(a,b) [ (4,8),(3,6,),(2,3),(6,3),(7,2),(9,7) ] Now you can loop through that and compare both elements, for instance I believe this list comprehension is what you're looking for: [ t[0

[Tutor] Snakes and Ladders

2008-01-04 Thread James Newton
Hi Python People! I've recently started learning Python in order to create educational content for the One Laptop Per Child project: The first application I'm working on is a game of Snakes and Ladders, to help younger children understand the conce

[Tutor] Tkinter OptionMenu question

2008-01-04 Thread Michael Schultz
Hello list! I was wondering if any of you could help me with this: I've got a small GUI connected to a SQLite DB. My OptionMenu pulls a category list from the DB, and there's a field to add a new Category if you need to. Now, I'd like the have the OptionMenu update with the new category after the

Re: [Tutor] Review and criticism of python project

2008-01-04 Thread GTXY20
There are no errors per se - the script is doing what it needs to I guess I just want to check it for compliance - for some reason I think itis a mess and should be much cleaner. I am only concerned with one particular area of the complete project - it is 229 lines in total - would this be too muc

Re: [Tutor] Review and criticism of python project

2008-01-04 Thread bob gailer
GTXY20 wrote: > > There are no errors per se - the script is doing what it needs to I > guess I just want to check it for compliance - for some reason I think > itis a mess and should be much cleaner. > > I am only concerned with one particular area of the complete project - > it is 229 line

Re: [Tutor] Snakes and Ladders (is: PNG transparency)

2008-01-04 Thread James Newton
Hello again Python Programmers! To reply to my own question: -Original Message- I'm importing a graphic named Counter_1.png for the counter. I'd like its background to be transparent, using the PNG's built-in alpha channel. -- I've modified the code at...

Re: [Tutor] Review and criticism of python project

2008-01-04 Thread GTXY20
Hi there. What this section area does is takes a data file that is comma separated and imports - there is a unique ID in the first field and a code in the second field that corresponds to a certain section of information. What I need from this is for the process to role up against unique ID all se

Re: [Tutor] Tkinter OptionMenu question

2008-01-04 Thread Tiger12506
Try the .add_command(...) method. > Hello list! > > I was wondering if any of you could help me with this: > > I've got a small GUI connected to a SQLite DB. My OptionMenu pulls a > category list from the DB, and there's a field to add a new Category if > you > need to. Now, I'd like the have th

[Tutor] Program review

2008-01-04 Thread Ricardo Aráoz
Considering we are reviewing programs I'd like to submit one of mine and I would be thankful for any critic/improvement you can suggest. My ex needs to send mails to a long list of customers, problem is that she can not send more than 70 every 10 minutes or her ISP will consider her a spammer. So s

Re: [Tutor] Program review

2008-01-04 Thread Tiger12506
> This~~ works, but may be a little inefficient. Especially the double > addr.strip() here. Given, it doesn't really matter, but I like even better > Perhaps a use of sets here... particularly intersection somehow... Whoops, I'm not versed in sets (blush) I meant difference_update _

Re: [Tutor] Program review

2008-01-04 Thread Tiger12506
After quickly looking over the code, I find it has a good foundation, it seems to have been designed very solidly. I haven't looked very closely, but if the messages are mostly alike with just one or two slight differences, you might consider dynamically creating the messages (from a customer li

Re: [Tutor] Review and criticism of python project

2008-01-04 Thread Alan Gauld
"GTXY20" <[EMAIL PROTECTED]> wrote > Sorry for the lengthly code response - all commenst are > appreciated - as > mentioned I am quite new with Python - it is doing what I need it to > do but > I think that it is a mess and needs to be cleaned up a little. I've only skimmed it very quickly and

Re: [Tutor] Review and criticism of python project

2008-01-04 Thread Tiger12506
Cool! Code! (gullom voice - we must look at code, yesss) > Hi there. > > What this section area does is takes a data file that is comma separated > and > imports - there is a unique ID in the first field and a code in the second > field that corresponds to a certain section of information. Wh

[Tutor] classes and the deepcopy function

2008-01-04 Thread Michael
Hi I was trying to learn about classes in Python and have been playing around but I am having a problem with the deepcopy function. I want to have a function that returns a clean copy of an object that you can change without it changing the original, but no matter what I do the original change

Re: [Tutor] Review and criticism of python project

2008-01-04 Thread Kent Johnson
Tiger12506 wrote: > Ouch. Usually in OOP, one never puts any user interaction into a class. That seems a bit strongly put to me. Generally user interaction should be separated from functional classes but you might have a class to help with command line interaction (e.g. the cmd module in the s

[Tutor] classes and the deepcopy function

2008-01-04 Thread Michael H. Goldwasser
Hi Michael, This is a very interesting example. You do indeed have two distinct copies. The interdependence you are observing is because you have defined CLASS-LEVEL variables (akin to static in Java) rather than instance-level variables. This is because of their declaration within th

Re: [Tutor] Program review

2008-01-04 Thread Kent Johnson
Ricardo Aráoz wrote: > except Exception, e : > logging.error('No pude leer "config.cfg" : %s', e.strerror) You might like to use logging.error('No pude...', exc_info=True) which will include the full traceback in the log. You can use the exc_info keyword with any of the lo

Re: [Tutor] Review and criticism of python project

2008-01-04 Thread GTXY20
thanks for the feedback - i will go through your comments line by line adjust and test and will re-post when complete. GTXY20 On Jan 4, 2008 9:29 PM, Kent Johnson <[EMAIL PROTECTED]> wrote: > Tiger12506 wrote: > > > Ouch. Usually in OOP, one never puts any user interaction into a class. > > That

Re: [Tutor] classes and the deepcopy function

2008-01-04 Thread Michael
Hi Michael Thanks for the quick reply, I think I get it. So becuase I did not declare them withing the init method using self they are shared by every object that is created, even completely brand new ones? Is it normal practice to declare your variables in a class? I notice that you don't hav