Python dynamic attribute creation

Carl Banks pavlovevidence at gmail.com
Tue Jun 29 18:16:09 EDT 2010


On Jun 29, 9:48 am, WANG Cong <xiyou.wangc... at gmail.com> wrote:
> On 06/27/10 12:01, Carl Banks <pavlovevide... at gmail.com> wrote:
>
>
>
>
>
> > On Jun 25, 8:24 pm, WANG Cong <xiyou.wangc... at gmail.com> 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 related with dynamic
> >> programming or not.
>
> > Because it makes dynamicism harder to do.
>
> > Like I said, Python's goal isn't simply to make dynamicism possible,
> > it's to make it easy.
>
> > "foo.new_attr = 'blah'" is easier than using setattr.
>
> I do agree it's easier, but why do we need this to be easy? This is
> really my question.

Because the guy who wrote Python (our BDFL, Guido van Rossum) knows
and understands your objection, but disagrees with you nonetheless.
I've already told you why, and that's just going to have to be your
answer.  There's really nothing more to it than that.


Carl Banks



More information about the Python-list mailing list