views:

156

answers:

3

Python is a great programming language, but certain things about it just annoy the heck out of me.

As such, I:

1) wanted to find out how to remove these annoyances from the language itself, or

2) find a language that is Python-like that don't have these annoyances.


I love Python for everything except:

  • self: just seems stupid to me that I need to include "self" as the first parameter of a function
  • double-underscores: It just looks ugly and a terrible special character.
  • _name_ has always felt like a hack to me. Try explaining it to a novice programmer, or worse to someone who programs in perl or ruby or java for a living. Comparing the magic variable name to the magic constant ”main” feels doubly so
  • Blocks give me of ruby envy or smalltalk envy. I like local functions. Love them. I tolerate lambda. But I really, really would like to see a more rubyesque iterator setup where we pass a callable to the list, and the callable can be defined free-form inline. Python doesn’t really do that and so it’s less of a language lab than I might like.
  • Properties are unattractive, partly because of blocks being absent. I don’t really want to define a named parameter (with double-underscores, most likely) and then two named functions, and THEN declare a property. That seems like so much work for such a simple situation. It is something I will only do if all other methods fail me, or if all other methods are overriding setattr and getattr.

I do realize this might be petty annoyances, but for a language I program in daily, these small annoyances can grow to be quite large.

A: 

How about trying back to the basics using UNIX bash scripts?

JavaNoob
+2  A: 

This is a troll, and you know the answers to your own questions:

self: Write a wrapper that does away with it and inherit from that. But it does need some name if you're going to reference the object in question, unless you just want it to just magically be present (an ugly thing indeed)...

double-underscores: don't use them. Simple. They're in no way required.

_name_: again, call it something else if you like, and inherit from that base class. I don't see what the problem here is. You still need something to provide that function.

Blocks: It sounds to me like you're trying to program ruby or java in python. You can certainly pass a callable to an iterator (and you should probably go read about generators), but defining it inline leads to serious code ugliness fast. Python makes you do it out of line so that you don't end up with half your program logic in an inline, unnamed function. I don't see what the problem here is.

Properties: I don't understand what you're saying. I certainly don't define multiple functions to use or create properties of an object in most cases.

Paul McMillan
Not trolling. To respond to your post 1) as you mentioned, writing a wrapper for self doesn't really solve the problem, 2) double-underscores, this is "pythonic" to use, 3) __name__, this is also "pythonic" to use
TeddyB
@TeddyB: So most of your problems aren't Python, they're to do with existing "conventions". Just remember that conventions are just that - you can ignore them if you really want to. Of course, people you have to work with might not like you if you deliberately flout them.
Anon.
+6  A: 

pypy is a complete implementation of Python in Python itself (with all of the things you consider annoyances, nevertheless a very high-level implementation language that makes altering even the core of the language itself for your own purposes easier than ever before). Download it, fork it, and edit it to fix whatever you like (be sure to eventually translate the compiler and runtime to your new non-Python language, too, of course).

If that's just too much work (whiners are rarely interested in working to fix their own complaints, no matter how easy you make such work for them), just switch to Ruby, which appears to match your tastes more closely - or find the Ruby implementation written in Ruby (I don't know how it's called, but surely such a powerful language will have one) and hack that one (to fix whatever your whines are against Ruby).

Meanwhile, at least some of your annoyances leave me quite perplexed. Take, for example, the rant about properties: I don't understand what you mean. The normal way to define a R/W property is:

@property
def thename(self):
    """add the geting-code here""

@property.set
def thename(self, value):
    """add the seting-code here""

so what the hey do you mean by

define a named parameter (with double-underscores, most likely) and then two named functions, and THEN declare a property

???

I could ask equally puzzled questions about the other whines, but let's wait to see if you clarify this one first (if the clarification is of the kind "oh I didn't know about it", i.e. you're whining against a language without knowing the fundaments thereof, well, I can make a guess about what that does to your credibility, of course;-).

Alex Martelli