What does Sprite = None mean?

Hi, I am learning / teaching python using Makecode Arcade. I’m trying to understand what the generated code means by “Ballie: Sprite = None”.

What does Sprite = None even mean?

Code in Python:

@namespace
class SpriteKind:
    Ball = SpriteKind.create()

def Make_Ball_Sprite():
    global Ballie
    Ballie = sprites.create(img("""
            . . . . . b b b b b b . . . . . 
                    . . . b b 9 9 9 9 9 9 b b . . . 
                    . . b b 9 9 9 9 9 9 9 9 b b . . 
                    . b b 9 d 9 9 9 9 9 9 9 9 b b . 
                    . b 9 d 9 9 9 9 9 1 1 1 9 9 b . 
                    b 9 d d 9 9 9 9 9 1 1 1 9 9 9 b 
                    b 9 d 9 9 9 9 9 9 1 1 1 9 9 9 b 
                    b 9 3 9 9 9 9 9 9 9 9 9 1 9 9 b 
                    b 5 3 d 9 9 9 9 9 9 9 9 9 9 9 b 
                    b 5 3 3 9 9 9 9 9 9 9 9 9 d 9 b 
                    b 5 d 3 3 9 9 9 9 9 9 9 d d 9 b 
                    . b 5 3 3 3 d 9 9 9 9 d d 5 b . 
                    . b d 5 3 3 3 3 3 3 3 d 5 b b . 
                    . . b d 5 d 3 3 3 3 5 5 b b . . 
                    . . . b b 5 5 5 5 5 5 b b . . . 
                    . . . . . b b b b b b . . . . .
        """),
        SpriteKind.Ball)
    Ballie.set_velocity(100, 100)
    Ballie.set_position(80, 0)
    Ballie.set_stay_in_screen(False)
    Ballie.set_bounce_on_wall(True)

Ballie: Sprite = None
Make_Ball_Sprite()

Code in Blocks:

1 Like

All variables in Blocks are global variables. Your variable, Ballie, is created in the “main” portion of your Python program (it’s the equivalent to on start in blocks) to make it a global variable. Because you don’t assign it a value in on start, it is set to None (the Python equivalent to null in other programming languages).

2 Likes