Re: [Tutor] A better way for greatest common divisor

2010-07-31 Thread David Hutto
On Sat, Jul 31, 2010 at 12:43 AM, David Hutto wrote: > On Sat, Jul 31, 2010 at 12:37 AM, David Hutto wrote: >> On Fri, Jul 30, 2010 at 11:51 PM, Steven D'Aprano >> wrote: >>> On Sat, 31 Jul 2010 01:03:27 pm David Hutto wrote: >>> This fixes the floating point 'bug' when numerator is greate

[Tutor] string editing

2010-07-31 Thread ANKUR AGGARWAL
hey although i knw string are mutable but i want to know if there is anyway to add in the string. like i m wrking on the tool and want to run the input from the user in the terminal like user makes input "this is ankur" and i want it like "this\ is\ ankur" ??? is it possible?? ___

Re: [Tutor] string editing

2010-07-31 Thread Mark Lawrence
On 31/07/2010 08:50, ANKUR AGGARWAL wrote: hey although i knw string are mutable but i want to know if there is anyway ^^^ immutable! to add in the string. like i m wrking on the tool and want to run the input from the user in the terminal like user makes input "

Re: [Tutor] Simple Python Program

2010-07-31 Thread Evert Rol
> Can anyone tell me how to fix the errors I am getting if possible? I'm quite > new and so confused... You're not telling us what the errors are. If you'd like us help to debug your program, best is to provide information about how you run it, and what output you're getting. Not just the progr

Re: [Tutor] string editing

2010-07-31 Thread Alan Gauld
"ANKUR AGGARWAL" wrote hey although i knw string are mutable but i want to know if there is anyway to add in the string. Although strings are immutable there are numerous ways to create a new variation on a string. For your purposes the replace() method is probably best but if you do he

Re: [Tutor] A better way for greatest common divisor

2010-07-31 Thread David Hutto
On Sat, Jul 31, 2010 at 3:39 AM, David Hutto wrote: > On Sat, Jul 31, 2010 at 12:43 AM, David Hutto wrote: >> On Sat, Jul 31, 2010 at 12:37 AM, David Hutto wrote: >>> On Fri, Jul 30, 2010 at 11:51 PM, Steven D'Aprano >>> wrote: On Sat, 31 Jul 2010 01:03:27 pm David Hutto wrote: >

Re: [Tutor] problem with simple script

2010-07-31 Thread Richard D. Moores
On Thu, Jul 29, 2010 at 12:22, Richard D. Moores wrote: > On Wed, Jul 28, 2010 at 08:35, Richard D. Moores wrote: > > Here's my slight revision of Steven's script (see my note, lines 9-14) > -- revised only because I wanted it to handle the case where the user > (me) entered the interval bounds i

Re: [Tutor] A better way for greatest common divisor

2010-07-31 Thread Richard D. Moores
>> On Sat, 31 Jul 2010 01:03:27 pm David Hutto wrote: > There is a difference between defining a function as a singular > activity needed to be performed, and a function that serves as a tool, > that asks for input and output, as well as serves several > utilizations, e.g., it not only accepts the

Re: [Tutor] problem with subprocess

2010-07-31 Thread Mac Ryan
On Fri, 2010-07-30 at 14:36 +0200, Bala subramanian wrote: > I have to do a series of job in a remote machine. I put each job in a > text file called 'job' as and wrote the following code that can read > each line in the text file and execute the job. If that works for you, no need to change it, o

Re: [Tutor] Python - RPG Combat System

2010-07-31 Thread bob gailer
On 7/30/2010 10:49 PM, Jason MacFiggen wrote: what can I do instead of writing print so many times? import random my_hp = 50 mo_hp = 50 my_dmg = random.randrange(1, 20) mo_dmg = random.randrange(1, 20) while True: if mo_hp < 0: print "The Lich King has been

Re: [Tutor] Python - RPG Combat System

2010-07-31 Thread David Hutto
On Sat, Jul 31, 2010 at 1:51 PM, bob gailer wrote: > On 7/30/2010 10:49 PM, Jason MacFiggen wrote: >> >> what can I do instead of writing print so many times? >> import random >>    my_hp = 50 >>    mo_hp = 50 >>    my_dmg = random.randrange(1, 20) >>    mo_dmg = random.randrange(1, 20) >>    whil

[Tutor] Writing scripts and apps for Internet consumption

2010-07-31 Thread Eric Hamiter
Not sure if this is the right place for this, since this is a tutor list, but I think it is because it involves learning Python and the application of knowledge. I've just started learning it as my initial programming language as of two months ago. I like to think I'm making steady progress, and I

Re: [Tutor] Writing scripts and apps for Internet consumption

2010-07-31 Thread David Hutto
On Sat, Jul 31, 2010 at 2:27 PM, Eric Hamiter wrote: > Not sure if this is the right place for this, since this is a tutor list, > but I think it is because it involves learning Python and the application of > knowledge. > > I've just started learning it as my initial programming language as of tw

Re: [Tutor] Simple Python Program

2010-07-31 Thread bob gailer
On 7/31/2010 12:00 AM, Jason MacFiggen wrote: Can anyone tell me how to fix the errors I am getting if possible? I'm quite new and so confused... I could give lots of diagnostic advice and detail. There is so much wrong with this program. I suggest you discard it, back up and start with the si

Re: [Tutor] Writing scripts and apps for Internet consumption

2010-07-31 Thread David Hutto
On Sat, Jul 31, 2010 at 2:34 PM, David Hutto wrote: > On Sat, Jul 31, 2010 at 2:27 PM, Eric Hamiter wrote: >> Not sure if this is the right place for this, since this is a tutor list, >> but I think it is because it involves learning Python and the application of >> knowledge. >> >> I've just sta

Re: [Tutor] Simple Python Program

2010-07-31 Thread David Hutto
On Sat, Jul 31, 2010 at 2:35 PM, bob gailer wrote: > On 7/31/2010 12:00 AM, Jason MacFiggen wrote: > > Can anyone tell me how to fix the errors I am getting if possible? I'm quite > new and so confused... > > > I could give lots of diagnostic advice and detail. There is so much wrong > with this p

Re: [Tutor] Writing scripts and apps for Internet consumption

2010-07-31 Thread Eric Hamiter
> > Get a linux hosting account, and a web address, most linux hosting > comes with python, so practice in the 'cloud'. > I have that-- an account with Dreamhost. This hasn't solved my problems yet though. Like I said, I can have it write a simple Hello, World! ...but if I make it do anything mo

Re: [Tutor] Writing scripts and apps for Internet consumption

2010-07-31 Thread David Hutto
On Sat, Jul 31, 2010 at 2:45 PM, Eric Hamiter wrote: >> Get a linux hosting account, and a web address, most linux hosting >> comes with python, so practice in the 'cloud'. > > I have that-- an account with Dreamhost. This hasn't solved my problems yet > though. Like I said, I can have it write a

[Tutor] Making a sound

2010-07-31 Thread Michael Bernhard Arp Sørensen
Greetings, programs. How do I create a sound from python? I'm thinking along the line of generating a sinus wave where I can control the frequency and duration. I want to produce a string of sounds based on a character string. Probably not original. :-) I don't want to save a sound to a file and p

Re: [Tutor] Writing scripts and apps for Internet consumption

2010-07-31 Thread David Hutto
On Sat, Jul 31, 2010 at 2:56 PM, David Hutto wrote: > On Sat, Jul 31, 2010 at 2:45 PM, Eric Hamiter wrote: >>> Get a linux hosting account, and a web address, most linux hosting >>> comes with python, so practice in the 'cloud'. >> >> I have that-- an account with Dreamhost. This hasn't solved my

Re: [Tutor] Making a sound

2010-07-31 Thread Luke Paireepinart
You can generate the sound data in a buffer either in native python or using numpy, then play it back by loading the buffer into a sound object with pygame. It depends how much control you want on the sounds. You might want to use csound or supercollider or something if you want to programmatica

Re: [Tutor] Order Of Operations Question

2010-07-31 Thread Roel Schroeven
Op 2010-07-28 11:41, David Hutto schreef: > From a practice exercise in Building Skills In Python page 64 I'm > working on How Much Does The Atmosphere Weigh? Part 1: > To check it states that the answer should be app. 10**18kg However, > and I've checked to make sure that the math I've layed out m

Re: [Tutor] Writing scripts and apps for Internet consumption

2010-07-31 Thread bob gailer
On 7/31/2010 2:45 PM, Eric Hamiter wrote: Get a linux hosting account, and a web address, most linux hosting comes with python, so practice in the 'cloud'. I have that-- an account with Dreamhost. This hasn't solved my problems yet though. Like I said, I can have it write a simple H

Re: [Tutor] Writing scripts and apps for Internet consumption

2010-07-31 Thread Eric Hamiter
On Sat, Jul 31, 2010 at 4:48 PM, bob gailer wrote: > > Please post that code, and the URL you use to invoke it. > test.py: this works on my laptop but not on the server http://pastebin.com/ChjUzLRU test-working.py: this works on both laptop & server http://pastebin.com/iLNTrGdW both availab

Re: [Tutor] Writing scripts and apps for Internet consumption

2010-07-31 Thread Alan Gauld
"Eric Hamiter" wrote the most rudimentary level of the basics. What I keep reading is how Python is most powerful on server side applications, in the cloud, so to speak. The portability of Python is also widely evangelized. I'm not sure I'd agree with that assertion. Python is a geeral pur

Re: [Tutor] Python - RPG Combat System

2010-07-31 Thread Alan Gauld
"Jason MacFiggen" wrote and also, what can I do instead of writing print so many times? Learn about format strings and use triple quoted strings. else: print "Menu Selections: " print "1 - Attack" print "2 - Defend" print menu1 = """ Me

Re: [Tutor] Simple Python Program

2010-07-31 Thread Steven D'Aprano
On Sun, 1 Aug 2010 04:35:03 am bob gailer wrote: > Continue to avoid writing functions. They are not necessary for such > a simple program. That is *terrible* advice. Absolutely awful. Functions should not be avoided unless necessary. Functions should be used unless there is a compelling reason

Re: [Tutor] Simple Python Program

2010-07-31 Thread Steven D'Aprano
Hi Jason, Let's see if we can clean up some of your program. You had this function: > def inputNames(playerOne, PlayerTwo): > p1name = raw_input("Enter your name.") > p2name = raw_input("Enter your name.") > return playerOne, playerTwo Let's write this in plain English. (1) The fu

Re: [Tutor] Making a sound

2010-07-31 Thread Dave Angel
Michael Bernhard Arp S wrote: Greetings, programs. How do I create a sound from python? I'm thinking along the line of generating a sinus wave where I can control the frequency and duration. I want to produce a string of sounds based on a character string. Probabl

Re: [Tutor] Writing scripts and apps for Internet consumption

2010-07-31 Thread Dave Angel
Eric Hamiter wrote: On Sat, Jul 31, 2010 at 4:48 PM, bob gailer wrote: Please post that code, and the URL you use to invoke it. test.py: this works on my laptop but not on the server http://pastebin.com/ChjUzLRU test-working.py: this works on both laptop & server http://pastebin

Re: [Tutor] Writing scripts and apps for Internet consumption

2010-07-31 Thread bob gailer
On 7/31/2010 6:40 PM, Eric Hamiter wrote: On Sat, Jul 31, 2010 at 4:48 PM, bob gailer > wrote: Please post that code, and the URL you use to invoke it. test.py: this works on my laptop but not on the server http://pastebin.com/ChjUzLRU test-working.py: this wor

Re: [Tutor] Writing scripts and apps for Internet consumption

2010-07-31 Thread Eric Hamiter
On Sat, Jul 31, 2010 at 9:53 PM, bob gailer wrote: > > Main difference I see is lack of any html tags in test.py! Try adding > >1. print "" > 2. print "Publix Aide" > 3. print "" > 4. # the store map print statements go here > 5. print "" > > I understand t

Re: [Tutor] Simple Python Program

2010-07-31 Thread bob gailer
On 7/31/2010 8:24 PM, Steven D'Aprano wrote: On Sun, 1 Aug 2010 04:35:03 am bob gailer wrote: Continue to avoid writing functions. They are not necessary for such a simple program. That is *terrible* advice. Absolutely awful. Well I disagree. I was trying to steer the OP to get

Re: [Tutor] Python - RPG Combat System

2010-07-31 Thread Steven D'Aprano
On Sun, 1 Aug 2010 10:20:31 am Alan Gauld wrote: > "Jason MacFiggen" wrote > > > and also, what can I do instead of writing print so many times? > > Learn about format strings and use triple quoted strings. *slaps self in head* Doh! How could I have forgotten triple quoted strings? *slinks off

Re: [Tutor] Writing scripts and apps for Internet consumption

2010-07-31 Thread bob gailer
On 7/31/2010 11:03 PM, Eric Hamiter wrote: On Sat, Jul 31, 2010 at 9:53 PM, bob gailer > wrote: Main difference I see is lack of any html tags in test.py! Try adding 1. print "" 2. print "Publix Aide" 3. print ""

Re: [Tutor] Simple Python Program

2010-07-31 Thread Luke Paireepinart
I think I agree more with bob on this one - he wasn't saying functions weren't important, just that they weren't important to this case. Sure polymorphism and inheritance and properties and generators and list comprehensions are awesome and useful, but I wouldn't suggest they are necessary for e

Re: [Tutor] Simple Python Program

2010-07-31 Thread Steven D'Aprano
On Sun, 1 Aug 2010 01:11:41 pm bob gailer wrote: > On 7/31/2010 8:24 PM, Steven D'Aprano wrote: > > On Sun, 1 Aug 2010 04:35:03 am bob gailer wrote: > >> Continue to avoid writing functions. They are not necessary for > >> such a simple program. > > > > That is *terrible* advice. Absolutely awful.