cmdref.net - Command Reference

This site is command references for system engineers.

User Tools

Site Tools


Top     SiteMap

Sidebar

Top     SiteMap








Etc


Reference











.

programming:python:index.html



Programming Languages

Python

References

Documentation

Web Sites

Free Python PDF & Ebooks

etc

IDE & Text Editor

IDE

IDE Explanation
Python IDLE http://www.python.org/idle
PyScripter https://code.google.com/p/pyscripter/
Windows Only
PyCharm http://www.jetbrains.com/pycharm/
Cross-platform IDE
Customer List : HP, Twitter, Expedia, Apple, ebay, Linkedin, Symantec, GROUPON
Eclipse + PyDev http://pydev.org/
NetBeans + Python Plugin http://netbeans.org/
Get the Python Plugin for NetBeans IDE
Visual Studio Visual Studio + IronPython + Python Tools for Visual Studio

Text Editor

Editor Explanation
Vi/Vim
Emacs
Sublime Text
TextMate (Mac) http://macromates.com/


Web Framework

Framework Explanation
Django https://www.djangoproject.com/
Flask http://flask.pocoo.org/
Flask is a microframework for Python
Pyramid http://www.pylonsproject.org/projects/pyramid/
Bottle http://bottlepy.org/
Bottle is a fast, simple and lightweight WSGI micro web-framework for Python. It is distributed as a single file module and has no dependencies other than the Python Standard Library.
CherryPy http://www.cherrypy.org/
A Minimalist Python Web Framework


Template Engine

GUI Explanation
Jinja2 http://jinja.pocoo.org/
It is inspired by Django's templating system.
Mako http://www.makotemplates.org/


GUI

GUI Explanation
wxPython http://www.wxpython.org/ wxPython
Applications Developed with wxPython
BitTorrent, Dropbox, Google Drive, Bittorrent, gui2py, wxGlade
PySide http://qt-project.org/wiki/PySide PySide
PyQt http://qt-project.org/ PyQt
PyGTK
pyFLTK
tkinter
GUI in Python? wxPython?
I've used both wxPython and PyQt for simple apps. I started with wxPython because the documentation made it very easy to learn.
If you're new to programming GUI's or you just need to get stuff done quickly the wxPython Examples are amazing. The wiki also has a lot of examples, tutorials and how-to's. The PyQt documentation is much less satisfying for beginners in my opinion - it's light on examples and how-to's and heavy on API documentation.

http://www.reddit.com/r/Python/comments/1p1gjf/gui_in_python_wxpython/


SmartPhone

Smart Phone Explanation
SL4A
QPython


Module

Module Explanation
Python for Windows Extensions http://sourceforge.net/projects/pywin32/
Pexpect http://sourceforge.net/projects/pexpect/




Installing Python

Grammar

# coding: utf-8
or
# -*- coding: UTF-8 -*-

Comment

# comment1 one line

# comment multiple lines
'''
print "comment 1"
print "comment 2"
'''

Import Library

import math

print

# Python2
print 'Hello world'
print 'hoge', 'moge', 'fuga'
print >>sys.stderr, 'nurupo'    #standard error

# Python3
print('Hello world')
print('hoge', 'moge', 'fuga')
print('nurupo', file=sys.stderr)    #standard error

input

raw_input()
input()

Variables

a = 1
a = 'hoge'

num = 1
num = 3.14
num = 1 + 1j

num = 1 + 1    # 2 
num = 1 - 1    # 0
num = 1 * 2    # 2
num = 5 / 2    # 2
num = 5.0 / 2  # 2.5
num = 5 % 2    # 1
num = 2 ** 3   # 8


Lists

a = [1, 2, 3, 4, 5]
for n in a:
    print n

a1 = a[0]    #1


tuple


dict

d = {'RHEL': 6.5, 'Windows': 7, 'iOS': 8}

d1 = d['RHEL']

for k, v in d.items():
    print k, v

for k in d.keys():
    print k, d[k]

for v in d.values():
    print v

for k, v in d.iteritems():
    print k, v          


Conditionals

if

if lines is not None:
    print 'true'

if else

if condition:
    print 'true'
else:
    print 'false'

if elif

if condition1:
    print 'if1'
elif condition2:
    print 'if2'

while

i = 0
while i < 5:
    i += 1

for

for i in [0, 1, 2, 3, 4]:
    print i

while-else

i=1
while i <= 0:
    i += 1
else:
    print 'else'

i=1
while i:
    i += 1
    if i>10:
        break
else:
    print 'else'

for-else

for i in ['hoge', 'moge', 'fuga']:
    print i
else:
    print 'else'


Function

def add1(num1, num2):
    return num1 + num2

lambda

add2 = lambda x, y: x + y
add2(1, 2) # 3


File Input/Output

orig = open('orig.txt')
copy = open('copy.txt', 'w')
for line in orig:
    copy.write(line)

orig.close()
copy.close()


args

import sys
 
argvs = sys.argv  # list
argc = len(argvs) # number of args

print argvs
print argc
print argvs[1]




programming/python/index.html.txt ยท Last modified: 2017/12/02 by admin