-
Notifications
You must be signed in to change notification settings - Fork 4.3k
[New Entry/ Edits] Python Builtin-Functions: super()/ Inheritance
#1008
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
Conversation
|
Added the super() term as discussed in issue #586
|
super()/
super()/ super()/ Inheritance
@beverand Thanks for submitting this PR! I'm looking forward to conducting the first review for this 😄 Quick tip: For your next PR, if you write "Closes #[this issue number]" (per the GitHub docs) in the "Description" near the top of the PR, the related issue will be linked to the PR. (No worries for this one, though; just edited the description 😎) |
Dusch4593
left a comment
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.
@beverand Finished with my review and just left some comments/suggestions for you to check out. I might have more later but I wanted to give you a chance to look at what I have so far. Let me know if you have any questions. 😄
content/python/concepts/built-in-functions/terms/super/super.md
Outdated
Show resolved
Hide resolved
content/python/concepts/built-in-functions/terms/super/super.md
Outdated
Show resolved
Hide resolved
| ## Example | ||
| In this case, the `.say_hi()` method is implemented utilizing `super()` inside `.intro()`: | ||
|
|
||
| ```py |
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.
| ```py | |
| ```codebyte/python |
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.
Updated!
| @@ -0,0 +1,53 @@ | |||
| --- | |||
| Title: 'super()' | |||
| Description: 'implicitly refer to the superclass' | |||
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.
| Description: 'implicitly refer to the superclass' | |
| Description: 'Returns a temporary object that allows a given class to inherit the methods and properties of a parent or sibling class.' |
Let's make sure to use capitalization and punctuation. 😄
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.
Updated
|
Thank you so much for the review. I didn't think it was going to be perfect
so I was fully anticipating that corrections would need to be made. I will
try to get these modifications in tonight and resubmit.
…On Fri, Sep 16, 2022 at 2:27 PM Brandon Dusch ***@***.***> wrote:
***@***.**** requested changes on this pull request.
@beverand <https://github.com/beverand> Finished with my review and just
left some comments/suggestions for you to check out. I might have more
later but I wanted to give you a chance to look at what I have so far. Let
me know if you have any questions. 😄
------------------------------
In content/python/concepts/built-in-functions/terms/super/super.md
<#1008 (comment)>:
> @@ -0,0 +1,53 @@
+---
+Title: 'super()'
+Description: 'implicitly refer to the superclass'
+Subjects:
+ - 'Computer Science'
⬇️ Suggested change
- - 'Computer Science'
+ - 'Computer Science'
+ - 'Data Science'
Since Python is commonly used in data science.
------------------------------
In content/python/concepts/built-in-functions/terms/super/super.md
<#1008 (comment)>:
> @@ -0,0 +1,53 @@
+---
+Title: 'super()'
+Description: 'implicitly refer to the superclass'
+Subjects:
+ - 'Computer Science'
+Tags:
+ - 'Functions'
+ - 'Objects'
+ - 'Inheritance'
+CatalogContent:
+ - 'learn-python-3'
+ - 'paths/computer-science'
+---
+
+The `super()` function is built into python and is used to refer to the the superclass of an object without specifically using the parent name.
⬇️ Suggested change
-The `super()` function is built into python and is used to refer to the the superclass of an object without specifically using the parent name.
+The **`super()`** function returns a temporary object that allows a given [class](https://www.codecademy.com/resources/docs/python/classes) to [inherit](https://www.codecademy.com/resources/docs/python/inheritance) the methods and properties of a parent or sibling class.
------------------------------
In content/python/concepts/built-in-functions/terms/super/super.md
<#1008 (comment)>:
> +---
+
+The `super()` function is built into python and is used to refer to the the superclass of an object without specifically using the parent name.
+
+## Syntax
+
+```pseudo
+super().function()
+super(type)
+```
+
+## `super()`
+
+`super()` returns a temporary object of the superclass, allowing the superclass’s methods to be called. This comes in handy when using [multiple inheritance](#multiple-inheritance).
+
+## Example
⬇️ Suggested change
-## Example
+## Codebyte Example
Let's allow one empty line above and below each header.
------------------------------
In content/python/concepts/built-in-functions/terms/super/super.md
<#1008 (comment)>:
> +
+## Syntax
+
+```pseudo
+super().function()
+super(type)
+```
+
+## `super()`
+
+`super()` returns a temporary object of the superclass, allowing the superclass’s methods to be called. This comes in handy when using [multiple inheritance](#multiple-inheritance).
+
+## Example
+In this case, the `.say_hi()` method is implemented utilizing `super()` inside `.intro()`:
+
+```py
⬇️ Suggested change
-```py
+```codebyte/python
------------------------------
In content/python/concepts/built-in-functions/terms/super/super.md
<#1008 (comment)>:
> +
+The output would be:
+
+```shell
+Hi! I am a Programming Language.
+Python here!
+```
⬇️ Suggested change
-
-The output would be:
-
-```shell
-Hi! I am a Programming Language.
-Python here!
-```
If we choose to go with a Codebyte example, then these lines can be
omitted; the output will appear on the screen after the code is run.
------------------------------
In content/python/concepts/inheritance/inheritance.md
<#1008 (comment)>:
> @@ -68,28 +68,6 @@ Python here!
**Note**: Inside the child class, the same number and type of arguments need to be passed into the parent class' method.
⬇️ Suggested change
-**Note**: Inside the child class, the same number and type of arguments need to be passed into the parent class' method.
+> **Note:** Inside the child class, the same number and type of arguments need to be passed into the parent class' method.
------------------------------
In content/python/concepts/built-in-functions/terms/super/super.md
<#1008 (comment)>:
> + - 'Functions'
+ - 'Objects'
+ - 'Inheritance'
⬇️ Suggested change
- - 'Functions'
- - 'Objects'
- - 'Inheritance'
+ - 'Classes'
+ - 'Functions'
+ - 'Inheritance'
+ - 'Methods'
+ - 'Objects'
+ - 'OOP'
------------------------------
In content/python/concepts/built-in-functions/terms/super/super.md
<#1008 (comment)>:
> @@ -0,0 +1,53 @@
+---
+Title: 'super()'
+Description: 'implicitly refer to the superclass'
⬇️ Suggested change
-Description: 'implicitly refer to the superclass'
+Description: 'Returns a temporary object that allows a given class to inherit the methods and properties of a parent or sibling class.'
Let's make sure to use capitalization and punctuation. 😄
------------------------------
In content/python/concepts/built-in-functions/terms/super/super.md
<#1008 (comment)>:
> +---
+
+The `super()` function is built into python and is used to refer to the the superclass of an object without specifically using the parent name.
+
+## Syntax
+
+```pseudo
+super().function()
+super(type)
+```
+
+## `super()`
+
+`super()` returns a temporary object of the superclass, allowing the superclass’s methods to be called. This comes in handy when using [multiple inheritance](#multiple-inheritance).
+
+## Example
Also let's rename this to "Codebyte Example" since Python is a supported
language for runnable code snippets
<https://help.codecademy.com/hc/en-us/articles/1260806285369-Codebytes>
(which is compatible with Codecademy Docs 😄)
------------------------------
In content/python/concepts/inheritance/inheritance.md
<#1008 (comment)>:
> @@ -68,28 +68,6 @@ Python here!
**Note**: Inside the child class, the same number and type of arguments need to be passed into the parent class' method.
Also, near the top on line # 16, can we *bold* the word "Inheritance"?
—
Reply to this email directly, view it on GitHub
<#1008 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEZUG6WHXZNSDMRI3GVT4E3V6TQ5VANCNFSM6AAAAAAQOCNCAQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
This reverts commit 4e8541e.
|
Thank you for your patience helping me. I admit, I'm using vi in the terminal for all of my edits. |
I'm always happy to help 😄 and kudos for working with the repo through the |
|
@beverand Would you be open to trying to format the entry on your side with the following command when you get a chance? |
And then |
|
I think there are things I have to install to make that work
…On Fri, Sep 16, 2022 at 4:21 PM Brandon Dusch ***@***.***> wrote:
@beverand <https://github.com/beverand> Would you be open to trying to
format the entry on your side with the following command when you get a
chance?
yarn format content/python/concepts/built-in-functions/terms/super/super.md content/python/concepts/inheritance/inheritance.md
—
Reply to this email directly, view it on GitHub
<#1008 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEZUG6XITOB5UZ2QZW3QWLTV6T6F7ANCNFSM6AAAAAAQOCNCAQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
|
I am getting errors. Something with prettier or something with Arborist.
On Fri, Sep 16, 2022 at 4:31 PM Beverly Andrews ***@***.***>
wrote:
… I think there are things I have to install to make that work
On Fri, Sep 16, 2022 at 4:21 PM Brandon Dusch ***@***.***>
wrote:
> @beverand <https://github.com/beverand> Would you be open to trying to
> format the entry on your side with the following command when you get a
> chance?
>
> yarn format content/python/concepts/built-in-functions/terms/super/super.md content/python/concepts/inheritance/inheritance.md
>
> —
> Reply to this email directly, view it on GitHub
> <#1008 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AEZUG6XITOB5UZ2QZW3QWLTV6T6F7ANCNFSM6AAAAAAQOCNCAQ>
> .
> You are receiving this because you were mentioned.Message ID:
> ***@***.***>
>
|
Any chance you could copy/paste the exact error message here? |
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.
Hey @beverand! I found a few last areas for suggestions and comments on my end before we merge. After you've implemented this last batch of feedback and @KTom101 and I approve the changes, we should be good for merge. 😄
Btw, I just wanna give you kudos for the work you've put into this PR this week. This is an incredibly important and oft-used Python function that has a lot packed into it. Major props! We can't wait for your contribution to come alive when it gets merged! 🚀
| super(type, object) | ||
| ``` | ||
|
|
||
| `.method()` is the accessed method of the parent class. `type` specifies the type object of the parent class and object is an instance or subtype of the `type`. |
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.
| `.method()` is the accessed method of the parent class. `type` specifies the type object of the parent class and object is an instance or subtype of the `type`. | |
| The `type` specifies the object type of the parent class and `object` is an instance or subtype of the `type`. | |
| The `super()` function is commonly applied to a single-inheritance class hierarchy: |
content/python/concepts/built-in-functions/terms/super/super.md
Outdated
Show resolved
Hide resolved
|
|
||
| `super()` returns a temporary object of the superclass, allowing the superclass’s methods to be called. This comes in handy when using multiple inheritance to derive a class from more than one base class. | ||
|
|
||
| ## Codebyte Example |
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.
Just one Codebyte example + snippet per entry. Since both snippets produce the same output, I would suggest using one Codebyte snippet that implement both syntaxes.
content/python/concepts/built-in-functions/terms/super/super.md
Outdated
Show resolved
Hide resolved
content/python/concepts/built-in-functions/terms/super/super.md
Outdated
Show resolved
Hide resolved
KTom101
left a comment
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.
@beverand Added a few more changes, mainly concerning the second codebyte. We only want one codebyte on the page and it should be at the end. I've added changes to reflect that.
content/python/concepts/built-in-functions/terms/super/super.md
Outdated
Show resolved
Hide resolved
content/python/concepts/built-in-functions/terms/super/super.md
Outdated
Show resolved
Hide resolved
content/python/concepts/built-in-functions/terms/super/super.md
Outdated
Show resolved
Hide resolved
content/python/concepts/built-in-functions/terms/super/super.md
Outdated
Show resolved
Hide resolved
content/python/concepts/built-in-functions/terms/super/super.md
Outdated
Show resolved
Hide resolved
content/python/concepts/built-in-functions/terms/super/super.md
Outdated
Show resolved
Hide resolved
Co-authored-by: KTom101 <kyrathompson@me.com>
Co-authored-by: KTom101 <kyrathompson@me.com>
…xample" Co-authored-by: KTom101 <kyrathompson@me.com>
Co-authored-by: KTom101 <kyrathompson@me.com>
Co-authored-by: KTom101 <kyrathompson@me.com>
Co-authored-by: KTom101 <kyrathompson@me.com>
Co-authored-by: KTom101 <kyrathompson@me.com>
Co-authored-by: KTom101 <kyrathompson@me.com>
Co-authored-by: Brandon Dusch <brandondusch@gmail.com>
Co-authored-by: Brandon Dusch <brandondusch@gmail.com>
Dusch4593
left a comment
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.
Hey @beverand! Thank you very much for the last batch of changes 😄 I think everything looks good from my end. I applied some changes that I wanted to let you know about:
- Added two subsections under "Syntax" that describe how both syntaxes (with and without arguments) can be applied inside and outside a class definition.
- Changed the example section into a Codebyte.
- Removed "## super" heading and text that originally came from the Python concept entry about inheritance.
KTom101
left a comment
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.
@beverand @Dusch4593 The new changes look great! 👍
|
Live links are up! |
…1008) * add definition for python super() * Made set of updateds for spacing and content improvement * Removed note * Bold inheritance in tag list * Revert "Bold inheritance in tag list" This reverts commit 4e8541e. * Bold Inheritance on line 16 * Removed extra line * Ran npm run format on super.md and inheirtance.md * Update content/python/concepts/inheritance/inheritance.md * Update content/python/concepts/built-in-functions/terms/super/super.md * Update content/python/concepts/built-in-functions/terms/super/super.md * Additional changes from second review update links and text changes * remove yarn.lock * Move text from above pseudo to below it * add yarn.lock back * Delete yarn.lock * added yarn.lock back (again) * re-mirrored yarn.lock against one from main branch * Update content/python/concepts/built-in-functions/terms/super/super.md * Updated super(type) to super(type, object) with example * Update reference to 'object' in pseudocode to 'obj' * remove line at 73 * Update intro to example from "this case" to "the following codebyte example" * remove line at 56 * Shorten reference from "object" to "obj" * Change example intro at line 39 * Remove Codebyte from example * Reverse change from codebyte/python back to py * Clarify child and subclass references * Update to note add > * Add 'Classes' to tags * Updates including mod to codebyte example and additional pseudo code * some last edits

Description
Closes #586
Type of Change
Checklist
mainbranch.