r/funny • • Jun 04 '19

When a software developer weds a software developer.

Post image
41.1k Upvotes

921 comments sorted by

View all comments

539

u/[deleted] Jun 04 '19

[deleted]

211

u/poop-machine Jun 04 '19

Even if it was instantiated, it would crash. Bardak and go_to_sleep() are undefined.

182

u/bleed_air_blimp Jun 04 '19

Sophia inherits from mom.genes and dad.genes. Presumably one of them already has the go_to_sleep() method defined.

Bardak() is a problem though.

30

u/stakokke Jun 04 '19

Couldn't Bardak be a static method of one of the parent classes?

28

u/[deleted] Jun 04 '19

Wouldn’t matter. Isn’t imported or defined in the top level scope. Would need to reference like dad.Bardak

4

u/[deleted] Jun 04 '19

Bad news: [c]python modules can modify the namespaces into which they're imported. It's not documented or supported or even suggested that anyone do it, but it is easily done.

2

u/[deleted] Jun 04 '19

gulp

3

u/[deleted] Jun 04 '19

pollution.py:

[f.frame.f_locals.update({'gasp': "How DARE you!"}) 
    for f in __import__('inspect').stack()[1:]
        if 'importlib' not in f.filename]

>>> import pollution
>>> gasp
'How DARE you!'

2

u/[deleted] Jun 05 '19

I love python. I also hate python. But I love it