Posts tagged ‘Python’

Formlayout – an user-friendly way to interact

The online document is very simple but maybe too simple. It shows how to create a basic dialog WITHOUT tab, but formlayout in fact can do more, like building a tabbed dialog shown in the picture.

Continue reading ‘Formlayout – an user-friendly way to interact’ »

Python and pizza.py


Pizza.py is a post-processing tool package for lammps – a MD package. I downloaded it and unpacked in a local directory. Each time I have to start it with a command like “python -f abs_path/pizza.py” where the abs_path is the absolute path to pizza.py source directory. However this directory is very long on my computer and it’s not a directory recognized by python. I found a convenient way to make the call easier. Just add the abs_path to a system environment variable named “PYTHONPATH” (if you have no such env variable, create it), then to use pizza.py we can start python as usual by typing “python” and then type in “import pizza” (no .py suffix!), then we have all the module defined in pizza at the interactive command line no matter what is your current working directory. PYTHONPATH will be add to the search path for modules if it’s not empty. I also add the abs_path to the PATH system environment variable, which makes I could type “pizza.py -f ***.py” directly in any working directory.

Use PYTHONPATH environment variable to install a python
module without the need of root privilege. For example,
set
    PYTHONPATH=/path/to/my/lib/python2.2/site-packages/
and when installing a third party Python module, use
    python setup.py install --prefix=/path/to/my

Continue reading ‘Python and pizza.py’ »

逆向切分由Python zip函数合并的列表

Unzip a Python list.

This is cool!

Suppose that you have a list with tuples as the member.

1
>>> test = [('x',1), ('y',2), ('z',3)]

Continue reading ‘逆向切分由Python zip函数合并的列表’ »

免费Python IDE的首选

Python的集成开发环境不少,有商业的WingIDE(不要用它们那个缩水的免费版,没有语法提示),也有很多免费的。我使用过一些,现在直接告诉你最好用的。如果你不想自己费力气去测试你自己最喜欢的一款,那么请直接选择Eclipse+PyDev(各种平台)或者PyScripter(Windows平台)。它们不会让你失望,因为无论调试,语法加亮,自动提示,配色方案,外挂工具,命令行窗口,todo,帮助等功能一应俱全,而且免费!希望我的推荐可以省去您一点时间。如果哪位朋友发现更好的(综合品质),请推荐给我。

注,如果您还想偷懒,可以选用Python(x,y)集成软件包,许多科学计算相关的python工具已经被集成(如IPython),包括了上面提到的PyDev。里面还包含了一个作者自己开发的IDE,pydee,看起来也是很不错的(喜欢里面的帮助系统当然还有集成的IPython的优点),只是感觉没有自动完成功能,如果这个功能可以加入,pydee也是一个很好的选择。