Live data from Hacker News

Why Python is Important for You

blaag.haard.se

111–120 of 231 posts

Re: Why Python is Important for You

#111
post #62

Earlier quoted context omitted.

On most projects I have seen where python was seen as problematic, I think that having types ala C++/Java would not have improved much. The real problem is that the function is not documented, nor is the function expectations. Typing in C++/java does not replace that (more advanced typing systems do much better, though). Package management and generally deployment is certainly a pain in python. I think it is one of t…

In most C++/Java code, the function is not documented either. The nice thing about manifest types is that the source code becomes the documentation (shitty documentation, yes, but usually good enough that you can figure out how to use it by looking at the source). Type inference with a doc generator would work too, as long as you run the doc generator regularly and everybody knows where to find the docs. History has…

[deleted]

Re: Why Python is Important for You

#112
post #12

I like Python the language, but the standard library can often annoy me as there is no unified style. thereAreMethodsLikeThis or_there_are_methods_like_this orevenworsefullylowercase. Gah.

Thats a thing where the standardization came after those libraries. It doesn't get to me that much, but I have a coworker it does bother a fair bit. I poke fun at him for this, but what he does is just take 15 minutes and write a "proxy" module (I think he was actually able to automate it...). If `baz.fooBar` is bugging him, he'll just create a `mybaz` module where mybaz.foo_bar either calls or is just a new name for baz.fooBar and then he just does an `import mybaz as baz`.

Re: Why Python is Important for You

#113
post #87

Earlier quoted context omitted.

In my opinion Ruby has a slightly more obscure syntax with custom symbols, and it's C API is not as clean and well put together as Python's.

Which is more obscure? Reverse a string in ruby: string.reverse() Reverse a string in python: string[::-1]

What an odd example. Other than perhaps a palindrome detector, I'm having a really hard time coming up with a use for a reversed-strings. Python DOES provide a reverse for arrays.

Re: Why Python is Important for You

#114
post #10
post #4

I work with python daily. I find that when I first started I avoid a lot of the "fancy" constructs such as list comprehensions, dynamic arguments, and decorators as well as meta programming. The great thing is the bar to being effective in the language is so low. You can pretty much pick up most python code and just read it and get a general feel for what it does. Not only that but it is much easier to read because o…

I find a great way to avoid deep nesting is to move code to functions, and bail out when some conditions are not met. As an example, this deeply nested code: def frob(someargs): if something > 2: ... # do some processing if that == "CONNECT": ... # some more processing if verdict in blessedsolutions: ... # even more processing print "Happy birthday!" I tend to write like this: def frob(someargs): if something I do th…

You should try inverting that code with guard statements:

    def frob(someargs):
        if something 
Code Complete 2 suggests this for many types of logic when overly deep nesting bites you.

Re: Why Python is Important for You

#115
post #82

Earlier quoted context omitted.

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

I didn't down vote you, it seems HN doesn't allow me to down vote on threads I'm participating in. If it did, I'd down vote your last comment. I think the JVM is the more significant platform compared to the clr and rubinius/pypy. Therefore I think it's maturity is more significant.

The PyPy team is amazing, for example Quora is now running on PyPy. and it's easy for a Python programmer run PyPy as an alternative(and hopefully fast) implementation.

Re: Why Python is Important for You

#116

My biggest problem with Python is that projects larger than a given size tend to become unmaintainable rather quickly. This is in large part because of the lack of strong typing and type annotations; if you aren't the only author or can't keep the codebase in your head, it takes real effort to figure out what a function does. Even the type annotations provided in a language like Java or C++ make this task much easier…

An alternative viewpoint is that Python makes it so you GET to that point a lot quicker, since your iterative development cycle is so much faster, No compiles, no need to refactor a bunch of stuff to accommodate minor data structure changes...

Re: Why Python is Important for You

#117
post #12

I like Python the language, but the standard library can often annoy me as there is no unified style. thereAreMethodsLikeThis or_there_are_methods_like_this orevenworsefullylowercase. Gah.

My biggest gripe too. Hopefully stdlib got more love lately on Python 3.

Re: Why Python is Important for You

#118

I have a list I wrote up once about Python's problems. Some of these are more exotic than others. Most of them are kludgearoundable. A couple are fixed in Python 3. Some are simply design choices that are exactly different from my mental model of the world, and due to the TOOWTDI Python world, it is frustrating to work with them. Some Things Wrong With Python * Immutable strings[0] * Everything a reference[1] * Envir…

You forgot mutable default arguments!

    def fn(ls=[]):
      ls += [1]
      return len(ls)
(My syntax might be a little off, but you get the idea.)

This will return an ever-increasing number if called repeatedly with no arguments.

Also, the reliance on tuples, particularly tuples of one item always gets me because (1) and (1,) are different.

Also, the scoping for list comprehensions doesn't make sense:

    x = 11
    [x for x in [1,2,3]]
    print x # 3!
This has also gotten me in the past.

Re: Why Python is Important for You

#119

Earlier quoted context omitted.

+1 on the static type checking problem.. i am beginning to feel very annoyed by the same... have found that writing and maintaining unit test cases help.. but are a PITA nevertheless...

Well, as I see it, more or less every error should be expressible as a type error. In order to actually do that, you’d need full dependent types, and that’s a huge language-design “now you have two problems” feature—compiler authors are understandably uncomfortable with undecidable, non-inferable type systems. Anyway, Haskell and even C++ used intelligently can tell you a lot about your program at the outset, so ulti…

> more or less every error should be expressible as a type error. Am not sure i agree.. i would like to believe it's true though.... >Haskell have just begun to poke around, like the currying + function composition.. will keep poking...

Re: Why Python is Important for You

#120
post #4

I work with python daily. I find that when I first started I avoid a lot of the "fancy" constructs such as list comprehensions, dynamic arguments, and decorators as well as meta programming. The great thing is the bar to being effective in the language is so low. You can pretty much pick up most python code and just read it and get a general feel for what it does. Not only that but it is much easier to read because o…

Deeply nested code is usually a symptom of not thinking the problem in advance and solving it with data structures, instead relying on ad-hoc conditionals to solve it.

When I find myself testing against too many conditions, I usually refactor code to use a map between values and behaviour (e.g., a dict mapping regexs to function objects). This way you remove business logic from code, and are free to make it more algorithmic, like a simple mapping problem.

Post reply on HN