Re: What value should be passed to make a function use the default argument value?

2006-10-13 Thread Steve Holden
Antoon Pardon wrote: > On 2006-10-12, Magnus Lycka <[EMAIL PROTECTED]> wrote: > >>Antoon Pardon wrote: >> >>>Well maybe he didn't intend that, but how is the reader of the >>>documentation to know that? The reader can only go by how >>>things are documented. If those are not entirely consistent >>

Re: What value should be passed to make a function use the default argument value?

2006-10-13 Thread Antoon Pardon
On 2006-10-12, Magnus Lycka <[EMAIL PROTECTED]> wrote: > Antoon Pardon wrote: >> Well maybe he didn't intend that, but how is the reader of the >> documentation to know that? The reader can only go by how >> things are documented. If those are not entirely consistent >> with the intend of the progr

Re: What value should be passed to make a function use the default argument value?

2006-10-12 Thread Magnus Lycka
Antoon Pardon wrote: > Well maybe he didn't intend that, but how is the reader of the > documentation to know that? The reader can only go by how > things are documented. If those are not entirely consistent > with the intend of the programmer, that is not the readers > fault. I don't think I ever

Re: What value should be passed to make a function use the default argument value?

2006-10-06 Thread hanumizzle
On 6 Oct 2006 10:57:01 GMT, Antoon Pardon <[EMAIL PROTECTED]> wrote: > Again that is not the fault of those that read the documentation. If > this discinction can't be easily made in python 2.X, you can't fault > the reader for coming to a conclusion that seems to follow rather > naturally from ho

Re: What value should be passed to make a function use the default argument value?

2006-10-06 Thread Steven D'Aprano
On Fri, 06 Oct 2006 12:42:08 +0200, Fredrik Lundh wrote: > Antoon Pardon wrote: > >> IMO this is a very natural thought process for a python programmer. >> So a python programmer seeing the first will tend to expect that >> last call to work. > > on the other hand, if a Python programmer *writes

Re: What value should be passed to make a function use the default argument value?

2006-10-06 Thread Antoon Pardon
On 2006-10-06, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Antoon Pardon wrote: > >> IMO this is a very natural thought process for a python programmer. >> So a python programmer seeing the first will tend to expect that >> last call to work. > > on the other hand, if a Python programmer *writes* so

Re: What value should be passed to make a function use the default argument value?

2006-10-06 Thread Fredrik Lundh
Antoon Pardon wrote: > IMO this is a very natural thought process for a python programmer. > So a python programmer seeing the first will tend to expect that > last call to work. on the other hand, if a Python programmer *writes* some code instead; say, a trivial function like: def calc

Re: What value should be passed to make a function use the default argument value?

2006-10-06 Thread Antoon Pardon
On 2006-10-06, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > hanumizzle wrote: > >> Not sure exactly what is going on / being argued about in this > > thread > > I'm describing best practices based on long experience of using and > developing and teaching and writing about Python stuff. Others have

Re: What value should be passed to make a function use the default argument value?

2006-10-06 Thread Antoon Pardon
On 2006-10-06, hanumizzle <[EMAIL PROTECTED]> wrote: > On 6 Oct 2006 09:21:11 GMT, Antoon Pardon <[EMAIL PROTECTED]> wrote: >> On 2006-10-06, Fredrik Lundh <[EMAIL PROTECTED]> wrote: >> > Antoon Pardon wrote: >> > >> >> Is this general rules documeted somewhere? My impression is that readers >> >>

Re: What value should be passed to make a function use the default argument value?

2006-10-06 Thread Fredrik Lundh
hanumizzle wrote: > Not sure exactly what is going on / being argued about in this > thread I'm describing best practices based on long experience of using and developing and teaching and writing about Python stuff. Others have other priorities, it seems. > This doesn't say anything positiv

Re: What value should be passed to make a function use the default argument value?

2006-10-06 Thread hanumizzle
On 6 Oct 2006 09:21:11 GMT, Antoon Pardon <[EMAIL PROTECTED]> wrote: > On 2006-10-06, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > > Antoon Pardon wrote: > > > >> Is this general rules documeted somewhere? My impression is that readers > >> of the documentation will treat arguments as keyword argumen

Re: What value should be passed to make a function use the default argument value?

2006-10-06 Thread Antoon Pardon
On 2006-10-06, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Antoon Pardon wrote: > >> Is this general rules documeted somewhere? My impression is that readers >> of the documentation will treat arguments as keyword arguments unless >> this is explicitly contradicted. > > Sorry, I missed that this was

Re: What value should be passed to make a function use the default argument value?

2006-10-06 Thread Fredrik Lundh
Antoon Pardon wrote: > Is this general rules documeted somewhere? My impression is that readers > of the documentation will treat arguments as keyword arguments unless > this is explicitly contradicted. Sorry, I missed that this was comp.lang.python.alternate.reality. My mistake. -- http://

Re: What value should be passed to make a function use the default argument value?

2006-10-06 Thread Antoon Pardon
On 2006-10-04, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Georg Brandl wrote: > >> This is an issue in most Python documentation: you're not told >> if the described function is implemented in C, and if it is >> keyword arg-enabled. The arguments must be given names though, >> to be able to documen

Re: What value should be passed to make a function use the default argument value?

2006-10-05 Thread Fredrik Lundh
Ben Finney wrote: > Perhaps you meant something other than "if the documentation doesn't > explicitly say that something is a keyword argument, it isn't", then. I'm sure it's perfectly possibly to use your foot as a door stop, but does that really mean that it is one? -- http://mail.python.o

Re: What value should be passed to make a function use the default argument value?

2006-10-05 Thread Ben Finney
Fredrik Lundh <[EMAIL PROTECTED]> writes: > Gabriel Genellina wrote: > > >> > the general rule is that if the documentation doesn't > >> > explicitly say that something is a keyword argument, it isn't, > >> > and shouldn't be treated as such. > > you guys need to look up the words "should" and "no

Re: What value should be passed to make a function use the default argument value?

2006-10-05 Thread Fredrik Lundh
Gabriel Genellina wrote: >> > the general rule is that if the documentation doesn't explicitly say >> > that something is a keyword argument, it isn't, and shouldn't be >> > treated as such. >> >> The first module I looked in to check this, it wasn't true. In the Queue >> Module is isn't explicit

Re: What value should be passed to make a function use the default argument value?

2006-10-05 Thread Gabriel Genellina
At Thursday 5/10/2006 11:41, Antoon Pardon wrote: > the general rule is that if the documentation doesn't explicitly say > that something is a keyword argument, it isn't, and shouldn't be treated > as such. The first module I looked in to check this, it wasn't true. In the Queue Module is isn't

Re: What value should be passed to make a function use the default argument value?

2006-10-05 Thread Steve Holden
Fredrik Lundh wrote: > Antoon Pardon wrote: > > >>The first module I looked in to check this, it wasn't true. In the Queue >>Module is isn't explicitly written that maxsize is a keyword argument yet >>Queue.Queue(maxsize=9) works just fine. > > > it's not a matter whether it works fine in any g

Re: What value should be passed to make a function use the default argument value?

2006-10-05 Thread Fredrik Lundh
Antoon Pardon wrote: > The first module I looked in to check this, it wasn't true. In the Queue > Module is isn't explicitly written that maxsize is a keyword argument yet > Queue.Queue(maxsize=9) works just fine. it's not a matter whether it works fine in any given version of Python, it's a mat

Re: What value should be passed to make a function use the default argument value?

2006-10-05 Thread Antoon Pardon
On 2006-10-04, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Georg Brandl wrote: > >> This is an issue in most Python documentation: you're not told >> if the described function is implemented in C, and if it is >> keyword arg-enabled. The arguments must be given names though, >> to be able to documen

Re: What value should be passed to make a function use the default argument value?

2006-10-04 Thread Fredrik Lundh
Georg Brandl wrote: > This is an issue in most Python documentation: you're not told > if the described function is implemented in C, and if it is > keyword arg-enabled. The arguments must be given names though, > to be able to document them. the general rule is that if the documentation doesn't

Re: What value should be passed to make a function use the default argument value?

2006-10-04 Thread Georg Brandl
Paul Rubin wrote: > Antoon Pardon <[EMAIL PROTECTED]> writes: >> repeat(object[, times]) >> Make an iterator that returns object over and over again. Runs >> indefinitely unless the times argument is specified. ... >> >> My first impression from this, is that it is possible to call >> this

Re: What value should be passed to make a function use the default argument value?

2006-10-04 Thread Antoon Pardon
On 2006-10-04, Antoon Pardon <[EMAIL PROTECTED]> wrote: > On 2006-10-03, LaundroMat <[EMAIL PROTECTED]> wrote: >> Suppose I have this function: >> >> def f(var=1): >> return var*2 >> >> What value do I have to pass to f() if I want it to evaluate var to 1? >> I know that f() will return 2, but what

Re: What value should be passed to make a function use the default argument value?

2006-10-04 Thread Antoon Pardon
On 2006-10-03, LaundroMat <[EMAIL PROTECTED]> wrote: > Suppose I have this function: > > def f(var=1): > return var*2 > > What value do I have to pass to f() if I want it to evaluate var to 1? > I know that f() will return 2, but what if I absolutely want to pass a > value to f()? "None" doesn't se

Re: What value should be passed to make a function use the default argument value?

2006-10-04 Thread Paul Rubin
Antoon Pardon <[EMAIL PROTECTED]> writes: > repeat(object[, times]) > Make an iterator that returns object over and over again. Runs > indefinitely unless the times argument is specified. ... > > My first impression from this, is that it is possible to call > this as follows: > repeat(No

Re: What value should be passed to make a function use the default argument value?

2006-10-04 Thread Antoon Pardon
On 2006-10-04, Georg Brandl <[EMAIL PROTECTED]> wrote: > Antoon Pardon wrote: >> On 2006-10-04, Paul Rubin wrote: >>> Antoon Pardon <[EMAIL PROTECTED]> writes: Now in this case you could start by assigning arg the value 1 and eliminate the if test. However that only works if you know the

Re: What value should be passed to make a function use the default argument value?

2006-10-04 Thread Georg Brandl
Antoon Pardon wrote: > On 2006-10-04, Paul Rubin wrote: >> Antoon Pardon <[EMAIL PROTECTED]> writes: >>> Now in this case you could start by assigning arg the value 1 and >>> eliminate the if test. However that only works if you know the >>> default value for the argument. What he seems to be aski

Re: What value should be passed to make a function use the default argument value?

2006-10-04 Thread Antoon Pardon
On 2006-10-04, Nick Craig-Wood <[EMAIL PROTECTED]> wrote: > Antoon Pardon <[EMAIL PROTECTED]> wrote: >> One possible way to do what I think you want is to code as follows: >> >> class Default (object): >>pass > > I'd have written > > Default = object() > >> def f(var=Default): >>if var

Re: What value should be passed to make a function use the default argument value?

2006-10-04 Thread Antoon Pardon
On 2006-10-04, Paul Rubin wrote: > Antoon Pardon <[EMAIL PROTECTED]> writes: >> Now in this case you could start by assigning arg the value 1 and >> eliminate the if test. However that only works if you know the >> default value for the argument. What he seems to be asking for >> is if there is an

Re: What value should be passed to make a function use the default argument value?

2006-10-04 Thread Nick Craig-Wood
Antoon Pardon <[EMAIL PROTECTED]> wrote: > One possible way to do what I think you want is to code as follows: > > class Default (object): >pass I'd have written Default = object() > def f(var=Default): >if var is Default: > var = 1 >return var * 2 > But yes, defining a se

Re: What value should be passed to make a function use the default argument value?

2006-10-04 Thread Nick Craig-Wood
LaundroMat <[EMAIL PROTECTED]> wrote: > I have in fact a bunch of functions that all pass similar information > to one main function. That function takes (amongst others) a template > variable. If it's not being passed, it is set to a default value by the > function called upon. > > For the m

Re: What value should be passed to make a function use the default argument value?

2006-10-04 Thread Antoon Pardon
On 2006-10-04, Paul Rubin wrote: > "LaundroMat" <[EMAIL PROTECTED]> writes: >> def f(var=1): >> return var*2 >> >> What value do I have to pass to f() if I want it to evaluate var to 1? >> I know that f() will return 2, but what if I absolutely want to pass a >> value to f()? "None" doesn't seem

Re: What value should be passed to make a function use the default argument value?

2006-10-04 Thread Paul Rubin
Antoon Pardon <[EMAIL PROTECTED]> writes: > Now in this case you could start by assigning arg the value 1 and > eliminate the if test. However that only works if you know the > default value for the argument. What he seems to be asking for > is if there is an object, (let as call it Default), that

Re: What value should be passed to make a function use the default argument value?

2006-10-04 Thread LaundroMat
Antoon Pardon wrote: > The problem is like the following. > > def f(var=1): > return var*2 > > def g(): > arg = None > try: > arg = Try_Processing() / 3 + 1 > except Nothing_To_Process: > pass > if arg is None: > return f() > else: > return f(arg) > > Now in this case y

Re: What value should be passed to make a function use the default argument value?

2006-10-04 Thread Paul Rubin
"LaundroMat" <[EMAIL PROTECTED]> writes: > def f(var=1): > return var*2 > > What value do I have to pass to f() if I want it to evaluate var to 1? > I know that f() will return 2, but what if I absolutely want to pass a > value to f()? "None" doesn't seem to work.. I don't understand your questio

Re: What value should be passed to make a function use the default argument value?

2006-10-04 Thread LaundroMat
Rob De Almeida wrote: > LaundroMat wrote: > > Suppose I have this function: > > > > def f(var=1): > > return var*2 > > > > What value do I have to pass to f() if I want it to evaluate var to 1? > > I know that f() will return 2, but what if I absolutely want to pass a > > value to f()? "None" doe

Re: What value should be passed to make a function use the default argument value?

2006-10-04 Thread Antoon Pardon
On 2006-10-03, LaundroMat <[EMAIL PROTECTED]> wrote: > Suppose I have this function: > > def f(var=1): > return var*2 > > What value do I have to pass to f() if I want it to evaluate var to 1? > I know that f() will return 2, but what if I absolutely want to pass a > value to f()? "None" doesn't se

Re: What value should be passed to make a function use the default argument value?

2006-10-03 Thread Rob De Almeida
LaundroMat wrote: > Suppose I have this function: > > def f(var=1): > return var*2 > > What value do I have to pass to f() if I want it to evaluate var to 1? > I know that f() will return 2, but what if I absolutely want to pass a > value to f()? "None" doesn't seem to work.. If you *absolutely* w

Re: What value should be passed to make a function use the default argument value?

2006-10-03 Thread Bruno Desthuilliers
LaundroMat a écrit : > Suppose I have this function: > > def f(var=1): > return var*2 > > What value do I have to pass to f() if I want it to evaluate var to 1? > > I know that f() will return 2, but what if I absolutely want to pass a > value to f()? "None" doesn't seem to work.. Have you trie

Re: What value should be passed to make a function use the default argument value?

2006-10-03 Thread Stan Graves
LaundroMat wrote: > Suppose I have this function: > > def f(var=1): > return var*2 > > What value do I have to pass to f() if I want it to evaluate var to 1? > I know that f() will return 2, but what if I absolutely want to pass a > value to f()? "None" doesn't seem to work.. What about this? >>

Re: What value should be passed to make a function use the default argument value?

2006-10-03 Thread Thomas Jollans
On Tue, 03 Oct 2006 13:16:57 -0700, "LaundroMat" <[EMAIL PROTECTED]> let this slip: > Suppose I have this function: > > def f(var=1): > return var*2 > > What value do I have to pass to f() if I want it to evaluate var to 1? > I know that f() will return 2, but what if I absolutely want to pass a

Re: What value should be passed to make a function use the default argument value?

2006-10-03 Thread Larry Bates
LaundroMat wrote: > Suppose I have this function: > > def f(var=1): > return var*2 > > What value do I have to pass to f() if I want it to evaluate var to 1? > I know that f() will return 2, but what if I absolutely want to pass a > value to f()? "None" doesn't seem to work.. > > Thanks in advan

Re: What value should be passed to make a function use the default argument value?

2006-10-03 Thread Tim Chase
> def f(var=1): > return var*2 > > What value do I have to pass to f() if I want it to evaluate var to 1? > I know that f() will return 2, but what if I absolutely want to pass a > value to f()? "None" doesn't seem to work.. >>> def f(var=1): ... return var*2 ... >>> f() 2 >>> f(0.5) 1.0

Re: What value should be passed to make a function use the default argument value?

2006-10-03 Thread Lawrence Oluyede
LaundroMat <[EMAIL PROTECTED]> wrote: > What value do I have to pass to f() if I want it to evaluate var to 1? > I know that f() will return 2, but what if I absolutely want to pass a > value to f()? "None" doesn't seem to work.. I don't know if I understand correctly here but: def f(v=1): re

Re: What value should be passed to make a function use the default argument value?

2006-10-03 Thread Fredrik Lundh
LaundroMat wrote: > Suppose I have this function: > > def f(var=1): > return var*2 > > What value do I have to pass to f() if I want it to evaluate var to 1? > I know that f() will return 2, but what if I absolutely want to pass a > value to f()? f(1) > "None" doesn't seem to work.. None is

What value should be passed to make a function use the default argument value?

2006-10-03 Thread LaundroMat
Suppose I have this function: def f(var=1): return var*2 What value do I have to pass to f() if I want it to evaluate var to 1? I know that f() will return 2, but what if I absolutely want to pass a value to f()? "None" doesn't seem to work.. Thanks in advance. -- http://mail.python.org/mailma