Movatterモバイル変換


[0]ホーム

URL:


why python annoys me

Marcin 'Qrczak' Kowalczykqrczak at knm.org.pl
Sat Apr 21 17:43:56 EDT 2001


Sat, 21 Apr 2001 11:30:54 -0700, James Logajan <JamesL at Lugoj.Com> pisze:> what are (or is?) "list comprehensions"?A syntax which looks for example like this in Python:    [x+y for x in l1 if x<0 for y in f(x)]which means:    __result = []    for x in l1:        if x<0:            for y in f(x):                __result.append(x+y)    # Result is in the variable __resultexcept that it's a single expression (and doesn't create the variablenamed __result).> definition of "functional programming"?IMHO the most important technical aspects are:1. working with immutable data,2. working with functions as values.In the resulting style implicit maintaining of mutable state isavoided, dependencies on inputs and produced outputs are more explicit,recursion is preferred to loops, expressions are more important thanstatements, values of expressions rarely depend on the moment ofevaluation, reading inputs is often separated from processing thedata in internal forms and from writing outputs, functions takingfunctions as arguments often replace control structures, behaviorsare expressed as data, examining object values is more important thanchecking object identities, effect of an operation is expressed asreturning appropriately structured data instead of setting variablesor raising exceptions, nesting of simple structures is preferred tobig flat objects, objects are more often put into structures whichdefine relationships with other objects than maintain relationshipsthemselves...I'm afraid it's hard to explain.--  __("<  Marcin Kowalczyk *qrczak at knm.org.plhttp://qrczak.ids.net.pl/ \__/  ^^                      SYGNATURA ZASTĘPCZAQRCZAK


More information about the Python-listmailing list

[8]ページ先頭

©2009-2025 Movatter.jp