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

Dead link



2 of 139816 is 0,000014305%


isn't it 0.00143045%?


My ISP is seemingly blocking that site. I can access it from my DO VPS, though.


NB a tuple of one item only requires a trailing comma, and a tuple of zero items is represented as ()


I don't mean to be pedantic, but a list (I am assuming df is a list) requires an int.

(That sentence I wrote about using hashable types need not apply, sorry!)

If you ran that code, you would get this error:

    TypeError: list indices must be integers, not list


That's a pandas dataframe (idiomatically denoted df), not a list. It has funky slicing properties, and he's selecting columns of the dataframe in a perfectly valid way.


    alist = [foo(word) for word in words if word.startswith('a')]
    alist = map(foo, filter(lambda word: word.startswith('a'), words))
Which reads better?


I don't use FP practices in Python much, but if I did I'd define the filter outside the map, like so:

    begins_with_a = lambda x: x.startswith('a')
    alist = map(foo, filter(begins_with_a, words))


Even with named functions, Python's use of global functions instead of methods for iterators force you to read the expression from the inside out. I think Lisp languages nailed this with their threading macros, which allow natural left-to-right reading, but Ruby's strategy is better than Python's, too, while maintaining very similar syntax.

    ;; clojure
    (let [begins-with-a #(.startsWith % "a")
          foo #(do-some-stuff-with %)]
      (-> words (filter begins-with-a) (map foo))))

    # ruby
    words.filter { |e| e.start_with?(?a) }.map { |e| foo(e) }
It doesn't really make sense for things like `len` and `map` to be global functions in object-oriented languages.


Those are not equivalent. You need to wrap the map in a list() call.


In Python 3 you'd be right, but I think people still call mostly that language "Python 3" and mean Python 2 when they say "Python".


Admittedly, my thought would be to chain the calls, not nest them:

   alist = words.filter(lambda word: word.startswith('a')
                .map(foo)
That being said, my Python is limited and I don't know it filter/map are available as methods of a list. At the end of the day, there are cases where list comprehensions are much cleaner/understandable... and cases where the reverse is true.


> I don't know it filter/map are available as methods of a list.

They're not. Which is a shame in my opinion, because as you've written it you can clearly read the operations in the order they happen, ie. filter followed by map. Instead, you do have to do the second line of what blossoms wrote above.

And I don't think it's possible to write a list comprehension that reads in execution order, either :(


Map and filter, of course; less syntactical noise, simple function semantics, and plenty of precedent and equivalents in all other languages.


It's not like list comprehensions lack equivalent in other languages. Let's take Haskell for example. Python lists comprehension could use a where clause from Haskell though so one could really pack everything into a one-liner :)

(as it is now, list comprehensions requiring various references to result of a function call evaluate the function each time it's used)


Afaik Apple's switching power supplies support the specifications you described (for example, see Mac Mini's tech specs https://www.apple.com/mac-mini/specs.html -- 50-60Hz 100-240v AC).

Not to mention Apple sells region-specialized units just like every other major computer retailer.


Anybody have a link to the document? It's behind a paywall?


I seem to be able to access it, and I've never paid Scribd anything.


They're referring to the document in the article. Not the article or scribd.


Any internet website can be attacked this same way.


That mangles binary data.

    $ printf 'binarydata'|awk '{ print }'|hexdump -C
    00000000  62 69 6e 61 72 79 64 61  74 61 0a                 |binarydata.|
    0000000b


Join us for AI Startup School this June 16-17 in San Francisco!

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

Search: