Dunedin, New Zealand
September 9-11, 2016
Barry Warsaw
Truth? What is truth? ... And by the way, if I always tell you the truth, you might start to believe me."
(as told by Victor Wooten in "The Music Lesson")
ondon
o
ome
arry
T
L
C
B
Relax (but don't collapse)
#include <iostream>
using namespace std;
class XYZ {
public:
XYZ(int, int, int);
void set(int, int, int);
void print();
private:
int x, y, z;
};
XYZ::XYZ(int a, int b, int c) {
x = a;
y = b;
z = c;
}
void XYZ::set(int a, int b, int c) {
x = a;
y = b;
z = c;
}
void XYZ::print() {
cout << x << " " << y << " " << z << endl;
}
int main() {
XYZ xyz(3, 2, 1);
xyz.print();
xyz.set(9, 8, 7);
xyz.print();
return 0;
}
class XYZ:
def __init__(self, a, b, c):
self.x = a
self.y = b
self.z = c
def set(self, a, b, c):
self.x = a
self.y = b
self.z = c
def __repr__(self):
return '%s %s %s' % (self.x, self.y, self.z)
xyz = XYZ(3, 2, 1)
print(xyz)
xyz.set(9, 8, 7)
print(xyz)
with Lock():
look_ma_no_race_conditions()
@decorator
def function_to_augment(*args, **kws):
yield from other
[x.name for x in seq]
''.join(x.name for x in seq)
{x.name: x for x in seq}
async def http_get(domain):
'%s is a member of %s' % (email, list_name)
'%(email)s is a member of %(list_name)s' % {
'email': email,
'list_name': list_name}
'%(list_name)s si a rebmem fo %(email)'
Oops!
The odd
%(placeholder)s
format
from string import Template as _
def make_text(email, list_name):
text = _('$email is a member of $list_name')
return text.safe_substitute(email=email,
name=list_name)
Oops!
'$email is a member of $list_name'
==
def _(original_text, **extras):
translated = lookup(original_text)
frame = sys._getframe()
d = frame.f_globals.copy()
d.update(frame.f_locals)
d.update(extras)
return translated.safe_substitute(d)
from flufl.i18n import _
def make_text(email, list_name):
return _('$email is a member of $list_name')
Find the root cause
Branches landed/week
Do Without Doing
What's in the way is the Way
Invest in Loss
Listen
barry@{python,list,debian}.org
barry@ubuntu.com
@pumpichank
github.com/warsaw
gitlab.com/warsaw