David wrote:
> 3. What is a simple example of a Pythonic use of __slots__ that does NOT
> involved the creation of **many** instances.
mu. Your question presupposes the existence of such an example.
-Mike
--
http://mail.python.org/mailman/listinfo/python-list
Op 2006-03-27, Georg Brandl schreef <[EMAIL PROTECTED]>:
> Antoon Pardon wrote:
>> Op 2006-03-25, John J. Lee schreef <[EMAIL PROTECTED]>:
>>> [EMAIL PROTECTED] (Alex Martelli) writes:
>>> [...]
you should be using pychecker or pylint
>>> [...]
>>>
>>> I'm curious, as somebody who doesn't regu
Antoon Pardon wrote:
> Op 2006-03-25, John J. Lee schreef <[EMAIL PROTECTED]>:
>> [EMAIL PROTECTED] (Alex Martelli) writes:
>> [...]
>>> you should be using pychecker or pylint
>> [...]
>>
>> I'm curious, as somebody who doesn't regularly use these tools: How do
>> they fit into your workflow? Do
Op 2006-03-25, John J. Lee schreef <[EMAIL PROTECTED]>:
> [EMAIL PROTECTED] (Alex Martelli) writes:
> [...]
>> you should be using pychecker or pylint
> [...]
>
> I'm curious, as somebody who doesn't regularly use these tools: How do
> they fit into your workflow? Do you run them every few hours,
John J. Lee wrote:
> [EMAIL PROTECTED] (Alex Martelli) writes:
>>you should be using pychecker or pylint
>
> I'm curious, as somebody who doesn't regularly use these tools: How do
> they fit into your workflow? Do you run them every few hours, every
> day, every time you run functional tests, eve
John J. Lee <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] (Alex Martelli) writes:
> [...]
> > you should be using pychecker or pylint
> [...]
>
> I'm curious, as somebody who doesn't regularly use these tools: How do
> they fit into your workflow? Do you run them every few hours, every
> day, e
[EMAIL PROTECTED] (Alex Martelli) writes:
[...]
> you should be using pychecker or pylint
[...]
I'm curious, as somebody who doesn't regularly use these tools: How do
they fit into your workflow? Do you run them every few hours, every
day, every time you run functional tests, every release, every
Ron Garret wrote:
> [EMAIL PROTECTED] (Alex Martelli) wrote:
>
>> > One other question I did not get answered: is there any
>> > simple example of a Pythonic use of __slots__ that does NOT
>> > involve the creation of **many** instances.
>>
>> Since the only benefit of __slots__ is saving a fe
Ron Garret <[EMAIL PROTECTED]> wrote:
> In article <[EMAIL PROTECTED]>,
> [EMAIL PROTECTED] (Alex Martelli) wrote:
>
> > > One other question I did not get answered: is there any
> > > simple example of a Pythonic use of __slots__ that does NOT
> > > involve the creation of **many** instances.
In article <[EMAIL PROTECTED]>,
[EMAIL PROTECTED] (Alex Martelli) wrote:
> > One other question I did not get answered: is there any
> > simple example of a Pythonic use of __slots__ that does NOT
> > involve the creation of **many** instances.
>
> Since the only benefit of __slots__ is saving
David Isaac <[EMAIL PROTECTED]> wrote:
...
> Does this beg the question of whether __slots__
> *should* break with inheritance?
How would you expect the following code to behave:
class Base(object):
def __init__(self): self.x = 23
class Derived(Base):
__slots__ = 'y',
? I would expe
"Aahz" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Because __slots__ breaks with inheritance.
I believe that was the point of Ziga's example,
which I acknowledged as a good one in my reply.
So there still appears to be this single reason, which
applies if your class may be subcla
In article <[EMAIL PROTECTED]>,
David Isaac <[EMAIL PROTECTED]> wrote:
>"Ziga Seilnacht" <[EMAIL PROTECTED]> wrote:
>>
>> If you want to restrict attribute asignment, you should use the
>> __setattr__ special method, see:
>> http://docs.python.org/ref/attribute-access.html
>
>That "should" is what
"Ziga Seilnacht" <[EMAIL PROTECTED]> wrote:
> If you want to restrict attribute asignment, you should use the
> __setattr__ special method, see:
> http://docs.python.org/ref/attribute-access.html
That "should" is what I am asking about. If I understand,
in the simplest case, you want me to say so
David Isaac wrote:
> 1. "Without a __dict__ variable,
> instances cannot be assigned new variables not listed in the __slots__
> definition."
>
> So this seemed an interesting restriction to impose in some instances,
> but I've noticed that this behavior is being called by some a side effect
> the
In article <[EMAIL PROTECTED]>,
=?ISO-8859-1?Q?Sch=FCle_Daniel?= <[EMAIL PROTECTED]> wrote:
>
>does __slots__ nothing when used in derived classes?
Short answer: don't use __slots__ until you're comfortable writing
metaclasses and decorators. __slots__ are a performance hack strictly
for advance
Schüle Daniel wrote:
> consider this code
>
> >>> class A(object):
> ... def __init__(self):
> ... self.a = 1
> ... self.b = 2
> ...
> >>> class B(A):
> ... __slots__ = ["x","y"]
> ...
> >>> b=B()
> >>> b.a
> 1
> >>> b.b
> 2
> >>> b.x = 100
> >>> b.y = 100
> >>> b.
Schüle Daniel wrote:
> Hello,
>
> consider this code
>
> >>> class A(object):
> ... def __init__(self):
> ... self.a = 1
> ... self.b = 2
> ...
> >>> class B(A):
> ... __slots__ = ["x","y"]
> ...
> >>> b=B()
> >>> b.a
> 1
> >>> b.b
> 2
> >>> b.x = 100
> >>> b
To be complete, the first code snippet, when modified as follows, works
fine in Python 2.4.2:
--- START ---
#!/usr/bin/env python
import copy
class Foo (object):
__slots__ = ('i', )
def __init__ (self):
self.i = 10
class Bar (Foo):
__slots__ = ('j', )
def __init__ (self):
supe
26 Dec 2005 20:33:35 -0800, fortepianissimo <[EMAIL PROTECTED]>:
> Mystery solved - when there's only one slot I should've used __slots__
> = ('i', ). Duh!
>
> So in short, __slots__ and copy.copy() work fine in Python 2.4.2.
>
Hard works, but very useful :)
--
I like python!
My Blog: http://www.
Mystery solved - when there's only one slot I should've used __slots__
= ('i', ). Duh!
So in short, __slots__ and copy.copy() work fine in Python 2.4.2.
--
http://mail.python.org/mailman/listinfo/python-list
More weird observations: the following code does not work until you
change the name of the member 'longer' to a one-char name, for example,
'j':
--- START ---
#!/usr/bin/env python
import copy
class Foo (object):
__slots__ = 'i'
class Bar (Foo):
__slots__ = 'longer'
#__slots__ = 'j'
I should've mentioned this was tested on Python 2.4.2.
fortepianissimo wrote:
> I remember from painful experience that copy.copy() won't really copy
> __slots__ members. But I have trouble explaning why the following code
> works:
>
> --- START---
> #!/usr/bin/env python
>
> import copy
>
>
> cl
Steven Bethard wrote:
> But why do you want a class level attribute with the same name as an
> instance level attribute? I would have written your class as:
>
> class A(object):
> __slots__ = ['value']
> def __init__(self, value=1):
> self.value = value
>
> where the default va
Ewald R. de Wit wrote:
> I'm running into a something unexpected for a new-style class
> that has both a class attribute and __slots__ defined. If the
> name of the class attribute also exists in __slots__, Python
> throws an AttributeError. Is this by design (if so, why)?
>
> class A( object ):
25 matches
Mail list logo