Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

No, the Style Guide says "use imports for packages and modules only", which (alias or not) rules out importing single functions.


You're right. I wouldn't import a function as a single letter module if I was only using it once or twice, but I do think there's value in some cases. decimal.Decimal("1.2345") or even d.Decimal("1.2345") can be cluttering.

Going by the guide, you would do 'import pprint; pprint.pprint("foo")'...which, at least in my experience, I've never seen. It's always "from pprint import pprint" or "from pprint import pprint as pp" It could be that I work with slobs.


I don't think having a different view on the relative value of conciseness vs. visible name spacing than is at play in the Google Python style guide makes you a slob.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: