# Python Interfaces

**URL:** <https://forum.makecode.com/t/python-interfaces/23783>\
**Category:** Help\
**Created:** [October 30, 2023, 4:47pm UTC](https://forum.makecode.com/t/python-interfaces/23783 "2023-10-30T16:47:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![MichaelVeneziano2](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/michaelveneziano2/32/4588_2.png) [@MichaelVeneziano2](https://forum.makecode.com/u/MichaelVeneziano2)\
**Post date:** [October 30, 2023, 4:47pm UTC](https://forum.makecode.com/t/python-interfaces/23783/1 "2023-10-30T16:47:57Z")

</div>

Hi,

I am trying to create a variable with an interface as its type, then assign objects that implement that interface. This works fine in TypeScript but when I translate it to Python, I am getting a type incompatible error. With namespaces in Python a decorator is needed since Python doesn’t have namespaces as a langue feature. Is there a similar step needed here because interfaces are also not a python langue feature?

Working TS:

```auto
let currentLevel : LevelInterface = null;
let currentLevelNum = 0;
let ps = sprites.create(img`. `, SpriteKind.Player);
controller.moveSprite(ps);
scene.cameraFollowSprite(ps);
function nextLevel() {
    if (currentLevel != null){
        currentLevel.endLevel();
    }
    currentLevelNum += 1;
    if (currentLevelNum == 1) {
        currentLevel = new Level1(nextLevel, ps, 4, 4);
    } else if (currentLevelNum == 2) {
        currentLevel = new Level2(nextLevel, ps, 2, 6);
    } else {
        game.over(true);
    }
}
nextLevel();

```

Not working Python:

```auto
currentLevel: LevelInterface = None
currentLevelNum = 0
ps = sprites.create(img(""" . """),
    SpriteKind.player)
controller.move_sprite(ps)
scene.camera_follow_sprite(ps)
def nextLevel():
    global currentLevelNum, currentLevel
    if currentLevel != None:
        currentLevel.end_level()
    currentLevelNum += 1
    if currentLevelNum == 1:
        currentLevel = Level1(nextLevel, ps, 4, 4)
    elif currentLevelNum == 2:
        currentLevel = Level2(nextLevel, ps, 2, 6)
    else:
        game.over(True)
nextLevel()

```
