Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
clusmore
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
32 ms
·
271.
▲
by
clusmore
10y ago
Actually Python does explicitly reject strings. >>> sum(['hello', ' world'], '') TypeError: sum() can't sum strings [use ''.join(seq) instead] But this is done explicitly agains
272.
▲
by
clusmore
10y ago
I understand your point, and perhaps we don't actually disagree on this. As an example, in Haskell (which you have shown in another comment that you are familiar with), this function would perhaps best be written as sum_and_stringi
273.
▲
by
clusmore
10y ago
Yes. Haskell's type deduction is exactly what I was thinking of as I read the article. You write a function using what you need and it deducts the requirements based on usage, giving you the most general type. I think this is actually
274.
▲
by
clusmore
10y ago
Yes, this is a good point too which I certainly agree with. Sometimes by using the most general type, you actually permit more than you intended and you might restrict yourself from making refactorings to the function because it would restr
275.
▲
by
clusmore
10y ago
Fair point. I realise I sound quite critical in my comments so perhaps I should add that I like the tool itself. The problems that I see are more in the usage as shown in the examples. I am not necessarily suggesting that in all circumstanc
276.
▲
by
clusmore
10y ago
Thanks for the suggestion. For the record, I'm a fairly happy C# for work, Haskell for hobby programmer, using Python as my go-to for quick-and-dirty scripts. My comments here are mostly based on my own thoughts on the static vs dynami
277.
▲
by
clusmore
10y ago
Pasting the relevant snippet from your link: def __subclasshook__(cls, C): if cls is Iterable: if any("__iter__" in B.__dict__ for B in C.__mro__): return True return NotImplemented Wow,
278.
▲
by
clusmore
10y ago
That's a fair point on the lack of support for strings by sum, but note this is only because the function is hard-coded explicitly to reject them and only because it's not the best way to build strings. By usage, strings should j
279.
▲
by
clusmore
10y ago
This is great provided that Addable is not just something hardcoded to know about builtins like int and float. If I create my own class that quacks like an Addable, then it needs to be supported. That's the essence of duck-typing.
280.
▲
by
clusmore
10y ago
Well sure but that's just the danger of duck typing vs explicit interface implementation, something Python already suffers from. Without MyPy, Python will already let you use this function on all sequences of addable things, not just l
281.
▲
by
clusmore
10y ago
Yeah but as I said it can still go far more general than just int, float and complex. It could be any arbitrary class defined by somebody else that I could not possibly know about at design time, and so a whitelisting approach of concrete c
282.
▲
by
clusmore
10y ago
Yeah I agree with you completely, I think we just use different terminology to describe the same thing. It sounds like you use "type" to mean "concrete type", i.e. the thing it actually is , and not the thing it acts li
283.
▲
by
clusmore
10y ago
Honestly I haven't looked into MyPy a huge amount, and haven't used it yet. But from reading the docs on it I feel like it's taking the wrong approach. In my opinion, Python is all about duck typing, so having a static type c
284.
▲
by
clusmore
10y ago
>If you are not trained in persuasion, Trump look scary. I don't really understand the point surrounding this statement. Most voters are not trained in persuasion, so how is it a good strategy to do something that makes you look sca
285.
▲
by
clusmore
10y ago
Interestingly, the webpage itself cannot be turned into a document. >We couldn't find any text for creating the document. Please send us the problematic link : https://documentcyborg.com/ via our contactus form. Thi
286.
▲
by
clusmore
10y ago
>The important question is what is the computational complexity of the transformation? In my view it makes no sense to use metrics from one model on the other. There is no computational complexity involved in the transformations defined
287.
▲
by
clusmore
10y ago
This may be confirmation bias but I feel like since the Megaprocessor thread[1] I'm noticing an increase in hardware-simulation related posts. Can't think of them all off the top of my head, but see also: * Nand2Tetris[2] [1] htt
288.
▲
by
clusmore
10y ago
>Out variables seem like a mis-feature, especially when they are adding a better alternative (Tuples) in the same release. You can't retro-fit multiple-returns (via Tuples) onto existing library functions, so for places where you&#x