On Wednesday 09 April 2014 05:47:37 Ian Kelly did opine:
> On Tue, Apr 8, 2014 at 9:31 PM, Gene Heskett wrote:
> >> 'Pneumonoultramicroscopicsilicovolcanoconiosis' has them all beat.
> >
> > Source citation please?
>
> http://en.wikipedia.org/wiki/Pneumonoultramicroscopicsilicovolcanoconios
> i
On Tue, Apr 8, 2014 at 9:31 PM, Gene Heskett wrote:
>> 'Pneumonoultramicroscopicsilicovolcanoconiosis' has them all beat.
>
> Source citation please?
http://en.wikipedia.org/wiki/Pneumonoultramicroscopicsilicovolcanoconiosis
http://www.oxforddictionaries.com/definition/english/pneumonoultramicros
On Tuesday 08 April 2014 23:31:35 Ian Kelly did opine:
> On Tue, Apr 8, 2014 at 8:45 PM, alex23 wrote:
> > On 9/04/2014 12:33 PM, Chris Angelico wrote:
> >>> Unfortunately I seem to be missing antidisestablishmentarianism,
> >>> because the longest words in my dict are only 24 characters,
> >>> e
On Tue, Apr 8, 2014 at 8:45 PM, alex23 wrote:
> On 9/04/2014 12:33 PM, Chris Angelico wrote:
>>>
>>> Unfortunately I seem to be missing antidisestablishmentarianism,
>>> because the longest words in my dict are only 24 characters,
>>> excluding the '\n'. Should I ask for my money back?
>>
>>
>> I
On 9/04/2014 12:33 PM, Chris Angelico wrote:
Unfortunately I seem to be missing antidisestablishmentarianism,
because the longest words in my dict are only 24 characters,
excluding the '\n'. Should I ask for my money back?
I think you should. That's a fundamental flaw in the dictionary.
Everyon
On 8/04/2014 6:31 PM, Frank Millman wrote:
Here is an idea, inspired by Peter Otten's suggestion earlier in this
thread.
Instead of defaultdict, subclass dict and use __missing__() to supply the
default values.
When the dictionary is set up, delete __missing__ from the subclass!
Ugly, but it see
On Wed, Apr 9, 2014 at 10:43 AM, Gregory Ewing
wrote:
> Chris Angelico wrote:
>>
>> in the dictionary I
>> have here (Debian Wheezy, using an American English dictionary - it's
>> a symlink to (ultimately) /usr/share/dict/american-english), there are
>> five entries in that list.
>
>
> Mine's bigg
Chris Angelico wrote:
in the dictionary I
have here (Debian Wheezy, using an American English dictionary - it's
a symlink to (ultimately) /usr/share/dict/american-english), there are
five entries in that list.
Mine's bigger than yours! On MacOSX 10.6 I get 41 words.
(I think someone must have f
"Chris Angelico" wrote in message
news:captjjmppaqmb6no7udddadqg_jv9yz0sn4d70kasksbwwr3...@mail.gmail.com...
> On Tue, Apr 8, 2014 at 7:28 PM, Frank Millman wrote:
>> Are you saying that
>>
>> all([len(word) == 23 for word in words_by_length[23]]) # hope I got
>> that right
>>
>> will not
On Tue, Apr 8, 2014 at 7:28 PM, Frank Millman wrote:
> Are you saying that
>
> all([len(word) == 23 for word in words_by_length[23]]) # hope I got
> that right
>
> will not return True?
That'll return true. What it won't show, though, is the length of the
word as you would understand it in t
"Chris Angelico" wrote in message
news:CAPTjJmoRxEhX02ZviHiLO+qi+dD+81smbGGYcPECpHb5E=p4=a...@mail.gmail.com...
> On Tue, Apr 8, 2014 at 6:26 PM, Frank Millman wrote:
>>> words_by_length = {}
>>> for word in open("/usr/share/dict/words"):
>>>words_by_length.setdefault(len(word), []).append(
On Tue, Apr 8, 2014 at 6:26 PM, Frank Millman wrote:
>> words_by_length = {}
>> for word in open("/usr/share/dict/words"):
>>words_by_length.setdefault(len(word), []).append(word)
>>
>> This will, very conveniently, give you a list of all words of a
>> particular length. (It's actually a littl
"Ian Kelly" wrote in message
news:CALwzidmP5Bevbace9GyQrVXe-_2T=jtpq1yvapsaepvomqe...@mail.gmail.com...
> On Tue, Apr 8, 2014 at 1:14 AM, Frank Millman wrote:
>>
>> It appears that when you use 'setdefault', the default is always
>> evaluated,
>> even if the key exists.
>>
>> It seems odd. Is
"Chris Angelico" wrote in message
news:captjjmpk-rqx0fp6_4vxyus2z34vc5fq_qntj+q9+kn8y5u...@mail.gmail.com...
> On Tue, Apr 8, 2014 at 5:14 PM, Frank Millman wrote:
>> It appears that when you use 'setdefault', the default is always
>> evaluated,
>> even if the key exists.
>>
>> It seems odd. I
Ian Kelly wrote:
> One thing I will note as a disadvantage of defaultdict is that
> sometimes you only want the default value behavior while you're
> initially building the dict, and then you just want a normal dict with
> KeyErrors from then on. defaultdict doesn't do that; once
> constructed, i
On Tue, Apr 8, 2014 at 5:14 PM, Frank Millman wrote:
> It appears that when you use 'setdefault', the default is always evaluated,
> even if the key exists.
>
def get_value(val):
> ... print('getting value', val)
> ... return val*2
> ...
my_dict = {}
my_dict.setdefault('a', get_
On Tue, Apr 8, 2014 at 1:14 AM, Frank Millman wrote:
>
> "Chris Angelico" wrote in message
> news:captjjmqfbt2xx+bdfnhz0gagordkhtpbzrr29duwn36girz...@mail.gmail.com...
>> On Tue, Apr 8, 2014 at 2:02 PM, Josh English
>> wrote:
>>>
>>> Would dict.setdefault() solve this problem? Is there any advan
On Tue, 08 Apr 2014 09:14:39 +0200, Frank Millman wrote:
> It appears that when you use 'setdefault', the default is always
> evaluated, even if the key exists.
>
def get_value(val):
> ... print('getting value', val)
> ... return val*2
> ...
my_dict = {}
my_dict.setdefault('a',
"Chris Angelico" wrote in message
news:captjjmqfbt2xx+bdfnhz0gagordkhtpbzrr29duwn36girz...@mail.gmail.com...
> On Tue, Apr 8, 2014 at 2:02 PM, Josh English
> wrote:
>>
>> Would dict.setdefault() solve this problem? Is there any advantage to
>> defaultdict over setdefault()
>
> That depends on
On Monday, April 7, 2014 9:08:23 PM UTC-7, Chris Angelico wrote:
> That depends on whether calling Brand() unnecessarily is a problem.
> Using setdefault() is handy when you're working with a simple list or
> something, but if calling Brand() is costly, or (worse) if it has side
> effects that you
On Tue, Apr 8, 2014 at 2:02 PM, Josh English wrote:
> On Sunday, April 6, 2014 12:44:13 AM UTC-7, Giuliano Bertoletti wrote:
>
>
>> obj = brands_seen.get(brandname)
>>
>> if obj is None:
>> obj = Brand()
>> brands_seen[brandname] = obj
>>
>>
>
> Would dict.setdefault() solve this problem?
On Sunday, April 6, 2014 12:44:13 AM UTC-7, Giuliano Bertoletti wrote:
> obj = brands_seen.get(brandname)
>
> if obj is None:
> obj = Brand()
> brands_seen[brandname] = obj
>
>
Would dict.setdefault() solve this problem? Is there any advantage to
defaultdict over setdefault()
Josh
Giuliano Bertoletti wrote:
> I frequently use this pattern to keep track of incoming data (for
> example, to sum up sales of a specific brand):
>
> =
>
> # read a brand record from a db
> ...
>
> # keep track of brands seen
> obj = brands_seen.get(brandname)
I frequently use this pattern to keep track of incoming data (for
example, to sum up sales of a specific brand):
=
# read a brand record from a db
...
# keep track of brands seen
obj = brands_seen.get(brandname)
if obj is None:
obj = Brand()
brands_s
24 matches
Mail list logo