在注册或更改密码表单中,确保用户提供密码的最佳方法是什么?
我有一个想法(在python中)
def validate_password(passwd):
conditions_met = 0
conditions_total = 3
if len(passwd) >= 6:
if passwd.lower() != passwd: conditions_met += 1
if len([x for x in passwd if x.isdigit()]) > 0: conditions_met += 1
if len([x for x in passwd if not x.isalnum()]) > 0: conditions_met += 1
result = False
print conditions_met
if conditions_met >= 2: result = True
return result
Run Code Online (Sandbox Code Playgroud) 这是Python中的一个好习惯(来自Active State Recipes - Public Decorator)吗?
import sys
def public(f):
"""Use a decorator to avoid retyping function/class names.
* Based on an idea by Duncan Booth:
http://groups.google.com/group/comp.lang.python/msg/11cbb03e09611b8a
* Improved via a suggestion by Dave Angel:
http://groups.google.com/group/comp.lang.python/msg/3d400fb22d8a42e1
"""
all = sys.modules[f.__module__].__dict__.setdefault('__all__', [])
if f.__name__ not in all: # Prevent duplicates if run from an IDE.
all.append(f.__name__)
return f
public(public) # Emulate decorating ourself
Run Code Online (Sandbox Code Playgroud)
一般的想法是定义一个装饰器,它接受一个函数或类,并将其名称添加到__all__当前模块的名称.
是否有一个python库,它采用wikitext(在mediawiki中使用)输入并将其转换为markdown?
我正在尝试使用Sphinx来记录项目,但我无法弄清楚如何使用intersphinx.我用这行:
:py:meth:`math.sin`
Run Code Online (Sandbox Code Playgroud)
添加链接,但在输出中,它显示为粗体,而不是链接.虽然该行不起作用,但以下两者都有效:
:py:meth:`dict.items`
:py:class:`zipfile.ZipFile`
Run Code Online (Sandbox Code Playgroud)
我在conf.py文件中的intersphinx_mapping值是:
intersphinx_mapping = {'python':('http://docs.python.org/2.7', None)}
Run Code Online (Sandbox Code Playgroud) 无论如何,有没有办法从 gdb 中的 corefile 中发现 PyObject* 的 python 值
python ×4
algorithm ×1
coding-style ×1
markdown ×1
mediawiki ×1
passwords ×1
python-c-api ×1
security ×1