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 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:
>>&g
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
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 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
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
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, strict
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
On 06/25/10 22:11, Mark Lawrence wrote:
> On 25/06/2010 19:23, WANG Cong wrote:
>> On 06/25/10 14:31, Richard Thomas wrote:
>>
>>
>>
>>>
>>> If you desperately want to limit the attribute assignments that can be
>>> performed on an obje
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
&
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
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
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
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, w
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
18 matches
Mail list logo