microsoft / microsoft/pxt

Help text for Python seems to be incorrect?

Open
#8,252 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
2.3k
Forks
641
Avg merge
12h 4m
Merged PRs (30d)
57

Description

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 the greet method. 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 private isn't right. Firstly it should be Animal("Cat").__name and 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 employee to animal. 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
image

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

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

Additional context
N/A

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with common-docs/python/classes.md and review the class members, visibility discussion, and structural-typing section against Python behavior and the reported Micro:bit/MakeCode context. Done means resolving which claims are inaccurate and correcting the affected help text without changing unrelated documentation.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.