pre-PEP: The create statement

Michele Simionato michele.simionato at gmail.com
Thu Apr 6 12:11:52 EDT 2006


Carl Banks wrote:
> My biggest concern with this is the special arguments of the caller.
> It breaks my heart that we couldn't do something like this:
>
> create dict keymap:
>     A = 1
>     B = 2
>
> And it'll probably confuse people as well.  We ought to keep that in
> mind.
>
>
> > Of course, properties are only one of the many possible uses of the
> > create statement. The create statement is useful in essentially any
> > situation where a name is associated with a namespace. So, for
> > example, sub-modules could be created as simply as::
> >
> >      create module mod:
> >          "This creates a sub-module named mod with an f1 function"
> >
> >          def f1():
> >              ...
>
> Let's not do this, really.  A module should be one-to-one with a file,
> and you should be able to import any module.  Having in-line modules
> complicates everything.  And it becomes a misnomer.  So, please, let's
> get a better example.  If you must, call it a scope or namespace.

You are right, I think I am responsible for the wrong choice of the
name.
What I had in mind was a namespace or, if you wish, a named dictionary.
An simple-minded implementation could be

class Namespace(object):
    def __init__(self, name, args, dic):
        self.__name__ = name
        self.__dict__.update(dic)

create Namespace keymap:
     A = 1
     B = 2

and nothing forbids to have the Namespace class in some module of the
standard
library ;)

          Michele Simionato




More information about the Python-list mailing list