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
""" | |
Usage: | |
- create and activate a virtual env | |
- `pip install launchpadlib` | |
- run `python main.py https://launchpad.net/~deadsnakes` | |
API: | |
https://launchpad.net/+apidoc/devel.html |
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
# packages is a list of packages, created from the configuration object (config.job.packages), | |
# but also external plugins can extend this list | |
# so I need something like this here | |
packages = list(itertools.chain(*pm.hook.lpcraft_install_packages())) | |
packages_cmd = ["apt", "install", "-y"] + packages | |
emit.progress("Installing system packages") | |
with emit.open_stream(f"Running {packages_cmd}") as stream: | |
proc = instance.execute_run( |
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
# pi_approx.py | |
from math import pi | |
def approximate_pi(iteration_count: int) -> float: | |
sign, result = 1, 0.0 | |
for at in range(iteration_count): | |
result += sign / (2 * at + 1) | |
sign *= -1 | |
return result * 4 |
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
tox on rewrite [$?] via 🐍 v2.7.17 | |
❯ tox4 -r -e flake8 | |
flake8: remove tox env folder /home/jugmac00/Projects/tox/.tox/4/flake8 | |
flake8: install_deps> python -I -m pip install flake8-bugbear==20.11.1 flake8-comprehensions==3.3.1 flake8-pytest-style==1.3 flake8-spellcheck==0.23 flake8-unused-arguments==0.0.6 flake8==3.8.4 | |
flake8: commands[0]> flake8 src tests docs | |
src/tox/pytest.py:66:1: PT004 fixture 'ensure_logging_framework_not_altered' does not return anything, add leading underscore | |
src/tox/pytest.py:111:1: PT004 fixture 'check_os_environ_stable' does not return anything, add leading underscore | |
src/tox/pytest.py:118:1: PT004 fixture 'no_color' does not return anything, add leading underscore | |
src/tox/pytest.py:274:1: PT004 fixture 'enable_pep517_backend_coverage' does not return anything, add leading underscore | |
src/tox/pytest.py:565:1: PT005 fixture '_invalid_index_fake_port' returns a value, remove leading underscore |
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
❯ ./configure --with-pydebug --enable-shared | |
❯ make -j2 -s | |
Python build finished successfully! | |
❯ ./python | |
./python: error while loading shared libraries: libpython3.9d.so.1.0: cannot open shared object file: No such file or directory | |
This is reproducible on Linux (Ubuntu 18.04) with the `enable-shared` option. |
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 time import sleep | |
cache = dict() | |
def get_data(): | |
if not cache.get("items"): | |
sleep(10) # simulates waiting for data | |
items = ["a", "b", "c"] | |
cache["items"] = items |
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
branch: 3.9.0b5 | |
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
import os | |
import os.path | |
import sys | |
import gocept.httpserverlayer.plonetestingzope as gc_httpserverlayer_zope | |
import gocept.selenium | |
import plone.testing.layer | |
import plone.testing.zodb | |
import plone.testing.zope as plone_testing_zope | |
import Products.MailHost.tests.testMailHost |
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 typing import Optional | |
from typing import List | |
class Pizza: | |
def __init__(self, ingredients=None): | |
# type: (Optional[List[str]]) -> None | |
if ingredients is None: | |
self.ingredients = [] | |
else: | |
self.ingredients = ingredients |
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
diff --git a/Grammar/Grammar b/Grammar/Grammar | |
index 170518af74..25067147bf 100644 | |
--- a/Grammar/Grammar | |
+++ b/Grammar/Grammar | |
@@ -138,7 +138,7 @@ not_test: 'not' not_test | comparison | |
comparison: expr (comp_op expr)* | |
# <> isn't actually a valid comparison operator in Python. It's here for the | |
# sake of a __future__ import described in PEP 401 (which really works :-) | |
-comp_op: '<'|'>'|'=='|'>='|'<='|'<>'|'!='|'in'|'not' 'in'|'is'|'is' 'not' | |
+comp_op: '<'|'>'|'=='|'>='|'<='|'<>'|'!='|'~='|'in'|'not' 'in'|'is'|'is' 'not' |
NewerOlder