News for hackers. Stuff that matters.
Re:Unfortunate Python by LeafStorm on Monday December 19, 2011 @06:00PM (#3371484)
Most of this I agree with, with a few comments/caveats:

> Easy Stuff First

The unfortunate part about this particular example is that subprocess's interface isn't really that well-designed, and so people resort to os.system simply because it is less complicated than subprocess.

> Ducks In A Row

I don't think isinstance is really that bad, but checking based on something's exact type is definitely wrong.

> Toys are for Children

One of the problems of a batteries-included stdlib is that you have to support it just about forever. Though I would like to note that for basic async programming Tornado is surprisingly good, and less complex than Twisted.

> Foreign Concepts

Apparently this is especially useful for scientific and mathematical computing. I can't see how it's especially dangerous since just about everyone will use list instead.

Re:Unfortunate Python by icebraining on Monday December 19, 2011 @06:07PM (#3371505)
I disagree that subprocess is complicated. Replacing the os.system() is really simple: http://docs.python.org/library/subprocess.html#replacing-os-...

I think people are just used to system(), particularly if they come from C.

Re:Unfortunate Python by zapman449 on Monday December 19, 2011 @06:27PM (#3371561)
I do really miss the 'command' module's convienience... so much that I often code my own version using subprocess, just so I can get at Std-out, Std-Err, and the return code all in one place.
Re:Unfortunate Python by rat87 on Tuesday December 20, 2011 @02:54AM (#3372688)
I think people might be complaining about how hard it is to do the equivalent of procs = `ps -ef` in ruby, not to mention crazy ways you can combine it with string interpolation.
Re:Unfortunate Python by nknight on Monday December 19, 2011 @11:49PM (#3372343)
One loads the subprocess documentation and is confronted by a (on my monitor/fonts) ~11 page morass.

The little part you link to starts off simple, sure, but then says "Calling the program through the shell is usually not required.", and proceeds to present a "more realistic example", leading to an immediate "WTF?" for anyone just learning of subprocess.

People who have been doing things the obvious way for years will not take well to a new mechanism that they don't understand the function nor implications of, and whose use is immediately discouraged by its own documentation.

Re:Unfortunate Python by icebraining on Tuesday December 20, 2011 @07:42AM (#3373213)
How is that a WTF? It's exactly the same code you could/should use with os.system()! And besides, it's completely straightforward Python.
Re:Unfortunate Python by nknight on Tuesday December 20, 2011 @08:05AM (#3373267)
You're talking about what you think programmers should do. I'm talking about what they actually do.

99% of system() calls (regardless of language) will never be so adorned. It's used for quick hacks, rarely anything more. If the return code is checked at all, people only pay attention to whether it's something other than 0.

Re:Unfortunate Python by angusgr on Monday December 19, 2011 @06:19PM (#3371539)
> Foreign Concepts ... I can't see how it's especially dangerous since just about everyone will use list instead.

I think it's potentially dangerous if/when Python newbies from other languages pick up old idioms and (ab)use them thinking they're "Pythonic".

I haven't seen it with a Python codebase, but I have worked on a Java codebase that was developed from scratch by C developers new to Java. They used lots of arrays (same sin), minimal Collections, and lots of for(i = 0; i < arr.length; i++) instead of foreach. Urgh.

So it isn't Python's fault, but I see how it could pose a danger.

Re:Unfortunate Python by _delirium on Monday December 19, 2011 @07:33PM (#3371750)
Some of that latter part could just be older Java code; foreach wasn't introduced until Java had been out for 8 years already (2004). I'm under 30 and some of my older Java code uses that style of loop, because it was written in 2002-03 before foreach was available.
Re:Unfortunate Python by angusgr on Monday December 19, 2011 @09:45PM (#3372084)
Not this time, this project was written from scratch in Java 6. :)

It's possible they learned Java at some earlier point in their lives, but my understanding was the team came from embedded/systems C backgrounds and I think they just did what felt right.

Re:Unfortunate Python by tocomment on Tuesday December 20, 2011 @07:40AM (#3373207)
I completely agree about subprocess. One thing I like about Perl is that it's dead easy to make a system call. I wish subprocess had a shortcut that's easy to remember/use.
Re:Unfortunate Python by icebraining on Tuesday December 20, 2011 @07:45AM (#3373219)

    run = lambda cmd: subprocess.check_output(cmd, shell=True)

    data = run("ps -e")
Re:Unfortunate Python by lloeki on Tuesday December 20, 2011 @08:07AM (#3373273)
I do something which looks largely the same, except I call it backtick
Re:Unfortunate Python by chimeracoder on Monday December 19, 2011 @08:14PM (#3371872)
> Apparently this is especially useful for scientific and mathematical computing. I can't see how it's especially dangerous since just about everyone will use list instead.

Actually, I use Python for mathematical computing, and I've never used Python's built-in arrays. NumPy arrays are much more convenient, and NumPy is written in C, so it's way faster than using a list.

It's a win-win: the speed of C, combined with the flexibility and syntax of Python.

The only reason array really exists in Python (this implementation, that is), is to support some other libraries that need O(1) indexing but don't want to depend on NumPy. For everything else, you should really just use NumPy.

Re:Unfortunate Python by kzrdude on Tuesday December 20, 2011 @06:15AM (#3373003)
Not a surprise. Python's `array` doesn't really do much, it just allows you to store and access homogenous data without wasting memory. That's all. It doesn't really deserve to be on this list.