What could 'f(this:that=other):' mean?

2005-01-05 Thread Jonathan Fine
Giudo has suggested adding optional static typing to Python. (I hope suggested is the correct word.) http://www.artima.com/weblogs/viewpost.jsp?thread=85551 An example of the syntax he proposes is: > def f(this:that=other): > print this This means that f() has a 'this' parameter, of type 'tha

Re: What could 'f(this:that=other):' mean?

2005-01-05 Thread Jonathan Fine
Jeff Shannon wrote: Jonathan Fine wrote: Giudo has suggested adding optional static typing to Python. (I hope suggested is the correct word.) http://www.artima.com/weblogs/viewpost.jsp?thread=85551 An example of the syntax he proposes is: > def f(this:that=other): > print this I&#

Re: What could 'f(this:that=other):' mean?

2005-01-07 Thread Jonathan Fine
Jonathan Fine wrote: I'll post some usage examples later today, I hope. Well, here are some examples. A day later, I'm afraid. ** Pipelines and other composites This is arising for me at work. I produce Postscript by running TeX on a document. And then running dvips on the output of T

Re: What could 'f(this:that=other):' mean?

2005-01-07 Thread Jonathan Fine
Jeff Shannon wrote: Jonathan Fine wrote: The use of *args and **kwargs allows functions to take a variable number of arguments. The addition of ***nsargs does not add significantly. I've posted usage examples elsewhere in this thread. I think they show that ***nsargs do provide a benefi

Re: What could 'f(this:that=other):' mean?

2005-01-11 Thread Jonathan Fine
Nick Coghlan wrote: If the caller is meant to supply a namespace, get them to supply a namespace. def f(ns1, ns2): print ns1['a'], ns1['b'], ns2['a'], ns2['b'] f(ns1 = dict(a=1, b=2), ns2 = dict(a=3, b=4)) Hey, where's Steve? Maybe his generic objects should be called namespaces instead of bun

Re: best way to do a series of regexp checks with groups

2005-01-24 Thread Jonathan Fine
Mark Fanty wrote: In perl, I might do (made up example just to illustrate the point): if(/add (\d+) (\d+)/) { do_add($1, $2); } elsif (/mult (\d+) (\d+)/) { do_mult($1,$2); } elsif(/help (\w+)/) { show_help($1); } or even do_add($1,$2) if /add (\d+) (\d+)/; do_mult($1,$2) if /mult (\d+) (\d+)

Non-blocking input on windows, like select in Unix

2005-03-01 Thread Jonathan Fine
Hello I have written a program that interacts with a command line program. Roughly speaking, it mimics human interaction. (With more speed and accuracy, less intelligence.) It works fine under Linux, using select(). But Windows does not support select for files. Only for sockets. Here's a google se

Re: Non-blocking input on windows, like select in Unix

2005-03-01 Thread Jonathan Fine
Paul Rubin wrote: Jonathan Fine <[EMAIL PROTECTED]> writes: My question is this: Under Windows, is it possible to read as many bytes as are available from stdout, without blocking? I think Windows implements non-blocking i/o calls. However the traditional (to some) Python or Java appro

Re: Non-blocking input on windows, like select in Unix

2005-03-02 Thread Jonathan Fine
fraca7 wrote: Jonathan Fine a écrit : Paul Rubin wrote: As I recall, some posts to this list say that Windows provides non-blocking i/o for sockets but not for files. No, Windows does provide non-blocking I/O for regular files, but it's a completely different mechanism than the one us

Simple Python + Tk text editor

2005-04-13 Thread Jonathan Fine
Hi I'm looking for a simple Python + Tk text editor. I want it as a building block/starting point. I need basic functions only: open a file, save a file, new file etc. It has to be open source. Anyone know of a candidate? -- Jonathan http://qatex.sourceforge.org -- http://mail.python.org/mailman/

Re: Simple Python + Tk text editor

2005-04-13 Thread Jonathan Fine
Paul Rubin wrote: Jonathan Fine <[EMAIL PROTECTED]> writes: I'm looking for a simple Python + Tk text editor. I want it as a building block/starting point. Something wrong with IDLE? Thanks for this suggestion. For some reason, I did not think of IDLE as an editor. Must have been a

Re: Simple Python + Tk text editor

2005-04-14 Thread Jonathan Fine
Eric Brunel wrote: Do you know the (apparently dead) project named e:doc? You can find it here: http://members.nextra.at/hfbuch/edoc/ It's a kind of word processor that can produce final documents to various formats using backends, and one of the backends is for LaTeX. It's written in Perl, but

Writing a bytecode interpreter (for TeX dvi files)

2005-05-26 Thread Jonathan Fine
I'm writing some routines for handling dvi files. In case you didn't know, these are TeX's typeset output. These are binary files containing opcodes. I wish to write one or more dvi opcode interpreters. Are there any tools or good examples to follow for writing a bytecode interpreter? I am alrea

Converting TeX tokens into characters

2005-06-28 Thread Jonathan Fine
I'm sort of wishing to convert TeX tokens into characters. We can assume the standard (i.e. plain) category codes. And that the characters are to be written to a file. This proceess to take place outside of TeX. Say in a Python program. Think of a pretty-printer. * Read the TeX in as tokens. * W

Wanted: a python24 package for Python 2.3

2007-03-20 Thread Jonathan Fine
Hello My problem is that I want a Python 2.4 module on a server that is running Python 2.3. I definitely want to use the 2.4 module, and I don't want to require the server to move to Python 2.4. More exactly, I am using subprocess, which is new in Python 2.4. What I am writing is something like

Re: Wanted: a python24 package for Python 2.3

2007-03-20 Thread Jonathan Fine
[EMAIL PROTECTED] wrote: > On Mar 20, 10:33 am, Jonathan Fine <[EMAIL PROTECTED]> wrote: >>My problem is that I want a Python 2.4 module on >>a server that is running Python 2.3. I definitely >>want to use the 2.4 module, and I don't want to >>require th

Re: Wanted: a python24 package for Python 2.3

2007-03-20 Thread Jonathan Fine
Alex Martelli wrote: > Jonathan Fine <[EMAIL PROTECTED]> wrote: >... > >>In other words, I'm asking for a python24 package that >>contains all (or most) of the modules that are new to >>Python 2.4. > > > For subprocess specifically, s

Re: Wanted: a python24 package for Python 2.3

2007-03-21 Thread Jonathan Fine
Gerald Klix wrote: > Hi, > You can't import subproces from future, only syntactic and semantic > changes that will become standard feature in future python version can > be activated that way. > > You can copy the subprocess module from python 2.4 somewhere where it > will be found from python

Two mappings inverse to each other: f, g = biject()

2007-02-06 Thread Jonathan Fine
Hello As part of the MathTran project I found myself wanting to maintain a bijection between long names and short names. http://www.open.ac.uk/mathtran In other words, I wanted to have two dictionaries f and g such that f[a] == b g[b] == a are equivalent statements. A google search for

Re: Two mappings inverse to each other: f, g = biject()

2007-02-06 Thread Jonathan Fine
Nick Vatamaniuc wrote: > If you need to get a short name, given a long name or vice-verse _and_ > the set of short names and long names is distinct (it would be > confusing if it wasn't!) then you can just have one dictionary, no > need to complicate things too much: > f[a]=b > f[b]=a > You won't

Re: Two mappings inverse to each other: f, g = biject()

2007-02-07 Thread Jonathan Fine
[EMAIL PROTECTED] wrote: >>A google search for biject.py and bijection.py >>produced no hits, so I suspect that this may not >>have been done before. > > > There are few (good too) implementations around, but they are called > bidict or bidirectional dicts. Sometimes I use this implementation, >

struct.pack bug?

2007-02-08 Thread Jonathan Fine
Hello I find the following inconsistent: === >>> sys.version '2.4.1a0 (#2, Feb 9 2005, 12:50:04) \n[GCC 3.3.5 (Debian 1:3.3.5-8)]' >>> pack('>B', 256) '\x00' >>> pack('>> pack('B', 256) Traceback (most recent call last): File "", line 1, in ? struct.error: ubyte format requires 0<=number<=2

[ANN] MathTran project

2007-02-22 Thread Jonathan Fine
://www.jisc.ac.uk/whatwedo/programmes/elearning_framework/toolkit_mathtran.aspx -- Jonathan Fine The Open University, Milton Keynes, England -- http://mail.python.org/mailman/listinfo/python-list

distutils - how to get more flexible configuration

2007-03-07 Thread Jonathan Fine
ble = '/wobble' === And when a distribution is created and installed we get === $ python setup.py install running install running build running install_data creating /wibble copying data/wibble.txt -> /wibble creating /wobble copying data/wobble.txt -> /wobble === This is an exa