On 7/2/2010 1:54 AM, Gregory Ewing wrote:
WANG Cong wrote:
Yeah, my point is why setattr() for dynamic attributes while assignments
for static attributes?
If you mean using exactly the same syntax for both, that would
require making the static case more verbose, e.g. instead of
foo.blarg
yo
WANG Cong a écrit :
On 06/30/10 01:25, Ethan Furman wrote:
But if so why setattr() still exists? What is it for if we can do the
same thing via assignments? Also, in order to be perfect, Python should
accept to add dynamic attributes dynamically, something like PEP
363. That doesn't happen.
S
WANG Cong a écrit :
On 07/01/10 23:19, Stephen Hansen wrote:
As long as setattr() exists in Python, that will be not so ordinary. :)
setattr is perfectly ordinary.
If you think setattr() is as ordinary as a trivial assignment,
setattr IS a trivial assignment.
However, I think setattr(
WANG Cong wrote:
However, I think setattr() is a builtin function, using it exposes the
*magic* of metaprogramming (or class-programming, if more correct) at a
first glance.
But, in Python, creating instance variables is *not*
class-programming. It doesn't touch the class at all.
In many OO l
WANG Cong wrote:
When I talked about OOP, it is general OOP, not related with
> any concrete programming languages.
There isn't really any such thing, though. There is no
universally agreed set of features that a language must
have in order to be considered OOP.
Arguments of the form "Language
WANG Cong wrote:
Yeah, my point is why setattr() for dynamic attributes while assignments
for static attributes?
I think there may be a misunderstanding here. You seem to
be thinking of "dynamic attribute" vs. "static attribute"
as the distinction between creating a new attribute and
modifying
WANG Cong wrote:
If you think setattr() is as ordinary as a trivial assignment, I will
argue with you, this is personal taste.
To my way of thinking, getattr() and setattr() are the
fundamental way of accessing attributes in Python. The
dot notation is just syntactic sugar for the overwhelming
On Thu, Jul 1, 2010 at 6:10 PM, Steven D'Aprano
wrote:
> Engineers are quite
> happy to make the tools they need to make the tools they need to make the
> tools they need to make something. Carpenters would think you were crazy
> if you said that building a scaffold was "meta-carpentry" and there
On Thu, 01 Jul 2010 23:46:55 +0800, WANG Cong wrote:
> However, I think setattr() is a builtin function, using it exposes the
> *magic* of metaprogramming (or class-programming, if more correct) at a
> first glance.
There's nothing magic about metaprogramming.
If you're a programmer, you write p
On 2010-07-01 23:42, WANG Cong wrote:
> On 07/01/10 22:53, Stephen Hansen wrote:
>
> >
> > One uses assignment syntax when the name of the attribute they are
> > setting is known at the time when one writes the code.
> >
> > One uses the setattr function when the name of the attribute is not
> >
On 7/1/10 8:46 AM, WANG Cong wrote:
However, I think setattr() is a builtin function, using it exposes the
*magic* of metaprogramming (or class-programming, if more correct) at a
first glance.
I'm going to try this one more time -- you place a great deal of
importance and special properties on
On 07/01/10 23:19, Stephen Hansen wrote:
>>
>> As long as setattr() exists in Python, that will be not so ordinary. :)
>
> setattr is perfectly ordinary.
If you think setattr() is as ordinary as a trivial assignment, I will
argue with you, this is personal taste.
However, I think setattr() is a
On 07/01/10 22:53, Stephen Hansen wrote:
>
> One uses assignment syntax when the name of the attribute they are
> setting is known at the time when one writes the code.
>
> One uses the setattr function when the name of the attribute is not
> known until runtime.
>
> The difference has *nothing a
On 7/1/10 8:02 AM, WANG Cong wrote:
On 06/27/10 09:06, Steven D'Aprano wrote:
In that situation, certainly: adding an attribute on the fly to that
formal definition seems entirely strange and special of an activity. But
that's only because you *chose* to *see* and *use* the object that way.
Th
On 06/28/10 17:43, Bruno Desthuilliers
wrote:
> Carl Banks a écrit :
>> On Jun 27, 3:49 am, Bruno Desthuilliers
>> wrote:
>>> WANG Cong a écrit :
>>>
On 06/26/10 00:11, Neil Hodgson wrote:
> WANG Cong:
>> 4) Also, this will _somewhat_ violate the OOP princples, in OOP,
>> this
On 7/1/10 7:44 AM, WANG Cong wrote:
On 07/01/10 13:49, Stephen Hansen wrote:
It may not be "the" primary concern, but elegance certainly is *a*
primary concern.
I concur.
Its not explicitly stated, but it is the Zen 0. This is further
supported by its implied presence in many of the Axioms a
On 06/27/10 09:06, Steven D'Aprano wrote:
>> In that situation, certainly: adding an attribute on the fly to that
>> formal definition seems entirely strange and special of an activity. But
>> that's only because you *chose* to *see* and *use* the object that way.
>> The "special"ness of the acti
In article ,
WANG Cong wrote:
>On 07/01/10 13:49, Stephen Hansen wrote:
>>Wang Cong deleted the attribution for Aahz:
>>>
>>> It may not be "the" primary concern, but elegance certainly is *a*
>>> primary concern.
>>
>> I concur.
>>
>> Its not explicitly stated, but it is the Zen 0. This is furt
In article ,
Michael Torrie wrote:
>On 06/28/2010 02:31 PM, Aahz wrote:
>> In article ,
>> Michael Torrie wrote:
>>>
>>> True. But you can't really criticize a language's implementation of OOP
>>> without a good understanding of the "pure" OO language. For example, in
>>> Smalltalk If/Then st
On 7/1/10 7:31 AM, WANG Cong wrote:
On 06/30/10 01:20, Stephen Hansen wrote:
But if so why setattr() still exists? What is it for if we can do the
same thing via assignments? Also, in order to be perfect, Python should
accept to add dynamic attributes dynamically, something like PEP
363. That
On 07/01/10 13:49, Stephen Hansen wrote:
Hi, Stephen,
>>
>> It may not be "the" primary concern, but elegance certainly is *a*
>> primary concern.
>
> I concur.
>
> Its not explicitly stated, but it is the Zen 0. This is further
> supported by its implied presence in many of the Axioms and Truth
On 7/1/10 5:41 AM, Bruno Desthuilliers wrote:
Stephen Hansen a écrit :
On 6/30/10 10:37 PM, Aahz wrote:
It may not be "the" primary concern, but elegance certainly is *a*
primary concern.
I concur.
Its not explicitly stated, but it is the Zen 0. This is further
supported by its implied prese
On 06/30/10 01:20, Stephen Hansen wrote:
>> But if so why setattr() still exists? What is it for if we can do the
>> same thing via assignments? Also, in order to be perfect, Python should
>> accept to add dynamic attributes dynamically, something like PEP
>> 363. That doesn't happen.
>
> What do
On 06/30/10 01:25, Ethan Furman wrote:
>> But if so why setattr() still exists? What is it for if we can do the
>> same thing via assignments? Also, in order to be perfect, Python should
>> accept to add dynamic attributes dynamically, something like PEP
>> 363. That doesn't happen.
>
> Setattr a
Stephen Hansen a écrit :
On 6/30/10 10:37 PM, Aahz wrote:
In article<4c29ad38$0$26210$426a7...@news.free.fr>,
Bruno Desthuilliers wrote:
Aahz a écrit :
In article<4c285e7c$0$17371$426a7...@news.free.fr>,
Bruno Desthuilliers wrote:
Aahz a écrit :
In article<4c2747c1$0$4545$426a7...@news.fre
On 6/30/10 10:37 PM, Aahz wrote:
In article<4c29ad38$0$26210$426a7...@news.free.fr>,
Bruno Desthuilliers wrote:
Aahz a écrit :
In article<4c285e7c$0$17371$426a7...@news.free.fr>,
Bruno Desthuilliers wrote:
Aahz a écrit :
In article<4c2747c1$0$4545$426a7...@news.free.fr>,
Bruno Desthuilliers
In article <4c29ad38$0$26210$426a7...@news.free.fr>,
Bruno Desthuilliers wrote:
>Aahz a écrit :
>> In article <4c285e7c$0$17371$426a7...@news.free.fr>,
>> Bruno Desthuilliers wrote:
>>> Aahz a écrit :
In article <4c2747c1$0$4545$426a7...@news.free.fr>,
Bruno Desthuilliers wrote:
>>>
On 06/29/2010 06:46 PM, WANG Cong wrote:
> On 06/29/10 17:48, Andre Alexander Bell wrote:
> var a
> a
>> -> should raise an variable 'unset' exception
>>
>> Keep in mind that the module you are writing in is just an object as is
>> any function or method. So using local variables therein y
On Jun 29, 9:48 am, WANG Cong wrote:
> On 06/27/10 12:01, Carl Banks wrote:
>
>
>
>
>
> > On Jun 25, 8:24 pm, WANG Cong wrote:
> >> Understand, but please consider my proposal again, if we switched to:
>
> >> setattr(foo, 'new_attr', "blah")
>
> >> by default, isn't Python still dynamic as it is
On 6/29/10 9:46 AM, WANG Cong wrote:
1) Disallow dynamic attribute creations by assignments _by default_,
thus I expect an error when I do:
So far I only did tell you _how_ it is in Python. If I understand your
question about the design of the language correctly than you would like
Python to de
On 6/29/10 9:48 AM, WANG Cong wrote:
On 06/27/10 12:01, Carl Banks wrote:
On Jun 25, 8:24 pm, WANG Cong wrote:
Understand, but please consider my proposal again, if we switched to:
setattr(foo, 'new_attr', "blah")
by default, isn't Python still dynamic as it is? (Please teach me if I
am wr
WANG Cong wrote:
On 06/29/10 17:48, Andre Alexander Bell wrote:
As said previously I don't think one should differentiate between meta
programming and programming within the language, since the former is
nothing different than the latter.
If you check other programming language rather than
WANG Cong wrote:
On 06/27/10 12:01, Carl Banks wrote:
On Jun 25, 8:24 pm, WANG Cong wrote:
Understand, but please consider my proposal again, if we switched to:
setattr(foo, 'new_attr', "blah")
by default, isn't Python still dynamic as it is? (Please teach me if I
am wrong here.)
This why
On Tue, Jun 29, 2010 at 9:48 AM, WANG Cong wrote:
> On 06/27/10 12:01, Carl Banks wrote:
>> On Jun 25, 8:24 pm, WANG Cong wrote:
>>> Understand, but please consider my proposal again, if we switched to:
>>>
>>> setattr(foo, 'new_attr', "blah")
>>>
>>> by default, isn't Python still dynamic as it
On 06/27/10 12:01, Carl Banks wrote:
> On Jun 25, 8:24 pm, WANG Cong wrote:
>> Understand, but please consider my proposal again, if we switched to:
>>
>> setattr(foo, 'new_attr', "blah")
>>
>> by default, isn't Python still dynamic as it is? (Please teach me if I
>> am wrong here.)
>>
>> This w
On 06/29/10 17:48, Andre Alexander Bell wrote:
> On 06/25/2010 03:15 PM, WANG Cong wrote:
>> 1) Modifying a class attribute is metaprogramming, and this is modifying
>> a class, i.e. adding a new attribute to it, thus this should belong
>> to metaprogramming. (I know, strictly speaking, maybe my
On 06/25/2010 03:15 PM, WANG Cong wrote:
> 1) Modifying a class attribute is metaprogramming, and this is modifying
> a class, i.e. adding a new attribute to it, thus this should belong
> to metaprogramming. (I know, strictly speaking, maybe my definition of
> "metaprogramming" here is incorrect, I
Aahz a écrit :
In article <4c285e7c$0$17371$426a7...@news.free.fr>,
Bruno Desthuilliers wrote:
Aahz a écrit :
In article <4c2747c1$0$4545$426a7...@news.free.fr>,
Bruno Desthuilliers wrote:
Python has no pretention at "elegance".
That's not true at all. More precisely, I would agree with
On 29/06/2010 00:21, Alexander Kapps wrote:
Mark Lawrence wrote:
On 28/06/2010 20:23, Alexander Kapps wrote:
UHHM! Forget it. This of course doesn't work with setattr too. My
stupidness. :-(
Don't worry too much, looks like your nation's football is much better
than your settattr knowledge.
Mark Lawrence wrote:
On 28/06/2010 20:23, Alexander Kapps wrote:
UHHM! Forget it. This of course doesn't work with setattr too. My
stupidness. :-(
Don't worry too much, looks like your nation's football is much better
than your settattr knowledge.
I very much appreciate your attempt to make
On 28/06/2010 20:23, Alexander Kapps wrote:
Alexander Kapps wrote:
Bruno Desthuilliers wrote:
Alexander Kapps a écrit :
(snip)
While I personally don't agree with this proposal (but I understand
why some people might want it), I can see a reason.
When disallowing direct attribute creation, th
On 06/28/2010 02:31 PM, Aahz wrote:
> In article ,
> Michael Torrie wrote:
>> True. But you can't really criticize a language's implementation of OOP
>> without a good understanding of the "pure" OO language. For example, in
>> Smalltalk If/Then statements are actually methods of Boolean object
In article ,
Michael Torrie wrote:
>On 06/27/2010 11:58 PM, Stephen Hansen wrote:
>>
>> To say you can't really know "much about" OOP without knowing "much
>> about" Smalltalk seems basically, well, wrong.
>
>True. But you can't really criticize a language's implementation of OOP
>without a goo
On 06/27/2010 11:58 PM, Stephen Hansen wrote:
> To say you can't really know "much about" OOP without knowing "much
> about" Smalltalk seems basically, well, wrong.
True. But you can't really criticize a language's implementation of OOP
without a good understanding of the "pure" OO language. Fo
On 06/25/2010 09:39 PM, WANG Cong wrote:
> Thanks, I have to admit that I know nothing about Smalltalk.
If you know nothing about Smalltalk then you really aren't in a position
to talk about what is and is not OOP. Smalltalk is one of the original
OOP languages and purists define OOP as the model
On 6/28/10 12:09 PM, Alexander Kapps wrote:
This seems to work quite well:
class TypoProtection(object):
def __init__(self):
self.foo = 42
self.bar = 24
def _setattr(self, name, value):
if name in self.__dict__:
self.__dict__[name] = value
else:
raise AttributeError, "%s has no '%s' attribute"
Alexander Kapps wrote:
Bruno Desthuilliers wrote:
Alexander Kapps a écrit :
(snip)
While I personally don't agree with this proposal (but I understand
why some people might want it), I can see a reason.
When disallowing direct attribute creation, those typos that seem to
catch newcommers won
Bruno Desthuilliers wrote:
Alexander Kapps a écrit :
(snip)
While I personally don't agree with this proposal (but I understand
why some people might want it), I can see a reason.
When disallowing direct attribute creation, those typos that seem to
catch newcommers won't happen anymore. What
On 6/28/10 8:27 AM, Aahz wrote:
In article<4c285e7c$0$17371$426a7...@news.free.fr>,
Bruno Desthuilliers wrote:
Aahz a écrit :
In article<4c2747c1$0$4545$426a7...@news.free.fr>,
Bruno Desthuilliers wrote:
Python has no pretention at "elegance".
That's not true at all. More precisely, I wo
In article <4c285e7c$0$17371$426a7...@news.free.fr>,
Bruno Desthuilliers wrote:
>Aahz a écrit :
>> In article <4c2747c1$0$4545$426a7...@news.free.fr>,
>> Bruno Desthuilliers wrote:
>>>
>>> Python has no pretention at "elegance".
>>
>> That's not true at all. More precisely, I would agree wit
Alexander Kapps a écrit :
(snip)
While I personally don't agree with this proposal (but I understand why
some people might want it), I can see a reason.
When disallowing direct attribute creation, those typos that seem to
catch newcommers won't happen anymore. What I mean is this:
class Foo(
Carl Banks a écrit :
On Jun 27, 3:49 am, Bruno Desthuilliers
wrote:
WANG Cong a écrit :
On 06/26/10 00:11, Neil Hodgson wrote:
WANG Cong:
4) Also, this will _somewhat_ violate the OOP princples, in OOP,
this is and should be implemented by inherence.
Most object oriented programming la
Aahz a écrit :
In article <4c2747c1$0$4545$426a7...@news.free.fr>,
Bruno Desthuilliers wrote:
Python has no pretention at "elegance".
That's not true at all. More precisely, I would agree with you if the
emphasis is on "pretention" but not if the emphasis is on elegance;
Python Zen, #9 (o
In article ,
Neil Hodgson wrote:
>WANG Cong:
>>
>> 4) Also, this will _somewhat_ violate the OOP princples, in OOP,
>> this is and should be implemented by inherence.
>
> Most object oriented programming languages starting with Smalltalk
>have allowed adding attributes (addInstVarName) to class
In article <4c2747c1$0$4545$426a7...@news.free.fr>,
Bruno Desthuilliers wrote:
>
>Python has no pretention at "elegance".
That's not true at all. More precisely, I would agree with you if the
emphasis is on "pretention" but not if the emphasis is on elegance; I
think that Python is extremely e
On Sun, Jun 27, 2010 at 6:49 AM, Bruno Desthuilliers
wrote:
> WANG Cong a écrit :
>> On 06/26/10 00:11, Neil Hodgson wrote:
>>
>>> WANG Cong:
>>>
4) Also, this will _somewhat_ violate the OOP princples, in OOP,
this is and should be implemented by inherence.
>>> Most object oriented
On 6/27/10 10:10 PM, Carl Banks wrote:
On Jun 27, 3:49 am, Bruno Desthuilliers
wrote:
WANG Cong a écrit :
On 06/26/10 00:11, Neil Hodgson wrote:
WANG Cong:
4) Also, this will _somewhat_ violate the OOP princples, in OOP,
this is and should be implemented by inherence.
Most object
On Jun 27, 3:49 am, Bruno Desthuilliers
wrote:
> WANG Cong a écrit :
>
> > On 06/26/10 00:11, Neil Hodgson wrote:
>
> >> WANG Cong:
>
> >>> 4) Also, this will _somewhat_ violate the OOP princples, in OOP,
> >>> this is and should be implemented by inherence.
> >> Most object oriented programmi
WANG Cong a écrit :
> On 06/26/10 00:11, Neil Hodgson wrote:
>
>> WANG Cong:
>>
>>> 4) Also, this will _somewhat_ violate the OOP princples, in OOP,
>>> this is and should be implemented by inherence.
>>Most object oriented programming languages starting with Smalltalk
>> have allowed adding
WANG Cong a écrit :
> On 06/25/10 17:25, Steven D'Aprano
> wrote:
>
>> On Fri, 25 Jun 2010 14:15:12 +0100, WANG Cong wrote:
>>
(snip)
>>> 4) Also, this will _somewhat_ violate the OOP princples, in OOP, this is
>>> and should be implemented by inherence.
>> Perhaps, and perhaps not. But Python h
WANG Cong a écrit :
(snip)
>
> The point is why making metaprogramming easy is wonderful?
Because it makes life easier ?-)
> AND, even if
> it were wonderful, why only this one, i.e. creating attributes by
> assignments, not other things?
Like :
class Test(object):
a = 1
del Test.a
?-)
WANG Cong a écrit :
> On 06/25/10 15:34, Bruno Desthuilliers
> wrote:
>
>> WANG Cong a écrit :
>>> Hi, list!
>>>
>>> I have a doubt about the design of dynamic attribute creation by
>>> assignments in Python.
>>>
>>> As we know, in Python, we are able to create a new attribute of
>>> a class dyn
On Jun 25, 8:24 pm, WANG Cong wrote:
> Understand, but please consider my proposal again, if we switched to:
>
> setattr(foo, 'new_attr', "blah")
>
> by default, isn't Python still dynamic as it is? (Please teach me if I
> am wrong here.)
>
> This why I said the questionable thing is not so much r
On Sat, 26 Jun 2010 18:35:25 -0700, Chris Rebert wrote:
> On Sat, Jun 26, 2010 at 6:06 PM, Steven D'Aprano
> wrote:
>> CPython is a fairly plodding implementation. But that's due to the
>> conservativeness of CPython: Unladen Swallow is faster, and PyPI is
>> faster still, and the PyPI people ex
On Sat, Jun 26, 2010 at 6:06 PM, Steven D'Aprano
wrote:
> CPython is a fairly plodding implementation. But that's due to the
> conservativeness of CPython: Unladen Swallow is faster, and PyPI is
> faster still, and the PyPI people expect to eventually be competitive
> with C for speed.
PyPy (htt
On Sat, 26 Jun 2010 10:10:39 -0700, Stephen Hansen wrote:
> This characterization of adding attributes to an object as something
> "else", some special kind of activity called "metaprogramming" I think I
> reject outright, whereas I believe -- though I do not claim to speak for
> him/her -- the OP
Stephen Hansen wrote:
On 6/26/10 9:01 AM, Alexander Kapps wrote:
While I personally don't agree with this proposal (but I understand why
some people might want it), I can see a reason.
When disallowing direct attribute creation, those typos that seem to
catch newcommers won't happen anymore. Wh
On 6/26/10 9:01 AM, Alexander Kapps wrote:
While I personally don't agree with this proposal (but I understand why
some people might want it), I can see a reason.
When disallowing direct attribute creation, those typos that seem to
catch newcommers won't happen anymore. What I mean is this:
I
Ixokai wrote:
In what possible way is:
setattr(foo, 'new_attr', 'blah')
getattr(foo, 'new_attr')
delattr(foo, 'new_attr')
Better then:
foo.new_attr = 'blah'
foo.new_attr
del foo.new_attr
I don't understand what your argument is or problem is with the regular
syntax,
On 06/26/2010 05:39 AM, WANG Cong wrote:
> On 06/26/10 00:11, Neil Hodgson wrote:
>
>> WANG Cong:
>>
>>> 4) Also, this will _somewhat_ violate the OOP princples, in OOP,
>>> this is and should be implemented by inherence.
>>
>>Most object oriented programming languages starting with Smalltalk
WANG Cong:
> From what you are saying, Smalltalk picks a way similar to setattr() in
> Python?
addInstVarName is a method on ClassDescription objects.
> Because you mentioned 'addInstVarName' which seems to be a
> method or a builtin function. If so, that is my point, as I mentioned
> earlier
On 06/25/10 20:22, Ian Kelly wrote:
> On Fri, Jun 25, 2010 at 12:51 PM, Stephen Hansen
> wrote:
>>> Using assignments to create an attribute hides metaprogramming behide,
>>> while using delattr() exposes it.
>>
>> I don't understand what you're saying here either.
>
> I think he's saying that w
be a performance issue, but comparing
>> it with a language design issue, _I think_ the latter thing is much more
>> important than the former one.
>>
>
> Blimey, one minute we're talking about "Python dynamic attribute
> creation", the next it's a pe
On 06/25/10 19:38, Ethan Furman wrote:
> WANG Cong wrote:
>> On 06/25/10 15:34, Bruno Desthuilliers
>> wrote:
>>
>>> WANG Cong a écrit :
Hi, list!
I have a doubt about the design of dynamic attribute creation by
assignments in Python.
As we know, in Python, we are
On 06/26/10 00:11, Neil Hodgson wrote:
> WANG Cong:
>
>> 4) Also, this will _somewhat_ violate the OOP princples, in OOP,
>> this is and should be implemented by inherence.
>
>Most object oriented programming languages starting with Smalltalk
> have allowed adding attributes (addInstVarName)
On Fri, Jun 25, 2010 at 8:24 PM, WANG Cong wrote:
> > Here's the thing: Python doesn't consider creating dynamic attributes
> > to be questionable. Python doesn't merely allow for dynamicism, it
> > encourages it. And encouraging something means to make it simple.
> >
>
> Understand, but please
On 06/26/10 03:31, Carl Banks wrote:
> On Jun 25, 6:15 am, WANG Cong wrote:
>> Hi, list!
>>
>> I have a doubt about the design of dynamic attribute creation by
>> assignments in Python.
>>
>> As we know, in Python, we are able to create a new attribute of
>> a class dynamically by an assignment:
On Fri, 25 Jun 2010 19:31:24 -0700, Carl Banks wrote:
> I will also tell you that claims like "it's doesn't use good OOP
> principles" or "C++ does it that way" carry almost no credit. How C++
> does something is a suggestion, nothing more.
And sometimes a horrible warning *wink*
--
Steven
--
On Jun 25, 6:15 am, WANG Cong wrote:
> Hi, list!
>
> I have a doubt about the design of dynamic attribute creation by
> assignments in Python.
>
> As we know, in Python, we are able to create a new attribute of
> a class dynamically by an assignment:
>
>
>
> >>> class test: pass
> ...
> >>> test.a
WANG Cong:
> 4) Also, this will _somewhat_ violate the OOP princples, in OOP,
> this is and should be implemented by inherence.
Most object oriented programming languages starting with Smalltalk
have allowed adding attributes (addInstVarName) to classes at runtime.
Low level OOPLs like C++ and
is by default, not vice versa?
Yeah, I do understand this could be a performance issue, but comparing
it with a language design issue, _I think_ the latter thing is much more
important than the former one.
Blimey, one minute we're talking about "Python dynamic attribute
creation&qu
On 25/06/2010 19:03, WANG Cong wrote:
[lots of snips]
"Happily mixes them all together" doesn't mean it is elegant. :)
Bollocks springs to my mind. :)
Kindest regards.
Mark Lawrence.
--
http://mail.python.org/mailman/listinfo/python-list
On Fri, Jun 25, 2010 at 12:51 PM, Stephen Hansen
wrote:
>> Using assignments to create an attribute hides metaprogramming behide,
>> while using delattr() exposes it.
>
> I don't understand what you're saying here either.
I think he's saying that when an attribute exists in the class
dictionary,
On Fri, Jun 25, 2010 at 11:03 AM, WANG Cong wrote:
> On 06/25/10 17:25, Steven D'Aprano
> wrote:
>
> > Yes, isn't it wonderful? In other languages, metaprogramming is deepest
> > black magic, or even completely impossible. In Python it is so easy that
> > anyone can do it, and it is something beg
WANG Cong wrote:
On 06/25/10 15:34, Bruno Desthuilliers
wrote:
WANG Cong a écrit :
Hi, list!
I have a doubt about the design of dynamic attribute creation by
assignments in Python.
As we know, in Python, we are able to create a new attribute of
a class dynamically by an assignment:
class
On 06/25/10 14:31, Richard Thomas wrote:
>
> If you desperately want to limit the attribute assignments that can be
> performed on an object you can set the __slots__ attribute of its
> type. However, the Python ethos has always been to restrict as little
> as necessary to provide the tools it
On 06/25/10 15:34, Bruno Desthuilliers
wrote:
> WANG Cong a écrit :
>> Hi, list!
>>
>> I have a doubt about the design of dynamic attribute creation by
>> assignments in Python.
>>
>> As we know, in Python, we are able to create a new attribute of
>> a class dynamically by an assignment:
>>
On 06/25/10 17:25, Steven D'Aprano wrote:
> On Fri, 25 Jun 2010 14:15:12 +0100, WANG Cong wrote:
>
>> Hi, list!
>>
>> I have a doubt about the design of dynamic attribute creation by
>> assignments in Python.
>>
>> As we know, in Python, we are able to create a new attribute of a class
>> dynam
On Fri, Jun 25, 2010 at 6:15 AM, WANG Cong wrote:
> 4) Also, this will _somewhat_ violate the OOP princples, in OOP,
> this is and should be implemented by inherence.
>
Others have answered the rest fine, I just wanted to add: Who says we have
to follow OOP principles, huh?
If you want to follo
On Fri, 25 Jun 2010 14:15:12 +0100, WANG Cong wrote:
> Hi, list!
>
> I have a doubt about the design of dynamic attribute creation by
> assignments in Python.
>
> As we know, in Python, we are able to create a new attribute of a class
> dynamically by an assignment:
>
class test: pass
> ..
WANG Cong a écrit :
Hi, list!
I have a doubt about the design of dynamic attribute creation by
assignments in Python.
As we know, in Python, we are able to create a new attribute of
a class dynamically by an assignment:
class test: pass
...
test.a = "hello"
test.a
'hello'
However, I still
You are thinking like a C programmer
Why do you want the language to tie your hands? I want a language to give
me the tools I need and get out of the way. The more assumptions that are
baked into a language the more opportunities it has to be wrong.
Furthermore, object oriented design is a
On Jun 25, 2:15 pm, WANG Cong wrote:
> Hi, list!
>
> I have a doubt about the design of dynamic attribute creation by
> assignments in Python.
>
> As we know, in Python, we are able to create a new attribute of
> a class dynamically by an assignment:
>
>
>
> >>> class test: pass
> ...
> >>> test.a
Hi, list!
I have a doubt about the design of dynamic attribute creation by
assignments in Python.
As we know, in Python, we are able to create a new attribute of
a class dynamically by an assignment:
>>> class test: pass
...
>>> test.a = "hello"
>>> test.a
'hello'
>>>
However, I still don't
94 matches
Mail list logo