# Python externs

**URL:** <https://community.haxe.org/t/python-externs/2368>\
**Category:** Haxe\
**Tags:** haxe-python\
**Created:** [April 18, 2020, 4:21pm UTC](https://community.haxe.org/t/python-externs/2368 "2020-04-18T16:21:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![damoebius](https://community.haxe.org/user_avatar/community.haxe.org/damoebius/32/73_2.png) [@damoebius](https://community.haxe.org/u/damoebius)\
**Post date:** [April 18, 2020, 4:21pm UTC](https://community.haxe.org/t/python-externs/2368/1 "2020-04-18T16:21:55Z")

</div>

Hi there,  
It’s been a long time…  
My wife recently offered a “[vector](https://www.anki.com/en-us/vector)”, a little cute robot that i can program.  
Sadly the only [SDK](https://developer.anki.com/vector/docs/index.html) available is in Python.

Here is a litle piece of code i want to do in Haxe

```haxe
import anki_vector

def main():
    args = anki_vector.util.parse_command_args()
    with anki_vector.Robot(args.serial) as robot:
        robot.behavior.say_text("haxe power")

if __name__ == " __main__":
    main()

```

And this is my miserable attempt

```haxe
class Main {
    static public function main():Void {
      trace("Hello World");
      var robot = new Robot();
    }
  }

@:pythonImport("anki_vector")
@:native("anki_vector.Robot")
extern class Robot {
  public function new();
}

```

My problem is that the generated code doesn’t import the anki\_vector as i want.

```haxe
import anki_vector as anki_vector_Robot

```

any help will be appreciated 😔

---

<div class="post-metadata">

**Author:** ![ibilon](https://community.haxe.org/user_avatar/community.haxe.org/ibilon/32/13_2.png) [@ibilon](https://community.haxe.org/u/ibilon)\
**Post date:** [April 18, 2020, 4:36pm UTC](https://community.haxe.org/t/python-externs/2368/2 "2020-04-18T16:36:24Z")

</div>

Doing

```haxe
@:pythonImport("anki_vector.Robot")
extern class Robot {
  public function new();
}

```

gives me `import anki_vector.Robot as Robot`, that should work I guess.

---

<div class="post-metadata">

**Author:** ![damoebius](https://community.haxe.org/user_avatar/community.haxe.org/damoebius/32/73_2.png) [@damoebius](https://community.haxe.org/u/damoebius)\
**Post date:** [April 19, 2020, 9:01am UTC](https://community.haxe.org/t/python-externs/2368/3 "2020-04-19T09:01:53Z")

</div>

Thank you Valention but it doesn’t work

```haxe
ModuleNotFoundError: No module named 'anki_vector.Robot'

```

---

<div class="post-metadata">

**Author:** ![ibilon](https://community.haxe.org/user_avatar/community.haxe.org/ibilon/32/13_2.png) [@ibilon](https://community.haxe.org/u/ibilon)\
**Post date:** [April 19, 2020, 10:55am UTC](https://community.haxe.org/t/python-externs/2368/4 "2020-04-19T10:55:21Z")

</div>

Then it seems Robot is not a module then.

This might work: (I assumed serial was a boolean, might not be)

```haxe
class Main {
	static public function main():Void {
		var robot = AnkiVector.Robot(false);
		robot.behavior.say_text("haxe power");
	}
}

@:pythonImport("anki_vector")
@:native("anki_vector")
extern class AnkiVector {
	public static function Robot(serial:Bool):Robot;
}

extern class Robot {
	public var behavior:Behavior;
}

extern class Behavior {
	public function say_text(msg:String):Void;
}

```

Note that in python the `with` probably calls some dispose function or something at the end of the block that’s not done here.
