@s_gruppetta surely, range() *is* a function - a constructor - which _returns_ an instance of a class? I guess the clever bit is that the class acts a bit like an iterator... (though why it's /not/ an iterator is a puzzle to me)
@s_gruppetta @raymondlesley What's the difference between calling a class and calling its initializer?
Also, if range is a class, shouldn't it start with an upper case letter?
@peterdrake @raymondlesley conceptually, I believe there is a difference. One creates a new object based on a template, the other normally performs actions with existing objects.
And the capital letter is just a convention, after all. I believe this is deliberate as the intention is that it’s used “like a function”, even though it isn’t. This comes from Python’s duck-typing philosophy.
@s_gruppetta @raymondlesley Can you give an example where the behavior is different?
@peterdrake @raymondlesley I never said the "behaviour" is different. On the contrary, if you look at my first post, I mention that their behaviour is the same and this is "what matters" in a duck typing language
@raymondlesley one could argue the functions are the __new__() and __init__() methods, as with any class, and not the class itself. But the class is callable, like a function, of course