opensubscriber
   Find in this group all groups
 
Unknown more information…

w : web-sig@python.org 16 April 2011 • 2:22AM -0400

Re: [Web-SIG] OT: dotted names (Was: Re: A Python Web Application Package and Format)
by Alice Bevan–McGregor

REPLY TO AUTHOR
 
REPLY TO GROUP




On 2011-04-15 11:02:17 -0700, Jim Fulton said:

> On Fri, Apr 15, 2011 at 1:32 PM, Éric Araujo
> <merwok@netw...> wrote:
>> As an aside, I wonder why people use dot+colon notation instead of just
>> dots to reference callables.  In distutils2 for example we resolve
>> dotted names to find command classes, command hooks and compilers.  So
>> what’s the benefit, marginally easier parsing?
>
> An opportunity of using a colon is that it allows::
>
>    dotted.module.name:expression
>
> where expression may be more than just a name::
>
>   foo.bar:Bar()

Or foo.bar:Baz.factory.

I wouldn't go so far as to eval() what's after the colon.  The real
difference is this:

[foo.bar]:[Baz.factory]
|         ^- Attribute lookup.
^- Module lookup.

You can't do this:

import foo.bar.Baz.factory

Thus the difference.  However, the syntax is actually more flexible than that:

[foo.bar]/[subfolder/file]
|         ^- Sub-path.
^- Module.

/[foo/bar]
  ^- Just path.

— Alice.


_______________________________________________
Web-SIG mailing list
Web-SIG@pyth...
Web SIG: http://www.python.org/sigs/web-sig
Unsubscribe: http://mail.python.org/mailman/options/web-sig/subscriber%40opensubscriber.com

Bookmark with:

Delicious   Digg   reddit   Facebook   StumbleUpon

Related Messages

opensubscriber is not affiliated with the authors of this message nor responsible for its content.