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.localtime())
y, d
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(indices, seq):
| ...
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 of wanting a
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.
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
Ben Finney [EMAIL PROTECTED] wrote:
Paul Rubin http://[EMAIL PROTECTED] 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's a terrible
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 you still have
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 means I don't care
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 sure you
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 =
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 license for
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 2008, 11:41:56)
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.local()[:2]
Sorry this was a
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 a generator
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
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)
type
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.
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
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
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
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
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 ignore.
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
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 name
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
Paul Rubin http://[EMAIL PROTECTED] 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 just use
26 matches
Mail list logo