Live data from Hacker News

Python's pre-declared constants are kinda weird

sebsite.pw

111–120 of 234 posts

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

#111

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 Nump…

I think Python remains a very good intro language for getting kids in the door because it doesn’t demand too much tedious stuff, is flexible, and lets people actually solve problems rather than doing computer science.

In my experience the difficulty is understanding what exactly is important when teaching someone something new. And it largely depends on the goals. What you’d teach some biology undergrad is going to be very different from what you teach a bunch of robotics team high schoolers (and no you’re not teaching them the best language for controls and embedded).

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

#112
post #78

Earlier quoted context omitted.

> Racket / Scheme / I dare say even Haskell would just be so much simpler for learners. I have used all three languages; and you clearly have no idea of the notion of usability of a language. So many things contradict this, let me list them off the top of my head - Getting a running toolchain working: Prexisting (most OSes bundle a Python interpreter) or a package install away for Python. Scheme / Racket is some odd…

> Quickly intelligible if you learned something else like Java or C++ You’re replying to a post making assertions about beginners . That doesn’t usually mean people with 4 years programming experience picking up a new language. Racket: criticizing for having a beginner-friendly IDE doesn’t make a lot of sense. There’s always Magic Racket for VSCode for the others. I guess you’re not starting people with “How to Desig…

> Haskell: that was funny but an absurd criticism ghc vs ghci?? Nobody has that problem.

Back when I was a beginner actually interested in getting out of the beginner step of Haskell, this was an issue for me times. So there's at least one person :)

Also anecdotally I have seen people ask this in Freenode #haskell as well (the “Freenode” probably tells you how long ago this was) ; and there a few issues [1] and [2] where I see beginners having the same/similar issue. The second one is particularly funny, 4 people give 5 solutions and no one seems to know what the actual fix is. Instead you have people arguing whether a repeated do works or not. This would never happen with Python, just saying :)

> Racket: criticizing for having a beginner-friendly IDE doesn’t make a lot of sense.

Sorry, perhaps too harsh but I don't think it's as beginner-friendly as you think. I think it would probably help if they made the design more modern and welcoming. All these details about you can rewrite entire languages in Lisp and we can't even at least get a GUI that looks like it was written after 2007?

---------

[1] https://www.reddit.com/r/haskell/comments/1kfym5s/difference...

[2] https://www.reddit.com/r/haskell/comments/18yj7i5/i_have_jus...

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

#113

A lot of Python design decisions have felt weird and off to me but they’ve long justified it by saying that it’s those little ugly design choices that make the language so usable and effective in practice compared to more well-designed languages that hardly anybody uses. I’m not enough of an expert to clearly say if that’s really true, but imo, there’s a repeated pattern of slightly weirdly designed languages becomin…

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

> __name__ == "__main__"

What makes this weirder than other languages detecting if they’re an import or an invoked file?

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

#114

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 Nump…

I think Python remains a very good intro language for getting kids in the door because it doesn’t demand too much tedious stuff, is flexible, and lets people actually solve problems rather than doing computer science. In my experience the difficulty is understanding what exactly is important when teaching someone something new. And it largely depends on the goals. What you’d teach some biology undergrad is going to b…

What is the best language for controls and embedded, in your opinion? I assume from your comment that it's not a great choice as a first language to teach newbies, but I've never done anything in the field of robotics or embedded stuff, so I'm quite ignorant in that area.

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

#115
If you count pre-release versions, there are actually 7 pre-declared constants, since Python 3.15 (planned for release in November [0]) adds a new constant "TYPE_CHECKING" that should behave like "Ellipsis" and "NotImplemented" do right now [1].

[0]: https://peps.python.org/pep-0790/#schedule

[1]: https://peps.python.org/pep-0781/#backwards-compatibility

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

#116
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

I agree that the examples on that site are not very good. What about

    [1, 2, 3] + [4, 5, 6] == "1, 2, 34, 5, 6"
or

    parseInt(0.000001) == 0
    parseInt(0.0000001) == 1
or

    "" + 5 == "5"
    "" - 5 = -5

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

#117

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 Nump…

Are academics who are not working in computer science interested in learning statically typed programming languages?

In the past, the usual answer to people who need a programming language but did not want to learn programming was to give them a domain specific language that focused on solving the specific problem they wanted to solve.

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

#118
post #85

> True, False, and None are keywords. they aren't identifiers, they're just straight up their own lexical tokens. Could this be so that the interpreter don't inadvertently manipulate them or pass them to a function? param=None and param="" can be very different.

It also helps prevent people from ever redefining them. I mean, if you try to redefine False (in a version of Python that allows it) then you deserve everything that's about to happen to your code... but at the same time, it could possibly lead to a security attack. Redefine False then import some module and get unexpected behavior that you can manipulate to your advantage, somehow. I don't know how that would work, it probably wouldn't... but there's also no reason not to lock those names in and prevent them from ever being redefined.

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

#119

Earlier quoted context omitted.

I’m not a regular JS user and haven’t touched the language in a long time, but I remember a (popular?) website for teaching modern JavaScript mentioned that some aspect of the function/macro that returns the type of an object was just plain wrong in a specific and important case. This was years ago however, so maybe the problem isn’t there anymore. Anyhow, I added JS to the list mainly because it is known as a badly…

There are certainly weird things about it, but they're all things you can ignore especially in modern times, whereas in Python you're constantly dealing with it head-on.

Ah yes, nowdays it is even easier, but "Javascript, the good parts" came out 18 years ago already.

https://www.oreilly.com/library/view/javascript-the-good/978...

Helped me get a more pragmatic approach to use that chaotic mess of a language and environment. Just use what works, ignore the rest (but I also ignored some specific advice from the book and used what worked for me).

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

#120
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

Fair, but I'd expect consistency. Number("1") equals `1` IIRC.
Post reply on HN