arr = [1, 2, 3]
arr = [2*i for i in arr]
print(arr)
import logging
# инициализируем логгер как нам надо
logger = logging.getLogger()
try:
variable = 1 / 0
except ZeroDivisionError:
logger.exception("ooops")
In [1]: for counter in range(1, 11):
...: print(".//*[@id='b_results']/li[{}]/div[2]/div/cite".format(counter))
...:
.//*[@id='b_results']/li[1]/div[2]/div/cite
.//*[@id='b_results']/li[2]/div[2]/div/cite
.//*[@id='b_results']/li[3]/div[2]/div/cite
.//*[@id='b_results']/li[4]/div[2]/div/cite
.//*[@id='b_results']/li[5]/div[2]/div/cite
.//*[@id='b_results']/li[6]/div[2]/div/cite
.//*[@id='b_results']/li[7]/div[2]/div/cite
.//*[@id='b_results']/li[8]/div[2]/div/cite
.//*[@id='b_results']/li[9]/div[2]/div/cite
.//*[@id='b_results']/li[10]/div[2]/div/cite
INSTALLED_APPS += (
'constance',
'constance.backends.database', )
CONSTANCE_BACKEND = 'constance.backends.database.DatabaseBackend'
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
}
}
CONSTANCE_DATABASE_CACHE_BACKEND = 'default'
CONSTANCE_CONFIG = {
'FOO': ('bar', 'FOO should be bar'),
}
Pickle is slow
Pickle is both slower and produces larger serialized values than most of the alternatives.
To illustrate this, I put together a simple benchmark comparing pickle to the built in JSON module, the Apache Thrift library, and MessagePack. This benchmark measures the number of objects a second each of these libraries can read and write. The data being serialized here are just randomly generated fake 'Tweet' objects containing just four fields:
Pickle is the clear underperformer here. Even the 'cPickle' extension thats written in C has a serialization rate thats about a quarter that of JSON or Thrift. Pickle also produces serialized values that are around double the size of Thrift or MessagePack.
Warning: The pickle module is not intended to be secure against erroneous or maliciously constructed data. Never unpickle data received from an untrusted or unauthenticated source.
>>> s = 'abc<def*gh?ikl'
>>> s.translate(None, '\/:*?"<>|')
'abcdefghikl'