13 thoughts on “LOLPython

  1. It’s exponent and it returns a float in one case and an int the other case. Because expressions can return either type, you’d think it would be wise to have a little polymorphism happening here. Is_integer () is only present on floats.

    Like

  2. John Hardy Turnbull delenda est I would put the ‘-2’ inside brackets. Just to be sure to be sure.

    Eg 10^(-2). The compiler may understand it, but hoomans may stuff up.

    Like

  3. To be fair, you started with an integer, and then expected to use a method that’s only in the float class on it.

    If you had used 10.0 (a float) instead of 10 (an int) this would have worked. Or even “type(10**2) is int” would probably be better.

    I think this is an issue with most scripting languages (or anything that’s auto-typed) where you’re forced to add an empty decimal value to specifically cast it as a float.

    That said… fuck python. And type identification functions should be global. Having that “.is_integer()” method specific to floats was bound to lead to confusion.

    Like

  4. Dave Maez I really dislike Python, and I believe that it’s never the best solution for any problem, and that the language itself is very poorly designed. So don’t take me as a Python apologist.

    But in this case, I think the biggest issue is the name of the method. is_integer is not a type identification method. Instead it simply checks if the number has any decimals.

    Like

  5. Satyr Icon: There’s no need to add parentheses because there’s no ambiguity here. ** is always an infix operator in Python, and although it can behave as a quasi-prefix in the syntactic sugar for passing a dict to a procedure as keyword arguments, it can never be misparsed as a postfix operator.

    Like

  6. Andres Soolo whilst the Python program may run quite happily, those who do not know Python (raises hand) can see and understand the commas.

    Back when I did programming as a subject we were taught Turbo Pascal. And the parenthesis were not necessary then either. But we put them in for humans (well i put them in) who neither knew Turbo Pascal nor its compiler.

    I understand Turbo Pascal is now a ‘dead language’, but the modular learning was probably useful.

    Self taught in Fortran (66?), C++, Lisp (don’t ask me anything about Lisp) amongst other languages. But forgot probably as much as the last time I wrote any programming was probably mid 90’s.

    Like

  7. To be honest I was only having a dig at python because it’s a dynamic language which inevitably has edge cases but which almost never are an issue.

    Of course JavaScript has a lot more of these mainly caused by automatic type coercion.

    Like

Leave a reply to Olivier Malinur Cancel reply