Summary

This example re-uses two existing transformations:

  • French Python, which uses a non-standard file extension .pyfr as an indication that an import hook must be used.

  • repeat as a keyword

French repeat

ideas logo

To produce the above image, you can use the following (files found in usage_demo directory):

from ideas.examples import french_repeat

french_repeat.add_hook()

import tortue  # noqa

and

"""tortue.pyfr"""

de turtle importer color, fd, left, pen

pen(pensize=3)

répéter 4:   # French ...
    repeat 4:  # or English ... both work.
        repeat 4:
            color('blue')
            fd(30)
            left(-90)
        color('green')
        fd(60)
        left(90)
    color('red')
    left(90)
    fd(90)


input("Press any key to quit.")

Demonstrates how we can simply combine source transformations.

ideas.examples.french_repeat.add_hook(**_kwargs)[source]

Creates and adds the import hook in sys.meta_path

ideas.examples.french_repeat.transform_source(source, **_kwargs)[source]

This function is called by the import hook loader and uses transformations from two other examples.