3 ms·
Besides the header issue mentioned in the sibling, sometimes the context is important too, for an example from Python, no one would `from os.path import join`—
by mikepurvis 7y ago
Besides the header issue mentioned in the sibling, sometimes the context is important too, for an example from Python, no one would `from os.path import join`— you always use `os.path.join` in its entirety.
- deleted 7y ago[deleted]
- tomjakubowski 7y agoI agree with your point and I'm just nit picking, but `from os import path` and `path.join` is pretty acceptable too.
- david2ndaccount 7y agoI have definitely seen `from os.path import join` in some ugly ML github repos.
- pfranz 7y ago:shrug: I've done that quite a bit. This randomly selected popular Python library does it, too[1]. The example for `os.walk` literally has `from os.path import join, getsize`[2]. The docs seem to back this up[3]: "Remember, there is nothing wrong with using `from package import specific_submodule!` In fact, this is the recommended notation unless the importing module needs to use submodules with the same name from different packages." I haven't dealt with a lot of C++ code but I feel like I see a lot of `using namespace ...` and haven't seen much `using ...;` (which I think is more readable/acceptable) [1] https://github.com/psf/requests/blob/df918c066fa275abc2bb0c960647dc064d136a01/requests/utils.py#L22 https://github.com/psf/requests/blob/df918c066fa275abc2bb0c9... [2] https://docs.python.org/3/library/os.html#os.walk https://docs.python.org/3/library/os.html#os.walk [3] https://docs.python.org/3/tutorial/modules.html#importing-from-a-package https://docs.python.org/3/tutorial/modules.html#importing-fr...