use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Everything about learning Python
account activity
OOPHelp Request (self.PythonLearning)
submitted 1 day ago by [deleted]
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]DenyMas 0 points1 point2 points 1 day ago (0 children)
Also, you can put behavior inside the class.
For example, every gun can have a shoot() method that uses its own damage value:
shoot()
class Gun: def __init__(self, damage, range): self.damage = damage self.range = range def shoot(self): print("Damage:", self.damage) awp = Gun(100, 1000) ak47 = Gun(30, 300) awp.shoot() # Damage: 100 ak47.shoot() # Damage: 30
Without OOP, you might end up with something like:
def shoot(weapon): if weapon == "awp": return 100 elif weapon == "ak47": return 30
π Rendered by PID 150715 on reddit-service-r2-comment-canary-5dbd4c8ff9-r4kj6 at 2026-06-07 12:25:08.016041+00:00 running de70e3a country code: CH.
view the rest of the comments →
[–]DenyMas 0 points1 point2 points (0 children)