Kod HTML/CSS napisany w poprawny sposób powinnien być:
- semantyczny
- zorientowany na komponenty
- łatwy w modyfikacji
| from unittest import mock | |
| # Approach #1 - hidden dependency | |
| def func_1(): | |
| pass | |
| # ugly | |
| def register_user(user_data): | |
| ... | |
| save_user_in_db( | |
| email=user_data['email'], | |
| first_name=user_data['first_name'], | |
| ... | |
| ) | |
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title>Title</title> | |
| </head> | |
| <body> | |
| {{ person.name }} - {{ person.email }} <- autocompletion works like a charm | |
| </body> | |
| </html> |
| import decimal | |
| import functools | |
| import typing | |
| @functools.total_ordering | |
| class Money: | |
| def __init__(self, amount: str) -> None: | |
| self.amount = decimal.Decimal(amount) |
| from typing import NamedTuple # >= Python.3.6.0 | |
| class Employee(NamedTuple): | |
| name: str | |
| department: str | |
| salary: int | |
| is_remote: bool = False # >= Python.3.6.1 | |
| bob = Employee(name='Bob', department='IT', salary=10000, is_remote=True) |
| # return double of first number from collection which is greater than 3 and even | |
| # this is Python 3 srcipt, in Python 2 you have to use itertools.imap and itertools.ifilter | |
| def is_gt_3(number): | |
| print('is_gt_3 called...') | |
| return number > 3 | |
| def is_even(number): | |
| print('is_even called...') | |
| return number % 2 == 0 |
| var LICENSE = 'License: For reuse of this video under a more permissive license please get in touch with us. The speakers retain the copyright for their performances.'; | |
| var WEBSITE = 'http://summit.pywaw.org'; | |
| var result = []; | |
| $(".speaker-modal").each(function() { | |
| var $speakerModal = $(this); | |
| var $talkDetails = $speakerModal.find('.speaker-modal__talk-title'); | |
| var speakerName = $speakerModal.find('.speaker-modal__name').text(); | |
| var speakerBio = $speakerModal.find('p:not(.speaker-modal__twitter)').first().text(); | |
| var mixedTalksDescription = $speakerModal.find('p:not(.speaker-modal__twitter)').slice(1).text(); |
| def view_example(request): | |
| print(request) | |
| class ViewTestCase(object): | |
| view_function = view_example | |
| def __init__(self): | |
| self.view = self.__class__.__dict__['view_function'] | |
| def refresh(instance): | |
| return instance.__class__._default_manager.get(pk=instance.pk) |