How can I know an instance is necessary to work module?

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
forester3
Posts: 22
Joined: Sat Oct 21, 2017 5:01 am

How can I know an instance is necessary to work module?

Post by forester3 » Tue Jun 26, 2018 11:08 am

Hi,
I have a question.
How can I know an instance is necessary to work module?

For example,
pyb.Pin.board.LED.on()
This will work without an instance.

However,
pyb.RTC.datetime()
This dose not work.
rtc = pyb.RTC()
rtc.datetime()
This works.

I can imagine that this difference depends on how to make a module.
How people who do not see the source of the module can find this diffrence?

User avatar
deshipu
Posts: 1388
Joined: Thu May 28, 2015 5:54 pm

Re: How can I know an instance is necessary to work module?

Post by deshipu » Tue Jun 26, 2018 11:35 am

We read the documentation.

forester3
Posts: 22
Joined: Sat Oct 21, 2017 5:01 am

Re: How can I know an instance is necessary to work module?

Post by forester3 » Wed Jun 27, 2018 10:50 am

Thank you, for your ans.

I have known pyb.RTC() sample code in documents.
However, there are many module functions without sample code in documents.

I felt uneasy and asked a question.

kevinkk525
Posts: 969
Joined: Sat Feb 03, 2018 7:02 pm

Re: How can I know an instance is necessary to work module?

Post by kevinkk525 » Wed Jun 27, 2018 2:11 pm

If you ask about a module without documentation, you might get an answer. But theser are documented.
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode

Post Reply