Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Python3-only Django project - the benefits

Python3-only Django project - the benefits

My lightning talk from EuroPython 2014.

Zbigniew Siciarz

July 23, 2014
Tweet

More Decks by Zbigniew Siciarz

Other Decks in Programming

Transcript

  1. # -*- coding: utf-8 -*-

    View full-size slide

  2. # -*- coding: utf-8 -*-

    View full-size slide

  3. from __future__ import (division,
    print_function,
    absolute_import,
    unicode_literals)

    View full-size slide

  4. from __future__ import (division,
    print_function,
    absolute_import,
    unicode_literals)

    View full-size slide

  5. class DocumentForm(forms.Form):
    def __init__(self, *args, **kwargs):
    super(DocumentForm, self).__init__(*args, **kwargs)
    # do stuff...
    class IndexView(TemplateView):
    def get_context_data(self, **kwargs):
    data = super(IndexView, self).get_context_data(**kwargs)
    data["foo"] = "bar"
    return data

    View full-size slide

  6. class DocumentForm(forms.Form):
    def __init__(self, *args, **kwargs):
    super(DocumentForm, self).__init__(*args, **kwargs)
    # do stuff...
    class IndexView(TemplateView):
    def get_context_data(self, **kwargs):
    data = super(IndexView, self).get_context_data(**kwargs)
    data["foo"] = "bar"
    return data

    View full-size slide

  7. def lazy_id_collector():
    yield from ItemA.objects.values("id")
    yield from ItemB.objects.values("id")
    yield from ItemC.objects.values("id")

    View full-size slide

  8. import faulthandler
    faulthandler.enable()

    View full-size slide

  9. pip install mock
    from mock import patch
    from unittest.mock import patch

    View full-size slide