[Yum] Future feature request...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxx
  Box 90305, Durham N.C. 27708-0305

[Index of Archives]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux