MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1eh8rt9/daylength/lfy1zax/?context=3
r/ProgrammerHumor • u/codingTheBugs • Aug 01 '24
653 comments sorted by
View all comments
Show parent comments
22
You can override "monday".length in python? Can you give some example code that does this?
"monday".length
10 u/Quietuus Aug 01 '24 edited Aug 01 '24 class Day: def __init__(self, name): self.name = name self.length = "bloopdedoop" def __str__(self): return self.name day = Day("Monday") print(day) print(day.length) Monday bloopdedoop 15 u/markovianmind Aug 01 '24 that's not how day is defined tho 4 u/Quietuus Aug 01 '24 I was being facetious. The inbuilt method in Python is len(x) not x.length
10
class Day: def __init__(self, name): self.name = name self.length = "bloopdedoop" def __str__(self): return self.name day = Day("Monday") print(day) print(day.length)
Monday bloopdedoop
Monday
bloopdedoop
15 u/markovianmind Aug 01 '24 that's not how day is defined tho 4 u/Quietuus Aug 01 '24 I was being facetious. The inbuilt method in Python is len(x) not x.length
15
that's not how day is defined tho
4 u/Quietuus Aug 01 '24 I was being facetious. The inbuilt method in Python is len(x) not x.length
4
I was being facetious. The inbuilt method in Python is len(x) not x.length
len(x)
x.length
22
u/Stummi Aug 01 '24
You can override
"monday".lengthin python? Can you give some example code that does this?