Quickstart#

Note

This is a quick guide for beginners to start using PySPL. For the full API documentation, see the section API Documentation.

Installation#

To use PySPL, first install it using pip:

(.venv) $ pip install py2spl

Getting Started#

import pyspl

First enter this piece of code shown above. You import the module using this.

Note

If your type checker does not like that, you can instead use the following to import PySPL:

from py2spl import pyspl

Then enter:

play = pyspl.Play('Hi? Hi.')

hamlet = play.character('Hamlet', 'a male.')
juliet = play.character('Juliet', 'a female.')

class ActI(pyspl.Act):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.add_scene(self.sceneI, 'I', 'The Only Scene.')

def sceneI(self):
    self.enter(hamlet, juliet)
    self.set(juliet, pyspl.sum(64, 8))
    self.print(juliet, str)
    self.set(hamlet, pyspl.sum(juliet, pyspl.sum(32, 1)))
    self.print(hamlet, str)
    self.exit()

We added two characters to the program, then written a program to print Hi using the ASCII codes.

Then add:

play.save('./play.spl')

You should then install the latest version of zmbc’s SPL interpreter, which is written in Python (if you haven’t yet):

$ git clone https://github.com/zmbc/shakespearelang && pip install ./shakespearelang

You can then run your SPL play by using the following command in your console:

$ shakespeare run ./play.spl

If it doesn’t work, using the following command might work:

$ python -m shakespeare run ./play.spl