Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #29923
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Subject | Re: Java singletonMap in Python |
| Date | 2012-09-24 20:44 +0100 |
| References | <k3o53u$8qf$1@ger.gmane.org> <CABicbJ+GgO2atgUv4aoNLkXDe94oBhO=TLPpM3mreBYYC7hg_w@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1205.1348515819.27098.python-list@python.org> (permalink) |
On 24/09/2012 20:22, Devin Jeanpierre wrote:
> On Sun, Sep 23, 2012 at 7:14 PM, Mark Lawrence <breamoreboy@yahoo.co.uk> wrote:
>> Purely for fun I've been porting some code to Python and came across the
>> singletonMap[1]. I'm aware that there are loads of recipes on the web for
>> both singletons e.g.[2] and immutable dictionaries e.g.[3]. I was wondering
>> how to combine any of the recipes to produce the best implementation
>
> The word "singleton" usually means "thing with only one item". For
> example, {a} is a singleton set containing only a, and with matrices,
> any dimension of size one is called a singleton dimension, and so on.
> In this case, a singleton map is a map with only one key-value pair,
> such as {a:b}.
>
> The singleton design antipattern is not relevant here.
>
> -- Devin
>
Java thinks so otherwise there wouldn't also be the singleton which is
the spelling for singletonSet (don't ask me!!!) and a singletonList.
From the Python viewpoint I think YAGNI is perfect. I now understand
why the BDFL and others fight so hard to keep bloatware out of the
standard library.
--
Cheers.
Mark Lawrence.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Java singletonMap in Python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-09-24 20:44 +0100
csiph-web