Re: [Tutor] unittest + tkinter

2010-11-02 Thread Alan Gauld
"Wayne Werner" wrote I'm trying my hand at test driven development via the unittest module. Since my program is using Tkinter, my thought is that I need to create the main window. The only problem is that when I launch the main loop, further lines of code aren't executed. Thats a feature

[Tutor] True Random Numbers

2010-11-02 Thread Crallion
In an attempt to generate "true" random numbers, I found this python script- http://code.google.com/p/truerandom/ Getting to the point, I get this error when I run my program. File "/dev/python/absolute/truerandom.py", line 9, in from urllib import urlopen ImportError: cannot import name url

Re: [Tutor] Complete Shutdown

2010-11-02 Thread Timo
On 01-11-10 21:01, Chris King wrote: Dear Tutors, How do I completely shutdown a computer without administrative rights using a simple python script. I once came across the following when playing with dbus. import dbus bus = dbus.SystemBus() bus_object = bus.get_object("org.freedesktop.Ha

Re: [Tutor] True Random Numbers

2010-11-02 Thread Christian Witts
On 02/11/2010 11:29, Crallion wrote: In an attempt to generate "true" random numbers, I found this python script- http://code.google.com/p/truerandom/ Getting to the point, I get this error when I run my program. File "/dev/python/absolute/truerandom.py", line 9, in from urllib import urlo

Re: [Tutor] True Random Numbers

2010-11-02 Thread Steven D'Aprano
Crallion wrote: In an attempt to generate "true" random numbers, Have you considered using your operating system's source of random numbers? random.SystemRandom and os.urandom return numbers which are cryptographically sound. They are also based on various sources of physical randomness (whi

[Tutor] mutable types

2010-11-02 Thread John
Hello, I thought the following should end with G[1] and G[0] returning 20. Why doesn't it? In [69]: a = 10 In [70]: G = {} In [71]: G[0] = [a] In [72]: G[1] = G[0] In [73]: a = 20 In [74]: G[1] Out[74]: [10] In [75]: G[0] Out[75]: [10] ?? ___ Tutor mail

Re: [Tutor] mutable types

2010-11-02 Thread Knacktus
Am 02.11.2010 13:51, schrieb John: Hello, I thought the following should end with G[1] and G[0] returning 20. Why doesn't it? In [69]: a = 10 "a" is a reference to an immutable object of type int with value 10. Somewhere in memory is an object of type int with value 10 stored. This object cann

Re: [Tutor] mutable types

2010-11-02 Thread Steven D'Aprano
John wrote: Hello, I thought the following should end with G[1] and G[0] returning 20. Why doesn't it? In [69]: a = 10 In [70]: G = {} In [71]: G[0] = [a] In [72]: G[1] = G[0] In [73]: a = 20 In [74]: G[1] Out[74]: [10] In [75]: G[0] Out[75]: [10] This doesn't actually have anything to do with

[Tutor] if statement

2010-11-02 Thread Glen Clark
File "/home/glen/workspace/test.py", line 19 if confirmed == "y": ^ SyntaxError: invalid syntax Why does this not work??? PyDev says "Expected:else" ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscriptio

Re: [Tutor] if statement

2010-11-02 Thread Alex Hall
On 11/2/10, Glen Clark wrote: > File "/home/glen/workspace/test.py", line 19 > if confirmed == "y": >^ > SyntaxError: invalid syntax > > Why does this not work??? PyDev says "Expected:else" It may help to see the rest of the file, or at least more of the code surroundi

Re: [Tutor] if statement

2010-11-02 Thread Glen Clark
sorry: NumItems = int(input("How many Items: ")) Entries = [] for In in range(0,NumItems): Entries.append("") for In in range(0,NumItems): Entries[In]=str(input("Enter name " + str(In+1) + ": ")) for In in range(0,NumItems): print(Entries[In]) confirmed = int(input("Are

Re: [Tutor] if statement

2010-11-02 Thread Adam Bark
On 02/11/10 19:02, Glen Clark wrote: File "/home/glen/workspace/test.py", line 19 if confirmed == "y": ^ SyntaxError: invalid syntax Why does this not work??? PyDev says "Expected:else" It's hard to tell without context. Can you send the code around it as well

Re: [Tutor] if statement

2010-11-02 Thread delegbede
It is not always enough to send just the error. What construct do you have after the if line? Make your sample detailed to get useful responses. Regards. Sent from my BlackBerry wireless device from MTN -Original Message- From: Glen Clark Sender: tutor-bounces+delegbede=dudupay@p

Re: [Tutor] if statement

2010-11-02 Thread James Reynolds
the syntax is: if True: do something that you want to do if the condition you are testing is True, in your case when confirmed is "y" elif True: optional: do something else when the above condition is false and this condition is True. else: do something else when the above condition

Re: [Tutor] if statement

2010-11-02 Thread Glen Clark
I tried that and it still does not work. On Tue, 2010-11-02 at 15:13 -0400, James Reynolds wrote: > the syntax is: > > > if True: > do something that you want to do if the condition you are testing > is True, in your case when confirmed is "y" > elif True: > optional: do something els

Re: [Tutor] if statement

2010-11-02 Thread Adam Bark
On 02/11/10 19:07, Glen Clark wrote: sorry: NumItems = int(input("How many Items: ")) Entries = [] for In in range(0,NumItems): Entries.append("") for In in range(0,NumItems): Entries[In]=str(input("Enter name " + str(In+1) + ": ")) for In in range(0,NumItems): print(E

Re: [Tutor] if statement

2010-11-02 Thread Vince Spicer
On Tue, Nov 2, 2010 at 1:07 PM, Glen Clark wrote: > sorry: > > NumItems = int(input("How many Items: ")) > > > Entries = [] > for In in range(0,NumItems): > Entries.append("") > > > > for In in range(0,NumItems): > Entries[In]=str(input("Enter name " + str(In+1) + ": ")) > > > for In in range

Re: [Tutor] if statement

2010-11-02 Thread Joel Goldstick
On Tue, Nov 2, 2010 at 3:17 PM, Glen Clark wrote: > I tried that and it still does not work. > > On Tue, 2010-11-02 at 15:13 -0400, James Reynolds wrote: > > the syntax is: > > > > > > if True: > > do something that you want to do if the condition you are testing > > is True, in your case wh

Re: [Tutor] if statement

2010-11-02 Thread Glen Clark
Okay, Thank you very much for the help guys :) On a side note.. I didn't know you could do something like this: x = z if (thus why I needed the closing parenthesis) ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription o

Re: [Tutor] if statement

2010-11-02 Thread christopher . henk
Glen Clark wrote on 11/02/2010 03:07:18 PM: in general you should use raw_input instead of input. > confirmed = int(input("Are you happy with this? (y/n): ") > you are missing a closing parenthesis above, and converting a string (y,n) to and int > if confirmed == "y": you are comparing an in

Re: [Tutor] if statement

2010-11-02 Thread Joel Goldstick
On Tue, Nov 2, 2010 at 3:34 PM, Adam Bark wrote: > On 02/11/10 19:07, Glen Clark wrote: > >> sorry: >> >> NumItems = int(input("How many Items: ")) >> >> >> Entries = [] >> for In in range(0,NumItems): >>Entries.append("") >> >> >> >> for In in range(0,NumItems): >>Entries[In]=str(input("

Re: [Tutor] if statement

2010-11-02 Thread Emile van Sebille
On 11/2/2010 12:07 PM Glen Clark said... sorry: NumItems = int(input("How many Items: ")) Entries = [] for In in range(0,NumItems): Entries.append("") for In in range(0,NumItems): Entries[In]=str(input("Enter name " + str(In+1) + ": ")) for In in range(0,NumItems): pri

Re: [Tutor] if statement

2010-11-02 Thread Alan Gauld
"Glen Clark" wrote confirmed = int(input("Are you happy with this? (y/n): ") if confirmed == "y": count the parens. It thinks you are trying to do: confimed = int(input('') if foo else bar) HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ __

Re: [Tutor] if statement

2010-11-02 Thread Adam Bark
On 02/11/10 19:36, christopher.h...@allisontransmission.com wrote: Glen Clark wrote on 11/02/2010 03:07:18 PM: in general you should use raw_input instead of input. > confirmed = int(input("Are you happy with this? (y/n): ") > It would appear that Glen is using python 3.x as he used the pri

Re: [Tutor] if statement

2010-11-02 Thread bob gailer
On 11/2/2010 3:07 PM, Glen Clark wrote: sorry: NumItems = int(input("How many Items: ")) Entries = [] for In in range(0,NumItems): Entries.append("") for In in range(0,NumItems): Entries[In]=str(input("Enter name " + str(In+1) + ": ")) for In in range(0,NumItems): prin

Re: [Tutor] if statement

2010-11-02 Thread Robert Berman
> -Original Message- > From: tutor-bounces+bermanrl=cfl.rr@python.org [mailto:tutor- > bounces+bermanrl=cfl.rr@python.org] On Behalf Of Glen Clark > Sent: Tuesday, November 02, 2010 3:07 PM > To: python mail list > Subject: Re: [Tutor] if statement > > sorry: > > > confirmed =

Re: [Tutor] if statement

2010-11-02 Thread Alan Gauld
"Glen Clark" wrote On a side note.. I didn't know you could do something like this: x = z if Yes it's python's equivalent to the C style foo = testVal() ? bar : baz Also found in other languages (Java, Javascript, Perl?) Alan G. ___ Tu