我没有找到jinja2和Mako的良好比较.你会用什么来完成什么任务?
我个人很满意mako(在一个pylons网络应用程序环境中),但我很想知道jinja2是否有一些很好的功能/改进mako不? - 或者可能是缺点? -
我想从应用程序启动psql.exe.用户找到脚本,因此它可以在他的磁盘上的任何位置,并且应用程序只是将该脚本提供给psql.就是这样.
什么是正确的命令行?
我试过这个没有成功
"C:\Program Files\PostgreSQL\9.1\bin\psql.exe" TEST SYSADM -f "C:\Documents and Settings\Administrateur\Mes documents\TD6.0\FETCHING\install.sql"
Run Code Online (Sandbox Code Playgroud)
我尝试使用引号,没有引号,没有工作,只是忽略了参数(在cmd.exe上试过)
C:\Documents and Settings\Administrateur>"C:\Program Files\PostgreSQL\9.1\bin\psql.exe" TEST SYSADM -f "C:\Documents and Settings\Administrateur\Mes documents\TD6.0\FETCHING\install.
sql"
psql: warning: extra command-line argument "-f" ignored
psql: warning: extra command-line argument "C:\Documents and Settings\Administrateur\Mes documents\TD6.0\FETCHING\install.sql" ignored
Password for user SYSADM:
Run Code Online (Sandbox Code Playgroud)
是的,如果脚本与psql.exe位于同一目录中,并且如果我首先将CD安装到安装psql.exe的位置,则表示没有引号,没有绝对路径,并且它可以正常工作.但是,在我的情况下,我希望应用程序可以在任何Windows安装上工作,这意味着psql.exe可以在任何地方,sql脚本也可以在任何地方.我仍然希望将脚本提供给psql.exe.
我正在研究我的第一个挂架+ SQLAlchemy应用程序(我是两个都是新手).
当我改变对表结构的看法时,我希望有一个类似于metadata.create_all()的函数,它检查是否有新的列定义并在数据库中创建它们.
这样的功能存在吗?
来自问题为什么或者更确切地说对象.__ new__在这两种情况下的工作方式不同
作者对其原因不感兴趣,而是对其如何感兴趣.
我非常想了解原因,特别是:
为什么不object.__init__打印参数而不是object.__new__ (in testclass1)
为什么没有为testclass3引发错误?(因为除了自我之外不需要任何参数)
码
>>> class testclass1(object):
... pass
...
>>> class testclass2(object):
... def __init__(self,param):
... pass
...
>>> a = object.__new__(testclass1, 56)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: object.__new__() takes no parameters
>>> b = object.__new__(testclass2, 56)
>>> b
<__main__.testclass2 object at 0x276a5d0>
>>> class testclass3(object):
... def __init__(self):
... pass
...
>>> c = object.__new__(testclass3, 56)
>>> c
<__main__.testclass3 object at 0x276a790> …Run Code Online (Sandbox Code Playgroud) 会发生的是,如果您的代码引发运行时异常并且您的完成不起作用,您就不知道为什么因为没有打印回溯.试试这个非常短的代码来看看我的意思:程序应该在c = 2 +"ddda"上崩溃,显然你要添加一个字符串和一个int,这根本不起作用.但是不是崩溃,而是异常被抓住了,你不知道发生了什么.该程序继续运行,好像什么也没发生.
import cmd
class App(cmd.Cmd):
def complete_foo(self,*arg):
# Uncommenting this line will silently crash the progrm
# making it hard to debug.
# Is there a way to force the program to crash ?
c = 2 + "ddda"
return "d dzpo idz dza dpaoi".split(" ")
def do_foo(self,*args):
print "foo"
App().cmdloop()
Run Code Online (Sandbox Code Playgroud)
我的问题是:当有错误时如何显示错误?(使用cmd模块时).
是否可以将ListBoxes放在SimpleListWalkers中?我正在尝试制作嵌套的ListBoxes,但是我有这个错误:
AttributeError: 'MyListBox' object has no attribute 'rows'
import urwid
class MyListBox(urwid.ListBox):
def focus_next(self):
try:
self.body.set_focus(self.body.get_next(self.body.get_focus()[1])[1])
except:
pass
def focus_previous(self):
try:
self.body.set_focus(self.body.get_prev(self.body.get_focus()[1])[1])
except:
pass
def handle_input(event):
frame.header.set_text("key pressed %s" % event)
if event == "q":
raise urwid.ExitMainLoop
elif event == "up":
lb.focus_previous()
elif event == "down" :
lb.focus_next()
widgets = [urwid.AttrMap(urwid.Text(str(x)),None,"focus") for x in xrange(3)]
nested = [urwid.AttrMap(urwid.Text(str(x)+"_sous"),None,"focus") for x in xrange(3)]
nested_lb = MyListBox(urwid.SimpleListWalker(nested))
lb = MyListBox(urwid.SimpleListWalker(widgets+[nested_lb]))
frame = urwid.Frame(lb,header=urwid.Text("Header"))
palette = [("focus","dark cyan","white")]
loop = urwid.MainLoop(frame,palette,unhandled_input = handle_input) …Run Code Online (Sandbox Code Playgroud) 此代码仅水平居中,如何使进度条也垂直居中?
import Tkinter
import ttk
root = Tkinter.Tk()
root.geometry("=500x500")
root.progressbar = ttk.Progressbar(root)
root.progressbar.pack(anchor=Tkinter.CENTER)
root.mainloop()
Run Code Online (Sandbox Code Playgroud)
想补充一下 GD zip扩展到php,完成了phpize ./configure make make install例程,还是找不到 GD压缩.任何的想法 ?
root@audio-mon[10.10.10.82] ~/DOWNLOADS/php-5.5.23/ext/zip # phpize
Configuring for:
PHP Api Version: 20121113
Zend Module Api No: 20121212
Zend Extension Api No: 220121212
root@audio-mon[10.10.10.82] ~/DOWNLOADS/php-5.5.23/ext/zip # ./configure
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking …Run Code Online (Sandbox Code Playgroud)