pxt
pxt copied to clipboard
Help text for Python seems to be incorrect?
Python Help Text
Describe the bug https://github.com/microsoft/pxt/blob/master/common-docs/python/classes.md
seems to have a few inaccuracies. I original filed a PR to fix them, but alas I have to withdraw it as my company doesn't allow me to sign the CLA - sorry about that!
I'm no Python expert, so let me know if I have this wrong, but...
- Several classes have members defined like
greeting = "". These are static members, so they're actually not getting used by the constructor and thegreetmethod. They can be removed. - The discussion on public/private/protected isn't quite right. There's nothing stopping you accessing any of the members in Python. The only thing is that prepending
__causes the name to be mangled so you have to do__ClassName__method. The use of_for protected and__for private is just a convention. The error message in the comment# Error: 'name' is privateisn't right. Firstly it should beAnimal("Cat").__nameand secondly the error will be "object has no attribute __name" or something similar. - The section on structural typing isn't right I think. As as far as I know there's no reason why you can't assign the value of
employeetoanimal. It's just a reference and is dynamically typed. [Or have I misunderstood and is Microbit Python a little 'non-standard' due to it needing to convert to/from JS? I've tried to test out the code in MakeCode but have been running into issues like https://github.com/microsoft/pxt-microbit/issues/4201]
To Reproduce N/A
Expected behavior
N/A
Screenshots

Desktop (please complete the following information): N/A
Smartphone (please complete the following information): N/A
Additional context N/A