GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||
GeezerVison is showing github.com — Fix broken python method by RDIL · Pull Request #8821 · PowerShell/PowerShell Conversation
|
|
Reece Dunham (@RDIL) Is this Python version related? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Ilya (@iSazonov) what do you mean? I’m just fixing broken code in this PR. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
I guess that the code worked on old Python version. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
The code clearly defines that the script should use a python 3.x.x version, but the this keyword hasn’t been a thing since the 2.5 series. I think it is time to update! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Worth noting that neither this nor self are keywords in Python; instance methods in Python pass the instance reference explicitly through the first parameter, and you can call that parameter whatever you like (you don't even need to be consistent):
class MyObject: def __init__(banana): banana.field = 10 def get_field(truck): return truck.field if __name__ == '__main__': print(MyObject().get_field()) # prints '10'
So this Python script would have run correctly using this.
However, self is the near-universal convention, and worth us aligning to that, especially in our examples. Thanks Reece Dunham (@RDIL)!
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Steve Lee (@SteveL-MSFT) Make sense to move this to Docs repo? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Ilya (@iSazonov) We may want to eventually have a doc page about interop with other languages, but we can keep this code here in this repo for now |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.