Simple questions?

As a beginner I read in the top of a Pi Pico program often (example) "from picographics import PicoGraphics, DISPLAY_PICO_EXPLORER or “from machine import ADC”
What does from and import mean? Obviously something is imported out of a module picographics or from a machine. But where do I find picographics and machine .
In the last example ADC is imported from machine. How did the programmer know what he had to import? Is there anywhere a list of possibilities?

I also read sometimes only “import utime” or “import time”
Why not “from xxx import time” ?

Coming back to the first question above: "from picographics import PicoGraphics, DISPLAY_PICO_EXPLORER then I should understand that the program wherein this line is used can handle display.set_pen or display.clear() etc. or are these instructions something else?
There must exist a list of all possible display.xxx be specified and how to use them.
This is because I found an example with at the end :

Display some text

display.text("hello", 0, 0)

That worked, but I liked to exchange “hello” by a variable name A used in that program.
So I changed this line by display.text(A, 0, 0). I know A is not a text and have to find another solution for it.

Maybe you may help me a bit further.

I’m far from any kind of expert, but I think I can explain some of it. Those imports etc are stored on the Pico. They are part and parcel of the uf2 file you flash the Pico with. The stock micro python uf2 has all the Micro Python modules etc in it. Custom uf2 files, like the ones Pimoroni supplies also have Pico Graphics and other Pimoroni Modules contained in them.
Getting Started with Raspberry Pi Pico
MicroPython - Python for microcontrollers
pimoroni-pico/micropython/modules/picographics at main · pimoroni/pimoroni-pico

Thank you. The link to MicroPython - Python for microcontrollers had I not yet visited. It is going to the site Micropython.org. I was focussing on the understanding of Modules. Where can I find/read which Modules are available, so that I am able to know what these Modules can do for me within Micropython and which function or keyword they have available
Example: At the top of a program I read:

  • from machine import Pin
  • from time import sleep
    This means that machine and time exist as a module and that I can use Pin and sleep as the keywords.
    So I need an overview with all available Modules and their keywords with a small example of each keyword how to use them.

I’m thinking this is one place to go.
Overview — MicroPython latest documentation

Yes, there is the Python Module Index and more what I was looking for. Necessary to make the first steps into the world of the Pi Pico. Thanks.

1 Like