随笔分类 - Python
摘要:原文地址:http://www.cnblogs.com/pumaboyd/archive/2008/08/11/1265416.html红色的为标注信息+++++++++++++++++引用+++++++++++++++++++++>PY提供INI配置文件的操作关于配置文件,很直观的感觉就是XML文件。对于XML文件的使用大家还是很喜欢的。但有时候只是简单的一个程序,实现一个简单的name:value关系。用XML文件就没这个必要。这种要求很符合MS的INI文件格式。所以这里主要介绍一下对INI文件的操作方式,而且最近写的第一个PY应用程序也是使用了INI什么是INI 文件PY所支持的I
阅读全文
摘要:I spent several days on building a system about this. And make it work well with serveral thousand lines of codes.
阅读全文
摘要:先说说思路一、安装这些东西,tornado, supervisor( sudo pip install supervisor 在linux 系统上), 安装 nginx (sudo apt-get install nginx -y)二、让supervior 和 已经写好的tornado 服务挂钩用supervisor 来管理服务和进程在命令行里面使用。然后,再在 supervisord.conf 最后面添加这几行这里tornado center.py 的本地服务地址是8100,写在center.py 文件里面了。当然为了标准,我们可以添加这几行在这里面,用来产看进程id,还有进程log(uni
阅读全文
摘要:题外话: 这里分享一个链接是将Flask 和 Apache 用 mod_wsgi 来进行传唤的部署方式,在digital ocean VPS 上的。https://www.digitalocean.com/community/articles/how-to-deploy-a-flask-application-on-an-ubuntu-vps挺不错的。但是对于tornado 来说,我们最好是采用tornado 和 nginx,因为“Tornado 对WSGI只提供了有限的支持,即使如此,因为 WSGI 并不支持非阻塞式的请求,所以如果你使用 WSGI 代替 Tornado 自己的 HTTP 服
阅读全文
摘要:原文这里有显示地址:http://zhou123.blog.51cto.com/4355617/1312791现在摘取一部分:这里介绍一下python执行shell命令的四种方法:1、os模块中的os.system()这个函数来执行shell命令123>>> os.system('ls')anaconda-ks.cfg install.log install.log.syslog send_sms_service.py sms.py0注,这个方法得不到shell命令的输出。2、popen()#这个方法能得到命令执行后的结果是一个字符串,要自行处理才能得到想要的
阅读全文
摘要:在tornado 里面这样用看看logging.warning() , logging.info() , 我们非常想用 zdaemon , 和 logging 将对系统的所有访问转换到服务器里面,作为日志。让我们看看目录树。transaction.py 是tornado服务看一下 testpage1handler@require_basic_authclass TestPage1Handler(BaseHandler): """This is a test page to show the asker's utmost parent's all d
阅读全文
摘要:现在,我们用torndo做web开发框架,用他内部机制来处理HTTP请求。传说中的非阻塞式服务。整来整去,可谓之一波三折。可是,无论怎么样,算是被我做成功了。在tornado服务上,采用三种数据库模型--》1)torndb2)django model3)SQLAlchemy model 都同时输出相应的JSON,做API服务。(一个比一个强大的ORM model)都同时实现了一样的功能注意:要说明的一点是,在数据库建立模型的时候,是用到的django model建立的数据库模型。所以在使用torndb(SQL 操作语言的ORM) 和 django model的时候,非常简单操作,直接引用...
阅读全文
摘要:django的模型from django.db import models""" A model pair to map car and its manufacturer"""class Manufacturer(models.Model): brand = models.CharField(max_length=100) location = models.CharField(max_length=100) def __unicode__(self): return self.brand class Meta: ordering =
阅读全文
摘要:django User model operationthis tutorial will guide us to know how to manipulate django User model.Read User object derived from databasefrom django.contrib.auth.models import User# Those two lines are different even if there is only one user 'admin' who registered beforeauser = User.objects
阅读全文
摘要:Here I got a very neat plugin for vim which is awesome indeed.It's from youtube years before.So let's check this out. :)http://www.youtube.com/watch?v=67OZNp9Z0CQ&noredirect=1you can download the reference tools here: https://github.com/klen/python-mode#how-to-installSomeone mentioned ab
阅读全文
摘要:Read by linux/GNU commandsLet's follow and start from here:http://django-tastypie.readthedocs.org/en/latest/tutorial.html#creating-resourcesAccording to tastypie's concept, Tastypie properly handles the Accept header.So we can use linux/GNU commands to do some fancy things!Bash script to get
阅读全文
摘要:tastypie is a good thing.Haven't test it thoroughly. Gonna need some provement.Now I will introduct how to use tastepie for newbies.Let me introduce all the equipments I have to deploy tastypie.1) linuxmint 132) virtualenv ( sudo apt-get install python-virtualenv )3) install django==1.5 in the v
阅读全文
摘要:Its one of the primary authors' lecture on pyCon: http://www.youtube.com/watch?v=Zv26xHYlc8s&noredirect=1What is Tastypie A REST framework for django Designed for extension Supports both Model & non-Model datafor more information, please visit http://tastypieapi.org1) make good use of HT
阅读全文
摘要:dango, 怎么说呢,什么东西都内置了,什么东西都是自己的东西。用过flask, cherrypy, web.py, pyramid 等等python 框架后,再选用dango 觉得,理念有很大的区别。藏着掖着的嫌疑比较大,高度封装,但是操作起来貌似省事情。时间久了会不会python的标准库不知道怎么用了,呵呵~这里一些简单的资料也许挺有用的。http://django-chinese-docs.readthedocs.org/en/latest/intro/tutorial01.htmlhttp://django-chinese-docs.readthedocs.org/en/latest
阅读全文
摘要:http://kivy.org/docs/api-kivy.uix.gridlayout.html?highlight=gridlayout#kivy.uix.gridlayoutIt's so nice to try this one:from kivy.app import Appfrom kivy.uix.gridlayout import GridLayoutfrom kivy.uix.label import Labelfrom kivy.uix.textinput import TextInputfrom kivy.uix.button import Buttonclass
阅读全文
摘要:Now that you've successfully coded an app. Now you want to deploy it to Android.So now we would need to have a look of this, from its official site:http://kivy.org/docs/guide/packaging.htmlLet's check this out.Mainly for Android .http://kivy.org/docs/guide/packaging-android.htmllet's do
阅读全文
摘要:http://kivy.org/docs/guide/basic.html#quickstartI followed this tutorial about how to create basic kivy application*********************Creating a kivy application is as simple as:sub-classing theAppclassimplementing itsbuild()method so it returns aWidgetinstance (the root of your widget tree)instan
阅读全文
摘要:Let's talk about kivy's EventDispatcher here:The codes I have tried here:codes here:from kivy.event import EventDispatcherclass MyEventDispatcher(EventDispatcher): def __init__(self, **kwargs): self.register_event_type('on_test') super(MyEventDispatcher, self).__init__(**kwargs) ...
阅读全文
摘要:[转]python普通继承方式和super继承方式原文出自:http://www.360doc.com/content/13/0306/15/9934052_269664772.shtml原文的错误,已经被我修改掉了。普通继承:class FooParent(object): def __init__(self): self.parent='Im the parent.' print 'Parent' def bar(self, message): print message, 'from Parent'class FooChild(Foo...
阅读全文
摘要:Python tips: 什么是*args和**kwargs?原文地址:http://www.cnblogs.com/fengmk2/archive/2008/04/21/1163766.html先来看个例子:def foo(*args, **kwargs): print 'args = ', args print 'kwargs = ', kwargs print '---------------------------------------'if __name__ == '__main__': foo(1,2,3,4) fo
阅读全文

浙公网安备 33010602011771号