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
def split_iter(iter, index): | |
for x in iter: | |
yeild x[index] | |
def split_tuple(iter): | |
return split_iter(0), split_iter(1) | |
foo = [(1,2),(3,4),(5,6)] | |
a,b = split_tuple(foo) |
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
>>> def f1(): | |
... a,b = 1,2 | |
... | |
>>> import dis | |
>>> def f2(): | |
... a,b = [1,2] | |
... | |
>>> dis.dis(f1) | |
2 0 LOAD_CONST 3 ((1, 2)) | |
3 UNPACK_SEQUENCE 2 |
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
(define-syntax multiple-let | |
(syntax-rules () | |
[(_ ((x* e*) ...) body body* ...) | |
((lambda (x* ...) body body* ...) e* ...)])) |
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
#-*- coding: utf-8 -*- | |
import sys | |
import os | |
import pprint | |
import internetarchive | |
def _search_collection(collection_name): | |
""" Searches the internet archive for the specified collection. | |
if no items are found for the collection it returns None otherwise |
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
#-*- coding: utf-8 -*- | |
import sys | |
import pprint | |
import internetarchive | |
def _search_collection(collection_name): | |
""" Searches the internet archive for the specified collection. | |
if no items are found for the collection it returns None otherwise | |
the Search object is returned. |
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
#-*- coding: utf-8 -*- | |
import sys | |
import pprint | |
import internetarchive | |
def _search_collection(collection_name): | |
""" Searches the internet archive for the specified collection. | |
if no items are found for the collection it returns None otherwise | |
the Search object is returned. |
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 selenium import webdriver | |
import random | |
import time | |
def get_url(tag_object): | |
a_tag = tag_object.find_elements_by_tag_name('a')[0] | |
return a_tag.get_attribute('href') | |
def write_results(f, url_list): | |
if len(url_list) == 0: return |
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
def f(n, l=[]): | |
return l.append(n) | |
f(1,[12]) # returnerar [12,1] | |
f(1) # returnerar [1] | |
f(2) # returnerar [1,2] |