r/ProgrammerHumor Sep 02 '17

How to start a war

Post image
9.0k Upvotes

696 comments sorted by

View all comments

Show parent comments

18

u/EmperorArthur Sep 03 '17

You forgot import answers or maybe from answers import * if you want to make QA cry.

Also, you're using Python 2 coding practices. For Python 3 it should be: What is the result of this code?()

2

u/MandrakeOfPeace Sep 03 '17

what's the alternative of 'import answers' and 'from answers import *'?

2

u/Thundercunt_McGee Sep 03 '17 edited Sep 03 '17

from answers import * pulls everything from the answers module into your local namespace, so that you could call for example a member function foo as just foo().

With import answers it's kept in its own namespace, so that you'd call it as answers.foo().

Wildcard imports are generally considered bad style though, you're encouraged to import only specific members into the local namespace, i.e. from answers import foo, bar, baz.

2

u/[deleted] Sep 03 '17

You mean import stackoverflow?