Live data from Hacker News

Python's pre-declared constants are kinda weird

sebsite.pw

101–110 of 234 posts

Re: Python's pre-declared constants are kinda weird

#101

Python is awful. There are so many one offs in libraries, none agree on a style, it’s slow, and it’s way too easy to do the wrong thing. I often work with data scientists and have to productionize their jupyter notebooks which is pure suboptimal hell. I guess it must be a good easy learning curve for research/scratchpad

Python is a language for "consenting adults". It doesn't try to prevent you from doing awful things so you can do great things. People who can't program well are given plenty of rope to hang themselves. It shares that with Perl and Ruby. That said, I find it the nicest, cleanest option of the three. I still wouldn't use it for large and complex projects. I really like it for stuff where one might otherwise use shells…

>language for "consenting adults". It doesn't try to prevent you from doing awful things so you can do great things. People who can't program well are given plenty of rope to hang themselves.

This is exactly what I remember being said about C (which I agree with) and often given as a reason why higher level languages like Python or Java have so many protections against things C/C++ allowed (memory management being the biggest one of course). Very funny, and I assume not coincidental, to read this about Python in the modern programming landscape.

Re: Python's pre-declared constants are kinda weird

#102

Earlier quoted context omitted.

Python is a language for "consenting adults". It doesn't try to prevent you from doing awful things so you can do great things. People who can't program well are given plenty of rope to hang themselves. It shares that with Perl and Ruby. That said, I find it the nicest, cleanest option of the three. I still wouldn't use it for large and complex projects. I really like it for stuff where one might otherwise use shells…

Until someone adds a dependency…

I generally just "apt install" them. pyenv and pip (just pyenv really) are a little clunky, but work too.

Re: Python's pre-declared constants are kinda weird

#104

Earlier quoted context omitted.

JS is a lot less weird than Python. And Python is what I started with and continue to use half the time. The article missed the most common one, __name__ == "__main__" like wtf

> JS is a lot less weird than Python. I challenge you to find Python behaviors as weird and off-putting as anything here: https://wtfjs.com/

I clicked on half a dozen of these at random and none of them are weird.

For example, why would you expect `Boolean("false")` to equal `false`? It's a string, and bears no relation to the Boolean type. [0]

[0] https://wtfjs.com/wtfs/2014-10-07-true-equals-false

Re: Python's pre-declared constants are kinda weird

#105
post #39

Earlier quoted context omitted.

Comparing it with PHP is unfair… to PHP. The amount of hard work that the PHP community has done to advance and keep their language relevant is impressive and admirable, and Python is perhaps the most extreme counterexample there is. The Python community has spent the last 15 years refusing to improve in any meaningful way, or to learn anything from their peers. As someone who used to choose only jobs that would let…

Most of the time downvoters don't explain their downvote, but I'll explain mine. I voted this comment down because it's just plain incorrect.I worked with PHP for nearly ten years (and I never want to go back). Maybe PHP has improved since I worked with it (PHP 7.4 was the most recent version when I last worked with it, I have never used PHP 8), but I doubt it. But to describe the Python community as "spen[ding] the…

You mentioned two biggies, but also the GIL removal, async, performance improvements, f-string, walrus, fast dicts w. merge ops, data classes, pattern matching, friendlier repl, and hundreds of smaller yearly improvements.

Re: Python's pre-declared constants are kinda weird

#106

Earlier quoted context omitted.

I honestly have never even heard of this constant and I feel like I've been using python for a pretty long time. Although maybe my memory for some things just gets garbage collected if I don't use it enough. Does it actually get used that often in real world code? Seems like it might be kind of risky.

Ditto. I’ve certainly never used it and can’t recall seeing it in any codebases I’ve worked on or looked at. Sounds interesting though! I’ve of course certainly heard of, seen, and used `assert`, but more often than not, outside of pytest, I see its use way more in potential footgun scenarios—I doubt that many people know that assertions can be silenced, and that they’d probably be better off raising exceptions in ma…

I made a CTF problem where `assert` was used as a critical safety check - and where "accidentally" running the program under -O (for speed!) resulted in a security vulnerability. A large fraction of the people who attempted the problem seemingly missed this bug.

I would not be surprised in the least if that pattern existed in the wild. In fact, it's quite common to see this in C/C++ codebases too: people will use assert() to check a security-relevant property, and then disable those checks in their release builds "because it can't happen".

Re: Python's pre-declared constants are kinda weird

#107
Python is just such a weird language in general despite its popularity that I honestly cannot recommend anyone who starts programming to choose Python as their first language, contrary to popular sentiments. I mean, I was one of the first person to start using Python when I was in grad school almost a decade ago when everybody else in my field was still using Matlab for their lab code, for the simply reason that Numpy was less awful than Matlab and I needed something that can easily print graphs to PDFs.

The only thing good I can say about Python nowadays is that it's easy to get started for the first five minutes, and then you'll have to deal with all of its weirdness: significant whitespace, truthiness, duck typing, GIL, distribution/packaging, etc, etc.

I was a big fan of Julia as the potential replacement for Python for science for such a long time and I had evangelized it a lot previously, but recently I've been more and more convinced that JIT/multiple dispatch was only good if you already know how to program well to begin with, which for a lot of academics who are not working in computer science, they write quite horrific code. I think it may be better off to skip Python altogether and write your code in a statically typed language to begin with.

Re: Python's pre-declared constants are kinda weird

#108

Earlier quoted context omitted.

Holy 2000s! Are we really still doing “programming” vs “scripting”?

Why wouldn't we? It's still a very relevant distinction, even if the terminology is a bit weird (since scripting is by definition programming). A programmer has very different needs when he writes a script to automate some server tasks versus a complex piece of software. It makes perfect sense that different tools will be more or less effective at meeting those different needs.

There is no reason why automating a server task cannot be a complex piece of software. I think you’re not aware of just what server automation is used for nowadays in countless cases. Also, Python is more popularly used in ML and web-development areas compared to server automation, so that would mean it’s not a scripting language by your logic.

Re: Python's pre-declared constants are kinda weird

#109
post #32

I remember reading that in early versions of Python there was no built in True and False. Each user would implement this themselves as True = 1 False = 0 then later these got added to the language. In Python 2 you could still reassign and swap them so that 'if False' was actually true! True, False = False, True Python 3 you could no longer reassign them.

Misery is trying to retrofit "bool", True/False, and nil/null to a language. C had to do that. Python had to do that. Getting those wrong is one of the classic language design mistakes. It seems like treating "True" as a value that equates to 1 will work, but then the special cases get you. Like being able to perform arithmetic on True. Common language design boners: - Not building in strings. That's now in the past.…

Oh wow, I had no idea that SL did another language change after migrating LSL to Mono. Surprising considering that happened late '00s/early '10s?

I'd consider LSL to have been foundational in my ultimate interest/career in software engineering. The strict typing, very usable compile/runtime errors, and good documentation/examples made it so easy to pick up as a teen. Not to mention as long as you didn't edit/save a script again it would always run the same regardless of updates.

Re: Python's pre-declared constants are kinda weird

#110
post #104

Earlier quoted context omitted.

> JS is a lot less weird than Python. I challenge you to find Python behaviors as weird and off-putting as anything here: https://wtfjs.com/

I clicked on half a dozen of these at random and none of them are weird. For example, why would you expect `Boolean("false")` to equal `false`? It's a string, and bears no relation to the Boolean type. [0] [0] https://wtfjs.com/wtfs/2014-10-07-true-equals-false

A lot of them are also about nulls and == vs ===, which are weird, but they're weird in many langs. Like Python has the whole == vs `is`. You just learn the convention and use it. Same with typecasts.
Post reply on HN