REPL docs?

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
Posts: 15
Joined: Mon May 12, 2014 6:13 pm

REPL docs?

Post by nsoatw » Fri May 16, 2014 6:49 am

Is there any way to see the variables/classes/objects/functions in the RPEL?
What about editing an existing function without feeding it back in?
I really like the interactive mode of programming and hope it is/will be powerful enough to prototype with.

Posts: 1155
Joined: Fri Feb 28, 2014 2:05 pm

Re: RPEL docs?

Post by pfalcon » Fri May 16, 2014 3:36 pm

What is RPEL?
Awesome MicroPython list
Pycopy - A better MicroPython
MicroPython standard library for all ports and forks -
More up to date docs -

User avatar
Posts: 3641
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada

Re: REPL docs?

Post by dhylands » Fri May 16, 2014 4:01 pm

I corrected the spelling in the title.

REPL, for the uninitiated means Read-Eval-Print-Loop.

Python has several introspection capabilities.

You can use the dir command to examine objects. For example, suppose you'd like to know which modules are implemented in pyb.

Code: Select all

>>> import pyb
>>> dir(pyb)
['__name__', 'info', 'unique_id', 'freq', 'gc', 'repl_info', 'wfi', 'disable_irq', 'enable_irq', 'stop', 'standby', 'source_dir', 'main', 'usb_mode', 'have_cdc', 'hid', 'millis', 'delay', 'udelay', 'sync', 'Timer', 'rng', 'RTC', 'Pin', 'ExtInt', 'pwm', 'servo', 'Servo', 'Switch', 'SD', 'LED', 'I2C', 'SPI', 'UART', 'ADC', 'ADCAll', 'DAC', 'Accel']
You can examine objects:

Code: Select all

>>> foo=3
>>> dir(foo)
['from_bytes', 'to_bytes']
>>> type(foo)
<class 'int'>
You can use dir with no arguments to discover what's currently defined:

Code: Select all

>>> dir()
['sys', 'LCD', '__name__', 'pyb', 'foo']

Posts: 15
Joined: Mon May 12, 2014 6:13 pm

Re: REPL docs?

Post by nsoatw » Fri May 16, 2014 4:59 pm

Thanks for the reply, REPL-coding became much easier!
Hopefully this info will also end up in the documentation soon? Or is there any other reference documentation regarding REPL?

Post Reply