class Foo(object):
def __getattribute__(self, name):
attr = super(Foo, self).__getattribute__(name)
if name in ('abc', 'bar'):
call_some_function()
return attr
class Foo(object):
def __getattribute__(self, name):
attr = super(Foo, self).__getattribute__(name)
if callable(attr):
call_some_functuon()
return attr
class Foo(object):
def __getattribute__(self, name):
attr = super(Foo, self).__getattribute__(name)
return some_decorator(attr) if callable(attr) else attr
/^.*?(\d+(\.\d+)?)?\s*([a-z0-9]+)?\s*(\(.+?\))?\s*-\s*\$\d+(\.\d+)?\s*$/mig
def schema():
return {'name': random_name()
'surname': random_surname()
'age': random_age()
'years': random_year()
}
random_size = 100
random_schemes = [schema() for x in range(random_size)]
import importlib
importlib.import_module("modul_python")
import importlib
import sys
importlib.import_module(sys.argv[1])
$.fn.serializeObject = function () {
var o = {};
var a = this.serializeArray();
$.each(a, function () {
if (o[this.name]) {
if (!o[this.name].push) {
o[this.name] = [o[this.name]];
}
o[this.name].push(this.value || '');
} else {
o[this.name] = this.value || '';
}
});
return o;
};
/*
data - полученный ответ от сервера
*/
var result = [];
for (var i = 0; i < data.length; i++) {
var obj = {};
obj[data[i].name] = data[i].value;
result.push(obj);
}
console.log(result);
// результат
/* [{"assigment":"1"},{"subject":""},{"title":""},{"description":""},{"`pages":""},{"sources`":""},{"id_writer":""},{"discount_code`":""},{"email":""}] */