background preloader

Python

Facebook Twitter

Drawing

Working with virtualenv — Arthur Koziel. SingleFileExecutable - py2exe.org. The "extending" example that comes with Py2Exe shows a nicely integrated approach for using Inno Setup to create single file executables. This example isn't so nicely integrated, but it uses NSIS instead of Inno Setup in case you prefer that. Drop a copy of this script in your source directory alongside setup.py and modify the first two lines. The first points to py2exe's output directory and the second is the name of the executable in that directory as well as the name of the executable that NSIS will create. You can also select compression behavior - NSIS' LZMA compression (based on 7-Zip) is pretty impressive - wxPython applications start at about 3.5 - 4 MB instead of 10 - 12 MB.

Once you've built your executable with py2exe, then compile the installer script with NSIS and an executable will be created in the same folder as the script. Command line parameters for your executable are not supported. The executables produced have only been tested on Windows XP. Jimmy Retzlaff setup.nsi: ! Pycron. Pycron Instructions A good introductory article about pycron can be found at "This article will discuss using a Cron type system, as used on Unix and Linux systems, to bring the flexibility, scalability and a need for more out of a task automation tool, to the Win32 environment. " pycron is a cron service written in Python converted to an executable with py2exe. It's a successor to cron with a couple of changes and extensions: New in version 0.5: rotating log file (pycron.log pycron.log.1 pycron.log.2 - each max. 100k) output of process id in log file (except python scripts) support of environment variables in commands (e.g.

Download Please follow the link to download the Setup program. Setup as a service copy the included file crontab.txt.sample to crontab.txt and change it to your needsgo to the service manager and change the "Python Cron Service" options The crontab.txt file Each line of CRONTAB.TXT has the following structure: Comments character '? ' ? Juno: A Lightweight and Simple Web Framework. EasyExtend. Abstract EasyExtend is a constructive approach to extend the Python language using pure Python. EasyExtend is developed as a Python framework depending only on tools provided by the CPython interpreter suite ( compiler ) and standard library as well as some pieces of code borrowed from the PyPy project.

Opposite to toolkits for writing extension modules in C ( or RPython in future ) the EasyExtend framework is dedicated to extend the language itself by adding new grammar rules and transformation of parse trees. Acting directly on the nodes of syntax trees makes EasyExtend safe and extensible. Overview 0. How to find the source tree and what it contains. 1. Explains the very basics of EE - the world of CST surgery. 2. We need to label our extensions. 3. Starting an interactive console cooperating with your fibers definitions should work immediately. 4. ...you write testcases and accessible documentation ( even if it is *bad* english ;) and... 0. C:\Python24\EE\Fibers\coverage\test>python .. Ruby/Python Documentation. $B$O$8$a$K(B Ruby/Python $B$H$O(B? Ruby/Python$B$O(BRuby$B$K(BPython$B%$%s%? %W%j%? $r%i%$%V%i%j$H$7$FKd$a9~$s$G$7$^(B $B$&!

"(BRuby $B$N3HD%%i%$%V%i%j$G$9! Ruby/Python $B$OFs$D$N8@8l$r=PMh$k8B$jF)2aE*$K7R$2$k$h$&$K:n$i$l$F$$$^(B $B$9! $B4JC1$JNc(B $B$^$:4JC1$JNc$H$7$F(Bftplib$B$r;HMQ$7$F! " require 'ftplib' ftp = FTP.open('ftp.netlab.co.jp') ftp.login ftp.chdir('pub/lang/ruby') puts ftp.dir ftp.quit Ruby$B$r;H$&$HHs>o$K4JC1$K=q$1$^$9$M! Require 'python' require 'python/ftplib' ftp = Py::Ftplib::FTP.new('ftp.netlab.co.jp') ftp.login ftp.cwd('pub/lang/ruby') ftp.dir ftp.quit $B:G=i$NNc$HHf$Y$F8+$F$/$@$5$$! $BMQ8l(B $B$3$N%I%-%e%a%s%H$G$O(BRuby$B$H(BPython$B$H$$$&(B2$B$D$N8@8l$K4X$9$k$3$H$,=q$+$l$F(B $B$$$^$9! Ruby/Python $B$3$N3HD%%i%$%V%i%j$=$N$b$N(B Ruby$B%*%V%8%'%/%H(B Ruby$B%$%s%?

Python$B%*%V%8%'%/%H(B Python$B%$%s%? Ruby$B%b%8%e! Ruby$B>e$GDj5A$5$l$? Python$B%b%8%e! Python$B>e$GDj5A$5$l$?! " Ruby$B%/%i%9(B Ruby$B>e$GDj5A$5$l$? Python$B%/%i%9(B Python$B>e$GDj5A$5$l$? Python packaging: a few observations, cabal for a solution ? « Nothing to say. The python packaging situation has been causing quite some controversy for some time. The venerable distutils has been augmented with setuptools, zc.buildout, pip, yolk and what not. Some people praise those tools, some other despise them; in particular, discussion about setuptools keeps coming up in the python community, and almost every time, the discussion goes nowhere, because what some people consider broken is a feature for the other.

It seems to me that the conclusion of those discussions is obvious: no tool can make everybody happy, so there has to be a system such as different tools can be used for different usage, without intefering with each other. The solution is to agree on common format and data/metadata, so that people can build on it and communicate each other.

You can find a lot of information on people who like setuptools/eggs, and their rationale for it. A good summary, with a web-developer POV is given by Ian Bicking. Distutils limitation Fragile extension system. College: Computer Science: PIL (Python Imaging Library) PIL (aka the Python Imaging Library) is used in many of the Carleton College Intro CS courses. NOTE: PIL is NOT available for Python 3. This page contains installation instructions for Python 2.x: WINDOWS XP and Vista and 7: The latest downloads of PIL for windows can be found at the current release: click on the downloaded executable. Enthought Download the installer: the installer and follow the instructionsRun Canopy onceYour python shell should now be using Enthought's version of python.

If you want to investigate other options talk to Mike Tie, or look at MacPorts If you have any questions about installing PIL for Windows, Mac, or any other operating system, please contact Michael Tie (mtie@carleton.edu x4067) If you having trouble with a laptop, you can even bring your computer to Mike Tie (cmc 305) for help. Python Memory Management. Tracing Python memory leaks. While I was writing a python daemon, I noticed that my application process memory usage is growing over time. The data wasn’t increasing so there must have been some memory leak. It’s not so easy for a Python application to leak memory.

Usually there are three scenarios: some low level C library is leakingyour Python code have global lists or dicts that grow over time, and you forgot to remove the objects after usethere are some reference cycles in your app I remembered the post from Marius Gedminas, in which he traced his memory leaks, but I haven’t noticed before that he published his tools. . $ pdb . After some time, when my application collected some garbages I pressed Ctrl+C: 2008-11-13 18:41:40,136 server.py INFO Quitting (Pdb) import gc (Pdb) gc.collect() 58 (Pdb) gc.collect() 0 Let’s see some statistics of object types in memory: Message objects definitely shouldn’t be in the memory. This is what I saw: Ok. There is also one other class that’s not being freed – NonBlockingConnection: Python's getattr : orestis.gr.

An interesting question So, yesterday I was asked an interesting question: Int: Are you familiar with Python's getattr? Me: Um, yes? Interviewer clarifies what it's all about Int: So I now want you to implement __getattr__ in such a way that when a method is called with the prefix print it'll print it's name before calling it. Before that, we had a discussion about decorators, where I created a decorator called printme: def printme(func): def decorated(*args, **kwargs): print func.func_name #well, it was "print func", but now I know better :) return func(*args,**kwargs) return decorated So after a bit of confusion (writing code like that in a piece of paper with two pairs of eyes looking at you can be tricky), I ended up with something that may have looked like this: Can you spot the error? Well, we didn't have access to a console, so we didn't. >>> f = Foo() >>> f.hi() Hello!

So far, so good. >>> f.blah() Traceback (most recent call last): File "<stdin>", line 1, in ? So, how does it work? Step by step: Compiling extensions with MS Visual C++ Toolkit 2003 - msvccompiler-patch.txt (0/1)