This syntax seems easier to use:
import foo only bar to mean from foo import bar rationale:
import foo
import foo except bar
import foo only bar
EDIT : or, without introducing a new keyword:
import foo
import foo : bar
import foo : bar1, bar2
import foo : nil
import foo as foo2 : bar3 as bar3_alias, bar4
I know it comes from python but IMO we can do better here (cf D's import foo:bar)
@dom96
As much as I like import foo.bar, Araq is right, it has different meaning already. However, I'm not sure if it's a good practice to have a submodule named the same as one of the module's own entities so maybe it's fine to have two meanings to that?
Well, I don't think from x import y should be depreciated just like do-notation shouldn't be depreciated just because we have =>. Both serve well and while I guess everybody has some preferences here (I prefer =>, for instance), it doesn't invalidate the other solution.
So it would be:
import foo
import foo only bar
import foo only bar1, bar2
import foo only nil
import foo as foo2 only bar3
EDIT or without introducing a new keyword:
import foo
import foo : bar
import foo : bar1, bar2
import foo : nil
import foo as foo2 : bar3 as bar3_alias, bar4
and the pre-existing syntax would NOT be depracated.
Well, I don't think from x import y should be depreciated just like do-notation shouldn't be depreciated just because we have =>
This is off-topic but I think do should be deprecated, mainly because it doesn't fit the language. I've been saying this for a while.
Looking at this thread again I agree with Araq. from foo import bar matches Python, and we shouldn't have more than one way to do the same thing, especially at the cost of a keyword.