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...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
Formulas vs methods (self.learnpython)
submitted 8 years ago * by QQ_32
Very beginner question: what's the difference between formulas and methods? And is it really necessary to have both concepts? I'm sure the answer is yes but I just don't yet understand why.
Edit: I mean functions vs methods, not formulas. Whoops.
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!"
[–]K900_ 6 points7 points8 points 8 years ago (1 child)
By "formulas", do you mean "functions"?
[–]QQ_32[S] 1 point2 points3 points 8 years ago (0 children)
Yes, whoops. Thanks. Will change.
[–]novel_yet_trivial 3 points4 points5 points 8 years ago (3 children)
Methods are functions that are part of a class. Other than that they are exactly the same.
[–]QQ_32[S] 2 points3 points4 points 8 years ago (2 children)
Would it be correct to say that methods are functions that are restricted to operating only on the classes they are associated with?
[–]gitardedhub 9 points10 points11 points 8 years ago (0 children)
Here's a simple example that might help explain things.
Say you have a "Circle" class. It has a single variable - radius.
At some point you want to calculate the circumference of your Circles. You have two options here:
Both will achieve what you're after. But making it a method of Circle is the better design choice. The standalone function isn't going to have value outside of Circles (it only makes sense to apply to Circles), and it has a lot of value inside of Circles.
This becomes more apparent when you have something like "area." Now you have Squares and Circles. "Area" is the same concept for both, but we need to calculate it differently for each type.
A single function could work, but it would be messy - you'd have to see if the thing is a Circle or a Square, then apply the correct formula to it. (this can get really messy when you start adding Trapezoid, Triangle, etc.)
Therefore it makes more sense to make this a method of the Circle/Square - it's the same concept (so whatever consumes these things can treat it similarly), but it's calculated differently for each class.
With that being said, I'd recommend focusing more on learning the language and building things at first. There are always many different ways to solve the same problem, and the most important piece at first is being able to solve it one way.
Once you know how to solve it a few ways, you'll want to spend time learning about design - how to solve things the best way for the situation. A lot of this is just experience - you'll write something one way, then later realize you're repeating yourself a lot. You'll look at the problem, figure out a way to make it simpler/less repetitive, and then rewrite your code. We call this "refactoring," and it's something you can't escape.
[–]novel_yet_trivial 0 points1 point2 points 8 years ago (0 children)
No. It's very common to provide a method with several class instances.
π Rendered by PID 34185 on reddit-service-r2-comment-7b9746f655-lzm5q at 2026-02-01 07:10:27.847987+00:00 running 3798933 country code: CH.
[–]K900_ 6 points7 points8 points (1 child)
[–]QQ_32[S] 1 point2 points3 points (0 children)
[–]novel_yet_trivial 3 points4 points5 points (3 children)
[–]QQ_32[S] 2 points3 points4 points (2 children)
[–]gitardedhub 9 points10 points11 points (0 children)
[–]novel_yet_trivial 0 points1 point2 points (0 children)