= Python = [[Mercurial]] == Parallelität mit joblib == {{{#!highlight python from joblib import Parallel, delayed Parallel(n_jobs=-1)(delayed(plot_all)(cg) for cg in cluster_groups) }}} == Liste von Dictionaries == {{{#!highlight python d = [] d.append({}) d[0].setdefault(bsl[0].split()[0],[]) }}} == Integer mit führender Null == {{{#!highlight python "%(a)02d" % {"a":1} }}} == Beautify log y-axis == {{{#!highlight python from matplotlib.ticker import FormatStrFormatter ... ax1.yaxis.set_major_formatter(FormatStrFormatter('%0.0f')) }}} == Reading GRIB == {{{#!highlight python gribs = pygrib.open('./forecast/GRIDHSTTESTA01+0000') for grib in gribs: print grib grib = gribs.select(name='Temperature')[0] # or grib = gribs.message(1) lats, lons = grib.latlons() }}} == Websites == http://www.johnloomis.org/python/ http://learnpython.pbworks.com/w/page/15956556/WebApplication http://www.astro.cornell.edu/staff/loredo/statpy/ http://mercurial.selenic.com/wiki/CGIinstall == CGIHTTPServer == {{{#!highlight sh python -m CGIHTTPServer }}} {{{#!highlight python import CGIHTTPServer import BaseHTTPServer class Handler(CGIHTTPServer.CGIHTTPRequestHandler): cgi_directories = ["/cgi-bin"] PORT = 8000 httpd = BaseHTTPServer.HTTPServer(("", PORT), Handler) print "serving at port", PORT httpd.serve_forever() }}} == Encoding == {{{ #!/usr/bin/env python # -*- coding: utf-8 -*- }}} == Plotting == {{{#!highlight python import matplotlib.pyplot as plt import numpy as n x=n.arange(-n.pi,n.pi,0.01) y=n.sin(x) plt.ylabel('sin(x)') plt.xlabel('x') plt.title('Sinus of x') plt.plot(x,y) plt.show() #plt.savefile('sinus_x.png') }}} == ScientificPython == [[http://dirac.cnrs-orleans.fr/plone/software/scientificpython|ScientificPython]] [[http://dirac.cnrs-orleans.fr/ScientificPython/ScientificPythonManual/|ScientificPythonManual]] [[http://scipy-central.org/]] == genutils == === statistics === {{{#!highlight python import genutil.statistics }}} http://www2-pcmdi.llnl.gov/cdat/source/api-reference/genutil.statistics.html === statusbar === {{{#!highlight python import genutil.statusbar prevall=0 previ=0 prevj=0 prevtxt=0 ni=100 nj=20 for i in range(ni): previ=statusbar(float(i)/ni,prev=previ,tk=1) for j in range(nj): prevj=statusbar(float(j)/nj,prev=prevj,tk=1) prevall=statusbar([float(i)/ni,float(j)/nj],prev=prevall,tk=1,title='Test') prevtxt=statusbar(float(j)/nj,prev=prevtxt,tk=None,title='Test') }}} == Cool modules == * PIL * pygrib * csv * ftplib * cgi * netrc * matplotlib