[openstack-dev] Use of local()

Salvatore Orlando sorlando at nicira.com
Fri Feb 8 15:27:40 UTC 2013


On 8 February 2013 15:15, Mark McClain <mark.mcclain at dreamhost.com> wrote:
> -1 on locals()
>
> -1 on adding kwargs to OpenStack logging methods.  It's replacing one type
> of magic with another type.

I subscribe to both points.

>
> It may not be perfect, but Python has a well established logging module.
> When we make decisions to create custom variants of python internals with
> different method signatures we actually make this project harder for new
> developers to join.  We're also breaking one of the ideals of Python "There
> should be one-- and preferably only one --obvious way to do it."  This is
> from the Zen of Python (If you've never read it, start up the interpreter
> and type 'import this').  Having the option to pass a dict via the args
> param or using the proposed kwargs parameter violates this concept.
>
> I also do not accept that dictionaries created in code have any readability
> impact when properly styled.  A method call with many keyword args is just
> as ugly.

Sorry this is not obvious to me (I'm not dutch ;-) ). Is your point
that the the dictionary we now use as
an alternative to locals() is no less readable than the list of
keyword args as proposed by Jason?

>
> There are also performance considerations about constructing dictionaries
> and I'd like to point everyone to Doug Hellman's written article  about
> dictionary construction performance.
>
> http://www.doughellmann.com/articles/misc/dict-performance/index.html
>
> mark
>
> On Feb 8, 2013, at 7:02 AM, Sean Dague <sdague at linux.vnet.ibm.com> wrote:
>
> On 02/08/2013 12:13 AM, Jay Pipes wrote:
>
> On 02/07/2013 09:58 PM, Sean Dague wrote:
>
> On 02/07/2013 06:04 PM, Nachi Ueno wrote:
>
> I suspect we should just slowly transition as people touch code.
>
>
> I agree. The reason why I asked this is for reviewing.
> so I'll comment not to use local() in review.
>
>
> If we have rough concensus start with updating HACKING in the relevant
> projects. Then I suggest a grind through replacing the code. Once it's
> out we can enforce it in hacking.py (comming soon to a project near you,
> and not just in nova and tempest).
>
>
> Go for it. Jason's suggestion for allowing LOG.debug() et al messages to
> allow kwargs would make things much more readable than supplying huge
> manually-coded dicts.
>
>
> +1, that was a nice suggestion.
>
> --
> Sean Dague
> IBM Linux Technology Center
> email: sdague at linux.vnet.ibm.com
> alt-email: sldague at us.ibm.com
>
>
> _______________________________________________
> OpenStack-dev mailing list
> OpenStack-dev at lists.openstack.org
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
>
>
>
> _______________________________________________
> OpenStack-dev mailing list
> OpenStack-dev at lists.openstack.org
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
>



More information about the OpenStack-dev mailing list