News for hackers. Stuff that matters.
Re:OO in Python is mostly pointless by aidenn0 on Thursday January 28, 2021 @04:21AM (#25939894)
How about file-like objects in python? Many file-like interfaces are necessarily stateful, and having the state wrapped in an object that encapsulates the state allows for graceful reuse.

As a bonus, there's no need for inheritance in python due to duck typing.

Re:OO in Python is mostly pointless by chriszhang on Thursday January 28, 2021 @05:37AM (#25940313)
> How about file-like objects in python? Many file-like interfaces are necessarily stateful.

Still the state and the functions that operate on them can be separated out. Right? No reason why the state and the functions need to be tied together inside a class.

Re:OO in Python is mostly pointless by aidenn0 on Thursday January 28, 2021 @01:03PM (#25945944)
Are you suggesting everything that currently takes a file-loke object "f" instead takes "fstate" "fread" "fwrite" "fclose" "fflush"...?
Re:OO in Python is mostly pointless by leontrolski on Thursday January 28, 2021 @05:09AM (#25940145)
I think you could be on to something - that feels like an area with tightly coupled state and functionality. (Sorry for spamming this thread with comments like this), but would you mind emailing some example code, and we can test what happens?