Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

Getting exported methods from mpy
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Getting exported methods from mpy

by rsrole on Wed Aug 12, 2020 12:52 pm

I'm new to python so this might be a simple question. I haven't found a reliable way to get exported methods in Mu. Sometimes you can type (for instance) cp. and you get an intellisense type hint, but it might only have one entry. Of course there are many more. I haven't found anything on their site that helps.

Thanks

rsrole
 
Posts: 10
Joined: Mon Apr 01, 2019 5:49 pm

Re: Getting exported methods from mpy

by dastels on Wed Aug 12, 2020 12:56 pm

You can get a list of members in any module, class, or object by using the dir() function.

Eg
Code: Select all | TOGGLE FULL SIZE
dir(cp)

Code: Select all | TOGGLE FULL SIZE
Adafruit CircuitPython 5.3.1 on 2020-07-13; Adafruit Trinket M0 with samd21e18
>>> import board
>>> dir(board)
['A0', 'A1', 'A2', 'A3', 'A4', 'APA102_MOSI', 'APA102_SCK', 'D0', 'D1', 'D13', '
D2', 'D3', 'D4', 'I2C', 'MISO', 'MOSI', 'RX', 'SCK', 'SCL', 'SDA', 'SPI', 'TX',
'UART']                                                                         
>>>

Code: Select all | TOGGLE FULL SIZE
>>> import time                                                                 
>>> dir(time)                                                                   
['__name__', 'monotonic', 'sleep', 'struct_time']                               
>>> dir(time.struct_time)                                                       
['count', 'index']                                                             
>>>

Code: Select all | TOGGLE FULL SIZE
>>> dir(10)                                                                     
['from_bytes', 'to_bytes']                                                     
>>>


Dave

dastels
 
Posts: 3480
Joined: Tue Oct 20, 2015 3:22 pm

Re: Getting exported methods from mpy

by rsrole on Wed Aug 12, 2020 1:11 pm

Thanks. That helps a lot

rsrole
 
Posts: 10
Joined: Mon Apr 01, 2019 5:49 pm

Please be positive and constructive with your questions and comments.