optional arguments

Cliff Wells logiplexsoftware at earthlink.net
Wed Sep 19 15:31:43 EDT 2001


On Monday 17 September 2001 02:52, Martin von Loewis wrote:
> Silvio Arcangeli <sarcangeli at montrouge.sema.slb.com> writes:
> > class Connection:
> > 	def __init__(self, ip=def_ip, port=def_port)
> > 		...
>
> [...]
>
> > how can I tell wheter no arguments were passed from the user or whether
> > they were passed but they were just like the default values?
>
>

Another possibility is mxTools which provides a NotGiven singleton similar to 
None:
(from the mxTools page):

import mx.Tools.NewBuiltins
def f(a,b=4,c=NotGiven,d=''):
    if c is NotGiven:
        return a / b, d
    else:
        return a*b + c, d

http://www.lemburg.com/files/python/mxTools.html


-- 
Cliff Wells
Software Engineer
Logiplex Corporation (www.logiplex.net)
(503) 978-6726 x308
(800) 735-0555 x308




More information about the Python-list mailing list