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. View Slide

  2. View Slide

  3. View Slide

  4. View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  9. 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 Slide

  10. 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 Slide

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

    View Slide

  12. import faulthandler
    faulthandler.enable()

    View Slide

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

    View Slide

  14. View Slide

  15. View Slide

  16. View Slide