293
submitted 4 months ago by sunshine@lemmy.ml to c/programmerhumor@lemmy.ml
you are viewing a single comment's thread
view the rest of the comments
[-] barubary@infosec.exchange 1 points 4 months ago

That's just syntax.

>>> 10 .yearsTraceback (most recent call last):  File "<stdin>", line 1, in <module>AttributeError: 'int' object has no attribute 'years'
[-] vga@sopuli.xyz 1 points 4 months ago* (last edited 4 months ago)

Yeah, I figured there would be a workaround. Also

>>> (10).years()
Traceback (most recent call last):
  File "<python-input-0>", line 1, in <module>
    (10).years()
    ^^^^^^^^^^
AttributeError: 'int' object has no attribute 'years'

But the other thing is also: can you add methods to the int class so that they're available everywhere? I suspect that you cannot in python, at least without significant hackery.

this post was submitted on 24 Aug 2025
293 points (97.7% liked)

Programmer Humor

39890 readers
77 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 6 years ago
MODERATORS