在 2013年1月10日星期四UTC+8下午7时34分23秒,Duncan Booth写道:
> Dave Cinege wrote:
>
>
>
> > You will notice that the code is disgusting simple. However I have
>
> > found that this has completely changed the way I program in python.
>
> > I've re-written some exiting programs using Thesaurus, and often
>
Dave Cinege wrote:
> You will notice that the code is disgusting simple. However I have
> found that this has completely changed the way I program in python.
> I've re-written some exiting programs using Thesaurus, and often
> relized 15-30% code reduction. Additionally I find the new code much
>
On Tue, Jan 8, 2013 at 12:16 PM, Neal Becker wrote:
> Did you intend to give anyone permission to use the code? I see only a
> copyright notice, but no permissions.
It also says "Licence: python, Copyright notice may not be altered."
Which suggests to me that the intent is that it be licensed u
Did you intend to give anyone permission to use the code? I see only a
copyright notice, but no permissions.
--
http://mail.python.org/mailman/listinfo/python-list
Thesaurus: A different way to call a dictionary.
Thesaurus is a new a dictionary subclass which allows calling keys as
if they are class attributes and will search through nested objects
recursively when __getitem__ is called.
You will notice that the code is disgusting simple. However I have fou
On Monday 10 December 2012 23:08:24 Jason Friedman wrote:
> 2) Posting your code at ActiveState.com.
If someone wants to please do. I'm back to being completely overloaded with
normal work now. The v20121212 release based on the last few days comments is
as far as I will go with this now.
Dave
Version 20121212
#!/usr/bin/env python
"""
thesaurus.py 2012-12-12
Copyright (c) 2012 Dave Cinege
Licence: PSF Licence, Copyright notice may not be altered.
Thesaurus: A different way to call a dictionary.
Thesaurus is a new a dictionary subclass which allows calling keys as
if they are class a
On 12/12/2012 7:30 PM, Steven D'Aprano wrote:
On Wed, 12 Dec 2012 17:20:53 -0500, Dave Cinege wrote:
Isn't super() depreciated?
Heavens no. super() is the recommended way to do inheritance, and the
*only* way to correctly do multiple inheritance[1].
Indeed. Rather than super() being depreca
On Wednesday 12 December 2012 20:14:08 Chris Angelico wrote:
Ok enough already, I'll use the frigging thing!
Be happy I'm at least still not coding for python 1.5.
> To add to this: Using enumerate gives the possibility (don't know if
> any current interpreter takes advantage or not, but a futur
On Thu, Dec 13, 2012 at 11:30 AM, Steven D'Aprano
wrote:
> On Wed, 12 Dec 2012 17:20:53 -0500, Dave Cinege wrote:
>> To me for i in range(len(l)) seems like simpler, faster, tighter code
>> for this now.
>
> * the version with enumerate makes the intent more clear: since we
> care about looping
On Wed, 12 Dec 2012 17:20:53 -0500, Dave Cinege wrote:
> Isn't super() depreciated?
Heavens no. super() is the recommended way to do inheritance, and the
*only* way to correctly do multiple inheritance[1]. What makes you think
that it has been deprecated?
[...]
> To me for i in range(len(l))
On Wed, 12 Dec 2012 23:56:24 +, Mark Lawrence wrote:
> Please don't place responses like this. The Python community prides
> itself on tolerance. If you don't wish to follow that recommendation
> please go to an alternative site.
Well, I must say, I think that you've just won an award for M
On 12/12/2012 18:13, Dave Cinege wrote:
On Wednesday 12 December 2012 05:25:11 D'Arcy J.M. Cain wrote:
As a 16yr OSS vet I know that for every 1 person that that actually creates
something there will always be 2000 people to bitch about it. My skin isn't
thin, I just don't give a shit to listen
On Wed, Dec 12, 2012 at 3:20 PM, Dave Cinege wrote:
> On Wednesday 12 December 2012 15:42:36 Ian Kelly wrote:
>
>> def __getattribute__(self, name):
>> if name.startswith('__') and name.endswith('__'):
>> return super(Thesaurus, self).__getattribute__(name)
>> return self.__getitem
On Wednesday 12 December 2012 15:42:36 Ian Kelly wrote:
> def __getattribute__(self, name):
> if name.startswith('__') and name.endswith('__'):
> return super(Thesaurus, self).__getattribute__(name)
> return self.__getitem__(name)
Ian,
Tested, and works as you advertised.
Isn't
On Wed, Dec 12, 2012 at 12:20 PM, Dave Cinege wrote:
> On Tuesday 11 December 2012 01:41:38 Ian Kelly wrote:
>
>> I have a few critiques on the code. First, you might want to use
>> __getattribute__ instead of __getattr__. Otherwise you'll end up
>
> File "/home/dcinege/src/thesaurus/thesaurus
On Tuesday 11 December 2012 01:41:38 Ian Kelly wrote:
> I have a few critiques on the code. First, you might want to use
> __getattribute__ instead of __getattr__. Otherwise you'll end up
File "/home/dcinege/src/thesaurus/thesaurus.py", line 84, in
__getattribute__
return self.__getitem_
On Wednesday 12 December 2012 05:25:11 D'Arcy J.M. Cain wrote:
As a 16yr OSS vet I know that for every 1 person that that actually creates
something there will always be 2000 people to bitch about it. My skin isn't
thin, I just don't give a shit to listen to anyone one that doesn't get it.
The
On Wed, 12 Dec 2012 17:44:24 +1100
Chris Angelico wrote:
> On Wed, Dec 12, 2012 at 5:34 PM, Steven D'Aprano
> wrote:
> > and you consider this "not productive, not worth my time". Code
> > review with you must be *all* sorts of fun.
>
> He never asked for code review :)
I think by posting it he
On Wed, Dec 12, 2012 at 5:34 PM, Steven D'Aprano
wrote:
> So, let's see now... I identified that your Thesaurus code:
>
> * will fail silently;
> * contains dead code that is never used;
> * contains redundant code that is pointless;
> * hides errors in the caller's code;
>
> and you consider this
On Tue, 11 Dec 2012 16:08:34 -0500, Dave Cinege wrote:
> On Tuesday 11 December 2012 03:12:19 Steven D'Aprano wrote:
>
>> Is this intended as a ready-for-production class?
>
> For me, yes. In production code.
>
>> py> d = Thesaurus()
>> py> d['spam'] = {}
>
> Maybe because spam is type dict in
On Tue, 11 Dec 2012 16:08:34 -0500, Dave Cinege wrote:
> On Tuesday 11 December 2012 03:12:19 Steven D'Aprano wrote:
>
>> Is this intended as a ready-for-production class?
>
> For me, yes. In production code.
>
>> py> d = Thesaurus()
>> py> d['spam'] = {}
>
> Maybe because spam is type dict in
On 12/11/2012 07:53 PM, Mitya Sirenef wrote:
By the way, the Thesaurus class reminds me of using the old recipe
called 'Bunch':
http://code.activestate.com/recipes/52308-the-simple-but-handy-collector-of-a-bunch-of-named/
like this:
b = Bunch(x=1) b.stuff = Bunch(y=2)
b.stuff.y 2
Sorry,
On 12/11/2012 05:39 PM, Dave Cinege wrote:
On Tuesday 11 December 2012 16:53:12 Ian Kelly wrote:
>
>> Just out of curiosity, how old are we talking? enumerate was added in
>> Python 2.3, which is nearly 10 years old. Prior to 2.2 I don't think
>> it was even possible to subclass dict, which wou
On Tuesday 11 December 2012 17:39:12 Dave Cinege wrote:
My memory is getting jogged more why did some things:
raise KeyError(key + ' [%s]' % i)
I did this to specificly give you the indice that failed recursion but provide
the entire key name as it was provided to __getitem__
So if:
g.
On 11Dec2012 15:57, Dave Cinege wrote:
| On Tuesday 11 December 2012 01:41:38 Ian Kelly wrote:
| > running into bugs like this:
| > >>> thes = Thesaurus()
| > >>> thes.update = 'now'
| > >>> thes.update
| >
| >
|
| I've noticed this but it's mostly pointless, as meaningful code does work.
| (Al
On Tuesday 11 December 2012 16:53:12 Ian Kelly wrote:
> Just out of curiosity, how old are we talking? enumerate was added in
> Python 2.3, which is nearly 10 years old. Prior to 2.2 I don't think
> it was even possible to subclass dict, which would make your Thesaurus
> implementation unusable,
On Tue, Dec 11, 2012 at 2:53 PM, Ian Kelly wrote:
> and then I ran the examples, and the output was unchanged. As Steven
> pointed out, I don't see how that first branch could succeed anyway,
> since self.data is never defined.
It occurs to me that the UserDict class does have a data attribute.
On Tue, Dec 11, 2012 at 1:57 PM, Dave Cinege wrote:
> On Tuesday 11 December 2012 01:41:38 Ian Kelly wrote:
>> Second, in __getitem__ you start a loop with "for i in
>> range(len(l)):", and then you use i as an index into l several times.
>> It would be cleaner and more Pythonic to do "for i, part
On Tuesday 11 December 2012 03:12:19 Steven D'Aprano wrote:
> Is this intended as a ready-for-production class?
For me, yes. In production code.
> py> d = Thesaurus()
> py> d['spam'] = {}
Maybe because spam is type dict instead of type thes???
>>> import thesaurus
>>> thes = thesaurus.Thesauru
On Tuesday 11 December 2012 01:41:38 Ian Kelly wrote:
> running into bugs like this:
> >>> thes = Thesaurus()
> >>> thes.update = 'now'
> >>> thes.update
>
>
I've noticed this but it's mostly pointless, as meaningful code does work.
(Also you stepped on the existing 'update()' dictionary method
- Original Message -
> Thesaurus: A different way to call a dictionary.
>
> Thesaurus is a new a dictionary subclass which allows calling keys as
> if they are class attributes and will search through nested objects
> recursively when __getitem__ is called.
>
> You will notice that the
On Mon, 10 Dec 2012 22:48:50 -0500, Dave Cinege wrote:
> Thesaurus: A different way to call a dictionary.
Is this intended as a ready-for-production class?
> Thesaurus is a new a dictionary subclass which allows calling keys as if
> they are class attributes and will search through nested objec
On Mon, Dec 10, 2012 at 8:48 PM, Dave Cinege wrote:
> Thesaurus: A different way to call a dictionary.
>
> Thesaurus is a new a dictionary subclass which allows calling keys as
> if they are class attributes and will search through nested objects
> recursively when __getitem__ is called.
>
> You w
> Thesaurus is a new a dictionary subclass which allows calling keys as
> if they are class attributes and will search through nested objects
> recursively when __getitem__ is called.
Good stuff. You might consider:
1) Licensing under an OSI-approved license
(http://opensource.org/licenses/index.
Thesaurus: A different way to call a dictionary.
Thesaurus is a new a dictionary subclass which allows calling keys as
if they are class attributes and will search through nested objects
recursively when __getitem__ is called.
You will notice that the code is disgusting simple. However I have fou
36 matches
Mail list logo