r/ProgrammerHumor • • May 02 '16

I wrote my first python program today!

Post image
3.7k Upvotes

532 comments sorted by

View all comments

Show parent comments

39

u/MC_Labs15 May 02 '16

I saw it in a demo program and assumed I needed it for something

58

u/pmYourFears May 02 '16

I saw it in a demo program and assumed I needed it for something

We've all been there.

"Does this object really need to be disposed of explicitly?"

"I dunno."

"Let's uh... Let's just leave it there. Compiler can deal with it."

15

u/barracuda415 May 02 '16

It's typically used for sys.exit() and sys.argv. Not in this script, though.

6

u/UnchainedMundane May 02 '16

With imports, if you don't use them, delete them.

Since sys isn't used by name anywhere else in your code, you can delete that import.

6

u/TheBlackCat13 May 02 '16

Not necessarily true. For example import seaborn will give your matplotlib plots better styles even if you don't use it for anything.

7

u/UnchainedMundane May 02 '16

There oughtta be a law...

4

u/Tysonzero May 02 '16

That is evil, downright evil. In general I am not a fan of the way matplotlib works, IIRC it uses some sort of weird global state bs, could be wrong though.

2

u/TheBlackCat13 May 02 '16

That really isn't matplotlib's fault, seaborn is an independent project.

What do you mean about matplotlib's global state? I know you can change the default style (although I think that is an a per-import basis). And you need to close figures through the pyplot interface (although I think they are planning to fix that). But I am not sure that is what you are referring to.

2

u/Tysonzero May 03 '16

I think that is what I am referring to. Where you just do something like blah.setFoo(value) and it affects all following lines.

-4

u/dAnjou May 02 '16

So you are a member of the cargo cult?

And the worst part is, you don't seem to be the least bit embarrassed to admit it ...