microsoft / microsoft/pxt-microbit
nested namespaces don't work in Python
Open
Nobody has claimed this yet.
P2
python
tsToPy
- Dominant language
- TypeScript
- Stars
- 804
- Forks
- 721
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 2
Description
This typescript:
namespace foo {
export const baz = 42
export namespace bar {
export const baz2 = 84
}
}
input.onButtonPressed(Button.A, function on_button_pressed_a() {
basic.showNumber(foo.bar.baz2)
})
converts to this python:
@namespace
class foo:
baz = 42
@namespace
class bar:
baz2 = 84
def on_button_pressed_a():
basic.show_number(foo.bar.baz2)
input.on_button_pressed(Button.A, on_button_pressed_a)
with these errors:

Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the nested namespace example and comparing the generated Python with the reported output and errors. The work is done when the example converts and runs without errors while preserving access to foo.bar.baz2.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100