(Jul-16-2018, 08:37 PM)porton Wrote: I mean if I rewrite a generator function as an iterator class or vice versa, I need to change its casing.
As per PEP 8, I would change it.
A little more reason on why this might not be
cargo-culty - as a client of your generator, I can assume that your generator is going to act like a normal Python generator. It won't have any additional methods (even if I want them) and if there's a bug I have a hint about where to start looking (there's not going to be any behavior overrides). If it's a class, I might want to look at the API more, if there are any behaviors I'm surprised by I will know that there might be more methods or behavior overrides involved, etc.
If you prefer following the logic that the name shouldn't change because the signature/interface didn't change, I'd just be sure to document that in your project. Especially if you're not confident that you can easily and completely do the rename, this seems like a reasonable time to violate PEP 8, which is a suggestion more than a rule.
Lastly, you can split the difference - name your thing as a class and then either wrap it with the function that returns an instance of your new generator class, or else include in the file it's imported from a line like
generator = Generator
which will allow existing clients to not have to be changed, potentially with a comment about the name being deprecated.