Stack Overflow - Why does Python print unicode characters when the default encoding is ASCII?
# encoding: utf8 | |
# 什么是lambda函数?它有什么好处?另外python在函数式编程方面提供了些什么函数和语法? | |
# - lambda 就是匿名函数 | |
# - 好处: 可以动态生成一个函数对象,不用给这个对象命名,污染名字空间 | |
# - 函数:map()/filter() | |
# - 语法:可以函数内部定义函数,闭包支持 | |
# 详细说说tuple、list、dict的用法,它们的特点; | |
# - tuple 固定长度的子项不可变的顺序型容器,一般用来做常量(策划配表)或者表示少量属性的对象(比如pos)表示 |
"""Simple TCP server for playing Tic-Tac-Toe game. | |
Use Player-to-Player game mode based on naming auth. | |
No thoughts about distribution or pub/sub mode | |
(for monitoring or something like this). Just | |
basic functionality. | |
""" | |
import time | |
import logging |
The Python unit testing framework, sometimes referred to as “PyUnit”.
unittest
supports test automation, sharing of setup and shutdown code for tests, aggregation of tests into collections, and independence of the tests from the reporting framework. The unittest module provides classes that make it easy to support these qualities for a set of tests.
To achieve this, unittest supports some important concepts:
- test fixture
- A test fixture represents the preparation needed to perform one or more tests, and any associate cleanup actions. This may involve, for example, creating temporary or proxy databases, directories, or starting a server process.
- test case
~/P/m/h/services python run.py | |
test_get_session (__main__.SoapServices) ... ok | |
test_get_token (__main__.SoapServices) ... ok | |
test_CompleteReturnRequest (__main__.SoapServices) ... ok | |
test_ReturnTransactionRequest (__main__.SoapServices) ... ok | |
test_UserInfoRequest (__main__.SoapServices) ... ok | |
test_RefundRequest (__main__.SoapServices) ... ok | |
test_StartTransactionRequest (__main__.SoapServices) ... ok | |
test_ReturnTransactionRequest (__main__.SoapServices) ... ok |
If you want a run-down of the 1.3 changes and the design decisions behidn those changes, check out the LonestarElixir Phoenix 1.3 keynote: https://www.youtube.com/watch?v=tMO28ar0lW8
To use the new phx.new
project generator, you can install the archive with the following command:
$ mix archive.install https://github.com/phoenixframework/archives/raw/master/phx_new.ez
Phoenix v1.3.0 is a backwards compatible release with v1.2.x. To upgrade your existing 1.2.x project, simply bump your phoenix dependency in mix.exs
:
If you want a run-down of the 1.3 changes and the design decisions behidn those changes, check out the LonestarElixir Phoenix 1.3 keynote: https://www.youtube.com/watch?v=tMO28ar0lW8
To use the new phx.new
project generator, you can install the archive with the following command:
$ mix archive.install https://github.com/phoenixframework/archives/raw/master/phx_new.ez
Phoenix v1.3.0 is a backwards compatible release with v1.2.x. To upgrade your existing 1.2.x project, simply bump your phoenix dependency in mix.exs
:
# -*- coding: utf-8 -*- | |
import asyncio | |
import re | |
import asyncio_redis | |
import tornado.concurrent | |
import tornado.httpclient | |
import tornado.web | |
import tornado.platform.asyncio |
""" | |
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy) | |
BSD License | |
""" | |
import numpy as np | |
# data I/O | |
data = open('input.txt', 'r').read() # should be simple plain text file | |
chars = list(set(data)) | |
data_size, vocab_size = len(data), len(chars) |