GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix broken python method by RDIL · Pull Request #8821 · PowerShell/PowerShell

Conversation

@RDIL

@RDIL Reece Dunham (RDIL) commented Feb 3, 2019 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

PR Summary

this doesn’t work in python, the keyword is self.

PR Context

It needs to be fixed.

PR Checklist

  • PR has a meaningful title
    • Use the present tense and imperative mood when describing your changes
  • Summarized changes
  • Change is not breaking
  • Make sure all .h, .cpp, .cs, .ps1 and .psm1 files have the correct copyright header
  • This PR is ready to merge and is not Work in Progress.
    • If the PR is work in progress, please add the prefix WIP: or [ WIP ] to the beginning of the title (the WIP bot will keep its status check at Pending while the prefix is present) and remove the prefix when the PR is ready.
  • User-facing changes
    • Not Applicable
    • OR
    • Documentation needed
      • Issue filed:
  • Testing - New and feature
    • N/A or can only be tested interactively
    • OR
    • Make sure you've added a new test if existing tests do not effectively test the code changed
      • Add [feature] to your commit messages if the change is significant or affects feature tests

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@RDIL
Fix broken python method
145be6b
@RDIL
Reece Dunham (RDIL) requested review from Hemant Mahawar (HemantMahawar), Steve Lee (SteveL-MSFT) and Joey Aiello (joeyaiello) as code owners February 3, 2019 22:15
Reece Dunham (RDIL) and others added 2 commits February 3, 2019 17:50
@RDIL
Update class1.py
1bb37b4
@RDIL
Update class1.py
f1fb21f
@iSazonov

Ilya (iSazonov) commented Feb 4, 2019

Copy link
Copy Markdown
Collaborator

Reece Dunham (@RDIL) Is this Python version related?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@RDIL

Reece Dunham (RDIL) commented Feb 4, 2019

Copy link
Copy Markdown
Contributor Author

Ilya (@iSazonov) what do you mean? I’m just fixing broken code in this PR.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@iSazonov

Ilya (iSazonov) commented Feb 4, 2019 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

I guess that the code worked on old Python version.
Perhaps we need to specify actual version in the doc.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@RDIL

Reece Dunham (RDIL) commented Feb 4, 2019

Copy link
Copy Markdown
Contributor Author

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!

iSazonov reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

TylerLeonhardt
TylerLeonhardt approved these changes Feb 4, 2019
View reviewed changes

@TylerLeonhardt TylerLeonhardt left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
TylerLeonhardt
TylerLeonhardt reviewed Feb 4, 2019
View reviewed changes
Comment thread demos/python/class1.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

rjmholt
Rob Holt (rjmholt) approved these changes Feb 4, 2019
View reviewed changes

@rjmholt Rob Holt (rjmholt) left a comment

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for 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.

Uh oh!

There was an error while loading. Please reload this page.

TylerLeonhardt and RDIL reacted with thumbs up emoji
All reactions
  • 👍 2 reactions
@iSazonov Ilya (iSazonov) self-assigned this Feb 5, 2019
@iSazonov Ilya (iSazonov) added the CL-Docs Indicates that a PR should be marked as a documentation change in the Change Log label Feb 5, 2019
@iSazonov

Ilya (iSazonov) commented Feb 5, 2019

Copy link
Copy Markdown
Collaborator

Steve Lee (@SteveL-MSFT) Make sense to move this to Docs repo?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@iSazonov
Ilya (iSazonov) merged commit bff73a3 into PowerShell:master Feb 5, 2019
@RDIL
Reece Dunham (RDIL) deleted the patch-10 branch February 5, 2019 12:32
@SteveL-MSFT

Steve Lee (SteveL-MSFT) commented Feb 5, 2019

Copy link
Copy Markdown
Member

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

iSazonov reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
@RDIL @iSazonov
Fix broken python method (PowerShell#8821)
a82b564
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@HemantMahawar Hemant Mahawar (HemantMahawar) Awaiting requested review from HemantMahawar
@joeyaiello Joey Aiello (joeyaiello) Awaiting requested review from joeyaiello
@SteveL-MSFT Steve Lee (SteveL-MSFT) Awaiting requested review from SteveL-MSFT
2 more reviewers
@TylerLeonhardt TylerLeonhardt TylerLeonhardt approved these changes
@rjmholt Rob Holt (rjmholt) rjmholt approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@iSazonov Ilya (iSazonov)

Labels

CL-Docs Indicates that a PR should be marked as a documentation change in the Change Log

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@RDIL @iSazonov @SteveL-MSFT @TylerLeonhardt @rjmholt
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.