Recent submissions

Comment · 10 years ago
Comment · 10 years ago
Comment · 10 years ago
Good question! There are separate capitalized types for List, Dict, etc provided as part of the `typing` module in order to let you specify element types. Types are all normal Python expressions, so if you wrote `list[int]` you'd get a runtime error, because `type` objects (i.e. the `list` class) aren't subscriptable.
Comment · 10 years ago
It should work with the Python 3 syntax if you quote your type annotation. I.e.

  def f() -> "Bar": ...
instead of

  def f() -> Bar: ...
(This is normally used for forward references.) This makes it slightly less nice, but not a terrible workaround overall.
Comment · 10 years ago
Yeah, you need to write `from typing import List` to get the generic List class that you can parameterize with an item type. As you pointed out, you can use the builtin lowercase-l list without importing anything, but that doesn't allow you to specify the item type.
Comment · 10 years ago
This is intended behavior, actually! By default, mypy doesn't type check the interior of functions that don't have any type annotations. This lets you slowly introduce types to a large codebase without having to convert everything at once (or even file by file). Adding a type annotation to "bar" will cause mypy to check it:

  def foo(n: int):
      pass
  def bar() -> None:
      foo("123")

  >> main: note: In function "bar":
  >> main:4: error: Argument 1 to "foo" has incompatible type "str"; expected "int"
Comment · 13 years ago
Leeching shouldn't be too much of a problem: the user will upload while they remain on the page (which should be much longer than it took them to download the assets).
Comment · 14 years ago
Re-reading, I can see that now. Oops! (I think the paragraph break confused me.)
Comment · 14 years ago
Comment · 14 years ago
I think "the root of all evil" is, in general, not a good choice of phrase. I understand the vehemence with with you speak, but I think it's a bit overly hyperbolic and creates quibbling over the word "all". Saying that religion is the cause of much evil (which far outweighs the good) would be sufficient.
Comment · 14 years ago
> Anyone who can complete Tour de France at all or moderately but steadily grow an investment portfolio over the years should be extremely satisfied with just that already.

(I'm not certain what "should" means in that sentence - a moral judgement? - but I'll interpret it as advice.) I think that this is excellent advice for some people, but poor advice for others. I don't think there is anything wrong, per se, with wanting to be the very best at something. There's just a trade-off: you can be happily excellent, or you can take a chance and be perhaps the best but most likely just unhappy. But this decision is, in my opinion, a personal one: happiness does not have to be the ultimate goal of life.

Comment · 14 years ago
Terrible. RIP. :(

What can we do to stop things like this from happening again? There's clearly no quick-fix overnight solution, but there should be some set of actions we can take to slowly reduce/eventually eliminate this kind of violence. Any ideas?

Comment · 14 years ago
Do it! What's stopping you?

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton