Förvillelser
link

bpython is a fancy interface to the Python interpreter for Unix-like operating systems (I hear it works fine on OS X). It is released under the MIT License. It has the following features:

  • In-line syntax highlighting.
  • Readline-like autocomplete with suggestions displayed as you type.
  • Expected parameter list for any Python function.
  • “Rewind” function to pop the last line of code from memory and re-evaluate.
  • Send the code you’ve entered off to a pastebin.
  • Save the code you’ve entered to a file.
  • Auto-indentation.
  • Python 3 support.

link

Python.

Plumbum was born to fill this very gap: on the one hand, be pythonic (and be backed by strong libraries), and on the other, make it all as easy and one-liner-ish by nature: use a real programming language, with a well-behaved object model and high level concepts, to achieve what you’d normally do in a shell script, with the same expressive power and wrist-handiness of the shell. I call it shell combinators, as they mimic shell syntax, but keep you pythonic.

Plumbum is actually a collection of utilities that I wrote for several separate projects, but the time has come to consolidate them into a single, production-grade library. The library provides local and remote program execution, with support for piping and IO redirection; local and remote file-system path abstraction; a programmatic command-line interface (CLI) toolkit, and numerous other utilities.

Exempel:

from plumbum import local
from plumbum.cmd import wc, ls, echo, grep
from plumbum.utils import copy, delete

delete(local.cwd // "*/*.pyc")

for fn in local.cwd / "src" // "*.py":
print wc("-l", fn)

num_of_src_lines
= (ls["-l"] | grep["\\.py"] | wc["-l"])()
echo["1"] > "/proc/sys/net/ipv4/ip_forward")()
link

docopt – pythonic option parser, that will make you smile

You know what’s awesome? It’s when the option parser is generated based on the help and usage-message that you write in a docstring!

"""

Usage: program.py [options] arguments

Options:

-h --help show this help message and exit

-v --verbose print status messages

-q --quiet report only file names

-r --repeat show all occurrences of the same error

--exclude=patterns exclude files or directories which match these comma separated patterns [default: .svn,CVS,.bzr,.hg,.git]

--filename=patterns when parsing directories, only check filenames matching these comma separated patterns [default: *.py]

--select=errors select errors and warnings (e.g. E,W6)

--ignore=errors skip errors and warnings (e.g. E4,W)

--show-source show source code for each error

"""

from docopt import docopt

def main(options, arguments):

   pass # ...

if __name__ == '__main__':

   # parse options based on docstring above

   options, arguments = docopt(__doc__)

   main(options, arguments)

(Source: reddit.com)

link

Report from the Python language summit at PyCon.

Guido van Rossum

link
Uppdatering av lolguides

Har donat lite med backenden för lolguides.net ikväll. Mycket skönt. Har äntligen fått insamlingsdelen trådad. Har även lyckats pilla till lite ny funktionalitet, det är nu enkelt att lägga till små notiser (olika eller likadana för index och champsidor).

Uppdatering: Glad att jag använder bootstrap2

link

Scrapy is a fast high-level screen scraping and web crawling framework, used to crawl websites and extract structured data from their pages. It can be used for a wide range of purposes, from data mining to monitoring and automated testing.

Skulle kunna vara ett lite mer rigid alternativ till BeautifulSoup för lolguides.net kanske?

link

PBS is a unique subprocess wrapper that maps your system programs to Python functions dynamically. PBS helps you write shell scripts in Python by giving you the good features of Bash (easy command calling, easy piping) with all the power and flexibility of Python.

Ser väldigt smidigt ut.

import pbs
print pbs.ifconfig("eth0")

# resolves to "curl http://duckduckgo.com/ -o page.html --silent" pbs.curl("http://duckduckgo.com/", o="page.html", silent=True)

# print the number of folders and files in /etc print pbs.wc(pbs.ls("/etc", "-1"), "-l")

# sudo
with pbs.sudo: print pbs.ls("/root")

link

by Allen B. Downey

Buy this book from Amazon.com.

Download this book in PDF.

Read this book online.

Description

This book is about complexity science, data structures and algorithms, intermediate programming in Python, and the philosophy of science:

  • Data structures and algorithms: A data structure is a collection that contains data elements organized in a way that supports particular operations. For example, a dictionary organizes key-value pairs in a way that provides fast mapping from keys to values, but mapping from values to keys is generally slower.

    An algorithm is a mechanical process for performing a computation. Designing efficient programs often involves the co-evolution of data structures and the algorithms that use them. For example, the first few chapters are about graphs, a data structure that is a good implementation of a graph—-nested dictionaries—-and several graph algorithms that use this data structure.

  • Python programming: This book picks up where Think Python leaves off. I assume that you have read that book or have equivalent knowledge of Python. As always, I will try to emphasize fundmental ideas that apply to programming in many languages, but along the way you will learn some useful features that are specific to Python.
  • Computational modeling: A model is a simplified description of a system that is useful for simulation or analysis. Computational models are designed to take advantage of cheap, fast computation.
  • Philosophy of science: The models and results in this book raise a number of questions relevant to the philosophy of science, including the nature of scientific laws, theory choice, realism and instrumentalism, holism and reductionism, and Bayesian epistemology.

link

Another static site generator?

With the ever growing population of static site generators, all filling a certain need, I’ve yet to find one that allows the generation of anything but the simplest of blogs.

That’s where mynt comes in, being designed to give you all the features of a CMS with none of the often rigid implementations of those features.

Highlights
  • Multiple ways of getting posts how you want, whether ordered by year and month, or by tag.
  • Automatic generation of common pages such as those for archives and tags.
  • Freedom in the markup language and rendering engine used.

    link

    Python is a wonderful language, but some parts should really have bright WARNING signs all over them. There are features that just can’t be used safely and others are that are useful but people tend to use in the wrong ways.

    link

    Ett helgprojekt som blev bättre än väntat. Lolguides.net är en sida som samlar de högst betygsatta och nyaste guidera för gratisspelet League of Legends.

    Tekniskt sett är lösningen egentligen inte så intressant. Ett pythonprogram samlar in data från solomid.net och clgaming.nets guider och skapar en JSON-dump. Ett annat pythonprogram kör sedan och skapar alla htmlsidor utifrån datan.

    Uppdatering: Jag har skapat en Google+ sida för siten, där kommer det postas nyheter om och kring siten och utveckling.

    link
    GothPyCon 2011

    IT universitetet

    Patricia Building, Göteborg (map)

    Schema till lördag, 29 oktober/ Schedule for Saturday, 29 October

    * Start at 09.30

    - Andrew Dalke, on Python’s other built-in data structures (~45 min)
    - Geoff Bache on the impact of GUI changes on tests (~45 min)

    * coffee break (around 11.30)

    - Niklas Gustavsson, on Spotify’s architecture (~45 min)

    * Lunch (around 12.30)

    - Armin Rigo on PyPy (~45 min)
    - Open discussion on “The tools you use” (~30 min)
       I’ll have a set of topics about IDEs, testing,
       profiling, networking libraries, etc. and let
       people give feedback about the tools they use
       or want to use.

    * coffee break (around 15.00)


    - Open Space; let’s do some coding!
      o Olof has offered to work with a group on programming
        with Sikuli
      o Feel free to present your own group idea and get
        others in on the fun. Ideas might be to try out pypy
        or get started with ZeroMQ.

    GothPyCon

    link

    Exempel i Python, Tcl och C.

    link
    Marc fornes & Theverymany har många fina former att visa upp. Rhino + Python.

    Marc fornes & Theverymany har många fina former att visa upp. Rhino + Python.