Parsing functions(?)

Gang Li gang.li at compuware.com
Mon Dec 13 16:23:41 EST 1999


def record(self, fname,  *args, **kw):
    self.flist.append((fname, args, kw))

def call_by_i(self, i):
    ff = self.flist[i]
    return apply(ff[0], ff[1], ff[2])

"Paul M" <paul.m at yale.edu> wrote in message
news:82p3ll$iqf$1 at news.ycc.yale.edu...
>
> I know I could instead define the record method like this:
>
>     def record(self, fname, fargs):
>         self.flist.append((fname, fargs))
>
> which would be called like:
>     rec.record(foo, (1,))
>
> but it doesn't seem as natural as the first example, and besides it
> means that one has to remember to do thinks like specify 1-tuples when
> the function only takes a single argument.
>
> Is this doable without parsing the command-line (or the *.py files -
> I'd like to do this from within a module hierarchy I'm building)?
>
> Thanks
>
> Paul
>
>
>
>
>
>





More information about the Python-list mailing list