I would hope CRV's immigrant staff are documented. If so, what's the beef with Trump? His official stance on immigration is to try to combat illegal immigration and temporarily pause immigration from unstable countries.
I just wanted to point out a bit of syntax from the article. I'm a huge fan of compact variable declaration if statements. The code from the article:
if name in names:
names[name] += 1
else:
names[name] = 1
That can actually be written as just one neat, readable line:
names[name] = names[name] + 1 if name in names else 1
It may not be as readable to some who are used to spelling it out as an if/else block, but I really prefer the one line way. It reads closer to regular English I think.
NO. That is not more readable, and is warned against in most style guides and code-quality books.
In the original, at a glance I know exactly what is going on.
In your version, I have to read the whole sentence carefully to notice that it's even a conditional and not a normal assignment, and then I have to mentally unpack it to understand the logic that you're trying to implement. If/else should never be a one-liner.
Yup, but the right way to do it would be a defaultdict, or a Counter anyway.
from collections import defaultdict
def count_names():
names = defaultdict(int)
for name in sys.stdin.readlines():
name = name.strip()
names[name] += 1
...
Me too. I've been doing web dev for 10+ years and I've never wrapped an input in a label tag. Always used the for attribute. Didn't even cross my mind it could be done differently.
We've banned this account for repeatedly posting uncivil and unsubstantive comments to HN. If you don't want it to be banned, you're welcome to email hn@ycombinator.com. We unban accounts when people give us reason to believe they'll follow the rules in the future.
"We're sorry but the page that you're looking for can not be found. The URL may be misspelled or may have changed. Try searching for the content in the search box below or select from AP's latest news instead. "
Just plugging "wikileaks" into the search box returned the correct URL:
"just for the pleasure, anyone want to try a simple
rm -rf --no-preserve-root /"
I don't have a Windows 10 computer, so I can't test this myself. I would love to know what happens though. Does this subsystem have Windows' typical self-preservation mindset, or is it full-on UNIX style?
It's much simpler to me. Tuples are used when you need a sequence but don't need to modify the contents, for instance returning multiple objects from a function call. Lists are used when you want to add things to it.
Namedtuples are wonderful! It's like a class with only attributes, except you don't have to define a new class and get slapped across the back of your head by more experienced programmers for creating a useless class. Access objects by index, by name, or by iteration. It's very versatile.
namedtuple is a reasonable way to define a new value type in python. unfortunately the very easy way to define a new type in python is to use `class`, which brings with it a bunch of behaviour that you often don't want or need: comparison by identity rather than comparison by equality, no default support for repr, no default support for ordering, mutability, support for inheritance, etc
that said, writing generic code that works transparently with both namedtuple values and objects can be a bit irritating: e.g. you might want to derive a new value/object from an existing value/object that updates one of the attributes of the value/object.
That's how the relationship between high-end PC games and the consoles work right now, so it's probably the case.