View gist:d85afa9d30a0f74bd481
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 logging | |
import logging.handlers | |
logf = logging.getLogger('MyLogger') | |
logf.setLevel(logging.INFO) | |
handler = logging.handlers.RotatingFileHandler( | |
'logfile.txt', maxBytes=100*1000*1000, backupCount=5) | |
logf.addHandler(handler) | |
logf.info('this is a log message') |
View ismulticast.py
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 ismulticast(hostname): | |
"""is this address a multicast address?""" | |
# -- yes if bits 0-3 are 1110 | |
import socket | |
import struct | |
ip=socket.gethostbyname(hostname) | |
mreq=struct.pack("4sl",socket.inet_aton(ip),socket.INADDR_ANY) | |
return ord(mreq[0]) & 0xf0 == 0xe0 | |
View 3columns.py
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
a=['a1'] | |
b=['b1','b2','b3'] | |
c=['c1','c2'] | |
print zip(a,b,c) |