Skip to content

Instantly share code, notes, and snippets.

import zipimport
# Used to try and prevent bugs from people who see that Wheels
# support being added to sys.path and expect that your library/tool should
# support this misfeature.
try:
if isinstance(__loader__, zipimport.zipimporter):
raise RuntimeError(
"Zipped imports are not supported, use something less terrible."
)
dig mx stufft.io
; <<>> DiG 9.8.3-P1 <<>> mx stufft.io
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 53355
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;stufft.io. IN MX
pip
---
.. contents::
Usage
*****
::
.
├── dtest
│   ├── __init__.py
│   └── data.file
└── setup.py
--allow-unverified PIL
--allow-unverified bar
PIL==1.0
foo=2.0 # Implicitly depends on bar, which requires an unverified
[distutils]
index-servers =
pypi
testpypi
[pypi]
username:dstufft
password:notmypassword
[testpypi]
>>> class Foo(dict):
... def keys(self):
... raise NotImplementedError()
...
>>> print(**Foo())
>>> Foo().keys()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 3, in keys
# Option 1
filename = None
try:
fileobj = tempfile.NamedTemporaryFile(delete=False)
filename = fileobj.name
fileobj.close() # Required because not all platforms can reopen a file a second time
with open(filename, "w") as fp:
fp.write(pkgutil.get_data("something.txt"))
>>> def __one__(self):
... pass
...
>>> class Foo:
... __two__ = __one__
... def __three__(self):
... pass
...
>>> Foo.__four__ = __one__
>>> obj = Foo()
## Option 1
# warehouse/packaging/db.py
class Database:
def query_that_thing(self):
pass
# warehouse/accounts/db.py
class Database:
def query_that_other_thing(self):
pass
# warehouse/application.py