In defence of the two-namespace rule

Paul Foley see at below
Sat Jan 22 08:01:55 EST 2000


On Fri, 21 Jan 2000 17:14:58 +0000, Edward Welbourne wrote:

> As to passing the default through globals, the problem then gets
> complicated by the fact that, of course, that dialog gets used by loads
> of bits of code, so someone writes this helper:

> def relativeto(root):
>     def result(*fragments, r=root):
>         return apply(os.path.join, (r,) + fragments)
>     return result

You don't need the (*args, var=...) thing.  You can do this, instead:

  class relativeto:
      def __init__(self, root):
         self.root = root
      def __call__(self, *fragments):
         return apply(os.path.join, (self.root,)+fragments)

-- 
C/C++/Java/Perl/etc are for people who want to make things that work.
Common Lisp is for people who want to make things that don't break.
                                                         -- Erik Naggum
(setq reply-to
  (concatenate 'string "Paul Foley " "<mycroft" '(#\@) "actrix.gen.nz>"))



More information about the Python-list mailing list