Re: Gadfly server startup error

2006-09-13 Thread Ralf Muschall
Steve Holden wrote:

> Yes, the whole Gadfly SF web seems to be a bit of a mess.

Maybe it has been infected by the source code+doc ;-)

I just started the server (after applying Carl's changes)
with

gfserver  foodb . ''

(the DB "foodb" had been created earlier using gfplus
locally).

If I look for it with "nmap localhost -p ", it enters
an endless loop (I don't know whether it would still work
after this, since I could not get it to work at all).

gfplus in client-mode wants the argument order
  DB, port-No, password, host
(inferred from the source, i.e. the manual is wrong).

The argument order of commandlines and functions seems to be
a general problem - maybe I should try all 24 possibilities
(almost each place in the source does them differently).

After that, it says

|gfplus $Revision: 1.7 $ -- Interactive gadfly shell  [readline]
|
|Wednesday September 13, 2006 04:53 PM
|Using:
|Policy: foodb
|Loc: localhost:

i.e. it includes a thing called "Policy" (unexplained, just
mentioned in the "Security" chapter of the server manual)
and fills it with the value of the database name (but comparing
scripts/gfplus.py and client.py, "database" and "policy" seem
to be synonyms (but this disagrees with server.py)).

Entering a lone semicolon+return at the client prompt causes
a timeout in the client and a message

|no such policy: foodb
|main loop on  

|server: waiting for connection(s)

in the server (which is true in some sense, since I never made
a policy - I just want a blood DB).

It seems the proper way to use gadfly over the net is to say

echo 'SQL statement;' | ssh -l remoteuser 'gfplus -localoptions'

:-(

Is anybody out there who has used the server+client operation
mode successfully?

Ralf
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Gadfly server startup error

2006-09-13 Thread Ralf Muschall
Steve Holden wrote:

> You're already doing better than I am. On Cygwin 2.5rc2 and Windows 
> 2.4.2 I can't even get it to runs its tests properly:

I don't remember whether I looked into that at all.

...
> NameError: global name 'Server' is not defined

...
> Time to report a bug, methinks? Makes SQLite look good  ...

Carl Waldbieser reported this bug (and a few others, including
fixes) in April 04 (entry 94049[35]).  It seems the project
fell asleep four years ago (but in "News" on SF is a more recent
message from the author pointing to xsdb).

Ralf
-- 
http://mail.python.org/mailman/listinfo/python-list


Gadfly server startup error

2006-09-12 Thread Ralf Muschall
Hello,

I just tried the recent gadfly (from SF), using Python
2.4.2 (hand built, since my Suse 8.2 had only 2.2.2).

The direct operation of gadfly works.

After calling gfserver, I get (in addition to a complete
users manual dumped on the screen) the following error
message:

|Traceback (most recent call last):
|  File "/usr/local/bin/gfserver", line 4, in ?
|main()
|  File 
"/usr/local/python-2.4.2/lib/python2.4/site-packages/gadfly/scripts/gfserver.py",
 line 89, in main
|S = Server(int(port), db, dr, pw, startup)
|NameError: global name 'Server' is not defined


which is factually correct (the script only imports sys,
but then tries to instantiate the class "Server" which is
nowhere defined).

Is this a bug somewhere, or is just my installation broken?

Ralf
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: time.clock() going backwards??

2006-08-29 Thread Ralf Muschall
Grant Edwards wrote:

> This is a _Microsoft_Product_.  There doesn't have to be a
> reason for something to be done in a half-assed manner.

No, it is a quantum effect.  If the energy of a clock has a
lower bound, there must be a nonzero probability for it to
run backwards.

See <[EMAIL PROTECTED]>

SCNR, Ralf
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Railroad track syntax diagrams

2006-08-02 Thread Ralf Muschall
Paddy wrote:

> I googlled and got these:
>   http://www.informatik.uni-freiburg.de/~thiemann/haskell/ebnf2ps/
>   http://www.antlr.org/share/1107033888258/SDG2-1.5.zip

There is another beast, also called ebnf2ps, but in elisp
(runs inside the editor).

It requires no additional software (i.e. no ghc) and is simpler
to use (no questions about inexistent .afm files etc.)

Ralf
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 10GB XML Blows out Memory, Suggestions?

2006-06-07 Thread Ralf Muschall
Paul McGuire schrieb:

> meat of the data can be relatively small.  Note also that this XML overhead
> is directly related to the verbosity of the XML designer's choice of tag
> names, and whether the designer was predisposed to using XML elements over
> attributes.  Imagine a record structure for a 3D coordinate point (described
> here in no particular coding language):

> struct ThreeDimPoint:
> xValue : integer,
> yValue : integer,
> zValue : integer

> Directly translated to XML gives:

> 
> 4
> 5
> 6
> 

This is essentially true, but should not cause the OP's problem.
After parsing, the overhead of XML is gone, and long tag names
are nothing but pointers to a string which happens to be long
(unless *all* tags in the XML are differently named, which would
cause a huge DTD/XSD as well).

> This expands 3 integers to a whopping 101 characters.  Throw in namespaces
> for good measure, and you inflate the data even more.

In the DOM, it contracts to 3 integers and a few pointers -
essentially the same as needed in a reasonably written
data structure.

> Try zipping your 10Gb file, and see what kind of compression you get - I'll
> bet it's close to 30:1.  If so, convert the data to a real data storage

In this case, his DOM (or whatever equivalent data structure, i.e.
that what he *must* process) would be 300 MB + pointers.
I'd even go as far and say that the best thing that can happen to
him is a huge overhead - this would mean he has a little data
in a rather spongy file (which collapses on parsing).

> medium.  Even a SQLite database table should do better, and you can ship it
> around just like a file (just can't open it up like a text file).

A table helps only if the data is tabular (i.e. a single relation),
i.e. probably never (otherwise the sending side would have shipped
something like CSV).

Ralf
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Name conflict in class hierarchy

2006-05-23 Thread Ralf Muschall
bruno at modulix wrote:

>> In Python, a function not intended to be overriden should be either
>> have a name starting with an underscore

> actually with *two* underscores. The single-leading-underscore naming
> scheme is the convention for 'protected' (read: 'implementation, not
> API') attributes.

That's what I meant.  "A.func" looked like an internal implementation
detail.

>> or be documented.

Having the implementation details documented too would be nice, but
hardly enforceable in real life.

Ralf
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Name conflict in class hierarchy

2006-05-20 Thread Ralf Muschall
Jeffrey Barish wrote:

[overriding of base class member functions by subclass]

> but then B does not inherit other functions of A that I would like to use. 
> It struck me that this must be a common problem in OOP, so I'm wondering
> whether there is a simple solution that I am missing.

In C++, one has virtual member functions (which behave like python's),
and their purpose is to be overriden (o.g. a print method, whose subclass
version will print more attributes than the base knows about).

Such functions usually are documented - otherwise their being virtual
would make no sense.

In Python, a function not intended to be overriden should be either
have a name starting with an underscore or be documented.  So the person
who should change something is the author of the library, not you.

In your current situation, the following options seem to remain:

1. Use funny names ("foobar239847562384756" instead of "func")
   and hope that the library update will not use them

2. Call dir(classname) at hacking time and avoid names listed
   therein.  This breaks if the library update may happen at the
   user's site without you being able to change your code.

3. Call dir(classname) at runtime and raise an exception
   if it contains a name used by you.

Ralf
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [silly] Does the python mascot have a name ?

2006-05-19 Thread Ralf Muschall
John D Salt wrote:

> I'll believe you if you can give me a list of ten things that don't have 
> names.

[ sub{$_},  sub{$_+1}, sub{$_+2}, sub{$_+3}, sub{$_+4},
 sub{$_+5}, sub{$_+6}, sub{$_+7}, sub{$_+8}, sub{$_+9}]

That was easy.

Ralf
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [OT] Any Python lullabies?

2006-04-18 Thread Ralf Muschall
Christos Georgiou wrote:
> Since there have been python limmericks, are there any Python lullabies that
> I can sing to my newborn son (actually, born yesterday)?  I tried to murmur
> some select parts from the tutorial, but he somehow wasn't very interested
> :)

There is something near the end of the Camel book (p. 552ff).
This isn't exactly python, but the baby probably won't see
the difference.

SCNR, Ralf
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: "The World's Most Maintainable Programming Language"

2006-04-05 Thread Ralf Muschall
Mirco Wahab wrote:

>  Perl, named after Pearl Biggar (Larry Wall’s fiancée),

His wife was Gloria since at least 1979, perl was published
in 1987.  This seems to be an insider joke (he wanted to call
the language "Gloria" first, then "pearl", then "perl").

>  set a high standard for naming techniques.

So we should rename Python into Cottonmouth to get more attention.

Ralf
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Any advantage in LISPs having simpler grammars than Python?

2006-03-08 Thread Ralf Muschall
Douglas Alan wrote:

> Experienced Lisp programmers use indentation to visually parse the
> program structure, just like Python programmers do for Python.
> Experienced Lisp programmers learn to not see the parentheses when
> they don't need to.

True, and this is IMHO an advantage of lisp to python (both humans
and computers get something they are good at parsing, and mistakes
in the one can be corrected using the other).

> When I did a lot of Lisp programming, I often felt that it would be
> kind of nice to have a version of Lisp that would infer many of the
> parentheses from indentation, so that you could elide most of them.

This is not necessary - just making them barely visible suffices.

(font-lock-add-keywords
 'emacs-lisp-mode
 '(("[()]" . somr-barely-visible-face)))

One can also use nil instead of the mode, wrap the thing into a
defun and use it as a hook (nil means "just the current buffer
whatever mode it is in").

Btw., vim seems to try to become a real editor - look at
http://wiki.alu.org/Vim_ECL

Ralf
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: processing the genetic code with python?

2006-03-07 Thread Ralf Muschall
James Stroud wrote:

> I'm writing your name down and this is the last time I'm doing homework 
> for you.

This won't help - she doesn't even know her name
(but google helps with that) ;-)

The fact that she uses E.coli ribosomal protein L1
strongly indicates that this is really homework.

...
> data = data.upper().replace('T', 'U')
...

I'd apply the "inverse" of this line to the codon table
(or a copy thereof, or just adding the entries) in the hope
that changing 37 table entries is less work than changing
each codon in a base sequence.

Ralf
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Determing whether two ranges overlap

2006-02-17 Thread Ralf Muschall
Robin Haswell wrote:

> I can think of lots of ways to do this but it's in a tight loop so I need
> it to be as efficient as possible. Any help welcome :-)

There are 24 possibilities of having 4 numbers in a row, and
the following 6 of them describe nonempty intervals (the remaining
18 are obtained by reversing the endpoints of one or both
intervals, thereby making them empty):

# separate
a0 a1 b0 b1
b0 b1 a0 a1

# inside
a0 b0 b1 a1
b0 a0 a1 b1

# cross
a0 b0 a1 b1
b0 a0 b1 a1

The simplest is to exclude the first pair, i.e.

not (a1=b0 and b1>=a0, given by Fredrik without proof ;-)

You will have to decide whether you want ">" or ">="
(beware of the former when using floats).

If you cannot assume that the pairs are in order, this
will break.

Ralf
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Shortest prime number program

2006-02-11 Thread Ralf Muschall
Christoph Zwerschke wrote:
> [EMAIL PROTECTED] schrieb:
>> How about:

>> [2]+[x for x in range(1,99) if 2**x%x==2]

> If the range goes beyond 340, it also gives non-primes...

[2,3]+[x for x in range(1,99) if 2**x%x==2 and 3**x%x==3]
[2,3,5]+[x for x in range(1,99) if 2**x%x==2 and 3**x%x==3 and 5**x%x==5]

SCNR, Ralf

PS: They both break at 561, and further strengthening of the
condition will not help.  Manual loop unrolling as follows works:

[2,3,... ]+[x for x in range(1,99) if False]

For sufficiently small values of 99, this will also be a rather
short program.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Encoding sniffer?

2006-01-06 Thread Ralf Muschall
Diez B. Roggisch wrote:

> AFAIK iso-8859-1 has all codepoints taken - so you won't go beyond that
> in your example.

IIRC the range 128-159 (i.e. control codes with the high bit set)
are unused.

Ralf
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: popen4

2005-10-19 Thread Ralf Muschall
Ganesan Rajagopal wrote:

> Try pexpect instead. http://pexpect.sourceforce.net/
   ^

That's a content-free ad site.  You probably mean sourceforGe.

Ralf
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Lots of pdf files

2005-07-21 Thread Ralf Muschall
Greg Lindstrom wrote:
> Hello-
> I'm running Python 2.3 on a Linux system and have lots (about 2000)
> files in pdf format to print each day.  If I just wind up and fire all
> the files at the printer at once (as 2000 separate print jobs), the
> print server throws a fit and our system admin comes down and slaps me
> around for a few minutes (which, I guess, is fair).

Are your sure it is the number (and not the sum of the sizes) of
the jobs your admin is worrying about?

What about

#!/bin/sh
for i in *.pdf; do
  lpr $i
  sleep 10
done

(maybe adding something that waits until the queue is empty instead
of sleep)?

Ralf
-- 
http://mail.python.org/mailman/listinfo/python-list