1

Can I know the right answer? Example.

from random import*
for i in range(15):                     
    print random.randrange(3,13,3)
Myat Thiha
  • 31
  • 1
  • 8
  • 1
    Please clarify what you mean by "file size". The literal file size is determined by the number of characters in your file, regardless of what they mean. – MisterMiyagi Sep 24 '19 at 08:27
  • 1
    Hello and welcome to SO. You may want to read about [Python's import mechanism](https://docs.python.org/3/reference/import.html) and more generally [Python's execution model](https://docs.python.org/3/reference/executionmodel.html). – bruno desthuilliers Sep 24 '19 at 08:32
  • I want to know import* can decrease the run time on memory?.I means which can faster the run time on memory,the use of import * or without the use of import*? – Myat Thiha Sep 24 '19 at 10:39

1 Answers1

3

The import doesn't affect the file size (i.e. you don't include the source code of what is imported into your file if that is what you think). No matter how you import during execution the whole imported module is well "imported/processed". The effects are mainly on the namespace. And finally from foo import * is considered bad practice, so don't do it....

You can read:

Use 'import module' or 'from module import'?

and

Why is "import *" bad?

buran
  • 13,682
  • 10
  • 36
  • 61
  • Thanks. And I want to know import* can decrease the run time on memory?.I means which can faster the run time on memory,the use of import * or without the use of import*? – Myat Thiha Sep 24 '19 at 10:37
  • I am afraid `run time on memory` doesn't make much sense. As already explained the whole module will be processed regardless of how you import. You really may want to check links provided by @brunodesthulliers in the comments. – buran Sep 24 '19 at 10:55
  • Ok. Thanks a million. – Myat Thiha Sep 25 '19 at 02:15