For example, clang and gcc can still compile C89 programs.
What new Python features are the most useful for you?
21–30 of 44 posts
Re: What new Python features are the most useful for you?
#22In the 15 years I have been developing in python (and C++ at the same time, daily), I can't remember a single bug I ever had on account of an incorrect type. I do like the := to save a few lines here and there. 3.10 does seem to run faster but maybe that is my imagination. I wish more people would focus on writing good python.
what do you attribute to never finding a bug due to incorrect type? and what is good python vs bad python?
If the function/method expects an int, string or complex type and I accidentally call it with the wrong type, resulting in an error, such as "can't add 1 to a string", or "can't access access that method because a string was passed".
>and what is good python vs bad python?
This is kinda of subjective but, for a start, don't just start at the type and do stuff until the bottom like a shell script. This is by far how I see most python scripts. All the other normal things. Don't repeat yourself (in moderation, a few times is OK). Keep it simple.
Re: What new Python features are the most useful for you?
#23That in itself is a great feature.
Re: What new Python features are the most useful for you?
#24Re: What new Python features are the most useful for you?
#25Earlier quoted context omitted.
what do you attribute to never finding a bug due to incorrect type? and what is good python vs bad python?
> what do you attribute to never finding a bug due to incorrect type? If the function/method expects an int, string or complex type and I accidentally call it with the wrong type, resulting in an error, such as "can't add 1 to a string", or "can't access access that method because a string was passed". >and what is good python vs bad python? This is kinda of subjective but, for a start, don't just start at the type a…
Re: What new Python features are the most useful for you?
#26In the 15 years I have been developing in python (and C++ at the same time, daily), I can't remember a single bug I ever had on account of an incorrect type. I do like the := to save a few lines here and there. 3.10 does seem to run faster but maybe that is my imagination. I wish more people would focus on writing good python.
it is not necessarily about type mismatch bugs per se, but more like without type information in the code I will misunderstand what kind of structure is passed in to a function, how to decompose it, what members the data has, what functions does it have, how do you spell them correctly, what elements to expect in dictionaries and what kinds of values do they have, and how can I make massive changes to code without knowing all those answers and expect it all to still work.
type annotations are solving a lot of those issues for me nicely, and the number of things that it doesn't solve well is decreasing with each version and the new features they are adding
Re: What new Python features are the most useful for you?
#27Earlier quoted context omitted.
> what do you attribute to never finding a bug due to incorrect type? If the function/method expects an int, string or complex type and I accidentally call it with the wrong type, resulting in an error, such as "can't add 1 to a string", or "can't access access that method because a string was passed". >and what is good python vs bad python? This is kinda of subjective but, for a start, don't just start at the type a…
I guess I meant what do you do to prevent that from happening.
Us older people tend to keep the whole workflow as simple as possible. That is why I love python. There is very little overhead to just using it.
If you tend to make this mistake a lot it might make sense to add some tooling. I don't need it. If I wanted strict typing I would probably just use C++.
Re: What new Python features are the most useful for you?
#28Earlier quoted context omitted.
I guess I meant what do you do to prevent that from happening.
That is my point. I don't have any tools to prevent it from happening. I just don't do it when I write the code. If I have and my code is tested it comes up very quickly. Us older people tend to keep the whole workflow as simple as possible. That is why I love python. There is very little overhead to just using it. If you tend to make this mistake a lot it might make sense to add some tooling. I don't need it. If I w…
For example, if you're redefining bug as "bug that made it past testing" that's one thing.
But I don't buy anyone writing Python daily for 15 years hasn't seen the term "TypeError" which is what your previous two comments were implying.
Re: What new Python features are the most useful for you?
#29Earlier quoted context omitted.
I guess I meant what do you do to prevent that from happening.
That is my point. I don't have any tools to prevent it from happening. I just don't do it when I write the code. If I have and my code is tested it comes up very quickly. Us older people tend to keep the whole workflow as simple as possible. That is why I love python. There is very little overhead to just using it. If you tend to make this mistake a lot it might make sense to add some tooling. I don't need it. If I w…
Re: What new Python features are the most useful for you?
#30Hope they will add support for Unicode sets `\p{}`, subexpression calls, (*SKIP)(*F), etc. For now, the third-party `regex` module is handy for such features.