u/One-Type-2842

I Require Help For Understanding super()

I understand how to use super() In subclass If they are not Written In init() method.

But If they are Implemented In init() method It becomes hard to read & understand.

Explain me what's happening Under the hood..

I know that init() method has only None return type.

class A:
	def __init__(self, mess="mess_from_A"):
		self.mess = mess

		
class B(A):
	def __init__(self, m):
		super().__init__(m)
		#self.mess


print(B("aditya").mess)
print(B("yash").mess)
reddit.com
u/One-Type-2842 — 9 days ago

Will This Reduce The Performance Or Makes Little Mistake?

num = [*range(100000)]
random.shuffle(num)
num = sorted(num)
a = ['y',"oefu","nf",'r',"fs","wowo","eqr","jdn","o""g","o","e","p","gsh"]
a = sorted(a)

Is There any Verdict to use the same variable name In line 5?

Will the Above code reduce The Performance If the List has plenty of Elements?

Personally, I Inspect using time.time() func. I seeNo difference If I changed the variable name

reddit.com
u/One-Type-2842 — 20 days ago

[help] Decorators are Hard To Construct

Firstly, Are Decorators useful in Python?

I want Tips to Define Decorators In Python.

I have Already practiced alot on them but still I am Lost.

What I know about them Is It only Decorator The 'return statement' It never Decorate print() function

reddit.com
u/One-Type-2842 — 27 days ago

When To Use __repr__() & __str__() Methods In Python

(Used AI to Improve English)

I understood that Python uses two different methods, repr() and str(), to convert objects into strings, and each one serves a distinct purpose. repr() is meant to give a precise, developer-focused description, while str() aims for a cleaner, user-friendly format. Sometimes I mix them up becuase they look kinda similar at first glance.

I noticed that the Python shell prefers repr() because it helps with debugging and gives full internal details. In contrast, the print() function calls str() whenever it exists, giving me a simpler and more readable output. This difference wasn’t obvious to me at first, but it clicked after a bit.

The example with datetime made the difference pretty clear. Evaluating the object directly showed the full technical representation, but printing it gave a more human-friendly date and time. That contrast helped me understand how Python decides which one to use in different situations.

It also became clear why defining repr() is kinda essential in custom classes. Even if I skip str(), having a reliable repr() still gives me useful info while I’m debugging or checking things in the shell. Without it, the object output just feels empty or useless.

Overall, I realised these two methods are not interchangeable at all. They each solve a different purpose—one for accurate internal representation and one for clean user display—and understanding that difference makes designing Python classes much cleaner and a bit more predictable for me.

reddit.com
u/One-Type-2842 — 28 days ago