Is there a way to combine import and from import in one statement?
Can:
from random import choice
import random
be combined into one statement?
No, they can't.
See the import
statement grammar:
import_stmt ::= "import" module ["as" name] ( "," module ["as" name] )* | "from" relative_module "import" identifier ["as" name] ( "," identifier ["as" name] )* | "from" relative_module "import" "(" identifier ["as" name] ( "," identifier ["as" name] )* [","] ")" | "from" module "import" "*"
The import module
and from relative_module import
forms are two entirely separate forms in the grammar.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With