Re: Is it allowed to use function results as default arguments ?

2008-07-30 Thread Terry Reedy
fred.haab wrote: Well, others have answered the question, but I thought I'd throw in that it would be more pythonic to do something like: def Get_Relative_Path(target, base = None): if base is None: base = os.curdir ... Since os.curdir is a constant, this is nonesensical. On

Re: Is it allowed to use function results as default arguments ?

2008-07-29 Thread Ben Finney
"fred.haab" <[EMAIL PROTECTED]> writes: > Well, others have answered the question, but I thought I'd throw in > that it would be more pythonic to do something like: > > def Get_Relative_Path(target, base = None): > if base is None: > base = os.curdir > ... Even more Pythonic woul

Re: Is it allowed to use function results as default arguments ?

2008-07-29 Thread fred.haab
Well, others have answered the question, but I thought I'd throw in that it would be more pythonic to do something like: def Get_Relative_Path(target, base = None): if base is None: base = os.curdir ... -- http://mail.python.org/mailman/listinfo/python-list

Re: Is it allowed to use function results as default arguments ?

2008-07-29 Thread Grant Edwards
On 2008-07-29, Stef Mientki <[EMAIL PROTECTED]> wrote: > brings me to one other question: > I guess this function is only evaluated once, is that correct ? Yes. > about '.' being the current directory, well I think windows > was thrown at the market about 25 years ago, and since then we > don'

Re: Is it allowed to use function results as default arguments ?

2008-07-29 Thread Steven D'Aprano
On Tue, 29 Jul 2008 09:43:26 +0200, Stef Mientki wrote: > about '.' being the current directory, well I think windows was thrown > at the market about 25 years ago, and since then we don't use '.' > anymore ;-) No, even Windows uses '.' as the current directory -- at least XP does, I haven't tri

Re: Is it allowed to use function results as default arguments ?

2008-07-29 Thread Stef Mientki
Terry Reedy wrote: To answer the subject line: param= will assign the result of the expression as the default argument object for the parameter. thanks Terry and others, brings me to one other question: I guess this function is only evaluated once, is that correct ? about os.curdir, I chec

Re: Is it allowed to use function results as default arguments ?

2008-07-29 Thread Terry Reedy
To answer the subject line: param= will assign the result of the expression as the default argument object for the parameter. tjr -- http://mail.python.org/mailman/listinfo/python-list

Re: Is it allowed to use function results as default arguments ?

2008-07-28 Thread Benjamin
On Jul 28, 3:28 pm, Stef Mientki <[EMAIL PROTECTED]> wrote: > hello, > > I've a perfect working procedure, > at least as far I've tested it it works perfect. > > But I was just experimenting with inspect, > and saw that the default argument was not parsed correctly. > > So I wonder if this is allow

Re: Is it allowed to use function results as default arguments ?

2008-07-28 Thread Guilherme Polo
On Mon, Jul 28, 2008 at 5:28 PM, Stef Mientki <[EMAIL PROTECTED]> wrote: > hello, > > I've a perfect working procedure, > at least as far I've tested it it works perfect. > > But I was just experimenting with inspect, > and saw that the default argument was not parsed correctly. > > So I wonder if

Re: Is it allowed to use function results as default arguments ?

2008-07-28 Thread Simon Forman
On Jul 28, 1:28 pm, Stef Mientki <[EMAIL PROTECTED]> wrote: > hello, > > I've a perfect working procedure, > at least as far I've tested it it works perfect. > > But I was just experimenting with inspect, > and saw that the default argument was not parsed correctly. > > So I wonder if this is allow

Is it allowed to use function results as default arguments ?

2008-07-28 Thread Stef Mientki
hello, I've a perfect working procedure, at least as far I've tested it it works perfect. But I was just experimenting with inspect, and saw that the default argument was not parsed correctly. So I wonder if this is allowed: def Get_Relative_Path ( target, base=os.curdir ) : ... As inspect r