Kori?tenje dekoratora je jednostavno, no pisanje zna biti kompleksno.
? Kroz jednostavne korake ?emo pro?i i nau?iti dekoratore
1. Funkcije
Kreiranje def, parametri, vra?anje vrijednosti, poziv funkcije
def foo():
return 1
print foo()
1
2. Scope
Namespace funkcije za identificiranje varijabli u tijelu funkcije
a_string = "This is a global variable"
def foo():
print a_string # 1
foo()
This is a global variable
3. variable resolution rules
Pristup globalnim varijablama (promjenjiv tip podataka podr?ava promjene)
a = ["Pero"]
b = "Pero¡±
def foo():
a[0] = "Ivo¡±
b = "Ivo"
print locals()
foo()
print globals()
print a
4. Variable lifetime
Namespace je svaki puta kreiran i uni?ten prilikom poziva funkcije, ne postoji sintaksa za vrijednost varijable.
def foo():
x = 1
foo()
5. Function arguments and parameters
Parametri funkcije mogu biti nazivi ili pozicije
def foo(x, y=0):
return x - y
print foo(3,1)
print foo(3)
6. Nested function
Python gleda scope outer prvo i pronalazi lokalnu varijablu kroz inner
def outer():
x = 1
def inner():
print x
inner()
outer()
7. Functions are first class objects in Python
Funkcije su objekti u Pythonu, (klase su tako?er objekti), shva?amo ih kao vrijednosti, te ih mo?emo koristiti npr. kao argumente.
print issubclass(int, object)
def foo():
pass
print foo.__class__
print issubclass(foo.__class__, object)
8. Closures
Inner funkcija definirana u ne globalnom scope pamti izgled namespace.
def outer():
x = 1
def inner():
print x
return inner
foo = outer()
foo()
9. Decorators
def outer(some_func):
def inner():
print "Before some_func"
ret = some_func()
print some_func.__name__
return ret + 1
return inner
def foo():
return 1
decorated = outer(foo)
print decorated()
10. Symbol @ applies a decorator
def outer(some_func):
def inner():
print "Before some_func"
ret = some_func()
print some_func.__name__
return ret + 1
return inner
@outer
def foo():
return 1
print foo()
11. *args and **kwargs
def logger(func):
def inner(*args, **kwargs):
print "Argumenti su bili : %s, %s" %(args, kwargs)
return func(*args, **kwargs)
return inner
@logger
def fool(x,y=1):
return x * y
@logger
def fool2():
return 2
print fool(5,2)
print fool2()
12. functools.wraps
from functools import wraps
def logged(func):
@wraps(func)
def with_logging(*args, **kwargs):
print func.__name__ + " was called"
return func(*args, **kwargs)
return with_logging
@logged
def f(x):
"""does some math"""
return x + x * x
print f(3)
print f.__name__
Comprendre la programmation fonctionnelle, Blend Web Mix le 02/11/2016Lo?c Knuchel
?
Vous commencez ¨¤ en entendre parler de plus en plus mais vous avez encore du mal ¨¤ voir ce que c¡¯est et ¨¤ comprendre de que ?a change concr¨¨tement, ce talk est fait pour vous !!!
La programmation fonctionnelle est une mani¨¨re de programmer bas¨¦e sur les fonctions qui permet de faire du code vraiment modulaire, am¨¦liorer la qualit¨¦ et limiter les bugs. Vous ne me croyez pas ? Venez voir cette session !
These documents have been drafted within the framework of the European project Talking about taboos.The project has been funded with support from the European Commission. The document reflects the view only of the authors, and the Commission cannot be held responsible for any use which may be made of the information contained therein.
This document has been drafted within the framework of the European project Talking about taboos.The project has been funded with support from the European Commission. The document reflects the view only of the authors, and the Commission cannot be held responsible for any use which may be made of the information contained therein.
Kori?tenje dekoratora je jednostavno, no pisanje zna biti kompleksno.
? Kroz jednostavne korake ?emo pro?i i nau?iti dekoratore
1. Funkcije
Kreiranje def, parametri, vra?anje vrijednosti, poziv funkcije
def foo():
return 1
print foo()
1
2. Scope
Namespace funkcije za identificiranje varijabli u tijelu funkcije
a_string = "This is a global variable"
def foo():
print a_string # 1
foo()
This is a global variable
3. variable resolution rules
Pristup globalnim varijablama (promjenjiv tip podataka podr?ava promjene)
a = ["Pero"]
b = "Pero¡±
def foo():
a[0] = "Ivo¡±
b = "Ivo"
print locals()
foo()
print globals()
print a
4. Variable lifetime
Namespace je svaki puta kreiran i uni?ten prilikom poziva funkcije, ne postoji sintaksa za vrijednost varijable.
def foo():
x = 1
foo()
5. Function arguments and parameters
Parametri funkcije mogu biti nazivi ili pozicije
def foo(x, y=0):
return x - y
print foo(3,1)
print foo(3)
6. Nested function
Python gleda scope outer prvo i pronalazi lokalnu varijablu kroz inner
def outer():
x = 1
def inner():
print x
inner()
outer()
7. Functions are first class objects in Python
Funkcije su objekti u Pythonu, (klase su tako?er objekti), shva?amo ih kao vrijednosti, te ih mo?emo koristiti npr. kao argumente.
print issubclass(int, object)
def foo():
pass
print foo.__class__
print issubclass(foo.__class__, object)
8. Closures
Inner funkcija definirana u ne globalnom scope pamti izgled namespace.
def outer():
x = 1
def inner():
print x
return inner
foo = outer()
foo()
9. Decorators
def outer(some_func):
def inner():
print "Before some_func"
ret = some_func()
print some_func.__name__
return ret + 1
return inner
def foo():
return 1
decorated = outer(foo)
print decorated()
10. Symbol @ applies a decorator
def outer(some_func):
def inner():
print "Before some_func"
ret = some_func()
print some_func.__name__
return ret + 1
return inner
@outer
def foo():
return 1
print foo()
11. *args and **kwargs
def logger(func):
def inner(*args, **kwargs):
print "Argumenti su bili : %s, %s" %(args, kwargs)
return func(*args, **kwargs)
return inner
@logger
def fool(x,y=1):
return x * y
@logger
def fool2():
return 2
print fool(5,2)
print fool2()
12. functools.wraps
from functools import wraps
def logged(func):
@wraps(func)
def with_logging(*args, **kwargs):
print func.__name__ + " was called"
return func(*args, **kwargs)
return with_logging
@logged
def f(x):
"""does some math"""
return x + x * x
print f(3)
print f.__name__
Comprendre la programmation fonctionnelle, Blend Web Mix le 02/11/2016Lo?c Knuchel
?
Vous commencez ¨¤ en entendre parler de plus en plus mais vous avez encore du mal ¨¤ voir ce que c¡¯est et ¨¤ comprendre de que ?a change concr¨¨tement, ce talk est fait pour vous !!!
La programmation fonctionnelle est une mani¨¨re de programmer bas¨¦e sur les fonctions qui permet de faire du code vraiment modulaire, am¨¦liorer la qualit¨¦ et limiter les bugs. Vous ne me croyez pas ? Venez voir cette session !
These documents have been drafted within the framework of the European project Talking about taboos.The project has been funded with support from the European Commission. The document reflects the view only of the authors, and the Commission cannot be held responsible for any use which may be made of the information contained therein.
This document has been drafted within the framework of the European project Talking about taboos.The project has been funded with support from the European Commission. The document reflects the view only of the authors, and the Commission cannot be held responsible for any use which may be made of the information contained therein.
The document discusses challenges with racism in Poland and the Netherlands, including antisemitism, ethnic profiling, and biased media and politics. It also describes differences in their legal frameworks for anti-discrimination and critiques lack of follow-through. Techniques for managing racial issues are discussed, such as dialogues to gain understanding, but some like online interventions can backfire. Overall, it argues that majorities must learn to discuss diversity openly without assumed hierarchies.
These documents have been drafted within the framework of the European project Talking about taboos.The project has been funded with support from the European Commission. The document reflects the view only of the authors, and the Commission cannot be held responsible for any use which may be made of the information contained therein.
This project has been funded with support from the European Commission.
This publication reflects the views only of the author, and the
Commission cannot be held responsible for any use which may be made of the information contained therein.
This document gives an overview of the project dissemination by Ezzev.
The text has been drafted within the framework of the European project Talking about taboos.The project has been funded with support from the European Commission. The document reflects the view only of the authors, and the Commission cannot be held responsible for any use which may be made of the information contained therein.
The document provides instructions for participants in a workshop to practice dialogue through a structured activity. Participants will be paired up and draw straws to determine who will ask questions and who will answer for 90 seconds. Without pre-establishing questions or themes, the pairs will use the time to find what they have in common and differ on. At the end, each pair will try to formulate either a shared new opinion or two separate opinions on the topic discussed. The goals of the activity are to concretely understand where the participants' views align or differ and develop new perspectives through respectful and patient dialogue.
This project has been funded with support from the European Commission.
This publication reflects the views only of the author, and the
Commission cannot be held responsible for any use which may be made of the information contained therein.
This project has been funded with support from the European Commission.
This publication reflects the views only of the author, and the
Commission cannot be held responsible for any use which may be made of the information contained therein.
Presentation at the international conference ¡°PECOS4SMEs ¨C Cross-border e-Commerce for SMEs¡± by Bram Alkema.
This project has been funded with support from the European Commission.
This publication reflects the views only of the author, and the Commission cannot be held responsible for any use which may be made of the information contained therein.
x3.js is a JavaScript library that improves page load performance. It does this by (1) caching JavaScript files and drawing pages faster, up to 6 times faster than normal pages, (2) caching files to WebSQL and WebStorage for offline access, and (3) lazily checking for file modifications and auto-refreshing pages. It has a compact minified size of only 2.1KB and implements URL dispatching.
This document has been drafted within the framework of the European project Talking about taboos.The project has been funded with support from the European Commission. The document reflects the view only of the authors, and the Commission cannot be held responsible for any use which may be made of the information contained therein.
·ÇͬÆÚ¥×¥í¥°¥é¥ß¥ó¥°¤òó@¤¤Î¥·¥ó¥×¥ë¤µ¤Ë ver 1.0.1
and more.
http://uupaa.hatenablog.com/entry/2013/03/12/185555
http://uupaa.hatenablog.com/entry/2013/03/14/131556
Projekt edukacyjny. E-LAB DYNAMICZNA TO?SAMO??.
Warsztatowa metoda: konstruktywna konfrontacja z mediami a autorefleksja offline i online.
Dofinansowane ze srodk¨®w Ministra Kultury i Dziedzictwa Narodowego