[python] pass the name of args

Chris Rebert clp2 at rebertia.com
Fri Jun 4 08:51:04 EDT 2010


On Fri, Jun 4, 2010 at 4:32 AM, macm <moura.mario at gmail.com> wrote:
> Hi Folks
>
> def myDef(x)
>        doSomething x
>        result = x.????
>        return coolThings
> ---------------------------------
>
> WhatYourName = ('python','is','cool')
>
> myDef(WhatYourName)
>
> so what I am looking for in myDef
>
>        result = WhatYourName
>
> ----------------------------------
> again :
> IhaveOtherName = ('some','thing')
>
> myDef(IhaveOtherName)
>
> so what I am looking for in myDef
>
>        result = IhaveOtherName
>
> ----------------------------------
>
> Is it possible with python?

Not without very evil black-magic hackery. Explain /why/ you want this
magic myDef() and someone will probably be able to suggest a better,
alternative approach.

Cheers,
Chris
--
http://blog.rebertia.com



More information about the Python-list mailing list