Generally you'll want to pass at least help (since this is provided as the help string for that parameter) and type (to ensure that you get the type of data you expect). Except for opt, all of these are just passed directly to argparse, so you have all the power of that module at your disposal. You can pass the following when calling Param: help, type, opt, action, nargs, const, choices, required. As a bonus, we can also use this function directly from a REPL such as Jupyter Notebook - it's not just for command line scripts! ParamĮach parameter in your function should have an annotation Param(.) (as in the example above). Test_fastscript.py: error: the following arguments are required: msgĪs you see, we didn't need any if _name_ = "_main_", we didn't have to parse arguments, we just wrote a function, added a decorator to it, and added some annotations to our function's parameters. When you run this script, you'll see: $ python examples/test_fastscript.py Upper: Param( "Convert to uppercase?", bool_arg) = False): Here's a complete example - it's provided in the fastscript repo as examples/test_fastscript.py:įrom fastscript import * call_parse def main( msg: Param( "The message", str), In fact, it's <50 lines of code! Basically, it's just a little wrapper around argparse that uses modern Python features and some thoughtful defaults to get rid of the boilerplate.
There are much fancier modules to help you write scripts (we recommend Python Fire, and Click is also popular), but fastscript is very fast and very simple. You can use argparse for this purpose, which comes with Python, but it's complex and verbose.įastscript makes life easier. But in Python, that involves a whole lot of boilerplate and ceremony, especially if you want to support command line arguments, provide help, and other niceties. Sometimes, you want to create a quick script, either for yourself, or for others. Part of fast.ai's toolkit for delightful developer experiences. Small footprint - 80-150Kb depending on used modules.A fast way to turn your python function into a script.Standard libraries for the access to the base classes, controls, forms and BD. Access to any object inside your application.Standard language set: variables, constants, procedures, functions (nested functions allowed) with var/const/defaultparameters, all the standard operators and statements (including case, try/finally/except, with), types (int, float, bool, char,string, multi-dimensional array, enum, variant), classes (with methods, events, properties, indices and default properties).For example, one module may be written in PascalScript, another one - using C++Script. You can add any procedural language (language grammar is stored in XML format). Multi-language architecture allows you to use a number of languages (at present moment PascalScript, C++Script, BasicScript, JScript).It is possible to add a new language - language definition is stored in the XML format, so you can perform it without writing a Delphi code.
#Fastscripts for windows windows
Unique feature of FastScript is ability to use several languages (PascalScript, C++Script, JScript and BasicScript), so you can write scripts using your favourite language.įastScript doesn't use Microsoft Scripting Host, so it can be used in Windows and Linux environment. FastScript is written on 100% Object Pascal and can be installed in Borland Delphi 4-7, 2005, 2006, C++Builder 4-6 and Kylix 1-3.
It is useful for the programmers who want to add scripting ability to their projects.