this post was submitted on 28 Aug 2025
173 points (93.0% liked)

Programmer Humor

26762 readers
1981 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 
top 7 comments
sorted by: hot top controversial new old
[–] JohnnyCanuck@lemmy.ca 26 points 1 month ago* (last edited 1 month ago) (1 children)
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")
[–] palordrolap@fedia.io 5 points 1 month ago

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.

[–] marsza@lemmy.cafe 10 points 1 month ago

Sometimes I wish there were Easter eggs like this in programming languages. But then, people would just be using these Easter eggs for everything

[–] goatinspace@feddit.org 7 points 1 month ago

I'm not surprised by anything at this point

[–] handsoffmydata@lemmy.zip 4 points 1 month ago

Why Yoda switched his major from CS to Jedi Studies

[–] Shady_Shiroe@lemmy.world 2 points 1 month ago

Well well well, how the turned have tables, they have

[–] pewpew@feddit.it 1 points 1 month ago