# Works class Test: a = [1, 2, 3] b = [1, 2, 3] c = [i for i in a] # Raises NameError: name 'b' is not defined class Test: a = [1, 2, 3] b = [1, 2, 3] c = [i*j for i in a for j in b]
-
-
Code on class bodies doesn't act like code at a module level or in a function body. Nested local scopes like can't see class variables. This includes list comprehensions because they run in their own scope (just like they were a separate function).
Prikaži ovu nitHvala. Twitter će to iskoristiti za poboljšanje vaše vremenske crte. PoništiPoništi
-
Čini se da učitavanje traje već neko vrijeme.
Twitter je možda preopterećen ili ima kratkotrajnih poteškoća u radu. Pokušajte ponovno ili potražite dodatne informacije u odjeljku Status Twittera.