This file contains hidden or 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 itertools import chain, islice | |
| def chunk(seq, chunksize, process=iter): | |
| """ Yields items from an iterator in iterable chunks.""" | |
| it = iter(seq) | |
| while True: | |
| yield process(chain([it.next()], islice(it, chunksize - 1))) | |
| if __name__ == '__main__': | |
| lst = ['a', 'b', 'c', 'd', 'e', 'f'] |
This file contains hidden or 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
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| # vim: ai ts=4 sts=4 et sw=4 | |
| """ | |
| Tools to extract feed links, test if they are valid and parse them | |
| with feedparser, returning content or a proper error. | |
| """ |
This file contains hidden or 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
| Environment: | |
| Request Method: GET | |
| Request URL: http://127.0.0.1:8000/admin/intake/patientprofile/1/ | |
| Django Version: 1.3.1 | |
| Python Version: 2.7.2 | |
| Installed Applications: |
This file contains hidden or 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
| On peut aussi s'amuser avec les (peu connus) sets, qui sont built-in comme les dictionnaires:: | |
| In [1]: set((1,2,3,3,3,3,4)) # les set n'ont pas de doublons | |
| Out[1]: set([1, 2, 3, 4]) | |
| In [2]: 1 in set((1,2,3,4)) # operation O(1) comme les dicts | |
| Out[2]: True | |
| In [4]: set((1,2,3,4)).intersection((4,5,6)) # operations ensemblistes | |
| Out[4]: set([4]) | |
| Toutes les collections sont iterables, et donc on peut utiliser functions associées telle que zip() sur les listes, les tuples, les dicts, les sets, etc:: |
This file contains hidden or 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
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| # vim: ai ts=4 sts=4 et sw=4 | |
| import urllib | |
| import urllib2 | |
| import cookielib | |
| import os | |
| import gzip | |
| import io |
This file contains hidden or 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
| <?xml version="1.0" encoding="UTF-8" ?> | |
| <!-- | |
| Licensed to the Apache Software Foundation (ASF) under one or more | |
| contributor license agreements. See the NOTICE file distributed with | |
| this work for additional information regarding copyright ownership. | |
| The ASF licenses this file to You under the Apache License, Version 2.0 | |
| (the "License"); you may not use this file except in compliance with | |
| the License. You may obtain a copy of the License at | |
| http://www.apache.org/licenses/LICENSE-2.0 |
This file contains hidden or 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
| # this works (like javascript) | |
| def test(value): # functions that returns a function | |
| def closure(plus): # function got 'value' in a closure | |
| return value + plus | |
| return closure |
This file contains hidden or 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
| #!/usr/bin/env python | |
| # coding: UTF-8 | |
| # code extracted from nigiri | |
| import os | |
| import datetime | |
| import sys | |
| import traceback | |
| import re |
This file contains hidden or 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
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| # vim: ai ts=4 sts=4 et sw=4 nu | |
| import urlparse | |
| import os | |
| import urllib | |
| from scrapy.utils.url import urljoin_rfc | |
| from scrapy.selector import HtmlXPathSelector |
This file contains hidden or 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
Show hidden characters
| [ | |
| { "keys": ["ctrl+d"], "command": "run_macro_file", "args": {"file": "Packages/Default/Delete Line.sublime-macro"} }, | |
| { "keys": ["shift+alt+d"], "command": "find_under_expand", "context": | |
| [ | |
| { "key": "selection_empty", "operator": "equal", "operand": false, "match_all": true } | |
| ] | |
| }, | |
| { "keys": ["shift+alt+c"], "command": "run_macro_file", "args": {"file": "Packages/User/color.sublime-macro"} }, | |
| { "keys": ["ctrl+alt+p"], "command": "previous_edit" }, | |
| { "keys": ["ctrl+alt+n"], "command": "next_edit" } |