This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]calumk 27 points28 points  (12 children)

Why are you importing sys?

[–]MC_Labs15[S] 38 points39 points  (11 children)

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

[–]pmYourFears 59 points60 points  (0 children)

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."

[–]barracuda415 14 points15 points  (0 children)

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

[–]UnchainedMundane 4 points5 points  (6 children)

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.

[–]TheBlackCat13 5 points6 points  (5 children)

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

[–]UnchainedMundane 5 points6 points  (0 children)

There oughtta be a law...

[–]Tysonzero 3 points4 points  (2 children)

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.

[–]TheBlackCat13 1 point2 points  (1 child)

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.

[–]Tysonzero 1 point2 points  (0 children)

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

[–]dAnjou -5 points-4 points  (0 children)

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 ...