In Python 2.6 (or earlier), use the dict constructor:
d = dict((key, value) for (key, value) in sequence)
In Python 2.7+ or 3, you can just use the dict comprehension syntax directly:
d = {key: value for (key, value) in sequence}
# | |
# The image server | |
# | |
proxy_cache_path /tmp/nginx-images-cache/ levels=1:2 keys_zone=images:10m inactive=24h max_size=100m; | |
upstream image_8083 { | |
server 127.0.0.1:8083 max_fails=3 fail_timeout=2s; | |
} |
# REF: http://www.quora.com/How-do-I-create-and-update-embedded-documents-with-MongoEngine | |
class Comment(EmbeddedDocument): | |
content = StringField() | |
name = StringField(max_length=120) | |
class Post(Document): | |
title = StringField(max_length=120, required=True) | |
author = StringField(required=True) |
In Python 2.6 (or earlier), use the dict constructor:
d = dict((key, value) for (key, value) in sequence)
In Python 2.7+ or 3, you can just use the dict comprehension syntax directly:
d = {key: value for (key, value) in sequence}
<style TYPE="text/css"> | |
<!-- | |
#go-to-top { | |
display: none; | |
position: fixed; | |
right: 60px; | |
bottom: 100px; | |
padding: 18px; | |
color: #666; |