Re: [Tutor] cannot convert eps to png using PIL

2009-10-15 Thread Chris Fuller
It's trying to launch GhostScript, and failing. The broken pipe is a clue that its trying to communicate with external software. Most likely, you don't have ghostscript installed. Google Ghostscript and you should find instructions for installing on windows (I'm fairly sure there is a port).

[Tutor] cannot convert eps to png using PIL

2009-10-15 Thread LL
Hi.. I also asked this question on the imaging group but thought people here might have insights as well.. all of the following code executes interactively except the last line. Converting a .jpg file to .png works fine. I'm using the PIL version for Python 2.6. Any suggestions will be greatly

Re: [Tutor] Putting a variable into a statement

2009-10-15 Thread bob gailer
GoodPotatoes wrote: I am using the module active_directory and have an ad object called myuser. I would like to run a series of statements like: myuser.attribute where attribute is a string variable, but python says that this is not the correct syntax. error: for x in myuser.properties:

Re: [Tutor] Putting a variable into a statement

2009-10-15 Thread bob gailer
GoodPotatoes wrote: I am using the module active_directory and have an ad object called myuser. I would like to run a series of statements like: myuser.attribute where attribute is a string variable, but python says that this is not the correct syntax. error: for x in myuser.properties:

[Tutor] Putting a variable into a statement

2009-10-15 Thread GoodPotatoes
I am using the module active_directory and have an ad object called myuser. I would like to run a series of statements like: myuser.attribute where attribute is a string variable, but python says that this is not the correct syntax. error: for x in myuser.properties:# "myuser.properties" r

Re: [Tutor] Most pythonic input validation

2009-10-15 Thread Emile van Sebille
On 10/15/2009 7:36 AM Wayne Werner said... Is that the most pythonic way of validating? Is there a better way? Pythonic in part having been addressed, I've some further comments to your valid_choice code... -- Emile def valid_choice(choice, min, max): # don't use min and max -- they shadow

Re: [Tutor] multiprocessing with more than two arguments

2009-10-15 Thread Kent Johnson
On Thu, Oct 15, 2009 at 2:04 PM, markus kossner wrote: > Hi, > let's simply start with an example: > > #!/usr/bin/python2.6 > import numpy as n > > def calculate(a,b=3,c=4): >        print b >        return n.sqrt(n.exp(a*b+c)/n.exp(c)**2) > > from multiprocessing import Pool > p = Pool(processes=

[Tutor] multiprocessing with more than two arguments

2009-10-15 Thread markus kossner
Hi, let's simply start with an example: #!/usr/bin/python2.6 import numpy as n def calculate(a,b=3,c=4): print b return n.sqrt(n.exp(a*b+c)/n.exp(c)**2) from multiprocessing import Pool p = Pool(processes=2) a_list=range(10) result=p.map(calculate,a_list) This code works q

Re: [Tutor] Methods that return instances of their own class?

2009-10-15 Thread David Perlman
Maybe there's a prettier way to do this, but I did it explicitly like this because the "transpose" I needed was specific to the structure of the game payoff matrix; it isn't a normal mathematical transpose. I agree that it's hard to read but I'm not sure the specific needs of this applicat

Re: [Tutor] Methods that return instances of their own class?

2009-10-15 Thread Steve Willoughby
On Thu, Oct 15, 2009 at 01:33:51PM -0400, Che M wrote: > > > > > In particular, I'm trying to run a simple prisoner's dilemma game, and > > I want to make a "game" object that has a method which returns the > > "game" object with the payoffs reversed; that is, the payoff matrix > > from th

Re: [Tutor] Methods that return instances of their own class?

2009-10-15 Thread Alan Gauld
"Che M" wrote Since this is the tutor list, I'd like to ask some questions about structures used here that I haven't encountered before. I hope you'll excuse me asking Thats OK. class Payoffs(list): def __init__(self, value=None): list.__init__(self) This class is a list

Re: [Tutor] Recursive user input collection problem

2009-10-15 Thread Alan Gauld
"William Witteman" wrote You need a loop, and putting a while True: around the whole thing solves it nicely. Don't *call* the function again, just loop back and do the operation again. That's what loops are for. True, that's why my code currently looks like this: Personally I don't think

Re: [Tutor] Methods that return instances of their own class?

2009-10-15 Thread Che M
> In particular, I'm trying to run a simple prisoner's dilemma game, and > I want to make a "game" object that has a method which returns the > "game" object with the payoffs reversed; that is, the payoff matrix > from the other player's point of view. Basically a kind of transpose > wh

Re: [Tutor] Most pythonic input validation

2009-10-15 Thread Rich Lovely
2009/10/15 Wayne Werner : > > > On Thu, Oct 15, 2009 at 10:50 AM, Rich Lovely > wrote: >> >> 2009/10/15 Wayne Werner : >> > Hi, >> > I'm writing a text based menu and want to validate the user input. I'm >> > giving the options as integers, and I want to make sure the user enters >> > a >> > prope

Re: [Tutor] Most pythonic input validation

2009-10-15 Thread Wayne Werner
On Thu, Oct 15, 2009 at 10:50 AM, Rich Lovely wrote: > 2009/10/15 Wayne Werner : > > Hi, > > I'm writing a text based menu and want to validate the user input. I'm > > giving the options as integers, and I want to make sure the user enters a > > proper value. > > Here's what I've got so far: http:

Re: [Tutor] Masking operation

2009-10-15 Thread Rich Lovely
2009/10/15 Kent Johnson : > On Wed, Oct 14, 2009 at 10:48 PM, Wayne wrote: > >> Using zip is redundant for me, this is what my function looks like now: >> def crypt(msg, mask): >>     m = itertools.cycle(mask) >>     word = '' >>     for l in msg: >>         word += chr(ord(l) ^ ord(m.next())) >>

Re: [Tutor] Most pythonic input validation

2009-10-15 Thread Rich Lovely
2009/10/15 Wayne Werner : > Hi, > I'm writing a text based menu and want to validate the user input. I'm > giving the options as integers, and I want to make sure the user enters a > proper value. > Here's what I've got so far: http://pastebin.com/m1fdd5863 > I'm most interested in this segment: >

Re: [Tutor] Methods that return instances of their own class?

2009-10-15 Thread David Perlman
Oh my goodness, it really is that easy! I guess I assumed that was too simple to work. Silly me. Thanks Andre! On Oct 15, 2009, at 10:31 AM, Andre Engels wrote: On Thu, Oct 15, 2009 at 5:14 PM, David Perlman wrote: I'm trying to figure out how to define a class so that its instances ha

Re: [Tutor] Methods that return instances of their own class?

2009-10-15 Thread Andre Engels
On Thu, Oct 15, 2009 at 5:14 PM, David Perlman wrote: > I'm trying to figure out how to define a class so that its instances have a > method that return a different object of the same class. > > In particular, I'm trying to run a simple prisoner's dilemma game, and I > want to make a "game" object

[Tutor] Methods that return instances of their own class?

2009-10-15 Thread David Perlman
I'm trying to figure out how to define a class so that its instances have a method that return a different object of the same class. In particular, I'm trying to run a simple prisoner's dilemma game, and I want to make a "game" object that has a method which returns the "game" object with t

Re: [Tutor] ok i need some help with a for loop

2009-10-15 Thread Christian Witts
Skylar Struble wrote: ok so im working on a text based rpg game and am trying to get this code to work, items = ['crate', 'grave'] lookwords = ['look', 'examine', 'investigate','open') input1 = raw_input('What do you want to do:') for word in items: for word2 in lookwords: if word a

[Tutor] Most pythonic input validation

2009-10-15 Thread Wayne Werner
Hi, I'm writing a text based menu and want to validate the user input. I'm giving the options as integers, and I want to make sure the user enters a proper value. Here's what I've got so far: http://pastebin.com/m1fdd5863 I'm most interested in this segment: while True: choice = raw_

Re: [Tutor] ok i need some help with a for loop

2009-10-15 Thread Michiel Overtoom
Skylar Struble wrote: lookwords = ['look', 'examine', 'investigate','open') The ')' probably has to be a ']'. if word and word2 in input1: Try this: if (word in input1) and (word2 in input1): it prints out all of the print things 2 times when i want it to print 1 or the other

[Tutor] ok i need some help with a for loop

2009-10-15 Thread Skylar Struble
ok so im working on a text based rpg game and am trying to get this code to work, items = ['crate', 'grave'] lookwords = ['look', 'examine', 'investigate','open') input1 = raw_input('What do you want to do:') for word in items: for word2 in lookwords: if word and word2 in input1:

Re: [Tutor] Recursive user input collection problem

2009-10-15 Thread William Witteman
On Thu, Oct 15, 2009 at 07:54:23AM -0400, Dave Angel wrote: >William Witteman wrote: >>Thanks to all who responded. There were several good points about the >>code itself, all of which both helped and work. >> >>I will likely use Alan's example because I find it the most lucid, but >>the other sug

Re: [Tutor] Recursive user input collection problem

2009-10-15 Thread Dave Angel
William Witteman wrote: Thanks to all who responded. There were several good points about the code itself, all of which both helped and work. I will likely use Alan's example because I find it the most lucid, but the other suggestions are good signposts to other ways to do the same thing (but r

Re: [Tutor] namespaces and global

2009-10-15 Thread Dave Angel
Jose Amoreira wrote: Alan, Kent, hello! Thanks for your help. As for your "curiosity", I'm teaching elementary physics to undergraduates in computer engineering. Trying to speak my students' language, I wanted to show them simple applications that compute numerical values for the kinematics fo

Re: [Tutor] numerical problem

2009-10-15 Thread Kent Johnson
On Thu, Oct 15, 2009 at 5:28 AM, Mr Timothy Hall wrote: > whenever i run this part of the program, no matter what values i put in for > vto, k1t etc... it always equals zero. > im slightly aware of floating point numbers but im not sure why this will > not give me a real answer. > when i do it on

Re: [Tutor] numerical problem

2009-10-15 Thread Andre Engels
On Thu, Oct 15, 2009 at 11:28 AM, Mr Timothy Hall wrote: >  hi, > i am writing a program for a runge-cutter method of solving ODE's and im > having a problem with one part. > > whenever i run this part of the program, no matter what values i put in for > vto, k1t etc... it always equals zero. > im

Re: [Tutor] Masking operation

2009-10-15 Thread Kent Johnson
On Wed, Oct 14, 2009 at 10:48 PM, Wayne wrote: > Using zip is redundant for me, this is what my function looks like now: > def crypt(msg, mask): >     m = itertools.cycle(mask) >     word = '' >     for l in msg: >         word += chr(ord(l) ^ ord(m.next())) >     return word With zip() and a ge

[Tutor] numerical problem

2009-10-15 Thread Mr Timothy Hall
hi, i am writing a program for a runge-cutter method of solving ODE's and im having a problem with one part. whenever i run this part of the program, no matter what values i put in for vto, k1t etc... it always equals zero. im slightly aware of floating point numbers but im not sure why this wi

Re: [Tutor] PyWin32 - Library of functions to interact with windows?

2009-10-15 Thread Tim Golden
Katt wrote: Hello all, I am currently using WinXP and python 2.6.2 I just installed PyWin32 v214 for python 2.6 from the following link: [... snip lots of advice from other people ...] Hi, Katt. Thanks for posting back over here. I must admit, I hadn't realised you were posting to the tutor l

Re: [Tutor] Changing the color of text in the windows shell (WinXP/python 2.6.2)

2009-10-15 Thread Alan Gauld
"Katt" wrote lucky). So I will pursue all three types of changing color. First I will try WConio, next to be followed by EasyGUI, EasyGUI won;t help change colour, it is just a way of making a command line script act like a GUI - by popping up dialog boxes to capture input and dsplay messa