Live data from Hacker News

Why Python is Important for You

blaag.haard.se

201–210 of 231 posts

Re: Why Python is Important for You

#201
post #72

Earlier quoted context omitted.

You dodged the first two issues. Python 3 is causing serious pain, does django work with it yet? Second, who cares why JRuby is more mature, it is.

> You dodged the first two issues. No (and screw you for your unwarranted downvote you ass) > Python 3 is causing serious pain, does django work with it yet? I did not deny that, I denied your equation of Python 3 with Ruby 1.9 when they have absolutely nothing in common and had very different goals. > Second, who cares why JRuby is more mature, it is. That's not the issue with your question, the issue is that you ch…

It's ironic that you would point the finger at communities for not being mature.

Yours is by far the least pleasant and counterproductive thread on this entire discussion

Re: Why Python is Important for You

#202
post #133

Many years ago I've decided it was time to pick up a modern programming language. In the past I had written lots of (Turbo) Pascal code, some x86 (and more exotic) Assembler and a bit of C, but then for several years I only did shell/awk scripts and ported C software to IRIX and SINIX/RU. So I sat down and decided to find a nice general-purpose language that I would focus on learning. I wasn't quite sure what for yet…

You can write in Python for Android, in case you're considering changing your phone so you can write in Python for it:

http://google-opensource.blogspot.com/2009/06/introducing-an...

http://code.google.com/p/android-scripting/

https://github.com/kivy/python-for-android

Re: Why Python is Important for You

#203
post #11

As a commenter on the article wrote: what about Ruby? I say this as a happy Python user. Ruby seems very similar but I'm reminded of a pg essay on language power: looking up the power curve, you see '$Language plus a bit of weird stuff that is probably irrelevant.' So I don't trust myself. As someone who loves Python and doesn't know any Ruby beyond a few bits of syntax and the obvious bits that are common to most la…

Ruby/Rails seems to have a more developer-friendly approach to the web development stack than Python/Django. (I am but an egg, more comfortable in Python/Django but learning Ruby/Rails, I wouldn't argue with more experienced folks about any of the following.) Ruby/Rails seems easier to develop and test the full stack application, from client JavaScript to server Ruby response and back. It supports Ajax through inject…

RE: javascript injection, it's totally optional and in years of doing rails dev work I've never used it (I presume you're talking about the 'remote' option).

Actually, the vast majority of my rails stuff recently has been RESTish (or at least Backbone compatible) json endpoints with a CoffeeScript frontend.

The front and back end in that case are totally decoupled (though rails does do some nice things to help you organize your frontend code).

This would have been hard a few years ago but I've found that as time has wore on rails has become quite a bit more forgiving when you disagree with DHH, e.g.. you can use whatever templating language, testing framework or ORM you like, and there will be others who made the same choice you can look to for support. It's still opinionated about defaults, but you can switch out whatever libraries you like these days, for the most part.

Re: Why Python is Important for You

#204
post #80

Earlier quoted context omitted.

Agreed that they can be tricky initially and hard to debug, but I think they're totally worth it for eliminating repetitive code. And IMO as long as there isn't a bug in the decorator itself, code with decorators can be just as readable (if not more so) to someone else (e.g. decorating your functions with @authenticated instead of if self.user.is_authenticated: # blah, blah blah)

if Python had better function syntax and anonynous functions, decorators wouldn't even be a 'thing'

> if Python had better function syntax and anonynous functions, decorators wouldn't even be a 'thing'

Better function syntax? What's wrong with python's function syntax and how does it relate to decorators?

Python does have anonymous functions, though they are limited: You can have only 1 expression, you can't have statements, and you can't have local variables. The reasoning is lambdas should be used for small operations; for everything else, named functions should be used.

The reasoning behind lambdas is arguable, but it still doesn't explain how it affects decorators.

Consider:

    def memoize(fn):
        from functools import wraps
        @wraps(fn)
        def memoized_fn(*args):
            if not memoized_fn.cache.has_key(args):
                memoized_fn.cache[args] = fn(*args)
            return memoized_fn.cache[args]
        memoized_fn.cache = {}
        return memoized_fn

    @memoize
    def fib(n):
        if n 
What would a better function syntax and anonymous functions do so that memoize decorator won't be a thing?

Re: Why Python is Important for You

#205

Earlier quoted context omitted.

> -lambdas can thus contain any expression why would you want to use lambdas if you have generator expressions? eg: map(lambda c: c.strip(), countries.split(',')) vs [c.strip() for c in countries.split(',')] IMHO the latter one is way more readable and generators cover almost all the use cases for lambdas. If you could not do it with a generator expression and choose to use a anonymous function it should have been a…

Thanks for mentioning sets - this is another thing that I would like to be built-in in Ruby. But "list(set(mylist))" seems like kind of a hack. > you can import the rational class via a simple from fractions import Fraction Sure, you can write a library for anything and by now Python has libraries for most everything. But it still makes a difference to have things in the core language, plus a nice syntax for them. >…

Ruby does have sets:

    require 'set'
    Set.new([1,2,3])

Re: Why Python is Important for You

#206
post #204

Earlier quoted context omitted.

if Python had better function syntax and anonynous functions, decorators wouldn't even be a 'thing'

> if Python had better function syntax and anonynous functions, decorators wouldn't even be a 'thing' Better function syntax? What's wrong with python's function syntax and how does it relate to decorators? Python does have anonymous functions, though they are limited: You can have only 1 expression, you can't have statements, and you can't have local variables. The reasoning is lambdas should be used for small opera…

Less restricted anonymous functions would allow stuff like this:

    fib=memoize(function...)
So the @ shortcut for:

    def fib():
        ...
    fib=memoize(fib)
wouldn't be necessary to 'clean up' the decoration of the function.

Re: Why Python is Important for You

#207

When I was at Google there was a paper titled "Please don't use Python for large programs." Can someone post that? It would be an interesting counterpoint.

What language do they recommend for large programs?

don't know for sure, it might be C++, Java, and now they have Go.

Re: Why Python is Important for You

#208
post #204

Earlier quoted context omitted.

> if Python had better function syntax and anonynous functions, decorators wouldn't even be a 'thing' Better function syntax? What's wrong with python's function syntax and how does it relate to decorators? Python does have anonymous functions, though they are limited: You can have only 1 expression, you can't have statements, and you can't have local variables. The reasoning is lambdas should be used for small opera…

Less restricted anonymous functions would allow stuff like this: fib=memoize(function...) So the @ shortcut for: def fib(): ... fib=memoize(fib) wouldn't be necessary to 'clean up' the decoration of the function.

Even if it were possible, I would stick with

    @memoize
    def fib:
        pass
fib = memoize(function ...) has unnecessary nesting, and @memoize is cleaner IMO.

I am curious - do you find @memoize confusing? Personally for me and anyone I have talked to, @memoize is vanilla - the confusing part is the decorator itself, especially one that takes arguments; that coupled with the fact that classes(which override __call__) and functions are both used as decorators.

Re: Why Python is Important for You

#209
post #208

Earlier quoted context omitted.

Less restricted anonymous functions would allow stuff like this: fib=memoize(function...) So the @ shortcut for: def fib(): ... fib=memoize(fib) wouldn't be necessary to 'clean up' the decoration of the function.

Even if it were possible, I would stick with @memoize def fib: pass fib = memoize(function ...) has unnecessary nesting, and @memoize is cleaner IMO. I am curious - do you find @memoize confusing? Personally for me and anyone I have talked to, @memoize is vanilla - the confusing part is the decorator itself, especially one that takes arguments; that coupled with the fact that classes(which override __call__) and func…

No, I don't find it confusing. But I read craigyk as mostly talking about the special decorator syntax, not function decoration in general.

Re: Why Python is Important for You

#210

Earlier quoted context omitted.

Syntactically, JS is funny in a lot of ways. I highly encourage you to investigate CoffeeScript.

As someone with lots of Python experience, having used CoffeeScript/JS for ~three months makes Python looks somewhat old fashioned when I switch back. If Coffee/JS had some way of overloading array access operations, and maybe a numpy equivalent, I don't think I would have any reason to go back to Python. It's also just so much faster than CPython...

I actually quite like Javascript, especially for its speed. However, the major obstacle to me is that JS is locked in web development. It even does not have a standardized module to read files line by line, let alone other system-level stuffs. One of the (small) reasons that python is not used in web browsers is the lack of speed.
Post reply on HN