On 2012-07-22, Jan Riechers janpet...@freenet.de wrote:
I am not sure why everyone is using the for-iterator option over a
map, but I would do it like that:
MODUS_LIST= map(int, options.modus_list)
map works on a list and does commandX (here int conversion, use
str for string.. et
On Jul 23, 7:27 pm, Grant Edwards inva...@invalid.invalid wrote:
That said, map seems to be frowned upon by the Python community for
reasons I've never really understood,...
Maybe the analogy:
comprehension : map:: relational calculus : relational algebra
In particular map, filter
On Sun, 22 Jul 2012 10:29:44 -0500, Tony the Tiger wrote:
Hi,
Is there such a thing in the language, or do I have to invent it myself?
I came up with the following:
# options.modus_list contains, e.g., [2,3,4]
# (a string from the command line)
# MODUS_LIST contains, e.g.,
In article 3rcdnuciwpp1gzhnnz2dnuvz7vqaa...@giganews.com,
Tony the Tiger tony@tiger.invalid wrote:
Hi,
Is there such a thing in the language, or do I have to invent it myself?
I came up with the following:
# options.modus_list contains, e.g., [2,3,4]
# (a string from the command
On 22.07.2012 18:39, Alister wrote:
On Sun, 22 Jul 2012 10:29:44 -0500, Tony the Tiger wrote:
I came up with the following:
# options.modus_list contains, e.g., [2,3,4]
# (a string from the command line)
# MODUS_LIST contains, e.g., [2,4,8,16]
# (i.e., a list of integers)
if
Tony the Tiger wrote:
On Sun, 22 Jul 2012 11:39:30 -0400, Roy Smith wrote:
To answer the question you asked, to convert a list of strings to a list
of ints, you want to do something like:
MODUS_LIST = [int(i) for i in options.modus_list]
Thanks. I'll look into that. I now remember
On Sun, Jul 22, 2012 at 12:20 PM, Jan Riechers janpet...@freenet.de wrote:
On 22.07.2012 18:39, Alister wrote:
looks like a classic list comprehension to me and can be achieved in a
single line
MODUS_LIST=[int(x) for x in options.modus_list]
Hi,
I am not sure why everyone is using the
Tony the Tiger tony@tiger.invalid writes:
# options.modus_list contains, e.g., [2,3,4]
Try this:
import ast
MODUS_LIST = ast.literal_eval(options.modus_list)
literal_eval is like eval except it can only evaluate literals rather
than calling functions and the like. The idea is you can
On Sun, 22 Jul 2012 19:20:18 +0300, Jan Riechers wrote:
map works on a list and does commandX (here int conversion, use
str for string.. et cetera) on sequenceY, returning a sequence. More
in the help file.
And if I'm not completely mistaken, it's also the quicker way to do
performance
On 22.07.2012 20:03, David Robinow wrote:
On Sun, Jul 22, 2012 at 12:20 PM, Jan Riechers janpet...@freenet.de wrote:
On 22.07.2012 18:39, Alister wrote:
looks like a classic list comprehension to me and can be achieved in a
single line
MODUS_LIST=[int(x) for x in options.modus_list]
Hi,
I am
On Sun, Jul 22, 2012 at 10:20 AM, Jan Riechers janpet...@freenet.de wrote:
Hi,
I am not sure why everyone is using the for-iterator option over a map,
but I would do it like that:
MODUS_LIST= map(int, options.modus_list)
map works on a list and does commandX (here int conversion, use str
On 22.07.2012 20:01, Steven D'Aprano wrote:
[SNIP]
map is faster than an ordinary for-loop if the function you are applying
is a builtin like int, str, etc. But if you have to write your own pure-
Python function, the overhead of calling a function negates the advantage
of map, which is no
On 07/22/2012 11:29 AM, Tony the Tiger wrote:
Hi,
Is there such a thing in the language, or do I have to invent it myself?
I came up with the following:
# options.modus_list contains, e.g., [2,3,4]
# (a string from the command line)
SNIP
So which is it, a list of strings, or a
13 matches
Mail list logo