This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import absolute_import, print_function, unicode_literals |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import absolute_import, print_function, unicode_literals | |
from six import string_types, text_type, binary_type | |
## Python 2 only | |
some_value = 20 | |
value_as_string = unicode(some_value) | |
value_as_bytes = str(some_value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import absolute_import, print_function, unicode_literals | |
from six import python_2_unicode_compatible | |
from django.db import models | |
@python_2_unicode_compatible | |
class MyModelClass(models.Model): | |
"""Python 2 and 3 compatible model. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import absolute_import, print_function, unicode_literals | |
from .modules import my_function, handle_exception | |
## Python 2 only | |
try: | |
my_function() | |
except AttributeError, exc: | |
handle_exception() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
grep "except\s\+\w\+,\s*\w\+:$" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<!-- ... --> | |
</head> | |
<body> | |
<!-- Where our application will render everything to --> | |
<div id="root"></div> | |
<!-- Link to your compiled application --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Application, View} from 'backbone.marionette'; | |
import _ from 'underscore'; | |
// If you use a navbar or panel | |
import {NavView} from './views/nav'; | |
// Your home page | |
import {IndexView} from './views/index'; | |
const RootView = View.extend({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Bb from 'backbone'; | |
import {Application, View} from 'backbone.marionette'; | |
import _ from 'underscore'; | |
// The Router class defined above | |
import {Router} from './router' | |
// If you use a navbar or panel | |
import {NavView} from './views/nav'; | |
// Your home page |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Model} from 'backbone'; | |
export const NoteModel = Model.extend({ | |
urlRoot: '/notes/', | |
defaults: { | |
header: '', | |
body: '' | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {View} from 'backbone.marionette'; | |
import {template} from 'underscore'; | |
import {NoteCollection} from './notes'; | |
import {NoteModel} from './note'; | |
import {NoteListView} from './list'; | |
import {NoteView} from './detail'; | |
OlderNewer