Re: [Tutor] Static Variable in Functions

2011-03-13 Thread Yaşar Arabacı
Wow. That was a great explanation indeed. Thanks a lot. After reading this, I discovered something like this, and found it pretty insteresting indeed: >>> a=["a"] >>> b=[a] >>> a.append("c") >>> b [['a', 'c']] >>> a.append("d") >>> b [['a', 'c', 'd']] Apperantly, I can change something (which

Re: [Tutor] Static Variable in Functions

2011-03-13 Thread Steven D'Aprano
Yaşar Arabacı wrote: Author of this post says that we can use mutable variables like this as static function variables. I was wondering what are mutable variables and what is rationale behind them. It sounds like you are reading about Python with the mind-set of a C programmer. Python is not

Re: [Tutor] Static Variable in Functions

2011-03-13 Thread Alan Gauld
"Yasar Arabaci" wrote exactly like static variables in other languages (as I have used in php static in other languages usually refers to variables declared on the memory heap rather than the stack, and therefore they retain their value between calls. Python tends to operate at a higher level

Re: [Tutor] defining / calling arguments on a compiled script?

2011-03-13 Thread Alan Gauld
"Ryan Hussain" wrote I was wondering if there is a solution to add arguments to a compiled python script, compiled with py2exe? Assuming you still have the original source code then there is no difference to it being compiled with py2exe than if it weren't You just read the command line argu

Re: [Tutor] defining / calling arguments on a compiled script?

2011-03-13 Thread Wayne Werner
On Sun, Mar 13, 2011 at 12:16 PM, Ryan Hussain wrote: > Hello, > > I was wondering if there is a solution to add arguments to a compiled > python script, compiled with py2exe? For example I would like to do > something such as running my script named "demo.exe -a". With the -a > argument I would

[Tutor] defining / calling arguments on a compiled script?

2011-03-13 Thread Ryan Hussain
Hello, I was wondering if there is a solution to add arguments to a compiled python script, compiled with py2exe? For example I would like to do something such as running my script named "demo.exe -a". With the -a argument I would like to run a function. How can I define arguments in my script? -

[Tutor] Static Variable in Functions

2011-03-13 Thread Yaşar Arabacı
Hi, As I am starting to learn python, I follow dive into python. As I read object section, I came across something called class attributes and data attributes. Because of the reason that class attributes look and behave exactly like static variables in other languages (as I have used in php f

Re: [Tutor] passing by reference

2011-03-13 Thread Steven D'Aprano
Vineeth Mohan wrote: Hi, How are variables in python passed. By value or by referrence? Neither. What makes you think that value and reference are the only two choices? See this Wikipedia article for a list of at least a dozen different argument passing techniques: http://en.wikipedia.o

Re: [Tutor] passing by reference

2011-03-13 Thread Alan Gauld
"Vineeth Mohan" wrote How are variables in python passed. By value or by referrence? Neither, and trying to force a comparison to these traditional styles will always lead to an exercise in frustration as you find cases which don't quite fit.. Variables in Python are names that refer to obj

Re: [Tutor] Simplistic drive simulation

2011-03-13 Thread Alan Gauld
"R. Alan Monroe" wrote I was just going to start with, say, 16 or 64 "blocks", then randomly add and delete ficticious "files" 1. Is there some more clever way of tracking this than the very naive approach: toc = { A: [0, 1, 2], D: [3, 4, 5, 9, 10], C: [6, 7, 8] } ? Obviously yes, th

[Tutor] passing by reference

2011-03-13 Thread Vineeth Mohan
Hi, How are variables in python passed. By value or by referrence? For example if we consider a simple function below wherein the value of a does not get modified in the main function. def addition(a,b): a = a+1 return a+b if __name__ == '__main__': a = 10 b = 15 addit