Re: [Tutor] Tutor Digest, Vol 101, Issue 12

2012-07-04 Thread Osemeka Osuagwu
Hi Alan, I appreciate the tip. Using the operator module does look better, the speed is about the same too. Thanks. Abasiemeka -- > > Message: 3 > Date: Wed, 04 Jul 2012 18:13:36 +0100 > From: Alan Gauld > To: tutor@python.org > Subject: Re: [Tutor] Bothersome NoneTyp

Re: [Tutor] VPYTHON (Emile van Sebille)

2012-07-04 Thread Osemeka Osuagwu
if k%x == 0: > return True > return False > > def lcm(numlist): #continuously divides numlist by each in a > list of prime numbers till cannot > primeslist = [2, 3, 5, 7, 11] > templist = [] > > for prime in primeslist: > if checkdi

Re: [Tutor] Pygame installation problems

2012-07-04 Thread Alan Gauld
On 01/07/12 23:22, mjoll wrote: I too am having the same problems i have fc17 and i use yum install pygame to install it!! You might be better asking on the pygame mailing list/forum. BTW Its a bad idea to reply to a 6 month old post even if it is a similar issue, anyone using a threaded

Re: [Tutor] Bothersome NoneType Error for a List object

2012-07-04 Thread Alan Gauld
On 04/07/12 17:01, Osemeka Osuagwu wrote: lcm = reduce(lambda x, y: x*y, templist) #my first lambda expression! (multiply all members of templist Congratulations :-) But you could have done: import operator lcm = reduce(operator.mul, templist) instead. -- Alan G Author of the Lear

Re: [Tutor] Python and boot sequences

2012-07-04 Thread Alan Gauld
On 28/06/12 13:54, Dave Wilder wrote: Can a Python script be written that has the ability to stop a Linux device in the middle of a boot when a certain sequence occurs and then perform an action? It depends... For example, when I boot my switch (w/ Linux OS 2.7.3), I want to stop the boot wh

Re: [Tutor] Script

2012-07-04 Thread Alan Gauld
On 28/06/12 06:21, Amit Prasad wrote: I want to write a script to replace hostname from /etc/hosts and /etc/sysconfig/network files. And the new hostname will be a new entry everytime. I mean everytime when i run the script and give a new hostname, it should be replaced with the old one. You d

Re: [Tutor] Seeking help with reading and writing files in Python

2012-07-04 Thread Alan Gauld
On 26/06/12 19:28, Aristotle wrote: with an assignment that asks me to read from one file and then write to another file. The problem is that the file to read from has not been created yet. So create it. Any old text editor will do. The whole point is, I believe that you are writing a program

Re: [Tutor] Bothersome NoneType Error for a List object

2012-07-04 Thread Steven D'Aprano
Osemeka Osuagwu wrote: templist = templist.append(prime) The append method operates in place, and returns None. It doesn't return a list: py> mylist = [] py> x = mylist.append(42) py> x is None True py> mylist [42] Replace that line with just templist.append(prime) -- Steven _

[Tutor] Bothersome NoneType Error for a List object

2012-07-04 Thread Osemeka Osuagwu
Hi, I am trying to find the smallest positive number that is divisible by all of the numbers from 1 to 20 without a remainder. I wrote the following code (implementation of a solution method found in http://en.wikipedia.org/wiki/Least_common_multiple#A_method_using_a_table ) but kept getting an err

Re: [Tutor] for loop question

2012-07-04 Thread Emile van Sebille
On 7/1/2012 2:50 PM Jim said... Hello Friends, I apologize for being such a bother. This problem has been evading me all day. Can you please give me a hint as to why I cannot put the variable UpperCaseSentence outside of the for loop? I can do it in other instances but not in this one. Thank you

Re: [Tutor] Passing numeral result of a defined function to a named value

2012-07-04 Thread Emile van Sebille
On 6/28/2012 11:51 PM Joseph Hines said... Hello. Sorry to bother you, but I'm self-teaching myself python, and having difficulty with a script I'm writing to auto-calc various derived stats for a PnP game I am hosting soon. I need to pass a numeral result of a defined function to a "named" valu

Re: [Tutor] VPYTHON

2012-07-04 Thread Emile van Sebille
On 6/27/2012 3:59 PM Prajwal Niraula said... Hi, I am trying to learn VPython for more interesting simulation. I downloaded it from the website: www.vpython.org While I have Python 3.2.3 in my computer, and it seems no equivalent version for vpython is available. Besides

Re: [Tutor] for loop question

2012-07-04 Thread Hugo Arts
On Sun, Jul 1, 2012 at 11:50 PM, Jim wrote: > Hello Friends, > I apologize for being such a bother. This problem has been evading me all > day. Can you please give me a hint as to why I cannot put the variable > UpperCaseSentence outside of the for loop? > I can do it in other instances but not i

[Tutor] for loop question

2012-07-04 Thread Jim
Hello Friends, I apologize for being such a bother. This problem has been evading me all day. Can you please give me a hint as to why I cannot put the variable UpperCaseSentence outside of the for loop? I can do it in other instances but not in this one. Thank you so much, Jim #Main function.

[Tutor] Python and boot sequences

2012-07-04 Thread Dave Wilder
Hello, This is a general Python question, so I don't require specific answers on how to do it, but... Can a Python script be written that has the ability to stop a Linux device in the middle of a boot when a certain sequence occurs and then perform an action? For example, when I boot my switch

Re: [Tutor] Pygame installation problems

2012-07-04 Thread mjoll
I too am having the same problems i have fc17 and i use yum install pygame to install it!! -- View this message in context: http://python.6.n6.nabble.com/Tutor-Pygame-installation-problems-tp4935611p4980266.html Sent from the Python - tutor mailing list archive at Nabble.com.

[Tutor] Script

2012-07-04 Thread Amit Prasad
Hello Sir, I want to write a script to replace hostname from /etc/hosts and /etc/sysconfig/network files. And the new hostname will be a new entry everytime. I mean everytime when i run the script and give a new hostname, it should be replaced with the old one. I am running out of time, please help

[Tutor] Passing numeral result of a defined function to a named value

2012-07-04 Thread Joseph Hines
Hello. Sorry to bother you, but I'm self-teaching myself python, and having difficulty with a script I'm writing to auto-calc various derived stats for a PnP game I am hosting soon. I need to pass a numeral result of a defined function to a "named" value (not sure if that's what it's called) The

Re: [Tutor] Generating random alphanumeric codes

2012-07-04 Thread Japhy Bartlett
I've always liked uuid4 >>> from uuid import uuid4 >>> str(uuid4())[:4] '0ca6' On Tue, Jun 26, 2012 at 3:47 PM, Dave Angel wrote: > On 06/26/2012 03:47 PM, Martin A. Brown wrote: > > Hello, > > > > : Would anyone have tips on how to generate random 4-digit > > : alphanumeric codes in python?

[Tutor] Seeking help with reading and writing files in Python

2012-07-04 Thread Aristotle
Hello, I am reading Tony Gaddis "Teach Python" book and I am having trouble with an assignment that asks me to read from one file and then write to another file. The problem is that the file to read from has not been created yet. Can anyone help me understand this instruction a little better?

[Tutor] VPYTHON

2012-07-04 Thread Prajwal Niraula
Hi, I am trying to learn VPython for more interesting simulation. I downloaded it from the website: www.vpython.org While I have Python 3.2.3 in my computer, and it seems no equivalent version for vpython is available. Besides when installing I had problem in which the installer would not recogni