Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Solved] Import syntax
#1
Hi everyone,

on https://docs.python.org/3/library/concur...or-example

we can see import concurrent.futures

is that exactly the same as from concurrent import futures

or there a difference beside the syntax ? (speed, security, options availables etc.. ?)

Thanks.
[Image: NfRQr9R.jpg]
Reply
#2
(Dec-28-2022, 06:46 AM)SpongeB0B Wrote: is that exactly the same
The only difference is that after import concurrent.futures, the name 'concurrent' will be in the current namespace, while after from concurrent import futures, it is the name 'futures' that appears in the current namespace.
Type "help", "copyright", "credits" or "license" for more information.
>>> import concurrent.futures
>>> dir()
['__annotations__', '__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__', 'concurrent']
>>> 
vs
Type "help", "copyright", "credits" or "license" for more information.
>>> from concurrent import futures
>>> dir()
['__annotations__', '__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__', 'futures']
>>>
SpongeB0B and ndc85430 like this post
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [solved] What is the best/pytonic way to import with dependency ? SpongeB0B 2 707 Jul-09-2023, 05:05 AM
Last Post: SpongeB0B
  [Solved] unkown (to me) function def parm "name1:name2" syntax. MvGulik 5 1,124 Nov-11-2022, 11:21 AM
Last Post: MvGulik
  import module with syntax error Skaperen 7 5,389 Jun-22-2021, 10:38 AM
Last Post: Skaperen
  Invalid Syntax Error on Import arjunsingh2908 3 18,473 Jul-07-2018, 05:02 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020