Re: anonymous assignment

2008-05-13 Thread Mark Wooding
Ben Finney <[EMAIL PROTECTED]> wrote: > Paul Rubin writes: >> You can just use a variable name than you ignore. It's traditional >> to use _ but it's not a special keyword, it's just a another >> variable name: >> >>y, _, d, _, _, _, _, _, _ = time.localtime() > > It

Re: anonymous assignment

2008-05-13 Thread Gabriel Genellina
En Tue, 13 May 2008 00:21:06 -0300, Yves Dorfsman <[EMAIL PROTECTED]> escribió: Ben Finney wrote: y, _, d, _, _, _, _, _, _ = time.localtime() But you still have have a variable that's using memory for nothing. No, you have one extra unused name binding. The values that you don't want

Re: anonymous assignment

2008-05-13 Thread Bruno Desthuilliers
Yves Dorfsman a écrit : Marc 'BlackJack' Rintsch wrote: y, _, d, _, _, _, _, _, _ = time.localtime() But you still have have a variable that's using memory for nothing. I'm afraid you just don't understand what Python's "variable" are. You're really worrying about a non-issue here. Seriou

Re: anonymous assignment

2008-05-13 Thread Marc 'BlackJack' Rintsch
On Tue, 13 May 2008 03:25:51 +, Yves Dorfsman wrote: > Marc 'BlackJack' Rintsch wrote: y, _, d, _, _, _, _, _, _ = time.localtime() >>> But you still have have a variable that's using memory for nothing. I >>> find this unsatisfactory... >> >> Get over it… > > Than what's the point o

Re: anonymous assignment

2008-05-13 Thread Terry Reedy
"Arnaud Delobelle" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | "Terry Reedy" <[EMAIL PROTECTED]> writes: | | > "Arnaud Delobelle" <[EMAIL PROTECTED]> wrote in message | > news:[EMAIL PROTECTED] | > | > here is a very sophisticated implementation :) | > | def extract(indice

Re: anonymous assignment

2008-05-12 Thread Arnaud Delobelle
"Terry Reedy" <[EMAIL PROTECTED]> writes: > "Arnaud Delobelle" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > here is a very sophisticated implementation :) > def extract(indices, seq): > ... return tuple(seq[i] for i in indices) > ... y, d = extract((0, 2), time.

Re: anonymous assignment

2008-05-12 Thread Kam-Hung Soh
On Tue, 13 May 2008 13:23:30 +1000, Yves Dorfsman <[EMAIL PROTECTED]> wrote: Scott David Daniels wrote: Yves Dorfsman wrote: ... Sorry this was a typo (again :-), I meant: d = time.local() y = d[0] d = d[2] Then: y, d = list(time.localtime())[:4:2] What is this ? Could you point me

Re: anonymous assignment

2008-05-12 Thread Yves Dorfsman
Marc 'BlackJack' Rintsch wrote: y, _, d, _, _, _, _, _, _ = time.localtime() But you still have have a variable that's using memory for nothing. I find this unsatisfactory... Get over it… Than what's the point of wanting a better language if every time we run in something that looks wron

Re: anonymous assignment

2008-05-12 Thread Yves Dorfsman
Scott David Daniels wrote: Yves Dorfsman wrote: ... Sorry this was a typo (again :-), I meant: d = time.local() y = d[0] d = d[2] Then: y, d = list(time.localtime())[:4:2] What is this ? Could you point me to a document on this syntax ? I've tried it, it works, but I don't understan

Re: anonymous assignment

2008-05-12 Thread Yves Dorfsman
Ben Finney wrote: y, _, d, _, _, _, _, _, _ = time.localtime() But you still have have a variable that's using memory for nothing. No, you have one extra unused name binding. The values that you don't want to use have *already* been allocated by the time the above statement is executed. Na

Re: anonymous assignment

2008-05-12 Thread Yves Dorfsman
Gabriel Genellina wrote: Uses Python 2.6! ;) No need of 2.6 - the above code works since Python 2.2 at least: Python 2.2.3 (#42, May 30 2003, 18:12:08) [MSC 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. import time t=time.localtime() type(t)

Re: anonymous assignment

2008-05-12 Thread Scott David Daniels
Yves Dorfsman wrote: ... Sorry this was a typo (again :-), I meant: d = time.local() y = d[0] d = d[2] Then: y, d = list(time.localtime())[:4:2] --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: anonymous assignment

2008-05-12 Thread Terry Reedy
"Arnaud Delobelle" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] here is a very sophisticated implementation :) >>> def extract(indices, seq): ... return tuple(seq[i] for i in indices) ... >>> y, d = extract((0, 2), time.localtime()) >>> y, d (2008, 12) === Or

Re: anonymous assignment

2008-05-12 Thread Richard G Riley
Yves Dorfsman <[EMAIL PROTECTED]> writes: > D'Arcy J.M. Cain wrote: >> On Mon, 12 May 2008 02:28:13 GMT >> Yves Dorfsman <[EMAIL PROTECTED]> wrote: >>> particular case, there's got to be a better way than: >>> >>> d = time.local() >>> y = d[0] >>> d = d[1] >> >> Like this? >> >> y, d = time.lo

Re: anonymous assignment

2008-05-12 Thread Gabriel Genellina
En Mon, 12 May 2008 06:45:40 -0300, Michele Simionato <[EMAIL PROTECTED]> escribió: > On May 12, 4:28 am, Yves Dorfsman <[EMAIL PROTECTED]> wrote: >> there's got to be a better way than: >> >> d = time.local() >> y = d[0] >> d = d[1] > > Uses Python 2.6! ;) > > Python 2.6a3 (r26a3:62861, May 12 20

Re: anonymous assignment

2008-05-12 Thread Michele Simionato
On May 12, 4:28 am, Yves Dorfsman <[EMAIL PROTECTED]> wrote: >there's got to be a better way than: > > d = time.local() > y = d[0] > d = d[1] Uses Python 2.6! ;) Python 2.6a3 (r26a3:62861, May 12 2008, 11:41:56) [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2 Type "help", "copyright", "credits" or

Re: anonymous assignment

2008-05-12 Thread Arnaud Delobelle
On May 12, 7:31 am, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > Yves Dorfsman <[EMAIL PROTECTED]> writes: > > Is there anyway to tell python I don't care about a value ? > > > Say I want today's year and day, I'd like to do something like: > > > import time > > y, None, d, None, None, None, None

Re: anonymous assignment

2008-05-11 Thread Arnaud Delobelle
Yves Dorfsman <[EMAIL PROTECTED]> writes: > Is there anyway to tell python I don't care about a value ? > > Say I want today's year and day, I'd like to do something like: > > import time > y, None, d, None, None, None, None = time.localtime() > > I know you can't assign anything to None, but I'm

Re: anonymous assignment

2008-05-11 Thread Ben Finney
Yves Dorfsman <[EMAIL PROTECTED]> writes: > Paul Rubin wrote: > > Yves Dorfsman <[EMAIL PROTECTED]> writes: > >> import time > >> y, None, d, None, None, None, None = time.localtime() > >> > >> I know you can't assign anything to None, but I'm sure you get what I > >> mean, a special keyword that

Re: anonymous assignment

2008-05-11 Thread Marc 'BlackJack' Rintsch
On Mon, 12 May 2008 03:40:03 +, Yves Dorfsman wrote: > Paul Rubin wrote: > >> You can just use a variable name than you ignore. It's traditional to >> use _ but it's not a special keyword, it's just a another variable >> name: >> >>y, _, d, _, _, _, _, _, _ = time.localtime() > > But yo

Re: anonymous assignment

2008-05-11 Thread Ben Finney
Paul Rubin writes: > Yves Dorfsman <[EMAIL PROTECTED]> writes: > > I know you can't assign anything to None, but I'm sure you get what I > > mean, a special keyword that means I don't care about this value. Snap. This topic was raised today in another thread. > You can

Re: anonymous assignment

2008-05-11 Thread Yves Dorfsman
D'Arcy J.M. Cain wrote: On Mon, 12 May 2008 02:28:13 GMT Yves Dorfsman <[EMAIL PROTECTED]> wrote: particular case, there's got to be a better way than: d = time.local() y = d[0] d = d[1] Like this? y, d = time.local()[:2] Sorry this was a typo (again :-), I meant: d = time.local() y

Re: anonymous assignment

2008-05-11 Thread Yves Dorfsman
Paul Rubin wrote: Yves Dorfsman <[EMAIL PROTECTED]> writes: import time y, None, d, None, None, None, None = time.localtime() I know you can't assign anything to None, but I'm sure you get what I mean, a special keyword that means I don't care about this value. You can just use a variable nam

Re: anonymous assignment

2008-05-11 Thread D'Arcy J.M. Cain
On Mon, 12 May 2008 02:28:13 GMT Yves Dorfsman <[EMAIL PROTECTED]> wrote: > particular case, there's got to be a better way than: > > d = time.local() > y = d[0] > d = d[1] Like this? y, d = time.local()[:2] -- D'Arcy J.M. Cain <[EMAIL PROTECTED]> | Democracy is three wolves http:

Re: anonymous assignment

2008-05-11 Thread Paul Rubin
Yves Dorfsman <[EMAIL PROTECTED]> writes: > import time > y, None, d, None, None, None, None = time.localtime() > > I know you can't assign anything to None, but I'm sure you get what I > mean, a special keyword that means I don't care about this value. You can just use a variable name than you i

anonymous assignment

2008-05-11 Thread Yves Dorfsman
Is there anyway to tell python I don't care about a value ? Say I want today's year and day, I'd like to do something like: import time y, None, d, None, None, None, None = time.localtime() I know you can't assign anything to None, but I'm sure you get what I mean, a special keyword that means