Robert Bradshaw, 10.02.2010 06:47:
> cdef extern from "foo.h" namespace "Foo::Bar":
>      int f(int)
> 
> cdef extern from "..." namespace "A::B" as X:
>      int x(int)
> 
> print X.x(5)

+1 for these two, the first meaning that the names get defined in the flat
module namespace.

I don't think automatic namespace injection makes sense for anything but
namespaces that are already valid Python identifiers. Given that there's
some magic to it, I'm all for leaving it out completely. The 'as' syntax is
simple enough, readable, and makes it clear what happens.

Also, the above will most likely appear in a (reusable) .pxd anyway. That
makes the 'as' syntax less important as there's almost always an explicit
namespace given by the .pxd file name and an additional import following in
a .pyx file, which can then decide what to name the things in the code, and
how to deal with naming collisions.

Stefan

_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to