News for hackers. Stuff that matters.
Re:What the f*ck python by forkLding on Thursday August 31, 2017 @12:55PM (#15141707)
There should probably be a javascript version
Re:What the f*ck python by nevir on Thursday August 31, 2017 @12:55PM (#15141713)
Re:What the f*ck python by astrobe_ on Thursday August 31, 2017 @01:03PM (#15141783)
Language inconsistencies and questionable decisions is why I use my own language whenever I can. When something is wrong, I just fix it. The end result is that it is therefore ugly, stupid and mean for everyone else though.
Re:What the f*ck python by oconnor663 on Thursday August 31, 2017 @01:04PM (#15141794)
> The principle of least surprise is not for you only. The principle of least surprise means principle of least my surprise.

- Matz, the inventor of Ruby

Re:What the f*ck python by forkLding on Thursday August 31, 2017 @01:24PM (#15141976)
Thanks, didnt know they already had one
Re:What the f*ck python by dehef on Thursday August 31, 2017 @02:26PM (#15142578)
== is most funny operator of all time. My prefered:

.1 + .2 == .3 \\false

[] == false \\true

but {} == true \\false

Re:What the f*ck python by Doxin on Friday September 01, 2017 @06:20AM (#15147296)
All of those have a sane reasoning though.

0.1+0.2 is in fact, not equal to 0.3. it is equal to 0.30000000000000004. Floating point numbers aren't exact and you shouldn't expect them to be.

When comparing things to a boolean that thing gets cast to a boolean. This is by design. bool([]) evaluates to False, so obviously False==False returns True. Same goes for your last example, bool({}) evaluates to False, after which False==True obviously returns False.

Now whether or not you like the way those works, that's how it works by design and is hardly unexpected, except if you're unfamiliar with the language.

Re:What the f*ck python by BrandoElFollito on Saturday September 02, 2017 @08:28AM (#15155622)
> that's how it works by design and is hardly unexpected

Not only that but also very useful (checking if a list a is not empty is easy to read for instance (if a:...))

Well except the first example which is an annoying fact of life.