On 2006-08-02, Diez B. Roggisch <[EMAIL PROTECTED]> wrote:
>> I find that a strange purpose because when you are working on a class,
>> you don't necessarily know if you will ever know many instance of that
>> class. So should I use __slots__ in all my classes, just to be sure
>> for when someone w
In <[EMAIL PROTECTED]>, Antoon Pardon wrote:
> On 2006-07-28, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
>> This avoids the problem but you get others in return. And it's an
>> abuse of `__slots__` which is meant as a way to save memory if you need
>> really many objects of that type an
> I find that a strange purpose because when you are working on a class,
> you don't necessarily know if you will ever know many instance of that
> class. So should I use __slots__ in all my classes, just to be sure
> for when someone wants many instances of one?
I find that a strange reasoning b
On 2006-07-28, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
>>
>> class MyClass(object):
>>
>> __slots__ = ('bar',)
>>
>> def func(self):
>> return 123
>>
>> x = MyClass()
>> x.instance_var_not_defined_in_the_class = 456
>> ==>
>> AttributeError: 'MyClass' object has no a
Ben Sizer wrote:
> Ray wrote:
> But remember, at no point did they think to make that stuff
> deliberately hard so that it would give you safety. It's hard because
> the implementation is relatively complex. The flipside of that is
> writing function objects in C++, which are an ugly hack to get a
Ray wrote:
> Yeah, I know... but the thing is that it's easy to "do it". Say in C++,
> you can rebind the method of a class to another function if you want
> to, you can muck around with the vtable and stuff, but you've gotta do
> something different than, say, a normal assignment.
But remember, a
Bruno Desthuilliers wrote:
> Ray wrote:
> > Bruno Desthuilliers wrote:
> > Actually Bruno, don't you think that the notion of flexibility in
> > Python comes at the expense of "security" is simply due to the fact
> > that the syntax of "screw up" is exactly the same as the syntax of "I
> > mean it
In <[EMAIL PROTECTED]>, Timo wrote:
> Steve Jobless kirjoitti:
>
>> Let's say the class is defined as:
>>
>> class MyClass:
>> def __init__(self):
>> pass
>> def func(self):
>> return 123
>>
>> But from the outside of the class my interpreter let me do:
>>
>> x = MyClass()
Ray wrote:
> Bruno Desthuilliers wrote:
>>> I'd rather let a machine to do that. Wasn't computer created for tasks
>>> like this? (No, not really. But...)
>> There's obviously a trade-off between 'security' and flexibility. As I
>> said, I do make lots of typo too, but OTOH the edit/test cycle in P
Steve Jobless wrote:
> Bruno Desthuilliers wrote:
>> Steve Jobless wrote:
>>> Sybren Stuvel wrote:
>>>
Steve Jobless enlightened us with:
> The first case can be just a typo, like:
>
> x.valeu = 5
>
> I make typos all the time. Without a spell checker, this message
>>
Steve Jobless wrote:
> Unfortunately, I don't see a way
> to separate interface from implementation in Python. So, it may not make
> much difference whether you subclass it or hack it from the outside.
Documentation. (And name-mangling, underscore prepending, all the stuff
the others said.) Whenev
Steve Jobless kirjoitti:
> Let's say the class is defined as:
>
> class MyClass:
> def __init__(self):
> pass
> def func(self):
> return 123
>
> But from the outside of the class my interpreter let me do:
>
> x = MyClass()
> x.instance_var_not_defined_in_the_class = 456
>
Ben Sizer wrote:
> Ray wrote:
> > Actually Bruno, don't you think that the notion of flexibility in
> > Python comes at the expense of "security" is simply due to the fact
> > that the syntax of "screw up" is exactly the same as the syntax of "I
> > mean it this way and I do want it"?
> >
> > Per
Ray wrote:
> Actually Bruno, don't you think that the notion of flexibility in
> Python comes at the expense of "security" is simply due to the fact
> that the syntax of "screw up" is exactly the same as the syntax of "I
> mean it this way and I do want it"?
>
> Perhaps if we use a different synta
In <[EMAIL PROTECTED]>, Steve Jobless wrote:
> Bruno Desthuilliers wrote:
>>
>> Steve Jobless wrote:
>> > But what about adding a method to the class? Am I supposed to ask "Is
>> > anyone using name xxx?"
>>
>> assert 'xxx' not in dir(SomeClassOrObject)
>>
>> > The class may be used by develop
Bruno Desthuilliers wrote:
> > I'd rather let a machine to do that. Wasn't computer created for tasks
> > like this? (No, not really. But...)
>
> There's obviously a trade-off between 'security' and flexibility. As I
> said, I do make lots of typo too, but OTOH the edit/test cycle in Python
> is u
Bruno Desthuilliers wrote:
>
> Steve Jobless wrote:
> > Sybren Stuvel wrote:
> >
> >>Steve Jobless enlightened us with:
> >>
> >>>The first case can be just a typo, like:
> >>>
> >>> x.valeu = 5
> >>>
> >>>I make typos all the time. Without a spell checker, this message
> >>>would be unreadable :
Steve Jobless wrote:
> Sybren Stuvel wrote:
> >
> > Steve Jobless enlightened us with:
> > > The first case can be just a typo, like:
> > >
> > > x.valeu = 5
> > >
> > > I make typos all the time. Without a spell checker, this message
> > > would be unreadable :).
> >
> > Then learn to read what
Bruno Desthuilliers wrote:
> Ray wrote:
> > Bruno Desthuilliers wrote:
> >
> >>Ray wrote:
> >>Ray, please, don't top-post
> >
> >
> > Um, top-post? I'm using Google News and it looks like it is placed
> > correctly in the thread... or you're referring to a different thing?
>
> http://en.wikipedia.
Ray wrote:
> Bruno Desthuilliers wrote:
>
>>Ray wrote:
>>Ray, please, don't top-post
>
>
> Um, top-post? I'm using Google News and it looks like it is placed
> correctly in the thread... or you're referring to a different thing?
http://en.wikipedia.org/wiki/Top-posting
--
bruno desthuilliers
Bruno Desthuilliers wrote:
> Ray wrote:
> Ray, please, don't top-post
Um, top-post? I'm using Google News and it looks like it is placed
correctly in the thread... or you're referring to a different thing?
Ray
--
http://mail.python.org/mailman/listinfo/python-list
John Machin wrote:
> Ray wrote:
>
> > The argument against this is that since development with Python is so
> > rapid, you're supposed to always equip your code with extensive unit
> > tests. I like Python but I've never really bought that argument--I
> > guess I've been doing Java too long :)
> >
Sybren Stuvel wrote:
> Ray enlightened us with:
> > Huh? No. The compiler will always tell you. Have you ever tried Java
> > before?
>
> I know what I'm talking about, I've got a degree in Computer Science
> from the University of Amsterdam.
Then how come you didn't know that the Java compiler wi
Steve Jobless wrote:
> Sybren Stuvel wrote:
>
>>Steve Jobless enlightened us with:
>>
>>>The first case can be just a typo, like:
>>>
>>> x.valeu = 5
>>>
>>>I make typos all the time. Without a spell checker, this message
>>>would be unreadable :).
>>
>>Then learn to read what you type, as you ty
Ray wrote:
> The argument against this is that since development with Python is so
> rapid, you're supposed to always equip your code with extensive unit
> tests. I like Python but I've never really bought that argument--I
> guess I've been doing Java too long :)
>
In Java, if you don't always e
Ray wrote:
Ray, please, don't top-post
(snip)
> Also having to check whether a name has already existed can be a major
> pain in the butt with Python.
assert 'somename' not in dir(someObject)
(snip)
> Regarding the lack of privacy,
s/privacy/language-inforced access restriction/
> --I guess
Sybren Stuvel wrote:
> Ray enlightened us with:
> > Also having to check whether a name has already existed can be a
> > major pain in the butt with Python. With Java you always know when a
> > name has already existed, and what type is bound to the name. I
> > consider this to be a Good Thing (tm
Hey Steve,
Yes, I agree with you. The lack of checking can get confusing fast.
It's not about typing without errors. Regardless of how you train as
long as you're human you WILL make typos.
Also having to check whether a name has already existed can be a major
pain in the butt with Python. With J
Sybren Stuvel wrote:
>
> Steve Jobless enlightened us with:
> > The first case can be just a typo, like:
> >
> > x.valeu = 5
> >
> > I make typos all the time. Without a spell checker, this message
> > would be unreadable :).
>
> Then learn to read what you type, as you type it. Typing without
Steve Jobless:
> I'm hearing that "they are features, but don't use them."
You can use them if you know why you are doing it.
You can also take a look at PyChecker and PyLint, they may help you.
Bye,
bearophile
--
http://mail.python.org/mailman/listinfo/python-list
On 7/26/06, Steve Jobless <[EMAIL PROTECTED]> wrote:
> If I was working on a large project with many engineers, I'd assume
> someone will do things like this sooner or later. I've seen many
> horrendous code in my life and I have no control over who I work with.
If you work with cowboys, not P
Steve Jobless wrote:
>
> Hi,
>
> I just started learning Python. I went through most of the tutorial at
> python.org. But I noticed something weird. I'm not talking about the
> __private hack.
>
> Let's say the class is defined as:
>
> class MyClass:
> def __init__(self):
> pass
>
Steve Jobless wrote:
> Hi,
>
> I just started learning Python. I went through most of the tutorial at
> python.org. But I noticed something weird. I'm not talking about the
> __private hack.
Actually this is __ultra_private. For normal privacy, _private is enough !-)
> Let's say the class is def
Steve Jobless wrote:
> Hi,
>
> I just started learning Python. I went through most of the tutorial at
> python.org. But I noticed something weird. I'm not talking about the
> __private hack.
>
> Let's say the class is defined as:
>
> class MyClass:
> def __init__(self):
> pass
> def
See:
http://redhanded.hobix.com/inspect/monkeypytching.html
Shouldn't be done unless you have a really cool reason for doing so.
--
http://mail.python.org/mailman/listinfo/python-list
On Tue, 25 Jul 2006 02:49:06 GMT, Steve Jobless <[EMAIL PROTECTED]> wrote:
>Hi,
>
>I just started learning Python. I went through most of the tutorial at
>python.org. But I noticed something weird. I'm not talking about the
>__private hack.
>
>Let's say the class is defined as:
>
> class MyClass:
Hi,
I just started learning Python. I went through most of the tutorial at
python.org. But I noticed something weird. I'm not talking about the
__private hack.
Let's say the class is defined as:
class MyClass:
def __init__(self):
pass
def func(self):
return 123
But from th
37 matches
Mail list logo