Re: [Tutor] Class Nesting

2012-02-06 Thread Steven D'Aprano
On Mon, Feb 06, 2012 at 08:17:05PM -0500, Greg Nielsen wrote: [...] > So here is the problem, to create an object, you need to assign it to > a variable, and you need to know what that variable is to call upon it > later, so to have a object build a second object, it would need to somehow > cr

Re: [Tutor] Lists/raw_input

2012-02-06 Thread Christian Witts
On 2012/02/07 07:40 AM, Michael Lewis wrote: I want to prompt the user only once to enter 5 numbers. I then want to create a list out of those five numbers. How can I do that? I know how to do it if I prompt the user 5 different times, but I only want to prompt the user once. Thanks. -- Mic

Re: [Tutor] Lists/raw_input

2012-02-06 Thread Andre' Walker-Loud
Hi Michael, I bet there is a better way (which I would like to see), but here is what I have come up with for my own uses. """ ints = [] u_in = False while u_in == False: try: u_input = raw_input('please enter 5 integers, space separated\n ') for n in

[Tutor] Lists/raw_input

2012-02-06 Thread Michael Lewis
I want to prompt the user only once to enter 5 numbers. I then want to create a list out of those five numbers. How can I do that? I know how to do it if I prompt the user 5 different times, but I only want to prompt the user once. Thanks. -- Michael

Re: [Tutor] Class Nesting

2012-02-06 Thread Dave Angel
On 02/06/2012 08:17 PM, Greg Nielsen wrote: Hello List, My name is Greg, and while working on a project I've come across a rather interesting problem. I'm trying to create a rough model of a star cluster and all of the stars and planets contained within. Kind of a cool project; hopefully i

[Tutor] Class Nesting

2012-02-06 Thread Greg Nielsen
Hello List, My name is Greg, and while working on a project I've come across a rather interesting problem. I'm trying to create a rough model of a star cluster and all of the stars and planets contained within. Kind of a cool project; hopefully it should work a little like this. I create a St

Re: [Tutor] Question on how to do exponents

2012-02-06 Thread Steven D'Aprano
On Mon, Feb 06, 2012 at 04:54:57PM -0800, William Stewart wrote: > Hello everyone, I am making a calculator and I need to know how to make it do > exponents and remainders > How can I input this info in python? > Any help would be appreciated You can do exponents either with the ** operator or th

Re: [Tutor] Question on how to do exponents

2012-02-06 Thread Nate Lastname
Exponents and remainder (modulus) are **(or ^) and % respectively. I.E.; d = a ** b (exponent) c = a % b (modulus) There you are! ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listi

[Tutor] Question on how to do exponents

2012-02-06 Thread William Stewart
Hello everyone, I am making a calculator and I need to know how to make it do exponents and remainders How can I input this info in python? Any help would be appreciated Thanks --- On Mon, 2/6/12, Steven D'Aprano wrote: From: Steven D'Aprano Subject: Re: [Tutor] Sandbox Game To: "tutor" Date

Re: [Tutor] Sandbox Game

2012-02-06 Thread Steven D'Aprano
On Mon, Feb 06, 2012 at 09:13:48AM -0500, Nate Lastname wrote: > Hello List, > > I am quite sorry for my attitude. I will look more thoroughly into the > search results. Thanks for the link to Epik. I had found this, but I > didn't realize that it was Python. I apologize once again, and thank

Re: [Tutor] what is the basic difference

2012-02-06 Thread Alan Gauld
On 06/02/12 19:12, Debashish Saha wrote: what is the basic difference between the commands import pylab as * Are you sure you don't mean from pylab import * ??? The other form won't work because * is not a valid name in Python. You should ghet a syntax error. import matplotlib.pyplot as pl

Re: [Tutor] Sandbox Game

2012-02-06 Thread Nate Lastname
Thanks, Greg. I actually have two projects on the pygame website, and I already have a great book, too. But thank you very much :D -- My Blog - Defenestration Coding http://defenestrationcoding.wordpress.com/ ___ Tutor maillist - Tutor@python.org T

Re: [Tutor] Sandbox Game

2012-02-06 Thread Greg Nielsen
Nate, I myself am a newer programmer with most of my experience in the use of pygame, perhaps I could help point you in the right direction. First, there is a lot of cool stuff over at the main pygame website, and a lot of the users will post projects with images, general overviews, and a lin

Re: [Tutor] Sandbox Game

2012-02-06 Thread Nate Lastname
Hold on... I just found one! It's not ideal, but it will work at least for a base - http://www.pygame.org/project-pysand-1387-2577.html. Thanks again, all, for your excellent help! The Defenestrator On 2/6/12, Nate Lastname wrote: > Some more info: > > It's in pygame. > It's 2d. > I cannot fin

Re: [Tutor] Sandbox Game

2012-02-06 Thread Nate Lastname
Some more info: It's in pygame. It's 2d. I cannot find any python versions out there. Yes, there is a graphical interface, and yes, it is a user-controlled game. Thank you all for your help! The Defenestrator On 2/6/12, bob gailer wrote: > On 2/6/2012 11:16 AM, Nate Lastname wrote: >> Hey all,

Re: [Tutor] Backwards message program

2012-02-06 Thread bob gailer
On 2/6/2012 2:05 PM, myles broomes wrote: Im trying to code a program where the user enters a message and it is returned backwards. Here is my code so far: message = input("Enter your message: ") backw = "" counter = le

Re: [Tutor] what is the basic difference

2012-02-06 Thread Dave Angel
On 02/06/2012 02:12 PM, Debashish Saha wrote: what is the basic difference between the commands import pylab as * import matplotlib.pyplot as plt import numpy as np import numpy as * import pylab as *pollutes your global namespace with all kinds of symbols. If you don't know them all, you m

Re: [Tutor] Backwards message program

2012-02-06 Thread Dave Angel
On 02/06/2012 02:05 PM, myles broomes wrote: Im trying to code a program where the user enters a message and it is returned backwards. Here is my code so far: message = input("Enter your message: ") backw = "" counter = len(message) while message != 0: backw += message[counter-1]

[Tutor] what is the basic difference

2012-02-06 Thread Debashish Saha
what is the basic difference between the commands import pylab as * import matplotlib.pyplot as plt import numpy as np import numpy as * ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/

[Tutor] Backwards message program

2012-02-06 Thread myles broomes
Im trying to code a program where the user enters a message and it is returned backwards. Here is my code so far: message = input("Enter your message: ") backw = "" counter = len(message) while message != 0: backw += message[counter-1] counter -= 1 print(backw) input("\nPress e

Re: [Tutor] Trouble with encoding/decoding a file

2012-02-06 Thread ALAN GAULD
That's not too surprising. Text files use an end-of-file character combination.  You might be lucky and not encounter that set of bytes in your file or you  might be unlucky and find it, in which case the file gets truncated.  That's why you need the binary setting, to ensure you read the  whole fi

Re: [Tutor] exercise with classes

2012-02-06 Thread Dave Angel
On 02/06/2012 01:24 PM, Tonu Mikk wrote: Now I get an error: NameError: global name 'self' is not define. Tonu Put your remarks after the stuff you quote. You're top-posting, which makes the reply difficult to follow. Use copy/paste to describe an error message. You retyped the one above

Re: [Tutor] Trouble with encoding/decoding a file

2012-02-06 Thread Tony Pelletier
On Mon, Feb 6, 2012 at 1:13 PM, Alan Gauld wrote: > On 06/02/12 15:11, Tony Pelletier wrote: > >> Hi, >> >> I've been tasked with getting the encoded value using a SOAP call and >> then writing the file out. I first used the interpreter to do so like >> such: >> >> import base64 >> >> encoded = '

Re: [Tutor] exercise with classes

2012-02-06 Thread Tonu Mikk
Now I get an error: NameError: global name 'self' is not define. Tonu On Mon, Feb 6, 2012 at 10:19 AM, Nate Lastname wrote: > Hey Tonu, > > The problem is that in your statement definition, you are not > including the self argument. Your definition needs to be something > like: > def dolt(sel

Re: [Tutor] exercise with classes

2012-02-06 Thread Alan Gauld
On 06/02/12 16:12, Tonu Mikk wrote: Alan, thanks for explaining about passing objects to classes. This is an important concept for me to understand. I tried running the code, but run into an error that I could not resolve: TypeError: doIt() takes no arguments (1 given). Sorry the code was on

Re: [Tutor] Trouble with encoding/decoding a file

2012-02-06 Thread Alan Gauld
On 06/02/12 15:11, Tony Pelletier wrote: Hi, I've been tasked with getting the encoded value using a SOAP call and then writing the file out. I first used the interpreter to do so like such: import base64 encoded = 'super long encoded string' data = base64.b64decode(encoded) outfile = open('t

Re: [Tutor] python editor

2012-02-06 Thread Alan Gauld
On 06/02/12 17:17, bob gailer wrote: On 2/6/2012 10:25 AM, Kapil Shukla wrote: Please also suggest a free editor for python which can at least repeat previous command with a key stroke That depends on the editor's mode of operation. In an editor like vi (elvis, vim etc) there is a repeat key

Re: [Tutor] Sandbox Game

2012-02-06 Thread bob gailer
On 2/6/2012 11:16 AM, Nate Lastname wrote: Hey all, The basic idea is that there are different types of sand. They fall and move (or don't, if they are solid) and interact with each other in different ways. I.E.; there is a lava type; it falls, and when it hits other sand types, it heats them

Re: [Tutor] python editor

2012-02-06 Thread bob gailer
On 2/6/2012 10:25 AM, Kapil Shukla wrote: Please also suggest a free editor for python which can at least repeat previous command with a key stroke It is better to ask an unrelated question in a separate email, with its own relevant subject. Please give an example of what you mean by "epeat

Re: [Tutor] Problem with smtplib

2012-02-06 Thread bob gailer
On 2/6/2012 6:05 AM, Nikolay Moskvin wrote: Hi, all I have a problem with sending mail via smtp. This error does not always happen. Does somebody seen this stacktrace? I've seen many like that. It means exactly what it says. "Connection unexpectedly closed" Most likely something went awry with

Re: [Tutor] exercise with classes

2012-02-06 Thread Nate Lastname
Hey Tonu, The problem is that in your statement definition, you are not including the self argument. Your definition needs to be something like: def dolt(self): # Do stuff. For more info on the self keyword, see http://docs.python.org/tutorial/classes.html, section 9.3.2. On 2/6/12, Tonu Mikk

Re: [Tutor] decimal precision in python

2012-02-06 Thread Modulok
For money, you should probably use the builtin module 'decimal' instead: http://docs.python.org/library/decimal.html There's also the third party module 'mpmath' which provides arbitrary precision floating point arithmetic. http://mpmath.googlecode.com/svn/trunk/doc/build/index.html -Modulok-

Re: [Tutor] Sandbox Game

2012-02-06 Thread Nate Lastname
Hey all, The basic idea is that there are different types of sand. They fall and move (or don't, if they are solid) and interact with each other in different ways. I.E.; there is a lava type; it falls, and when it hits other sand types, it heats them up. If it gets cold, it becomes sand. I do

Re: [Tutor] exercise with classes

2012-02-06 Thread Tonu Mikk
Alan, thanks for explaining about passing objects to classes. This is an important concept for me to understand. I tried running the code, but run into an error that I could not resolve: TypeError: doIt() takes no arguments (1 given). Tonu On Thu, Feb 2, 2012 at 7:09 PM, Alan Gauld wrote: > O

Re: [Tutor] Sandbox Game

2012-02-06 Thread bob gailer
On 2/6/2012 9:16 AM, Nate Lastname wrote: P.S.: I also would like to say that I am a noob at Python, Pygame, and the list. I'll try not to post more stupid questions, though. We are here to help the newcomers. Questions are not "stupid". The easier you make it for us to answer the more likel

Re: [Tutor] Sandbox Game

2012-02-06 Thread bob gailer
On 2/6/2012 9:13 AM, Nate Lastname wrote: Hello List, I am quite sorry for my attitude. I will look more thoroughly into the search results. Thanks for the link to Epik. I had found this, but I didn't realize that it was Python. I apologize once again, and thank you for your help. I did

Re: [Tutor] decimal precision in python

2012-02-06 Thread Dave Angel
On 02/06/2012 10:25 AM, Kapil Shukla wrote: i tried writing a small code to calculate option price using the binomial tree model. I compared my results with results of the same program in excel. There seems to be a minor difference due to decimal precision as excel is using 15 decimal precision a

Re: [Tutor] decimal precision in python

2012-02-06 Thread James Reynolds
On Mon, Feb 6, 2012 at 10:25 AM, Kapil Shukla wrote: > i tried writing a small code to calculate option price using the binomial > tree model. I compared my results with results of the same program in > excel. There seems to be a minor difference due to decimal precision as > excel is using 15 dec

Re: [Tutor] decimal precision in python

2012-02-06 Thread Steve Willoughby
On 06-Feb-12 07:25, Kapil Shukla wrote: i tried writing a small code to calculate option price using the binomial tree model. I compared my results with results of the same program in excel. There seems to be a minor difference due to decimal precision as excel is using 15 decimal precision and p

[Tutor] decimal precision in python

2012-02-06 Thread Kapil Shukla
i tried writing a small code to calculate option price using the binomial tree model. I compared my results with results of the same program in excel. There seems to be a minor difference due to decimal precision as excel is using 15 decimal precision and python (both 2.7 and 3.1) using 11. (at lea

[Tutor] Trouble with encoding/decoding a file

2012-02-06 Thread Tony Pelletier
Hi, I've been tasked with getting the encoded value using a SOAP call and then writing the file out. I first used the interpreter to do so like such: import base64 encoded = 'super long encoded string' data = base64.b64decode(encoded) outfile = open('test.xls', 'w') outfile.write(data) outfile.

Re: [Tutor] Sandbox Game

2012-02-06 Thread Nate Lastname
P.S.: I also would like to say that I am a noob at Python, Pygame, and the list. I'll try not to post more stupid questions, though. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/li

Re: [Tutor] Sandbox Game

2012-02-06 Thread Nate Lastname
Hello List, I am quite sorry for my attitude. I will look more thoroughly into the search results. Thanks for the link to Epik. I had found this, but I didn't realize that it was Python. I apologize once again, and thank you for your help. I did give you a link to a sandbox game (powdertoy.co

[Tutor] Problem with smtplib

2012-02-06 Thread Nikolay Moskvin
Hi, all I have a problem with sending mail via smtp. This error does not always happen. Does somebody seen this stacktrace? smtp.sendmail(send_from, send_to, msg.as_string()) File "/usr/local/lib/python2.7/smtplib.py", line 725, in sendmail (code, resp) = self.data(msg) File "/usr/loca