Re: [Tutor] role playing game - help needed

2010-12-06 Thread Alan Gauld
"Alan Stern" wrote Hi all. My name is Al Stern. Hi Al, Chapter 5: Lists and Dictionaries. Note Lists AND Dictionaries I'm not sure exactly how this mailing list works but was hoping someone here could give me some insight You are doing just fine. The only extra info we could fin

[Tutor] modified dictionary class

2010-12-06 Thread John
Hello all, I have been using this class extensively in my modules / scripts. It provides the ability to .reference dictionary values. I find it handy, but am afraid it may come back to haunt me at some point. Is there anything wrong with using this? class Structure(dict): """ A 'fancy' dicti

Re: [Tutor] modified dictionary class

2010-12-06 Thread Joel Goldstick
On Mon, Dec 6, 2010 at 7:34 AM, John wrote: > Hello all, > > I have been using this class extensively in my modules / scripts. It > provides the ability to .reference dictionary values. I find it handy, > but am afraid it may come back to haunt me at some point. Is there > anything wrong with usi

Re: [Tutor] modified dictionary class

2010-12-06 Thread Alan Gauld
"Joel Goldstick" wrote def __getattr__(self, attr): # Fake a __getstate__ method that resturns None if attr == "__getstate__": return lambda: None why not "return None"? Presumably the caller is expecting a function that he can call. The lambda is such a functio

[Tutor] Python vs. MATLAB

2010-12-06 Thread Jaidev Deshpande
Dear all What advantages does Python have over MATLAB as a programming language, (not the computing environment of MATLAB)? Also, wikipedia says Python is an interpreted language, what does that mean? ___ Tutor maillist - Tutor@python.org To unsubscri

Re: [Tutor] modified dictionary class

2010-12-06 Thread Alan Gauld
"Joel Goldstick" wrote def __getattr__(self, attr): # Fake a __getstate__ method that resturns None if attr == "__getstate__": return lambda: None why not "return None"? return self[attr] Oops, too quick. I neant to add: But this line seems to retur

Re: [Tutor] role playing game - help needed

2010-12-06 Thread Robert Sjöblom
>I am starting with a book called Python Programming for the Absolute Beginner >by Michael Dawson.  The book has been >pretty good >and up to this point, I >have grasped all the concepts it has covered.  At the end of each chapter, >there are a number of challenges you >need to complete before m

Re: [Tutor] Python vs. MATLAB

2010-12-06 Thread Chris Fuller
1) Python is free! 2) Python indices start at 0! 3) Python has way better GUIs 4) Python can emulate a lot of Matlab functionality with matplotlib and numpy 5) Matlab has a rather limited number of data structures 6) Matlab doesn't have anything like the third party support for almost anything 7)

Re: [Tutor] modified dictionary class

2010-12-06 Thread Hugo Arts
On Mon, Dec 6, 2010 at 2:47 PM, Alan Gauld wrote: > Oops, too quick. I neant to add: > > But this line seems to return a value so the return values of this function > seem to be incompatible which is not a good design pattern. I agree it's not the clearest way to do this, but not because of incom

Re: [Tutor] role playing game - help needed

2010-12-06 Thread Al Stern
Thanks for the advice. I think I have the dictionary function set up right now although I'm still not clear why it is better than the list. attributes = {"strength": 0, "health": 0, "wisdom": 0, "dexterity": 0} I think my next task is to set up a while function based on when available_points dro

Re: [Tutor] modified dictionary class

2010-12-06 Thread John
Hugo, Thank you for the response, it's very helpful. I posted a question earlier to this list (or possibly numpy) about how to create a 'matlab like structure'. This was early in my learning of Python, and yes, the intention was to have something that was similar to a matlab structure... now, I've

Re: [Tutor] modified dictionary class

2010-12-06 Thread Hugo Arts
On Mon, Dec 6, 2010 at 4:32 PM, John wrote: > Hugo, > > Thank you for the response, it's very helpful. I posted a question > earlier to this list (or possibly numpy) about how to create a 'matlab > like structure'. This was early in my learning of Python, and yes, the > intention was to have somet

Re: [Tutor] Python vs. MATLAB

2010-12-06 Thread Joel Schwartz
Chris, Can you say more about number (7) in your list? What does "pass by value" mean and what are the alternatives? Thanks, Joel > -Original Message- > From: tutor-bounces+joel=joelschwartz@python.org > [mailto:tutor-bounces+joel=joelschwartz@python.org] On > Behalf Of Chris

Re: [Tutor] Python vs. MATLAB

2010-12-06 Thread Wayne Werner
On Mon, Dec 6, 2010 at 11:09 AM, Joel Schwartz wrote: > Chris, > > Can you say more about number (7) in your list? What does "pass by value" > mean and what are the alternatives? > Pass by value is exactly what it sounds like - you pass the value (a copy of everything in the memory). This is bad

Re: [Tutor] Python vs. MATLAB

2010-12-06 Thread Hugo Arts
On Mon, Dec 6, 2010 at 6:09 PM, Joel Schwartz wrote: > Chris, > > Can you say more about number (7) in your list? What does "pass by value" > mean and what are the alternatives? > > Thanks, > Joel > Generally, pass-by-* refers to how the arguments to functions are treated. * In call-by-value, the

Re: [Tutor] role playing game - help needed

2010-12-06 Thread Alan Gauld
"Al Stern" wrote Thanks for the advice. I think I have the dictionary function set up right now although I'm still not clear why it is better than the list. attributes = {"strength": 0, "health": 0, "wisdom": 0, "dexterity": 0} Consider where you want to update the points for "health" U

Re: [Tutor] Python vs. MATLAB

2010-12-06 Thread Alan Gauld
"Jaidev Deshpande" wrote What advantages does Python have over MATLAB as a programming language, Python is a general purpose programming language. Matlab is a mathematical modelling toool that happens to be programmable. You wouldn't sensibly use Matlab to create a web site, or an action

Re: [Tutor] Python vs. MATLAB

2010-12-06 Thread Chris Fuller
It also makes it hard to modify some data structure you are working with. I was experimenting with some object-oriented programming in Matlab, and you actually have to explicitly inherit from "handle" if you have any methods that modify internal state. That was a surprise! If you've got a da

[Tutor] SAVE FILE IN A SPECIFIC DIRECTORY

2010-12-06 Thread Susana Iraiis Delgado Rodriguez
I'm trying to save files into a specific directory, the file will be generated from a python script. The script will look for some data stored in a directory which only allows to read files, it doesn't let the user write or modify information. But when I run the script I got the next error: Python

Re: [Tutor] Python vs. MATLAB

2010-12-06 Thread Steven D'Aprano
Chris Fuller wrote: On Monday 06 December 2010, Jaidev Deshpande wrote: Also, wikipedia says Python is an interpreted language, what does that mean? The "interpreted" bit refers to the fact that the source code is not compiled before it is run. This is also true of Matlab. That's not comp

Re: [Tutor] SAVE FILE IN A SPECIFIC DIRECTORY

2010-12-06 Thread Peter Otten
Susana Iraiis Delgado Rodriguez wrote: [UPPER CASE text is interpreted as shouting in emails and usenet posts. Please don't shout. Because spammers do it all the time it's more likely to make potential readers turn away from your writ rather than pay extra attention.] > I'm trying to save file

Re: [Tutor] Python vs. MATLAB

2010-12-06 Thread Steven D'Aprano
Joel Schwartz wrote: Chris, Can you say more about number (7) in your list? What does "pass by value" mean and what are the alternatives? Oh boy, is that a can of worms... and this is going to be a long post. You might want to go make yourself a coffee first :) Pass by whatever (also writte

Re: [Tutor] role playing game - help needed

2010-12-06 Thread Al Stern
Ok. I think I am starting to get it but still not sure how to separate the value from the key. Once I have this... attributes = {"strength": 0, "health": 0, "wisdom": 0, "dexterity": 0} MAX_POINTS = 30 How do I set the variable for available_points? available_points = MAX_POINTS - (not sure wh