Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blocks: "change <variable> by" block causes import error #45

Open
jaustin opened this issue Mar 20, 2017 · 2 comments
Open

Blocks: "change <variable> by" block causes import error #45

jaustin opened this issue Mar 20, 2017 · 2 comments
Labels

Comments

@jaustin
Copy link
Contributor

jaustin commented Mar 20, 2017

The 'change variable by' block causes the following import statement to be emitted:
from numbers import Number

Which in turn causes an ImportError on the device.

It also generates rather confusing code:

count = (count if isinstance(count, Number) else 0) + -1

See the following program as an example of failure:
image

@ntoll
Copy link
Contributor

ntoll commented Mar 20, 2017

Ugh... that's horrible. 😱

I know how to fix it but it'll mean faffing about with the XML menu and creating a new block. It's probably also something that should be addressed in the "upstream" PyBlocks project run by the esteemed @carlosperate.

@carlosperate
Copy link
Contributor

Yes, that is one of the disadvantages of blockly trying to generate "always valid" code, it sometimes end ups generating verbose and ugly code as well. One of the next things I wanted to do is extract the default blocks (for reasons of compability with blockly and scratch-blocks) and extend them or make them a bit more pythonic.
Taking in consideration we are going to find a few things like this I think the best way forward would be to overwrite the "change by" block generator in the microbit instance.

@jaustin jaustin added the bug label Mar 24, 2017
microbit-sam added a commit to microbit-sam/PythonEditor that referenced this issue Aug 6, 2019
* Updated CI config - WIP

* Added comments to ./bin/deploy

* add cleanup script

* Spelling

* Review suggestions. (bbcmicrobit#45)

- Clearer filter.
- Bash script with options motivated by safety.

* Remove echo from delete bucket

* Add clean up to CI

* Upgrade jessie->stretch

* Push branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants