Hacker News new | past | comments | ask | show | jobs | submit | ferrari8608's comments login

> Will they design games for this and simply cut out graphics features to make it run on the slower version?

That's how the relationship between high-end PC games and the consoles work right now, so it's probably the case.


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.

Good code is boring code :)


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
            ...


Or just `names[name] += 1` if you're using a Counter.


Which would of course be the optimal solution. I always forget about that object.


This is where `collections.defaultdict` shines


I learned something new. It's not a big deal, but I'm glad it was posted nonetheless.


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.


[flagged]


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.


What a pain


Some of us are comfortable enough to admit silly little faults.


"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:

http://bigstory.ap.org/article/b70da83fd111496dbdf015acbb798...


I would love to see that core sample. The tree isn't, or at least doesn't appear to be very big, so the rings must have been tiny.


One of the commenters on that article said:

"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?


I had the same doubt


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.


If you like namedtuples, you'll love attrs. https://pypi.python.org/pypi/attrs/16.0.0


I like namedtuples, but attrs looks so wrong to me.


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.


First para: I think maybe you're confusing 'class' with inheritance from 'object'. A good tip is to do:

    class Foo(namedtuple('Foo', (...)):
        def __repr__(self):
            ...
Your 'Foo' gets ordering, hashing, comparison, because it derives from 'namedtuple'. It gets '__repr__' too, but in the example I'm overriding that.


I would also add

    __slots__ = ()
to your class definition so that instances of Foo keep the small memory footprint benefits do namedtuple.


The fact they didn't want us to know


We don't, but I haven't seen any around.


Maybe they're just hiding in the dark.

Or maybe they are the dark.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: