Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
pansa2
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
13 ms
·
181.
▲
by
pansa2
1y ago
> I don't think it's a particularly useful model for actually programming I think “everything is by reference” is a better model for programming than “you need to learn which objects are by reference and which are by value”.
182.
▲
by
pansa2
1y ago
Ah, I missed that. Thanks
183.
▲
by
pansa2
1y ago
> I'd argue the first one is not a smaller WTF than the latter. I think the first one probably arises more frequently, but at least there's a fairly straightforward explanation: "`x += y` acts in-place if-and-only-if `x`
184.
▲
by
pansa2
1y ago
> Your first example has to do with the fact that tuples are copied by value, whereas lists are "copied" by reference. My mental model for Python is that everything is '"copied" by reference', but that som
185.
▲
by
pansa2
1y ago
Neither of the examples is problematic on its own; it's the fact that the language supports both of them. They're very hard to distinguish at-a-glance yet behave entirely differently.
186.
▲
by
pansa2
1y ago
The walrus operator hardly changes that example at all: if m := re.match(pattern1, line): do_stuff(m.group(1)) else: if m := re.match(pattern2, line): do_other_stuff(m.group(2)) else:
187.
▲
by
pansa2
1y ago
My favourite Python misfeature is that `x += y` sometimes does the same thing as `x = x + y` and sometimes doesn't. This leads to minor WTFs like this: >>> a = b = (1, 2) >>> a = b = (1, 2) >>> a
188.
▲
by
pansa2
1y ago
> many recent Python extensions seem features in search of use cases […] The real problem with Python, of course, is that its evolution is largely driven by narcissism, not user feedback. Mark Lutz https://learning-python.co
189.
▲
by
pansa2
1y ago
Despite the URL, I’d only consider a few of these to be WTFs. Questions 20 & 21 definitely are, though: >>> a = 42 >>> print(f"{a:=10}") 42 >>> print(f"{(a:=10)}") 10
190.
▲
by
pansa2
1y ago
“for” is short for “for each”, presumably. `for i in 1..=10` is short for “for each integer i in the range 1 to 10”.
191.
▲
by
pansa2
1y ago
> strange misuses of "call" My favourite (least favourite?) is using “call” with “return”. On more than one occasion I’ve heard: “When we call the return keyword, the function ends.”
192.
▲
by
pansa2
1y ago
> Both sentences mean the same Not really. The first sentence is about a boy, the second is about a ball. The best one to use depends on context.
193.
▲
by
pansa2
1y ago
Keyword-only arguments? Yes: https://peps.python.org/pep-3102/ More recently, Python also added support for positional-only parameters: https://peps.python.org/pep-0570/
194.
▲
by
pansa2
1y ago
That PEP says “rejected”
195.
▲
by
pansa2
1y ago
> Cristal became ubiquitous around the world Not quite; in New Zealand they're surprisingly rare. I've never seen them for sale there, even though they're common in Australia.
196.
▲
by
pansa2
1y ago
Yes, a Father Ted Kilnettle Shrine Tape Dispenser is an alternative to a Correct Horse Battery Staple
197.
▲
by
pansa2
1y ago
Is it common in Julia to use multiple-dispatch on 3 or more arguments, or just double-dispatch? Julia definitely made the right choice to implement operators in terms of double-dispatch - it’s straightforward to know what happens when you w
198.
▲
by
pansa2
1y ago
> Most iterators provide the ability to walk an entire sequence [...] Calling the iterator again walks the sequence again. > "Single-use iterators" break that convention, providing the ability to walk a sequence only once
199.
▲
by
pansa2
1y ago
Why does this post say “Python-style syntax”, but “SYNTAX.md” shows a “clean syntax inspired by JavaScript and C-like languages”?
200.
▲
by
pansa2
1y ago
There’s at least one downside: only having lambda expressions instead of full anonymous functions. Python’s grammar works great for expressions-inside-statements (and expressions-inside-expressions), but it can’t do statements-inside-expres
201.
▲
by
pansa2
1y ago
IIRC Lua deliberately doesn’t resemble C - so if you’re going back-and-forth, editing both the host application code and a script, you can immediately tell which one you’re looking at. Makes sense to me - which means scripting languages f
202.
▲
by
pansa2
1y ago
3% of the whole company - but a lot of Python specialists were in that 3%. Including, apparently, the entire "Faster CPython" team.
203.
▲
by
pansa2
1y ago
Python’s core developers don’t even seem to care about other Python implementations (only about CPython). There’s no way they would move to, say, PyPy as the official implementation - let alone to a VM designed for a completely different la
204.
▲
by
pansa2
1y ago
You can do so in free-threaded Python too, right? The dict is still protected by a lock, but one that’s much more fine-grained than the GIL.
205.
▲
by
pansa2
1y ago
Does removal of the GIL have any other effects on multi-threaded Python code (other than allowing it to run in parallel)? My understanding is that the GIL has lasted this long not because multi-threaded Python depends on it, but because r
206.
▲
by
pansa2
1y ago
> I really wish the Lua authors would add official types to Lua. Never going to happen IMO. Adding static types would change the nature of the language completely, even more than it has in Python. As Teal shows, it would require giving
207.
▲
by
pansa2
1y ago
> How confident are you in the soundness of the type system? Teal's types are hints , like Python's and TypeScript's, so I suspect it's not sound by design. > Also, are there any Lua constructs that are difficu
208.
▲
by
pansa2
1y ago
Am I right in thinking that Python's type annotation syntax originally came from Mypy though? IIRC Mypy started off as a type annotation syntax and corresponding type checker for Python. Mypy's type annotations were adopted by Pyt
209.
▲
by
pansa2
1y ago
> Teal is a statically-typed dialect of Lua. I was expecting Teal to be "Lua + type annotations", similar to Mypy. However from a quick look it does indeed seem to be a "dialect" in its own right. Teal is Lua-like a
210.
▲
by
pansa2
1y ago
Thanks, I didn’t see that discussion at the time.
More ›