TerryP wrote:
Somehow I doubt that Look up X in dictionary D could ever be more
efficient (in terms of space and time, at least) then Check if X is
equal to Y. It's not about what you get in runtime but what you get
in monkey time.
Most expressions that would make someone reach for a C-like
I wonder the reason for ELIF. it's not aligned with IF, make code ugly
IMHO
OR maybe better?
if foo == bar:
...
or foo == baz:
...
or foo == bra:
...
else:
...
--
http://mail.python.org/mailman/listinfo/python-list
metal wrote:
I wonder the reason for ELIF. it's not aligned with IF, make code ugly
IMHO
OR maybe better?
if foo == bar:
...
or foo == baz:
...
or foo == bra:
...
else:
...
Because that's uglier. `or` means something completely unrelated in
expressions.
On Sat, 10 Oct 2009 23:47:38 -0700, metal wrote:
I wonder the reason for ELIF. it's not aligned with IF, make code ugly
IMHO
OR maybe better?
if foo == bar:
...
or foo == baz:
...
or foo == bra:
...
else:
...
`or` has another meaning in Python, and many
On 2009-10-11, metal metal...@gmail.com wrote:
I wonder the reason for ELIF. it's not aligned with IF, make code ugly
It most certainly is aligned with IF:
if cond1:
do this
elif cond2:
do that
else:
do the other
The if elif and else are all aligned in all of the code
On Oct 11, 7:07 am, Erik Max Francis m...@alcyone.com wrote:
Because that's uglier. `or` means something completely unrelated in
expressions. Variations of `else if` in `if ... else if ...` chains is
routine in computer languages. Choosing a deliberately different syntax
just for the sake
Steven D'Aprano wrote:
By the way, if you're testing a single name against a series of
alternatives, it is often better to look up the value in a dictionary:
table = {bar: 23, baz: 42, boop: 73, beep: 124}
value = table[foo]
instead of:
if foo == bar:
value = 23
elif foo == baz:
Grant Edwards wrote:
On 2009-10-11, metal metal...@gmail.com wrote:
I wonder the reason for ELIF. it's not aligned with IF, make code ugly
It most certainly is aligned with IF:
if cond1:
do this
elif cond2:
do that
else:
do the other
The if elif and else are all
On Oct 11, 3:42 pm, Esmail ebo...@hotmail.com wrote:
cool .. I hadn't seen that. Not working quite at the 'pythonic' level yet
I am not sure I think it's more readable that the if statement. Also, curious
if the dictionary approach is more efficient.
Somehow I doubt that Look up X in
On Sun, Oct 11, 2009 at 2:15 PM, TerryP bigboss1...@gmail.com wrote:
On Oct 11, 3:42 pm, Esmail ebo...@hotmail.com wrote:
cool .. I hadn't seen that. Not working quite at the 'pythonic' level yet
I am not sure I think it's more readable that the if statement. Also, curious
if the dictionary
TerryP schrieb:
Note: let Commands be a dictionary, such that { ham : ...,
spam : ..., eggs : ... }.
args = re.split('\s', line)
cmd = args.pop(0)
if cmd in Commands:
Commands[cmd](args)
else:
raise SyntaxWarning(Syntax error in above program)
[...] I might take
Simon Forman wrote:
[snip]
I'll often do that this way:
args = re.split('\s', line)
This has the same result, but is shorter and quicker:
args = line.split()
--
http://mail.python.org/mailman/listinfo/python-list
On Sun, 11 Oct 2009 11:15:06 -0700, TerryP wrote:
On Oct 11, 3:42 pm, Esmail ebo...@hotmail.com wrote:
cool .. I hadn't seen that. Not working quite at the 'pythonic' level
yet I am not sure I think it's more readable that the if statement.
Also, curious if the dictionary approach is more
On Oct 11, 7:10 am, Grant Edwards inva...@invalid.invalid wrote:
On 2009-10-11, metal metal...@gmail.com wrote:
I wonder the reason for ELIF. it's not aligned with IF, make code ugly
It most certainly is aligned with IF:
if cond1:
do this
elif cond2:
do that
else:
On Oct 11, 5:05�pm, Carl Banks pavlovevide...@gmail.com wrote:
On Oct 11, 7:10�am, Grant Edwards inva...@invalid.invalid wrote:
On 2009-10-11, metal metal...@gmail.com wrote:
I wonder the reason for ELIF. it's not aligned with IF, make code ugly
It most certainly is aligned with IF:
On Oct 11, 4:12 pm, Mensanator mensana...@aol.com wrote:
On Oct 11, 5:05 pm, Carl Banks pavlovevide...@gmail.com wrote:
On Oct 11, 7:10 am, Grant Edwards inva...@invalid.invalid wrote:
On 2009-10-11, metal metal...@gmail.com wrote:
I wonder the reason for ELIF. it's not aligned
MRAB python at mrabarnett.plus.com writes:
Simon Forman wrote:
[snip]
I'll often do that this way:
args = re.split('\s', line)
This has the same result, but is shorter and quicker:
args = line.split()
HUH?
Shorter and quicker, yes, but provides much better functionality;
On Oct 11, 6:43�pm, Carl Banks pavlovevide...@gmail.com wrote:
On Oct 11, 4:12�pm, Mensanator mensana...@aol.com wrote:
On Oct 11, 5:05 pm, Carl Banks pavlovevide...@gmail.com wrote:
On Oct 11, 7:10 am, Grant Edwards inva...@invalid.invalid wrote:
On 2009-10-11, metal
On Oct 11, 9:43 pm, Steven D'Aprano st...@remove-this-
cybersource.com.au wrote:
On Sun, 11 Oct 2009 11:15:06 -0700, TerryP wrote:
I might take flak here, for writing something like 'dict[key]
(func_args)' instead of something more Pythonic,
Looking up a first-class function in a dictionary
19 matches
Mail list logo