Right, __slots__ is definitely not a good idea to use except in very
specific situations. I would strongly recommend against its usage here.
http://groups.google.com/group/comp.lang.python/msg/0f2e859b9c002b28
On Thu, Jan 5, 2012 at 3:50 PM, Eric Firing <efir...@hawaii.edu> wrote:
> On 01/05/2012 07:34 AM, Ryan May wrote:
> > On Thu, Jan 5, 2012 at 10:58 AM, Benjamin Root<ben.r...@ou.edu> wrote:
> >>
> >>
> >> On Thu, Jan 5, 2012 at 10:40 AM, Benjamin Root<ben.r...@ou.edu> wrote:
> >>>
> >>>
> >>>> At the very least, it would help in compartmentallizing all the
> possible
> >>>> drawing attributes that are common across all artists. Currently, I
> am
> >>>> envisioning using a defaultdict object (which was introduced in
> python 2.5)
> >>>> or subclassing from it. This might help in keeping compatibility with
> >>>> existing code. Subclassing would allow for modifying __get__ and
> __set__ to
> >>>> treat some elements like 'c' and 'color', 'lw' and 'linewidth' and so
> on as
> >>>> the same.
> >>
> >>
> >> Grrrr, in defaultdict(), the default_factory is called without
> arguments, so
> >> a factory can't be made to produce a default value for a given key,
> unless I
> >> resort to more hackary...
> >
> > Might be better to explicitly use properties for this rather than
> > overriding dict:
> >
> > class Style(object):
> > __slots__ = ('_lw')
> >
> > def __init__(self, lw=None):
> > self.lw = lw
> >
> > def _set_linewidth(self, lw):
> > self._lw = lw
> >
> > def _get_linewidth(self):
> > return self._lw
> >
> > lw = property(_get_linewidth, _set_linewidth)
> > linewidth = property(_get_linewidth, _set_linewidth)
> >
> > Declaring slots allows you to keep the available attributes to those
> > explicity listed. This way, you can't set a random (misspelled?)
> > attribute and wonder for hours why style.edgcolor = 'blue' doesn't
> > work.
>
> This seems useful, and may be OK for this application; but a little
> googling indicates that it is not really what __slots__ was intended
> for, it is at best controversial, and it should be used very sparingly
> and carefully.
>
> Eric
>
> >
> > Ryan
> >
>
>
>
> ------------------------------------------------------------------------------
> Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
> infrastructure or vast IT resources to deliver seamless, secure access to
> virtual desktops. With this all-in-one solution, easily deploy virtual
> desktops for less than the cost of PCs and save 60% on VDI infrastructure
> costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
--
Daniel Hyams
dhy...@gmail.com
------------------------------------------------------------------------------
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual
desktops for less than the cost of PCs and save 60% on VDI infrastructure
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users