Abhas Bhattacharya writes:
[...]
> If i call one() and two() respectively, i would like to see "one"
> and "two". I dont have much knowledge of lambda functions, neither
> am i going to use them, so that's something I cant answer.
It's not about lambda. The following does not contain lambda. Wha
Abhas Bhattacharya wrote:
>
>Now, for your questions:
>If i call one() and two() respectively, i would like to see "one" and "two".
>I dont have much knowledge of lambda functions, neither am i going to use
>them, so that's something I cant answer.
My point is not that these are special cases to
On Dec 27, 11:31 pm, Steven D'Aprano wrote:
> Unfortunately this doesn't help if you actually need the function name
> *inside* the function
Here's an extension of Steven's original decorator that adds a
reference to the function itself into the function's globals, and then
composes a new functio
On Thu, 27 Dec 2012 10:09:01 -0500, Roy Smith wrote:
> In article <50dc29e9$0$29967$c3e8da3$54964...@news.astraweb.com>,
> Steven D'Aprano wrote:
>
>> On Wed, 26 Dec 2012 23:46:31 -0800, Abhas Bhattacharya wrote:
>>
>> >> > two = lamba : "one"
>> >> > one = two
>> >>
>> >> > Which one of thes
In article <50dc29e9$0$29967$c3e8da3$54964...@news.astraweb.com>,
Steven D'Aprano wrote:
> On Wed, 26 Dec 2012 23:46:31 -0800, Abhas Bhattacharya wrote:
>
> >> > two = lamba : "one"
> >> > one = two
> >>
> >> > Which one of these is the "name" of the function?
> [...]
> > If i call one() and t
On Thu, 27 Dec 2012 07:32:16 -0600, Tim Chase wrote:
> Depending on where in the code you are, the same function object also
> has a local name of "fn". It's madness until you understand it, and
> then it's beauty :)
"This is madness!"
"No, this is PYTHON!!!"
--
Steven
--
http://mail.pytho
On Tue, 25 Dec 2012 18:00:38 -0800, Abhas Bhattacharya wrote:
> While I am defining a function, how can I access the name (separately as
> string as well as object) of the function without explicitly naming
> it(hard-coding the name)? For eg. I am writing like:
> def abc():
> #how do i access
On 12/27/12 04:58, Steven D'Aprano wrote:
> On Wed, 26 Dec 2012 23:46:31 -0800, Abhas Bhattacharya wrote:
>
two = lamba : "one"
one = two
>>>
Which one of these is the "name" of the function?
> [...]
>> If i call one() and two() respectively, i would like to see "one" and
>> "two".
On Tue, 25 Dec 2012 22:11:28 -0500, Roy Smith wrote:
> I've only ever wanted the name. If you need the actual function object,
> I suppose you might eval() the name, or something like that.
Oh look, I found a peanut! Let me get a 50lb sledgehammer to crack it
open!
*wink*
Please do not use ev
On Wed, 26 Dec 2012 23:46:31 -0800, Abhas Bhattacharya wrote:
>> > two = lamba : "one"
>> > one = two
>>
>> > Which one of these is the "name" of the function?
[...]
> If i call one() and two() respectively, i would like to see "one" and
> "two".
I'm afraid you're going to be disappointed. There
On 12/27/2012 03:26 AM, Abhas Bhattacharya wrote:
On Thursday, 27 December 2012 13:33:34 UTC+5:30, Mitya Sirenef wrote:
How about defining a function that prints value and then calls a function?
def call(func_name):
print(mydict[func_name])
globals()[func_name]()
You could als
On Dec 26, 2012 11:55 PM, "Abhas Bhattacharya"
wrote:
>
> On Thursday, 27 December 2012 10:22:15 UTC+5:30, Tim Roberts wrote:
> > Abhas Bhattacharya wrote:
> >
[Oh god please stop/avoid using Google Groups with its godawful
reply-quoting style that adds excessive blank lines]
> > >While I am def
On Thursday, 27 December 2012 13:56:24 UTC+5:30, Chris Rebert wrote:
> On Dec 25, 2012 6:06 PM, "Abhas Bhattacharya" wrote:
>
> >
>
> > While I am defining a function, how can I access the name (separately as
> > string as well as object) of the function without explicitly naming
> > it(hard-
On Dec 25, 2012 6:06 PM, "Abhas Bhattacharya"
wrote:
>
> While I am defining a function, how can I access the name (separately as
string as well as object) of the function without explicitly naming
it(hard-coding the name)?
> For eg. I am writing like:
> def abc():
> #how do i access the funct
On Thursday, 27 December 2012 13:33:34 UTC+5:30, Mitya Sirenef wrote:
>
> How about defining a function that prints value and then calls a function?
>
>
>
> def call(func_name):
>
>print(mydict[func_name])
>
>globals()[func_name]()
>
>
>
>
>
> You could also define a custom clas
On 12/27/2012 02:45 AM, Abhas Bhattacharya wrote:
On Thursday, 27 December 2012 10:22:15 UTC+5:30, Tim Roberts wrote:
Abhas Bhattacharya wrote:
While I am defining a function, how can I access the name (separately as
string as well as object) of the function without explicitly naming
it(hard
On Thu, Dec 27, 2012 at 6:46 PM, Abhas Bhattacharya
wrote:
> [ a whole lot of double-spaced quoted text - please trim it ]
> If i call one() and two() respectively, i would like to see "one" and "two".
That completely goes against your idea of knowing at compile-time,
because the name "two" isn't
On Thursday, 27 December 2012 13:22:45 UTC+5:30, Chris Angelico wrote:
> On Thu, Dec 27, 2012 at 6:46 PM, Abhas Bhattacharya
>
> wrote:
>
> > [ a whole lot of double-spaced quoted text - please trim it ]
>
> > If i call one() and two() respectively, i would like to see "one" and "two".
>
>
>
On Thursday, 27 December 2012 13:18:19 UTC+5:30, Chris Angelico wrote:
> On Thu, Dec 27, 2012 at 6:26 PM, Abhas Bhattacharya
>
> wrote:
>
> > During run-time, I can always use: function_name.__name__ (although that's
> > kind of lame because it returns "function_name"). But if the function
>
On Thursday, 27 December 2012 10:22:15 UTC+5:30, Tim Roberts wrote:
> Abhas Bhattacharya wrote:
>
> >
>
> >While I am defining a function, how can I access the name (separately as
>
> >string as well as object) of the function without explicitly naming
>
> >it(hard-coding the name)?
>
> >Fo
On Thu, Dec 27, 2012 at 6:26 PM, Abhas Bhattacharya
wrote:
> During run-time, I can always use: function_name.__name__ (although that's
> kind of lame because it returns "function_name"). But if the function itself
> contains print(__name__) and I call the function, it returns __main__ (yes,
>
On Thursday, 27 December 2012 11:14:36 UTC+5:30, Chris Angelico wrote:
> On Thu, Dec 27, 2012 at 3:52 PM, Tim Roberts wrote:
>
> > The
>
> > compiled code in a function, for example, exists as an object without a
>
> > name. That unnamed object can be bound to one or more function names, but
On Wednesday, 26 December 2012 08:41:28 UTC+5:30, Roy Smith wrote:
> In article ,
>
> Abhas Bhattacharya wrote:
>
>
>
> > While I am defining a function, how can I access the name (separately as
>
> > string as well as object) of the function without explicitly naming
>
> > it(hard-codin
On Thu, Dec 27, 2012 at 3:52 PM, Tim Roberts wrote:
> The
> compiled code in a function, for example, exists as an object without a
> name. That unnamed object can be bound to one or more function names, but
> the code doesn't know that. Example:
>
> def one():
> print( "Here's one" )
>
> tw
Abhas Bhattacharya wrote:
>
>While I am defining a function, how can I access the name (separately as
>string as well as object) of the function without explicitly naming
>it(hard-coding the name)?
>For eg. I am writing like:
>def abc():
>#how do i access the function abc here without hard-co
In article ,
Abhas Bhattacharya wrote:
> While I am defining a function, how can I access the name (separately as
> string as well as object) of the function without explicitly naming
> it(hard-coding the name)?
> For eg. I am writing like:
> def abc():
> #how do i access the function abc
26 matches
Mail list logo