Files
python/exercises/concept/ellens-alien-game/.docs/introduction.md

270 lines
10 KiB
Markdown
Raw Normal View History

# Introduction
## Object Oriented Programming in Python
If you have been programming in a [functional][functional], [declarative][declarative], or [imperative][imperative] style, shifting focus to [object oriented programming][oop] (OOP) may feel a bit foreign.
An OOP approach asks the programmer to think about modeling a problem as one or more `objects` that interact with one another, keep state, and act upon data.
Objects can represent real world entities (_such as cars or cats_) - or more abstract concepts (_such as integers, vehicles, or mammals_).
Each object becomes a unique instance in computer memory and represents some part of the overall model.
## Classes
`Classes` are the definitions of new object types, and from which new `instances` of objects are created.
They often bundle data with code or functions that operate on that data.
In this sense, classes are _blueprints_ or sets of instructions from which many objects of a similar type can be built and used.
A complex program can have many classes, each building many different flavors of objects.
The process of building an object from a class is known as `instantiation` (_or creating an instance of the class_).
A class definition in Python is straightforward:
```python
[Classes Concept & Ellens Alien Game]: Updates (#2941) * New concept exercise: ellens-alien-game Introduces the concept of classes. Message-Id: <20220126095726.46310-2-keeperotphones+patch@gmail.com> * Update config.json Message-Id: <71aad1e9fc012ef13fa5c02ceb4e3ec349715d85.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <bc2601f32a9d9247ac2f767d1f4267f340a22ec6.1643195691.git.keeperotphones+patch@gmail.com> * Delete introduction-draft.md Message-Id: <d11b031b5ef068658b9e2b1efa882a75c2ba70c5.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <f61ad700909f434f38fb55076ab4dc4d9258a6ab.1643195691.git.keeperotphones+patch@gmail.com> * Create introduction Message-Id: <938209240cdbc86bbddc5c33403659a290ec55ac.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <ca99353a7426f0bea05df556cc19752edf48ffce.1643195691.git.keeperotphones+patch@gmail.com> * Rename introduction to introduction.md Message-Id: <4373a3b66fac460701b429d22c76cd33d8b7db4a.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <c675ca900a18a3ad9f8a6b48cdad1157ea312321.1643195691.git.keeperotphones+patch@gmail.com> * Update and rename design-draft.md to design.md Message-Id: <c863549b1a61dc045162be8d6d42ae9a505cddd1.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <71b06afa96db6e5b6dde815560a5776bc8368e8f.1643195691.git.keeperotphones+patch@gmail.com> * Fixed typo in instructions.md Message-Id: <21826fc58f9cfa53d61e6e3ccf5fcc30e6d9e411.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <88a24ed3e8685ba96fdf26bb4c0629131272281f.1643195691.git.keeperotphones+patch@gmail.com> * Formatting with YAPF Confirmed with pylint and flake8. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <ec52cd798d671348f5b29c0a691155d072c023af.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <58b93bb2ed0919c3e5753e25228bcc175a24edfa.1643195691.git.keeperotphones+patch@gmail.com> * Update config.json Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <467259ba695c8005f7106d1f359b1d4fe6c14562.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <29a418465a89c10dfd711475da4236932c4e8eff.1643195691.git.keeperotphones+patch@gmail.com> * Update exercises/concept/ellens-alien-game/.meta/config.json We'll need to rename the files though Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <933195ff036507b273b55633b40a7b76cc27f130.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <529e34d1258c17b00e20278430682cd237cae6a7.1643195691.git.keeperotphones+patch@gmail.com> * Improve wording and formatting for code formatting Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <cf9cfa5b19e0a51a1b47f11abc6d4bfdef9c7b64.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <5fd8622d5e4147746a85f3f1e63a2d5d64a066b4.1643195691.git.keeperotphones+patch@gmail.com> * Using comprehension for our list of aliens Comprehensions were introduced earlier in the concept, and so we use them here. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <1c8e73efaddfe077fe446aed6989da14398b53c6.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <e49ae05922f3dab213853e10ccad7654a4b44e7c.1643195691.git.keeperotphones+patch@gmail.com> * Rename alien_class_test.py to classes_test.py Message-Id: <493ff778d4422e418d1990f96d10c0d41c4f59ed.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <ff33af10e4617a92fcb343ead33a4060b4c7d6ad.1643195691.git.keeperotphones+patch@gmail.com> * Rename alien_class.py to classes.py Message-Id: <394f35b706b695c4e89ed55c9ee5a440701a78b0.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <52bca7f28924b4006ec1deca1e6bfa45f4f922de.1643195691.git.keeperotphones+patch@gmail.com> * Added pytest decorators to classes.py Message-Id: <8b14cd3955060ba75203fd17f088876af23c403d.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <68f7980c8bc3a8a17bef575aa20b9cfb33af1a60.1643195691.git.keeperotphones+patch@gmail.com> * Filled design.md with content Message-Id: <c785ab3f2ef18847df4b787710f8d49789acb2ff.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <d9fed4beb51fa8cdfd6f998bae46efa1cef878b5.1643195691.git.keeperotphones+patch@gmail.com> * Added missing pytest decorator Message-Id: <e175774a005235c5fe4629efffc1c49b44d4898f.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <85d06e4f2024883c120931fec152cc197a74dbc4.1643195691.git.keeperotphones+patch@gmail.com> * Update instructions.md Message-Id: <4a6c7e47a87398e50d6b864ecafe879d13c522d7.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <adea0f3324e0d5aee0a0ddfb4dc4a001baeff404.1643195691.git.keeperotphones+patch@gmail.com> * Update design.md Message-Id: <e90afd667cb2428c6d86c95a0b692aa3b97c7ce4.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <c8d2ec180d0979d65eb7760495022f58d027b6f1.1643195691.git.keeperotphones+patch@gmail.com> * Update classes.py Message-Id: <1dc38f5ebfcfe86df926b98b465465e540670528.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <30be55cc209a83e431f2cb7d735830ad2ea3e40e.1643195691.git.keeperotphones+patch@gmail.com> * Update hints.md Message-Id: <6ed9657bfa2d166f445f9825b9ccf117d5d6a4b1.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <e935f4bafa27d6da7ea3c1c7827c7f7b55155881.1643195691.git.keeperotphones+patch@gmail.com> * remove trailing whitespace Message-Id: <9e59aa73585b1f50a27dda59d7960c9f89f54dd8.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <b1e7081ca1bed4d9c159e20b42c9e9ada3848923.1643195691.git.keeperotphones+patch@gmail.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Moved back-quotes and added smiley to line 45. Added additional instruction to line 46. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Added back-quotes around `class` and `method`. Specified decrement amount. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Corrected 'function' to 'method' and put back-quotes around it. Single-letter-variables changed to word-variables. Instances of 'position' -> 'coordinate' to maintain consistency with new word-variables. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Added back-quotes (for consistency). Clarified task instruction. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Single-letter-variable -> word-variable (style conformity + consistency) Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.meta/exemplar.py Single-letter-variable -> word-variable (style conformity + consistency) Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update instructions.md All instances of: - coordinate_x -> x_coordinate. - coordinate_y -> y_coordinate * Update exemplar.py Implemented x_coordinate and y_coordinate instance variables (and variants thereof - see teleport method) to conform with both expected style (i.e. no single-letter-variables) and the changes made to instructions.md. * Update exercises/concept/ellens-alien-game/.docs/instructions.md Made the instructions in the first task more explicit. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * design.md: Removed `properties` from Concepts * Code Files Cleanup * Added docstring to exemplar.py Alien class * Corrected tests in classes_test.py * Changed new_alien_list to new_aliens_collection * Edited Instructions to Match Exemplar * Merge branch 'main' of github.com:PaulT89/python Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added contents to intro Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added content to about Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Add content to concept intro Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added two links + descriptions Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Update config.json * Added blurb to config.json * Apply suggestions from code review Fixed a few typos and added missing code block in introduction. * Added additional resources to links.json * Added Python Morsels and Dan Bader * Added links on static vs class methods * Added link on history of New Style classes in python. * Added links + fixed typos Added link to: - Official Python Classes tutorial page - The DO tutorial article already linked in the exercise introduction (and as a resource in design.md) - A subsequent DO tutorial article focusing specifically on class and instance variables * Fixed typos * General Cleaning Reworded clumsy sentences, deleted whitespace, fixed typos, removed some back-quotes to improve consistency with other documentation. * Fixed typos + removed whitespace * Corrections, Nits, and Picks * Adding IsaacG as contributor * Added IsaacG as contributor Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Co-authored-by: KOTP <keeperotphones+patch@gmail.com>
2022-02-18 23:42:50 +11:00
class MyClass:
# Class body goes here
```
### Class Attributes
Class fields (_otherwise known as `properties`, `attributes`, `data members`, or `variables`_) can be added to the body of the class:
```python
[Classes Concept & Ellens Alien Game]: Updates (#2941) * New concept exercise: ellens-alien-game Introduces the concept of classes. Message-Id: <20220126095726.46310-2-keeperotphones+patch@gmail.com> * Update config.json Message-Id: <71aad1e9fc012ef13fa5c02ceb4e3ec349715d85.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <bc2601f32a9d9247ac2f767d1f4267f340a22ec6.1643195691.git.keeperotphones+patch@gmail.com> * Delete introduction-draft.md Message-Id: <d11b031b5ef068658b9e2b1efa882a75c2ba70c5.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <f61ad700909f434f38fb55076ab4dc4d9258a6ab.1643195691.git.keeperotphones+patch@gmail.com> * Create introduction Message-Id: <938209240cdbc86bbddc5c33403659a290ec55ac.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <ca99353a7426f0bea05df556cc19752edf48ffce.1643195691.git.keeperotphones+patch@gmail.com> * Rename introduction to introduction.md Message-Id: <4373a3b66fac460701b429d22c76cd33d8b7db4a.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <c675ca900a18a3ad9f8a6b48cdad1157ea312321.1643195691.git.keeperotphones+patch@gmail.com> * Update and rename design-draft.md to design.md Message-Id: <c863549b1a61dc045162be8d6d42ae9a505cddd1.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <71b06afa96db6e5b6dde815560a5776bc8368e8f.1643195691.git.keeperotphones+patch@gmail.com> * Fixed typo in instructions.md Message-Id: <21826fc58f9cfa53d61e6e3ccf5fcc30e6d9e411.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <88a24ed3e8685ba96fdf26bb4c0629131272281f.1643195691.git.keeperotphones+patch@gmail.com> * Formatting with YAPF Confirmed with pylint and flake8. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <ec52cd798d671348f5b29c0a691155d072c023af.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <58b93bb2ed0919c3e5753e25228bcc175a24edfa.1643195691.git.keeperotphones+patch@gmail.com> * Update config.json Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <467259ba695c8005f7106d1f359b1d4fe6c14562.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <29a418465a89c10dfd711475da4236932c4e8eff.1643195691.git.keeperotphones+patch@gmail.com> * Update exercises/concept/ellens-alien-game/.meta/config.json We'll need to rename the files though Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <933195ff036507b273b55633b40a7b76cc27f130.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <529e34d1258c17b00e20278430682cd237cae6a7.1643195691.git.keeperotphones+patch@gmail.com> * Improve wording and formatting for code formatting Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <cf9cfa5b19e0a51a1b47f11abc6d4bfdef9c7b64.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <5fd8622d5e4147746a85f3f1e63a2d5d64a066b4.1643195691.git.keeperotphones+patch@gmail.com> * Using comprehension for our list of aliens Comprehensions were introduced earlier in the concept, and so we use them here. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <1c8e73efaddfe077fe446aed6989da14398b53c6.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <e49ae05922f3dab213853e10ccad7654a4b44e7c.1643195691.git.keeperotphones+patch@gmail.com> * Rename alien_class_test.py to classes_test.py Message-Id: <493ff778d4422e418d1990f96d10c0d41c4f59ed.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <ff33af10e4617a92fcb343ead33a4060b4c7d6ad.1643195691.git.keeperotphones+patch@gmail.com> * Rename alien_class.py to classes.py Message-Id: <394f35b706b695c4e89ed55c9ee5a440701a78b0.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <52bca7f28924b4006ec1deca1e6bfa45f4f922de.1643195691.git.keeperotphones+patch@gmail.com> * Added pytest decorators to classes.py Message-Id: <8b14cd3955060ba75203fd17f088876af23c403d.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <68f7980c8bc3a8a17bef575aa20b9cfb33af1a60.1643195691.git.keeperotphones+patch@gmail.com> * Filled design.md with content Message-Id: <c785ab3f2ef18847df4b787710f8d49789acb2ff.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <d9fed4beb51fa8cdfd6f998bae46efa1cef878b5.1643195691.git.keeperotphones+patch@gmail.com> * Added missing pytest decorator Message-Id: <e175774a005235c5fe4629efffc1c49b44d4898f.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <85d06e4f2024883c120931fec152cc197a74dbc4.1643195691.git.keeperotphones+patch@gmail.com> * Update instructions.md Message-Id: <4a6c7e47a87398e50d6b864ecafe879d13c522d7.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <adea0f3324e0d5aee0a0ddfb4dc4a001baeff404.1643195691.git.keeperotphones+patch@gmail.com> * Update design.md Message-Id: <e90afd667cb2428c6d86c95a0b692aa3b97c7ce4.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <c8d2ec180d0979d65eb7760495022f58d027b6f1.1643195691.git.keeperotphones+patch@gmail.com> * Update classes.py Message-Id: <1dc38f5ebfcfe86df926b98b465465e540670528.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <30be55cc209a83e431f2cb7d735830ad2ea3e40e.1643195691.git.keeperotphones+patch@gmail.com> * Update hints.md Message-Id: <6ed9657bfa2d166f445f9825b9ccf117d5d6a4b1.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <e935f4bafa27d6da7ea3c1c7827c7f7b55155881.1643195691.git.keeperotphones+patch@gmail.com> * remove trailing whitespace Message-Id: <9e59aa73585b1f50a27dda59d7960c9f89f54dd8.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <b1e7081ca1bed4d9c159e20b42c9e9ada3848923.1643195691.git.keeperotphones+patch@gmail.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Moved back-quotes and added smiley to line 45. Added additional instruction to line 46. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Added back-quotes around `class` and `method`. Specified decrement amount. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Corrected 'function' to 'method' and put back-quotes around it. Single-letter-variables changed to word-variables. Instances of 'position' -> 'coordinate' to maintain consistency with new word-variables. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Added back-quotes (for consistency). Clarified task instruction. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Single-letter-variable -> word-variable (style conformity + consistency) Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.meta/exemplar.py Single-letter-variable -> word-variable (style conformity + consistency) Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update instructions.md All instances of: - coordinate_x -> x_coordinate. - coordinate_y -> y_coordinate * Update exemplar.py Implemented x_coordinate and y_coordinate instance variables (and variants thereof - see teleport method) to conform with both expected style (i.e. no single-letter-variables) and the changes made to instructions.md. * Update exercises/concept/ellens-alien-game/.docs/instructions.md Made the instructions in the first task more explicit. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * design.md: Removed `properties` from Concepts * Code Files Cleanup * Added docstring to exemplar.py Alien class * Corrected tests in classes_test.py * Changed new_alien_list to new_aliens_collection * Edited Instructions to Match Exemplar * Merge branch 'main' of github.com:PaulT89/python Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added contents to intro Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added content to about Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Add content to concept intro Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added two links + descriptions Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Update config.json * Added blurb to config.json * Apply suggestions from code review Fixed a few typos and added missing code block in introduction. * Added additional resources to links.json * Added Python Morsels and Dan Bader * Added links on static vs class methods * Added link on history of New Style classes in python. * Added links + fixed typos Added link to: - Official Python Classes tutorial page - The DO tutorial article already linked in the exercise introduction (and as a resource in design.md) - A subsequent DO tutorial article focusing specifically on class and instance variables * Fixed typos * General Cleaning Reworded clumsy sentences, deleted whitespace, fixed typos, removed some back-quotes to improve consistency with other documentation. * Fixed typos + removed whitespace * Corrections, Nits, and Picks * Adding IsaacG as contributor * Added IsaacG as contributor Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Co-authored-by: KOTP <keeperotphones+patch@gmail.com>
2022-02-18 23:42:50 +11:00
class MyClass:
number = 5
string = "Hello!"
```
[Classes Concept & Ellens Alien Game]: Updates (#2941) * New concept exercise: ellens-alien-game Introduces the concept of classes. Message-Id: <20220126095726.46310-2-keeperotphones+patch@gmail.com> * Update config.json Message-Id: <71aad1e9fc012ef13fa5c02ceb4e3ec349715d85.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <bc2601f32a9d9247ac2f767d1f4267f340a22ec6.1643195691.git.keeperotphones+patch@gmail.com> * Delete introduction-draft.md Message-Id: <d11b031b5ef068658b9e2b1efa882a75c2ba70c5.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <f61ad700909f434f38fb55076ab4dc4d9258a6ab.1643195691.git.keeperotphones+patch@gmail.com> * Create introduction Message-Id: <938209240cdbc86bbddc5c33403659a290ec55ac.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <ca99353a7426f0bea05df556cc19752edf48ffce.1643195691.git.keeperotphones+patch@gmail.com> * Rename introduction to introduction.md Message-Id: <4373a3b66fac460701b429d22c76cd33d8b7db4a.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <c675ca900a18a3ad9f8a6b48cdad1157ea312321.1643195691.git.keeperotphones+patch@gmail.com> * Update and rename design-draft.md to design.md Message-Id: <c863549b1a61dc045162be8d6d42ae9a505cddd1.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <71b06afa96db6e5b6dde815560a5776bc8368e8f.1643195691.git.keeperotphones+patch@gmail.com> * Fixed typo in instructions.md Message-Id: <21826fc58f9cfa53d61e6e3ccf5fcc30e6d9e411.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <88a24ed3e8685ba96fdf26bb4c0629131272281f.1643195691.git.keeperotphones+patch@gmail.com> * Formatting with YAPF Confirmed with pylint and flake8. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <ec52cd798d671348f5b29c0a691155d072c023af.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <58b93bb2ed0919c3e5753e25228bcc175a24edfa.1643195691.git.keeperotphones+patch@gmail.com> * Update config.json Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <467259ba695c8005f7106d1f359b1d4fe6c14562.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <29a418465a89c10dfd711475da4236932c4e8eff.1643195691.git.keeperotphones+patch@gmail.com> * Update exercises/concept/ellens-alien-game/.meta/config.json We'll need to rename the files though Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <933195ff036507b273b55633b40a7b76cc27f130.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <529e34d1258c17b00e20278430682cd237cae6a7.1643195691.git.keeperotphones+patch@gmail.com> * Improve wording and formatting for code formatting Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <cf9cfa5b19e0a51a1b47f11abc6d4bfdef9c7b64.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <5fd8622d5e4147746a85f3f1e63a2d5d64a066b4.1643195691.git.keeperotphones+patch@gmail.com> * Using comprehension for our list of aliens Comprehensions were introduced earlier in the concept, and so we use them here. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <1c8e73efaddfe077fe446aed6989da14398b53c6.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <e49ae05922f3dab213853e10ccad7654a4b44e7c.1643195691.git.keeperotphones+patch@gmail.com> * Rename alien_class_test.py to classes_test.py Message-Id: <493ff778d4422e418d1990f96d10c0d41c4f59ed.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <ff33af10e4617a92fcb343ead33a4060b4c7d6ad.1643195691.git.keeperotphones+patch@gmail.com> * Rename alien_class.py to classes.py Message-Id: <394f35b706b695c4e89ed55c9ee5a440701a78b0.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <52bca7f28924b4006ec1deca1e6bfa45f4f922de.1643195691.git.keeperotphones+patch@gmail.com> * Added pytest decorators to classes.py Message-Id: <8b14cd3955060ba75203fd17f088876af23c403d.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <68f7980c8bc3a8a17bef575aa20b9cfb33af1a60.1643195691.git.keeperotphones+patch@gmail.com> * Filled design.md with content Message-Id: <c785ab3f2ef18847df4b787710f8d49789acb2ff.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <d9fed4beb51fa8cdfd6f998bae46efa1cef878b5.1643195691.git.keeperotphones+patch@gmail.com> * Added missing pytest decorator Message-Id: <e175774a005235c5fe4629efffc1c49b44d4898f.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <85d06e4f2024883c120931fec152cc197a74dbc4.1643195691.git.keeperotphones+patch@gmail.com> * Update instructions.md Message-Id: <4a6c7e47a87398e50d6b864ecafe879d13c522d7.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <adea0f3324e0d5aee0a0ddfb4dc4a001baeff404.1643195691.git.keeperotphones+patch@gmail.com> * Update design.md Message-Id: <e90afd667cb2428c6d86c95a0b692aa3b97c7ce4.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <c8d2ec180d0979d65eb7760495022f58d027b6f1.1643195691.git.keeperotphones+patch@gmail.com> * Update classes.py Message-Id: <1dc38f5ebfcfe86df926b98b465465e540670528.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <30be55cc209a83e431f2cb7d735830ad2ea3e40e.1643195691.git.keeperotphones+patch@gmail.com> * Update hints.md Message-Id: <6ed9657bfa2d166f445f9825b9ccf117d5d6a4b1.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <e935f4bafa27d6da7ea3c1c7827c7f7b55155881.1643195691.git.keeperotphones+patch@gmail.com> * remove trailing whitespace Message-Id: <9e59aa73585b1f50a27dda59d7960c9f89f54dd8.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <b1e7081ca1bed4d9c159e20b42c9e9ada3848923.1643195691.git.keeperotphones+patch@gmail.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Moved back-quotes and added smiley to line 45. Added additional instruction to line 46. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Added back-quotes around `class` and `method`. Specified decrement amount. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Corrected 'function' to 'method' and put back-quotes around it. Single-letter-variables changed to word-variables. Instances of 'position' -> 'coordinate' to maintain consistency with new word-variables. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Added back-quotes (for consistency). Clarified task instruction. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Single-letter-variable -> word-variable (style conformity + consistency) Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.meta/exemplar.py Single-letter-variable -> word-variable (style conformity + consistency) Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update instructions.md All instances of: - coordinate_x -> x_coordinate. - coordinate_y -> y_coordinate * Update exemplar.py Implemented x_coordinate and y_coordinate instance variables (and variants thereof - see teleport method) to conform with both expected style (i.e. no single-letter-variables) and the changes made to instructions.md. * Update exercises/concept/ellens-alien-game/.docs/instructions.md Made the instructions in the first task more explicit. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * design.md: Removed `properties` from Concepts * Code Files Cleanup * Added docstring to exemplar.py Alien class * Corrected tests in classes_test.py * Changed new_alien_list to new_aliens_collection * Edited Instructions to Match Exemplar * Merge branch 'main' of github.com:PaulT89/python Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added contents to intro Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added content to about Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Add content to concept intro Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added two links + descriptions Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Update config.json * Added blurb to config.json * Apply suggestions from code review Fixed a few typos and added missing code block in introduction. * Added additional resources to links.json * Added Python Morsels and Dan Bader * Added links on static vs class methods * Added link on history of New Style classes in python. * Added links + fixed typos Added link to: - Official Python Classes tutorial page - The DO tutorial article already linked in the exercise introduction (and as a resource in design.md) - A subsequent DO tutorial article focusing specifically on class and instance variables * Fixed typos * General Cleaning Reworded clumsy sentences, deleted whitespace, fixed typos, removed some back-quotes to improve consistency with other documentation. * Fixed typos + removed whitespace * Corrections, Nits, and Picks * Adding IsaacG as contributor * Added IsaacG as contributor Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Co-authored-by: KOTP <keeperotphones+patch@gmail.com>
2022-02-18 23:42:50 +11:00
An instance (_object_) of `MyClass` can be created and bound to a name by [_calling_][calling] the class (_in the same way a function is called_):
```python
[Classes Concept & Ellens Alien Game]: Updates (#2941) * New concept exercise: ellens-alien-game Introduces the concept of classes. Message-Id: <20220126095726.46310-2-keeperotphones+patch@gmail.com> * Update config.json Message-Id: <71aad1e9fc012ef13fa5c02ceb4e3ec349715d85.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <bc2601f32a9d9247ac2f767d1f4267f340a22ec6.1643195691.git.keeperotphones+patch@gmail.com> * Delete introduction-draft.md Message-Id: <d11b031b5ef068658b9e2b1efa882a75c2ba70c5.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <f61ad700909f434f38fb55076ab4dc4d9258a6ab.1643195691.git.keeperotphones+patch@gmail.com> * Create introduction Message-Id: <938209240cdbc86bbddc5c33403659a290ec55ac.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <ca99353a7426f0bea05df556cc19752edf48ffce.1643195691.git.keeperotphones+patch@gmail.com> * Rename introduction to introduction.md Message-Id: <4373a3b66fac460701b429d22c76cd33d8b7db4a.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <c675ca900a18a3ad9f8a6b48cdad1157ea312321.1643195691.git.keeperotphones+patch@gmail.com> * Update and rename design-draft.md to design.md Message-Id: <c863549b1a61dc045162be8d6d42ae9a505cddd1.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <71b06afa96db6e5b6dde815560a5776bc8368e8f.1643195691.git.keeperotphones+patch@gmail.com> * Fixed typo in instructions.md Message-Id: <21826fc58f9cfa53d61e6e3ccf5fcc30e6d9e411.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <88a24ed3e8685ba96fdf26bb4c0629131272281f.1643195691.git.keeperotphones+patch@gmail.com> * Formatting with YAPF Confirmed with pylint and flake8. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <ec52cd798d671348f5b29c0a691155d072c023af.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <58b93bb2ed0919c3e5753e25228bcc175a24edfa.1643195691.git.keeperotphones+patch@gmail.com> * Update config.json Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <467259ba695c8005f7106d1f359b1d4fe6c14562.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <29a418465a89c10dfd711475da4236932c4e8eff.1643195691.git.keeperotphones+patch@gmail.com> * Update exercises/concept/ellens-alien-game/.meta/config.json We'll need to rename the files though Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <933195ff036507b273b55633b40a7b76cc27f130.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <529e34d1258c17b00e20278430682cd237cae6a7.1643195691.git.keeperotphones+patch@gmail.com> * Improve wording and formatting for code formatting Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <cf9cfa5b19e0a51a1b47f11abc6d4bfdef9c7b64.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <5fd8622d5e4147746a85f3f1e63a2d5d64a066b4.1643195691.git.keeperotphones+patch@gmail.com> * Using comprehension for our list of aliens Comprehensions were introduced earlier in the concept, and so we use them here. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <1c8e73efaddfe077fe446aed6989da14398b53c6.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <e49ae05922f3dab213853e10ccad7654a4b44e7c.1643195691.git.keeperotphones+patch@gmail.com> * Rename alien_class_test.py to classes_test.py Message-Id: <493ff778d4422e418d1990f96d10c0d41c4f59ed.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <ff33af10e4617a92fcb343ead33a4060b4c7d6ad.1643195691.git.keeperotphones+patch@gmail.com> * Rename alien_class.py to classes.py Message-Id: <394f35b706b695c4e89ed55c9ee5a440701a78b0.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <52bca7f28924b4006ec1deca1e6bfa45f4f922de.1643195691.git.keeperotphones+patch@gmail.com> * Added pytest decorators to classes.py Message-Id: <8b14cd3955060ba75203fd17f088876af23c403d.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <68f7980c8bc3a8a17bef575aa20b9cfb33af1a60.1643195691.git.keeperotphones+patch@gmail.com> * Filled design.md with content Message-Id: <c785ab3f2ef18847df4b787710f8d49789acb2ff.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <d9fed4beb51fa8cdfd6f998bae46efa1cef878b5.1643195691.git.keeperotphones+patch@gmail.com> * Added missing pytest decorator Message-Id: <e175774a005235c5fe4629efffc1c49b44d4898f.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <85d06e4f2024883c120931fec152cc197a74dbc4.1643195691.git.keeperotphones+patch@gmail.com> * Update instructions.md Message-Id: <4a6c7e47a87398e50d6b864ecafe879d13c522d7.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <adea0f3324e0d5aee0a0ddfb4dc4a001baeff404.1643195691.git.keeperotphones+patch@gmail.com> * Update design.md Message-Id: <e90afd667cb2428c6d86c95a0b692aa3b97c7ce4.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <c8d2ec180d0979d65eb7760495022f58d027b6f1.1643195691.git.keeperotphones+patch@gmail.com> * Update classes.py Message-Id: <1dc38f5ebfcfe86df926b98b465465e540670528.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <30be55cc209a83e431f2cb7d735830ad2ea3e40e.1643195691.git.keeperotphones+patch@gmail.com> * Update hints.md Message-Id: <6ed9657bfa2d166f445f9825b9ccf117d5d6a4b1.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <e935f4bafa27d6da7ea3c1c7827c7f7b55155881.1643195691.git.keeperotphones+patch@gmail.com> * remove trailing whitespace Message-Id: <9e59aa73585b1f50a27dda59d7960c9f89f54dd8.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <b1e7081ca1bed4d9c159e20b42c9e9ada3848923.1643195691.git.keeperotphones+patch@gmail.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Moved back-quotes and added smiley to line 45. Added additional instruction to line 46. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Added back-quotes around `class` and `method`. Specified decrement amount. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Corrected 'function' to 'method' and put back-quotes around it. Single-letter-variables changed to word-variables. Instances of 'position' -> 'coordinate' to maintain consistency with new word-variables. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Added back-quotes (for consistency). Clarified task instruction. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Single-letter-variable -> word-variable (style conformity + consistency) Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.meta/exemplar.py Single-letter-variable -> word-variable (style conformity + consistency) Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update instructions.md All instances of: - coordinate_x -> x_coordinate. - coordinate_y -> y_coordinate * Update exemplar.py Implemented x_coordinate and y_coordinate instance variables (and variants thereof - see teleport method) to conform with both expected style (i.e. no single-letter-variables) and the changes made to instructions.md. * Update exercises/concept/ellens-alien-game/.docs/instructions.md Made the instructions in the first task more explicit. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * design.md: Removed `properties` from Concepts * Code Files Cleanup * Added docstring to exemplar.py Alien class * Corrected tests in classes_test.py * Changed new_alien_list to new_aliens_collection * Edited Instructions to Match Exemplar * Merge branch 'main' of github.com:PaulT89/python Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added contents to intro Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added content to about Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Add content to concept intro Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added two links + descriptions Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Update config.json * Added blurb to config.json * Apply suggestions from code review Fixed a few typos and added missing code block in introduction. * Added additional resources to links.json * Added Python Morsels and Dan Bader * Added links on static vs class methods * Added link on history of New Style classes in python. * Added links + fixed typos Added link to: - Official Python Classes tutorial page - The DO tutorial article already linked in the exercise introduction (and as a resource in design.md) - A subsequent DO tutorial article focusing specifically on class and instance variables * Fixed typos * General Cleaning Reworded clumsy sentences, deleted whitespace, fixed typos, removed some back-quotes to improve consistency with other documentation. * Fixed typos + removed whitespace * Corrections, Nits, and Picks * Adding IsaacG as contributor * Added IsaacG as contributor Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Co-authored-by: KOTP <keeperotphones+patch@gmail.com>
2022-02-18 23:42:50 +11:00
>>> new_object = MyClass()
2022-02-18 03:10:42 +11:00
# Class is instantiated and resulting object is bound to the "new_object" name.
# Note: the object address 'at 0x15adc55b0' will vary by computer.
>>> new_object
[Classes Concept & Ellens Alien Game]: Updates (#2941) * New concept exercise: ellens-alien-game Introduces the concept of classes. Message-Id: <20220126095726.46310-2-keeperotphones+patch@gmail.com> * Update config.json Message-Id: <71aad1e9fc012ef13fa5c02ceb4e3ec349715d85.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <bc2601f32a9d9247ac2f767d1f4267f340a22ec6.1643195691.git.keeperotphones+patch@gmail.com> * Delete introduction-draft.md Message-Id: <d11b031b5ef068658b9e2b1efa882a75c2ba70c5.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <f61ad700909f434f38fb55076ab4dc4d9258a6ab.1643195691.git.keeperotphones+patch@gmail.com> * Create introduction Message-Id: <938209240cdbc86bbddc5c33403659a290ec55ac.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <ca99353a7426f0bea05df556cc19752edf48ffce.1643195691.git.keeperotphones+patch@gmail.com> * Rename introduction to introduction.md Message-Id: <4373a3b66fac460701b429d22c76cd33d8b7db4a.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <c675ca900a18a3ad9f8a6b48cdad1157ea312321.1643195691.git.keeperotphones+patch@gmail.com> * Update and rename design-draft.md to design.md Message-Id: <c863549b1a61dc045162be8d6d42ae9a505cddd1.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <71b06afa96db6e5b6dde815560a5776bc8368e8f.1643195691.git.keeperotphones+patch@gmail.com> * Fixed typo in instructions.md Message-Id: <21826fc58f9cfa53d61e6e3ccf5fcc30e6d9e411.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <88a24ed3e8685ba96fdf26bb4c0629131272281f.1643195691.git.keeperotphones+patch@gmail.com> * Formatting with YAPF Confirmed with pylint and flake8. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <ec52cd798d671348f5b29c0a691155d072c023af.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <58b93bb2ed0919c3e5753e25228bcc175a24edfa.1643195691.git.keeperotphones+patch@gmail.com> * Update config.json Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <467259ba695c8005f7106d1f359b1d4fe6c14562.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <29a418465a89c10dfd711475da4236932c4e8eff.1643195691.git.keeperotphones+patch@gmail.com> * Update exercises/concept/ellens-alien-game/.meta/config.json We'll need to rename the files though Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <933195ff036507b273b55633b40a7b76cc27f130.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <529e34d1258c17b00e20278430682cd237cae6a7.1643195691.git.keeperotphones+patch@gmail.com> * Improve wording and formatting for code formatting Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <cf9cfa5b19e0a51a1b47f11abc6d4bfdef9c7b64.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <5fd8622d5e4147746a85f3f1e63a2d5d64a066b4.1643195691.git.keeperotphones+patch@gmail.com> * Using comprehension for our list of aliens Comprehensions were introduced earlier in the concept, and so we use them here. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <1c8e73efaddfe077fe446aed6989da14398b53c6.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <e49ae05922f3dab213853e10ccad7654a4b44e7c.1643195691.git.keeperotphones+patch@gmail.com> * Rename alien_class_test.py to classes_test.py Message-Id: <493ff778d4422e418d1990f96d10c0d41c4f59ed.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <ff33af10e4617a92fcb343ead33a4060b4c7d6ad.1643195691.git.keeperotphones+patch@gmail.com> * Rename alien_class.py to classes.py Message-Id: <394f35b706b695c4e89ed55c9ee5a440701a78b0.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <52bca7f28924b4006ec1deca1e6bfa45f4f922de.1643195691.git.keeperotphones+patch@gmail.com> * Added pytest decorators to classes.py Message-Id: <8b14cd3955060ba75203fd17f088876af23c403d.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <68f7980c8bc3a8a17bef575aa20b9cfb33af1a60.1643195691.git.keeperotphones+patch@gmail.com> * Filled design.md with content Message-Id: <c785ab3f2ef18847df4b787710f8d49789acb2ff.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <d9fed4beb51fa8cdfd6f998bae46efa1cef878b5.1643195691.git.keeperotphones+patch@gmail.com> * Added missing pytest decorator Message-Id: <e175774a005235c5fe4629efffc1c49b44d4898f.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <85d06e4f2024883c120931fec152cc197a74dbc4.1643195691.git.keeperotphones+patch@gmail.com> * Update instructions.md Message-Id: <4a6c7e47a87398e50d6b864ecafe879d13c522d7.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <adea0f3324e0d5aee0a0ddfb4dc4a001baeff404.1643195691.git.keeperotphones+patch@gmail.com> * Update design.md Message-Id: <e90afd667cb2428c6d86c95a0b692aa3b97c7ce4.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <c8d2ec180d0979d65eb7760495022f58d027b6f1.1643195691.git.keeperotphones+patch@gmail.com> * Update classes.py Message-Id: <1dc38f5ebfcfe86df926b98b465465e540670528.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <30be55cc209a83e431f2cb7d735830ad2ea3e40e.1643195691.git.keeperotphones+patch@gmail.com> * Update hints.md Message-Id: <6ed9657bfa2d166f445f9825b9ccf117d5d6a4b1.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <e935f4bafa27d6da7ea3c1c7827c7f7b55155881.1643195691.git.keeperotphones+patch@gmail.com> * remove trailing whitespace Message-Id: <9e59aa73585b1f50a27dda59d7960c9f89f54dd8.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <b1e7081ca1bed4d9c159e20b42c9e9ada3848923.1643195691.git.keeperotphones+patch@gmail.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Moved back-quotes and added smiley to line 45. Added additional instruction to line 46. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Added back-quotes around `class` and `method`. Specified decrement amount. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Corrected 'function' to 'method' and put back-quotes around it. Single-letter-variables changed to word-variables. Instances of 'position' -> 'coordinate' to maintain consistency with new word-variables. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Added back-quotes (for consistency). Clarified task instruction. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Single-letter-variable -> word-variable (style conformity + consistency) Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.meta/exemplar.py Single-letter-variable -> word-variable (style conformity + consistency) Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update instructions.md All instances of: - coordinate_x -> x_coordinate. - coordinate_y -> y_coordinate * Update exemplar.py Implemented x_coordinate and y_coordinate instance variables (and variants thereof - see teleport method) to conform with both expected style (i.e. no single-letter-variables) and the changes made to instructions.md. * Update exercises/concept/ellens-alien-game/.docs/instructions.md Made the instructions in the first task more explicit. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * design.md: Removed `properties` from Concepts * Code Files Cleanup * Added docstring to exemplar.py Alien class * Corrected tests in classes_test.py * Changed new_alien_list to new_aliens_collection * Edited Instructions to Match Exemplar * Merge branch 'main' of github.com:PaulT89/python Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added contents to intro Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added content to about Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Add content to concept intro Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added two links + descriptions Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Update config.json * Added blurb to config.json * Apply suggestions from code review Fixed a few typos and added missing code block in introduction. * Added additional resources to links.json * Added Python Morsels and Dan Bader * Added links on static vs class methods * Added link on history of New Style classes in python. * Added links + fixed typos Added link to: - Official Python Classes tutorial page - The DO tutorial article already linked in the exercise introduction (and as a resource in design.md) - A subsequent DO tutorial article focusing specifically on class and instance variables * Fixed typos * General Cleaning Reworded clumsy sentences, deleted whitespace, fixed typos, removed some back-quotes to improve consistency with other documentation. * Fixed typos + removed whitespace * Corrections, Nits, and Picks * Adding IsaacG as contributor * Added IsaacG as contributor Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Co-authored-by: KOTP <keeperotphones+patch@gmail.com>
2022-02-18 23:42:50 +11:00
<__main__.MyClass at 0x15adc55b0>
```
`Class attributes` are shared across all objects (_or instances_) created from a class, and can be accessed via [`dot notation`][dot notation] - a `.` placed after the object name and before the attribute name:
```python
[Classes Concept & Ellens Alien Game]: Updates (#2941) * New concept exercise: ellens-alien-game Introduces the concept of classes. Message-Id: <20220126095726.46310-2-keeperotphones+patch@gmail.com> * Update config.json Message-Id: <71aad1e9fc012ef13fa5c02ceb4e3ec349715d85.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <bc2601f32a9d9247ac2f767d1f4267f340a22ec6.1643195691.git.keeperotphones+patch@gmail.com> * Delete introduction-draft.md Message-Id: <d11b031b5ef068658b9e2b1efa882a75c2ba70c5.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <f61ad700909f434f38fb55076ab4dc4d9258a6ab.1643195691.git.keeperotphones+patch@gmail.com> * Create introduction Message-Id: <938209240cdbc86bbddc5c33403659a290ec55ac.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <ca99353a7426f0bea05df556cc19752edf48ffce.1643195691.git.keeperotphones+patch@gmail.com> * Rename introduction to introduction.md Message-Id: <4373a3b66fac460701b429d22c76cd33d8b7db4a.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <c675ca900a18a3ad9f8a6b48cdad1157ea312321.1643195691.git.keeperotphones+patch@gmail.com> * Update and rename design-draft.md to design.md Message-Id: <c863549b1a61dc045162be8d6d42ae9a505cddd1.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <71b06afa96db6e5b6dde815560a5776bc8368e8f.1643195691.git.keeperotphones+patch@gmail.com> * Fixed typo in instructions.md Message-Id: <21826fc58f9cfa53d61e6e3ccf5fcc30e6d9e411.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <88a24ed3e8685ba96fdf26bb4c0629131272281f.1643195691.git.keeperotphones+patch@gmail.com> * Formatting with YAPF Confirmed with pylint and flake8. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <ec52cd798d671348f5b29c0a691155d072c023af.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <58b93bb2ed0919c3e5753e25228bcc175a24edfa.1643195691.git.keeperotphones+patch@gmail.com> * Update config.json Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <467259ba695c8005f7106d1f359b1d4fe6c14562.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <29a418465a89c10dfd711475da4236932c4e8eff.1643195691.git.keeperotphones+patch@gmail.com> * Update exercises/concept/ellens-alien-game/.meta/config.json We'll need to rename the files though Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <933195ff036507b273b55633b40a7b76cc27f130.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <529e34d1258c17b00e20278430682cd237cae6a7.1643195691.git.keeperotphones+patch@gmail.com> * Improve wording and formatting for code formatting Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <cf9cfa5b19e0a51a1b47f11abc6d4bfdef9c7b64.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <5fd8622d5e4147746a85f3f1e63a2d5d64a066b4.1643195691.git.keeperotphones+patch@gmail.com> * Using comprehension for our list of aliens Comprehensions were introduced earlier in the concept, and so we use them here. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <1c8e73efaddfe077fe446aed6989da14398b53c6.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <e49ae05922f3dab213853e10ccad7654a4b44e7c.1643195691.git.keeperotphones+patch@gmail.com> * Rename alien_class_test.py to classes_test.py Message-Id: <493ff778d4422e418d1990f96d10c0d41c4f59ed.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <ff33af10e4617a92fcb343ead33a4060b4c7d6ad.1643195691.git.keeperotphones+patch@gmail.com> * Rename alien_class.py to classes.py Message-Id: <394f35b706b695c4e89ed55c9ee5a440701a78b0.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <52bca7f28924b4006ec1deca1e6bfa45f4f922de.1643195691.git.keeperotphones+patch@gmail.com> * Added pytest decorators to classes.py Message-Id: <8b14cd3955060ba75203fd17f088876af23c403d.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <68f7980c8bc3a8a17bef575aa20b9cfb33af1a60.1643195691.git.keeperotphones+patch@gmail.com> * Filled design.md with content Message-Id: <c785ab3f2ef18847df4b787710f8d49789acb2ff.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <d9fed4beb51fa8cdfd6f998bae46efa1cef878b5.1643195691.git.keeperotphones+patch@gmail.com> * Added missing pytest decorator Message-Id: <e175774a005235c5fe4629efffc1c49b44d4898f.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <85d06e4f2024883c120931fec152cc197a74dbc4.1643195691.git.keeperotphones+patch@gmail.com> * Update instructions.md Message-Id: <4a6c7e47a87398e50d6b864ecafe879d13c522d7.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <adea0f3324e0d5aee0a0ddfb4dc4a001baeff404.1643195691.git.keeperotphones+patch@gmail.com> * Update design.md Message-Id: <e90afd667cb2428c6d86c95a0b692aa3b97c7ce4.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <c8d2ec180d0979d65eb7760495022f58d027b6f1.1643195691.git.keeperotphones+patch@gmail.com> * Update classes.py Message-Id: <1dc38f5ebfcfe86df926b98b465465e540670528.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <30be55cc209a83e431f2cb7d735830ad2ea3e40e.1643195691.git.keeperotphones+patch@gmail.com> * Update hints.md Message-Id: <6ed9657bfa2d166f445f9825b9ccf117d5d6a4b1.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <e935f4bafa27d6da7ea3c1c7827c7f7b55155881.1643195691.git.keeperotphones+patch@gmail.com> * remove trailing whitespace Message-Id: <9e59aa73585b1f50a27dda59d7960c9f89f54dd8.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <b1e7081ca1bed4d9c159e20b42c9e9ada3848923.1643195691.git.keeperotphones+patch@gmail.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Moved back-quotes and added smiley to line 45. Added additional instruction to line 46. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Added back-quotes around `class` and `method`. Specified decrement amount. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Corrected 'function' to 'method' and put back-quotes around it. Single-letter-variables changed to word-variables. Instances of 'position' -> 'coordinate' to maintain consistency with new word-variables. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Added back-quotes (for consistency). Clarified task instruction. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Single-letter-variable -> word-variable (style conformity + consistency) Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.meta/exemplar.py Single-letter-variable -> word-variable (style conformity + consistency) Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update instructions.md All instances of: - coordinate_x -> x_coordinate. - coordinate_y -> y_coordinate * Update exemplar.py Implemented x_coordinate and y_coordinate instance variables (and variants thereof - see teleport method) to conform with both expected style (i.e. no single-letter-variables) and the changes made to instructions.md. * Update exercises/concept/ellens-alien-game/.docs/instructions.md Made the instructions in the first task more explicit. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * design.md: Removed `properties` from Concepts * Code Files Cleanup * Added docstring to exemplar.py Alien class * Corrected tests in classes_test.py * Changed new_alien_list to new_aliens_collection * Edited Instructions to Match Exemplar * Merge branch 'main' of github.com:PaulT89/python Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added contents to intro Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added content to about Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Add content to concept intro Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added two links + descriptions Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Update config.json * Added blurb to config.json * Apply suggestions from code review Fixed a few typos and added missing code block in introduction. * Added additional resources to links.json * Added Python Morsels and Dan Bader * Added links on static vs class methods * Added link on history of New Style classes in python. * Added links + fixed typos Added link to: - Official Python Classes tutorial page - The DO tutorial article already linked in the exercise introduction (and as a resource in design.md) - A subsequent DO tutorial article focusing specifically on class and instance variables * Fixed typos * General Cleaning Reworded clumsy sentences, deleted whitespace, fixed typos, removed some back-quotes to improve consistency with other documentation. * Fixed typos + removed whitespace * Corrections, Nits, and Picks * Adding IsaacG as contributor * Added IsaacG as contributor Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Co-authored-by: KOTP <keeperotphones+patch@gmail.com>
2022-02-18 23:42:50 +11:00
>>> new_object = MyClass()
2022-02-18 03:10:42 +11:00
# Accessing the class attribute "number" via dot-notation.
>>> new_object.number
5
2022-02-18 03:10:42 +11:00
# Accessing the class attribute "string" via dot-notation.
>>> new_object.string
'Hello!'
2022-02-18 03:10:42 +11:00
# Instantiating an additional object and binding it to the "second_new_object" name.
[Classes Concept & Ellens Alien Game]: Updates (#2941) * New concept exercise: ellens-alien-game Introduces the concept of classes. Message-Id: <20220126095726.46310-2-keeperotphones+patch@gmail.com> * Update config.json Message-Id: <71aad1e9fc012ef13fa5c02ceb4e3ec349715d85.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <bc2601f32a9d9247ac2f767d1f4267f340a22ec6.1643195691.git.keeperotphones+patch@gmail.com> * Delete introduction-draft.md Message-Id: <d11b031b5ef068658b9e2b1efa882a75c2ba70c5.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <f61ad700909f434f38fb55076ab4dc4d9258a6ab.1643195691.git.keeperotphones+patch@gmail.com> * Create introduction Message-Id: <938209240cdbc86bbddc5c33403659a290ec55ac.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <ca99353a7426f0bea05df556cc19752edf48ffce.1643195691.git.keeperotphones+patch@gmail.com> * Rename introduction to introduction.md Message-Id: <4373a3b66fac460701b429d22c76cd33d8b7db4a.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <c675ca900a18a3ad9f8a6b48cdad1157ea312321.1643195691.git.keeperotphones+patch@gmail.com> * Update and rename design-draft.md to design.md Message-Id: <c863549b1a61dc045162be8d6d42ae9a505cddd1.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <71b06afa96db6e5b6dde815560a5776bc8368e8f.1643195691.git.keeperotphones+patch@gmail.com> * Fixed typo in instructions.md Message-Id: <21826fc58f9cfa53d61e6e3ccf5fcc30e6d9e411.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <88a24ed3e8685ba96fdf26bb4c0629131272281f.1643195691.git.keeperotphones+patch@gmail.com> * Formatting with YAPF Confirmed with pylint and flake8. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <ec52cd798d671348f5b29c0a691155d072c023af.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <58b93bb2ed0919c3e5753e25228bcc175a24edfa.1643195691.git.keeperotphones+patch@gmail.com> * Update config.json Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <467259ba695c8005f7106d1f359b1d4fe6c14562.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <29a418465a89c10dfd711475da4236932c4e8eff.1643195691.git.keeperotphones+patch@gmail.com> * Update exercises/concept/ellens-alien-game/.meta/config.json We'll need to rename the files though Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <933195ff036507b273b55633b40a7b76cc27f130.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <529e34d1258c17b00e20278430682cd237cae6a7.1643195691.git.keeperotphones+patch@gmail.com> * Improve wording and formatting for code formatting Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <cf9cfa5b19e0a51a1b47f11abc6d4bfdef9c7b64.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <5fd8622d5e4147746a85f3f1e63a2d5d64a066b4.1643195691.git.keeperotphones+patch@gmail.com> * Using comprehension for our list of aliens Comprehensions were introduced earlier in the concept, and so we use them here. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <1c8e73efaddfe077fe446aed6989da14398b53c6.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <e49ae05922f3dab213853e10ccad7654a4b44e7c.1643195691.git.keeperotphones+patch@gmail.com> * Rename alien_class_test.py to classes_test.py Message-Id: <493ff778d4422e418d1990f96d10c0d41c4f59ed.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <ff33af10e4617a92fcb343ead33a4060b4c7d6ad.1643195691.git.keeperotphones+patch@gmail.com> * Rename alien_class.py to classes.py Message-Id: <394f35b706b695c4e89ed55c9ee5a440701a78b0.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <52bca7f28924b4006ec1deca1e6bfa45f4f922de.1643195691.git.keeperotphones+patch@gmail.com> * Added pytest decorators to classes.py Message-Id: <8b14cd3955060ba75203fd17f088876af23c403d.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <68f7980c8bc3a8a17bef575aa20b9cfb33af1a60.1643195691.git.keeperotphones+patch@gmail.com> * Filled design.md with content Message-Id: <c785ab3f2ef18847df4b787710f8d49789acb2ff.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <d9fed4beb51fa8cdfd6f998bae46efa1cef878b5.1643195691.git.keeperotphones+patch@gmail.com> * Added missing pytest decorator Message-Id: <e175774a005235c5fe4629efffc1c49b44d4898f.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <85d06e4f2024883c120931fec152cc197a74dbc4.1643195691.git.keeperotphones+patch@gmail.com> * Update instructions.md Message-Id: <4a6c7e47a87398e50d6b864ecafe879d13c522d7.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <adea0f3324e0d5aee0a0ddfb4dc4a001baeff404.1643195691.git.keeperotphones+patch@gmail.com> * Update design.md Message-Id: <e90afd667cb2428c6d86c95a0b692aa3b97c7ce4.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <c8d2ec180d0979d65eb7760495022f58d027b6f1.1643195691.git.keeperotphones+patch@gmail.com> * Update classes.py Message-Id: <1dc38f5ebfcfe86df926b98b465465e540670528.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <30be55cc209a83e431f2cb7d735830ad2ea3e40e.1643195691.git.keeperotphones+patch@gmail.com> * Update hints.md Message-Id: <6ed9657bfa2d166f445f9825b9ccf117d5d6a4b1.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <e935f4bafa27d6da7ea3c1c7827c7f7b55155881.1643195691.git.keeperotphones+patch@gmail.com> * remove trailing whitespace Message-Id: <9e59aa73585b1f50a27dda59d7960c9f89f54dd8.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <b1e7081ca1bed4d9c159e20b42c9e9ada3848923.1643195691.git.keeperotphones+patch@gmail.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Moved back-quotes and added smiley to line 45. Added additional instruction to line 46. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Added back-quotes around `class` and `method`. Specified decrement amount. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Corrected 'function' to 'method' and put back-quotes around it. Single-letter-variables changed to word-variables. Instances of 'position' -> 'coordinate' to maintain consistency with new word-variables. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Added back-quotes (for consistency). Clarified task instruction. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Single-letter-variable -> word-variable (style conformity + consistency) Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.meta/exemplar.py Single-letter-variable -> word-variable (style conformity + consistency) Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update instructions.md All instances of: - coordinate_x -> x_coordinate. - coordinate_y -> y_coordinate * Update exemplar.py Implemented x_coordinate and y_coordinate instance variables (and variants thereof - see teleport method) to conform with both expected style (i.e. no single-letter-variables) and the changes made to instructions.md. * Update exercises/concept/ellens-alien-game/.docs/instructions.md Made the instructions in the first task more explicit. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * design.md: Removed `properties` from Concepts * Code Files Cleanup * Added docstring to exemplar.py Alien class * Corrected tests in classes_test.py * Changed new_alien_list to new_aliens_collection * Edited Instructions to Match Exemplar * Merge branch 'main' of github.com:PaulT89/python Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added contents to intro Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added content to about Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Add content to concept intro Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added two links + descriptions Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Update config.json * Added blurb to config.json * Apply suggestions from code review Fixed a few typos and added missing code block in introduction. * Added additional resources to links.json * Added Python Morsels and Dan Bader * Added links on static vs class methods * Added link on history of New Style classes in python. * Added links + fixed typos Added link to: - Official Python Classes tutorial page - The DO tutorial article already linked in the exercise introduction (and as a resource in design.md) - A subsequent DO tutorial article focusing specifically on class and instance variables * Fixed typos * General Cleaning Reworded clumsy sentences, deleted whitespace, fixed typos, removed some back-quotes to improve consistency with other documentation. * Fixed typos + removed whitespace * Corrections, Nits, and Picks * Adding IsaacG as contributor * Added IsaacG as contributor Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Co-authored-by: KOTP <keeperotphones+patch@gmail.com>
2022-02-18 23:42:50 +11:00
>>> second_new_object = MyClass()
>>> second_new_object
2022-02-18 03:10:42 +11:00
# Note: the object address "at 0x15ad99970" will vary by computer.
[Classes Concept & Ellens Alien Game]: Updates (#2941) * New concept exercise: ellens-alien-game Introduces the concept of classes. Message-Id: <20220126095726.46310-2-keeperotphones+patch@gmail.com> * Update config.json Message-Id: <71aad1e9fc012ef13fa5c02ceb4e3ec349715d85.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <bc2601f32a9d9247ac2f767d1f4267f340a22ec6.1643195691.git.keeperotphones+patch@gmail.com> * Delete introduction-draft.md Message-Id: <d11b031b5ef068658b9e2b1efa882a75c2ba70c5.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <f61ad700909f434f38fb55076ab4dc4d9258a6ab.1643195691.git.keeperotphones+patch@gmail.com> * Create introduction Message-Id: <938209240cdbc86bbddc5c33403659a290ec55ac.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <ca99353a7426f0bea05df556cc19752edf48ffce.1643195691.git.keeperotphones+patch@gmail.com> * Rename introduction to introduction.md Message-Id: <4373a3b66fac460701b429d22c76cd33d8b7db4a.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <c675ca900a18a3ad9f8a6b48cdad1157ea312321.1643195691.git.keeperotphones+patch@gmail.com> * Update and rename design-draft.md to design.md Message-Id: <c863549b1a61dc045162be8d6d42ae9a505cddd1.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <71b06afa96db6e5b6dde815560a5776bc8368e8f.1643195691.git.keeperotphones+patch@gmail.com> * Fixed typo in instructions.md Message-Id: <21826fc58f9cfa53d61e6e3ccf5fcc30e6d9e411.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <88a24ed3e8685ba96fdf26bb4c0629131272281f.1643195691.git.keeperotphones+patch@gmail.com> * Formatting with YAPF Confirmed with pylint and flake8. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <ec52cd798d671348f5b29c0a691155d072c023af.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <58b93bb2ed0919c3e5753e25228bcc175a24edfa.1643195691.git.keeperotphones+patch@gmail.com> * Update config.json Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <467259ba695c8005f7106d1f359b1d4fe6c14562.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <29a418465a89c10dfd711475da4236932c4e8eff.1643195691.git.keeperotphones+patch@gmail.com> * Update exercises/concept/ellens-alien-game/.meta/config.json We'll need to rename the files though Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <933195ff036507b273b55633b40a7b76cc27f130.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <529e34d1258c17b00e20278430682cd237cae6a7.1643195691.git.keeperotphones+patch@gmail.com> * Improve wording and formatting for code formatting Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <cf9cfa5b19e0a51a1b47f11abc6d4bfdef9c7b64.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <5fd8622d5e4147746a85f3f1e63a2d5d64a066b4.1643195691.git.keeperotphones+patch@gmail.com> * Using comprehension for our list of aliens Comprehensions were introduced earlier in the concept, and so we use them here. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <1c8e73efaddfe077fe446aed6989da14398b53c6.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <e49ae05922f3dab213853e10ccad7654a4b44e7c.1643195691.git.keeperotphones+patch@gmail.com> * Rename alien_class_test.py to classes_test.py Message-Id: <493ff778d4422e418d1990f96d10c0d41c4f59ed.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <ff33af10e4617a92fcb343ead33a4060b4c7d6ad.1643195691.git.keeperotphones+patch@gmail.com> * Rename alien_class.py to classes.py Message-Id: <394f35b706b695c4e89ed55c9ee5a440701a78b0.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <52bca7f28924b4006ec1deca1e6bfa45f4f922de.1643195691.git.keeperotphones+patch@gmail.com> * Added pytest decorators to classes.py Message-Id: <8b14cd3955060ba75203fd17f088876af23c403d.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <68f7980c8bc3a8a17bef575aa20b9cfb33af1a60.1643195691.git.keeperotphones+patch@gmail.com> * Filled design.md with content Message-Id: <c785ab3f2ef18847df4b787710f8d49789acb2ff.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <d9fed4beb51fa8cdfd6f998bae46efa1cef878b5.1643195691.git.keeperotphones+patch@gmail.com> * Added missing pytest decorator Message-Id: <e175774a005235c5fe4629efffc1c49b44d4898f.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <85d06e4f2024883c120931fec152cc197a74dbc4.1643195691.git.keeperotphones+patch@gmail.com> * Update instructions.md Message-Id: <4a6c7e47a87398e50d6b864ecafe879d13c522d7.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <adea0f3324e0d5aee0a0ddfb4dc4a001baeff404.1643195691.git.keeperotphones+patch@gmail.com> * Update design.md Message-Id: <e90afd667cb2428c6d86c95a0b692aa3b97c7ce4.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <c8d2ec180d0979d65eb7760495022f58d027b6f1.1643195691.git.keeperotphones+patch@gmail.com> * Update classes.py Message-Id: <1dc38f5ebfcfe86df926b98b465465e540670528.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <30be55cc209a83e431f2cb7d735830ad2ea3e40e.1643195691.git.keeperotphones+patch@gmail.com> * Update hints.md Message-Id: <6ed9657bfa2d166f445f9825b9ccf117d5d6a4b1.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <e935f4bafa27d6da7ea3c1c7827c7f7b55155881.1643195691.git.keeperotphones+patch@gmail.com> * remove trailing whitespace Message-Id: <9e59aa73585b1f50a27dda59d7960c9f89f54dd8.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <b1e7081ca1bed4d9c159e20b42c9e9ada3848923.1643195691.git.keeperotphones+patch@gmail.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Moved back-quotes and added smiley to line 45. Added additional instruction to line 46. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Added back-quotes around `class` and `method`. Specified decrement amount. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Corrected 'function' to 'method' and put back-quotes around it. Single-letter-variables changed to word-variables. Instances of 'position' -> 'coordinate' to maintain consistency with new word-variables. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Added back-quotes (for consistency). Clarified task instruction. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Single-letter-variable -> word-variable (style conformity + consistency) Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.meta/exemplar.py Single-letter-variable -> word-variable (style conformity + consistency) Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update instructions.md All instances of: - coordinate_x -> x_coordinate. - coordinate_y -> y_coordinate * Update exemplar.py Implemented x_coordinate and y_coordinate instance variables (and variants thereof - see teleport method) to conform with both expected style (i.e. no single-letter-variables) and the changes made to instructions.md. * Update exercises/concept/ellens-alien-game/.docs/instructions.md Made the instructions in the first task more explicit. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * design.md: Removed `properties` from Concepts * Code Files Cleanup * Added docstring to exemplar.py Alien class * Corrected tests in classes_test.py * Changed new_alien_list to new_aliens_collection * Edited Instructions to Match Exemplar * Merge branch 'main' of github.com:PaulT89/python Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added contents to intro Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added content to about Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Add content to concept intro Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added two links + descriptions Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Update config.json * Added blurb to config.json * Apply suggestions from code review Fixed a few typos and added missing code block in introduction. * Added additional resources to links.json * Added Python Morsels and Dan Bader * Added links on static vs class methods * Added link on history of New Style classes in python. * Added links + fixed typos Added link to: - Official Python Classes tutorial page - The DO tutorial article already linked in the exercise introduction (and as a resource in design.md) - A subsequent DO tutorial article focusing specifically on class and instance variables * Fixed typos * General Cleaning Reworded clumsy sentences, deleted whitespace, fixed typos, removed some back-quotes to improve consistency with other documentation. * Fixed typos + removed whitespace * Corrections, Nits, and Picks * Adding IsaacG as contributor * Added IsaacG as contributor Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Co-authored-by: KOTP <keeperotphones+patch@gmail.com>
2022-02-18 23:42:50 +11:00
<__main__.MyClass at 0x15ad99970>
2022-02-18 03:10:42 +11:00
# Second_new_object shares the same class attributes as new_object.
>>> new_object.number == second_new_object.number
True
```
Class attributes are defined in the body of the class itself, before any other methods.
They are owned by the class - allowing them to be shared across instances of the class.
Because these attributes are shared, their value can be accessed and manipulated from the class _directly_.
Altering the value of class attributes alters the value _**for all objects instantiated from the class**_:
```python
[Classes Concept & Ellens Alien Game]: Updates (#2941) * New concept exercise: ellens-alien-game Introduces the concept of classes. Message-Id: <20220126095726.46310-2-keeperotphones+patch@gmail.com> * Update config.json Message-Id: <71aad1e9fc012ef13fa5c02ceb4e3ec349715d85.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <bc2601f32a9d9247ac2f767d1f4267f340a22ec6.1643195691.git.keeperotphones+patch@gmail.com> * Delete introduction-draft.md Message-Id: <d11b031b5ef068658b9e2b1efa882a75c2ba70c5.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <f61ad700909f434f38fb55076ab4dc4d9258a6ab.1643195691.git.keeperotphones+patch@gmail.com> * Create introduction Message-Id: <938209240cdbc86bbddc5c33403659a290ec55ac.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <ca99353a7426f0bea05df556cc19752edf48ffce.1643195691.git.keeperotphones+patch@gmail.com> * Rename introduction to introduction.md Message-Id: <4373a3b66fac460701b429d22c76cd33d8b7db4a.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <c675ca900a18a3ad9f8a6b48cdad1157ea312321.1643195691.git.keeperotphones+patch@gmail.com> * Update and rename design-draft.md to design.md Message-Id: <c863549b1a61dc045162be8d6d42ae9a505cddd1.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <71b06afa96db6e5b6dde815560a5776bc8368e8f.1643195691.git.keeperotphones+patch@gmail.com> * Fixed typo in instructions.md Message-Id: <21826fc58f9cfa53d61e6e3ccf5fcc30e6d9e411.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <88a24ed3e8685ba96fdf26bb4c0629131272281f.1643195691.git.keeperotphones+patch@gmail.com> * Formatting with YAPF Confirmed with pylint and flake8. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <ec52cd798d671348f5b29c0a691155d072c023af.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <58b93bb2ed0919c3e5753e25228bcc175a24edfa.1643195691.git.keeperotphones+patch@gmail.com> * Update config.json Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <467259ba695c8005f7106d1f359b1d4fe6c14562.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <29a418465a89c10dfd711475da4236932c4e8eff.1643195691.git.keeperotphones+patch@gmail.com> * Update exercises/concept/ellens-alien-game/.meta/config.json We'll need to rename the files though Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <933195ff036507b273b55633b40a7b76cc27f130.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <529e34d1258c17b00e20278430682cd237cae6a7.1643195691.git.keeperotphones+patch@gmail.com> * Improve wording and formatting for code formatting Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <cf9cfa5b19e0a51a1b47f11abc6d4bfdef9c7b64.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <5fd8622d5e4147746a85f3f1e63a2d5d64a066b4.1643195691.git.keeperotphones+patch@gmail.com> * Using comprehension for our list of aliens Comprehensions were introduced earlier in the concept, and so we use them here. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <1c8e73efaddfe077fe446aed6989da14398b53c6.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <e49ae05922f3dab213853e10ccad7654a4b44e7c.1643195691.git.keeperotphones+patch@gmail.com> * Rename alien_class_test.py to classes_test.py Message-Id: <493ff778d4422e418d1990f96d10c0d41c4f59ed.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <ff33af10e4617a92fcb343ead33a4060b4c7d6ad.1643195691.git.keeperotphones+patch@gmail.com> * Rename alien_class.py to classes.py Message-Id: <394f35b706b695c4e89ed55c9ee5a440701a78b0.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <52bca7f28924b4006ec1deca1e6bfa45f4f922de.1643195691.git.keeperotphones+patch@gmail.com> * Added pytest decorators to classes.py Message-Id: <8b14cd3955060ba75203fd17f088876af23c403d.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <68f7980c8bc3a8a17bef575aa20b9cfb33af1a60.1643195691.git.keeperotphones+patch@gmail.com> * Filled design.md with content Message-Id: <c785ab3f2ef18847df4b787710f8d49789acb2ff.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <d9fed4beb51fa8cdfd6f998bae46efa1cef878b5.1643195691.git.keeperotphones+patch@gmail.com> * Added missing pytest decorator Message-Id: <e175774a005235c5fe4629efffc1c49b44d4898f.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <85d06e4f2024883c120931fec152cc197a74dbc4.1643195691.git.keeperotphones+patch@gmail.com> * Update instructions.md Message-Id: <4a6c7e47a87398e50d6b864ecafe879d13c522d7.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <adea0f3324e0d5aee0a0ddfb4dc4a001baeff404.1643195691.git.keeperotphones+patch@gmail.com> * Update design.md Message-Id: <e90afd667cb2428c6d86c95a0b692aa3b97c7ce4.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <c8d2ec180d0979d65eb7760495022f58d027b6f1.1643195691.git.keeperotphones+patch@gmail.com> * Update classes.py Message-Id: <1dc38f5ebfcfe86df926b98b465465e540670528.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <30be55cc209a83e431f2cb7d735830ad2ea3e40e.1643195691.git.keeperotphones+patch@gmail.com> * Update hints.md Message-Id: <6ed9657bfa2d166f445f9825b9ccf117d5d6a4b1.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <e935f4bafa27d6da7ea3c1c7827c7f7b55155881.1643195691.git.keeperotphones+patch@gmail.com> * remove trailing whitespace Message-Id: <9e59aa73585b1f50a27dda59d7960c9f89f54dd8.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <b1e7081ca1bed4d9c159e20b42c9e9ada3848923.1643195691.git.keeperotphones+patch@gmail.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Moved back-quotes and added smiley to line 45. Added additional instruction to line 46. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Added back-quotes around `class` and `method`. Specified decrement amount. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Corrected 'function' to 'method' and put back-quotes around it. Single-letter-variables changed to word-variables. Instances of 'position' -> 'coordinate' to maintain consistency with new word-variables. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Added back-quotes (for consistency). Clarified task instruction. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Single-letter-variable -> word-variable (style conformity + consistency) Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.meta/exemplar.py Single-letter-variable -> word-variable (style conformity + consistency) Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update instructions.md All instances of: - coordinate_x -> x_coordinate. - coordinate_y -> y_coordinate * Update exemplar.py Implemented x_coordinate and y_coordinate instance variables (and variants thereof - see teleport method) to conform with both expected style (i.e. no single-letter-variables) and the changes made to instructions.md. * Update exercises/concept/ellens-alien-game/.docs/instructions.md Made the instructions in the first task more explicit. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * design.md: Removed `properties` from Concepts * Code Files Cleanup * Added docstring to exemplar.py Alien class * Corrected tests in classes_test.py * Changed new_alien_list to new_aliens_collection * Edited Instructions to Match Exemplar * Merge branch 'main' of github.com:PaulT89/python Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added contents to intro Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added content to about Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Add content to concept intro Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added two links + descriptions Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Update config.json * Added blurb to config.json * Apply suggestions from code review Fixed a few typos and added missing code block in introduction. * Added additional resources to links.json * Added Python Morsels and Dan Bader * Added links on static vs class methods * Added link on history of New Style classes in python. * Added links + fixed typos Added link to: - Official Python Classes tutorial page - The DO tutorial article already linked in the exercise introduction (and as a resource in design.md) - A subsequent DO tutorial article focusing specifically on class and instance variables * Fixed typos * General Cleaning Reworded clumsy sentences, deleted whitespace, fixed typos, removed some back-quotes to improve consistency with other documentation. * Fixed typos + removed whitespace * Corrections, Nits, and Picks * Adding IsaacG as contributor * Added IsaacG as contributor Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Co-authored-by: KOTP <keeperotphones+patch@gmail.com>
2022-02-18 23:42:50 +11:00
>>> obj_one = MyClass()
>>> obj_two = MyClass()
# Accessing a class attribute from an object.
>>> obj_two.number
5
# Accessing the class attribute from the class itself.
[Classes Concept & Ellens Alien Game]: Updates (#2941) * New concept exercise: ellens-alien-game Introduces the concept of classes. Message-Id: <20220126095726.46310-2-keeperotphones+patch@gmail.com> * Update config.json Message-Id: <71aad1e9fc012ef13fa5c02ceb4e3ec349715d85.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <bc2601f32a9d9247ac2f767d1f4267f340a22ec6.1643195691.git.keeperotphones+patch@gmail.com> * Delete introduction-draft.md Message-Id: <d11b031b5ef068658b9e2b1efa882a75c2ba70c5.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <f61ad700909f434f38fb55076ab4dc4d9258a6ab.1643195691.git.keeperotphones+patch@gmail.com> * Create introduction Message-Id: <938209240cdbc86bbddc5c33403659a290ec55ac.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <ca99353a7426f0bea05df556cc19752edf48ffce.1643195691.git.keeperotphones+patch@gmail.com> * Rename introduction to introduction.md Message-Id: <4373a3b66fac460701b429d22c76cd33d8b7db4a.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <c675ca900a18a3ad9f8a6b48cdad1157ea312321.1643195691.git.keeperotphones+patch@gmail.com> * Update and rename design-draft.md to design.md Message-Id: <c863549b1a61dc045162be8d6d42ae9a505cddd1.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <71b06afa96db6e5b6dde815560a5776bc8368e8f.1643195691.git.keeperotphones+patch@gmail.com> * Fixed typo in instructions.md Message-Id: <21826fc58f9cfa53d61e6e3ccf5fcc30e6d9e411.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <88a24ed3e8685ba96fdf26bb4c0629131272281f.1643195691.git.keeperotphones+patch@gmail.com> * Formatting with YAPF Confirmed with pylint and flake8. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <ec52cd798d671348f5b29c0a691155d072c023af.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <58b93bb2ed0919c3e5753e25228bcc175a24edfa.1643195691.git.keeperotphones+patch@gmail.com> * Update config.json Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <467259ba695c8005f7106d1f359b1d4fe6c14562.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <29a418465a89c10dfd711475da4236932c4e8eff.1643195691.git.keeperotphones+patch@gmail.com> * Update exercises/concept/ellens-alien-game/.meta/config.json We'll need to rename the files though Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <933195ff036507b273b55633b40a7b76cc27f130.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <529e34d1258c17b00e20278430682cd237cae6a7.1643195691.git.keeperotphones+patch@gmail.com> * Improve wording and formatting for code formatting Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <cf9cfa5b19e0a51a1b47f11abc6d4bfdef9c7b64.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <5fd8622d5e4147746a85f3f1e63a2d5d64a066b4.1643195691.git.keeperotphones+patch@gmail.com> * Using comprehension for our list of aliens Comprehensions were introduced earlier in the concept, and so we use them here. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <1c8e73efaddfe077fe446aed6989da14398b53c6.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <e49ae05922f3dab213853e10ccad7654a4b44e7c.1643195691.git.keeperotphones+patch@gmail.com> * Rename alien_class_test.py to classes_test.py Message-Id: <493ff778d4422e418d1990f96d10c0d41c4f59ed.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <ff33af10e4617a92fcb343ead33a4060b4c7d6ad.1643195691.git.keeperotphones+patch@gmail.com> * Rename alien_class.py to classes.py Message-Id: <394f35b706b695c4e89ed55c9ee5a440701a78b0.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <52bca7f28924b4006ec1deca1e6bfa45f4f922de.1643195691.git.keeperotphones+patch@gmail.com> * Added pytest decorators to classes.py Message-Id: <8b14cd3955060ba75203fd17f088876af23c403d.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <68f7980c8bc3a8a17bef575aa20b9cfb33af1a60.1643195691.git.keeperotphones+patch@gmail.com> * Filled design.md with content Message-Id: <c785ab3f2ef18847df4b787710f8d49789acb2ff.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <d9fed4beb51fa8cdfd6f998bae46efa1cef878b5.1643195691.git.keeperotphones+patch@gmail.com> * Added missing pytest decorator Message-Id: <e175774a005235c5fe4629efffc1c49b44d4898f.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <85d06e4f2024883c120931fec152cc197a74dbc4.1643195691.git.keeperotphones+patch@gmail.com> * Update instructions.md Message-Id: <4a6c7e47a87398e50d6b864ecafe879d13c522d7.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <adea0f3324e0d5aee0a0ddfb4dc4a001baeff404.1643195691.git.keeperotphones+patch@gmail.com> * Update design.md Message-Id: <e90afd667cb2428c6d86c95a0b692aa3b97c7ce4.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <c8d2ec180d0979d65eb7760495022f58d027b6f1.1643195691.git.keeperotphones+patch@gmail.com> * Update classes.py Message-Id: <1dc38f5ebfcfe86df926b98b465465e540670528.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <30be55cc209a83e431f2cb7d735830ad2ea3e40e.1643195691.git.keeperotphones+patch@gmail.com> * Update hints.md Message-Id: <6ed9657bfa2d166f445f9825b9ccf117d5d6a4b1.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <e935f4bafa27d6da7ea3c1c7827c7f7b55155881.1643195691.git.keeperotphones+patch@gmail.com> * remove trailing whitespace Message-Id: <9e59aa73585b1f50a27dda59d7960c9f89f54dd8.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <b1e7081ca1bed4d9c159e20b42c9e9ada3848923.1643195691.git.keeperotphones+patch@gmail.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Moved back-quotes and added smiley to line 45. Added additional instruction to line 46. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Added back-quotes around `class` and `method`. Specified decrement amount. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Corrected 'function' to 'method' and put back-quotes around it. Single-letter-variables changed to word-variables. Instances of 'position' -> 'coordinate' to maintain consistency with new word-variables. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Added back-quotes (for consistency). Clarified task instruction. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Single-letter-variable -> word-variable (style conformity + consistency) Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.meta/exemplar.py Single-letter-variable -> word-variable (style conformity + consistency) Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update instructions.md All instances of: - coordinate_x -> x_coordinate. - coordinate_y -> y_coordinate * Update exemplar.py Implemented x_coordinate and y_coordinate instance variables (and variants thereof - see teleport method) to conform with both expected style (i.e. no single-letter-variables) and the changes made to instructions.md. * Update exercises/concept/ellens-alien-game/.docs/instructions.md Made the instructions in the first task more explicit. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * design.md: Removed `properties` from Concepts * Code Files Cleanup * Added docstring to exemplar.py Alien class * Corrected tests in classes_test.py * Changed new_alien_list to new_aliens_collection * Edited Instructions to Match Exemplar * Merge branch 'main' of github.com:PaulT89/python Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added contents to intro Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added content to about Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Add content to concept intro Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added two links + descriptions Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Update config.json * Added blurb to config.json * Apply suggestions from code review Fixed a few typos and added missing code block in introduction. * Added additional resources to links.json * Added Python Morsels and Dan Bader * Added links on static vs class methods * Added link on history of New Style classes in python. * Added links + fixed typos Added link to: - Official Python Classes tutorial page - The DO tutorial article already linked in the exercise introduction (and as a resource in design.md) - A subsequent DO tutorial article focusing specifically on class and instance variables * Fixed typos * General Cleaning Reworded clumsy sentences, deleted whitespace, fixed typos, removed some back-quotes to improve consistency with other documentation. * Fixed typos + removed whitespace * Corrections, Nits, and Picks * Adding IsaacG as contributor * Added IsaacG as contributor Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Co-authored-by: KOTP <keeperotphones+patch@gmail.com>
2022-02-18 23:42:50 +11:00
>>> MyClass.number
5
# Modifying the value of the "number" class attribute.
[Classes Concept & Ellens Alien Game]: Updates (#2941) * New concept exercise: ellens-alien-game Introduces the concept of classes. Message-Id: <20220126095726.46310-2-keeperotphones+patch@gmail.com> * Update config.json Message-Id: <71aad1e9fc012ef13fa5c02ceb4e3ec349715d85.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <bc2601f32a9d9247ac2f767d1f4267f340a22ec6.1643195691.git.keeperotphones+patch@gmail.com> * Delete introduction-draft.md Message-Id: <d11b031b5ef068658b9e2b1efa882a75c2ba70c5.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <f61ad700909f434f38fb55076ab4dc4d9258a6ab.1643195691.git.keeperotphones+patch@gmail.com> * Create introduction Message-Id: <938209240cdbc86bbddc5c33403659a290ec55ac.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <ca99353a7426f0bea05df556cc19752edf48ffce.1643195691.git.keeperotphones+patch@gmail.com> * Rename introduction to introduction.md Message-Id: <4373a3b66fac460701b429d22c76cd33d8b7db4a.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <c675ca900a18a3ad9f8a6b48cdad1157ea312321.1643195691.git.keeperotphones+patch@gmail.com> * Update and rename design-draft.md to design.md Message-Id: <c863549b1a61dc045162be8d6d42ae9a505cddd1.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <71b06afa96db6e5b6dde815560a5776bc8368e8f.1643195691.git.keeperotphones+patch@gmail.com> * Fixed typo in instructions.md Message-Id: <21826fc58f9cfa53d61e6e3ccf5fcc30e6d9e411.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <88a24ed3e8685ba96fdf26bb4c0629131272281f.1643195691.git.keeperotphones+patch@gmail.com> * Formatting with YAPF Confirmed with pylint and flake8. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <ec52cd798d671348f5b29c0a691155d072c023af.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <58b93bb2ed0919c3e5753e25228bcc175a24edfa.1643195691.git.keeperotphones+patch@gmail.com> * Update config.json Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <467259ba695c8005f7106d1f359b1d4fe6c14562.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <29a418465a89c10dfd711475da4236932c4e8eff.1643195691.git.keeperotphones+patch@gmail.com> * Update exercises/concept/ellens-alien-game/.meta/config.json We'll need to rename the files though Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <933195ff036507b273b55633b40a7b76cc27f130.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <529e34d1258c17b00e20278430682cd237cae6a7.1643195691.git.keeperotphones+patch@gmail.com> * Improve wording and formatting for code formatting Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <cf9cfa5b19e0a51a1b47f11abc6d4bfdef9c7b64.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <5fd8622d5e4147746a85f3f1e63a2d5d64a066b4.1643195691.git.keeperotphones+patch@gmail.com> * Using comprehension for our list of aliens Comprehensions were introduced earlier in the concept, and so we use them here. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <1c8e73efaddfe077fe446aed6989da14398b53c6.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <e49ae05922f3dab213853e10ccad7654a4b44e7c.1643195691.git.keeperotphones+patch@gmail.com> * Rename alien_class_test.py to classes_test.py Message-Id: <493ff778d4422e418d1990f96d10c0d41c4f59ed.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <ff33af10e4617a92fcb343ead33a4060b4c7d6ad.1643195691.git.keeperotphones+patch@gmail.com> * Rename alien_class.py to classes.py Message-Id: <394f35b706b695c4e89ed55c9ee5a440701a78b0.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <52bca7f28924b4006ec1deca1e6bfa45f4f922de.1643195691.git.keeperotphones+patch@gmail.com> * Added pytest decorators to classes.py Message-Id: <8b14cd3955060ba75203fd17f088876af23c403d.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <68f7980c8bc3a8a17bef575aa20b9cfb33af1a60.1643195691.git.keeperotphones+patch@gmail.com> * Filled design.md with content Message-Id: <c785ab3f2ef18847df4b787710f8d49789acb2ff.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <d9fed4beb51fa8cdfd6f998bae46efa1cef878b5.1643195691.git.keeperotphones+patch@gmail.com> * Added missing pytest decorator Message-Id: <e175774a005235c5fe4629efffc1c49b44d4898f.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <85d06e4f2024883c120931fec152cc197a74dbc4.1643195691.git.keeperotphones+patch@gmail.com> * Update instructions.md Message-Id: <4a6c7e47a87398e50d6b864ecafe879d13c522d7.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <adea0f3324e0d5aee0a0ddfb4dc4a001baeff404.1643195691.git.keeperotphones+patch@gmail.com> * Update design.md Message-Id: <e90afd667cb2428c6d86c95a0b692aa3b97c7ce4.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <c8d2ec180d0979d65eb7760495022f58d027b6f1.1643195691.git.keeperotphones+patch@gmail.com> * Update classes.py Message-Id: <1dc38f5ebfcfe86df926b98b465465e540670528.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <30be55cc209a83e431f2cb7d735830ad2ea3e40e.1643195691.git.keeperotphones+patch@gmail.com> * Update hints.md Message-Id: <6ed9657bfa2d166f445f9825b9ccf117d5d6a4b1.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <e935f4bafa27d6da7ea3c1c7827c7f7b55155881.1643195691.git.keeperotphones+patch@gmail.com> * remove trailing whitespace Message-Id: <9e59aa73585b1f50a27dda59d7960c9f89f54dd8.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <b1e7081ca1bed4d9c159e20b42c9e9ada3848923.1643195691.git.keeperotphones+patch@gmail.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Moved back-quotes and added smiley to line 45. Added additional instruction to line 46. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Added back-quotes around `class` and `method`. Specified decrement amount. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Corrected 'function' to 'method' and put back-quotes around it. Single-letter-variables changed to word-variables. Instances of 'position' -> 'coordinate' to maintain consistency with new word-variables. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Added back-quotes (for consistency). Clarified task instruction. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Single-letter-variable -> word-variable (style conformity + consistency) Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.meta/exemplar.py Single-letter-variable -> word-variable (style conformity + consistency) Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update instructions.md All instances of: - coordinate_x -> x_coordinate. - coordinate_y -> y_coordinate * Update exemplar.py Implemented x_coordinate and y_coordinate instance variables (and variants thereof - see teleport method) to conform with both expected style (i.e. no single-letter-variables) and the changes made to instructions.md. * Update exercises/concept/ellens-alien-game/.docs/instructions.md Made the instructions in the first task more explicit. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * design.md: Removed `properties` from Concepts * Code Files Cleanup * Added docstring to exemplar.py Alien class * Corrected tests in classes_test.py * Changed new_alien_list to new_aliens_collection * Edited Instructions to Match Exemplar * Merge branch 'main' of github.com:PaulT89/python Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added contents to intro Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added content to about Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Add content to concept intro Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added two links + descriptions Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Update config.json * Added blurb to config.json * Apply suggestions from code review Fixed a few typos and added missing code block in introduction. * Added additional resources to links.json * Added Python Morsels and Dan Bader * Added links on static vs class methods * Added link on history of New Style classes in python. * Added links + fixed typos Added link to: - Official Python Classes tutorial page - The DO tutorial article already linked in the exercise introduction (and as a resource in design.md) - A subsequent DO tutorial article focusing specifically on class and instance variables * Fixed typos * General Cleaning Reworded clumsy sentences, deleted whitespace, fixed typos, removed some back-quotes to improve consistency with other documentation. * Fixed typos + removed whitespace * Corrections, Nits, and Picks * Adding IsaacG as contributor * Added IsaacG as contributor Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Co-authored-by: KOTP <keeperotphones+patch@gmail.com>
2022-02-18 23:42:50 +11:00
>>> MyClass.number = 27
# Modifying the "number" class attribute changes the "number" attribute for all objects.
>>> obj_one.number
27
>>> obj_two.number
27
```
Having a bunch of objects with synchronized data at all times is not particularly useful.
Fortunately, objects created from a class can be customized with their own `instance attributes` (_or instance properties, variables, or fields_).
As their name suggests, instance attributes are unique to each object, and can be modified independently.
[Classes Concept & Ellens Alien Game]: Updates (#2941) * New concept exercise: ellens-alien-game Introduces the concept of classes. Message-Id: <20220126095726.46310-2-keeperotphones+patch@gmail.com> * Update config.json Message-Id: <71aad1e9fc012ef13fa5c02ceb4e3ec349715d85.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <bc2601f32a9d9247ac2f767d1f4267f340a22ec6.1643195691.git.keeperotphones+patch@gmail.com> * Delete introduction-draft.md Message-Id: <d11b031b5ef068658b9e2b1efa882a75c2ba70c5.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <f61ad700909f434f38fb55076ab4dc4d9258a6ab.1643195691.git.keeperotphones+patch@gmail.com> * Create introduction Message-Id: <938209240cdbc86bbddc5c33403659a290ec55ac.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <ca99353a7426f0bea05df556cc19752edf48ffce.1643195691.git.keeperotphones+patch@gmail.com> * Rename introduction to introduction.md Message-Id: <4373a3b66fac460701b429d22c76cd33d8b7db4a.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <c675ca900a18a3ad9f8a6b48cdad1157ea312321.1643195691.git.keeperotphones+patch@gmail.com> * Update and rename design-draft.md to design.md Message-Id: <c863549b1a61dc045162be8d6d42ae9a505cddd1.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <71b06afa96db6e5b6dde815560a5776bc8368e8f.1643195691.git.keeperotphones+patch@gmail.com> * Fixed typo in instructions.md Message-Id: <21826fc58f9cfa53d61e6e3ccf5fcc30e6d9e411.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <88a24ed3e8685ba96fdf26bb4c0629131272281f.1643195691.git.keeperotphones+patch@gmail.com> * Formatting with YAPF Confirmed with pylint and flake8. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <ec52cd798d671348f5b29c0a691155d072c023af.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <58b93bb2ed0919c3e5753e25228bcc175a24edfa.1643195691.git.keeperotphones+patch@gmail.com> * Update config.json Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <467259ba695c8005f7106d1f359b1d4fe6c14562.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <29a418465a89c10dfd711475da4236932c4e8eff.1643195691.git.keeperotphones+patch@gmail.com> * Update exercises/concept/ellens-alien-game/.meta/config.json We'll need to rename the files though Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <933195ff036507b273b55633b40a7b76cc27f130.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <529e34d1258c17b00e20278430682cd237cae6a7.1643195691.git.keeperotphones+patch@gmail.com> * Improve wording and formatting for code formatting Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <cf9cfa5b19e0a51a1b47f11abc6d4bfdef9c7b64.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <5fd8622d5e4147746a85f3f1e63a2d5d64a066b4.1643195691.git.keeperotphones+patch@gmail.com> * Using comprehension for our list of aliens Comprehensions were introduced earlier in the concept, and so we use them here. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <1c8e73efaddfe077fe446aed6989da14398b53c6.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <e49ae05922f3dab213853e10ccad7654a4b44e7c.1643195691.git.keeperotphones+patch@gmail.com> * Rename alien_class_test.py to classes_test.py Message-Id: <493ff778d4422e418d1990f96d10c0d41c4f59ed.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <ff33af10e4617a92fcb343ead33a4060b4c7d6ad.1643195691.git.keeperotphones+patch@gmail.com> * Rename alien_class.py to classes.py Message-Id: <394f35b706b695c4e89ed55c9ee5a440701a78b0.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <52bca7f28924b4006ec1deca1e6bfa45f4f922de.1643195691.git.keeperotphones+patch@gmail.com> * Added pytest decorators to classes.py Message-Id: <8b14cd3955060ba75203fd17f088876af23c403d.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <68f7980c8bc3a8a17bef575aa20b9cfb33af1a60.1643195691.git.keeperotphones+patch@gmail.com> * Filled design.md with content Message-Id: <c785ab3f2ef18847df4b787710f8d49789acb2ff.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <d9fed4beb51fa8cdfd6f998bae46efa1cef878b5.1643195691.git.keeperotphones+patch@gmail.com> * Added missing pytest decorator Message-Id: <e175774a005235c5fe4629efffc1c49b44d4898f.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <85d06e4f2024883c120931fec152cc197a74dbc4.1643195691.git.keeperotphones+patch@gmail.com> * Update instructions.md Message-Id: <4a6c7e47a87398e50d6b864ecafe879d13c522d7.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <adea0f3324e0d5aee0a0ddfb4dc4a001baeff404.1643195691.git.keeperotphones+patch@gmail.com> * Update design.md Message-Id: <e90afd667cb2428c6d86c95a0b692aa3b97c7ce4.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <c8d2ec180d0979d65eb7760495022f58d027b6f1.1643195691.git.keeperotphones+patch@gmail.com> * Update classes.py Message-Id: <1dc38f5ebfcfe86df926b98b465465e540670528.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <30be55cc209a83e431f2cb7d735830ad2ea3e40e.1643195691.git.keeperotphones+patch@gmail.com> * Update hints.md Message-Id: <6ed9657bfa2d166f445f9825b9ccf117d5d6a4b1.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <e935f4bafa27d6da7ea3c1c7827c7f7b55155881.1643195691.git.keeperotphones+patch@gmail.com> * remove trailing whitespace Message-Id: <9e59aa73585b1f50a27dda59d7960c9f89f54dd8.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <b1e7081ca1bed4d9c159e20b42c9e9ada3848923.1643195691.git.keeperotphones+patch@gmail.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Moved back-quotes and added smiley to line 45. Added additional instruction to line 46. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Added back-quotes around `class` and `method`. Specified decrement amount. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Corrected 'function' to 'method' and put back-quotes around it. Single-letter-variables changed to word-variables. Instances of 'position' -> 'coordinate' to maintain consistency with new word-variables. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Added back-quotes (for consistency). Clarified task instruction. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Single-letter-variable -> word-variable (style conformity + consistency) Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.meta/exemplar.py Single-letter-variable -> word-variable (style conformity + consistency) Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update instructions.md All instances of: - coordinate_x -> x_coordinate. - coordinate_y -> y_coordinate * Update exemplar.py Implemented x_coordinate and y_coordinate instance variables (and variants thereof - see teleport method) to conform with both expected style (i.e. no single-letter-variables) and the changes made to instructions.md. * Update exercises/concept/ellens-alien-game/.docs/instructions.md Made the instructions in the first task more explicit. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * design.md: Removed `properties` from Concepts * Code Files Cleanup * Added docstring to exemplar.py Alien class * Corrected tests in classes_test.py * Changed new_alien_list to new_aliens_collection * Edited Instructions to Match Exemplar * Merge branch 'main' of github.com:PaulT89/python Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added contents to intro Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added content to about Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Add content to concept intro Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added two links + descriptions Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Update config.json * Added blurb to config.json * Apply suggestions from code review Fixed a few typos and added missing code block in introduction. * Added additional resources to links.json * Added Python Morsels and Dan Bader * Added links on static vs class methods * Added link on history of New Style classes in python. * Added links + fixed typos Added link to: - Official Python Classes tutorial page - The DO tutorial article already linked in the exercise introduction (and as a resource in design.md) - A subsequent DO tutorial article focusing specifically on class and instance variables * Fixed typos * General Cleaning Reworded clumsy sentences, deleted whitespace, fixed typos, removed some back-quotes to improve consistency with other documentation. * Fixed typos + removed whitespace * Corrections, Nits, and Picks * Adding IsaacG as contributor * Added IsaacG as contributor Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Co-authored-by: KOTP <keeperotphones+patch@gmail.com>
2022-02-18 23:42:50 +11:00
## Customizing Object Instantiation with `__init__()`
The special ["dunder method"][dunder] (_short for "double underscore method"_) `__init__()` is used to customize class instances, and can be used to initialize instance attributes or properties for objects.
[Classes Concept & Ellens Alien Game]: Updates (#2941) * New concept exercise: ellens-alien-game Introduces the concept of classes. Message-Id: <20220126095726.46310-2-keeperotphones+patch@gmail.com> * Update config.json Message-Id: <71aad1e9fc012ef13fa5c02ceb4e3ec349715d85.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <bc2601f32a9d9247ac2f767d1f4267f340a22ec6.1643195691.git.keeperotphones+patch@gmail.com> * Delete introduction-draft.md Message-Id: <d11b031b5ef068658b9e2b1efa882a75c2ba70c5.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <f61ad700909f434f38fb55076ab4dc4d9258a6ab.1643195691.git.keeperotphones+patch@gmail.com> * Create introduction Message-Id: <938209240cdbc86bbddc5c33403659a290ec55ac.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <ca99353a7426f0bea05df556cc19752edf48ffce.1643195691.git.keeperotphones+patch@gmail.com> * Rename introduction to introduction.md Message-Id: <4373a3b66fac460701b429d22c76cd33d8b7db4a.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <c675ca900a18a3ad9f8a6b48cdad1157ea312321.1643195691.git.keeperotphones+patch@gmail.com> * Update and rename design-draft.md to design.md Message-Id: <c863549b1a61dc045162be8d6d42ae9a505cddd1.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <71b06afa96db6e5b6dde815560a5776bc8368e8f.1643195691.git.keeperotphones+patch@gmail.com> * Fixed typo in instructions.md Message-Id: <21826fc58f9cfa53d61e6e3ccf5fcc30e6d9e411.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <88a24ed3e8685ba96fdf26bb4c0629131272281f.1643195691.git.keeperotphones+patch@gmail.com> * Formatting with YAPF Confirmed with pylint and flake8. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <ec52cd798d671348f5b29c0a691155d072c023af.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <58b93bb2ed0919c3e5753e25228bcc175a24edfa.1643195691.git.keeperotphones+patch@gmail.com> * Update config.json Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <467259ba695c8005f7106d1f359b1d4fe6c14562.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <29a418465a89c10dfd711475da4236932c4e8eff.1643195691.git.keeperotphones+patch@gmail.com> * Update exercises/concept/ellens-alien-game/.meta/config.json We'll need to rename the files though Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <933195ff036507b273b55633b40a7b76cc27f130.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <529e34d1258c17b00e20278430682cd237cae6a7.1643195691.git.keeperotphones+patch@gmail.com> * Improve wording and formatting for code formatting Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <cf9cfa5b19e0a51a1b47f11abc6d4bfdef9c7b64.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <5fd8622d5e4147746a85f3f1e63a2d5d64a066b4.1643195691.git.keeperotphones+patch@gmail.com> * Using comprehension for our list of aliens Comprehensions were introduced earlier in the concept, and so we use them here. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <1c8e73efaddfe077fe446aed6989da14398b53c6.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <e49ae05922f3dab213853e10ccad7654a4b44e7c.1643195691.git.keeperotphones+patch@gmail.com> * Rename alien_class_test.py to classes_test.py Message-Id: <493ff778d4422e418d1990f96d10c0d41c4f59ed.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <ff33af10e4617a92fcb343ead33a4060b4c7d6ad.1643195691.git.keeperotphones+patch@gmail.com> * Rename alien_class.py to classes.py Message-Id: <394f35b706b695c4e89ed55c9ee5a440701a78b0.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <52bca7f28924b4006ec1deca1e6bfa45f4f922de.1643195691.git.keeperotphones+patch@gmail.com> * Added pytest decorators to classes.py Message-Id: <8b14cd3955060ba75203fd17f088876af23c403d.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <68f7980c8bc3a8a17bef575aa20b9cfb33af1a60.1643195691.git.keeperotphones+patch@gmail.com> * Filled design.md with content Message-Id: <c785ab3f2ef18847df4b787710f8d49789acb2ff.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <d9fed4beb51fa8cdfd6f998bae46efa1cef878b5.1643195691.git.keeperotphones+patch@gmail.com> * Added missing pytest decorator Message-Id: <e175774a005235c5fe4629efffc1c49b44d4898f.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <85d06e4f2024883c120931fec152cc197a74dbc4.1643195691.git.keeperotphones+patch@gmail.com> * Update instructions.md Message-Id: <4a6c7e47a87398e50d6b864ecafe879d13c522d7.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <adea0f3324e0d5aee0a0ddfb4dc4a001baeff404.1643195691.git.keeperotphones+patch@gmail.com> * Update design.md Message-Id: <e90afd667cb2428c6d86c95a0b692aa3b97c7ce4.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <c8d2ec180d0979d65eb7760495022f58d027b6f1.1643195691.git.keeperotphones+patch@gmail.com> * Update classes.py Message-Id: <1dc38f5ebfcfe86df926b98b465465e540670528.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <30be55cc209a83e431f2cb7d735830ad2ea3e40e.1643195691.git.keeperotphones+patch@gmail.com> * Update hints.md Message-Id: <6ed9657bfa2d166f445f9825b9ccf117d5d6a4b1.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <e935f4bafa27d6da7ea3c1c7827c7f7b55155881.1643195691.git.keeperotphones+patch@gmail.com> * remove trailing whitespace Message-Id: <9e59aa73585b1f50a27dda59d7960c9f89f54dd8.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <b1e7081ca1bed4d9c159e20b42c9e9ada3848923.1643195691.git.keeperotphones+patch@gmail.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Moved back-quotes and added smiley to line 45. Added additional instruction to line 46. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Added back-quotes around `class` and `method`. Specified decrement amount. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Corrected 'function' to 'method' and put back-quotes around it. Single-letter-variables changed to word-variables. Instances of 'position' -> 'coordinate' to maintain consistency with new word-variables. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Added back-quotes (for consistency). Clarified task instruction. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Single-letter-variable -> word-variable (style conformity + consistency) Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.meta/exemplar.py Single-letter-variable -> word-variable (style conformity + consistency) Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update instructions.md All instances of: - coordinate_x -> x_coordinate. - coordinate_y -> y_coordinate * Update exemplar.py Implemented x_coordinate and y_coordinate instance variables (and variants thereof - see teleport method) to conform with both expected style (i.e. no single-letter-variables) and the changes made to instructions.md. * Update exercises/concept/ellens-alien-game/.docs/instructions.md Made the instructions in the first task more explicit. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * design.md: Removed `properties` from Concepts * Code Files Cleanup * Added docstring to exemplar.py Alien class * Corrected tests in classes_test.py * Changed new_alien_list to new_aliens_collection * Edited Instructions to Match Exemplar * Merge branch 'main' of github.com:PaulT89/python Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added contents to intro Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added content to about Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Add content to concept intro Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added two links + descriptions Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Update config.json * Added blurb to config.json * Apply suggestions from code review Fixed a few typos and added missing code block in introduction. * Added additional resources to links.json * Added Python Morsels and Dan Bader * Added links on static vs class methods * Added link on history of New Style classes in python. * Added links + fixed typos Added link to: - Official Python Classes tutorial page - The DO tutorial article already linked in the exercise introduction (and as a resource in design.md) - A subsequent DO tutorial article focusing specifically on class and instance variables * Fixed typos * General Cleaning Reworded clumsy sentences, deleted whitespace, fixed typos, removed some back-quotes to improve consistency with other documentation. * Fixed typos + removed whitespace * Corrections, Nits, and Picks * Adding IsaacG as contributor * Added IsaacG as contributor Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Co-authored-by: KOTP <keeperotphones+patch@gmail.com>
2022-02-18 23:42:50 +11:00
For its role in initializing instance attributes, `__init__()` is also referred to as a `class constructor` or `initializer`.
`__init__()` takes one required parameter called `self`, which refers to the newly initialized or created object.
Data for instance attributes or properties can then be passed as arguments of `__init__()`, following the `self` parameter.
[Classes Concept & Ellens Alien Game]: Updates (#2941) * New concept exercise: ellens-alien-game Introduces the concept of classes. Message-Id: <20220126095726.46310-2-keeperotphones+patch@gmail.com> * Update config.json Message-Id: <71aad1e9fc012ef13fa5c02ceb4e3ec349715d85.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <bc2601f32a9d9247ac2f767d1f4267f340a22ec6.1643195691.git.keeperotphones+patch@gmail.com> * Delete introduction-draft.md Message-Id: <d11b031b5ef068658b9e2b1efa882a75c2ba70c5.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <f61ad700909f434f38fb55076ab4dc4d9258a6ab.1643195691.git.keeperotphones+patch@gmail.com> * Create introduction Message-Id: <938209240cdbc86bbddc5c33403659a290ec55ac.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <ca99353a7426f0bea05df556cc19752edf48ffce.1643195691.git.keeperotphones+patch@gmail.com> * Rename introduction to introduction.md Message-Id: <4373a3b66fac460701b429d22c76cd33d8b7db4a.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <c675ca900a18a3ad9f8a6b48cdad1157ea312321.1643195691.git.keeperotphones+patch@gmail.com> * Update and rename design-draft.md to design.md Message-Id: <c863549b1a61dc045162be8d6d42ae9a505cddd1.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <71b06afa96db6e5b6dde815560a5776bc8368e8f.1643195691.git.keeperotphones+patch@gmail.com> * Fixed typo in instructions.md Message-Id: <21826fc58f9cfa53d61e6e3ccf5fcc30e6d9e411.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <88a24ed3e8685ba96fdf26bb4c0629131272281f.1643195691.git.keeperotphones+patch@gmail.com> * Formatting with YAPF Confirmed with pylint and flake8. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <ec52cd798d671348f5b29c0a691155d072c023af.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <58b93bb2ed0919c3e5753e25228bcc175a24edfa.1643195691.git.keeperotphones+patch@gmail.com> * Update config.json Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <467259ba695c8005f7106d1f359b1d4fe6c14562.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <29a418465a89c10dfd711475da4236932c4e8eff.1643195691.git.keeperotphones+patch@gmail.com> * Update exercises/concept/ellens-alien-game/.meta/config.json We'll need to rename the files though Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <933195ff036507b273b55633b40a7b76cc27f130.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <529e34d1258c17b00e20278430682cd237cae6a7.1643195691.git.keeperotphones+patch@gmail.com> * Improve wording and formatting for code formatting Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <cf9cfa5b19e0a51a1b47f11abc6d4bfdef9c7b64.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <5fd8622d5e4147746a85f3f1e63a2d5d64a066b4.1643195691.git.keeperotphones+patch@gmail.com> * Using comprehension for our list of aliens Comprehensions were introduced earlier in the concept, and so we use them here. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <1c8e73efaddfe077fe446aed6989da14398b53c6.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <e49ae05922f3dab213853e10ccad7654a4b44e7c.1643195691.git.keeperotphones+patch@gmail.com> * Rename alien_class_test.py to classes_test.py Message-Id: <493ff778d4422e418d1990f96d10c0d41c4f59ed.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <ff33af10e4617a92fcb343ead33a4060b4c7d6ad.1643195691.git.keeperotphones+patch@gmail.com> * Rename alien_class.py to classes.py Message-Id: <394f35b706b695c4e89ed55c9ee5a440701a78b0.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <52bca7f28924b4006ec1deca1e6bfa45f4f922de.1643195691.git.keeperotphones+patch@gmail.com> * Added pytest decorators to classes.py Message-Id: <8b14cd3955060ba75203fd17f088876af23c403d.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <68f7980c8bc3a8a17bef575aa20b9cfb33af1a60.1643195691.git.keeperotphones+patch@gmail.com> * Filled design.md with content Message-Id: <c785ab3f2ef18847df4b787710f8d49789acb2ff.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <d9fed4beb51fa8cdfd6f998bae46efa1cef878b5.1643195691.git.keeperotphones+patch@gmail.com> * Added missing pytest decorator Message-Id: <e175774a005235c5fe4629efffc1c49b44d4898f.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <85d06e4f2024883c120931fec152cc197a74dbc4.1643195691.git.keeperotphones+patch@gmail.com> * Update instructions.md Message-Id: <4a6c7e47a87398e50d6b864ecafe879d13c522d7.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <adea0f3324e0d5aee0a0ddfb4dc4a001baeff404.1643195691.git.keeperotphones+patch@gmail.com> * Update design.md Message-Id: <e90afd667cb2428c6d86c95a0b692aa3b97c7ce4.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <c8d2ec180d0979d65eb7760495022f58d027b6f1.1643195691.git.keeperotphones+patch@gmail.com> * Update classes.py Message-Id: <1dc38f5ebfcfe86df926b98b465465e540670528.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <30be55cc209a83e431f2cb7d735830ad2ea3e40e.1643195691.git.keeperotphones+patch@gmail.com> * Update hints.md Message-Id: <6ed9657bfa2d166f445f9825b9ccf117d5d6a4b1.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <e935f4bafa27d6da7ea3c1c7827c7f7b55155881.1643195691.git.keeperotphones+patch@gmail.com> * remove trailing whitespace Message-Id: <9e59aa73585b1f50a27dda59d7960c9f89f54dd8.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <b1e7081ca1bed4d9c159e20b42c9e9ada3848923.1643195691.git.keeperotphones+patch@gmail.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Moved back-quotes and added smiley to line 45. Added additional instruction to line 46. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Added back-quotes around `class` and `method`. Specified decrement amount. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Corrected 'function' to 'method' and put back-quotes around it. Single-letter-variables changed to word-variables. Instances of 'position' -> 'coordinate' to maintain consistency with new word-variables. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Added back-quotes (for consistency). Clarified task instruction. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Single-letter-variable -> word-variable (style conformity + consistency) Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.meta/exemplar.py Single-letter-variable -> word-variable (style conformity + consistency) Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update instructions.md All instances of: - coordinate_x -> x_coordinate. - coordinate_y -> y_coordinate * Update exemplar.py Implemented x_coordinate and y_coordinate instance variables (and variants thereof - see teleport method) to conform with both expected style (i.e. no single-letter-variables) and the changes made to instructions.md. * Update exercises/concept/ellens-alien-game/.docs/instructions.md Made the instructions in the first task more explicit. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * design.md: Removed `properties` from Concepts * Code Files Cleanup * Added docstring to exemplar.py Alien class * Corrected tests in classes_test.py * Changed new_alien_list to new_aliens_collection * Edited Instructions to Match Exemplar * Merge branch 'main' of github.com:PaulT89/python Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added contents to intro Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added content to about Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Add content to concept intro Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added two links + descriptions Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Update config.json * Added blurb to config.json * Apply suggestions from code review Fixed a few typos and added missing code block in introduction. * Added additional resources to links.json * Added Python Morsels and Dan Bader * Added links on static vs class methods * Added link on history of New Style classes in python. * Added links + fixed typos Added link to: - Official Python Classes tutorial page - The DO tutorial article already linked in the exercise introduction (and as a resource in design.md) - A subsequent DO tutorial article focusing specifically on class and instance variables * Fixed typos * General Cleaning Reworded clumsy sentences, deleted whitespace, fixed typos, removed some back-quotes to improve consistency with other documentation. * Fixed typos + removed whitespace * Corrections, Nits, and Picks * Adding IsaacG as contributor * Added IsaacG as contributor Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Co-authored-by: KOTP <keeperotphones+patch@gmail.com>
2022-02-18 23:42:50 +11:00
Below, `MyClass` now has instance attributes called `location_x` and `location_y`.
As you can see, the two attributes have been assigned to the first and second indexes of the `location` (_a tuple_) argument that has been passed to `__init__()`.
[Classes Concept & Ellens Alien Game]: Updates (#2941) * New concept exercise: ellens-alien-game Introduces the concept of classes. Message-Id: <20220126095726.46310-2-keeperotphones+patch@gmail.com> * Update config.json Message-Id: <71aad1e9fc012ef13fa5c02ceb4e3ec349715d85.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <bc2601f32a9d9247ac2f767d1f4267f340a22ec6.1643195691.git.keeperotphones+patch@gmail.com> * Delete introduction-draft.md Message-Id: <d11b031b5ef068658b9e2b1efa882a75c2ba70c5.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <f61ad700909f434f38fb55076ab4dc4d9258a6ab.1643195691.git.keeperotphones+patch@gmail.com> * Create introduction Message-Id: <938209240cdbc86bbddc5c33403659a290ec55ac.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <ca99353a7426f0bea05df556cc19752edf48ffce.1643195691.git.keeperotphones+patch@gmail.com> * Rename introduction to introduction.md Message-Id: <4373a3b66fac460701b429d22c76cd33d8b7db4a.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <c675ca900a18a3ad9f8a6b48cdad1157ea312321.1643195691.git.keeperotphones+patch@gmail.com> * Update and rename design-draft.md to design.md Message-Id: <c863549b1a61dc045162be8d6d42ae9a505cddd1.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <71b06afa96db6e5b6dde815560a5776bc8368e8f.1643195691.git.keeperotphones+patch@gmail.com> * Fixed typo in instructions.md Message-Id: <21826fc58f9cfa53d61e6e3ccf5fcc30e6d9e411.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <88a24ed3e8685ba96fdf26bb4c0629131272281f.1643195691.git.keeperotphones+patch@gmail.com> * Formatting with YAPF Confirmed with pylint and flake8. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <ec52cd798d671348f5b29c0a691155d072c023af.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <58b93bb2ed0919c3e5753e25228bcc175a24edfa.1643195691.git.keeperotphones+patch@gmail.com> * Update config.json Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <467259ba695c8005f7106d1f359b1d4fe6c14562.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <29a418465a89c10dfd711475da4236932c4e8eff.1643195691.git.keeperotphones+patch@gmail.com> * Update exercises/concept/ellens-alien-game/.meta/config.json We'll need to rename the files though Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <933195ff036507b273b55633b40a7b76cc27f130.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <529e34d1258c17b00e20278430682cd237cae6a7.1643195691.git.keeperotphones+patch@gmail.com> * Improve wording and formatting for code formatting Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <cf9cfa5b19e0a51a1b47f11abc6d4bfdef9c7b64.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <5fd8622d5e4147746a85f3f1e63a2d5d64a066b4.1643195691.git.keeperotphones+patch@gmail.com> * Using comprehension for our list of aliens Comprehensions were introduced earlier in the concept, and so we use them here. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <1c8e73efaddfe077fe446aed6989da14398b53c6.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <e49ae05922f3dab213853e10ccad7654a4b44e7c.1643195691.git.keeperotphones+patch@gmail.com> * Rename alien_class_test.py to classes_test.py Message-Id: <493ff778d4422e418d1990f96d10c0d41c4f59ed.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <ff33af10e4617a92fcb343ead33a4060b4c7d6ad.1643195691.git.keeperotphones+patch@gmail.com> * Rename alien_class.py to classes.py Message-Id: <394f35b706b695c4e89ed55c9ee5a440701a78b0.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <52bca7f28924b4006ec1deca1e6bfa45f4f922de.1643195691.git.keeperotphones+patch@gmail.com> * Added pytest decorators to classes.py Message-Id: <8b14cd3955060ba75203fd17f088876af23c403d.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <68f7980c8bc3a8a17bef575aa20b9cfb33af1a60.1643195691.git.keeperotphones+patch@gmail.com> * Filled design.md with content Message-Id: <c785ab3f2ef18847df4b787710f8d49789acb2ff.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <d9fed4beb51fa8cdfd6f998bae46efa1cef878b5.1643195691.git.keeperotphones+patch@gmail.com> * Added missing pytest decorator Message-Id: <e175774a005235c5fe4629efffc1c49b44d4898f.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <85d06e4f2024883c120931fec152cc197a74dbc4.1643195691.git.keeperotphones+patch@gmail.com> * Update instructions.md Message-Id: <4a6c7e47a87398e50d6b864ecafe879d13c522d7.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <adea0f3324e0d5aee0a0ddfb4dc4a001baeff404.1643195691.git.keeperotphones+patch@gmail.com> * Update design.md Message-Id: <e90afd667cb2428c6d86c95a0b692aa3b97c7ce4.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <c8d2ec180d0979d65eb7760495022f58d027b6f1.1643195691.git.keeperotphones+patch@gmail.com> * Update classes.py Message-Id: <1dc38f5ebfcfe86df926b98b465465e540670528.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <30be55cc209a83e431f2cb7d735830ad2ea3e40e.1643195691.git.keeperotphones+patch@gmail.com> * Update hints.md Message-Id: <6ed9657bfa2d166f445f9825b9ccf117d5d6a4b1.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <e935f4bafa27d6da7ea3c1c7827c7f7b55155881.1643195691.git.keeperotphones+patch@gmail.com> * remove trailing whitespace Message-Id: <9e59aa73585b1f50a27dda59d7960c9f89f54dd8.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <b1e7081ca1bed4d9c159e20b42c9e9ada3848923.1643195691.git.keeperotphones+patch@gmail.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Moved back-quotes and added smiley to line 45. Added additional instruction to line 46. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Added back-quotes around `class` and `method`. Specified decrement amount. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Corrected 'function' to 'method' and put back-quotes around it. Single-letter-variables changed to word-variables. Instances of 'position' -> 'coordinate' to maintain consistency with new word-variables. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Added back-quotes (for consistency). Clarified task instruction. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Single-letter-variable -> word-variable (style conformity + consistency) Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.meta/exemplar.py Single-letter-variable -> word-variable (style conformity + consistency) Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update instructions.md All instances of: - coordinate_x -> x_coordinate. - coordinate_y -> y_coordinate * Update exemplar.py Implemented x_coordinate and y_coordinate instance variables (and variants thereof - see teleport method) to conform with both expected style (i.e. no single-letter-variables) and the changes made to instructions.md. * Update exercises/concept/ellens-alien-game/.docs/instructions.md Made the instructions in the first task more explicit. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * design.md: Removed `properties` from Concepts * Code Files Cleanup * Added docstring to exemplar.py Alien class * Corrected tests in classes_test.py * Changed new_alien_list to new_aliens_collection * Edited Instructions to Match Exemplar * Merge branch 'main' of github.com:PaulT89/python Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added contents to intro Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added content to about Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Add content to concept intro Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added two links + descriptions Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Update config.json * Added blurb to config.json * Apply suggestions from code review Fixed a few typos and added missing code block in introduction. * Added additional resources to links.json * Added Python Morsels and Dan Bader * Added links on static vs class methods * Added link on history of New Style classes in python. * Added links + fixed typos Added link to: - Official Python Classes tutorial page - The DO tutorial article already linked in the exercise introduction (and as a resource in design.md) - A subsequent DO tutorial article focusing specifically on class and instance variables * Fixed typos * General Cleaning Reworded clumsy sentences, deleted whitespace, fixed typos, removed some back-quotes to improve consistency with other documentation. * Fixed typos + removed whitespace * Corrections, Nits, and Picks * Adding IsaacG as contributor * Added IsaacG as contributor Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Co-authored-by: KOTP <keeperotphones+patch@gmail.com>
2022-02-18 23:42:50 +11:00
The `location_x` and `location_y` attributes for a class instance will now be initialized when you instantiate the class, and an object is created:
```python
[Classes Concept & Ellens Alien Game]: Updates (#2941) * New concept exercise: ellens-alien-game Introduces the concept of classes. Message-Id: <20220126095726.46310-2-keeperotphones+patch@gmail.com> * Update config.json Message-Id: <71aad1e9fc012ef13fa5c02ceb4e3ec349715d85.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <bc2601f32a9d9247ac2f767d1f4267f340a22ec6.1643195691.git.keeperotphones+patch@gmail.com> * Delete introduction-draft.md Message-Id: <d11b031b5ef068658b9e2b1efa882a75c2ba70c5.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <f61ad700909f434f38fb55076ab4dc4d9258a6ab.1643195691.git.keeperotphones+patch@gmail.com> * Create introduction Message-Id: <938209240cdbc86bbddc5c33403659a290ec55ac.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <ca99353a7426f0bea05df556cc19752edf48ffce.1643195691.git.keeperotphones+patch@gmail.com> * Rename introduction to introduction.md Message-Id: <4373a3b66fac460701b429d22c76cd33d8b7db4a.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <c675ca900a18a3ad9f8a6b48cdad1157ea312321.1643195691.git.keeperotphones+patch@gmail.com> * Update and rename design-draft.md to design.md Message-Id: <c863549b1a61dc045162be8d6d42ae9a505cddd1.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <71b06afa96db6e5b6dde815560a5776bc8368e8f.1643195691.git.keeperotphones+patch@gmail.com> * Fixed typo in instructions.md Message-Id: <21826fc58f9cfa53d61e6e3ccf5fcc30e6d9e411.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <88a24ed3e8685ba96fdf26bb4c0629131272281f.1643195691.git.keeperotphones+patch@gmail.com> * Formatting with YAPF Confirmed with pylint and flake8. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <ec52cd798d671348f5b29c0a691155d072c023af.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <58b93bb2ed0919c3e5753e25228bcc175a24edfa.1643195691.git.keeperotphones+patch@gmail.com> * Update config.json Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <467259ba695c8005f7106d1f359b1d4fe6c14562.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <29a418465a89c10dfd711475da4236932c4e8eff.1643195691.git.keeperotphones+patch@gmail.com> * Update exercises/concept/ellens-alien-game/.meta/config.json We'll need to rename the files though Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <933195ff036507b273b55633b40a7b76cc27f130.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <529e34d1258c17b00e20278430682cd237cae6a7.1643195691.git.keeperotphones+patch@gmail.com> * Improve wording and formatting for code formatting Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <cf9cfa5b19e0a51a1b47f11abc6d4bfdef9c7b64.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <5fd8622d5e4147746a85f3f1e63a2d5d64a066b4.1643195691.git.keeperotphones+patch@gmail.com> * Using comprehension for our list of aliens Comprehensions were introduced earlier in the concept, and so we use them here. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <1c8e73efaddfe077fe446aed6989da14398b53c6.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <e49ae05922f3dab213853e10ccad7654a4b44e7c.1643195691.git.keeperotphones+patch@gmail.com> * Rename alien_class_test.py to classes_test.py Message-Id: <493ff778d4422e418d1990f96d10c0d41c4f59ed.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <ff33af10e4617a92fcb343ead33a4060b4c7d6ad.1643195691.git.keeperotphones+patch@gmail.com> * Rename alien_class.py to classes.py Message-Id: <394f35b706b695c4e89ed55c9ee5a440701a78b0.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <52bca7f28924b4006ec1deca1e6bfa45f4f922de.1643195691.git.keeperotphones+patch@gmail.com> * Added pytest decorators to classes.py Message-Id: <8b14cd3955060ba75203fd17f088876af23c403d.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <68f7980c8bc3a8a17bef575aa20b9cfb33af1a60.1643195691.git.keeperotphones+patch@gmail.com> * Filled design.md with content Message-Id: <c785ab3f2ef18847df4b787710f8d49789acb2ff.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <d9fed4beb51fa8cdfd6f998bae46efa1cef878b5.1643195691.git.keeperotphones+patch@gmail.com> * Added missing pytest decorator Message-Id: <e175774a005235c5fe4629efffc1c49b44d4898f.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <85d06e4f2024883c120931fec152cc197a74dbc4.1643195691.git.keeperotphones+patch@gmail.com> * Update instructions.md Message-Id: <4a6c7e47a87398e50d6b864ecafe879d13c522d7.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <adea0f3324e0d5aee0a0ddfb4dc4a001baeff404.1643195691.git.keeperotphones+patch@gmail.com> * Update design.md Message-Id: <e90afd667cb2428c6d86c95a0b692aa3b97c7ce4.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <c8d2ec180d0979d65eb7760495022f58d027b6f1.1643195691.git.keeperotphones+patch@gmail.com> * Update classes.py Message-Id: <1dc38f5ebfcfe86df926b98b465465e540670528.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <30be55cc209a83e431f2cb7d735830ad2ea3e40e.1643195691.git.keeperotphones+patch@gmail.com> * Update hints.md Message-Id: <6ed9657bfa2d166f445f9825b9ccf117d5d6a4b1.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <e935f4bafa27d6da7ea3c1c7827c7f7b55155881.1643195691.git.keeperotphones+patch@gmail.com> * remove trailing whitespace Message-Id: <9e59aa73585b1f50a27dda59d7960c9f89f54dd8.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <b1e7081ca1bed4d9c159e20b42c9e9ada3848923.1643195691.git.keeperotphones+patch@gmail.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Moved back-quotes and added smiley to line 45. Added additional instruction to line 46. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Added back-quotes around `class` and `method`. Specified decrement amount. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Corrected 'function' to 'method' and put back-quotes around it. Single-letter-variables changed to word-variables. Instances of 'position' -> 'coordinate' to maintain consistency with new word-variables. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Added back-quotes (for consistency). Clarified task instruction. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Single-letter-variable -> word-variable (style conformity + consistency) Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.meta/exemplar.py Single-letter-variable -> word-variable (style conformity + consistency) Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update instructions.md All instances of: - coordinate_x -> x_coordinate. - coordinate_y -> y_coordinate * Update exemplar.py Implemented x_coordinate and y_coordinate instance variables (and variants thereof - see teleport method) to conform with both expected style (i.e. no single-letter-variables) and the changes made to instructions.md. * Update exercises/concept/ellens-alien-game/.docs/instructions.md Made the instructions in the first task more explicit. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * design.md: Removed `properties` from Concepts * Code Files Cleanup * Added docstring to exemplar.py Alien class * Corrected tests in classes_test.py * Changed new_alien_list to new_aliens_collection * Edited Instructions to Match Exemplar * Merge branch 'main' of github.com:PaulT89/python Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added contents to intro Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added content to about Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Add content to concept intro Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added two links + descriptions Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Update config.json * Added blurb to config.json * Apply suggestions from code review Fixed a few typos and added missing code block in introduction. * Added additional resources to links.json * Added Python Morsels and Dan Bader * Added links on static vs class methods * Added link on history of New Style classes in python. * Added links + fixed typos Added link to: - Official Python Classes tutorial page - The DO tutorial article already linked in the exercise introduction (and as a resource in design.md) - A subsequent DO tutorial article focusing specifically on class and instance variables * Fixed typos * General Cleaning Reworded clumsy sentences, deleted whitespace, fixed typos, removed some back-quotes to improve consistency with other documentation. * Fixed typos + removed whitespace * Corrections, Nits, and Picks * Adding IsaacG as contributor * Added IsaacG as contributor Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Co-authored-by: KOTP <keeperotphones+patch@gmail.com>
2022-02-18 23:42:50 +11:00
class MyClass:
# These are class attributes, variables, or fields.
number = 5
string = "Hello!"
# This is the class "constructor", with a "location" parameter that is a tuple.
def __init__(self, location):
# This is an instance or object property, attribute, or variable.
# Note that we are unpacking the tuple argument into two separate instance variables.
self.location_x = location[0]
self.location_y = location[1]
2022-02-18 03:10:42 +11:00
# Create a new object "new_object_one", with object property (1, 2).
[Classes Concept & Ellens Alien Game]: Updates (#2941) * New concept exercise: ellens-alien-game Introduces the concept of classes. Message-Id: <20220126095726.46310-2-keeperotphones+patch@gmail.com> * Update config.json Message-Id: <71aad1e9fc012ef13fa5c02ceb4e3ec349715d85.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <bc2601f32a9d9247ac2f767d1f4267f340a22ec6.1643195691.git.keeperotphones+patch@gmail.com> * Delete introduction-draft.md Message-Id: <d11b031b5ef068658b9e2b1efa882a75c2ba70c5.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <f61ad700909f434f38fb55076ab4dc4d9258a6ab.1643195691.git.keeperotphones+patch@gmail.com> * Create introduction Message-Id: <938209240cdbc86bbddc5c33403659a290ec55ac.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <ca99353a7426f0bea05df556cc19752edf48ffce.1643195691.git.keeperotphones+patch@gmail.com> * Rename introduction to introduction.md Message-Id: <4373a3b66fac460701b429d22c76cd33d8b7db4a.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <c675ca900a18a3ad9f8a6b48cdad1157ea312321.1643195691.git.keeperotphones+patch@gmail.com> * Update and rename design-draft.md to design.md Message-Id: <c863549b1a61dc045162be8d6d42ae9a505cddd1.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <71b06afa96db6e5b6dde815560a5776bc8368e8f.1643195691.git.keeperotphones+patch@gmail.com> * Fixed typo in instructions.md Message-Id: <21826fc58f9cfa53d61e6e3ccf5fcc30e6d9e411.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <88a24ed3e8685ba96fdf26bb4c0629131272281f.1643195691.git.keeperotphones+patch@gmail.com> * Formatting with YAPF Confirmed with pylint and flake8. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <ec52cd798d671348f5b29c0a691155d072c023af.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <58b93bb2ed0919c3e5753e25228bcc175a24edfa.1643195691.git.keeperotphones+patch@gmail.com> * Update config.json Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <467259ba695c8005f7106d1f359b1d4fe6c14562.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <29a418465a89c10dfd711475da4236932c4e8eff.1643195691.git.keeperotphones+patch@gmail.com> * Update exercises/concept/ellens-alien-game/.meta/config.json We'll need to rename the files though Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <933195ff036507b273b55633b40a7b76cc27f130.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <529e34d1258c17b00e20278430682cd237cae6a7.1643195691.git.keeperotphones+patch@gmail.com> * Improve wording and formatting for code formatting Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <cf9cfa5b19e0a51a1b47f11abc6d4bfdef9c7b64.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <5fd8622d5e4147746a85f3f1e63a2d5d64a066b4.1643195691.git.keeperotphones+patch@gmail.com> * Using comprehension for our list of aliens Comprehensions were introduced earlier in the concept, and so we use them here. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <1c8e73efaddfe077fe446aed6989da14398b53c6.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <e49ae05922f3dab213853e10ccad7654a4b44e7c.1643195691.git.keeperotphones+patch@gmail.com> * Rename alien_class_test.py to classes_test.py Message-Id: <493ff778d4422e418d1990f96d10c0d41c4f59ed.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <ff33af10e4617a92fcb343ead33a4060b4c7d6ad.1643195691.git.keeperotphones+patch@gmail.com> * Rename alien_class.py to classes.py Message-Id: <394f35b706b695c4e89ed55c9ee5a440701a78b0.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <52bca7f28924b4006ec1deca1e6bfa45f4f922de.1643195691.git.keeperotphones+patch@gmail.com> * Added pytest decorators to classes.py Message-Id: <8b14cd3955060ba75203fd17f088876af23c403d.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <68f7980c8bc3a8a17bef575aa20b9cfb33af1a60.1643195691.git.keeperotphones+patch@gmail.com> * Filled design.md with content Message-Id: <c785ab3f2ef18847df4b787710f8d49789acb2ff.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <d9fed4beb51fa8cdfd6f998bae46efa1cef878b5.1643195691.git.keeperotphones+patch@gmail.com> * Added missing pytest decorator Message-Id: <e175774a005235c5fe4629efffc1c49b44d4898f.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <85d06e4f2024883c120931fec152cc197a74dbc4.1643195691.git.keeperotphones+patch@gmail.com> * Update instructions.md Message-Id: <4a6c7e47a87398e50d6b864ecafe879d13c522d7.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <adea0f3324e0d5aee0a0ddfb4dc4a001baeff404.1643195691.git.keeperotphones+patch@gmail.com> * Update design.md Message-Id: <e90afd667cb2428c6d86c95a0b692aa3b97c7ce4.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <c8d2ec180d0979d65eb7760495022f58d027b6f1.1643195691.git.keeperotphones+patch@gmail.com> * Update classes.py Message-Id: <1dc38f5ebfcfe86df926b98b465465e540670528.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <30be55cc209a83e431f2cb7d735830ad2ea3e40e.1643195691.git.keeperotphones+patch@gmail.com> * Update hints.md Message-Id: <6ed9657bfa2d166f445f9825b9ccf117d5d6a4b1.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <e935f4bafa27d6da7ea3c1c7827c7f7b55155881.1643195691.git.keeperotphones+patch@gmail.com> * remove trailing whitespace Message-Id: <9e59aa73585b1f50a27dda59d7960c9f89f54dd8.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <b1e7081ca1bed4d9c159e20b42c9e9ada3848923.1643195691.git.keeperotphones+patch@gmail.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Moved back-quotes and added smiley to line 45. Added additional instruction to line 46. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Added back-quotes around `class` and `method`. Specified decrement amount. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Corrected 'function' to 'method' and put back-quotes around it. Single-letter-variables changed to word-variables. Instances of 'position' -> 'coordinate' to maintain consistency with new word-variables. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Added back-quotes (for consistency). Clarified task instruction. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Single-letter-variable -> word-variable (style conformity + consistency) Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.meta/exemplar.py Single-letter-variable -> word-variable (style conformity + consistency) Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update instructions.md All instances of: - coordinate_x -> x_coordinate. - coordinate_y -> y_coordinate * Update exemplar.py Implemented x_coordinate and y_coordinate instance variables (and variants thereof - see teleport method) to conform with both expected style (i.e. no single-letter-variables) and the changes made to instructions.md. * Update exercises/concept/ellens-alien-game/.docs/instructions.md Made the instructions in the first task more explicit. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * design.md: Removed `properties` from Concepts * Code Files Cleanup * Added docstring to exemplar.py Alien class * Corrected tests in classes_test.py * Changed new_alien_list to new_aliens_collection * Edited Instructions to Match Exemplar * Merge branch 'main' of github.com:PaulT89/python Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added contents to intro Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added content to about Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Add content to concept intro Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added two links + descriptions Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Update config.json * Added blurb to config.json * Apply suggestions from code review Fixed a few typos and added missing code block in introduction. * Added additional resources to links.json * Added Python Morsels and Dan Bader * Added links on static vs class methods * Added link on history of New Style classes in python. * Added links + fixed typos Added link to: - Official Python Classes tutorial page - The DO tutorial article already linked in the exercise introduction (and as a resource in design.md) - A subsequent DO tutorial article focusing specifically on class and instance variables * Fixed typos * General Cleaning Reworded clumsy sentences, deleted whitespace, fixed typos, removed some back-quotes to improve consistency with other documentation. * Fixed typos + removed whitespace * Corrections, Nits, and Picks * Adding IsaacG as contributor * Added IsaacG as contributor Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Co-authored-by: KOTP <keeperotphones+patch@gmail.com>
2022-02-18 23:42:50 +11:00
>>> new_object_one = MyClass((1, 2))
2022-02-18 03:10:42 +11:00
# Create a second new object "new_object_two" with object property (-8, -9).
[Classes Concept & Ellens Alien Game]: Updates (#2941) * New concept exercise: ellens-alien-game Introduces the concept of classes. Message-Id: <20220126095726.46310-2-keeperotphones+patch@gmail.com> * Update config.json Message-Id: <71aad1e9fc012ef13fa5c02ceb4e3ec349715d85.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <bc2601f32a9d9247ac2f767d1f4267f340a22ec6.1643195691.git.keeperotphones+patch@gmail.com> * Delete introduction-draft.md Message-Id: <d11b031b5ef068658b9e2b1efa882a75c2ba70c5.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <f61ad700909f434f38fb55076ab4dc4d9258a6ab.1643195691.git.keeperotphones+patch@gmail.com> * Create introduction Message-Id: <938209240cdbc86bbddc5c33403659a290ec55ac.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <ca99353a7426f0bea05df556cc19752edf48ffce.1643195691.git.keeperotphones+patch@gmail.com> * Rename introduction to introduction.md Message-Id: <4373a3b66fac460701b429d22c76cd33d8b7db4a.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <c675ca900a18a3ad9f8a6b48cdad1157ea312321.1643195691.git.keeperotphones+patch@gmail.com> * Update and rename design-draft.md to design.md Message-Id: <c863549b1a61dc045162be8d6d42ae9a505cddd1.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <71b06afa96db6e5b6dde815560a5776bc8368e8f.1643195691.git.keeperotphones+patch@gmail.com> * Fixed typo in instructions.md Message-Id: <21826fc58f9cfa53d61e6e3ccf5fcc30e6d9e411.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <88a24ed3e8685ba96fdf26bb4c0629131272281f.1643195691.git.keeperotphones+patch@gmail.com> * Formatting with YAPF Confirmed with pylint and flake8. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <ec52cd798d671348f5b29c0a691155d072c023af.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <58b93bb2ed0919c3e5753e25228bcc175a24edfa.1643195691.git.keeperotphones+patch@gmail.com> * Update config.json Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <467259ba695c8005f7106d1f359b1d4fe6c14562.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <29a418465a89c10dfd711475da4236932c4e8eff.1643195691.git.keeperotphones+patch@gmail.com> * Update exercises/concept/ellens-alien-game/.meta/config.json We'll need to rename the files though Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <933195ff036507b273b55633b40a7b76cc27f130.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <529e34d1258c17b00e20278430682cd237cae6a7.1643195691.git.keeperotphones+patch@gmail.com> * Improve wording and formatting for code formatting Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <cf9cfa5b19e0a51a1b47f11abc6d4bfdef9c7b64.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <5fd8622d5e4147746a85f3f1e63a2d5d64a066b4.1643195691.git.keeperotphones+patch@gmail.com> * Using comprehension for our list of aliens Comprehensions were introduced earlier in the concept, and so we use them here. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <1c8e73efaddfe077fe446aed6989da14398b53c6.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <e49ae05922f3dab213853e10ccad7654a4b44e7c.1643195691.git.keeperotphones+patch@gmail.com> * Rename alien_class_test.py to classes_test.py Message-Id: <493ff778d4422e418d1990f96d10c0d41c4f59ed.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <ff33af10e4617a92fcb343ead33a4060b4c7d6ad.1643195691.git.keeperotphones+patch@gmail.com> * Rename alien_class.py to classes.py Message-Id: <394f35b706b695c4e89ed55c9ee5a440701a78b0.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <52bca7f28924b4006ec1deca1e6bfa45f4f922de.1643195691.git.keeperotphones+patch@gmail.com> * Added pytest decorators to classes.py Message-Id: <8b14cd3955060ba75203fd17f088876af23c403d.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <68f7980c8bc3a8a17bef575aa20b9cfb33af1a60.1643195691.git.keeperotphones+patch@gmail.com> * Filled design.md with content Message-Id: <c785ab3f2ef18847df4b787710f8d49789acb2ff.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <d9fed4beb51fa8cdfd6f998bae46efa1cef878b5.1643195691.git.keeperotphones+patch@gmail.com> * Added missing pytest decorator Message-Id: <e175774a005235c5fe4629efffc1c49b44d4898f.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <85d06e4f2024883c120931fec152cc197a74dbc4.1643195691.git.keeperotphones+patch@gmail.com> * Update instructions.md Message-Id: <4a6c7e47a87398e50d6b864ecafe879d13c522d7.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <adea0f3324e0d5aee0a0ddfb4dc4a001baeff404.1643195691.git.keeperotphones+patch@gmail.com> * Update design.md Message-Id: <e90afd667cb2428c6d86c95a0b692aa3b97c7ce4.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <c8d2ec180d0979d65eb7760495022f58d027b6f1.1643195691.git.keeperotphones+patch@gmail.com> * Update classes.py Message-Id: <1dc38f5ebfcfe86df926b98b465465e540670528.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <30be55cc209a83e431f2cb7d735830ad2ea3e40e.1643195691.git.keeperotphones+patch@gmail.com> * Update hints.md Message-Id: <6ed9657bfa2d166f445f9825b9ccf117d5d6a4b1.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <e935f4bafa27d6da7ea3c1c7827c7f7b55155881.1643195691.git.keeperotphones+patch@gmail.com> * remove trailing whitespace Message-Id: <9e59aa73585b1f50a27dda59d7960c9f89f54dd8.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <b1e7081ca1bed4d9c159e20b42c9e9ada3848923.1643195691.git.keeperotphones+patch@gmail.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Moved back-quotes and added smiley to line 45. Added additional instruction to line 46. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Added back-quotes around `class` and `method`. Specified decrement amount. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Corrected 'function' to 'method' and put back-quotes around it. Single-letter-variables changed to word-variables. Instances of 'position' -> 'coordinate' to maintain consistency with new word-variables. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Added back-quotes (for consistency). Clarified task instruction. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Single-letter-variable -> word-variable (style conformity + consistency) Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.meta/exemplar.py Single-letter-variable -> word-variable (style conformity + consistency) Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update instructions.md All instances of: - coordinate_x -> x_coordinate. - coordinate_y -> y_coordinate * Update exemplar.py Implemented x_coordinate and y_coordinate instance variables (and variants thereof - see teleport method) to conform with both expected style (i.e. no single-letter-variables) and the changes made to instructions.md. * Update exercises/concept/ellens-alien-game/.docs/instructions.md Made the instructions in the first task more explicit. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * design.md: Removed `properties` from Concepts * Code Files Cleanup * Added docstring to exemplar.py Alien class * Corrected tests in classes_test.py * Changed new_alien_list to new_aliens_collection * Edited Instructions to Match Exemplar * Merge branch 'main' of github.com:PaulT89/python Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added contents to intro Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added content to about Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Add content to concept intro Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added two links + descriptions Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Update config.json * Added blurb to config.json * Apply suggestions from code review Fixed a few typos and added missing code block in introduction. * Added additional resources to links.json * Added Python Morsels and Dan Bader * Added links on static vs class methods * Added link on history of New Style classes in python. * Added links + fixed typos Added link to: - Official Python Classes tutorial page - The DO tutorial article already linked in the exercise introduction (and as a resource in design.md) - A subsequent DO tutorial article focusing specifically on class and instance variables * Fixed typos * General Cleaning Reworded clumsy sentences, deleted whitespace, fixed typos, removed some back-quotes to improve consistency with other documentation. * Fixed typos + removed whitespace * Corrections, Nits, and Picks * Adding IsaacG as contributor * Added IsaacG as contributor Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Co-authored-by: KOTP <keeperotphones+patch@gmail.com>
2022-02-18 23:42:50 +11:00
>>> new_object_two = MyClass((-8, -9))
# Note that new_object_one.location_x and new_object_two.location_x two different values.
>>> new_object_one.location_x
1
>>> new_object_two.location_x
-8
```
[Classes Concept & Ellens Alien Game]: Updates (#2941) * New concept exercise: ellens-alien-game Introduces the concept of classes. Message-Id: <20220126095726.46310-2-keeperotphones+patch@gmail.com> * Update config.json Message-Id: <71aad1e9fc012ef13fa5c02ceb4e3ec349715d85.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <bc2601f32a9d9247ac2f767d1f4267f340a22ec6.1643195691.git.keeperotphones+patch@gmail.com> * Delete introduction-draft.md Message-Id: <d11b031b5ef068658b9e2b1efa882a75c2ba70c5.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <f61ad700909f434f38fb55076ab4dc4d9258a6ab.1643195691.git.keeperotphones+patch@gmail.com> * Create introduction Message-Id: <938209240cdbc86bbddc5c33403659a290ec55ac.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <ca99353a7426f0bea05df556cc19752edf48ffce.1643195691.git.keeperotphones+patch@gmail.com> * Rename introduction to introduction.md Message-Id: <4373a3b66fac460701b429d22c76cd33d8b7db4a.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <c675ca900a18a3ad9f8a6b48cdad1157ea312321.1643195691.git.keeperotphones+patch@gmail.com> * Update and rename design-draft.md to design.md Message-Id: <c863549b1a61dc045162be8d6d42ae9a505cddd1.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <71b06afa96db6e5b6dde815560a5776bc8368e8f.1643195691.git.keeperotphones+patch@gmail.com> * Fixed typo in instructions.md Message-Id: <21826fc58f9cfa53d61e6e3ccf5fcc30e6d9e411.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <88a24ed3e8685ba96fdf26bb4c0629131272281f.1643195691.git.keeperotphones+patch@gmail.com> * Formatting with YAPF Confirmed with pylint and flake8. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <ec52cd798d671348f5b29c0a691155d072c023af.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <58b93bb2ed0919c3e5753e25228bcc175a24edfa.1643195691.git.keeperotphones+patch@gmail.com> * Update config.json Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <467259ba695c8005f7106d1f359b1d4fe6c14562.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <29a418465a89c10dfd711475da4236932c4e8eff.1643195691.git.keeperotphones+patch@gmail.com> * Update exercises/concept/ellens-alien-game/.meta/config.json We'll need to rename the files though Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <933195ff036507b273b55633b40a7b76cc27f130.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <529e34d1258c17b00e20278430682cd237cae6a7.1643195691.git.keeperotphones+patch@gmail.com> * Improve wording and formatting for code formatting Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <cf9cfa5b19e0a51a1b47f11abc6d4bfdef9c7b64.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <5fd8622d5e4147746a85f3f1e63a2d5d64a066b4.1643195691.git.keeperotphones+patch@gmail.com> * Using comprehension for our list of aliens Comprehensions were introduced earlier in the concept, and so we use them here. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <1c8e73efaddfe077fe446aed6989da14398b53c6.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <e49ae05922f3dab213853e10ccad7654a4b44e7c.1643195691.git.keeperotphones+patch@gmail.com> * Rename alien_class_test.py to classes_test.py Message-Id: <493ff778d4422e418d1990f96d10c0d41c4f59ed.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <ff33af10e4617a92fcb343ead33a4060b4c7d6ad.1643195691.git.keeperotphones+patch@gmail.com> * Rename alien_class.py to classes.py Message-Id: <394f35b706b695c4e89ed55c9ee5a440701a78b0.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <52bca7f28924b4006ec1deca1e6bfa45f4f922de.1643195691.git.keeperotphones+patch@gmail.com> * Added pytest decorators to classes.py Message-Id: <8b14cd3955060ba75203fd17f088876af23c403d.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <68f7980c8bc3a8a17bef575aa20b9cfb33af1a60.1643195691.git.keeperotphones+patch@gmail.com> * Filled design.md with content Message-Id: <c785ab3f2ef18847df4b787710f8d49789acb2ff.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <d9fed4beb51fa8cdfd6f998bae46efa1cef878b5.1643195691.git.keeperotphones+patch@gmail.com> * Added missing pytest decorator Message-Id: <e175774a005235c5fe4629efffc1c49b44d4898f.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <85d06e4f2024883c120931fec152cc197a74dbc4.1643195691.git.keeperotphones+patch@gmail.com> * Update instructions.md Message-Id: <4a6c7e47a87398e50d6b864ecafe879d13c522d7.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <adea0f3324e0d5aee0a0ddfb4dc4a001baeff404.1643195691.git.keeperotphones+patch@gmail.com> * Update design.md Message-Id: <e90afd667cb2428c6d86c95a0b692aa3b97c7ce4.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <c8d2ec180d0979d65eb7760495022f58d027b6f1.1643195691.git.keeperotphones+patch@gmail.com> * Update classes.py Message-Id: <1dc38f5ebfcfe86df926b98b465465e540670528.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <30be55cc209a83e431f2cb7d735830ad2ea3e40e.1643195691.git.keeperotphones+patch@gmail.com> * Update hints.md Message-Id: <6ed9657bfa2d166f445f9825b9ccf117d5d6a4b1.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <e935f4bafa27d6da7ea3c1c7827c7f7b55155881.1643195691.git.keeperotphones+patch@gmail.com> * remove trailing whitespace Message-Id: <9e59aa73585b1f50a27dda59d7960c9f89f54dd8.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <b1e7081ca1bed4d9c159e20b42c9e9ada3848923.1643195691.git.keeperotphones+patch@gmail.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Moved back-quotes and added smiley to line 45. Added additional instruction to line 46. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Added back-quotes around `class` and `method`. Specified decrement amount. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Corrected 'function' to 'method' and put back-quotes around it. Single-letter-variables changed to word-variables. Instances of 'position' -> 'coordinate' to maintain consistency with new word-variables. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Added back-quotes (for consistency). Clarified task instruction. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Single-letter-variable -> word-variable (style conformity + consistency) Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.meta/exemplar.py Single-letter-variable -> word-variable (style conformity + consistency) Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update instructions.md All instances of: - coordinate_x -> x_coordinate. - coordinate_y -> y_coordinate * Update exemplar.py Implemented x_coordinate and y_coordinate instance variables (and variants thereof - see teleport method) to conform with both expected style (i.e. no single-letter-variables) and the changes made to instructions.md. * Update exercises/concept/ellens-alien-game/.docs/instructions.md Made the instructions in the first task more explicit. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * design.md: Removed `properties` from Concepts * Code Files Cleanup * Added docstring to exemplar.py Alien class * Corrected tests in classes_test.py * Changed new_alien_list to new_aliens_collection * Edited Instructions to Match Exemplar * Merge branch 'main' of github.com:PaulT89/python Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added contents to intro Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added content to about Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Add content to concept intro Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added two links + descriptions Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Update config.json * Added blurb to config.json * Apply suggestions from code review Fixed a few typos and added missing code block in introduction. * Added additional resources to links.json * Added Python Morsels and Dan Bader * Added links on static vs class methods * Added link on history of New Style classes in python. * Added links + fixed typos Added link to: - Official Python Classes tutorial page - The DO tutorial article already linked in the exercise introduction (and as a resource in design.md) - A subsequent DO tutorial article focusing specifically on class and instance variables * Fixed typos * General Cleaning Reworded clumsy sentences, deleted whitespace, fixed typos, removed some back-quotes to improve consistency with other documentation. * Fixed typos + removed whitespace * Corrections, Nits, and Picks * Adding IsaacG as contributor * Added IsaacG as contributor Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Co-authored-by: KOTP <keeperotphones+patch@gmail.com>
2022-02-18 23:42:50 +11:00
Note that you only need to pass one argument when initializing `MyClass` above -- Python takes care of passing `self` when the class is called.
## Methods
A `method` is a `function` that is bound to either the class itself (_known as a [class method][class method], which will be discussed in a later exercise_) or an _instance_ of the class (object).
Methods that operate on an object (instance) need to be defined with `self` as the first parameter.
You can then define the rest of the parameters as you would for a "normal" or non-bound function:
```python
[Classes Concept & Ellens Alien Game]: Updates (#2941) * New concept exercise: ellens-alien-game Introduces the concept of classes. Message-Id: <20220126095726.46310-2-keeperotphones+patch@gmail.com> * Update config.json Message-Id: <71aad1e9fc012ef13fa5c02ceb4e3ec349715d85.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <bc2601f32a9d9247ac2f767d1f4267f340a22ec6.1643195691.git.keeperotphones+patch@gmail.com> * Delete introduction-draft.md Message-Id: <d11b031b5ef068658b9e2b1efa882a75c2ba70c5.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <f61ad700909f434f38fb55076ab4dc4d9258a6ab.1643195691.git.keeperotphones+patch@gmail.com> * Create introduction Message-Id: <938209240cdbc86bbddc5c33403659a290ec55ac.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <ca99353a7426f0bea05df556cc19752edf48ffce.1643195691.git.keeperotphones+patch@gmail.com> * Rename introduction to introduction.md Message-Id: <4373a3b66fac460701b429d22c76cd33d8b7db4a.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <c675ca900a18a3ad9f8a6b48cdad1157ea312321.1643195691.git.keeperotphones+patch@gmail.com> * Update and rename design-draft.md to design.md Message-Id: <c863549b1a61dc045162be8d6d42ae9a505cddd1.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <71b06afa96db6e5b6dde815560a5776bc8368e8f.1643195691.git.keeperotphones+patch@gmail.com> * Fixed typo in instructions.md Message-Id: <21826fc58f9cfa53d61e6e3ccf5fcc30e6d9e411.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <88a24ed3e8685ba96fdf26bb4c0629131272281f.1643195691.git.keeperotphones+patch@gmail.com> * Formatting with YAPF Confirmed with pylint and flake8. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <ec52cd798d671348f5b29c0a691155d072c023af.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <58b93bb2ed0919c3e5753e25228bcc175a24edfa.1643195691.git.keeperotphones+patch@gmail.com> * Update config.json Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <467259ba695c8005f7106d1f359b1d4fe6c14562.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <29a418465a89c10dfd711475da4236932c4e8eff.1643195691.git.keeperotphones+patch@gmail.com> * Update exercises/concept/ellens-alien-game/.meta/config.json We'll need to rename the files though Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <933195ff036507b273b55633b40a7b76cc27f130.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <529e34d1258c17b00e20278430682cd237cae6a7.1643195691.git.keeperotphones+patch@gmail.com> * Improve wording and formatting for code formatting Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <cf9cfa5b19e0a51a1b47f11abc6d4bfdef9c7b64.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <5fd8622d5e4147746a85f3f1e63a2d5d64a066b4.1643195691.git.keeperotphones+patch@gmail.com> * Using comprehension for our list of aliens Comprehensions were introduced earlier in the concept, and so we use them here. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <1c8e73efaddfe077fe446aed6989da14398b53c6.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <e49ae05922f3dab213853e10ccad7654a4b44e7c.1643195691.git.keeperotphones+patch@gmail.com> * Rename alien_class_test.py to classes_test.py Message-Id: <493ff778d4422e418d1990f96d10c0d41c4f59ed.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <ff33af10e4617a92fcb343ead33a4060b4c7d6ad.1643195691.git.keeperotphones+patch@gmail.com> * Rename alien_class.py to classes.py Message-Id: <394f35b706b695c4e89ed55c9ee5a440701a78b0.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <52bca7f28924b4006ec1deca1e6bfa45f4f922de.1643195691.git.keeperotphones+patch@gmail.com> * Added pytest decorators to classes.py Message-Id: <8b14cd3955060ba75203fd17f088876af23c403d.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <68f7980c8bc3a8a17bef575aa20b9cfb33af1a60.1643195691.git.keeperotphones+patch@gmail.com> * Filled design.md with content Message-Id: <c785ab3f2ef18847df4b787710f8d49789acb2ff.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <d9fed4beb51fa8cdfd6f998bae46efa1cef878b5.1643195691.git.keeperotphones+patch@gmail.com> * Added missing pytest decorator Message-Id: <e175774a005235c5fe4629efffc1c49b44d4898f.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <85d06e4f2024883c120931fec152cc197a74dbc4.1643195691.git.keeperotphones+patch@gmail.com> * Update instructions.md Message-Id: <4a6c7e47a87398e50d6b864ecafe879d13c522d7.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <adea0f3324e0d5aee0a0ddfb4dc4a001baeff404.1643195691.git.keeperotphones+patch@gmail.com> * Update design.md Message-Id: <e90afd667cb2428c6d86c95a0b692aa3b97c7ce4.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <c8d2ec180d0979d65eb7760495022f58d027b6f1.1643195691.git.keeperotphones+patch@gmail.com> * Update classes.py Message-Id: <1dc38f5ebfcfe86df926b98b465465e540670528.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <30be55cc209a83e431f2cb7d735830ad2ea3e40e.1643195691.git.keeperotphones+patch@gmail.com> * Update hints.md Message-Id: <6ed9657bfa2d166f445f9825b9ccf117d5d6a4b1.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <e935f4bafa27d6da7ea3c1c7827c7f7b55155881.1643195691.git.keeperotphones+patch@gmail.com> * remove trailing whitespace Message-Id: <9e59aa73585b1f50a27dda59d7960c9f89f54dd8.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <b1e7081ca1bed4d9c159e20b42c9e9ada3848923.1643195691.git.keeperotphones+patch@gmail.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Moved back-quotes and added smiley to line 45. Added additional instruction to line 46. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Added back-quotes around `class` and `method`. Specified decrement amount. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Corrected 'function' to 'method' and put back-quotes around it. Single-letter-variables changed to word-variables. Instances of 'position' -> 'coordinate' to maintain consistency with new word-variables. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Added back-quotes (for consistency). Clarified task instruction. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Single-letter-variable -> word-variable (style conformity + consistency) Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.meta/exemplar.py Single-letter-variable -> word-variable (style conformity + consistency) Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update instructions.md All instances of: - coordinate_x -> x_coordinate. - coordinate_y -> y_coordinate * Update exemplar.py Implemented x_coordinate and y_coordinate instance variables (and variants thereof - see teleport method) to conform with both expected style (i.e. no single-letter-variables) and the changes made to instructions.md. * Update exercises/concept/ellens-alien-game/.docs/instructions.md Made the instructions in the first task more explicit. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * design.md: Removed `properties` from Concepts * Code Files Cleanup * Added docstring to exemplar.py Alien class * Corrected tests in classes_test.py * Changed new_alien_list to new_aliens_collection * Edited Instructions to Match Exemplar * Merge branch 'main' of github.com:PaulT89/python Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added contents to intro Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added content to about Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Add content to concept intro Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added two links + descriptions Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Update config.json * Added blurb to config.json * Apply suggestions from code review Fixed a few typos and added missing code block in introduction. * Added additional resources to links.json * Added Python Morsels and Dan Bader * Added links on static vs class methods * Added link on history of New Style classes in python. * Added links + fixed typos Added link to: - Official Python Classes tutorial page - The DO tutorial article already linked in the exercise introduction (and as a resource in design.md) - A subsequent DO tutorial article focusing specifically on class and instance variables * Fixed typos * General Cleaning Reworded clumsy sentences, deleted whitespace, fixed typos, removed some back-quotes to improve consistency with other documentation. * Fixed typos + removed whitespace * Corrections, Nits, and Picks * Adding IsaacG as contributor * Added IsaacG as contributor Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Co-authored-by: KOTP <keeperotphones+patch@gmail.com>
2022-02-18 23:42:50 +11:00
class MyClass:
number = 5
string = "Hello!"
2022-02-18 03:10:42 +11:00
# Class constructor.
def __init__(self, location):
# Instance properties
self.location_x = location[0]
self.location_y = location[1]
2022-02-18 03:10:42 +11:00
# Instance method. Note "self" as first parameter.
def change_location(self, amount):
self.location_x += amount
self.location_y += amount
return self.location_x, self.location_y
```
Like attribute access, calling a method simply requires putting a `.` after the object name, and before the method name.
The called method does not need a copy of the object as a first parameter -- Python fills in `self` automatically:
```python
[Classes Concept & Ellens Alien Game]: Updates (#2941) * New concept exercise: ellens-alien-game Introduces the concept of classes. Message-Id: <20220126095726.46310-2-keeperotphones+patch@gmail.com> * Update config.json Message-Id: <71aad1e9fc012ef13fa5c02ceb4e3ec349715d85.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <bc2601f32a9d9247ac2f767d1f4267f340a22ec6.1643195691.git.keeperotphones+patch@gmail.com> * Delete introduction-draft.md Message-Id: <d11b031b5ef068658b9e2b1efa882a75c2ba70c5.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <f61ad700909f434f38fb55076ab4dc4d9258a6ab.1643195691.git.keeperotphones+patch@gmail.com> * Create introduction Message-Id: <938209240cdbc86bbddc5c33403659a290ec55ac.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <ca99353a7426f0bea05df556cc19752edf48ffce.1643195691.git.keeperotphones+patch@gmail.com> * Rename introduction to introduction.md Message-Id: <4373a3b66fac460701b429d22c76cd33d8b7db4a.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <c675ca900a18a3ad9f8a6b48cdad1157ea312321.1643195691.git.keeperotphones+patch@gmail.com> * Update and rename design-draft.md to design.md Message-Id: <c863549b1a61dc045162be8d6d42ae9a505cddd1.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <71b06afa96db6e5b6dde815560a5776bc8368e8f.1643195691.git.keeperotphones+patch@gmail.com> * Fixed typo in instructions.md Message-Id: <21826fc58f9cfa53d61e6e3ccf5fcc30e6d9e411.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <88a24ed3e8685ba96fdf26bb4c0629131272281f.1643195691.git.keeperotphones+patch@gmail.com> * Formatting with YAPF Confirmed with pylint and flake8. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <ec52cd798d671348f5b29c0a691155d072c023af.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <58b93bb2ed0919c3e5753e25228bcc175a24edfa.1643195691.git.keeperotphones+patch@gmail.com> * Update config.json Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <467259ba695c8005f7106d1f359b1d4fe6c14562.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <29a418465a89c10dfd711475da4236932c4e8eff.1643195691.git.keeperotphones+patch@gmail.com> * Update exercises/concept/ellens-alien-game/.meta/config.json We'll need to rename the files though Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <933195ff036507b273b55633b40a7b76cc27f130.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <529e34d1258c17b00e20278430682cd237cae6a7.1643195691.git.keeperotphones+patch@gmail.com> * Improve wording and formatting for code formatting Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <cf9cfa5b19e0a51a1b47f11abc6d4bfdef9c7b64.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <5fd8622d5e4147746a85f3f1e63a2d5d64a066b4.1643195691.git.keeperotphones+patch@gmail.com> * Using comprehension for our list of aliens Comprehensions were introduced earlier in the concept, and so we use them here. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <1c8e73efaddfe077fe446aed6989da14398b53c6.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <e49ae05922f3dab213853e10ccad7654a4b44e7c.1643195691.git.keeperotphones+patch@gmail.com> * Rename alien_class_test.py to classes_test.py Message-Id: <493ff778d4422e418d1990f96d10c0d41c4f59ed.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <ff33af10e4617a92fcb343ead33a4060b4c7d6ad.1643195691.git.keeperotphones+patch@gmail.com> * Rename alien_class.py to classes.py Message-Id: <394f35b706b695c4e89ed55c9ee5a440701a78b0.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <52bca7f28924b4006ec1deca1e6bfa45f4f922de.1643195691.git.keeperotphones+patch@gmail.com> * Added pytest decorators to classes.py Message-Id: <8b14cd3955060ba75203fd17f088876af23c403d.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <68f7980c8bc3a8a17bef575aa20b9cfb33af1a60.1643195691.git.keeperotphones+patch@gmail.com> * Filled design.md with content Message-Id: <c785ab3f2ef18847df4b787710f8d49789acb2ff.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <d9fed4beb51fa8cdfd6f998bae46efa1cef878b5.1643195691.git.keeperotphones+patch@gmail.com> * Added missing pytest decorator Message-Id: <e175774a005235c5fe4629efffc1c49b44d4898f.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <85d06e4f2024883c120931fec152cc197a74dbc4.1643195691.git.keeperotphones+patch@gmail.com> * Update instructions.md Message-Id: <4a6c7e47a87398e50d6b864ecafe879d13c522d7.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <adea0f3324e0d5aee0a0ddfb4dc4a001baeff404.1643195691.git.keeperotphones+patch@gmail.com> * Update design.md Message-Id: <e90afd667cb2428c6d86c95a0b692aa3b97c7ce4.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <c8d2ec180d0979d65eb7760495022f58d027b6f1.1643195691.git.keeperotphones+patch@gmail.com> * Update classes.py Message-Id: <1dc38f5ebfcfe86df926b98b465465e540670528.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <30be55cc209a83e431f2cb7d735830ad2ea3e40e.1643195691.git.keeperotphones+patch@gmail.com> * Update hints.md Message-Id: <6ed9657bfa2d166f445f9825b9ccf117d5d6a4b1.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <e935f4bafa27d6da7ea3c1c7827c7f7b55155881.1643195691.git.keeperotphones+patch@gmail.com> * remove trailing whitespace Message-Id: <9e59aa73585b1f50a27dda59d7960c9f89f54dd8.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <b1e7081ca1bed4d9c159e20b42c9e9ada3848923.1643195691.git.keeperotphones+patch@gmail.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Moved back-quotes and added smiley to line 45. Added additional instruction to line 46. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Added back-quotes around `class` and `method`. Specified decrement amount. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Corrected 'function' to 'method' and put back-quotes around it. Single-letter-variables changed to word-variables. Instances of 'position' -> 'coordinate' to maintain consistency with new word-variables. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Added back-quotes (for consistency). Clarified task instruction. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Single-letter-variable -> word-variable (style conformity + consistency) Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.meta/exemplar.py Single-letter-variable -> word-variable (style conformity + consistency) Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update instructions.md All instances of: - coordinate_x -> x_coordinate. - coordinate_y -> y_coordinate * Update exemplar.py Implemented x_coordinate and y_coordinate instance variables (and variants thereof - see teleport method) to conform with both expected style (i.e. no single-letter-variables) and the changes made to instructions.md. * Update exercises/concept/ellens-alien-game/.docs/instructions.md Made the instructions in the first task more explicit. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * design.md: Removed `properties` from Concepts * Code Files Cleanup * Added docstring to exemplar.py Alien class * Corrected tests in classes_test.py * Changed new_alien_list to new_aliens_collection * Edited Instructions to Match Exemplar * Merge branch 'main' of github.com:PaulT89/python Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added contents to intro Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added content to about Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Add content to concept intro Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added two links + descriptions Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Update config.json * Added blurb to config.json * Apply suggestions from code review Fixed a few typos and added missing code block in introduction. * Added additional resources to links.json * Added Python Morsels and Dan Bader * Added links on static vs class methods * Added link on history of New Style classes in python. * Added links + fixed typos Added link to: - Official Python Classes tutorial page - The DO tutorial article already linked in the exercise introduction (and as a resource in design.md) - A subsequent DO tutorial article focusing specifically on class and instance variables * Fixed typos * General Cleaning Reworded clumsy sentences, deleted whitespace, fixed typos, removed some back-quotes to improve consistency with other documentation. * Fixed typos + removed whitespace * Corrections, Nits, and Picks * Adding IsaacG as contributor * Added IsaacG as contributor Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Co-authored-by: KOTP <keeperotphones+patch@gmail.com>
2022-02-18 23:42:50 +11:00
class MyClass:
number = 5
string = "Hello!"
def __init__(self, location):
self.location_x = location[0]
self.location_y = location[1]
def change_location(self, amount):
self.location_x += amount
self.location_y += amount
return self.location_x, self.location_y
# Make a new test_object with location (3,7)
[Classes Concept & Ellens Alien Game]: Updates (#2941) * New concept exercise: ellens-alien-game Introduces the concept of classes. Message-Id: <20220126095726.46310-2-keeperotphones+patch@gmail.com> * Update config.json Message-Id: <71aad1e9fc012ef13fa5c02ceb4e3ec349715d85.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <bc2601f32a9d9247ac2f767d1f4267f340a22ec6.1643195691.git.keeperotphones+patch@gmail.com> * Delete introduction-draft.md Message-Id: <d11b031b5ef068658b9e2b1efa882a75c2ba70c5.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <f61ad700909f434f38fb55076ab4dc4d9258a6ab.1643195691.git.keeperotphones+patch@gmail.com> * Create introduction Message-Id: <938209240cdbc86bbddc5c33403659a290ec55ac.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <ca99353a7426f0bea05df556cc19752edf48ffce.1643195691.git.keeperotphones+patch@gmail.com> * Rename introduction to introduction.md Message-Id: <4373a3b66fac460701b429d22c76cd33d8b7db4a.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <c675ca900a18a3ad9f8a6b48cdad1157ea312321.1643195691.git.keeperotphones+patch@gmail.com> * Update and rename design-draft.md to design.md Message-Id: <c863549b1a61dc045162be8d6d42ae9a505cddd1.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <71b06afa96db6e5b6dde815560a5776bc8368e8f.1643195691.git.keeperotphones+patch@gmail.com> * Fixed typo in instructions.md Message-Id: <21826fc58f9cfa53d61e6e3ccf5fcc30e6d9e411.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <88a24ed3e8685ba96fdf26bb4c0629131272281f.1643195691.git.keeperotphones+patch@gmail.com> * Formatting with YAPF Confirmed with pylint and flake8. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <ec52cd798d671348f5b29c0a691155d072c023af.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <58b93bb2ed0919c3e5753e25228bcc175a24edfa.1643195691.git.keeperotphones+patch@gmail.com> * Update config.json Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <467259ba695c8005f7106d1f359b1d4fe6c14562.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <29a418465a89c10dfd711475da4236932c4e8eff.1643195691.git.keeperotphones+patch@gmail.com> * Update exercises/concept/ellens-alien-game/.meta/config.json We'll need to rename the files though Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <933195ff036507b273b55633b40a7b76cc27f130.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <529e34d1258c17b00e20278430682cd237cae6a7.1643195691.git.keeperotphones+patch@gmail.com> * Improve wording and formatting for code formatting Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <cf9cfa5b19e0a51a1b47f11abc6d4bfdef9c7b64.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <5fd8622d5e4147746a85f3f1e63a2d5d64a066b4.1643195691.git.keeperotphones+patch@gmail.com> * Using comprehension for our list of aliens Comprehensions were introduced earlier in the concept, and so we use them here. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <1c8e73efaddfe077fe446aed6989da14398b53c6.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <e49ae05922f3dab213853e10ccad7654a4b44e7c.1643195691.git.keeperotphones+patch@gmail.com> * Rename alien_class_test.py to classes_test.py Message-Id: <493ff778d4422e418d1990f96d10c0d41c4f59ed.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <ff33af10e4617a92fcb343ead33a4060b4c7d6ad.1643195691.git.keeperotphones+patch@gmail.com> * Rename alien_class.py to classes.py Message-Id: <394f35b706b695c4e89ed55c9ee5a440701a78b0.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <52bca7f28924b4006ec1deca1e6bfa45f4f922de.1643195691.git.keeperotphones+patch@gmail.com> * Added pytest decorators to classes.py Message-Id: <8b14cd3955060ba75203fd17f088876af23c403d.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <68f7980c8bc3a8a17bef575aa20b9cfb33af1a60.1643195691.git.keeperotphones+patch@gmail.com> * Filled design.md with content Message-Id: <c785ab3f2ef18847df4b787710f8d49789acb2ff.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <d9fed4beb51fa8cdfd6f998bae46efa1cef878b5.1643195691.git.keeperotphones+patch@gmail.com> * Added missing pytest decorator Message-Id: <e175774a005235c5fe4629efffc1c49b44d4898f.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <85d06e4f2024883c120931fec152cc197a74dbc4.1643195691.git.keeperotphones+patch@gmail.com> * Update instructions.md Message-Id: <4a6c7e47a87398e50d6b864ecafe879d13c522d7.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <adea0f3324e0d5aee0a0ddfb4dc4a001baeff404.1643195691.git.keeperotphones+patch@gmail.com> * Update design.md Message-Id: <e90afd667cb2428c6d86c95a0b692aa3b97c7ce4.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <c8d2ec180d0979d65eb7760495022f58d027b6f1.1643195691.git.keeperotphones+patch@gmail.com> * Update classes.py Message-Id: <1dc38f5ebfcfe86df926b98b465465e540670528.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <30be55cc209a83e431f2cb7d735830ad2ea3e40e.1643195691.git.keeperotphones+patch@gmail.com> * Update hints.md Message-Id: <6ed9657bfa2d166f445f9825b9ccf117d5d6a4b1.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <e935f4bafa27d6da7ea3c1c7827c7f7b55155881.1643195691.git.keeperotphones+patch@gmail.com> * remove trailing whitespace Message-Id: <9e59aa73585b1f50a27dda59d7960c9f89f54dd8.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <b1e7081ca1bed4d9c159e20b42c9e9ada3848923.1643195691.git.keeperotphones+patch@gmail.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Moved back-quotes and added smiley to line 45. Added additional instruction to line 46. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Added back-quotes around `class` and `method`. Specified decrement amount. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Corrected 'function' to 'method' and put back-quotes around it. Single-letter-variables changed to word-variables. Instances of 'position' -> 'coordinate' to maintain consistency with new word-variables. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Added back-quotes (for consistency). Clarified task instruction. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Single-letter-variable -> word-variable (style conformity + consistency) Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.meta/exemplar.py Single-letter-variable -> word-variable (style conformity + consistency) Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update instructions.md All instances of: - coordinate_x -> x_coordinate. - coordinate_y -> y_coordinate * Update exemplar.py Implemented x_coordinate and y_coordinate instance variables (and variants thereof - see teleport method) to conform with both expected style (i.e. no single-letter-variables) and the changes made to instructions.md. * Update exercises/concept/ellens-alien-game/.docs/instructions.md Made the instructions in the first task more explicit. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * design.md: Removed `properties` from Concepts * Code Files Cleanup * Added docstring to exemplar.py Alien class * Corrected tests in classes_test.py * Changed new_alien_list to new_aliens_collection * Edited Instructions to Match Exemplar * Merge branch 'main' of github.com:PaulT89/python Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added contents to intro Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added content to about Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Add content to concept intro Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added two links + descriptions Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Update config.json * Added blurb to config.json * Apply suggestions from code review Fixed a few typos and added missing code block in introduction. * Added additional resources to links.json * Added Python Morsels and Dan Bader * Added links on static vs class methods * Added link on history of New Style classes in python. * Added links + fixed typos Added link to: - Official Python Classes tutorial page - The DO tutorial article already linked in the exercise introduction (and as a resource in design.md) - A subsequent DO tutorial article focusing specifically on class and instance variables * Fixed typos * General Cleaning Reworded clumsy sentences, deleted whitespace, fixed typos, removed some back-quotes to improve consistency with other documentation. * Fixed typos + removed whitespace * Corrections, Nits, and Picks * Adding IsaacG as contributor * Added IsaacG as contributor Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Co-authored-by: KOTP <keeperotphones+patch@gmail.com>
2022-02-18 23:42:50 +11:00
>>> test_object = MyClass((3,7))
>>> (test_object.location_x, test_object.location_y)
(3,7)
# Call change_location to increase location_x and location_y by 7.
>>> test_object.change_location(7)
(10, 14)
```
Class attributes can be accessed from within instance methods in the same way that they are accessed outside of the class:
```python
[Classes Concept & Ellens Alien Game]: Updates (#2941) * New concept exercise: ellens-alien-game Introduces the concept of classes. Message-Id: <20220126095726.46310-2-keeperotphones+patch@gmail.com> * Update config.json Message-Id: <71aad1e9fc012ef13fa5c02ceb4e3ec349715d85.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <bc2601f32a9d9247ac2f767d1f4267f340a22ec6.1643195691.git.keeperotphones+patch@gmail.com> * Delete introduction-draft.md Message-Id: <d11b031b5ef068658b9e2b1efa882a75c2ba70c5.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <f61ad700909f434f38fb55076ab4dc4d9258a6ab.1643195691.git.keeperotphones+patch@gmail.com> * Create introduction Message-Id: <938209240cdbc86bbddc5c33403659a290ec55ac.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <ca99353a7426f0bea05df556cc19752edf48ffce.1643195691.git.keeperotphones+patch@gmail.com> * Rename introduction to introduction.md Message-Id: <4373a3b66fac460701b429d22c76cd33d8b7db4a.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <c675ca900a18a3ad9f8a6b48cdad1157ea312321.1643195691.git.keeperotphones+patch@gmail.com> * Update and rename design-draft.md to design.md Message-Id: <c863549b1a61dc045162be8d6d42ae9a505cddd1.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <71b06afa96db6e5b6dde815560a5776bc8368e8f.1643195691.git.keeperotphones+patch@gmail.com> * Fixed typo in instructions.md Message-Id: <21826fc58f9cfa53d61e6e3ccf5fcc30e6d9e411.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <88a24ed3e8685ba96fdf26bb4c0629131272281f.1643195691.git.keeperotphones+patch@gmail.com> * Formatting with YAPF Confirmed with pylint and flake8. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <ec52cd798d671348f5b29c0a691155d072c023af.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <58b93bb2ed0919c3e5753e25228bcc175a24edfa.1643195691.git.keeperotphones+patch@gmail.com> * Update config.json Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <467259ba695c8005f7106d1f359b1d4fe6c14562.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <29a418465a89c10dfd711475da4236932c4e8eff.1643195691.git.keeperotphones+patch@gmail.com> * Update exercises/concept/ellens-alien-game/.meta/config.json We'll need to rename the files though Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <933195ff036507b273b55633b40a7b76cc27f130.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <529e34d1258c17b00e20278430682cd237cae6a7.1643195691.git.keeperotphones+patch@gmail.com> * Improve wording and formatting for code formatting Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <cf9cfa5b19e0a51a1b47f11abc6d4bfdef9c7b64.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <5fd8622d5e4147746a85f3f1e63a2d5d64a066b4.1643195691.git.keeperotphones+patch@gmail.com> * Using comprehension for our list of aliens Comprehensions were introduced earlier in the concept, and so we use them here. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <1c8e73efaddfe077fe446aed6989da14398b53c6.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <e49ae05922f3dab213853e10ccad7654a4b44e7c.1643195691.git.keeperotphones+patch@gmail.com> * Rename alien_class_test.py to classes_test.py Message-Id: <493ff778d4422e418d1990f96d10c0d41c4f59ed.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <ff33af10e4617a92fcb343ead33a4060b4c7d6ad.1643195691.git.keeperotphones+patch@gmail.com> * Rename alien_class.py to classes.py Message-Id: <394f35b706b695c4e89ed55c9ee5a440701a78b0.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <52bca7f28924b4006ec1deca1e6bfa45f4f922de.1643195691.git.keeperotphones+patch@gmail.com> * Added pytest decorators to classes.py Message-Id: <8b14cd3955060ba75203fd17f088876af23c403d.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <68f7980c8bc3a8a17bef575aa20b9cfb33af1a60.1643195691.git.keeperotphones+patch@gmail.com> * Filled design.md with content Message-Id: <c785ab3f2ef18847df4b787710f8d49789acb2ff.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <d9fed4beb51fa8cdfd6f998bae46efa1cef878b5.1643195691.git.keeperotphones+patch@gmail.com> * Added missing pytest decorator Message-Id: <e175774a005235c5fe4629efffc1c49b44d4898f.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <85d06e4f2024883c120931fec152cc197a74dbc4.1643195691.git.keeperotphones+patch@gmail.com> * Update instructions.md Message-Id: <4a6c7e47a87398e50d6b864ecafe879d13c522d7.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <adea0f3324e0d5aee0a0ddfb4dc4a001baeff404.1643195691.git.keeperotphones+patch@gmail.com> * Update design.md Message-Id: <e90afd667cb2428c6d86c95a0b692aa3b97c7ce4.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <c8d2ec180d0979d65eb7760495022f58d027b6f1.1643195691.git.keeperotphones+patch@gmail.com> * Update classes.py Message-Id: <1dc38f5ebfcfe86df926b98b465465e540670528.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <30be55cc209a83e431f2cb7d735830ad2ea3e40e.1643195691.git.keeperotphones+patch@gmail.com> * Update hints.md Message-Id: <6ed9657bfa2d166f445f9825b9ccf117d5d6a4b1.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <e935f4bafa27d6da7ea3c1c7827c7f7b55155881.1643195691.git.keeperotphones+patch@gmail.com> * remove trailing whitespace Message-Id: <9e59aa73585b1f50a27dda59d7960c9f89f54dd8.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <b1e7081ca1bed4d9c159e20b42c9e9ada3848923.1643195691.git.keeperotphones+patch@gmail.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Moved back-quotes and added smiley to line 45. Added additional instruction to line 46. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Added back-quotes around `class` and `method`. Specified decrement amount. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Corrected 'function' to 'method' and put back-quotes around it. Single-letter-variables changed to word-variables. Instances of 'position' -> 'coordinate' to maintain consistency with new word-variables. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Added back-quotes (for consistency). Clarified task instruction. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Single-letter-variable -> word-variable (style conformity + consistency) Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.meta/exemplar.py Single-letter-variable -> word-variable (style conformity + consistency) Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update instructions.md All instances of: - coordinate_x -> x_coordinate. - coordinate_y -> y_coordinate * Update exemplar.py Implemented x_coordinate and y_coordinate instance variables (and variants thereof - see teleport method) to conform with both expected style (i.e. no single-letter-variables) and the changes made to instructions.md. * Update exercises/concept/ellens-alien-game/.docs/instructions.md Made the instructions in the first task more explicit. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * design.md: Removed `properties` from Concepts * Code Files Cleanup * Added docstring to exemplar.py Alien class * Corrected tests in classes_test.py * Changed new_alien_list to new_aliens_collection * Edited Instructions to Match Exemplar * Merge branch 'main' of github.com:PaulT89/python Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added contents to intro Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added content to about Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Add content to concept intro Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added two links + descriptions Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Update config.json * Added blurb to config.json * Apply suggestions from code review Fixed a few typos and added missing code block in introduction. * Added additional resources to links.json * Added Python Morsels and Dan Bader * Added links on static vs class methods * Added link on history of New Style classes in python. * Added links + fixed typos Added link to: - Official Python Classes tutorial page - The DO tutorial article already linked in the exercise introduction (and as a resource in design.md) - A subsequent DO tutorial article focusing specifically on class and instance variables * Fixed typos * General Cleaning Reworded clumsy sentences, deleted whitespace, fixed typos, removed some back-quotes to improve consistency with other documentation. * Fixed typos + removed whitespace * Corrections, Nits, and Picks * Adding IsaacG as contributor * Added IsaacG as contributor Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Co-authored-by: KOTP <keeperotphones+patch@gmail.com>
2022-02-18 23:42:50 +11:00
class MyClass:
number = 5
string = "Hello!"
def __init__(self, location):
self.location_x = location[0]
self.location_y = location[1]
2022-02-18 03:10:42 +11:00
# Alter instance variable location_x and location_y
def change_location(self, amount):
self.location_x += amount
self.location_y += amount
return self.location_x, self.location_y
2022-02-18 03:10:42 +11:00
# Alter class variable number for all instances from within an instance.
def increment_number(self):
# Increment the 'number' class variable by 1.
[Classes Concept & Ellens Alien Game]: Updates (#2941) * New concept exercise: ellens-alien-game Introduces the concept of classes. Message-Id: <20220126095726.46310-2-keeperotphones+patch@gmail.com> * Update config.json Message-Id: <71aad1e9fc012ef13fa5c02ceb4e3ec349715d85.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <bc2601f32a9d9247ac2f767d1f4267f340a22ec6.1643195691.git.keeperotphones+patch@gmail.com> * Delete introduction-draft.md Message-Id: <d11b031b5ef068658b9e2b1efa882a75c2ba70c5.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <f61ad700909f434f38fb55076ab4dc4d9258a6ab.1643195691.git.keeperotphones+patch@gmail.com> * Create introduction Message-Id: <938209240cdbc86bbddc5c33403659a290ec55ac.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <ca99353a7426f0bea05df556cc19752edf48ffce.1643195691.git.keeperotphones+patch@gmail.com> * Rename introduction to introduction.md Message-Id: <4373a3b66fac460701b429d22c76cd33d8b7db4a.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <c675ca900a18a3ad9f8a6b48cdad1157ea312321.1643195691.git.keeperotphones+patch@gmail.com> * Update and rename design-draft.md to design.md Message-Id: <c863549b1a61dc045162be8d6d42ae9a505cddd1.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <71b06afa96db6e5b6dde815560a5776bc8368e8f.1643195691.git.keeperotphones+patch@gmail.com> * Fixed typo in instructions.md Message-Id: <21826fc58f9cfa53d61e6e3ccf5fcc30e6d9e411.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <88a24ed3e8685ba96fdf26bb4c0629131272281f.1643195691.git.keeperotphones+patch@gmail.com> * Formatting with YAPF Confirmed with pylint and flake8. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <ec52cd798d671348f5b29c0a691155d072c023af.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <58b93bb2ed0919c3e5753e25228bcc175a24edfa.1643195691.git.keeperotphones+patch@gmail.com> * Update config.json Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <467259ba695c8005f7106d1f359b1d4fe6c14562.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <29a418465a89c10dfd711475da4236932c4e8eff.1643195691.git.keeperotphones+patch@gmail.com> * Update exercises/concept/ellens-alien-game/.meta/config.json We'll need to rename the files though Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <933195ff036507b273b55633b40a7b76cc27f130.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <529e34d1258c17b00e20278430682cd237cae6a7.1643195691.git.keeperotphones+patch@gmail.com> * Improve wording and formatting for code formatting Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <cf9cfa5b19e0a51a1b47f11abc6d4bfdef9c7b64.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <5fd8622d5e4147746a85f3f1e63a2d5d64a066b4.1643195691.git.keeperotphones+patch@gmail.com> * Using comprehension for our list of aliens Comprehensions were introduced earlier in the concept, and so we use them here. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <1c8e73efaddfe077fe446aed6989da14398b53c6.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <e49ae05922f3dab213853e10ccad7654a4b44e7c.1643195691.git.keeperotphones+patch@gmail.com> * Rename alien_class_test.py to classes_test.py Message-Id: <493ff778d4422e418d1990f96d10c0d41c4f59ed.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <ff33af10e4617a92fcb343ead33a4060b4c7d6ad.1643195691.git.keeperotphones+patch@gmail.com> * Rename alien_class.py to classes.py Message-Id: <394f35b706b695c4e89ed55c9ee5a440701a78b0.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <52bca7f28924b4006ec1deca1e6bfa45f4f922de.1643195691.git.keeperotphones+patch@gmail.com> * Added pytest decorators to classes.py Message-Id: <8b14cd3955060ba75203fd17f088876af23c403d.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <68f7980c8bc3a8a17bef575aa20b9cfb33af1a60.1643195691.git.keeperotphones+patch@gmail.com> * Filled design.md with content Message-Id: <c785ab3f2ef18847df4b787710f8d49789acb2ff.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <d9fed4beb51fa8cdfd6f998bae46efa1cef878b5.1643195691.git.keeperotphones+patch@gmail.com> * Added missing pytest decorator Message-Id: <e175774a005235c5fe4629efffc1c49b44d4898f.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <85d06e4f2024883c120931fec152cc197a74dbc4.1643195691.git.keeperotphones+patch@gmail.com> * Update instructions.md Message-Id: <4a6c7e47a87398e50d6b864ecafe879d13c522d7.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <adea0f3324e0d5aee0a0ddfb4dc4a001baeff404.1643195691.git.keeperotphones+patch@gmail.com> * Update design.md Message-Id: <e90afd667cb2428c6d86c95a0b692aa3b97c7ce4.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <c8d2ec180d0979d65eb7760495022f58d027b6f1.1643195691.git.keeperotphones+patch@gmail.com> * Update classes.py Message-Id: <1dc38f5ebfcfe86df926b98b465465e540670528.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <30be55cc209a83e431f2cb7d735830ad2ea3e40e.1643195691.git.keeperotphones+patch@gmail.com> * Update hints.md Message-Id: <6ed9657bfa2d166f445f9825b9ccf117d5d6a4b1.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <e935f4bafa27d6da7ea3c1c7827c7f7b55155881.1643195691.git.keeperotphones+patch@gmail.com> * remove trailing whitespace Message-Id: <9e59aa73585b1f50a27dda59d7960c9f89f54dd8.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <b1e7081ca1bed4d9c159e20b42c9e9ada3848923.1643195691.git.keeperotphones+patch@gmail.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Moved back-quotes and added smiley to line 45. Added additional instruction to line 46. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Added back-quotes around `class` and `method`. Specified decrement amount. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Corrected 'function' to 'method' and put back-quotes around it. Single-letter-variables changed to word-variables. Instances of 'position' -> 'coordinate' to maintain consistency with new word-variables. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Added back-quotes (for consistency). Clarified task instruction. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Single-letter-variable -> word-variable (style conformity + consistency) Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.meta/exemplar.py Single-letter-variable -> word-variable (style conformity + consistency) Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update instructions.md All instances of: - coordinate_x -> x_coordinate. - coordinate_y -> y_coordinate * Update exemplar.py Implemented x_coordinate and y_coordinate instance variables (and variants thereof - see teleport method) to conform with both expected style (i.e. no single-letter-variables) and the changes made to instructions.md. * Update exercises/concept/ellens-alien-game/.docs/instructions.md Made the instructions in the first task more explicit. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * design.md: Removed `properties` from Concepts * Code Files Cleanup * Added docstring to exemplar.py Alien class * Corrected tests in classes_test.py * Changed new_alien_list to new_aliens_collection * Edited Instructions to Match Exemplar * Merge branch 'main' of github.com:PaulT89/python Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added contents to intro Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added content to about Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Add content to concept intro Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added two links + descriptions Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Update config.json * Added blurb to config.json * Apply suggestions from code review Fixed a few typos and added missing code block in introduction. * Added additional resources to links.json * Added Python Morsels and Dan Bader * Added links on static vs class methods * Added link on history of New Style classes in python. * Added links + fixed typos Added link to: - Official Python Classes tutorial page - The DO tutorial article already linked in the exercise introduction (and as a resource in design.md) - A subsequent DO tutorial article focusing specifically on class and instance variables * Fixed typos * General Cleaning Reworded clumsy sentences, deleted whitespace, fixed typos, removed some back-quotes to improve consistency with other documentation. * Fixed typos + removed whitespace * Corrections, Nits, and Picks * Adding IsaacG as contributor * Added IsaacG as contributor Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Co-authored-by: KOTP <keeperotphones+patch@gmail.com>
2022-02-18 23:42:50 +11:00
MyClass.number += 1
2022-02-18 03:10:42 +11:00
[Classes Concept & Ellens Alien Game]: Updates (#2941) * New concept exercise: ellens-alien-game Introduces the concept of classes. Message-Id: <20220126095726.46310-2-keeperotphones+patch@gmail.com> * Update config.json Message-Id: <71aad1e9fc012ef13fa5c02ceb4e3ec349715d85.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <bc2601f32a9d9247ac2f767d1f4267f340a22ec6.1643195691.git.keeperotphones+patch@gmail.com> * Delete introduction-draft.md Message-Id: <d11b031b5ef068658b9e2b1efa882a75c2ba70c5.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <f61ad700909f434f38fb55076ab4dc4d9258a6ab.1643195691.git.keeperotphones+patch@gmail.com> * Create introduction Message-Id: <938209240cdbc86bbddc5c33403659a290ec55ac.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <ca99353a7426f0bea05df556cc19752edf48ffce.1643195691.git.keeperotphones+patch@gmail.com> * Rename introduction to introduction.md Message-Id: <4373a3b66fac460701b429d22c76cd33d8b7db4a.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <c675ca900a18a3ad9f8a6b48cdad1157ea312321.1643195691.git.keeperotphones+patch@gmail.com> * Update and rename design-draft.md to design.md Message-Id: <c863549b1a61dc045162be8d6d42ae9a505cddd1.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <71b06afa96db6e5b6dde815560a5776bc8368e8f.1643195691.git.keeperotphones+patch@gmail.com> * Fixed typo in instructions.md Message-Id: <21826fc58f9cfa53d61e6e3ccf5fcc30e6d9e411.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <88a24ed3e8685ba96fdf26bb4c0629131272281f.1643195691.git.keeperotphones+patch@gmail.com> * Formatting with YAPF Confirmed with pylint and flake8. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <ec52cd798d671348f5b29c0a691155d072c023af.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <58b93bb2ed0919c3e5753e25228bcc175a24edfa.1643195691.git.keeperotphones+patch@gmail.com> * Update config.json Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <467259ba695c8005f7106d1f359b1d4fe6c14562.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <29a418465a89c10dfd711475da4236932c4e8eff.1643195691.git.keeperotphones+patch@gmail.com> * Update exercises/concept/ellens-alien-game/.meta/config.json We'll need to rename the files though Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <933195ff036507b273b55633b40a7b76cc27f130.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <529e34d1258c17b00e20278430682cd237cae6a7.1643195691.git.keeperotphones+patch@gmail.com> * Improve wording and formatting for code formatting Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <cf9cfa5b19e0a51a1b47f11abc6d4bfdef9c7b64.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <5fd8622d5e4147746a85f3f1e63a2d5d64a066b4.1643195691.git.keeperotphones+patch@gmail.com> * Using comprehension for our list of aliens Comprehensions were introduced earlier in the concept, and so we use them here. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <1c8e73efaddfe077fe446aed6989da14398b53c6.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <e49ae05922f3dab213853e10ccad7654a4b44e7c.1643195691.git.keeperotphones+patch@gmail.com> * Rename alien_class_test.py to classes_test.py Message-Id: <493ff778d4422e418d1990f96d10c0d41c4f59ed.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <ff33af10e4617a92fcb343ead33a4060b4c7d6ad.1643195691.git.keeperotphones+patch@gmail.com> * Rename alien_class.py to classes.py Message-Id: <394f35b706b695c4e89ed55c9ee5a440701a78b0.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <52bca7f28924b4006ec1deca1e6bfa45f4f922de.1643195691.git.keeperotphones+patch@gmail.com> * Added pytest decorators to classes.py Message-Id: <8b14cd3955060ba75203fd17f088876af23c403d.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <68f7980c8bc3a8a17bef575aa20b9cfb33af1a60.1643195691.git.keeperotphones+patch@gmail.com> * Filled design.md with content Message-Id: <c785ab3f2ef18847df4b787710f8d49789acb2ff.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <d9fed4beb51fa8cdfd6f998bae46efa1cef878b5.1643195691.git.keeperotphones+patch@gmail.com> * Added missing pytest decorator Message-Id: <e175774a005235c5fe4629efffc1c49b44d4898f.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <85d06e4f2024883c120931fec152cc197a74dbc4.1643195691.git.keeperotphones+patch@gmail.com> * Update instructions.md Message-Id: <4a6c7e47a87398e50d6b864ecafe879d13c522d7.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <adea0f3324e0d5aee0a0ddfb4dc4a001baeff404.1643195691.git.keeperotphones+patch@gmail.com> * Update design.md Message-Id: <e90afd667cb2428c6d86c95a0b692aa3b97c7ce4.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <c8d2ec180d0979d65eb7760495022f58d027b6f1.1643195691.git.keeperotphones+patch@gmail.com> * Update classes.py Message-Id: <1dc38f5ebfcfe86df926b98b465465e540670528.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <30be55cc209a83e431f2cb7d735830ad2ea3e40e.1643195691.git.keeperotphones+patch@gmail.com> * Update hints.md Message-Id: <6ed9657bfa2d166f445f9825b9ccf117d5d6a4b1.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <e935f4bafa27d6da7ea3c1c7827c7f7b55155881.1643195691.git.keeperotphones+patch@gmail.com> * remove trailing whitespace Message-Id: <9e59aa73585b1f50a27dda59d7960c9f89f54dd8.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <b1e7081ca1bed4d9c159e20b42c9e9ada3848923.1643195691.git.keeperotphones+patch@gmail.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Moved back-quotes and added smiley to line 45. Added additional instruction to line 46. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Added back-quotes around `class` and `method`. Specified decrement amount. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Corrected 'function' to 'method' and put back-quotes around it. Single-letter-variables changed to word-variables. Instances of 'position' -> 'coordinate' to maintain consistency with new word-variables. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Added back-quotes (for consistency). Clarified task instruction. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Single-letter-variable -> word-variable (style conformity + consistency) Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.meta/exemplar.py Single-letter-variable -> word-variable (style conformity + consistency) Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update instructions.md All instances of: - coordinate_x -> x_coordinate. - coordinate_y -> y_coordinate * Update exemplar.py Implemented x_coordinate and y_coordinate instance variables (and variants thereof - see teleport method) to conform with both expected style (i.e. no single-letter-variables) and the changes made to instructions.md. * Update exercises/concept/ellens-alien-game/.docs/instructions.md Made the instructions in the first task more explicit. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * design.md: Removed `properties` from Concepts * Code Files Cleanup * Added docstring to exemplar.py Alien class * Corrected tests in classes_test.py * Changed new_alien_list to new_aliens_collection * Edited Instructions to Match Exemplar * Merge branch 'main' of github.com:PaulT89/python Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added contents to intro Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added content to about Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Add content to concept intro Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added two links + descriptions Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Update config.json * Added blurb to config.json * Apply suggestions from code review Fixed a few typos and added missing code block in introduction. * Added additional resources to links.json * Added Python Morsels and Dan Bader * Added links on static vs class methods * Added link on history of New Style classes in python. * Added links + fixed typos Added link to: - Official Python Classes tutorial page - The DO tutorial article already linked in the exercise introduction (and as a resource in design.md) - A subsequent DO tutorial article focusing specifically on class and instance variables * Fixed typos * General Cleaning Reworded clumsy sentences, deleted whitespace, fixed typos, removed some back-quotes to improve consistency with other documentation. * Fixed typos + removed whitespace * Corrections, Nits, and Picks * Adding IsaacG as contributor * Added IsaacG as contributor Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Co-authored-by: KOTP <keeperotphones+patch@gmail.com>
2022-02-18 23:42:50 +11:00
>>> test_object_one = MyClass((0,0))
>>> test_object_one.number
5
[Classes Concept & Ellens Alien Game]: Updates (#2941) * New concept exercise: ellens-alien-game Introduces the concept of classes. Message-Id: <20220126095726.46310-2-keeperotphones+patch@gmail.com> * Update config.json Message-Id: <71aad1e9fc012ef13fa5c02ceb4e3ec349715d85.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <bc2601f32a9d9247ac2f767d1f4267f340a22ec6.1643195691.git.keeperotphones+patch@gmail.com> * Delete introduction-draft.md Message-Id: <d11b031b5ef068658b9e2b1efa882a75c2ba70c5.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <f61ad700909f434f38fb55076ab4dc4d9258a6ab.1643195691.git.keeperotphones+patch@gmail.com> * Create introduction Message-Id: <938209240cdbc86bbddc5c33403659a290ec55ac.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <ca99353a7426f0bea05df556cc19752edf48ffce.1643195691.git.keeperotphones+patch@gmail.com> * Rename introduction to introduction.md Message-Id: <4373a3b66fac460701b429d22c76cd33d8b7db4a.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <c675ca900a18a3ad9f8a6b48cdad1157ea312321.1643195691.git.keeperotphones+patch@gmail.com> * Update and rename design-draft.md to design.md Message-Id: <c863549b1a61dc045162be8d6d42ae9a505cddd1.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <71b06afa96db6e5b6dde815560a5776bc8368e8f.1643195691.git.keeperotphones+patch@gmail.com> * Fixed typo in instructions.md Message-Id: <21826fc58f9cfa53d61e6e3ccf5fcc30e6d9e411.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <88a24ed3e8685ba96fdf26bb4c0629131272281f.1643195691.git.keeperotphones+patch@gmail.com> * Formatting with YAPF Confirmed with pylint and flake8. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <ec52cd798d671348f5b29c0a691155d072c023af.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <58b93bb2ed0919c3e5753e25228bcc175a24edfa.1643195691.git.keeperotphones+patch@gmail.com> * Update config.json Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <467259ba695c8005f7106d1f359b1d4fe6c14562.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <29a418465a89c10dfd711475da4236932c4e8eff.1643195691.git.keeperotphones+patch@gmail.com> * Update exercises/concept/ellens-alien-game/.meta/config.json We'll need to rename the files though Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <933195ff036507b273b55633b40a7b76cc27f130.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <529e34d1258c17b00e20278430682cd237cae6a7.1643195691.git.keeperotphones+patch@gmail.com> * Improve wording and formatting for code formatting Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <cf9cfa5b19e0a51a1b47f11abc6d4bfdef9c7b64.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <5fd8622d5e4147746a85f3f1e63a2d5d64a066b4.1643195691.git.keeperotphones+patch@gmail.com> * Using comprehension for our list of aliens Comprehensions were introduced earlier in the concept, and so we use them here. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <1c8e73efaddfe077fe446aed6989da14398b53c6.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <e49ae05922f3dab213853e10ccad7654a4b44e7c.1643195691.git.keeperotphones+patch@gmail.com> * Rename alien_class_test.py to classes_test.py Message-Id: <493ff778d4422e418d1990f96d10c0d41c4f59ed.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <ff33af10e4617a92fcb343ead33a4060b4c7d6ad.1643195691.git.keeperotphones+patch@gmail.com> * Rename alien_class.py to classes.py Message-Id: <394f35b706b695c4e89ed55c9ee5a440701a78b0.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <52bca7f28924b4006ec1deca1e6bfa45f4f922de.1643195691.git.keeperotphones+patch@gmail.com> * Added pytest decorators to classes.py Message-Id: <8b14cd3955060ba75203fd17f088876af23c403d.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <68f7980c8bc3a8a17bef575aa20b9cfb33af1a60.1643195691.git.keeperotphones+patch@gmail.com> * Filled design.md with content Message-Id: <c785ab3f2ef18847df4b787710f8d49789acb2ff.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <d9fed4beb51fa8cdfd6f998bae46efa1cef878b5.1643195691.git.keeperotphones+patch@gmail.com> * Added missing pytest decorator Message-Id: <e175774a005235c5fe4629efffc1c49b44d4898f.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <85d06e4f2024883c120931fec152cc197a74dbc4.1643195691.git.keeperotphones+patch@gmail.com> * Update instructions.md Message-Id: <4a6c7e47a87398e50d6b864ecafe879d13c522d7.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <adea0f3324e0d5aee0a0ddfb4dc4a001baeff404.1643195691.git.keeperotphones+patch@gmail.com> * Update design.md Message-Id: <e90afd667cb2428c6d86c95a0b692aa3b97c7ce4.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <c8d2ec180d0979d65eb7760495022f58d027b6f1.1643195691.git.keeperotphones+patch@gmail.com> * Update classes.py Message-Id: <1dc38f5ebfcfe86df926b98b465465e540670528.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <30be55cc209a83e431f2cb7d735830ad2ea3e40e.1643195691.git.keeperotphones+patch@gmail.com> * Update hints.md Message-Id: <6ed9657bfa2d166f445f9825b9ccf117d5d6a4b1.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <e935f4bafa27d6da7ea3c1c7827c7f7b55155881.1643195691.git.keeperotphones+patch@gmail.com> * remove trailing whitespace Message-Id: <9e59aa73585b1f50a27dda59d7960c9f89f54dd8.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <b1e7081ca1bed4d9c159e20b42c9e9ada3848923.1643195691.git.keeperotphones+patch@gmail.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Moved back-quotes and added smiley to line 45. Added additional instruction to line 46. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Added back-quotes around `class` and `method`. Specified decrement amount. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Corrected 'function' to 'method' and put back-quotes around it. Single-letter-variables changed to word-variables. Instances of 'position' -> 'coordinate' to maintain consistency with new word-variables. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Added back-quotes (for consistency). Clarified task instruction. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Single-letter-variable -> word-variable (style conformity + consistency) Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.meta/exemplar.py Single-letter-variable -> word-variable (style conformity + consistency) Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update instructions.md All instances of: - coordinate_x -> x_coordinate. - coordinate_y -> y_coordinate * Update exemplar.py Implemented x_coordinate and y_coordinate instance variables (and variants thereof - see teleport method) to conform with both expected style (i.e. no single-letter-variables) and the changes made to instructions.md. * Update exercises/concept/ellens-alien-game/.docs/instructions.md Made the instructions in the first task more explicit. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * design.md: Removed `properties` from Concepts * Code Files Cleanup * Added docstring to exemplar.py Alien class * Corrected tests in classes_test.py * Changed new_alien_list to new_aliens_collection * Edited Instructions to Match Exemplar * Merge branch 'main' of github.com:PaulT89/python Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added contents to intro Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added content to about Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Add content to concept intro Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added two links + descriptions Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Update config.json * Added blurb to config.json * Apply suggestions from code review Fixed a few typos and added missing code block in introduction. * Added additional resources to links.json * Added Python Morsels and Dan Bader * Added links on static vs class methods * Added link on history of New Style classes in python. * Added links + fixed typos Added link to: - Official Python Classes tutorial page - The DO tutorial article already linked in the exercise introduction (and as a resource in design.md) - A subsequent DO tutorial article focusing specifically on class and instance variables * Fixed typos * General Cleaning Reworded clumsy sentences, deleted whitespace, fixed typos, removed some back-quotes to improve consistency with other documentation. * Fixed typos + removed whitespace * Corrections, Nits, and Picks * Adding IsaacG as contributor * Added IsaacG as contributor Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Co-authored-by: KOTP <keeperotphones+patch@gmail.com>
2022-02-18 23:42:50 +11:00
>>> test_object_two = MyClass((13, -3))
>>> test_object_two.increment_number()
>>> test_object_one.number
6
```
## Placeholding or Stubbing Implementation with Pass
In previous concept exercises and practice exercise stubs, you will have seen the `pass` keyword used within the body of functions in place of actual code.
The `pass` keyword is a syntactically valid placeholder - it prevents Python from throwing a syntax error for an empty function or class definition.
Essentially, it is a way to say to the Python interpreter, 'Don't worry! I _will_ put code here eventually, I just haven't done it yet.'
```python
[Classes Concept & Ellens Alien Game]: Updates (#2941) * New concept exercise: ellens-alien-game Introduces the concept of classes. Message-Id: <20220126095726.46310-2-keeperotphones+patch@gmail.com> * Update config.json Message-Id: <71aad1e9fc012ef13fa5c02ceb4e3ec349715d85.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <bc2601f32a9d9247ac2f767d1f4267f340a22ec6.1643195691.git.keeperotphones+patch@gmail.com> * Delete introduction-draft.md Message-Id: <d11b031b5ef068658b9e2b1efa882a75c2ba70c5.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <f61ad700909f434f38fb55076ab4dc4d9258a6ab.1643195691.git.keeperotphones+patch@gmail.com> * Create introduction Message-Id: <938209240cdbc86bbddc5c33403659a290ec55ac.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <ca99353a7426f0bea05df556cc19752edf48ffce.1643195691.git.keeperotphones+patch@gmail.com> * Rename introduction to introduction.md Message-Id: <4373a3b66fac460701b429d22c76cd33d8b7db4a.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <c675ca900a18a3ad9f8a6b48cdad1157ea312321.1643195691.git.keeperotphones+patch@gmail.com> * Update and rename design-draft.md to design.md Message-Id: <c863549b1a61dc045162be8d6d42ae9a505cddd1.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <71b06afa96db6e5b6dde815560a5776bc8368e8f.1643195691.git.keeperotphones+patch@gmail.com> * Fixed typo in instructions.md Message-Id: <21826fc58f9cfa53d61e6e3ccf5fcc30e6d9e411.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <88a24ed3e8685ba96fdf26bb4c0629131272281f.1643195691.git.keeperotphones+patch@gmail.com> * Formatting with YAPF Confirmed with pylint and flake8. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <ec52cd798d671348f5b29c0a691155d072c023af.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <58b93bb2ed0919c3e5753e25228bcc175a24edfa.1643195691.git.keeperotphones+patch@gmail.com> * Update config.json Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <467259ba695c8005f7106d1f359b1d4fe6c14562.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <29a418465a89c10dfd711475da4236932c4e8eff.1643195691.git.keeperotphones+patch@gmail.com> * Update exercises/concept/ellens-alien-game/.meta/config.json We'll need to rename the files though Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <933195ff036507b273b55633b40a7b76cc27f130.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <529e34d1258c17b00e20278430682cd237cae6a7.1643195691.git.keeperotphones+patch@gmail.com> * Improve wording and formatting for code formatting Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <cf9cfa5b19e0a51a1b47f11abc6d4bfdef9c7b64.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <5fd8622d5e4147746a85f3f1e63a2d5d64a066b4.1643195691.git.keeperotphones+patch@gmail.com> * Using comprehension for our list of aliens Comprehensions were introduced earlier in the concept, and so we use them here. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <1c8e73efaddfe077fe446aed6989da14398b53c6.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <e49ae05922f3dab213853e10ccad7654a4b44e7c.1643195691.git.keeperotphones+patch@gmail.com> * Rename alien_class_test.py to classes_test.py Message-Id: <493ff778d4422e418d1990f96d10c0d41c4f59ed.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <ff33af10e4617a92fcb343ead33a4060b4c7d6ad.1643195691.git.keeperotphones+patch@gmail.com> * Rename alien_class.py to classes.py Message-Id: <394f35b706b695c4e89ed55c9ee5a440701a78b0.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <52bca7f28924b4006ec1deca1e6bfa45f4f922de.1643195691.git.keeperotphones+patch@gmail.com> * Added pytest decorators to classes.py Message-Id: <8b14cd3955060ba75203fd17f088876af23c403d.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <68f7980c8bc3a8a17bef575aa20b9cfb33af1a60.1643195691.git.keeperotphones+patch@gmail.com> * Filled design.md with content Message-Id: <c785ab3f2ef18847df4b787710f8d49789acb2ff.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <d9fed4beb51fa8cdfd6f998bae46efa1cef878b5.1643195691.git.keeperotphones+patch@gmail.com> * Added missing pytest decorator Message-Id: <e175774a005235c5fe4629efffc1c49b44d4898f.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <85d06e4f2024883c120931fec152cc197a74dbc4.1643195691.git.keeperotphones+patch@gmail.com> * Update instructions.md Message-Id: <4a6c7e47a87398e50d6b864ecafe879d13c522d7.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <adea0f3324e0d5aee0a0ddfb4dc4a001baeff404.1643195691.git.keeperotphones+patch@gmail.com> * Update design.md Message-Id: <e90afd667cb2428c6d86c95a0b692aa3b97c7ce4.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <c8d2ec180d0979d65eb7760495022f58d027b6f1.1643195691.git.keeperotphones+patch@gmail.com> * Update classes.py Message-Id: <1dc38f5ebfcfe86df926b98b465465e540670528.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <30be55cc209a83e431f2cb7d735830ad2ea3e40e.1643195691.git.keeperotphones+patch@gmail.com> * Update hints.md Message-Id: <6ed9657bfa2d166f445f9825b9ccf117d5d6a4b1.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <e935f4bafa27d6da7ea3c1c7827c7f7b55155881.1643195691.git.keeperotphones+patch@gmail.com> * remove trailing whitespace Message-Id: <9e59aa73585b1f50a27dda59d7960c9f89f54dd8.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <b1e7081ca1bed4d9c159e20b42c9e9ada3848923.1643195691.git.keeperotphones+patch@gmail.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Moved back-quotes and added smiley to line 45. Added additional instruction to line 46. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Added back-quotes around `class` and `method`. Specified decrement amount. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Corrected 'function' to 'method' and put back-quotes around it. Single-letter-variables changed to word-variables. Instances of 'position' -> 'coordinate' to maintain consistency with new word-variables. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Added back-quotes (for consistency). Clarified task instruction. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Single-letter-variable -> word-variable (style conformity + consistency) Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.meta/exemplar.py Single-letter-variable -> word-variable (style conformity + consistency) Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update instructions.md All instances of: - coordinate_x -> x_coordinate. - coordinate_y -> y_coordinate * Update exemplar.py Implemented x_coordinate and y_coordinate instance variables (and variants thereof - see teleport method) to conform with both expected style (i.e. no single-letter-variables) and the changes made to instructions.md. * Update exercises/concept/ellens-alien-game/.docs/instructions.md Made the instructions in the first task more explicit. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * design.md: Removed `properties` from Concepts * Code Files Cleanup * Added docstring to exemplar.py Alien class * Corrected tests in classes_test.py * Changed new_alien_list to new_aliens_collection * Edited Instructions to Match Exemplar * Merge branch 'main' of github.com:PaulT89/python Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added contents to intro Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added content to about Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Add content to concept intro Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added two links + descriptions Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Update config.json * Added blurb to config.json * Apply suggestions from code review Fixed a few typos and added missing code block in introduction. * Added additional resources to links.json * Added Python Morsels and Dan Bader * Added links on static vs class methods * Added link on history of New Style classes in python. * Added links + fixed typos Added link to: - Official Python Classes tutorial page - The DO tutorial article already linked in the exercise introduction (and as a resource in design.md) - A subsequent DO tutorial article focusing specifically on class and instance variables * Fixed typos * General Cleaning Reworded clumsy sentences, deleted whitespace, fixed typos, removed some back-quotes to improve consistency with other documentation. * Fixed typos + removed whitespace * Corrections, Nits, and Picks * Adding IsaacG as contributor * Added IsaacG as contributor Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Co-authored-by: KOTP <keeperotphones+patch@gmail.com>
2022-02-18 23:42:50 +11:00
class MyClass:
number = 5
string = "Hello!"
def __init__(self, location):
self.location_x = location[0]
self.location_y = location[1]
2022-02-18 03:10:42 +11:00
# Alter instance variable location_x and location_y
def change_location(self, amount):
self.location_x += amount
self.location_y += amount
return self.location_x, self.location_y
2022-02-18 03:10:42 +11:00
# Alter class variable number for all instances
def increment_number(self):
# Increment the 'number' class variable by 1.
[Classes Concept & Ellens Alien Game]: Updates (#2941) * New concept exercise: ellens-alien-game Introduces the concept of classes. Message-Id: <20220126095726.46310-2-keeperotphones+patch@gmail.com> * Update config.json Message-Id: <71aad1e9fc012ef13fa5c02ceb4e3ec349715d85.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <bc2601f32a9d9247ac2f767d1f4267f340a22ec6.1643195691.git.keeperotphones+patch@gmail.com> * Delete introduction-draft.md Message-Id: <d11b031b5ef068658b9e2b1efa882a75c2ba70c5.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <f61ad700909f434f38fb55076ab4dc4d9258a6ab.1643195691.git.keeperotphones+patch@gmail.com> * Create introduction Message-Id: <938209240cdbc86bbddc5c33403659a290ec55ac.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <ca99353a7426f0bea05df556cc19752edf48ffce.1643195691.git.keeperotphones+patch@gmail.com> * Rename introduction to introduction.md Message-Id: <4373a3b66fac460701b429d22c76cd33d8b7db4a.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <c675ca900a18a3ad9f8a6b48cdad1157ea312321.1643195691.git.keeperotphones+patch@gmail.com> * Update and rename design-draft.md to design.md Message-Id: <c863549b1a61dc045162be8d6d42ae9a505cddd1.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <71b06afa96db6e5b6dde815560a5776bc8368e8f.1643195691.git.keeperotphones+patch@gmail.com> * Fixed typo in instructions.md Message-Id: <21826fc58f9cfa53d61e6e3ccf5fcc30e6d9e411.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <88a24ed3e8685ba96fdf26bb4c0629131272281f.1643195691.git.keeperotphones+patch@gmail.com> * Formatting with YAPF Confirmed with pylint and flake8. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <ec52cd798d671348f5b29c0a691155d072c023af.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <58b93bb2ed0919c3e5753e25228bcc175a24edfa.1643195691.git.keeperotphones+patch@gmail.com> * Update config.json Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <467259ba695c8005f7106d1f359b1d4fe6c14562.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <29a418465a89c10dfd711475da4236932c4e8eff.1643195691.git.keeperotphones+patch@gmail.com> * Update exercises/concept/ellens-alien-game/.meta/config.json We'll need to rename the files though Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <933195ff036507b273b55633b40a7b76cc27f130.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <529e34d1258c17b00e20278430682cd237cae6a7.1643195691.git.keeperotphones+patch@gmail.com> * Improve wording and formatting for code formatting Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <cf9cfa5b19e0a51a1b47f11abc6d4bfdef9c7b64.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <5fd8622d5e4147746a85f3f1e63a2d5d64a066b4.1643195691.git.keeperotphones+patch@gmail.com> * Using comprehension for our list of aliens Comprehensions were introduced earlier in the concept, and so we use them here. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Message-Id: <1c8e73efaddfe077fe446aed6989da14398b53c6.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <e49ae05922f3dab213853e10ccad7654a4b44e7c.1643195691.git.keeperotphones+patch@gmail.com> * Rename alien_class_test.py to classes_test.py Message-Id: <493ff778d4422e418d1990f96d10c0d41c4f59ed.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <ff33af10e4617a92fcb343ead33a4060b4c7d6ad.1643195691.git.keeperotphones+patch@gmail.com> * Rename alien_class.py to classes.py Message-Id: <394f35b706b695c4e89ed55c9ee5a440701a78b0.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <52bca7f28924b4006ec1deca1e6bfa45f4f922de.1643195691.git.keeperotphones+patch@gmail.com> * Added pytest decorators to classes.py Message-Id: <8b14cd3955060ba75203fd17f088876af23c403d.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <68f7980c8bc3a8a17bef575aa20b9cfb33af1a60.1643195691.git.keeperotphones+patch@gmail.com> * Filled design.md with content Message-Id: <c785ab3f2ef18847df4b787710f8d49789acb2ff.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <d9fed4beb51fa8cdfd6f998bae46efa1cef878b5.1643195691.git.keeperotphones+patch@gmail.com> * Added missing pytest decorator Message-Id: <e175774a005235c5fe4629efffc1c49b44d4898f.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <85d06e4f2024883c120931fec152cc197a74dbc4.1643195691.git.keeperotphones+patch@gmail.com> * Update instructions.md Message-Id: <4a6c7e47a87398e50d6b864ecafe879d13c522d7.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <adea0f3324e0d5aee0a0ddfb4dc4a001baeff404.1643195691.git.keeperotphones+patch@gmail.com> * Update design.md Message-Id: <e90afd667cb2428c6d86c95a0b692aa3b97c7ce4.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <c8d2ec180d0979d65eb7760495022f58d027b6f1.1643195691.git.keeperotphones+patch@gmail.com> * Update classes.py Message-Id: <1dc38f5ebfcfe86df926b98b465465e540670528.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <30be55cc209a83e431f2cb7d735830ad2ea3e40e.1643195691.git.keeperotphones+patch@gmail.com> * Update hints.md Message-Id: <6ed9657bfa2d166f445f9825b9ccf117d5d6a4b1.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <e935f4bafa27d6da7ea3c1c7827c7f7b55155881.1643195691.git.keeperotphones+patch@gmail.com> * remove trailing whitespace Message-Id: <9e59aa73585b1f50a27dda59d7960c9f89f54dd8.1643189851.git.keeperotphones+patch@gmail.com> Message-Id: <b1e7081ca1bed4d9c159e20b42c9e9ada3848923.1643195691.git.keeperotphones+patch@gmail.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Moved back-quotes and added smiley to line 45. Added additional instruction to line 46. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Added back-quotes around `class` and `method`. Specified decrement amount. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Corrected 'function' to 'method' and put back-quotes around it. Single-letter-variables changed to word-variables. Instances of 'position' -> 'coordinate' to maintain consistency with new word-variables. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Added back-quotes (for consistency). Clarified task instruction. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.docs/instructions.md Single-letter-variable -> word-variable (style conformity + consistency) Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update exercises/concept/ellens-alien-game/.meta/exemplar.py Single-letter-variable -> word-variable (style conformity + consistency) Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * Update instructions.md All instances of: - coordinate_x -> x_coordinate. - coordinate_y -> y_coordinate * Update exemplar.py Implemented x_coordinate and y_coordinate instance variables (and variants thereof - see teleport method) to conform with both expected style (i.e. no single-letter-variables) and the changes made to instructions.md. * Update exercises/concept/ellens-alien-game/.docs/instructions.md Made the instructions in the first task more explicit. Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> * design.md: Removed `properties` from Concepts * Code Files Cleanup * Added docstring to exemplar.py Alien class * Corrected tests in classes_test.py * Changed new_alien_list to new_aliens_collection * Edited Instructions to Match Exemplar * Merge branch 'main' of github.com:PaulT89/python Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added contents to intro Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added content to about Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Add content to concept intro Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Added two links + descriptions Co-Authored-By: BethanyG <BethanyG@users.noreply.github.com> * Update config.json * Added blurb to config.json * Apply suggestions from code review Fixed a few typos and added missing code block in introduction. * Added additional resources to links.json * Added Python Morsels and Dan Bader * Added links on static vs class methods * Added link on history of New Style classes in python. * Added links + fixed typos Added link to: - Official Python Classes tutorial page - The DO tutorial article already linked in the exercise introduction (and as a resource in design.md) - A subsequent DO tutorial article focusing specifically on class and instance variables * Fixed typos * General Cleaning Reworded clumsy sentences, deleted whitespace, fixed typos, removed some back-quotes to improve consistency with other documentation. * Fixed typos + removed whitespace * Corrections, Nits, and Picks * Adding IsaacG as contributor * Added IsaacG as contributor Co-authored-by: BethanyG <BethanyG@users.noreply.github.com> Co-authored-by: KOTP <keeperotphones+patch@gmail.com>
2022-02-18 23:42:50 +11:00
MyClass.number += 1
2022-02-18 03:10:42 +11:00
# This will compile and run without error, but has no current functionality.
def pending_functionality(self):
2022-02-18 03:10:42 +11:00
# Stubbing or placholding the body of this method.
pass
```
[calling]: https://www.pythonmorsels.com/topics/calling-a-function
[class method]: https://stackoverflow.com/questions/17134653/difference-between-class-and-instance-methods
[dunder]: https://www.dataindependent.com/python/python-glossary/python-dunder/
[imperative]: https://en.wikipedia.org/wiki/Imperative_programming
[declarative]: https://en.wikipedia.org/wiki/Declarative_programming
[oop]: https://www.digitalocean.com/community/tutorials/how-to-construct-classes-and-define-objects-in-python-3
[functional]: https://en.wikipedia.org/wiki/Functional_programming
[dot notation]: https://stackoverflow.com/questions/45179186/understanding-the-dot-notation-in-python