Programmer meme
Programmer Humor
7
Posts
7
Posters
0
Views
-
This post did not contain any content.
-
This post did not contain any content.
I'm not surprised by anything at this point
-
This post did not contain any content.wrote last edited by [email protected]
import builtins def HelloWorld(funcname): getattr(builtins, funcname)("HelloWorld") HelloWorld("print")
Edit, improved:
import inspect, builtins def HelloWorld(funcname): caller = inspect.currentframe().f_code.co_name getattr(builtins, funcname)(caller) HelloWorld("print")
-
This post did not contain any content.
Sometimes I wish there were Easter eggs like this in programming languages. But then, people would just be using these Easter eggs for everything
-
import builtins def HelloWorld(funcname): getattr(builtins, funcname)("HelloWorld") HelloWorld("print")
Edit, improved:
import inspect, builtins def HelloWorld(funcname): caller = inspect.currentframe().f_code.co_name getattr(builtins, funcname)(caller) HelloWorld("print")
Perl time:
sub AUTOLOAD { our $AUTOLOAD=~s/.*:://; no strict; local $_=$_[0] and *STDOUT->$_($AUTOLOAD) } HelloWorld("print");
Pro: You can Give HelloWorld any (syntactically valid) name you like and (as long as the parameter is
"print"
, anyway) its name will be printed, no pre-declaration required.Con: The specified function inside the quotes has to be a method associated with a file descriptor.
-
This post did not contain any content.
Well well well, how the turned have tables, they have
-
This post did not contain any content.
Why Yoda switched his major from CS to Jedi Studies