[Tutor] keep from opening multiple Toplevel windows

2008-10-03 Thread dwbarne
I have a Tkinter button widget that when pressed invokes a Toplevel window call each time. The Toplevel window thus generated has a close button on it. As you might guess, when multiple Toplevel windows are open, I can press on a 'close' button to '.destroy' the window, but all other Toplevel wi

Re: [Tutor] UnicodeEncodeError

2008-10-03 Thread Kent Johnson
On Fri, Oct 3, 2008 at 2:39 PM, Rob Sutherland <[EMAIL PROTECTED]> wrote: > On Fri, Oct 3, 2008 at 12:23 PM, Kent Johnson <[EMAIL PROTECTED]> wrote: > >> It helps if you show the code that is causing the error and the full >> traceback. Presumably you are calling someString.encode("some >> encoding

Re: [Tutor] Coin Flip

2008-10-03 Thread bhaaluu
First off, check your program's indentation. On Fri, Oct 3, 2008 at 2:04 PM, realNewbie <[EMAIL PROTECTED]> wrote: > > This is a class assignment, I am to create a program that flips a coin 100 > times and tells me the number of heads and tails. > I've been working on it for 2 days now and I am st

Re: [Tutor] Coin Flip

2008-10-03 Thread taserian
Since the variable *count* never increases inside of the loop body, it gets stuck in the *while* loop. I recommend taking a hard look at the program, consider what it should be doing, and then seeing which statements should be in the *while* loop, and which ones should be outside it. Tony R. On

Re: [Tutor] UnicodeEncodeError

2008-10-03 Thread Kent Johnson
On Fri, Oct 3, 2008 at 1:50 PM, Rob Sutherland <[EMAIL PROTECTED]> wrote: > I'm working on a python application that stores email in a postgresql > database and > I'm encountering the UnicodeEncodeError - while storing a particular > email I receive > this error > > UnicodeEncodeError: 'charmap' co

[Tutor] Coin Flip

2008-10-03 Thread realNewbie
This is a class assignment, I am to create a program that flips a coin 100 times and tells me the number of heads and tails. I've been working on it for 2 days now and I am stuck. I a trying to run the program but it is not running. Can someone please point out my error? Here is what I have com

Re: [Tutor] assigning values to dictionary

2008-10-03 Thread jeremiah
Awesome. Thanks! On Fri, 2008-10-03 at 11:07 -0700, Steve Willoughby wrote: > On Fri, Oct 03, 2008 at 11:02:34AM -0700, jeremiah wrote: > > i think i figured it out. The result is that I have a dictionary > within > > a dictionary..i think. > > > > for example: > > > > {'mcdonalds': {'hamburger':

Re: [Tutor] assigning values to dictionary

2008-10-03 Thread Steve Willoughby
On Fri, Oct 03, 2008 at 11:02:34AM -0700, jeremiah wrote: > i think i figured it out. The result is that I have a dictionary within > a dictionary..i think. > > for example: > > {'mcdonalds': {'hamburger': 'big mac','drink':'coke'}} > > How would I go about itterating through this? Depends on h

Re: [Tutor] assigning values to dictionary

2008-10-03 Thread W W
On Fri, Oct 3, 2008 at 1:02 PM, jeremiah <[EMAIL PROTECTED]>wrote: > i think i figured it out. The result is that I have a dictionary within > a dictionary..i think. > > for example: > > {'mcdonalds': {'hamburger': 'big mac','drink':'coke'}} > > How would I go about itterating through this? > for

Re: [Tutor] assigning values to dictionary

2008-10-03 Thread jeremiah
i think i figured it out. The result is that I have a dictionary within a dictionary..i think. for example: {'mcdonalds': {'hamburger': 'big mac','drink':'coke'}} How would I go about itterating through this? Thanks, JJ On Fri, 2008-10-03 at 10:39 -0700, Steve Willoughby wrote: > On Fri, Oct

[Tutor] UnicodeEncodeError

2008-10-03 Thread Rob Sutherland
I'm working on a python application that stores email in a postgresql database and I'm encountering the UnicodeEncodeError - while storing a particular email I receive this error UnicodeEncodeError: 'charmap' codec can't encode character u'\u2019' in position 144: character maps to I'm a little

Re: [Tutor] assigning values to dictionary

2008-10-03 Thread Steve Willoughby
On Fri, Oct 03, 2008 at 10:29:13AM -0700, jeremiah wrote: > I have a list of dictionary values that i am looping through that upon > each iteration I would like to assign these values to a new dictionary > name. > > For example... > > item=0 > for line in some_dict: > ## some how assign di

Re: [Tutor] Hands-on beginner's project?

2008-10-03 Thread Steve Willoughby
On Fri, Oct 03, 2008 at 09:38:56AM -0700, Chris Babcock wrote: > room = 1 > while 1: Also, it may be more clear to say "while True:" in preference to "while 1:". Note that in your earlier version you didn't capitalize "True" which meant Python had no idea what that value was (could be a variable

[Tutor] assigning values to dictionary

2008-10-03 Thread jeremiah
I have a list of dictionary values that i am looping through that upon each iteration I would like to assign these values to a new dictionary name. For example... item=0 for line in some_dict: ## some how assign dict values to new name "new_dict_name_"+item = line I have not tes

Re: [Tutor] Hands-on beginner's project?

2008-10-03 Thread Chris Babcock
> Loops, then? The code this is based off of had the second line of > actual code (between "room = 1" and "if room ==1") as "while true:", > but when I include this, it gives an error at that line. Is there > another way to do that? Maybe "while room != 4.2"? What you had before was... room =

Re: [Tutor] How trustworthy are pseudo-random numbers?

2008-10-03 Thread Robert Berman
Andre Engels wrote: On Fri, Oct 3, 2008 at 5:25 PM, Luke Paireepinart <[EMAIL PROTECTED]> wrote: Is your math correct? That's ridiculously large. 1 year equals 3600 * 24 * 365 makes about 3*10^8 seconds. The universe is about 15.000.000.000 years old, that's about 5*1

Re: [Tutor] How trustworthy are pseudo-random numbers?

2008-10-03 Thread Daniele
2008/10/3 Andre Engels <[EMAIL PROTECTED]>: > On Fri, Oct 3, 2008 at 4:11 PM, Daniele <[EMAIL PROTECTED]> wrote: > If you used every atom in the known universe as a computer, then let > them turn out a billion combinations a second for the entire time > since the big bang, and call the number of co

Re: [Tutor] How trustworthy are pseudo-random numbers?

2008-10-03 Thread Andre Engels
On Fri, Oct 3, 2008 at 5:32 PM, Andre Engels <[EMAIL PROTECTED]> wrote: > On Fri, Oct 3, 2008 at 5:25 PM, Luke Paireepinart > <[EMAIL PROTECTED]> wrote: >> Is your math correct? That's ridiculously large. > > 1 year equals 3600 * 24 * 365 makes about 3*10^8 seconds. > The universe is about 15.000.

Re: [Tutor] How trustworthy are pseudo-random numbers?

2008-10-03 Thread Andre Engels
On Fri, Oct 3, 2008 at 5:25 PM, Luke Paireepinart <[EMAIL PROTECTED]> wrote: > Is your math correct? That's ridiculously large. 1 year equals 3600 * 24 * 365 makes about 3*10^8 seconds. The universe is about 15.000.000.000 years old, that's about 5*10^17 seconds. With 1 billion combinations per s

Re: [Tutor] How trustworthy are pseudo-random numbers?

2008-10-03 Thread Luke Paireepinart
Is your math correct? That's ridiculously large. On Fri, Oct 3, 2008 at 10:03 AM, Andre Engels <[EMAIL PROTECTED]> wrote: > On Fri, Oct 3, 2008 at 4:11 PM, Daniele <[EMAIL PROTECTED]> wrote: >> >From here >> http://en.wikipedia.org/wiki/Pseudorandom_number_generator#Periodicity >> and here >> htt

Re: [Tutor] Apress on sale at Bookpool

2008-10-03 Thread Kent Johnson
Oops, that's October, not December! On Fri, Oct 3, 2008 at 11:08 AM, Kent Johnson <[EMAIL PROTECTED]> wrote: > Bookpool.com is selling Apress titles at 50% off for December. Apress > has many good Python titles: > > For learning Python: > - Beginning Python: From Novice to Professional, Second Edi

[Tutor] Apress on sale at Bookpool

2008-10-03 Thread Kent Johnson
Bookpool.com is selling Apress titles at 50% off for December. Apress has many good Python titles: For learning Python: - Beginning Python: From Novice to Professional, Second Edition - Dive Into Python Django: - The Definitive Guide to Django: Web Development Done Right - Practical Django Projec

Re: [Tutor] How trustworthy are pseudo-random numbers?

2008-10-03 Thread Andre Engels
On Fri, Oct 3, 2008 at 4:11 PM, Daniele <[EMAIL PROTECTED]> wrote: > >From here > http://en.wikipedia.org/wiki/Pseudorandom_number_generator#Periodicity > and here > http://en.wikipedia.org/wiki/Mersenne_twister#Advantages > > I think it can be argued that the randomness is pretty trustworthy :o)

Re: [Tutor] Hands-on beginner's project?

2008-10-03 Thread nathan virgil
On Fri, Oct 3, 2008 at 10:24 AM, nathan virgil <[EMAIL PROTECTED]>wrote: > > > On Fri, Oct 3, 2008 at 10:02 AM, Luke Paireepinart <[EMAIL PROTECTED] > > wrote: > >> On Fri, Oct 3, 2008 at 8:50 AM, nathan virgil <[EMAIL PROTECTED]> >> wrote: >> > >> > >> > On Fri, Oct 3, 2008 at 9:19 AM, David <[EM

Re: [Tutor] Hands-on beginner's project?

2008-10-03 Thread nathan virgil
On Fri, Oct 3, 2008 at 10:02 AM, Luke Paireepinart <[EMAIL PROTECTED]>wrote: > On Fri, Oct 3, 2008 at 8:50 AM, nathan virgil <[EMAIL PROTECTED]> > wrote: > > > > > > On Fri, Oct 3, 2008 at 9:19 AM, David <[EMAIL PROTECTED]> wrote: > >> > >> > Okay, I'm resurrecting this project. > >> Where is this

Re: [Tutor] How trustworthy are pseudo-random numbers?

2008-10-03 Thread Daniele
>> [Alec Henriksen] >> > How trustworthy is the "randomness" generated by the random module? >> >> Python uses the Mersenne Twister algorithm for generating >> pseudo-random numbers, and that's one of the highest-quality methods >> known. >From here http://en.wikipedia.org/wiki/Pseudorandom_number

Re: [Tutor] Hands-on beginner's project?

2008-10-03 Thread Luke Paireepinart
On Fri, Oct 3, 2008 at 8:50 AM, nathan virgil <[EMAIL PROTECTED]> wrote: > > > On Fri, Oct 3, 2008 at 9:19 AM, David <[EMAIL PROTECTED]> wrote: >> >> > Okay, I'm resurrecting this project. >> Where is this project code? > It seems like good code, It's not. > # Content > # retrieve data for curren

Re: [Tutor] Hands-on beginner's project?

2008-10-03 Thread nathan virgil
On Fri, Oct 3, 2008 at 9:19 AM, David <[EMAIL PROTECTED]> wrote: > > Okay, I'm resurrecting this project. > Where is this project code? > Right here. The content is going to eventually go through some drastic changes, but what's here should be good enough for testing.

Re: [Tutor] Hands-on beginner's project?

2008-10-03 Thread David
> Okay, I'm resurrecting this project. Where is this project code? -- Have Fun, David A. Powered by Gentoo GNU/LINUX http://www.linuxcrazy.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Finding the "streaks" in heads/tails list

2008-10-03 Thread nathan virgil
You need to store the count before resetting it since you want > to know the largest value of count over the list. Or at least keep a > separate max variable that you update if count > max. > Fairly easy: if Cur_Count > Max_Count: Max_Count = Cur_Count See? Just two extra lines of code. _

Re: [Tutor] Hands-on beginner's project?

2008-10-03 Thread nathan virgil
Hm... Tried changing that, but it didn't help On Thu, Oct 2, 2008 at 9:18 AM, Luke Paireepinart <[EMAIL PROTECTED]>wrote: > room == start is a comparison (check if room is equal to start - doesn't > make a whole lot of sense to be doing that here). The "room" variable name > doesn't exist in

Re: [Tutor] How trustworthy are pseudo-random numbers?

2008-10-03 Thread W W
On Fri, Oct 3, 2008 at 12:44 AM, Tim Peters <[EMAIL PROTECTED]> wrote: > [Alec Henriksen] > > How trustworthy is the "randomness" generated by the random module? > > Python uses the Mersenne Twister algorithm for generating > pseudo-random numbers, and that's one of the highest-quality methods > k

Re: [Tutor] dealing with user input whose value I don't know

2008-10-03 Thread Alan Gauld
"David" <[EMAIL PROTECTED]> wrote the string into substrings and then convert each substring to an integer. This I have now done by using eval(). But now I wonder whether that is actually clever because it is supposed to be similarly problematic as the input() function in terms of security.

Re: [Tutor] dealing with user input whose value I don't know

2008-10-03 Thread David
Hello Alan, dear list members, Alan Gauld wrote: The solution you have already seen - use string.split(',') to separate the string into substrings and then convert each substring to an integer. This I have now done by using eval(). But now I wonder whether that is actually clever because it is