Python to RPN
A Python to HP42S RPN converter website www.pyrpn.atug.com
Allows you to program your old vintage HP Calculator in Python!
See also my blog post How I used the Python AST capabilities to build a Python to Rpn converter.
You write code in a high level structured language (which happens to be Python 3 syntax), hit a button and RPN is generated.
You then paste the RPN into Free42 or transfer it to your DM42 (by creating a raw) - and it runs.
- Examples: http://www.pyrpn.atug.com/examples
- User Guide: http://www.pyrpn.atug.com/help
- Canvas for 42S Simulator: http://www.pyrpn.atug.com/canvas
- List of HP42S Commands Supported Reference: http://www.pyrpn.atug.com/cmds
The converter supports core Python syntax (which is very powerful), but does not implement the built in Python libraries that you would get in desktop Python. You have to rely on the ability to call HP42S commands from Python to do your work - which of course you can do. Specifically, it has the following capabilities:
- Variables
- Functions, Multiple functions, nested functions
- Parameter passing, receiving return values, multiple return values
- if elif else
- Comparison operators == != > < >= <=
- Booleans True, False and operators not or and
- for loops, range(), for..in iteration through lists and dictionary keys
- while loops, while…else
- continue and break operations in for loops and while loops
- Lists and Dictionaries (basic operations only).
- Matrices, Pythonic matrix element access syntax [row,col]
- NumPy compatible slicing syntax for sub-matrices
- Complex numbers using either 42S or Python native syntax
- Expressions involving nested brackets
- assert
- Testing and clearing of flags
- Access most HP42S commands as function calls e.g. FIX(2)
- Some enhanced functions to make life easier e.g. varmenu() automates and simplifies the generation of MVAR based code.
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.