Page 1 of 1

REPL docs?

Posted: Fri May 16, 2014 6:49 am
by nsoatw
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.

Re: RPEL docs?

Posted: Fri May 16, 2014 3:36 pm
by pfalcon
What is RPEL?

Re: REPL docs?

Posted: Fri May 16, 2014 4:01 pm
by dhylands
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']

Re: REPL docs?

Posted: Fri May 16, 2014 4:59 pm
by nsoatw
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?