Skip to content

Comment on Python Programming for the Privileged Classparent

Comments

I would definitely prefer jmpeax's answer.

Although, there was a question/discussion similar to this here: https://www.youtube.com/watch?v=u-kkf76TDHE#t=2584

The gist was that, if the interface and the structs that are supposed to satisfy that interface belong to the same package, and then you want to prevent any outsider from implementing that interface, you can actually include an unexported method:

    type HtmlStringer interface {
        ToString() string
        isHtmlStringer()
    }
Since it is unexported, no outsider struct can actually satisfy this interface anymore.
AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.