Re: Temporary variables in list comprehensions

2017-04-06 Thread Piet van Oostrum
Steven D'Aprano writes: > Suppose you have an expensive calculation that gets used two or more times in > a > loop. The obvious way to avoid calculating it twice in an ordinary loop is > with > a temporary variable: > > result = [] > for x in data: > tmp = expensive_calculation(x) > r

PYTHON

2017-04-06 Thread aldersilva676
Hello, how can I start programming? -- https://mail.python.org/mailman/listinfo/python-list

Re: PYTHON

2017-04-06 Thread Jan Erik Moström
On 6 Apr 2017, at 14:43, aldersilva...@gmail.com wrote: > Hello, how can I start programming? Let me google that for you => http://www.learnpython.org -- https://mail.python.org/mailman/listinfo/python-list

Re: Temporary variables in list comprehensions

2017-04-06 Thread Vincent Vande Vyvre
Le 06/04/17 à 14:25, Piet van Oostrum a écrit : Steven D'Aprano writes: Suppose you have an expensive calculation that gets used two or more times in a loop. The obvious way to avoid calculating it twice in an ordinary loop is with a temporary variable: result = [] for x in data: tmp = e

Re: Problem installing 3.6.1 AMD64

2017-04-06 Thread Colin J. Williams
Eryk, Many thanks. I wasn't aware of the Path Editor, Colin W. On 2017-04-05 7:55 PM, eryk sun wrote: On Wed, Apr 5, 2017 at 6:46 PM, Colin J. Williams [1] wrote: Successful install reported, but: Microsoft Windows [Version 10.0.14393] (c) 2016 Microsoft Corporat

Re: Temporary variables in list comprehensions

2017-04-06 Thread Jussi Piitulainen
Vincent Vande Vyvre writes: > Le 06/04/17 à 14:25, Piet van Oostrum a écrit : >> Steven D'Aprano writes: >> >>> Suppose you have an expensive calculation that gets used two or more >>> times in a loop. The obvious way to avoid calculating it twice in an >>> ordinary loop is with a temporary varia

Re: Quick questions about globals and database connections

2017-04-06 Thread Jussi Piitulainen
DFS writes: > On 4/5/2017 10:52 PM, Dan Sommers wrote: >> On Wed, 05 Apr 2017 22:00:46 -0400, DFS wrote: >> >>> I have a simple hard-coded check in place before even trying to connect: >>> >>> if dbtype not in ('sqlite postgres'): >>>print "db type must be sqlite or postgres" >>>exit() >>

Re: Quick questions about globals and database connections

2017-04-06 Thread Python
Le 06/04/2017 à 16:46, DFS a écrit : On 4/5/2017 10:52 PM, Dan Sommers wrote: On Wed, 05 Apr 2017 22:00:46 -0400, DFS wrote: I have a simple hard-coded check in place before even trying to connect: if dbtype not in ('sqlite postgres'): print "db type must be sqlite or postgres" exit()

Correction of announcement of Version 2 of a steganographical software of mine

2017-04-06 Thread Mok-Kong Shen
Due to a new convention of my Internet provider, my current home page is now: http://mokkong-shen.homepage.t-online.de M. K. Shen -- https://mail.python.org/mailman/listinfo/python-list

Re: Temporary variables in list comprehensions

2017-04-06 Thread Lele Gaifax
Piet van Oostrum writes: > It is a poor man's 'let'. It would be nice if python had a real 'let' > construction. Or for example: > > [(tmp, tmp + 1) for x in data with tmp = expensive_calculation(x)] > > Alas! It would be nice indeed! Or even [(tmp, tmp + 1) for x in data with expensive_c

Re: Temporary variables in list comprehensions

2017-04-06 Thread Tim Chase
On 2017-04-06 14:56, Vincent Vande Vyvre wrote: > With two passes > > e = [expensive_calculation(x) for x in data] > final = [(x, y+1) for x, y in zip(e, e)] Using a generator it can be done in one pass: final = [ (value, tmp, tmp+1) for value, tmp in ( (x, expensive_calculation(x

Re: Quick questions about globals and database connections

2017-04-06 Thread Jussi Piitulainen
DFS writes: > On 4/6/2017 10:54 AM, Python wrote: >> Le 06/04/2017 à 16:46, DFS a écrit : >>> On 4/5/2017 10:52 PM, Dan Sommers wrote: On Wed, 05 Apr 2017 22:00:46 -0400, DFS wrote: > I have a simple hard-coded check in place before even trying to > connect: > > if dbtyp