On Fri, Jun 03, 2016 at 06:17:30AM -0700, Neil Schemenauer wrote:
Here is a thought that occured to me. Create a patched version of Python 3.x, making a stepping stone version for people porting from Python 2. I know this would have been useful for me. Specific changes that would be helpful, all generating warnings so code can be eventually fixed:
- comparision with None, smaller than all other types
Sometimes I think that would be useful as a feature, not just for 2.x compatibility...
- comparision of distinct types: use Python 2 behavior (i.e. order by type name) - mixing of unicode strings with byte strings: decode/encode using latin-1
These would be a reversion to harmful behaviour and I guarantee they would be abused. But I don't understand why you want 3.x to raise a warning? It will raise an exception, which you then fix. How is this better than a warning that you will ignore? If this is purely a budget issue ("my boss has given me six weeks to port, but it will take eight, however if we can get warnings and suppress them, we'll squeeze in under budget") then you have my sympathy but not much else.
- dict objects: make keys() items() values() return special sequence that warns if iterated over multiple times or indexed as sequence
This is surely unnecessary -- you just need to mechanically change your dict iteration to use dict.viewkeys() etc in Python 2, fix any problems, then mechanically remove the "view" in Python 3. -- Steve