There is plenty we can do with strings, we have already seen .upper() in
previous chapter.
>>> message = u"hello world"
>>> message.upper()
u'HELLO WORLD'| #!/usr/bin/python | |
| import numpy | |
| import pyaudio | |
| import re | |
| import sys | |
| WIDTH = 79 | |
| BOOST = 1.0 |
| <VirtualHost *:80> | |
| ServerAdmin webmaster@localhost | |
| DocumentRoot /var/www | |
| <Location /elastichq> | |
| #Order allow,deny | |
| #Allow from all | |
| AuthUserFile /etc/apache2/.htpasswd | |
| AuthType Basic | |
| AuthName "Username and Password" | |
| Require valid-user |
| @contextlib.contextmanager | |
| def multiple_targets(mock_patches): | |
| """ | |
| `mock_patches` is a list (or iterable) of mock.patch objects | |
| Example usage: | |
| with mock.patch.multiple_targets([ | |
| mock.patch('os.path.exists', side_effect=mock_path_exists), | |
| mock.patch('subprocess.Popen'), |
| from collections import defaultdict, namedtuple | |
| from itertools import chain | |
| ex = namedtuple('ex', ['name', 'desc']) | |
| items = defaultdict(lambda: defaultdict(ex)) | |
| # items is populated with a bunch of stuff like: | |
| # [1] -> integer key, such as group 1, group 2, so on | |
| # |-> ex('apple', 'a fruit') | |
| # [2] |
| package main | |
| import ( | |
| "bytes" | |
| "encoding/json" | |
| "fmt" | |
| "strconv" | |
| ) | |
| func main() { |
There is plenty we can do with strings, we have already seen .upper() in
previous chapter.
>>> message = u"hello world"
>>> message.upper()
u'HELLO WORLD'This script provides an example of learning a decision tree with scikit-learn. Pandas is used to read data and custom functions are employed to investigate the decision tree after it is learned. Grab the code and try it out.
A blog post about this code is available here, check it out!
| [global] | |
| # after default setup | |
| socket options = IPTOS_LOWDELAY TCP_NODELAY | |
| security = user | |
| [sample_writeable] | |
| path = /srv/path | |
| public = yes | |
| browseable = yes | |
| valid users = youruser, anotheruser, etc |
| #!/usr/bin/env python | |
| import io | |
| import time | |
| import picamera | |
| import picamera.array | |
| import numpy as np | |
| from PIL import Image, ImageDraw | |