Live data from Hacker News

Unpythonic Python

skien.cc

21–30 of 156 posts

Re: Unpythonic Python

#22
post #18

Earlier quoted context omitted.

A minor quibble, but in Python 3 you can print in a lambda because print is no longer a keyword.

As a non-Python 3 user, I just opened up the python 3 REPL to try something I always find myself wanting to do in tiny little python scripts: map(print, some_list) Unfortunately, it returned a map object, which I guess is also new in Python 3 (I assume it's a lazy application device).

Yeah, the map builtin is essentially itertools.imap in python 3.

Re: Unpythonic Python

#23
The actual Java implementation: https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpris...

A non-programmer’s solution to “Fizz Buzz” https://news.ycombinator.com/item?id=4853509

FizzBuzz Still Works http://www.globalnerdy.com/2012/11/15/fizzbuzz-still-works/

FizzBuzz with CSS http://dabblet.com/gist/2628265

Re: Unpythonic Python

#24
post #14

Earlier quoted context omitted.

Something annoying about python is that the word "lambda" is so long for what are supposed to be one-off functions. You have f=lambda x,y=1,a='Fizz',b='Buzz': ... But it's actually shorter to say def f(x,y=1,a='Fizz',b='Buzz'): ... I much prefer Haskell's \x -> x Style lambdas.

I generally don't particularly like giving punctuation meaning that, well, isn't punctuating. The bottleneck when writing code is almost never keypresses. I think CoffeeScript gets it probably the most right of languages I've worked with, in that the choice of punctuation makes intuitive sense... "Hey! It's an Arrow. It goes from here to here". FWIW, I don't like the word "lambda" either... Naming things with one let…

I cannot agree enough. Someone give me a call when a Haskell-like language with readable syntax appears. I really like the ideas behind Haskell, but the syntax is so unfriendly that I cannot be bothered to really start using it. Less special characters, please.

Re: Unpythonic Python

#25
post #14

Earlier quoted context omitted.

I generally don't particularly like giving punctuation meaning that, well, isn't punctuating. The bottleneck when writing code is almost never keypresses. I think CoffeeScript gets it probably the most right of languages I've worked with, in that the choice of punctuation makes intuitive sense... "Hey! It's an Arrow. It goes from here to here". FWIW, I don't like the word "lambda" either... Naming things with one let…

The reasoning behind using '\' for lambda in Haskell was because it sort of looks like a lambda character ( λ vs \ ) if you squint hard enough.

That's just horrible. I don't know what more to say about it than that. How did anyone think this would be a good idea on balance?

Re: Unpythonic Python

#26
post #7

This was what one of our Java coworkers wrote a while back: https://gist.github.com/1337/8155054

That kind of code could make sense when you're using a very opinionated API, that is designed (for better or worse) with patterns in mind, such as Android. But, when you start bringing that style of coding outside of that environment...

Yuck.

Re: Unpythonic Python

#27
post #18

Earlier quoted context omitted.

A minor quibble, but in Python 3 you can print in a lambda because print is no longer a keyword.

As a non-Python 3 user, I just opened up the python 3 REPL to try something I always find myself wanting to do in tiny little python scripts: map(print, some_list) Unfortunately, it returned a map object, which I guess is also new in Python 3 (I assume it's a lazy application device).

You can (ab)use iterable unpacking in Py3k, now that print's a real function:

    print(*[1,2,3], sep='\n')

Re: Unpythonic Python

#28
post #25

Earlier quoted context omitted.

The reasoning behind using '\' for lambda in Haskell was because it sort of looks like a lambda character ( λ vs \ ) if you squint hard enough.

That's just horrible. I don't know what more to say about it than that. How did anyone think this would be a good idea on balance?

Mmm I suppose it's really just preference. I love that syntax. But I guess there's no arguing about taste.

Re: Unpythonic Python

#29
post #3

Playing code golf with Python, this is the shortest I could get: https://gist.github.com/tghw/3702360 Definitely a little unpythonic.

Something annoying about python is that the word "lambda" is so long for what are supposed to be one-off functions. You have f=lambda x,y=1,a='Fizz',b='Buzz': ... But it's actually shorter to say def f(x,y=1,a='Fizz',b='Buzz'): ... I much prefer Haskell's \x -> x Style lambdas.

So what's if it's shorter. You'll run out of screen? You'll wear down your keyboard?

If you don't like typing it, have a macro. Otherwise, as Objective C shows, the verbosity of code is not relevant at all. It's what it says and what it does, which is.

Re: Unpythonic Python

#30
post #18

Earlier quoted context omitted.

A minor quibble, but in Python 3 you can print in a lambda because print is no longer a keyword.

As a non-Python 3 user, I just opened up the python 3 REPL to try something I always find myself wanting to do in tiny little python scripts: map(print, some_list) Unfortunately, it returned a map object, which I guess is also new in Python 3 (I assume it's a lazy application device).

Use `list()` to force eager evaluation with Python 3 map / filter.
Post reply on HN