Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
Suor
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
8 ms
·
31.
▲
by
Suor
12y ago
It's not lazy, it returns iterator. There is a difference, you can't slice or index its result anymore. Compare to Clojure or Haskell map, which are truly lazy.
32.
▲
by
Suor
12y ago
No it won't, unless you `tee` an iterator first.
33.
▲
by
Suor
12y ago
It's easy cause it's familiar. But it's not simple. This excellent talk by Rich Hickey explains the difference http://www.infoq.com/presentations/Simple-Made-Easy
34.
▲
by
Suor
12y ago
If core is small then such language should provide a way to extend it outside. Like macros.
35.
▲
by
Suor
12y ago
Just zip(seq, seq[1:]) Won't work with iterator though.
36.
▲
by
Suor
12y ago
It doesn't need direct port. But it can take advantage borrowing ideas or library design principles.
37.
▲
Why Every Language Needs Its Underscore
(hackflow.com)
88 points
by
Suor
12y ago
|
76 comments
38.
▲
On ORM Cache Invalidation
(hackflow.com)
5 points
by
Suor
13y ago
|
0 comments
39.
▲
by
Suor
13y ago
The first part of a post is mere reasoning showing how I got to the actual interface I use. @decorator works with `call` not with `func, args, *kwargs`.
40.
▲
by
Suor
13y ago
funcy doesn't preserve function signature. The only way for now to do this is to use exec, e.g. compile code from source or AST, which I choose to avoid.
41.
▲
by
Suor
13y ago
You will still need a wrapper function and update it's metadata. Which is even more boilerplate. Or you can hide that in base Decorator class, but then we'll back to another layer of abstraction. So it's either more boilerpla
42.
▲
by
Suor
13y ago
This handles decorators with arguments and makes a general case of passing same arguments to function as to wrapper less cluttered.
43.
▲
by
Suor
13y ago
This looks like even more boilerplate.
44.
▲
Painless Decorators in Python
(hackflow.com)
97 points
by
Suor
13y ago
|
26 comments
45.
▲
by
Suor
13y ago
You can pass flags and compiled regular expression. Pattern with named captures causes re_find to return dict. You won't get entire match if you have several captures, but you can add a pair of parentheses around your regexp to circumv
46.
▲
by
Suor
13y ago
re_find returns tuple of all captures if there are more than one. See parse ini example
47.
▲
Functional Python Made Easy
(hackflow.com)
138 points
by
Suor
13y ago
|
33 comments
48.
▲
by
Suor
13y ago
Oh, I probably should spend some time clarifying the docs. But basically it just helps avoiding nesting functions, a common boilerplate when writing decorators.
49.
▲
by
Suor
13y ago
No, @decorator takes care of it - http://funcy.readthedocs.org/en/latest/decorators.html
50.
▲
by
Suor
13y ago
There is a price for new vocabulary involved, which is some learning curve. By the way, first piece of code can become much more hairy with time.
51.
▲
Abstracting Control Flow
(hackflow.com)
27 points
by
Suor
13y ago
|
11 comments
52.
▲
Show HN: Pattern matching for Python
(github.com)
2 points
by
Suor
13y ago
|
0 comments
53.
▲
by
Suor
13y ago
Yes, that decisions look dirty and dubious, but using funcy for several months, I've come to that practicality and convenience is worth it. Some of itertools things are just reexports and builtins are extended purely - so that they behave t
54.
▲
by
Suor
13y ago
Yes, where() doesn't handle that case, but it makes its interface more smooth for more common case of string keys. That was a deliberate choice.
55.
▲
by
Suor
13y ago
Predicate in some() is optional. A test for boolean truth is used in that case. So, first example is the same as: some(bool, [0, '', -1, None, 2])
56.
▲
Show HN: A set of handy tools to work with sequences and collections in Python
(github.com)
29 points
by
Suor
13y ago
|
10 comments
57.
▲
Some clojure inspired functional tools in python
(github.com)
4 points
by
Suor
14y ago
|
0 comments
58.
▲
by
Suor
14y ago
Sorry, if this is a dump question, but how I can add some package and then require it in playground? I'm trying to (require 'http.async.client)