Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

Import Convention

Can someone explain one of the answers to this question: Peewee's convention is to import everything with *. Why is this usually considered a bad practice? Ans: Peewee's contents are no longer contained in the the peewee namespace.

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,423 Points

Based on this StackOverflow response:

  • Because it puts a lot of stuff into your namespace (might shadow some other object from previous import and you won't know about it).
  • Because you don't know exactly what is imported and can't find place from what module certain thing was imported easily (readability).
  • Because you can't use cool tools like pyflakes to detect statically errors in your code.