Clear the screen with the running Python interpreter.
...as a function
def clear_screen(): import os; os.system('cls' if os.name=='nt' else 'clear')...as a lambda expression with explicit import statement
| // Test Gist | |
| #include <iostream> | |
| int main() | |
| { | |
| std::cout << "Hello World!" << std::endl; | |
| return 0; // EXIT_SUCCESS | |
| } |
| class A(object): | |
| def __init__(self): | |
| self.__var = 1 | |
| def __private(self): | |
| print("--private--") | |
| a = A() | |
| print(A.__dict__.keys()) |
| /** | |
| Reads the content and returns it as a string. | |
| @param filename | |
| @returns string | |
| */ | |
| const char * read_text(const char * filename) | |
| { | |
| assert(NULL != filename); | |
| FILE * fp; |
| fn main() { | |
| println!("Hello, World!") | |
| } |
| def get_docx_paragraphs_content(path, delimiter="\n"): | |
| """ | |
| Funkce vrací obsah odstavců Word dokumentu. | |
| :path: Cesta k Word dokumentu. | |
| :delimiter: Oddělovací znak jednotlivých odstavců ve výstupním řetězci. | |
| :returns paragraphs: Vrací obsah odstavců jako řetězec. | |
| """ | |
| import os | |
| import zipfile | |
| from xml.etree.ElementTree import XML |
| /// | |
| /// uetoyo | |
| /// | |
| template<typename F, typename S> | |
| class Pair | |
| { | |
| public: | |
| inline Pair(F first, S second) : _first(first), _second(second) | |
| { | |
| } |
Clear the screen with the running Python interpreter.
...as a function
def clear_screen(): import os; os.system('cls' if os.name=='nt' else 'clear')...as a lambda expression with explicit import statement
| def num_cpu_cores(): | |
| with open('/proc/cpuinfo') as f: | |
| return f.read().count('processor') |
V tomto článku si vysvětlíme k čemu jsou properties, jak jich využít, jaké výhody přináší a proč bychom je měli používat namísto přímého přístupu k proměnným nebo namísto tzv. get/set metod, které se běžné používají v jiných OOP jazycích.
V následujícím příkladu vytvoříme třídu A s jedním instančním atributem x a výchozí hodnotou 0.
| #!/usr/bin/env python2 | |
| #-*- coding=utf-8 -*- | |
| # © 2013 Mark Harviston, BSD License | |
| from __future__ import absolute_import, unicode_literals, print_function | |
| """ | |
| Qt data models that bind to SQLAlchemy queries | |
| """ | |
| from PyQt4 import QtGui | |
| from PyQt4.QtCore import QAbstractTableModel, QVariant, Qt | |
| import logging # noqa |