Created
January 22, 2016 15:46
-
-
Save guyskk/8ae152653220800e9b9a to your computer and use it in GitHub Desktop.
被注释掉的语句都是会报错的
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
#!/usr/bin/env python | |
# coding: utf-8 | |
from __future__ import unicode_literals, absolute_import, print_function | |
k1 = 'v1' | |
k2 = 'v2' | |
module_items = locals() | |
module_keys = ['k1', 'k2'] | |
# print({k: locals()[k] for k in module_keys}) | |
print({k: module_items[k] for k in module_keys}) | |
class MyClass(object): | |
key1 = 'value1' | |
key2 = 'value2' | |
items = locals() | |
print(items) | |
keys = ['key1', 'key2'] | |
# print({k: locals()[k] for k in keys}) | |
# print({k: items[k] for k in keys}) | |
print(dict([(k, items[k]) for k in keys])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment