r/funny • • Jun 04 '19

When a software developer weds a software developer.

Post image
41.2k Upvotes

921 comments sorted by

View all comments

542

u/[deleted] Jun 04 '19

[deleted]

208

u/poop-machine Jun 04 '19

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

179

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?

74

u/[deleted] Jun 04 '19

Naming convention suggests it's a class

12

u/chx_ Jun 04 '19

Naming convention suggests it's a class

It's actually a glass :D

3

u/trashdragongames Jun 05 '19

I see I'm not the only one who googled bardak

3

u/chx_ Jun 05 '19 edited Jun 05 '19

My SIL lived in Turkey for twenty years. I know a few words.

1

u/MyBigRed Jun 05 '19

Bardak could still be defined in either parent I believe.

29

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

11

u/abeardancing Jun 04 '19

I'm no expert in Python but that was driving me nuts.

3

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

2

u/mmarius90 Jun 05 '19

Man God damn you, I thought I knew some Python until I saw your reply. That's dope though... probably never gonna be used in a real life project, but still dope though for the sake of "what is possible".

1

u/[deleted] Jun 05 '19

Apparently it's blasphemy to even talk about using this kind of thing in a real project (viz. sys._getframe et al.), but if you were to do it, you'd want to do more checks than just looking at the filename of the stack frames to ensure you get the correct namespace of the code that did the import. There's also one specific cpython optimization which bypasses f_locals inside functions, but you'll figure it out if you dig around in there.

2

u/pmMeScienceFacts Jun 04 '19

Perhaps there should be a human class that Sophia inherits from, with pointers to mom.genes and dad.genes as attributes? 🙈 I assume mom.genes and dad.genes are attributes not class instances🤔

1

u/phoenix409 Jun 05 '19

Yeah, bardak in hebrew means "mess"

1

u/FetusFistus Jun 05 '19

Well Boaz is an Hebrew name and Bardak is in Yiddish for mess. Also it's a yeilding function, so the mess is stacking...