Re: Calling functions: Why this complicated ?

2009-08-01 Thread lkcl
On Jul 14, 11:31 pm, Chris Rebert wrote: > On Tue, Jul 14, 2009 at 1:40 PM, Mohan Parthasarathy > wrote: > > Hi, > > I am a newbie. I am reading > >http://www.network-theory.co.uk/docs/pytut/KeywordArguments.html > > Defining a function with "N" arguments and calling them in "M" different > > way

Re: Calling functions: Why this complicated ?

2009-07-15 Thread Jeremiah Dodds
On Wed, Jul 15, 2009 at 11:54 AM, Tim Rowe wrote: > > Curiously, I never use the all-named style in Python, whereas it's my > normal style in Ada. I shall now enter a period of self-refelection to > try to work out why I am so inconsistent :-) > > > I use it for functions that only (or mostly) ha

Re: Calling functions: Why this complicated ?

2009-07-15 Thread Tim Rowe
2009/7/15 Jeremiah Dodds : > As a hopefully semi-informative aside, I've been writing python code for a > few years now, and I regularly use all four forms of argument passing listed > above. Curiously, I never use the all-named style in Python, whereas it's my normal style in Ada. I shall now en

Re: Calling functions: Why this complicated ?

2009-07-15 Thread Jeremiah Dodds
On Wed, Jul 15, 2009 at 1:42 AM, Mohan Parthasarathy wrote: > So, all four of them above has its use cases in practice i guess. > > thanks > mohan > As a hopefully semi-informative aside, I've been writing python code for a few years now, and I regularly use all four forms of argument passing lis

Re: Calling functions: Why this complicated ?

2009-07-14 Thread Mohan Parthasarathy
Chris, Thanks for your clarifications > > I am a newbie. I am reading > > http://www.network-theory.co.uk/docs/pytut/KeywordArguments.html > > Defining a function with "N" arguments and calling them in "M" different > > ways. Why does it have to be this complicated ? I like the idea of > calling

Re: Calling functions: Why this complicated ?

2009-07-14 Thread Chris Rebert
On Tue, Jul 14, 2009 at 1:40 PM, Mohan Parthasarathy wrote: > Hi, > I am a newbie. I am reading > http://www.network-theory.co.uk/docs/pytut/KeywordArguments.html > Defining a function with "N" arguments and calling them in "M" different > ways. Why does it have to be this complicated ? I like the

Re: Calling functions with dynamic arguments

2006-11-29 Thread SeanDavis12
Roberto Bonvallet wrote: > SeanDavis12 wrote: > > I have a dictionary like: > > > > {"a":1, "b":2} > > > > and I want to call a function: > > > > def func1(a=3,b=4): > >print a,b > > > > so that I get a=1,b=2, how can I go about that? > > func1(**yourdict) Thanks, Roberto. Sean -- http:

Re: Calling functions with dynamic arguments

2006-11-29 Thread Roberto Bonvallet
SeanDavis12 wrote: > I have a dictionary like: > > {"a":1, "b":2} > > and I want to call a function: > > def func1(a=3,b=4): >print a,b > > so that I get a=1,b=2, how can I go about that? func1(**yourdict) -- Roberto Bonvallet -- http://mail.python.org/mailman/listinfo/python-list

Re: Calling functions

2006-10-19 Thread Tommy Grav
That does work yes :) I just noticed that the script had another little error in it, making me believe that the function call was crooking.Cheers   TommyOn Oct 19, 2006, at 12:30 PM, Dustin J. Mitchell wrote:Tommy Grav wrote: I have a small program that goes something like thisdef funcA() : passdef

Re: Calling functions

2006-10-19 Thread Fredrik Lundh
Tommy Grav wrote: > I have a small program that goes something like this > > def funcA() : pass > def funcB() : pass > def funcC() : pass > > def determine(f): > t = f() > return t > > What I would like to do is be able to > > n = determine(funcA) > m = determine(funcB) > > But I can

Re: Calling functions

2006-10-19 Thread Dustin J. Mitchell
Tommy Grav wrote: > I have a small program that goes something like this > > def funcA() : pass > def funcB() : pass > def funcC() : pass > > def determine(f): > t = f() > return t > > What I would like to do is be able to > > n = determine(funcA) > m = determine(funcB) > > But I can't really

Re: calling functions style question

2006-06-06 Thread Kay Schluehr
Brian wrote: > I just have a basic style question here. Suppose you have the program: > > def foo1(): > do something > > def foo2() > do something else > > Assume that you want to call these functions at execution. Is it more > proper to call them directly like: > > foo1() > foo2() > > o

Re: calling functions style question

2006-06-06 Thread Thomas Nelson
The difference becomes clear when you import your program into another program (or the command line python editor). __name__!='__main__' when you import, so the functions will not be called if they're inside the block. This is why you see this block so often at the end of scripts; so that the scr

Re: calling functions

2005-08-02 Thread bruno modulix
anthonyberet wrote: > This is the first time I have tried out functions (is that the main way > of making subroutines in Python?) A function is allowed to change it's arguments and to return None, so yes, you can consider it as a 'subroutine'. > > Anyway, my function, mutate, below > > #make a

Re: calling functions

2005-08-01 Thread jepler
Without a 'global' statement, all variables which are assigned in the body of a function are local to that function. Here is an example showing that f() does not create a module-level variable, but g() does. >>> def f(): ... z = 3 ... >>> def g(): ... global z ... z = 3 ... >>> z Tr

Re: calling functions across threads

2004-12-29 Thread It's me
I haven't play with the thread stuff in Python (yet) but in general terms (from a C mind), one should not expect read/write actions to be sequential across threads. I would assume the Python threads eventually goes back to some system calls for thread handling. If that were the case, you should

Re: calling functions across threads

2004-12-29 Thread Steve Holden
Steven Bethard wrote: Fernando Perez wrote: Steven Bethard wrote: Fernando Perez wrote: Steven Bethard wrote: I get the correct output, but if you run this yourself, you'll see that the numbers 1 through 10 aren't printed in sync with the writes (i.e. every half second); they're all printed at t

Re: calling functions across threads

2004-12-29 Thread Steven Bethard
Fernando Perez wrote: Steven Bethard wrote: Fernando Perez wrote: Steven Bethard wrote: I get the correct output, but if you run this yourself, you'll see that the numbers 1 through 10 aren't printed in sync with the writes (i.e. every half second); they're all printed at the end. Could someone

Re: calling functions across threads

2004-12-29 Thread Fernando Perez
Steven Bethard wrote: > Fernando Perez wrote: >> Steven Bethard wrote: >> >> >>>I get the correct output, but if you run this yourself, you'll see that >>>the numbers 1 through 10 aren't printed in sync with the writes (i.e. >>>every half second); they're all printed at the end. Could someone >

Re: calling functions across threads

2004-12-29 Thread Steven Bethard
Fernando Perez wrote: Steven Bethard wrote: I get the correct output, but if you run this yourself, you'll see that the numbers 1 through 10 aren't printed in sync with the writes (i.e. every half second); they're all printed at the end. Could someone explain to me why this happens, and how (if p

Re: calling functions across threads

2004-12-29 Thread Fernando Perez
Steven Bethard wrote: > I get the correct output, but if you run this yourself, you'll see that > the numbers 1 through 10 aren't printed in sync with the writes (i.e. > every half second); they're all printed at the end. Could someone > explain to me why this happens, and how (if possible) I can

Re: calling functions across threads

2004-12-29 Thread Steven Bethard
Thomas Rast wrote: Steven Bethard <[EMAIL PROTECTED]> writes: I get the correct output, but if you run this yourself, you'll see that the numbers 1 through 10 aren't printed in sync with the writes (i.e. every half second); they're all printed at the end. Could someone explain to me why this happe

Re: calling functions across threads

2004-12-29 Thread Thomas Rast
Steven Bethard <[EMAIL PROTECTED]> writes: > I get the correct output, but if you run this yourself, you'll see > that the numbers 1 through 10 aren't printed in sync with the writes > (i.e. every half second); they're all printed at the end. Could > someone explain to me why this happens, and ho