Some extra details:
micropython-lib needs some attention. It provides four things:
- some libraries that are used as part of the core firmware (e.g. urequests, uasyncio)
- some libraries that are similar but different and incompatible to ones used in the core firmware (e.g. upip)
- some libraries that extend the functionality in the core firmware (random being a good example, it extends the built-in urandom)
- some libraries that are only for the unix port and provide access to functionality provided by existing linux libraries.
I'd quite like to split out the four things and have it become just the third thing.
So in your case (as previously explained):
- Any builtin library is usually named "ufoo", but is always aliased to "foo".
- If you create a file on the device "foo.py", then it will be imported preferentially to ufoo when you write "import foo". But foo.py can use ufoo in it's implementation (this is the case for random -- it starts with "from ufoo import *")
- If you want to use the extra functionality provided by the micropython-lib version, you can copy https://github.com/micropython/micropyt ... /random.py
to your device (or use upip to install it).
The surprising part though, that maybe would have avoided this confusion in the first place is that somehow "urandom" isn't listed in the documentation http://docs.micropython.org/en/latest/l ... -libraries
I have raised https://github.com/micropython/micropython/issues/5518
to track this.
Another point is that different ports will have different methods available. This is the MICROPY_PY_URANDOM_EXTRA_FUNCS you'll see if you look at modurandom.c. So ESP32 and STM32 have these methods, but (for example) ESP8266 won't.