Re: [Tutor] Multiples python files

2011-03-01 Thread Christopher Brookes
Thank you all for answers. Again. 2011/2/28 Alan Gauld alan.ga...@btinternet.com Christopher Brookes chris.klai...@gmail.com wrote I don't understand @classmethod def DisplayAll(cls, herosAll): What is cls ? This is one of the advanced techniques I referred to a few days ago.

[Tutor] Accessing a DLL from python

2011-03-01 Thread Hanlie Pretorius
Hi Python Tutors, I'm using a storm water modelling program, EPA SWMM, to model the hydrology and hydraulics of a study area. SWMM reports its results in a binary (.out) file that contains the results for each element in the model at each time step in the model run. According to the SWMM

Re: [Tutor] Accessing a DLL from python

2011-03-01 Thread Hanlie Pretorius
I see that I have misread the manual and that I need to reproduce the code in the C example in python. The SWMM DLL doesn't contain ready-made functions to open files etc. Apologies for posting before I was completely sure of the problem. Hanlie 2011/3/1, Hanlie Pretorius

Re: [Tutor] Accessing a DLL from python

2011-03-01 Thread Hanlie Pretorius
Can anyone perhaps suggest the easiest way of translating the C code into Python, bearing in mind that I'm rather a beginner? Thanks Hanlie 2011/3/1, Hanlie Pretorius hanlie.pretor...@gmail.com: I see that I have misread the manual and that I need to reproduce the code in the C example in

Re: [Tutor] Accessing a DLL from python

2011-03-01 Thread Stefan Behnel
Hanlie Pretorius, 01.03.2011 13:33: Can anyone perhaps suggest the easiest way of translating the C code into Python, bearing in mind that I'm rather a beginner? A beginner of what? Python? Programming in general? The C code you posted doesn't look too complex, so you could try to translate

Re: [Tutor] A class that instantiates conditionally ?

2011-03-01 Thread Alan Gauld
David bouncingc...@gmail.com wrote clever enough to refuse to instantiate itself if a necessary condition is not met. class MyClass_2(object): def __new__(self, condition): if condition: return object.__new__(self) else: return None

Re: [Tutor] A class that instantiates conditionally ?

2011-03-01 Thread Alan Gauld
David bouncingc...@gmail.com wrote clever enough to refuse to instantiate itself if a necessary condition is not met. Oops, sent too soon. I meant to add that you should realize that the implication of your design is that the user of the class now has to check each object to see if it is a

[Tutor] Recommendation for Pygame

2011-03-01 Thread ANKUR AGGARWAL
Hey Any good recommendation (ebook,links,videos,Live Example) to get started with the pygame api. I am totally new to pygame. Thanks in advance. Waiting for the suggestions :):) Ankur Aggarwal ___ Tutor maillist - Tutor@python.org To unsubscribe or

Re: [Tutor] A class that instantiates conditionally ?

2011-03-01 Thread Hugo Arts
On Tue, Mar 1, 2011 at 5:35 PM, Alan Gauld alan.ga...@btinternet.com wrote: David bouncingc...@gmail.com wrote clever enough to refuse to instantiate itself if a necessary condition is not met. Oops, sent too soon. I meant to add that you should realize that the implication of your

Re: [Tutor] Recommendation for Pygame

2011-03-01 Thread Chris Fuller
http://www.pyweek.org/ Cheers On Tuesday 01 March 2011, ANKUR AGGARWAL wrote: Hey Any good recommendation (ebook,links,videos,Live Example) to get started with the pygame api. I am totally new to pygame. Thanks in advance. Waiting for the suggestions :):) Ankur Aggarwal

Re: [Tutor] A class that instantiates conditionally ?

2011-03-01 Thread Alan Gauld
Hugo Arts hugo.yo...@gmail.com wrote Side question: Any reason why you'd raise the exception from __new__ rather than __init__? If you want to return None, then yeah I can see why you'd have to use __new__, but would there be any reason you can't or shouldn't simply raise an exception from

Re: [Tutor] Recommendation for Pygame

2011-03-01 Thread Alan Gauld
ANKUR AGGARWAL coolankur2...@gmail.com wrote Any good recommendation (ebook,links,videos,Live Example) to get started with the pygame api. I am totally new to pygame. Thanks in advance. Waiting for the suggestions :):) Have you looked at the tutorial on the pygamje web site? Also the

[Tutor] Dynamically assign variable names to tuple objects

2011-03-01 Thread Sean Carolan
Maybe someone can help with this. I have a function that takes a single file as an argument and outputs a tuple with each line of the file as a string element. This is part of a script that is intended to concatenate lines in files, and output them to a different file. This is as far as I've

Re: [Tutor] Dynamically assign variable names to tuple objects

2011-03-01 Thread Sean Carolan
On Tue, Mar 1, 2011 at 11:55 AM, Sean Carolan scaro...@gmail.com wrote: Maybe someone can help with this.  I have a function that takes a single file as an argument and outputs a tuple with each line of the file as a string element.  This is part of a script that is intended to concatenate

Re: [Tutor] Recommendation for pygame

2011-03-01 Thread Fernando Salamero
I teach videogames programming to my students using Python and Pygame: http://pythonwiki.wikispaces.com Sorry, in spanish... ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options:

Re: [Tutor] Dynamically assign variable names to tuple objects

2011-03-01 Thread Martin A. Brown
Sean, : Maybe someone can help with this. I have a function that takes a : single file as an argument and outputs a tuple with each line of : the file as a string element. This is part of a script that is : intended to concatenate lines in files, and output them to a : different file.

Re: [Tutor] Dynamically assign variable names to tuple objects

2011-03-01 Thread Hugo Arts
On Tue, Mar 1, 2011 at 7:10 PM, Sean Carolan scaro...@gmail.com wrote: On Tue, Mar 1, 2011 at 11:55 AM, Sean Carolan scaro...@gmail.com wrote: Maybe someone can help with this.  I have a function that takes a single file as an argument and outputs a tuple with each line of the file as a string

Re: [Tutor] Dynamically assign variable names to tuple objects

2011-03-01 Thread Sean Carolan
I saw in your follow-up that you went straight for vars().  I really don't think that's what you wish to use.  Get rid of vars(), he had to go to jail.  Don't go visit vars() again for at least two months, then maybe he'll be out on probation. Thanks Martin and Hugo. As you can tell I'm no

Re: [Tutor] Dynamically assign variable names to tuple objects

2011-03-01 Thread Joel Goldstick
On Tue, Mar 1, 2011 at 1:59 PM, Sean Carolan scaro...@gmail.com wrote: I saw in your follow-up that you went straight for vars(). I really don't think that's what you wish to use. Get rid of vars(), he had to go to jail. Don't go visit vars() again for at least two months, then maybe

Re: [Tutor] Dynamically assign variable names to tuple objects

2011-03-01 Thread Emile van Sebille
On 3/1/2011 10:59 AM Sean Carolan said... Take an arbitrary number of text files. Assume that each text file has the exact same number of lines. Concatenate each line of each file with the corresponding lines of the other files and output the data. So in other words, the first line of output

Re: [Tutor] Dynamically assign variable names to tuple objects

2011-03-01 Thread Hugo Arts
On Tue, Mar 1, 2011 at 7:59 PM, Sean Carolan scaro...@gmail.com wrote: I saw in your follow-up that you went straight for vars().  I really don't think that's what you wish to use.  Get rid of vars(), he had to go to jail.  Don't go visit vars() again for at least two months, then maybe he'll

[Tutor] File transfer HTTP - SFTP

2011-03-01 Thread Emanuel Lauria
Sorry if im annoying, but I think this is a better question than my previous one of today. I have some Images in an HTTP Server that I need to transfer to an SFTP server using a Python script. So far I can download them to my hard drive, and upload them to the sftp server; quite easy. I would

Re: [Tutor] Dynamically assign variable names to tuple objects

2011-03-01 Thread Sean Carolan
My advice would be to go read up on the zip() function and the str.join() function. Then, if you are using python 2.x, go find itertools.izip. It does the same thing as zip but it's more memory efficient. With those two you can do it in about two lines or so (and maybe a few for set up and

Re: [Tutor] Dynamically assign variable names to tuple objects

2011-03-01 Thread Emile van Sebille
On 3/1/2011 11:49 AM Sean Carolan said... My advice would be to go read up on the zip() function and the str.join() function. Then, if you are using python 2.x, go find itertools.izip. It does the same thing as zip but it's more memory efficient. With those two you can do it in about two lines

Re: [Tutor] couchdb.mapping 'Document' class

2011-03-01 Thread Knacktus
Am 01.03.2011 16:19, schrieb Emanuel Lauria: Hi everyone, I'm trying to map a couchdb document to a python object using couchdb.mapping. I'm stuck in the very first part were it says I should declare a Python class that inherits from the 'Document'.. Where does this 'Document' superclass comes

Re: [Tutor] File transfer HTTP - SFTP

2011-03-01 Thread Modulok
This isn't a python solution, but if you have an ssh connection to both servers, (I assume so) you can forward them directly. It would look like this in an operating system shell like tcsh or bash: me@baz scp -r m...@foo.com:/home/me/pictures m...@bar.com:/somewhere/ You could wrap the above

Re: [Tutor] Dynamically assign variable names to tuple objects

2011-03-01 Thread Steven D'Aprano
Emile van Sebille wrote: On 3/1/2011 11:49 AM Sean Carolan said... My advice would be to go read up on the zip() function and the str.join() function. Then, if you are using python 2.x, go find itertools.izip. It does the same thing as zip but it's more memory efficient. With those two you can

Re: [Tutor] Dynamically assign variable names to tuple objects

2011-03-01 Thread Sean Carolan
Another way is: zip(*map(open, myfiles)) Then your loop looks like: for i in zip([ cleanedup(filename) for filename in myfiles ]) Thanks, Steven! I knew there was a way to do this with just a few lines. I will read up some more on list expansion and the map built-in.