These are both valid examples of Python syntax and effectively doing the same thing in a slightly different way.


import microbit imports the entire module and from microbit import * is importing all the classes, functions and variables from that module, so it's just down to user preference.


Here is some more information from stack overflow:


import microbit
microbit.display.scroll('hi')


  • Pros:
    • Less maintenance of your import statements. Don't need to add any additional imports to start using another item from the module
    • You can clearly see where the function display comes from
  • Cons:
    • Typing microbit.display every time in your code can be tedious and redundant


from microbit import display
display.scroll('hi')


  • Pros:
    • Less typing to use display
    • More control over which items of a module can be accessed
  • Cons:
    • To use a new item from the module you have to update your import statement
    • It's harder to tell where display was coming from



from microbit import *
display.scroll('hi')


  • Pros:
    • Less typing to use display or any other function from within microbit.
    • No need to keep updating the import line to use other items from the microbit module.
  • Cons:
    • Unclear what you are importing and how many things you are importing
    • You completely lose context about where display was coming from


Either of the first two methods are recommended, but the third method (from microbit import *) is not recommended. This is because it is difficult to determine what items used in the code are coming from 'microbit'.