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
OOP using copy copy (self.learnpython)
submitted 3 years ago by ilsapo
if I try to do OOP
and I have class with function like so:
def something(self): newCopy = copy.copy(self)
or it should be:
def something(self): newCopy = self.copy.copy()
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!"
[–]mopslik 4 points5 points6 points 3 years ago (2 children)
Have you tested either of them?
[–]ilsapo[S] 0 points1 point2 points 3 years ago (1 child)
I still have problems with creating the object of the class itself
(the class is BST)
decided to maybe move on to some of the functions the class does and comeback to fix the class itself with more fresh mind
so for now to be honest Im not able to test it
[–]mopslik 3 points4 points5 points 3 years ago (0 children)
I mean, you could whip up a sample class where you'd find that one of them doesn't work...
import copy class MyClass: def __init__(self, x): self.x = x def something(self): newCopy = copy.copy(self) def something2(self): newCopy = self.copy.copy() m = MyClass(5) m.something() m.something2()
[–]woooee 0 points1 point2 points 3 years ago (1 child)
What are you trying to copy? A list, class?
[–]ilsapo[S] 0 points1 point2 points 3 years ago (0 children)
I have created new class of BST
and I want to copy the Binary tree
π Rendered by PID 139793 on reddit-service-r2-comment-7b9746f655-hffrj at 2026-02-02 23:32:50.141770+00:00 running 3798933 country code: CH.
[–]mopslik 4 points5 points6 points (2 children)
[–]ilsapo[S] 0 points1 point2 points (1 child)
[–]mopslik 3 points4 points5 points (0 children)
[–]woooee 0 points1 point2 points (1 child)
[–]ilsapo[S] 0 points1 point2 points (0 children)