[Yum] Future feature request...

Michael Stenner mstenner at phy.duke.edu
Wed Nov 12 14:28:07 UTC 2003


On Wed, Nov 12, 2003 at 08:47:24AM -0500, seth vidal wrote:
> So just to respond in kind:
> 
> when I build up that dict I'd need:
> 
> 
> command {name: function
>          name2: function2
>          name3: function3
>          ...
>          name80:function80}
> 
> Yah, that's not ugly at all.
> 
> riiiiiiiiiiiight

Yes, a long list is uglier than a short list.  This will be true no
matter how you represent the list.  The question I was addressing is:

  GIVEN A LONG LIST of name->function pairs, how do we more cleanly
  deal with them?

Besides, if this particular implementation offends you, there are lots
of other options:

======================================
command = {}

def command_foo(args):
    # do some stuff
command['foo'] = command_foo

def command_bar(args):
    # do some stuff
command['bar'] = command_bar
.
.
.

==================================
command = {}
for name, value in globals().items():
    if name.startswith('command_'):
        command[name] = value
==================================

and many more...
					-Michael
-- 
  Michael Stenner                       Office Phone: 919-660-2513
  Duke University, Dept. of Physics       mstenner at phy.duke.edu
  Box 90305, Durham N.C. 27708-0305



More information about the Yum mailing list