<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	>
<channel>
	<title>Comments on: __func__ missing!?</title>
	<atom:link href="http://wolfram.kriesing.de/blog/index.php/2005/__func__-missing/feed" rel="self" type="application/rss+xml" />
	<link>http://wolfram.kriesing.de/blog/index.php/2005/__func__-missing</link>
	<description>all the other blogs have such cool names, I don't know one ...</description>
	<pubDate>Sat, 04 Feb 2012 12:46:17 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: kerja part time</title>
		<link>http://wolfram.kriesing.de/blog/index.php/2005/__func__-missing/comment-page-1#comment-430652</link>
		<dc:creator>kerja part time</dc:creator>
		<pubDate>Mon, 20 Jun 2011 07:52:37 +0000</pubDate>
		<guid isPermaLink="false">http://wolfram.kriesing.de/blog/?p=16#comment-430652</guid>
		<description>I obtained to say a significant thanks for posting this, planning to get pretty valuable for my university undertaking.</description>
		<content:encoded><![CDATA[<p>I obtained to say a significant thanks for posting this, planning to get pretty valuable for my university undertaking.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Prinos</title>
		<link>http://wolfram.kriesing.de/blog/index.php/2005/__func__-missing/comment-page-1#comment-8210</link>
		<dc:creator>Chris Prinos</dc:creator>
		<pubDate>Thu, 23 Nov 2006 16:19:20 +0000</pubDate>
		<guid isPermaLink="false">http://wolfram.kriesing.de/blog/?p=16#comment-8210</guid>
		<description>You don't need a magic method, just use the function name itself:

def foo():
    'this is doc for foo'
    print foo.__doc__</description>
		<content:encoded><![CDATA[<p>You don&#8217;t need a magic method, just use the function name itself:</p>
<p>def foo():<br />
    &#8216;this is doc for foo&#8217;<br />
    print foo.__doc__</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dbrodie</title>
		<link>http://wolfram.kriesing.de/blog/index.php/2005/__func__-missing/comment-page-1#comment-16</link>
		<dc:creator>dbrodie</dc:creator>
		<pubDate>Sun, 23 Oct 2005 20:21:06 +0000</pubDate>
		<guid isPermaLink="false">http://wolfram.kriesing.de/blog/?p=16#comment-16</guid>
		<description>The problem with a __func__ variable is the same problem with the inspect.currentframe solution that Florian and Simon said were discussing.

If __func__ will equal classname.funcname then it will not really be the function inside of which you are running. Example (using squigglies so tabbing dosn' get messed up):
class a
{
    def h(): pass
    print id(h)
}
print id(h)

as you will see you get different values. (Look at type(a.h))

And if you do the function inside which you are really running then it is not the actual function that is getting called.

These same problems will exsist with decorators if they return new functions. So should __func__ refer to the new function or to the original one?

All of these can cause some very subtle bugs depending on how you are going to use it. Ok, if you use __doc__ then it works great, but how about if you are trying to access func_* and some decorator is actually implemented as a class (like instancemethod).

Anyway, it might SEEM simple but depending on what you are doing, this can lead to very subtle bugs.</description>
		<content:encoded><![CDATA[<p>The problem with a __func__ variable is the same problem with the inspect.currentframe solution that Florian and Simon said were discussing.</p>
<p>If __func__ will equal classname.funcname then it will not really be the function inside of which you are running. Example (using squigglies so tabbing dosn&#8217; get messed up):<br />
class a<br />
{<br />
    def h(): pass<br />
    print id(h)<br />
}<br />
print id(h)</p>
<p>as you will see you get different values. (Look at type(a.h))</p>
<p>And if you do the function inside which you are really running then it is not the actual function that is getting called.</p>
<p>These same problems will exsist with decorators if they return new functions. So should __func__ refer to the new function or to the original one?</p>
<p>All of these can cause some very subtle bugs depending on how you are going to use it. Ok, if you use __doc__ then it works great, but how about if you are trying to access func_* and some decorator is actually implemented as a class (like instancemethod).</p>
<p>Anyway, it might SEEM simple but depending on what you are doing, this can lead to very subtle bugs.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pterk</title>
		<link>http://wolfram.kriesing.de/blog/index.php/2005/__func__-missing/comment-page-1#comment-15</link>
		<dc:creator>pterk</dc:creator>
		<pubDate>Sat, 22 Oct 2005 11:01:56 +0000</pubDate>
		<guid isPermaLink="false">http://wolfram.kriesing.de/blog/?p=16#comment-15</guid>
		<description>It's not '__func__' but it's a bit more dynamic than the earlier example using inspect. Another candidate might be getattr but I never know how the use getattr outside classes.

import inspect

def getname():
    """Here are the instructions of what input I expect
    and of what the function does, two things in one, I am just lazy!
    """
    f = inspect.currentframe().f_code.co_name
    print globals()[f].__doc__
    inp = raw_input('Please input here: ')
    # Prepare input data ...
    return inp</description>
		<content:encoded><![CDATA[<p>It&#8217;s not &#8216;__func__&#8217; but it&#8217;s a bit more dynamic than the earlier example using inspect. Another candidate might be getattr but I never know how the use getattr outside classes.</p>
<p>import inspect</p>
<p>def getname():<br />
    &#8220;&#8221;"Here are the instructions of what input I expect<br />
    and of what the function does, two things in one, I am just lazy!<br />
    &#8220;&#8221;"<br />
    f = inspect.currentframe().f_code.co_name<br />
    print globals()[f].__doc__<br />
    inp = raw_input(&#8217;Please input here: &#8216;)<br />
    # Prepare input data &#8230;<br />
    return inp</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Florian</title>
		<link>http://wolfram.kriesing.de/blog/index.php/2005/__func__-missing/comment-page-1#comment-14</link>
		<dc:creator>Florian</dc:creator>
		<pubDate>Fri, 21 Oct 2005 06:55:01 +0000</pubDate>
		<guid isPermaLink="false">http://wolfram.kriesing.de/blog/?p=16#comment-14</guid>
		<description>There is an advantage to a decorator beeing a  class rather then nested functions.

It has to do with name binding, not entirely unlike the issue of lambdas in loops if I remember correctly.</description>
		<content:encoded><![CDATA[<p>There is an advantage to a decorator beeing a  class rather then nested functions.</p>
<p>It has to do with name binding, not entirely unlike the issue of lambdas in loops if I remember correctly.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Simon</title>
		<link>http://wolfram.kriesing.de/blog/index.php/2005/__func__-missing/comment-page-1#comment-13</link>
		<dc:creator>Simon</dc:creator>
		<pubDate>Thu, 20 Oct 2005 21:26:31 +0000</pubDate>
		<guid isPermaLink="false">http://wolfram.kriesing.de/blog/?p=16#comment-13</guid>
		<description>Ups, I shouldn't have used &lt; so carelessly. The last sentence should read:

As for __func__ for a method, I think it should return &amp;;ltclass_name&gt;.&lt;method_name&gt; to allow method unbinding (via staticmethod() decorator).

Sorry for the mess.</description>
		<content:encoded><![CDATA[<p>Ups, I shouldn&#8217;t have used &lt; so carelessly. The last sentence should read:</p>
<p>As for __func__ for a method, I think it should return &amp;;ltclass_name&gt;.&lt;method_name&gt; to allow method unbinding (via staticmethod() decorator).</p>
<p>Sorry for the mess.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Simon</title>
		<link>http://wolfram.kriesing.de/blog/index.php/2005/__func__-missing/comment-page-1#comment-12</link>
		<dc:creator>Simon</dc:creator>
		<pubDate>Thu, 20 Oct 2005 21:24:06 +0000</pubDate>
		<guid isPermaLink="false">http://wolfram.kriesing.de/blog/?p=16#comment-12</guid>
		<description>A bit off-topic perhaps, but are there any benefits to having decorator implemented as a class?

As for __func__ for a method, I think it should return . to allow method unbinding (via staticmethod() decorator).</description>
		<content:encoded><![CDATA[<p>A bit off-topic perhaps, but are there any benefits to having decorator implemented as a class?</p>
<p>As for __func__ for a method, I think it should return . to allow method unbinding (via staticmethod() decorator).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bob Ippolito</title>
		<link>http://wolfram.kriesing.de/blog/index.php/2005/__func__-missing/comment-page-1#comment-11</link>
		<dc:creator>Bob Ippolito</dc:creator>
		<pubDate>Thu, 20 Oct 2005 20:29:16 +0000</pubDate>
		<guid isPermaLink="false">http://wolfram.kriesing.de/blog/?p=16#comment-11</guid>
		<description>The get_name() function above is basically identical to the hacky PHP solution: it returns the name of the current function.</description>
		<content:encoded><![CDATA[<p>The get_name() function above is basically identical to the hacky PHP solution: it returns the name of the current function.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Wolfram</title>
		<link>http://wolfram.kriesing.de/blog/index.php/2005/__func__-missing/comment-page-1#comment-10</link>
		<dc:creator>Wolfram</dc:creator>
		<pubDate>Thu, 20 Oct 2005 12:10:18 +0000</pubDate>
		<guid isPermaLink="false">http://wolfram.kriesing.de/blog/?p=16#comment-10</guid>
		<description>Well how it could work in Python is probably something smarter people can answer, and well thought-through it might be different to the &lt;a href="http://www.php.net/manual/en/language.constants.predefined.php" rel="nofollow"&gt;hacky PHP-solution :-)&lt;/a&gt; ...</description>
		<content:encoded><![CDATA[<p>Well how it could work in Python is probably something smarter people can answer, and well thought-through it might be different to the <a href="http://www.php.net/manual/en/language.constants.predefined.php" rel="nofollow">hacky PHP-solution <img src='http://wolfram.kriesing.de/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </a> &#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Florian</title>
		<link>http://wolfram.kriesing.de/blog/index.php/2005/__func__-missing/comment-page-1#comment-9</link>
		<dc:creator>Florian</dc:creator>
		<pubDate>Thu, 20 Oct 2005 12:01:35 +0000</pubDate>
		<guid isPermaLink="false">http://wolfram.kriesing.de/blog/?p=16#comment-9</guid>
		<description>me= guy with autocomment

Neither do I understand it. But I'd like to ask a question.

if __func__ refers to the function you're in (as in def foo(): __func__ == foo)

what does __func__ in a class method refer to,

class bar:
  def foo( self ): __func__ == bar.foo or __func__ == self.foo ?

and what is it in a generator
def foo(): yield __func__ == foo  or __func__ == foo()?</description>
		<content:encoded><![CDATA[<p>me= guy with autocomment</p>
<p>Neither do I understand it. But I&#8217;d like to ask a question.</p>
<p>if __func__ refers to the function you&#8217;re in (as in def foo(): __func__ == foo)</p>
<p>what does __func__ in a class method refer to,</p>
<p>class bar:<br />
  def foo( self ): __func__ == bar.foo or __func__ == self.foo ?</p>
<p>and what is it in a generator<br />
def foo(): yield __func__ == foo  or __func__ == foo()?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

