11 Replies - 4165 Views - Last Post: 23 June 2012 - 07:56 PM Rate Topic: -----

#1 atraub  Icon User is offline

  • Pythoneer
  • member icon

Reputation: 756
  • View blog
  • Posts: 1,990
  • Joined: 23-December 08

What's Missing From Python?

Post icon  Posted 02 July 2011 - 11:55 AM

*
POPULAR

We all know that Python is a glorious language that has made life worth living... but I suppose it's still not perfect. So here's my question: What's Python missing? I don't care if you have a gripe about performance, I'm talking about missing features.

To give you an example:
I personally would love to see something similar to C++ enumerators in Python.
Is This A Good Question/Topic? 5
  • +

Replies To: What's Missing From Python?

#2 Nallo  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 161
  • View blog
  • Posts: 247
  • Joined: 19-July 09

Re: What's Missing From Python?

Posted 02 July 2011 - 01:24 PM

I would love to see a natural way to monads in python :bananaman:

Just kidding. A while ago I read a blog from someone that claimed that monads were the natural choice for his problem ... and he went on to implement them in python. Did neither understand nor bookmark it though :o

No really the point is, what does python need without becoming a bloated language that takes in every silly idea like php.

I can't think of one ;)
Was This Post Helpful? 0
  • +
  • -

#3 Raynes  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 610
  • View blog
  • Posts: 2,815
  • Joined: 05-January 09

Re: What's Missing From Python?

Posted 02 July 2011 - 01:36 PM

TCO would be nice.
Was This Post Helpful? 0
  • +
  • -

#4 MATTtheSEAHAWK  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 137
  • View blog
  • Posts: 782
  • Joined: 11-September 10

Re: What's Missing From Python?

Posted 02 July 2011 - 04:11 PM

importing anti-gravity does not work.

Sorry had to say it.

But seriously I wish...

This post has been edited by MATTtheSEAHAWK: 02 July 2011 - 04:13 PM

Was This Post Helpful? 1
  • +
  • -

#5 kiwi_steve  Icon User is offline

  • D.I.C Head

Reputation: 31
  • View blog
  • Posts: 109
  • Joined: 26-September 09

Re: What's Missing From Python?

Posted 03 July 2011 - 01:59 AM

++ and --

Drives me nuts every time I have to go += 1 just to increment something.

And an old-school ternary operator (?) I know there is a Pythonic way to do it, but it doesn't work for me or my brain. I like the if (test_something)? true_do_this:false_do_this

I almost added that I'd love to see semicolons and squiggly braces too... but then I realised I was asking for Java so I'll wash my mouth out instead :tooth:

Nah, everything else I am pretty happy with :sigh:
Was This Post Helpful? 3
  • +
  • -

#6 atraub  Icon User is offline

  • Pythoneer
  • member icon

Reputation: 756
  • View blog
  • Posts: 1,990
  • Joined: 23-December 08

Re: What's Missing From Python?

Posted 03 July 2011 - 05:54 AM

Good call on the ++! I'd love to see that too!
Was This Post Helpful? 0
  • +
  • -

#7 Nallo  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 161
  • View blog
  • Posts: 247
  • Joined: 19-July 09

Re: What's Missing From Python?

Posted 03 July 2011 - 08:26 AM

kiwi_steve said:

And an old-school ternary operator (?) I know there is a Pythonic way to do it, but it doesn't work for me or my brain. I like the if (test_something)? true_do_this:false_do_this

You probably thought about that infamous and or construct that is unreadable. But since Python 2.5 there is a ternary operator.
result = expression_on_true if condition else expression_on_false


It only allows expressions not statements though.

>>> a = 5
>>> "a is positve" if a >= 0 else "a is negative"
'a is positive'


This post has been edited by Nallo: 03 July 2011 - 08:28 AM

Was This Post Helpful? 0
  • +
  • -

#8 atraub  Icon User is offline

  • Pythoneer
  • member icon

Reputation: 756
  • View blog
  • Posts: 1,990
  • Joined: 23-December 08

Re: What's Missing From Python?

Posted 03 July 2011 - 11:11 AM

That's true Nallo, but it's not a true ternary operator. It's overloading the if else keywords.

This post has been edited by atraub: 03 July 2011 - 11:14 AM

Was This Post Helpful? 0
  • +
  • -

#9 kiwi_steve  Icon User is offline

  • D.I.C Head

Reputation: 31
  • View blog
  • Posts: 109
  • Joined: 26-September 09

Re: What's Missing From Python?

Posted 03 July 2011 - 05:14 PM

View PostNallo, on 04 July 2011 - 04:26 AM, said:

kiwi_steve said:

And an old-school ternary operator (?) I know there is a Pythonic way to do it, but it doesn't work for me or my brain. I like the if (test_something)? true_do_this:false_do_this

You probably thought about that infamous and or construct that is unreadable. But since Python 2.5 there is a ternary operator.
result = expression_on_true if condition else expression_on_false


It only allows expressions not statements though.


Nope, thats the one I was thinking of... :) I can never remember it when I need it...

Sometimes I think things get done differently in Python just so it can be called 'Pythonic'... and despite the fact I like the language overall, sometimes Pythonic is just Pythetic...
Was This Post Helpful? 0
  • +
  • -

#10 atraub  Icon User is offline

  • Pythoneer
  • member icon

Reputation: 756
  • View blog
  • Posts: 1,990
  • Joined: 23-December 08

Re: What's Missing From Python?

Posted 23 June 2012 - 12:32 PM

I have no deep love for vb, but they do have a nice feature with conditionals that I always liked. There's a cool keyword called "also" that allows you write a statement where anything after the also only gets interpreted if the stuff before it results in True. With that, you could write something like this if len(myList) == 1 and also myList[0] == "blah blah blah":. Normally, if the list were empty, a line like this if len(myList) == 1 and myList[0] == "blah blah blah": would cause an error because you can't get the value at index 0 of an empty list, but in vb, the second condition would only be interpreted if the first one was true.

It's a small feature, but I think it would be nice to have.

This post has been edited by atraub: 23 June 2012 - 08:05 PM

Was This Post Helpful? 0
  • +
  • -

#11 sepp2k  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2009
  • View blog
  • Posts: 3,032
  • Joined: 21-June 11

Re: What's Missing From Python?

Posted 23 June 2012 - 07:45 PM

That behavior is called short circuiting and it's how and/&& and or/|| behave in most languages - including Python.

So len(myList) == 1 and myList[0] == "blah blah blah" will not cause an error in Python if myList is empty.

This post has been edited by sepp2k: 23 June 2012 - 07:57 PM

Was This Post Helpful? 1
  • +
  • -

#12 atraub  Icon User is offline

  • Pythoneer
  • member icon

Reputation: 756
  • View blog
  • Posts: 1,990
  • Joined: 23-December 08

Re: What's Missing From Python?

Posted 23 June 2012 - 07:56 PM

Wow, I stand 100% corrected! I wonder why I thought otherwise?

EDIT:
Also, I guess that means Python is even greater than I realized! wah-hah!

This post has been edited by atraub: 23 June 2012 - 07:57 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1