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 re | |
from random import choice | |
#e1 = re.compile('((x((y|z))*x)|(y|z))*$') # my | |
#e2 = re.compile('(y|z)*(x(y|z)*x(y|z)*)*$') | |
e1 = re.compile('(?:(?:x(?:[yz])*x)|[yz])*$') #my | |
e2 = re.compile('(?:y|z)*(?:x(?:y|z)*x(?:y|z)*)*$') | |
res = 0 |
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 re | |
from random import choice | |
e1 = re.compile('(?:(?:x(?:[yz])*x)|[yz])*$') #my | |
e2 = re.compile('(?:y|z)*(?:x(?:y|z)*x(?:y|z)*)*$') | |
res = 0 | |
def test(e, s): | |
global res |
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
format: | |
n: | |
regexp1_try1 try2 try3 regexp2_try1 try2 try3 | |
10 : | |
4.35, 4.30, 4.31, 4.80, 4.81, 4.71, | |
4.31, 4.35, 4.33, 5.00, 5.04, 4.99, | |
3.88, 3.84, 3.85, 4.03, 3.99, 4.02, | |
4.13, 4.14, 4.17, 4.54, 4.53, 4.54, | |
4.42, 4.47, 4.37, 5.00, 4.96, 5.04, |
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 jinja2 | |
env = jinja2.Environment(extensions=['jinja2.ext.do']) | |
template = ''' | |
{% set p = [4,5,6] %} | |
{% set res = [] %} | |
{% for i in p %} | |
{% do res.append(i) %} | |
{% endfor %} |
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
test(markdown('[Google - поиск №1](http://google.com)'), | |
'<a href="http://google.com">Google - поиск №1</a>') | |
test(markdown('[MS Bing] компания [Microsoft Bing](http://bing.com)'), | |
'[MS Bing] компания <a href="http://bing.com">Microsoft Bing</a>') | |
test(markdown('[Python](http://python.org)(v3.7)'), | |
'<a href="http://python.org">Python</a>(v3.7)') | |
test(markdown('[Яндекс!](http://ya.ru) и [百度](http://baidu.com)'), | |
'<a href="http://ya.ru">Яндекс!</a> и <a href="http://baidu.com">百度</a>') |
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
INSTALLED_APPS = [ | |
'core', | |
'django.contrib.admin', |
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 django.db import models | |
from django.contrib.auth.models import User | |
class Book(models.Model): | |
author = models.ForeignKey(User) |
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
In [1]: from django.contrib.auth.models import User | |
In [2]: from core.models import * | |
In [3]: u = User.objects.create(username='aaa') | |
In [4]: Book.objects.create(author=u) | |
Out[4]: <Book: Book object (1)> | |
In [5]: Comment.objects.create(author=u) |
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 django.contrib.auth.models import AbstractUser | |
class User(AbstractUser): | |
class Meta: | |
db_table = 'auth_user' |
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
AUTH_USER_MODEL = 'users.CustomUser' |
OlderNewer