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…
Why Python is Important for You
111–120 of 231 posts
Re: Why Python is Important for You
#112I 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.
Re: Why Python is Important for You
#113Earlier 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]
Re: Why Python is Important for You
#114I 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…
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
#115Earlier 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.
Re: Why Python is Important for You
#116My 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…
Re: Why Python is Important for You
#117I 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.
Re: Why Python is Important for You
#118I 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…
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
#119Earlier 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…
Re: Why Python is Important for You
#120I 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…
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.