Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #17937 > unrolled thread

Re: How safe is this way of getting a default that allows None?

Started byTim Chase <python.list@tim.thechases.com>
First post2011-12-25 19:14 -0600
Last post2011-12-25 19:14 -0600
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: How safe is this way of getting a default that allows None? Tim Chase <python.list@tim.thechases.com> - 2011-12-25 19:14 -0600

#17937 — Re: How safe is this way of getting a default that allows None?

FromTim Chase <python.list@tim.thechases.com>
Date2011-12-25 19:14 -0600
SubjectRe: How safe is this way of getting a default that allows None?
Message-ID<mailman.4087.1324862079.27778.python-list@python.org>
On 12/25/11 18:49, Dan Stromberg wrote:
> How safe is this?  I like the idea.
>
> UNSPECIFIED = object()
>
> def fn(x, y=UNSPECIFIED):
>     if y is UNSPECIFIED:
>        print x, 'default'
>     else:
>        print x, y

safe?  It's idiomatic :)

-tkc

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web