From: Steven D'Aprano on
On Mon, 14 Jun 2010 12:24:59 +1000, Ben Finney wrote:

> With 'reduce' gone in Python 3 [0]
....
> [0] <URL:http://docs.python.org/py3k/library/functions.html>


It's not gone, it's just resting.

http://docs.python.org/py3k/library/functools.html#functools.reduce


--
Steven
From: Mark Leander on
(pytyhon 2.x code):
print input('Enter expression: ')



Example uses:
Enter expression: 3+4
7
Enter expression: 1+2+3+4+5
15
Enter expression: 7*18
126
Enter expression: 2**19-1
524287

From: cristeto1981 on



alex23 wrote:
>
> exar...(a)twistedmatrix.com wrote:
>> Fore!
>>
>>     print(sum(map(int, input('enter two numbers: ').split())))
>
> Well, I _was_ trying to stick to Steven's more simple map-less form :)
>
> (Although I have to say, I have little sympathy for Steven's
> hypothetical "new programmer who isn't familiar with map and reduce".
> Python isn't PHP, its built-ins are nowhere near as exhaustive,
> something like 80ish vs 2000+ functions? Not exactly a huge lookup
> burden.)
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>
Whoa. This forum is kinda confusing. Where do i ask questions about phytons?
Great threab by the way. :)

-----
[url=http://crosspromotion.wizard4u.com/]joint ventures[/url]

--
View this message in context: http://old.nabble.com/a-%2Bb---tp28855796p28878155.html
Sent from the Python - python-list mailing list archive at Nabble.com.

From: Mark Dickinson on
On Jun 13, 5:46 pm, exar...(a)twistedmatrix.com wrote:
> On 04:25 pm, wuwe...(a)gmail.com wrote:
>
>
>
> >Steven D'Aprano <st...(a)REMOVE-THIS-cybersource.com.au> wrote:
> >>No, I think your code is very simple. You can save a few lines by
> >>writing
> >>it like this:
>
> >>s = input('enter two numbers: ')
> >>t = s.split()
> >>print(int(t[0]) + int(t[1]))  # no need for temporary variables a and
> >>b
>
> >Not that we're playing a round of code golf here, but this is a
> >slightly nicer take on your version:
>
> >one, two = input('enter two numbers: ').split()
> >print(int(one) + int(two))
>
> >I like names over subscripts, but that's just me :)
>
> Fore!
>
>     print(sum(map(int, input('enter two numbers: ').split())))
>
> Jean-Paul

58 characters. You could remove the space after 'int' to make it 57.
Here's an evil 56-character version...

print(eval(input('enter two numbers: ').replace(*' +')))

--
Mark
From: Ian on
On 14/06/2010 02:35, alex23 wrote:
> Python isn't PHP, its built-ins are nowhere near as exhaustive,
> something like 80ish vs 2000+ functions? Not exactly a huge lookup
> burden.
>
The problem is not learning Python, its learning about the standard
libraries that Python gives you access to!

..NET from Iron Python anyone?

Regards

Ian