This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Instalando no Mac Os | |
| $ sudo easy_install pip | |
| # Instalando no Ubuntu: | |
| $ sudo apt-get install python-pip | |
| # Instalando no Fedora: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # coding: utf-8 | |
| import unittest | |
| class Discount(object): | |
| def __init__(self, customer_type, value): | |
| self.customer_type = customer_type | |
| self.value = value |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # coding: utf-8 | |
| class Discount(object): | |
| def __init__(self, customer_type, value): | |
| self.customer_type = customer_type | |
| self.value = value | |
| def twenty_percent(self, value): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
| fastcgi_param QUERY_STRING $query_string; | |
| fastcgi_param REQUEST_METHOD $request_method; | |
| fastcgi_param CONTENT_TYPE $content_type; | |
| fastcgi_param CONTENT_LENGTH $content_length; | |
| fastcgi_param SCRIPT_NAME $fastcgi_script_name; | |
| fastcgi_param REQUEST_URI $request_uri; | |
| fastcgi_param DOCUMENT_URI $document_uri; | |
| fastcgi_param DOCUMENT_ROOT $document_root; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # coding: utf-8 | |
| from django.conf import settings | |
| from django.conf.urls import patterns, include, url | |
| from django.conf.urls.static import static | |
| from django.contrib import admin | |
| admin.autodiscover() | |
| urlpatterns = patterns('', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| >>> a = [1,3,5,7] | |
| >>> b = [2,4,6,8] | |
| >>> zip(a,b) | |
| [(1, 2), (3, 4), (5, 6), (7, 8)] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public function query_column_info($table) | |
| { | |
| $sql = <<<SQL | |
| SELECT | |
| a.attname AS field, a.attlen, t.typname AS type, | |
| format_type(a.atttypid, a.atttypmod) AS complete_type, | |
| a.attnotnull AS not_nullable, | |
| (SELECT 't' FROM pg_index WHERE c.oid = pg_index.indrelid | |
| AND a.attnum = ANY (pg_index.indkey) | |
| AND pg_index.indisprimary = 't') IS NOT NULL AS pk, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from random import shuffle | |
| from inplace import pairswap | |
| class Tombola(object): | |
| '''Sorteia itens sem repetir''' | |
| def __iter__(self): | |
| return IteratorTombola(self.itens) | |
| def carregar(self, seq): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # coding: utf-8 | |
| """ | |
| Código inicial usado na Lista de Exercícios 1 do curso | |
| "Objetos Pythonicos" de Luciano Ramalho, Oficinas Turing. | |
| """ | |
| __all__ = ('Contador', 'ContadorAmigavel', 'ContadorTotalizador', 'ContadorTotalizadorAmigavel') | |
| class Contador(object): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| >>> t = (4, 3, 6, 7, 8) | |
| # Diferente do sort(), o sorted() cria uma cópia e não altera no local | |
| >>> t2 = sorted(t) | |
| >>> t2 | |
| [3, 4, 6, 7, 8] # sorted gerou uma lista ordenada com os itens copiados da tupla | |
| >>> type(t2) | |
| <type 'list'> | |
| # transformando a lista em tupla | |
| >>> t2 = tuple(t2) |
NewerOlder