Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #64508
| Path | csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.009 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'none:': 0.07; 'cc:addr :python-list': 0.11; 'def': 0.12; 'jan': 0.12; '23,': 0.16; 'creation.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'singleton': 0.16; 'wrote:': 0.18; 'thu,': 0.19; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'header:In-Reply- To:1': 0.27; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; 'subject:from': 0.34; 'except': 0.35; 'skip:s 30': 0.35; 'late': 0.35; 'one,': 0.35; 'received:google.com': 0.35; 'possible': 0.36; 'las': 0.37; 'anything': 0.39; 'to:none': 0.92 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=6yy94tchLMATn8BFEQ2sNDe0arRY6argI8Or2zxnZLs=; b=gCovKu03UuS9DF1eSCwd0JY7789/NUDyHZXINqS5aUlHj3QV3YMNCCf8xnnqIRKSCh Z2snha2unSmsz90NGeiGn2cHP0j8+kjYQ1jM1EHmZJsAOeY41nHCj7UHfSauk+ynOF03 CPMESNDDdXy1TYKKlo8pSkfRDkAqRgy/v8mfltCIVBpUISluxr0R+lPr5jo+Swd+W1J9 NQX6kGqVE9U/YHEXp6OR07XXePtO3LgfuhWZj+IlwsMGFFuAZr28rp8EyiLjt/zuc3gn o840ZI+/OahD/t1rG9fGfgYoGQTMgGHPm5Lm97VcoGEs1gEc/2SRBOh6hY7GkiMZ/+lS MQsA== |
| MIME-Version | 1.0 |
| X-Received | by 10.68.182.165 with SMTP id ef5mr2372654pbc.169.1390407537460; Wed, 22 Jan 2014 08:18:57 -0800 (PST) |
| In-Reply-To | <26ff768d-349c-48cd-a46f-25343807e18a@googlegroups.com> |
| References | <26ff768d-349c-48cd-a46f-25343807e18a@googlegroups.com> |
| Date | Thu, 23 Jan 2014 03:18:57 +1100 |
| Subject | Re: SIngleton from __defaults__ |
| From | Chris Angelico <rosuav@gmail.com> |
| Cc | "python-list@python.org" <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.5843.1390407541.18130.python-list@python.org> (permalink) |
| Lines | 22 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1390407541 news.xs4all.nl 2948 [2001:888:2000:d::a6]:50148 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:64508 |
Show key headers only | View raw
On Thu, Jan 23, 2014 at 3:07 AM, Asaf Las <roegltd@gmail.com> wrote:
> is it possible to create singleton using construct below :
>
> def singleton_provider(x = [None]):
> if singleton_provider.__defaults__[0][0] == None:
> singleton_provider.__defaults__[0][0] = SomeClass()
> return singleton_provider.__defaults__[0][0]
>
Why not simply:
def get_singleton(x = SomeClass()):
return x
Or even:
singleton = SomeClass()
? Neither of the above provides anything above the last one, except
for late creation.
ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
SIngleton from __defaults__ Asaf Las <roegltd@gmail.com> - 2014-01-22 08:07 -0800
Re: SIngleton from __defaults__ Chris Angelico <rosuav@gmail.com> - 2014-01-23 03:18 +1100
Re: SIngleton from __defaults__ Asaf Las <roegltd@gmail.com> - 2014-01-22 08:37 -0800
Re: SIngleton from __defaults__ 88888 Dihedral <dihedral88888@gmail.com> - 2014-01-22 09:23 -0800
Re: SIngleton from __defaults__ Ned Batchelder <ned@nedbatchelder.com> - 2014-01-22 14:18 -0500
Re: SIngleton from __defaults__ Asaf Las <roegltd@gmail.com> - 2014-01-22 11:52 -0800
Re: SIngleton from __defaults__ Johannes Schneider <johannes.schneider@galileo-press.de> - 2014-01-23 14:36 +0100
Re: SIngleton from __defaults__ Dave Angel <davea@davea.name> - 2014-01-23 11:56 -0500
Re: SIngleton from __defaults__ Terry Reedy <tjreedy@udel.edu> - 2014-01-23 19:10 -0500
Re: SIngleton from __defaults__ Johannes Schneider <johannes.schneider@galileo-press.de> - 2014-01-24 09:20 +0100
Re: SIngleton from __defaults__ Asaf Las <roegltd@gmail.com> - 2014-01-22 13:10 -0800
Re: SIngleton from __defaults__ Asaf Las <roegltd@gmail.com> - 2014-01-22 14:34 -0800
csiph-web