[Bf-committers] Idea: deprecate the attribute access for user properties in the BGE

Campbell Barton ideasman42 at gmail.com
Mon May 25 18:42:39 CEST 2009


+1, practically this isn't a very bug change to 2.49
it only means adding a warning since both access methods are currently
supported.

Wasn't sure if we should deprecate attribute style access because I
taught users would complain, interesting ZanQdo and yourself asked for
this change separately, Blengine is ok about it too (as an example of
a BGE user who isn't a total python/correctness pendent :) ).

On 5/25/09, José Ignacio <jose.cyborg at gmail.com> wrote:
> On Mon, May 25, 2009 at 1:16 PM, José Ignacio <jose.cyborg at gmail.com> wrote:
>  > Proposal:
>  > Deprecate & remove attribute access for user properties in
>  > KX_GameObject in favor of the recently introduced dictionary syntax.
>  > this: obj.userprop would become: obj["userprop"]
>  >
>  > Rationale:
>  > - Dictionary access allows the used of reserved or even illegal python
>  > names (like "for" and "class"), like the GUI and the logic bricks let
>  > you do now (thus being consistent with them), plus preventing name
>  > clashes between these and current/future class attributes. This is
>  > very important for beginners (and maybe even people with some
>  > experience), that would start wondering "why cant i access this
>  > property in python while i can use it perfectly with logic bricks?"
>  > - It is way faster, since it doesn't have to go trough all the python
>  > getattr system and dicts have very fast lookups.
>  > - Also, since names are python strings lets you do things would have
>  > to do with a __getattr() hack
>  > - Typing a class attribute wrong assignation would raise an exception
>  > instead of failing silently. For example, typing
>  > # -----------------------------
>  > obj.poistion = [1, 2.5, 3] # notice the typo
>  > # -----------------------------
>  > would create a property called "poistion" instead of raising an
>  > exception, thus leading to headaches and a lot of time wasting trying
>  > to find the issue. More if we are talking about beginners.
>  >
>  sorry, the last argument has some mistakes, should read as follows:
>
>  - With the attribute access removed, typing a class attribute wrong
>  in an assignation operation would raise an exception instead of
>  failing silently.
>  For example, typing in the current engine:
>  # -----------------------------
>  obj.poistion = [1, 2.5, 3] # notice the typo
>  # -----------------------------
>  would create a property called "poistion" instead of raising an
>  exception, thus leading to headaches and a lot of time wasting trying
>  to find the issue. More if we are talking about beginners.
>
>  > -- love
>  > cyborg_ar
>  >
>  _______________________________________________
>  Bf-committers mailing list
>  Bf-committers at blender.org
>  http://lists.blender.org/mailman/listinfo/bf-committers
>


-- 
- Campbell


More information about the Bf-committers mailing list