ANN: PyXG = Python + Xgrid

2005-05-04 Thread Brian Granger
Announcing PyXG

PyXG = Python + Xgrid

Summary:

PyXG provides a Python interface to Xgrid, Xgrid is Apple's solution for running jobs on a cluster of Macintosh computers. The main goal of this project is to enable users to submit and manage Xgrid jobs on a cluster of Macs from a Python script or within an interactive Python session.

Features:

-- 	Use Xgrid from within python scripts as well as in interactive Python sessions

-- 	Submit and manage simple (one task) and batch (many task) Xgrid jobs

-- 	List available grids and query their status

--	List active Xgrid jobs, query their status and perform various actions
(delete, restart, etc.) on them

--	Easily work with more than one Xgrid controller or grid at the same time.

--	Quickly create sets of jobs using Python's powerful syntax

The homepage for PyXG is at:

http://hammonds.scu.edu/~classes/pyxg.html

Apple's description of Xgrid is at:

http://www.apple.com/server/macosx/features/xgrid.html

Brian Granger


Brian E. Granger
Assistant Professor of Physics
Santa Clara University
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations.html


ANN: CherryPy-2.0-final released

2005-05-04 Thread remi
Hello everyone,

I am happy to announce the first stable release of CherryPy-2.

CherryPy-2 is a pythonic, object-oriented web development framework.

CherryPy-2 is a redesign of CherryPy-1 (the unpythonic features have
been removed): no more compilation step, pure python source code (no
more CherryClass).

Here is a sample Hello, World in CherryPy-2:

# from cherrypy import cpg
# class HelloWorld:
# @cpg.expose
# def index(self):
# return Hello world!
# cpg.root = HelloWorld()
# cpg.server.start()

Main properties:
- this code starts a multi-threaded HTTP server that dispatches
requests to methods
- requests like http://domain/dir/page?arg1=val1arg2=val2; are
mapped to dir.page(arg1='val1', arg2='val2')
- CherryPy also supports positional arguments in URLs like
http://domain/book/science/9
- requests are mapped to an object tree that is mounted on cpg.root
(for instance: cpg.root.user, cpg.root.user.remi, ...)
- method must be explicitely exposed with a decorator @cpg.expose
(or index.exposed = True for Python-2.3)
- methods can return a generator instead of a string (useful when
generating big pages)

Here is a non-exhaustive list of CherryPy-2 features:
multi-threaded HTTP server, XML-RPC server, sessions, form handling,
authentication, unicode support, gzip-compression, virtual hosting,
WSGI adapter

The design of CherryPy-2 allows to easily write/use pluggable filters
or modules:
- filters perform operations on the request/response such as
gzip-compression or string encoding
- modules are web applications (like a blog or a web forum) than can
be easily mounted anywhere you want in your website

CherryPy-2 is already used in production by many sites and is
supported by an active community.

Remi.

http://www.cherrypy.org

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

Support the Python Software Foundation:
http://www.python.org/psf/donations.html


Re: control precision for str(obj) output?

2005-05-04 Thread Dan Bishop
Andrew Dalke wrote:
 Mike Meyer wrote:
  Someone want to tell me the procedure for submitting FAQ entries,
so I
  can do that for this?

 You mean more than what already exists at

http://www.python.org/doc/faq/general.html#why-are-floating-point-calculations-so-inaccurate

 which has a link to an even more detailed chapter in the tutorial at
   http://docs.python.org/tut/node16.html

Yes.  Those pages explain why repr(0.2) != '0.2', but they don't
explain why str([x]) != '[%s]' % x .

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


How to write this regular expression?

2005-05-04 Thread could ildg
I need a regular expression to check if a string matches it.
The string consists of one to there parts, each parts is a underline
followed by a number,
and the number of the first part should be 0~31, and numbers of other
parts should be
larger than 31.

The requested re should match the following strings:
_3
_5_33
_21
_29_50
_29_700_70

And the re shouldn't match the following strings:
_3_5   the number of part 2 is less than 31
_43the number of part 1 shouldn't be less than 31
_5_43_69_98  there shouldn't be more than 3 parts

How to write the re, please?
Thanks in advance.
-- 
http://mail.python.org/mailman/listinfo/python-list


OOPS concept

2005-05-04 Thread km

Hi all,

Is there any good step by step online tutorial on OOPS concepts in python ?
i have checked some on the python.org.__doc__ page but couldnt make much sense. 
 especially i need help on newstyle classes. 

regards,
KM
-- 
http://mail.python.org/mailman/listinfo/python-list


How To Reply

2005-05-04 Thread phil
I get a digest several times a day.
When I wish to respond to an item I must
cut and paste the item and the subject line.
Is there something to click on for a simple reply?
Using an old mozilla mail.
Thanks

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


Creating Files

2005-05-04 Thread Dan


I know how to open a system file with Python, but is there some way to
create one if it's not there?

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


Re: Mod_python

2005-05-04 Thread Dan
On 3 May 2005 19:22:52 -0700, Gensek [EMAIL PROTECTED]
wrote:

I want to use mod_python, but I'm having trouble. Here's what I have in
my config:

I've been using cherrypy (cherrypy.org) instead of apache with
mod_python.  In a lot of cases, apache is overkill.  With cherrypy you
can build a web application with a built in web server. It might be
worth a look, it's reasonably easy to use.

Dan


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


Re: OOPS concept

2005-05-04 Thread monkey
Try this online book, it may help, the url is:  http://www.byteofpython.info

 Hi all,

 Is there any good step by step online tutorial on OOPS concepts in python
?
 i have checked some on the python.org.__doc__ page but couldnt make much
sense.  especially i need help on newstyle classes.

 regards,
 KM


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


Re: wxpython on cygwin for drPython - ImportError: No module named _core_

2005-05-04 Thread monkey
I install the original python(www.python.org), it works with wxpython and
DrPython very very well.
But your case seem to be due to DrPython is not programed for Cygwin. You
should read through the system requirement of DrPython. As remember, it
stated the www.python.org only ( ;

 Hi,

 Did someone installed and used successfully drPython on Cygwin? The
 installation requires
 wxpython. I tried many different alternatives (source, binary, etc) but so
 far the best I get is the following.



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


Re: PHPParser pod Zope

2005-05-04 Thread Josef Meile
George Sakkis wrote:
 Bruno Desthuilliers wrote:
 
JZ a crit :

Probuje zainstalowac modul php pod zope i tam napisali dziwna rzecz
 
 ze
 
potrzebuje PHP CGI program a nie PHP CLI. Kompilacja php 5.0.4
 
 pod
 
linuksem daje mi w wyniku mod_php + 5 plikow binarnych: pear, php,
php-config, phpextdist, phpsize. Zas lektura skryptu do zope jest
 
 nizbyt
 
jasna. Napisali:


(snip)
Dsol, ce groupe est anglophone, il serait donc trs probablement
 
 
prfrable (en tous cas pour toi, et si bien sr tu espres une
 
 rponse,
 
mais sinon je ne vois pas l'intrt de poster ici...) de nous
 
 renvoyer
 
a en anglais dans le texte !-)

I-too-can-speak-weird-foreign-languages-ly'yrs
Bruno
 
 
  
  ,
  
   ...
 
 If-this-is-all-greek-to-you-you're-right-ly'yrs
 George
I don't find this two replies funy :-(. I think it is impolite to make
fun of the OP. You could say: The official language is english or
something like that. And if somebody knows the language he speaks, then
a pointer to an appropiate list would be usefull.

Best regards,
Josef

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

Re: file parsing/watching + qt

2005-05-04 Thread Phil Thompson
 this is a Qt app. app should watch for changes in /var/log/isdn.log and
 on file change (like new line was added to isdn.log) it should activate
 event in my app.

 i'm trying to fetch last line in file whenever isdnlog logs something
 so that i can parse that line for a number and store it somewhere else,
 is there a standard solution for this?

 i'm using python2.3 on linux with PyQt3.

This is UNIX/Linux specific, but one way would be to use QProcess to run
tail -f /var/log/isdn.log and connect the readyReadStdout() signal to
the Python callable that will handle the line.

Phil

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


Re: How to write this regular expression?

2005-05-04 Thread George Sakkis
This newsgroup is in general very helpful, but there are some
exceptions; one of them is when the problem appears blatantly to be a
homework. Perhaps if you showed that you worked on it and made some
progress, but it's not quite right, someone may help you.

George

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


Re: PHPParser pod Zope

2005-05-04 Thread bruno modulix
Josef Meile wrote:
(snip)
 
 I don't find this two replies funy :-(. I think it is impolite to make
 fun of the OP. 

My intent was not to make fun *of* the OP. Now I'm willing to admit that 
my answer may not be as (kindly) funny as intended, and so I hope the OP 
has a better sens of humor than you and me !-)

-- 
bruno desthuilliers
python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for 
p in '[EMAIL PROTECTED]'.split('@')])
-- 
http://mail.python.org/mailman/listinfo/python-list


_RE: Mod_python

2005-05-04 Thread Paul Boddie
Gensek wrote:

 I want to use mod_python, but I'm having trouble. Here's what I have in
 my config:

 LoadModule python_module /usr/local/apache2/modules/mod_python.so

 Directory /usr/local/apache2/htdocs/python
 AddHandler mod_python .py
 PythonHandler mptest
 PythonDebug On
 /Directory

My guess is that you need to add an Alias directive:

Alias /python /usr/local/apache2/htdocs/python

Otherwise, when you try the following URL...

 http://localhost/python/mptest.py

...Apache/mod_python doesn't know where to find the modules/files in
the filesystem corresponding to the Web path /python. Apologies if
you've already done this but didn't mention it.

[...]

 Is there any worthwhile alternative to modpython? I find it rather
 troublesome.

There are certainly a number of different options, and it depends on
how much you want to use the mod_python style of programming as to
which of those options you want to evaluate.

If you like Web programming frameworks using the publisher style -
that is, where you write Python functions and classes which correspond
to names in the URL, as in the example here...

http://www.modpython.org/live/current/doc-html/tut-pub.html

...then you might want to consider CherryPy, Quixote and Twisted Web
(amongst others).

If you don't care about (or don't care for) Web programming frameworks
using that style, but like a more servlet style approach or
mod_python's handler style, as in the example here...

http://www.modpython.org/live/current/doc-html/inst-testing.html

...then there's jonpy, Snakelets and Webware (amongst others).

I'm a bit biased when it comes to recommending frameworks, since I
always have to mention WebStack which favours a handler/servlet style
rather than the publisher style, although you can obviously build
publishers on top of it, and there are some helper classes included
for such purposes. However, you'll also want to consider how your
application produces its Web pages and whether you'll want to access
databases really easily or not - some frameworks attempt to cover
those issues as well.

WebStack applications can run on Apache (if you can stomach the
configuration, which isn't that hard once you've done it a few times)
but also on other servers and frameworks (if you'd prefer something a
bit more obvious). It has been said that people don't really need this
flexibility, but even if you aren't deploying on Zope (or whatever)
today, it's surely nice to know that you have the chance at some later
point in time without rewriting lots of code.

Paul

P.S. Start here: http://www.python.org/moin/WebProgramming
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PHPParser pod Zope

2005-05-04 Thread George Sakkis
bruno modulix [EMAIL PROTECTED] wrote:

 Josef Meile wrote:
 (snip)
 
  I don't find this two replies funy :-(. I think it is impolite to
make
  fun of the OP.

 My intent was not to make fun *of* the OP. Now I'm willing to admit
that
 my answer may not be as (kindly) funny as intended, and so I hope the
OP
 has a better sens of humor than you and me !-)


jokingor perhaps the OP's sense of humor is irrelevant if he/she
cannot read this thread in english :-) /joking 

George

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


Re: How to write this regular expression?

2005-05-04 Thread could ildg
Does it matter whether it is a homework?
Why do you look down upon homework?
Everyone can do his homework well without any problems in your logic?
It's a problem I met. I tried a lot and I can't work it out,
so I came here for help.
I saw someone complained that a question is too lengthy,
and I saw some questions were complained to be unclear,
but I never saw someone waste his time to judge if a question is a
homework. If this is natural, I'll pay attention from now on.

On 4 May 2005 01:31:48 -0700, George Sakkis [EMAIL PROTECTED] wrote:
 This newsgroup is in general very helpful, but there are some
 exceptions; one of them is when the problem appears blatantly to be a
 homework. Perhaps if you showed that you worked on it and made some
 progress, but it's not quite right, someone may help you.
 
 George
 
 --
 http://mail.python.org/mailman/listinfo/python-list

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


Re: Creating Files

2005-05-04 Thread Dan
On Wed, 04 May 2005 10:24:23 +0200, bruno modulix [EMAIL PROTECTED]
wrote:

As in any other language I know : just open it in write mode !-)

Easy when you know how.

Thanks

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


Re: How to write this regular expression?

2005-05-04 Thread Heiko Wundram
On Wednesday 04 May 2005 11:34, could ildg wrote:
 Does it matter whether it is a homework?

Yes, it does matter. We're not your CS-class homework monkeys... :-) We're a 
forum of Python programmers who aid each other at thinking about solutions, 
we don't present solutions (normally), for a beautiful example of this, see 
the thread about finding similarities between two wave files...

But, anyway, as an additional hint: the stuff you need to do _can_ be solved 
by an RE (the language you're matching is actually regular if you impose 
several restrictions), but I'd rather not do it that way. Programming a small 
function which splits the string and then does the appropriate checks (by 
using int) should be much easier and faster.

And in case you really need an RE, watch this monster (to match a single term 
having numerical value = 40)...

0*(([1-9][0-9]{2,})|([4-9][0-9]))

Matching numbers = 31 isn't hard too, I leave this as an exercise to the 
reader... :-) But beware, I'd guess this regex performs rather poorly with 
respect to backtracking on erraneous input such as 
30...

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


Better way to do parsing?

2005-05-04 Thread André Roberge
Hi all,

I posted the following on the python tutor list 3 days ago ... and 
haven't heard a peep from anyone - which is highly unusual on that list.

[Apologies for the slightly longer post due to code
with tests cases included at the end .]

I have created a severely restricted environment within with
users can learn the basics of programming in Python.

[note: eval, exec, chr, input, raw_input are not allowed.]

Within that environment, I want to have the user test the five
valid forms that an import statement can have, by attempting to
import a fake module whose name is useful.  Other import
statements are disallowed.

1. import useful
2. from useful import *
3. from useful import valid_function1 [, valid_function2, ...]
4. from useful import valid_function as better_named_function
5. import useful as not_so_useful_after_all

As far as I can tell, the following works, but it looks rather
clunky to me.  My *very limited* experience with the
re module may have something to do with this.

Any suggestion would be most welcome.

André

===Here's the code formatted (fingers crossed) to work if cut and
pasted from email =


# test_import.py

import re

isolate_words = re.compile(r'\W+')  # used with .split()

# pre-compiled some regular expression with allowable use of import

imp_use = re.compile('^import useful', re.MULTILINE)
imp_use_as = re.compile('^import useful as (\w+)', re.MULTILINE)
from_use_imp_star = re.compile('^from useful import \*', re.MULTILINE)
from_use_imp_names = re.compile(
 ^from useful import (\w+(,[ ]*\w+)*),
  re.MULTILINE)
from_use_imp_as = re.compile(
^from useful import (\w+) as (\w+),
re.MULTILINE)


# In the following, r is used so that \b identifies a word boundary,
# and is not interpreted as backslash by Python.

import_misuse = re.compile(r'\bimport\b', re.MULTILINE)

# use to commenting out the valid import statements after processed.

comment_from = re.compile('^from ', re.MULTILINE)
comment_import = re.compile('^import ', re.MULTILINE)

# Create a fake module which can be imported

right = turn_right():\n+\
  turn_left()\n+\
  turn_left()\n+\
  turn_left()\n\n

around = turn_around():\n+\
  turn_left()\n+\
  turn_left()\n\n

up_east = climb_up_east():\n+\
  turn_left()\n+\
  move()\n+\
  turn_left()\n+\
  turn_left()\n+\
  turn_left()\n\n

up_west = climb_up_west():\n+\
  turn_left()\n+\
  turn_left()\n+\
  turn_left()\n+\
  move()\n+\
  turn_left()\n\n

down_west =  climb_down_west():\n+\
  turn_left()\n+\
  move()\n+\
  turn_left()\n+\
  turn_left()\n+\
  turn_left()\n\n

down_east =  climb_down_east():\n+\
  turn_left()\n+\
  turn_left()\n+\
  turn_left()\n+\
  move()\n+\
  turn_left()\n\n

commands = {'turn_right': right, 'turn_around': around,
  'climb_up_east': up_east, 'climb_up_west': up_west,
  'climb_down_east': down_east, 'climb_down_west': down_west}

#=== end of info on fake module

# The following fonctions are helper functions to
# process the import statement:
# they add the appropriate imported commands
# before the import statement,
# before commenting out (by pre-pending #) the import statement line

def import_useful():
  added_text = ''
  for instruction in commands:
  new = def  + 'useful.' + commands[instruction]
  added_text += new
  return added_text, True

def from_useful_import_star():
  added_text = ''
  for instruction in commands:
  new = def  + commands[instruction]
  added_text += new
  return added_text, True

def import_useful_as(syn):
  added_text = ''
  for instruction in commands:
  new = def  + syn + '.' + commands[instruction]
  added_text += new
  return added_text, True

def from_useful_import_names(names):
  added_text = ''
  for instruction in isolate_words.split(names):
  try:
  new = def  + commands[instruction]
  except:
  print instruction,  not found in module useful
  added_text += new
  return added_text, True

def from_useful_import_as(name, syn):
  added_text = ''
  try:
  new = def  + commands[name].replace(name, syn)
  except:
  print name,  not found in module useful
  added_text += new
  return added_text, True

def process_no_import():
  added_text = ''
  return added_text, True

# the basic processing function

def process_file(file_text):
  if imp_use_as.search(file_text): # look for import useful as ...
  syn = imp_use_as.findall(file_text)
  

Re: file parsing/watching + qt

2005-05-04 Thread Swaroop C H
On 3 May 2005 22:43:02 -0700, aljosa [EMAIL PROTECTED] wrote:
 i'm trying to fetch last line in file whenever isdnlog logs something
 so that i can parse that line for a number and store it somewhere else,
 is there a standard solution for this?
 i'm using python2.3 on linux with PyQt3.

Use the Python binding to FAM (File Alteration Monitor):
http://python-fam.sourceforge.net/


HTH,
-- 
Swaroop C H
Blog: http://www.swaroopch.info
Book: http://www.byteofpython.info
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: py2exe and library.zip

2005-05-04 Thread Simon Brunning
On 5/3/05, Timothy Smith [EMAIL PROTECTED] wrote:
 exactly what i just stated, i don't want py2exe to zip up it's
 library's, but to put them in a sub dir.
 the reason for this, is so that when users login and update from svn,
 they only have to download some tiny pyc files, not a great big zip file
 with everything in it ( 99% of which never changes)

The zip file is a generated artifact. I've always found it a good rule
of thumb that you should keep source artifacts in your version control
system, not generated artifacts.

-- 
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to write this regular expression?

2005-05-04 Thread Antoon Pardon
Op 2005-05-04, could ildg schreef [EMAIL PROTECTED]:
 Does it matter whether it is a homework?

Yes, because if other do your homework for you, you wont
have learned anything from it.

 Why do you look down upon homework?

Who says he does. That he is not willing to do your homework
for you, doesn't imply he looks down on it.

 Everyone can do his homework well without any problems in your logic?

There is difference in asking for help on how to solve a
problem yourself and asking for the solution.

-- 
Antoon Pardon
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: py2exe and library.zip

2005-05-04 Thread Simon Brunning
On 5/4/05, Timothy Smith [EMAIL PROTECTED] wrote:
 Simon Brunning wrote:
 The zip file is a generated artifact. I've always found it a good rule
 of thumb that you should keep source artifacts in your version control
 system, not generated artifacts.
 
 
 
 version control systems are used for many purposes. it's just as
 important to keep track of your packaged releases and documentation as
 it is source code.
 its also a very convenient method of keeping people up with the lastest
 version.

Well, they may be used for many things, but what they are *good* at is
what they were designed for. Use them to do a job that they *weren't*
designed for, and they don't do so well.

The zip file essentially contains the whole system in on lump. Change
the system, and naturally your users will have to download the whole
lump again. (In my 'day job', I'm a Java web app developer. We keep
the source for our systems in SVN, any 3rd party JARs, and our build
scripts. We *used* to keep the installable WAR files in there too, but
we've stopped doing that now, for this reason amongst others.)

 i know i've seen what i'm asking for before, but no one seems to be able
 to tell me.

Sorry, but I'm not aware that py2exe can do this, or has ever been
able to. Again, it's designed to build you a minimum-file-count
distributable, and that's what it's good at.

-- 
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


sha-2 and sha-512 bindings

2005-05-04 Thread Almad
Hi, 

is there any python bindings for sha-2 or sha-512? 

Pycrypto seems to have only sha-1 bindings and I can't see any other package
on net...

Thanks, 
-- 
Lukas Almad Linhart

[:: http://www.almad.net/ ::]
[:: Humans are too complicated to be described with words. ::]
[:: PGP/GNUPg key: http://www.almad.net/download/pubkey.asc ::]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: py2exe and library.zip

2005-05-04 Thread Timothy Smith
Simon Brunning wrote:

On 5/4/05, Timothy Smith [EMAIL PROTECTED] wrote:
  

Simon Brunning wrote:


The zip file is a generated artifact. I've always found it a good rule
of thumb that you should keep source artifacts in your version control
system, not generated artifacts.



  

version control systems are used for many purposes. it's just as
important to keep track of your packaged releases and documentation as
it is source code.
its also a very convenient method of keeping people up with the lastest
version.



Well, they may be used for many things, but what they are *good* at is
what they were designed for. Use them to do a job that they *weren't*
designed for, and they don't do so well.

  

don't do so well how.  all it does is keep of files and tracks their 
revisions.

The zip file essentially contains the whole system in on lump. Change
the system, and naturally your users will have to download the whole
lump again. (In my 'day job', I'm a Java web app developer. We keep
the source for our systems in SVN, any 3rd party JARs, and our build
scripts. We *used* to keep the installable WAR files in there too, but
we've stopped doing that now, for this reason amongst others.)
  

but if it was just a dir, when they update from the svn at log in, all 
they do is download the extra\changed files. much much quicker then 
downloading a 4 meg uncompressed zip file.
there's no technical reason for this not to work that i can see, apart 
from py2exe's ability/inablity to not use a zip file.

  

i know i've seen what i'm asking for before, but no one seems to be able
to tell me.



Sorry, but I'm not aware that py2exe can do this, or has ever been
able to. Again, it's designed to build you a minimum-file-count
distributable, and that's what it's good at.

  


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


Re: Creating Files

2005-05-04 Thread Terje Johan Abrahamsen

Dan wrote:
 On Wed, 04 May 2005 10:24:23 +0200, bruno modulix [EMAIL PROTECTED]
 wrote:

 As in any other language I know : just open it in write mode !-)

 Easy when you know how.

 Thanks

e = file('c:/file.txt', 'w')

By the way, check out the Python tutor service...
http://mail.python.org/mailman/listinfo/tutor

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


Re: Regular Expression tools?

2005-05-04 Thread Terje Johan Abrahamsen
This is what you are looking for. 
http://kodos.sourceforge.net/

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


Re: Problem with pyXML DOM

2005-05-04 Thread Maniac
Florian Lindner wrote:

Traceback (most recent call last):
  File ConfigReader.py, line 40, in ?
c = ConfigReader(f)
  File ConfigReader.py, line 32, in __init__
print sourceNode.getElementsByTagName(filename)[0].nodeValue()
TypeError: 'NoneType' object is not callable
  

This is because nodeValue here is 'None' and 'None()' doesn't make 
sense. Looks like you want the thing between filename and /filename. 
This is not a nodeValue, this is nodeValue of firstChild of element 
'filename'. So this should work:

print sourceNode.getElementsByTagName(filename)[0].firstChild.nodeValue
-- 
http://mail.python.org/mailman/listinfo/python-list


Difference between Python CGI applications and Php applications

2005-05-04 Thread praba kar

Dear all,

   I have a project that is conversion
of Php Web applications into Python cgi
applications.  In my mind compare python-cgi
php is better.  But I want to know clearly.
which one is better. so kindly show me the 
advantages of python-cgi compare to Php


regards
PRaba


Yahoo! India Matrimony: Find your life partner online
Go to: http://yahoo.shaadi.com/india-matrimony
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: twisted jabber and xmlstream

2005-05-04 Thread Operation Latte Thunder
Sylvain Thenault [EMAIL PROTECTED] wrote:
 you can find some examples in our fatima project, a jabber bot testing
 client, available at http://www.logilab.org/projects/fatima/0.1
 You'll find a jabber.py module in the distribution containing jabber
 related code.
 
 hope that helps

thanks, I'll check it out!

-- 
[EMAIL PROTECTED]   | Roma Invicta!
-- 
http://mail.python.org/mailman/listinfo/python-list


Problems calling cdrdao from python 2.3

2005-05-04 Thread Jeremy Wilkins
Hi all,

I'm trying to use popen3 to call cdrdao from within python, it gets half way 
through though then hangs. This is easy to replicate from the interpreter.

import popen2
child = popen2.Popen3('cdrdao disk-info --device 0,0,0'.split(' '), 1, 100)
child.fromchild.read()

The above code works fine, the code below reads half the cd then hangs though.

import popen2
child = popen2.Popen3('cdrdao read-cd --device 0,0,0 testfile'.split(' '), 1, 
100)
child.fromchild.read()

If I close python, it seems to read in some more of the cd, but doesn't finish 
properly since no toc file is written.

Any help appreciated.

Jeb

PS: Please cc me as I'm not on the list

-- 

Whatever you Wanadoo:
http://www.wanadoo.co.uk/time/

This email has been checked for most known viruses - find out more at: 
http://www.wanadoo.co.uk/help/id/7098.htm

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


Re: py2exe and library.zip

2005-05-04 Thread Peter Hansen
Timothy Smith wrote:
 Peter Hansen wrote:
 Anything's possible.  Maybe you could explain what you're actually 
 trying to accomplish (or the reasons) so we can better understand 
 where you're going with this...

 exactly what i just stated, i don't want py2exe to zip up it's 
 library's, but to put them in a sub dir.
 the reason for this, is so that when users login and update from svn, 
 they only have to download some tiny pyc files, not a great big zip file 
 with everything in it ( 99% of which never changes)

More detail on this version control thing would probably help.  (Things 
like that are why I asked fo more background... exactly what I stated 
isn't as useful as something like (for example) I want my app users to 
use Subversion to retrieve updates to the application without having to 
download a big zip file.)

Do you know that Subversion has (as I understand it) a fairly 
intelligent binary file comparison routine, and it will (again, as I 
understand it) not transmit the entire contents of the zip file but 
would actually send only the portions that have changed?  At least, 
that's if the file isn't compressed in some way that prevents this 
algorithm from working well.  (Note to self: check if zip files that can 
be in sys.path can be compressed, and if py2exe compresses them.)

Anyway, while this sort of thing isn't directly supported (probably 
since almost nobody would want to do it, for reasons similar to what 
Simon has explained), you should be able to work it out yourself.  The 
.exe produced by py2exe contains a stub executable that basically sets 
  sys.path to point to the .zip file, then runs the main .py which has 
been integrated into the .exe file (not even compiled to a .pyc, just 
like normal).  If you modify your main .py to adjust sys.path to point 
to an external subdirectory, you should be able to leave .py files (or 
.pyc files) there and use svn to update them.

I'll leave it as an exercise for the reader (mainly because I don't know 
how to do it offhand) what you should do to prevent py2exe from putting 
all your files in its zip.  It should probably still put the standard 
library modules there, since otherwise you'd have little reason to be 
using py2exe in the first place...

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


Re: How to write this regular expression?

2005-05-04 Thread Peter Hansen
could ildg wrote:
 I need a regular expression to check if a string matches it.

Why do you think you need a regular expression?

If another approach that involved no regular expressions worked much 
better, would you reject it for some reason?

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


Re: How To Reply

2005-05-04 Thread Peter Hansen
phil wrote:
 I get a digest several times a day.
 When I wish to respond to an item I must
 cut and paste the item and the subject line.
 Is there something to click on for a simple reply?
 Using an old mozilla mail.

You are forced to cut and paste if you want to get the messages in a 
digest.  I doubt any mail program has been designed to know how to do 
anything smarter, and I'm sure old mozilla wasn't.  Either accept the 
hard way, or stop using the digest approach.

(Please try not to use the Python list for basic questions about how do 
I use my computer.  If everyone did that, this place would be a mess 
and your digests would be ten times larger.  Thanks.)

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


Re: Problem with pyXML DOM

2005-05-04 Thread Florian Lindner
Maniac wrote:

 Florian Lindner wrote:
 
Traceback (most recent call last):
  File ConfigReader.py, line 40, in ?
c = ConfigReader(f)
  File ConfigReader.py, line 32, in __init__
print sourceNode.getElementsByTagName(filename)[0].nodeValue()
TypeError: 'NoneType' object is not callable
  

 This is because nodeValue here is 'None' and 'None()' doesn't make
 sense. Looks like you want the thing between filename and /filename.
 This is not a nodeValue, this is nodeValue of firstChild of element
 'filename'. So this should work:
 
 print sourceNode.getElementsByTagName(filename)[0].firstChild.nodeValue

Ok, works perfect. Thanks!

But I don't really understand the logic:

given I have the node A

filenamepath/filename

A.firstChild.nodeValue == path

How would the second child of A look like? (ok, None in this case) How would
a XML fragment look like that has a second child?

What would be the nodeValue of A?

for me a child of a node is something like

filename
  child1 /
  child2 /
/filename


Thanks,

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


Re: Regular Expression tools?

2005-05-04 Thread Kent Johnson
Lee Cullens wrote:
 Been here before, but can't remember what I used and anyway that was a 
 PC platform.
 
 So, if you use a Regular Expression tool (PCRE standard) for Python 
 programming and your development platform is Mac OS X, would you please 
 help narrow down the search for me.  All I seem to be finding are other 
 platforms and/or not standalone.

Maybe you are looking for RegexPlor:
http://python.net/~gherman/RegexPlor.html

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


Re: Form and Database

2005-05-04 Thread bruno modulix
v wrote:
 Please help. I'm new with Python.
 Using Boa (or Pythoncard) and pysqlite, how can I read/write from/to
 database, thanks

First learn how to read/write data from your db (without any gui stuff). 
Then learn how to use your gui (without any db stuff). Then make the two 
working together, and you're done !-)

-- 
bruno desthuilliers
ruby -e print '[EMAIL PROTECTED]'.split('@').collect{|p| 
p.split('.').collect{|w| w.reverse}.join('.')}.join('@')
python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for 
p in '[EMAIL PROTECTED]'.split('@')])
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Regular Expression tools?

2005-05-04 Thread Lee Cullens
Tim Henderson:
 I am not quite sure what you want. However if you are looking for
 Python's regular expression module it is the re module. Just go to
 interactive help and view the api for it.

Thanks Tim,

I found RegexPlor - not as full as I was thinking of, but it does the 
job.

Lee C

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


Re: Problem with pyXML DOM

2005-05-04 Thread Maniac
Florian Lindner wrote:

But I don't really understand the logic:

given I have the node A

filenamepath/filename

A.firstChild.nodeValue == path

How would the second child of A look like? (ok, None in this case)

Yes. It's actually required by DOM standard: NodeList (which is returned 
from getElementsByTagName) should return 'null' (None in Python) on 
unknown index: 
http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-844377136

 How would
a XML fragment look like that has a second child?
  

Like this for example:
filenamechild/child//filename

or like this:

filenameI'm a text child node ElementChildNode//filename

What would be the nodeValue of A?
  

It's not related to children. There are several types of nodes: 
documents, elements, text, comments, processing instructions (things in 
??)... Their nodeValue depends on their nature.
http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-844377136

for me a child of a node is something like

filename
  child1 /
  child2 /
/filename
  

Almost :-). Here filename has actually 5 nodes:
1. text node '\n  '
2. element node 'child'
3. text node '\n  '
4. element node 'child'
5. text node '\n'

In other words: in DOM whitespace counts.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: py2exe and library.zip

2005-05-04 Thread Timothy Smith
Peter Hansen wrote:

Timothy Smith wrote:
  

Peter Hansen wrote:


Anything's possible.  Maybe you could explain what you're actually 
trying to accomplish (or the reasons) so we can better understand 
where you're going with this...

  

exactly what i just stated, i don't want py2exe to zip up it's 
library's, but to put them in a sub dir.
the reason for this, is so that when users login and update from svn, 
they only have to download some tiny pyc files, not a great big zip file 
with everything in it ( 99% of which never changes)



More detail on this version control thing would probably help.  (Things 
like that are why I asked fo more background... exactly what I stated 
isn't as useful as something like (for example) I want my app users to 
use Subversion to retrieve updates to the application without having to 
download a big zip file.)

Do you know that Subversion has (as I understand it) a fairly 
intelligent binary file comparison routine, and it will (again, as I 
understand it) not transmit the entire contents of the zip file but 
would actually send only the portions that have changed?  At least, 
that's if the file isn't compressed in some way that prevents this 
algorithm from working well.  (Note to self: check if zip files that can 
be in sys.path can be compressed, and if py2exe compresses them.)

Anyway, while this sort of thing isn't directly supported (probably 
since almost nobody would want to do it, for reasons similar to what 
Simon has explained), you should be able to work it out yourself.  The 
.exe produced by py2exe contains a stub executable that basically sets 
  sys.path to point to the .zip file, then runs the main .py which has 
been integrated into the .exe file (not even compiled to a .pyc, just 
like normal).  If you modify your main .py to adjust sys.path to point 
to an external subdirectory, you should be able to leave .py files (or 
.pyc files) there and use svn to update them.

I'll leave it as an exercise for the reader (mainly because I don't know 
how to do it offhand) what you should do to prevent py2exe from putting 
all your files in its zip.  It should probably still put the standard 
library modules there, since otherwise you'd have little reason to be 
using py2exe in the first place...

-Peter
  

ideally i'd love to not to have to use py2exe at all, then they can just
update from the stable branch of my svn. the problem with THAT is how to
install python, wx,pysvn,reportlab etc etc on their systems with no
fuss(py2exe convienently packages all dll's together for me). if you
know of a way i can achieve that i'd be your best friend forever.

the whole reason i'm going with the svn updating method is there is no
user interaction required. even getting users to click a single button
to update has proven too much to ask of them :/

the other reason is my particular project gets updated very often, so
you can imagine the combination of users resistant to any kind of
computer use with an environment requiring frequent updating.


i have some other problems to solve before i get to that point, mainly
svn related eg. pysvn whinges because files exist in the working
directory that it wants to update ( with the same name ), only they
aren't under version control.


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


Announcing CherryShell a python shell in your webbrowser

2005-05-04 Thread nopa90
A python interpreter embedded in a cherrypy webserver and controlled by
webbrower. Powered by AJAX. Currently only version 0.10 and only works
with firefox.

http://john.thetrotter.net

Also example of using cherrypy with AJAX (jsonrpc)

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


Re: Read / Write image file

2005-05-04 Thread codecraig
so something like,

x = sock.recv(1024)
while (len(x)  0):
# do stuff
x = sock.recv(1024)


??

So what if the client sends 4 bytes, and then sends 8000 bytes?  WIll I
get the first 4 bytes as a separate msg so to speak?  Basically i want
to catch each message from the client as a whole.

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


About Encapsulation

2005-05-04 Thread Adriano Monteiro
Hey folks,

I wanna know more about encapsulation in python. Is it fully suported?
How can I define the encapsulation statements for methods and attributes?

Regards!

[]'s!


-- 

Adriano Monteiro Marques
www.gopython.com.br
[EMAIL PROTECTED]

I'm FREE... Are you?
(PYTHON powered)
-- 
http://mail.python.org/mailman/listinfo/python-list


Problem with pyXML DOM

2005-05-04 Thread Florian Lindner
Hello,
I'm using the PyXML Package.

My XML document looks like that:

visConf
graph name=testgraph1 type=chart
source type=CSV
filename/home/florian/visualizer/testdata.csv/filename
/source

/graph
/visConf

print sourceNode.getElementsByTagName(filename)[0]
print sourceNode.getElementsByTagName(filename)[0].nodeValue()

gives:

Element Node at b7af74ac: Name='filename' with 0 attributes and 1 children

Traceback (most recent call last):
  File ConfigReader.py, line 40, in ?
c = ConfigReader(f)
  File ConfigReader.py, line 32, in __init__
print sourceNode.getElementsByTagName(filename)[0].nodeValue()
TypeError: 'NoneType' object is not callable

Given only the first call everything seems fine, I have a Node object for
the filename.
But why does the second call fails?

The documentationhttp://pyxml.sourceforge.net/topics/howto/node20.html says:


nodeValue
Value of this node. For some types of node, such as Text nodes, the value is
a string containing a chunk of textual data; for others, such as Text, the
value is just None.

Which I don't really understand? What is differencee between the two text
nodes??

Thanks,

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



Re: sha-2 and sha-512 bindings

2005-05-04 Thread rbt
Almad wrote:
 Hi, 
 
 is there any python bindings for sha-2 or sha-512? 
 
 Pycrypto seems to have only sha-1 bindings and I can't see any other package
 on net...
 
 Thanks, 

On Debian GNU\Linux Testing, Python2.3-crypto contains sha256 hashing.

http://packages.debian.org/testing/python/python2.3-crypto

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


Re: xmlrpclib and decoding entity references

2005-05-04 Thread Chris Curvey
yep, I'm using SimpleRPCServer, but something is getting messed up
between the receipt of the XML stream and the delivery to my function.
The normal entity references (like lt; and amp;) are handled OK,
but the character references are not working.  For instance,

Andr#xe9; is received by the server, but it's delivered to the
function as Andr;

I've figured out how to parse through the string to find all the
character references and convert them back, but that seems to be
causing a ProtocolError.

Hopefully someone can lend me a clue; I really don't want to have to
switch over to SOAP and end up in WSDL hell.

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


Re: Difference between Python CGI applications and Php applications

2005-05-04 Thread Ville Vainio
 Praba == praba kar [EMAIL PROTECTED] writes:

Praba Dear all,

Praba I have a project that is conversion of Php Web applications
Praba into Python cgi applications.  In my mind compare

You might want to look into mod_python and psp (python server pages)
for a more straightforward conversion:

http://www.onlamp.com/pub/a/python/2004/02/26/python_server_pages.html

-- 
Ville Vainio   http://tinyurl.com/2prnb
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: py2exe and library.zip

2005-05-04 Thread Just
In article [EMAIL PROTECTED],
 Peter Hansen [EMAIL PROTECTED] wrote:

 [ ... ] (Note to self: check if zip files that can 
 be in sys.path can be compressed,

Yes.

 and if py2exe compresses them.)

Don't know, but I assume yes.

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


Re: About Encapsulation

2005-05-04 Thread Sébastien Boisgérault
You mean private, protected, public, that kind of stuff ?

They do not exist in Python. Conventionally if you don't want
the user of a class to access a method or attribute, you use
the prefix _ ;

class K(object):

_a = 1

def __init__(self, val):
self.arg = val
self._hidden = 1

def _method(self):
pass


The _hidden attribute can still be accessed by ...

 h = K()._hidden

... but hey ! You know you *should* not. It's the
we are all consenting adults philosophy of
programming.

By the way, K._method and K._a won't appear
in the (py-)doc of the class ...

Cheers,

SB

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


Re: How To Reply

2005-05-04 Thread François Pinard
[Peter Hansen]

 You are forced to cut and paste if you want to get the messages in a 
 digest.  I doubt any mail program has been designed to know how to do 
 anything smarter,

Lars Magne Ingebrigtsen's wonderful Gnus (a much boosted, combined
news/mail reader, running within or over Emacs) knows about digests.

(Moreover, with not so much trickery, it is Python extensible.  I
vaguely remember having written one or two Python backends for Gnus.)

-- 
François Pinard   http://pinard.progiciels-bpi.ca
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to write this regular expression?

2005-05-04 Thread vkeyboard
Personally I'd use groups.

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


Re: control precision for str(obj) output?

2005-05-04 Thread Bo Peng
Dan Bishop wrote:
 Andrew Dalke wrote:
 
Mike Meyer wrote:

Someone want to tell me the procedure for submitting FAQ entries,
 
 so I
 
can do that for this?

You mean more than what already exists at

 
 http://www.python.org/doc/faq/general.html#why-are-floating-point-calculations-so-inaccurate
 
which has a link to an even more detailed chapter in the tutorial at
  http://docs.python.org/tut/node16.html
 
 
 Yes.  Those pages explain why repr(0.2) != '0.2', but they don't
 explain why str([x]) != '[%s]' % x .
 

I am new to Python but has experience with other languages. I am quite 
aware of 'why-are-floating-point-calculations-so-inaccurate'. I would 
not be surprised if

  str[0.0002)
0.0002001
  str([0.0002])
[0.0002001]

It was the difference between str([x]) and '[%s]' % x str(x) that 
confused me.

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


ANN: Leo 4.3-b1

2005-05-04 Thread Edward K. Ream
Leo 4.3 beta 1 is now available at http://sourceforge.net/projects/leo/

Leo 4.3 beta 1 completes all major features of Leo 4.3.  There are no known 
significant bugs.

The defining features of Leo 4.3:
-
1. Leo now stores options in @settings trees, that is, outlines whose 
headline is '@settings'. When opening a .leo file, Leo looks for @settings 
trees not only in the outline being opened but also in various 
leoSettings.leo files. Users can create arbitrarily complex user options 
with @settings trees.

2. The Preferences command temporarily replaces the outline pane with an 
outline showing all the @settings trees in effect. The Preferences command 
also replaces the body pane with a settings pane. This settings pane 
allows you to change the settings selected in the outline pane using 
standard gui widgets.

3. Leo now stores recent files information in .leoRecentFiles.txt files.

4. Leo's read/write code in leoAtFile.py has been rewritten to support 
user-defined tangling and untangling. This is a major cleanup of Leo's core.

5. Leo now contains an excellent Plugins Manager plugin. This plugin enables 
and disables plugins automatically and tells you everything you need to know 
about each plugin. This plugin also lets you download plugins from Leo's cvs 
site.

6. You can install third-party extensions in Leo's extensions directory. Leo 
will attempt to import such extensions from the extensions directory when 
normal imports fail. The distribution contains Python Mega Widgets in the 
extensions directory.

What people are saying about Leo

Another day, another breakthrough using Leo--now I realize Leo is the best 
URL bookmark manager there is. No more bookmarks menus or favorites lists 
inside the browser for me. With the @url directive I can just double click 
on the URL to open it in my browser. Leo lets me arrange the URLs in a 
hierarchy (or multiple hierarchies), attach notes to them, save clippings of 
things I read on the sites. It's sooo much better than anything the browsers 
have built in and it lets me easily use different browsers on different 
platforms and different machines (try that with the browsers' built-in 
bookmark managers). -- Dan Winkler

I am an amateur photographer. I use plain old 35mm. film for my pictures. 
Over the weekend, I used Leo to organize my lists of pictures. It is quite 
helpful--I can have separate nodes for pictures I have enlarged, as well as 
pictures I have submitted to our local camera club. Thanks! -- Rich Reis

Cloning is pure genius!... Leo's cloning facility, allows me to create 
several views on the CFA course material. My main view follows the 
prescribed study guide. Another view is organized like the textbooks. Yet 
another gives me a glossary of terms. And when I'm done, I'll have some nice 
libraries...I can re-use later in other projects. -- Michael Manti

More quotes at: http://webpages.charter.net/edreamleo/testimonials.html

What makes Leo special?
---
- Leo's outlines add a new dimension to programming.
- Leo shows you your code and data the way _you_ want to see them.
- Leo extends, completes and simplifies literate programming.
- Leo's script buttons bring scripts to data.

What is Leo?

- A programmer's editor, an outlining editor and a flexible browser.
- A literate programming tool, compatible with noweb and CWEB.
- A data organizer and project manager. Leo provides multiple views
  of projects within a single outline.
- Fully scriptable using Python. Leo saves its files in XML format.
- Portable. leo.py is 100% pure Python.
- Open Software, distributed under the Python License.

Leo requires Python 2.2.1 or above and tcl/tk 8.4 or above.
Leo works on Linux, Windows and MacOs X.

Links:
--
Leo:  http://webpages.charter.net/edreamleo/front.html
Home: http://sourceforge.net/projects/leo/
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
CVS:  http://sourceforge.net/cvs/?group_id=3458
Quotes:   http://webpages.charter.net/edreamleo/testimonials.html


Edward K. Ream   email:  [EMAIL PROTECTED]
Leo: Literate Editor with Outlines
Leo: http://webpages.charter.net/edreamleo/front.html



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


Re: py2exe and library.zip

2005-05-04 Thread Thomas Heller
Timothy Smith [EMAIL PROTECTED] writes:

 is it possible instead of py2exe putting all library's in a zip file,
 to just put them in a sub dir?

You can subclass the build_exe command (the extending sample shows how
to do this, althoutgh for a different purpose), and copy the files into
a sub dir instead of building an archive.  You still have to make sure
that your exe has this directory on sys.path.

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


Re: py2exe and library.zip

2005-05-04 Thread Thomas Heller
Just [EMAIL PROTECTED] writes:

 In article [EMAIL PROTECTED],
  Peter Hansen [EMAIL PROTECTED] wrote:

 [ ... ] (Note to self: check if zip files that can 
 be in sys.path can be compressed,

 Yes.

 and if py2exe compresses them.)

 Don't know, but I assume yes.

There's an option for that, because it slows down the imports.

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


Re: How To Reply

2005-05-04 Thread Grant Edwards
On 2005-05-03, phil [EMAIL PROTECTED] wrote:

 I get a digest several times a day.
 When I wish to respond to an item I must
 cut and paste the item and the subject line.
 Is there something to click on for a simple reply?
 Using an old mozilla mail.

Instead of accessing the newsgroup through an e-mail gateway,
why not use a newsreader and access it directly?  It eliminates
all the hassles associated with digested mail.  I even use
gmane.org to access normal mailing lists via a newsreader.

-- 
Grant Edwards   grante Yow!
  at   
FISH-NET-FISH-NET-FISH-NET-FISH-NET-FISH!!
   visi.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Python FAQ entries (Was: control precision for str(obj) output?)

2005-05-04 Thread Mike Meyer
Dan Bishop [EMAIL PROTECTED] writes:

 Andrew Dalke wrote:
 Mike Meyer wrote:
  Someone want to tell me the procedure for submitting FAQ entries,
 so I
  can do that for this?

 You mean more than what already exists at

 http://www.python.org/doc/faq/general.html#why-are-floating-point-calculations-so-inaccurate

 which has a link to an even more detailed chapter in the tutorial at
   http://docs.python.org/tut/node16.html

 Yes.  Those pages explain why repr(0.2) != '0.2', but they don't
 explain why str([x]) != '[%s]' % x .

Exactly. The point that needs to go in the FAQ is the behavior of str
on lists, not floating point representation. The latter needs to be
mentioned, but isn't critical.

A quick check of the Python site turns up no discussion on submitting
new FAQ entries. There are patch submission guidelines, and lots of
things related to the mailman FAQ, but nothing on how to submit new
entries for the FAQ. Or has the FAQ been supplanted by the wiki at
www.python.org/moin, even though there doesn't appear to be a FAQ
page?

mike
-- 
Mike Meyer [EMAIL PROTECTED]  http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How To Reply

2005-05-04 Thread Mike Meyer
François Pinard [EMAIL PROTECTED] writes:

 [Peter Hansen]

 You are forced to cut and paste if you want to get the messages in a 
 digest.  I doubt any mail program has been designed to know how to do 
 anything smarter,

 Lars Magne Ingebrigtsen's wonderful Gnus (a much boosted, combined
 news/mail reader, running within or over Emacs) knows about digests.

So does the emacs VM mail reader. It bursts a digest into a collection
of submessages.

Unfortunately, digests often lose critical headers, making the reply
come out broken in some way. I've not read the python list as  a
digest, so I don't know if it will have problems or not.

mike
-- 
Mike Meyer [EMAIL PROTECTED]  http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: tkinter and threads

2005-05-04 Thread Philippe C. Martin
I might be wrong, but my experience is to keep all tkinter calls in the main
thread and use queues to have other threads tell the main one what to do.

Regards,

Philippe



Nir Aides wrote:

 Hello,
 
 In Tkinter, is it safe to call widget.after(time, callback) from another
 thread (other than the gui thread)?
 
 Thanks,
 Nir

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


Re: Better way to do parsing?

2005-05-04 Thread [EMAIL PROTECTED]
Isn't it a better idea to manipulate the import statement with use of
of the 'imp' module to get a restriction on the import statement?

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


SWIG/Python2.4.1: ImportError: dynamic module does not define init function (initSHIP)

2005-05-04 Thread Bill Davy
Hello,

I am using SWIG-1.3.24 to make an extension (called SHIP) to Python2.4.1 and 
then running under IDLE (if that makes any difference) but when I import 
SHIP I get:

 import SHIP

Traceback (most recent call last):
  File pyshell#0, line 1, in -toplevel-
import SHIP
ImportError: dynamic module does not define init function (initSHIP)


Indeed, SHIP.py does not define an initSHIP.  It does have import _SHIP

SHIP_wrap.cpp (produced by SWIG) does have init_SHIP (defined to SWIG_init).

It seems to me I should not be editing SHIP.py (as made by SWIG) but it does 
seem to be missing something, or am I?

Thanks in advance,

   Bill

PS I gave up trying to use IDLE with a locally compiled debug version of 
Python - that's for another day (or week), but thanks for the assorted help 
I was given. 


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


Re: empty lists vs empty generators

2005-05-04 Thread Leif K-Brooks
Jeremy Bowers wrote:
 def __init__(self, generator):
 self.generator = generator

You'll want to use iter(generator) there in order to handle reiterables.
-- 
http://mail.python.org/mailman/listinfo/python-list


Variable option count

2005-05-04 Thread Florian Lindner
Hello,
how can I give an arbitrary number of options in a automated way to a
function?

Example.

I've the list A =

[
1
2
3
...
]

Now I want to give this list to a function so that it is the same for
function like:

f(1, 2, 3, ...)

How can I do that?

Thanks,
Florian
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Better way to do parsing?

2005-05-04 Thread Bengt Richter
On Wed, 04 May 2005 07:13:22 -0300, =?ISO-8859-1?Q?Andr=E9_Roberge?= [EMAIL 
PROTECTED] wrote:

Hi all,

I posted the following on the python tutor list 3 days ago ... and 
haven't heard a peep from anyone - which is highly unusual on that list.

[Apologies for the slightly longer post due to code
with tests cases included at the end .]

I have created a severely restricted environment within with
users can learn the basics of programming in Python.

[note: eval, exec, chr, input, raw_input are not allowed.]

Within that environment, I want to have the user test the five
valid forms that an import statement can have, by attempting to
import a fake module whose name is useful.  Other import
statements are disallowed.

1. import useful
2. from useful import *
3. from useful import valid_function1 [, valid_function2, ...]
4. from useful import valid_function as better_named_function
5. import useful as not_so_useful_after_all

As far as I can tell, the following works, but it looks rather
clunky to me.  My *very limited* experience with the
re module may have something to do with this.

Any suggestion would be most welcome.

I don't in any way want to discourage your enthusiastic pursuit of
your goal, but I suspect you might have more fun with another approach,
unless you really want to learn about the limitations of regexes first ;-)
(Don't get me wrong, regexes are great for what they do best).

I.e., if you want to parse python, there are modules that will help you
a lot more than just re will. If you want to validate source
according to your own rules before compiling, you could walk the
ast and raise exceptions where your rules are violated. Or if you
want to emulate excution as you walk the tree, you can do that too.
Either way, this post of Michael Spencer's ought to give you food for thought:

http://mail.python.org/pipermail/python-list/2005-March/270760.html

Also for more general (not just python syntax) parssing the pyparsing
program referenced in the followon post looks very nice, though I have not 
tried it.

http://pyparsing.sourceforge.net/


Regards,
Bengt Richter
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python SQLite

2005-05-04 Thread Andy Jeffries
dcrespo wrote:
 Does PySQLite run on Linux?

Yes!

From my Gentoo laptop:

andyvaio root # emerge -av pysqlite

These are the packages that I would merge, in order:

Calculating dependencies ...done!
[ebuild   R   ] dev-python/pysqlite-0.5.1  0 kB

Total size of downloads: 0 kB

Do you want me to merge these packages? [Yes/No]



Cheers,


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


ANN: CherryPy-2.0-final released

2005-05-04 Thread remi
Hello everyone,

I am happy to announce the first stable release of CherryPy-2.

CherryPy-2 is a pythonic, object-oriented web development framework.

CherryPy-2 is a redesign of CherryPy-1 (the unpythonic features have
been removed): no more compilation step, pure python source code (no
more CherryClass).


Here is a sample Hello, World in CherryPy-2:

# from cherrypy import cpg
# class HelloWorld:
# @cpg.expose
# def index(self):
# return Hello world!
# cpg.root = HelloWorld()
# cpg.server.start()

Main properties:
- this code starts a multi-threaded HTTP server that dispatches
requests to methods
- requests like http://domain/dir/page?arg1=val1arg2=val2; are
mapped to dir.page(arg1='val1', arg2='val2')
- CherryPy also supports positional arguments in URLs like
http://domain/book/science/9
- requests are mapped to an object tree that is mounted on cpg.root
(for instance: cpg.root.user, cpg.root.user.remi, ...)
- method must be explicitely exposed with a decorator @cpg.expose
(or index.exposed = True for Python-2.3)
- methods can return a generator instead of a string (useful when
generating big pages)

Here is a non-exhaustive list of CherryPy-2 features:
multi-threaded HTTP server, XML-RPC server, sessions, form handling,
authentication, unicode support, gzip-compression, virtual hosting,
WSGI adapter

The design of CherryPy-2 allows to easily write/use pluggable filters
or modules:
- filters perform operations on the request/response such as
gzip-compression or string encoding
- modules are web applications (like a blog or a web forum) than can
be easily mounted anywhere you want in your website

CherryPy-2 is already used in production by many sites and is
supported by an active community.

Remi.

http://www.cherrypy.org

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


Re: xmlrpclib and decoding entity references

2005-05-04 Thread Chris Curvey
Here is the solution.  Incidentally, the client is Cold Fusion.

import re
import logging
import logging.config
import os
import SimpleXMLRPCServer

logging.config.fileConfig(logging.ini)


class
LoggingXMLRPCRequestHandler(SimpleXMLRPCServer.CGIXMLRPCRequestHandler):
def __dereference(self, request_text):
entityRe = re.compile(((?Per#x)(?Pcode..)(?Psemi;)))
for m in re.finditer(entityRe, request_text):
hexref = int(m.group(3),16)
charref = chr(hexref)
request_text = request_text.replace(m.group(1), charref)

return request_text


#---
def handle_xmlrpc(self, request_text):
logger = logging.getLogger()
#logger.debug()
#logger.debug(request_text)
try:
#logger.debug(-)
request_text = self.__dereference(request_text)
#logger.debug(request_text)
request_text = request_text.decode(latin-1).encode('utf-8')
#logger.debug()
except Exception, e:
logger.error(request_text)
logger.error(had a problem dereferencing)
logger.error(e)

SimpleXMLRPCServer.CGIXMLRPCRequestHandler.handle_xmlrpc(self,
request_text)

class Foo:
def settings(self):
return os.environ
def echo(self, something):
logger = logging.getLogger()
logger.debug(something)
return something
def greeting(self, name):
return hello,  + name

# these are used to run as a CGI
handler = LoggingXMLRPCRequestHandler()
handler.register_instance(Foo())
handler.handle_request()

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


New Zope Italia Association (AZI)

2005-05-04 Thread Stefano Noferi
We are pleased to announce the foundation of the Zope Italia
Association (AZI - Associazione Zope Italia).

It was created by a couple of mailing list users in the last months
(since march).

Main goals are to manage the Zope.IT community activities, to contribute
to the diffusion and to improve the visibility of Zope, Plone and Python
in Italy.

Further details can be found at http://zope.it.

-- 
Stefano Noferi
Zope Italia Association
-- 
http://mail.python.org/mailman/listinfo/python-list


Q: The `print' statement over Unicode

2005-05-04 Thread François Pinard
Hi, people.  I hope someone would like to enlighten me.

For any application handling Unicode internally, I'm usually careful
at properly converting those Unicode strings into 8-bit strings before
writing them out.

However, this morning, I mistakenly forgot to do so before using one
Unicode string (containing a non-ASCII character) as an argument to
the `print' statement, and I did _not_ get an error.  This is rather
surprising to me.  I reread the section of the Python reference manual
(version 2.3.4, this machine uses 2.3.3 currently), and it does not say
anything about a special processing for Unicode strings.

In my understanding, when `print' is given an argument which is not
already a string (I read: 8-bit string), it first gets converted into
a string (I read: calling __str__).  But if I call `str()' explicitly,
_then_ I get an error as expected.  The question is, why is there no
error if I do not call `str()' explicity?

For example, given file `question.py' with this contents:

   # -*- coding: UTF-8 -*-
   texte = unicode(Fran\xe7ois, 'latin1')
   print type(texte), repr(texte), texte
   print type(texte), repr(texte), str(texte)

doing `python question.py' yields:

   type 'unicode' u'Fran\xe7ois' François
   type 'unicode' u'Fran\xe7ois'
   Traceback (most recent call last):
 File question.py, line 4, in ?
   print type(texte), repr(texte), str(texte)
   UnicodeEncodeError: 'ascii' codec can't encode character u'\xe7' \
  in position 4: ordinal not in range(128)

(last line wrapped for legibility).

So (trying to be crystal clear), why is the first `print' working over
its third argument, but not the second?  How does `print' convert that
Unicode string to a 8-bit string for output, if not through `str()'?
What is missing to the documentation, or to my way of understanding it?

-- 
François Pinard   http://pinard.progiciels-bpi.ca
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Read / Write image file

2005-05-04 Thread Scott David Daniels
phil wrote:

 By the way, what is 'rb' and 'wb' ?

 
 Read Binary, Write Binary
 In Win32 the default is text mode which
 will screw up binary files
 
In fact, this is not just for Windows.  Linux / Unix is unusual
using the originally non-standards-conforming line feed ('\n')
character as a line separator.  Various different OS's define
text files in different ways.  The distinction between binary
and text is a C standards thing, not a Windows goof.  Heaven
knows I dislike a lot of what Microsoft has done in the way
of interfering with standard ways of doing things, but their
end-of-line convention is not one of those things.  The use
of the extension .doc was such a deliberate violation of
standards.  Note older Apple files used '\r' as a line separator,
Tenex used \r\n, or \037, some systems used a line count (leaving
no end-of-line string), and so on

It is a good idea to provide an indication of whether a file
is binary or text to the file system; the clue could guide
compression information.

-Scott David Daniels
[EMAIL PROTECTED]


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


Re: Q: The `print' statement over Unicode

2005-05-04 Thread Thomas Heller
François Pinard [EMAIL PROTECTED] writes:

 Hi, people.  I hope someone would like to enlighten me.

 For any application handling Unicode internally, I'm usually careful
 at properly converting those Unicode strings into 8-bit strings before
 writing them out.

 However, this morning, I mistakenly forgot to do so before using one
 Unicode string (containing a non-ASCII character) as an argument to
 the `print' statement, and I did _not_ get an error.  This is rather
 surprising to me.  I reread the section of the Python reference manual
 (version 2.3.4, this machine uses 2.3.3 currently), and it does not say
 anything about a special processing for Unicode strings.

 In my understanding, when `print' is given an argument which is not
 already a string (I read: 8-bit string), it first gets converted into
 a string (I read: calling __str__).  But if I call `str()' explicitly,
 _then_ I get an error as expected.  The question is, why is there no
 error if I do not call `str()' explicity?

 For example, given file `question.py' with this contents:

# -*- coding: UTF-8 -*-
texte = unicode(Fran\xe7ois, 'latin1')
print type(texte), repr(texte), texte
print type(texte), repr(texte), str(texte)

 doing `python question.py' yields:

type 'unicode' u'Fran\xe7ois' François
type 'unicode' u'Fran\xe7ois'
Traceback (most recent call last):
  File question.py, line 4, in ?
print type(texte), repr(texte), str(texte)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe7' \
   in position 4: ordinal not in range(128)

 (last line wrapped for legibility).

 So (trying to be crystal clear), why is the first `print' working over
 its third argument, but not the second?  How does `print' convert that
 Unicode string to a 8-bit string for output, if not through `str()'?
 What is missing to the documentation, or to my way of understanding it?

AFAIK, print uses sys.stdout.encoding to encode the unicode string.

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


Re: Read / Write image file REC SEP

2005-05-04 Thread phil

So what if the client sends 4 bytes, and then sends 8000 bytes?  WIll I
get the first 4 bytes as a separate msg so to speak?  Basically i want
to catch each message from the client as a whole.


IF YOU WANT SEPARATE MESSAGES:
Modify the client to send an end of record, then:
On Server:


datasep = 'EOR'   # or whatever you like
datal = []
seversocket.settimeout(5.0) # or 0(infinite) or something reasonable
while 1:
 try:
 data = serversocket.recv(BUFFERSIZE) # fails on timeout
 if not data: break
 datal.append(data)
 except: break

msglist = datal.split(datasep)   # a list of messages

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


Re: xmlrpclib and decoding entity references

2005-05-04 Thread Bengt Richter
On 3 May 2005 08:07:06 -0700, Chris Curvey [EMAIL PROTECTED] wrote:

I'm writing an XMLRPC server, which is receiving a request (from a
non-Python client) that looks like this (formatted for legibility):

?xml version=1.0?
methodCall
methodNameecho/methodName
params
param
value
stringLe Martyre de Saint Andr#xe9; lt;BRgt; avec inscription
apos;Le Dominiquain.apos; et apos;Le tableau fait par le dominicain,
dapos;apr#xe8;s son dessein #xe0;... est #xe0; Rome, #xe0;
lapos;#xe9;glise Saint Andr#xe9; della Valleapos; sur le
cadrelt;BRgt; craie noire, plume et encre brune, lavis brun
rehauss#xe9; de blanc sur papier brunlt;BRgt; 190 x 228 mm. (7 1/2 x
9 in.)/string
/value
/param
/params
/methodCall

But when my echo method is invoked, the value of the string is:

Le Martyre de Saint Andr; BR avec inscription 'Le Dominiquain.' et
'Le tableau fait par le dominicain, d'apr:s son dessein 2... est 2
Rome, 2 l';glise Saint Andr; della Valle' sur le cadreBR craie noire,
plume et encre brune, lavis brun rehauss; de blanc sur papier brunBR
190 x 228 mm. (7 1/2 x 9 in.)

Can anyone give me a lead on how to convert the entity references into
something that will make it through to my method call?

I haven't used XMLRPC but superficially this looks like a quoting and/or 
encoding
problem. IOW, your request is XML, and the string.../string part is also 
XML
which is part of the whole, not encapsulated in e.g. ![CDATA[...stuff...]]
(which would tell an XML parser to suspend markup interpretation of 
...stuff...).

So IWT you would at least need the string.../string content to be converted 
to
unicode to preserve all the represented characters. It wouldn't surprise me if 
the
whole request is routinely converted to unicode, and the value you are showing
above is a result of converting from unicode to an encoding that can't represent
everything, and maybe just drops conversion errors. What do you
get if you print repr(value)? (assuming value is passed to you echo method)

If it is a unicode string, you will just have to choose an appropriate 
value.encode('appropriate')
from available codecs. If it looks like e.g., a utf-8 encoding of unicode, you 
could try
value.decode('utf-8').encode('appropriate')

I'm just guessing here. But something is interpreting the basic XML, since
lt;BRgt; is being converted to BR. Seems not unlikely that the rest are
also being converted, and to unicode. You just wouldn't notice a glitch when
unicode BR is converted to any usual western text encoding.

OTOH, if the intent (which I doubt) of the non-python client were to pass 
through
a block of pre-formatted XML as such (possibly for direct pasting into e.g. web 
page XHTML?)
then a way to avoid escaping every  and  would be to use CDATA to encapsulate 
it. That
would have to be fixed on that end.

Regards,
Bengt Richter
-- 
http://mail.python.org/mailman/listinfo/python-list


postgresql plpython bug

2005-05-04 Thread Mage
  Hello!

create or replace function trigger_keywords_maintain() returns trigger as $$
return 'MODIFY'
$$ language plpythonu;

update table set id = id where id = 7;

ERROR:  invalid input syntax for type timestamp: 2005-05-03
14:07:33,279213

I see that Python's timestamp format is not accepted by postgresql.

   Mage

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


Re: descriptor dilemma

2005-05-04 Thread Sébastien Boisgérault

Yup ?!? Weird ... especially as:

 id(c.f) == id(C.__dict__['f'].__get__(c,C))
True

I was pretty sure that 'id(a) == id(b)' iff 'a is b' ...

I thought initially that you had two *copies* of the
same method bot obviously it's not true ...

SB

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


Re: descriptor dilemma

2005-05-04 Thread Jeff Epler
On Wed, May 04, 2005 at 09:14:18AM -0700, Sébastien Boisgérault wrote:
 
 Yup ?!? Weird ... especially as:
 
  id(c.f) == id(C.__dict__['f'].__get__(c,C))
 True

Here, c.f is discarded by the time the right-hand-side of == is
executed.  So the object whose id() is being calculated on the
right-hand-side could turn out to be the same, since the two objects
have disjoint lifetimes.

Here are some more cases of the same thing:
 id([]) == id([])
1
 id([]) == id([1])
1

Jeff


pgp0amP007OuW.pgp
Description: PGP signature
-- 
http://mail.python.org/mailman/listinfo/python-list

How do you convert a string obj to a file obj?

2005-05-04 Thread Matthew Thorley
I'm writing a web app whereby a user uploads a tar acrhive which is then
opened and processed. My web form reads the file like this:

while 1:
data = value.file.read(1024 * 8) # Read blocks of 8KB at a time
if not data: break

which leaves me with data as a string obj. The problem that I have is
that the function that processes the archive expects a file object. So
far the only solution I have found it to write the file to disk and then
read it back.

Is there an easy way to convert data, in the example above into a file
object?

Thanks
-Matthew
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A faster method to generate a nested list from a template?

2005-05-04 Thread jasondrew72

Jeff Epler wrote:
 Are there only a few, unchanging templates?  If so, (dynamiclly)
create
 a function for each template.  This will be nearly the fastest you
can
 go in Python, excluding the time to create and byte-compile the
nesting
 function.

 # This code is in the public domain
 def make_nesting_expression(l, s):
 result = []
 for c in l:
 if isinstance(c, list):
 sub, s = make_nesting_expression(c, s)
 result.append(sub)
 else:
 result.append(l[%d] % s)
 s += 1
 print make_nesting_expression, l, result
 return [ + ,.join(result) + ], s

 def make_nesting_function(l):
 return eval(lambda l: %s % make_nesting_expression(l, 0)[0])

 t = [['a1','a2'],['b1'],['c1'],['d1']]
 l = [1, 2, 3, 4, 5]
 f = make_nesting_function(t)
 print f(l)

 Jeff


Nice approach! Though I'm wondering, because the template is so close
to the function you're trying to create, why not just create the
function directly? As in:

 f5 = lambda p: (p[0:2], p[2], p[3], p[4])
 f5(('a', 'b', 'c', 'd', 'e', 'f'))
(('a', 'b'), 'c', 'd', 'e')

Or if you need to be able to remember what the template looks like
(e.g. reading/writing it as a string in a file), you can always create
the function by evaluating a (properly constructed) template string:

 f5 = eval(lambda p: (p[0:2], p[2], p[3], p[4]))
 f5(('a', 'b', 'c', 'd', 'e', 'f'))
(('a', 'b'), 'c', 'd', 'e')

If you want to avoid lambdas, the same ideas can be used with short
defs, e.g.:
def f5(p): return (p[0:2], p[2], p[3], p[4])

Incidentally, these solutions raise an IndexError if your list is too
short, and silently drop the end of a list that's too long.

That's my keep-it-simple-I-might-understand-it approach.

Jason

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


Re: How do you convert a string obj to a file obj?

2005-05-04 Thread John Abel
Matthew Thorley wrote:

I'm writing a web app whereby a user uploads a tar acrhive which is then
opened and processed. My web form reads the file like this:

while 1:
data = value.file.read(1024 * 8) # Read blocks of 8KB at a time
if not data: break

which leaves me with data as a string obj. The problem that I have is
that the function that processes the archive expects a file object. So
far the only solution I have found it to write the file to disk and then
read it back.

Is there an easy way to convert data, in the example above into a file
object?

Thanks
-Matthew
  

fileObj = StringIO.StringIO()
fileObj.write( data )

J

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


Re: descriptor dilemma

2005-05-04 Thread Peter Otten
john wrote:

 Why do c.f and C.__dict__['f'].__get__(c,C) compare as equal under ==
 but not under *is*  ?

These variations are equivalent. Every  attribute access gives you a new
bound method:

 class C(object):
... def f(self): pass
...
 c = C()
 c.f is c.f
False
 c.f == c.f
True

'a is b' is true only when the names a and b are bound to the same object.
For bound methods, c.f is c.f == True would mean that Python would have to
cache them, and I don't see a potential advantage of that.
'a == b' on the other hand does what the programmer specifies:

 class Str(str):
... def __eq__(self, other): return True
...
 Str(black) == Str(blue)
True

It makes sense for bound methods to compare equal if they refer to the same
function and instance (though I don't know if the class is checked, too).

Peter

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


zipimport

2005-05-04 Thread Gabriele *Darkbard* Farina
Hi,

I have a zip file structured like this:

mymodule.zip\
   module1.py
   submodule\
submodule1.py

I tried to load submodule.submodule1 using this pice of code:

import zipimport

z = zipimport.zipimporter(mymodule.zip)
z.load_module(submodule.submodule1)

but it does not work (load_module raises an exception)

why?

tnx, bye
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How do you convert a string obj to a file obj?

2005-05-04 Thread Matthew Thorley
John Abel wrote:
 Matthew Thorley wrote:
 
 I'm writing a web app whereby a user uploads a tar acrhive which is then
 opened and processed. My web form reads the file like this:

 while 1:
data = value.file.read(1024 * 8) # Read blocks of 8KB at a time
if not data: break

 which leaves me with data as a string obj. The problem that I have is
 that the function that processes the archive expects a file object. So
 far the only solution I have found it to write the file to disk and then
 read it back.

 Is there an easy way to convert data, in the example above into a file
 object?

 Thanks
 -Matthew
  

 fileObj = StringIO.StringIO()
 fileObj.write( data )
 
 J
 

I gave that a shot but got this error? Perhaps I misunderstood what kind
of object I needed. Any thoughts?

AttributeError: StringIO instance has no attribute 'rfind'
-- 
http://mail.python.org/mailman/listinfo/python-list


FTP/TLS connection using python

2005-05-04 Thread scrimp
Hello,
   I was wondering if there is any other way to securly connect to an
FTP site using SSL or TLS? I dont have the option of purchasing
M2Crypto from the site. Any help/suggestions would help. Thanks!

--Barry

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


Re: descriptor dilemma

2005-05-04 Thread Sébastien Boisgérault

Jeff Epler wrote:
   id(c.f) == id(C.__dict__['f'].__get__(c,C))
  True

 Here, c.f is discarded by the time the right-hand-side of == is
 executed.  So the object whose id() is being calculated on the
 right-hand-side could turn out to be the same, since the two objects
 have disjoint lifetimes.

Understood. I guess I was influenced by C++ where a temporary survives
up to the end of the complete statement in which it was created. Right
?

SB

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


Re: FTP/TLS connection using python

2005-05-04 Thread Larry Bates
I don't have direct experience by Google turned this up:

http://trevp.net/tlslite/

Larry Bates


scrimp wrote:
 Hello,
I was wondering if there is any other way to securly connect to an
 FTP site using SSL or TLS? I dont have the option of purchasing
 M2Crypto from the site. Any help/suggestions would help. Thanks!
 
 --Barry
 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: FTP/TLS connection using python

2005-05-04 Thread scrimp
Wow, thanks very much Ive been searching on google for a few days now
and have never seen this yet. Thanks ill take a look at what I can do
with this

--Barry

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


Re: how can I sort a bunch of lists over multiple fields?

2005-05-04 Thread Steven Bethard
Lonnie Princehouse wrote:
 Non-trivial:
   Any time the user decides to (1) cache intermediary results for a cmp
 function or (2) define a __cmp__ function for the key return value.
 These arise when comparison of partial keys is often sufficient to
 establish order between two objects.

If you want to compare partial keys, often the simplest approach is to 
use tuples as keys, with the elements of the tuple being the parts of 
the key.  Python's standard tuple comparison mechanism takes care of the 
rest.

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


python and glut

2005-05-04 Thread max(01)*
hi there.

i installed python2.3-opengl, then i tried one of those demos:



#!/usr/bin/python2.3

# This is statement is required by the build system to query build info
if __name__ == '__build__':
 raise Exception

import sys
from OpenGL.GL import *
from OpenGL.GLE import *
from OpenGL.GLUT import *


class GLE_demo:

 def __init__(self):
 # initial mouse position
 self.lastx = 121
 self.lasty = 121

 # set the display mode and create the window
 glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH)
 glutCreateWindow(GLE demo)

 # setup the callbacks
 glutDisplayFunc(self.on_display)
 glutMotionFunc(self.on_motion)
 glutReshapeFunc(self.on_reshape)

 #
 glClearDepth(1.0)
 glEnable(GL_DEPTH_TEST)
 glClearColor(0.0, 0.0, 0.0, 0.0)
 glShadeModel(GL_SMOOTH)

 glMatrixMode(GL_MODELVIEW)
 # initialize lighting */
 glLightfv(GL_LIGHT0, GL_POSITION,  (40.0, 40, 100.0, 0.0))
 glLightfv(GL_LIGHT0, GL_DIFFUSE, (0.99, 0.99, 0.99, 1.0))
 glEnable(GL_LIGHT0)
 glLightfv(GL_LIGHT1, GL_POSITION, (-40.0, 40, 100.0, 0.0))
 glLightfv(GL_LIGHT1, GL_DIFFUSE, (0.99, 0.99, 0.99, 1.0))
 glEnable(GL_LIGHT1)
 glEnable(GL_LIGHTING)
 glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE)
 glEnable(GL_COLOR_MATERIAL)


 def on_motion(self, x, y):
 # store the mouse coordinate
 self.lastx = x
 self.lasty = y
 # redisplay
 glutPostRedisplay()


 def on_reshape(self, width, height):
 # setup the viewport
 glViewport(0, 0, width, height)
 # setup the projection matrix
 glMatrixMode(GL_PROJECTION)
 glLoadIdentity()
 # calculate left/right and top/bottom clipping planes 
based the
smallest square viewport
 a = 9.0/min(width, height)
 clipping_planes = (a*width, a*height)
 # setup the projection
 glFrustum(-clipping_planes[0], clipping_planes[0], 
-clipping_pla
nes[1], clipping_planes[1], 50.0, 150.0)


 def on_display(self):
 # clear the buffer
 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

 # Set up the model view matrix
 glMatrixMode(GL_MODELVIEW)
 glLoadIdentity()
 glTranslatef(0.0, 0.0, -80.0)
 glRotatef(self.lastx, 0.0, 1.0, 0.0)
 glRotatef(self.lasty, 1.0, 0.0, 0.0)

 # a nice pale lime green
 glColor3f(0.6, 0.8, 0.3)

 # set the join styles for GLE
 gleSetJoinStyle(TUBE_NORM_EDGE | TUBE_JN_ANGLE | 
TUBE_JN_CAP)
 gleHelicoid(1.0, 6.0, 2.0, -3.0, 4.0, None, None, 0.0, 
1080.0)

 # swap the buffer
 glutSwapBuffers()



if __name__ == '__main__':
 # initialize GLUT
 glutInit(sys.argv)
 # create the demo window
 GLE_demo()
 # enter the event loop
 glutMainLoop ()



(sorry for some line breaks, some day i'll repair my newsreader)

but when i try to run it:

$ python GLE.py
freeglut (GLE.py): OpenGL GLX extension not supported by display ':0.0'

what's up? what's missing?

i use a standard debian installation.

thanks for your attention

bye

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


Re: zipimport

2005-05-04 Thread Jonathan Brady

Gabriele *Darkbard* Farina [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Hi,

 I have a zip file structured like this:

 mymodule.zip\
   module1.py
   submodule\
submodule1.py

 I tried to load submodule.submodule1 using this pice of code:

 import zipimport

 z = zipimport.zipimporter(mymodule.zip)
 z.load_module(submodule.submodule1)

 but it does not work (load_module raises an exception)

 why?

try z.load_module(submodule/submodule1) instead.

Or in otherwords replace the dot with a slash, now quoting from the docs 
'fullname' must be the fully qualified (dotted) module name..  The dotted 
part of that doesn't seem to be correct, at least with the version of python 
(2.3.4) I'm running.

Anyway personally I find:

import sys
sys.path.insert(0, 'mymodule.zip')
import submodule.submodule1

a much cleaner way of thinking about this.

-- 
Jonathan 


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


Re: How to write this regular expression?

2005-05-04 Thread James Stroud
On Wednesday 04 May 2005 02:34 am, so sayeth could ildg:
 I saw someone complained that a question is too lengthy,
 and I saw some questions were complained to be unclear,
 but I never saw someone waste his time to judge if a question is a
 homework. If this is natural, I'll pay attention from now on.

 On 4 May 2005 01:31:48 -0700, George Sakkis [EMAIL PROTECTED] wrote:
  This newsgroup is in general very helpful, but there are some
  exceptions; one of them is when the problem appears blatantly to be a
  homework. Perhaps if you showed that you worked on it and made some
  progress, but it's not quite right, someone may help you.

I think by participating in this list, most of the members have felt that they 
have agreed to the following unofficial terms and conditions of use:

http://www.catb.org/~esr/faqs/smart-questions.html

The interesting thing is that those who follow the letter most strictly are 
usually the best ones to ask. Moreover, most members of this list are usually 
looking for any excuse to compose a regular expression. In fact, they 
probably come up with an answer before they make any assessments about 
homework.

 I can tell you that this is not any homework at all,
 I think it by myself.

In that case, your question is free game:


 r = re.compile(r_[0-3]\d?(_\d\d?){0,2})

 r.search('_29_700_70')
_sre.SRE_Match object at 0x402ccba0
 r.search('_29_50')
_sre.SRE_Match object at 0x402f8820
 r.search('_5_33')
_sre.SRE_Match object at 0x402ccba0
 r.search('_500')


James

-- 
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

http://www.jamesstroud.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Newbie.......Python and Networking

2005-05-04 Thread xeron
Hi ya fellas

I am planning to learn Python, and because i have a networking
background so would like to direct my learning in a way that is
beneficial to my tasks in the mentioned field, please suggest a couple
of projects which i can implement so as to accelerate the learning
process(Python projects in Networking domain, let it be
big...3 months2 hrs per day)

Really appreciate any help

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


Bandwith Shaping

2005-05-04 Thread flamesrock
Just curious - is there an easy way to shape bandwith in python. If I
wanted to have a max download speed for instance

-thanks

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


Re: Newbie.......Python and Networking

2005-05-04 Thread phil
xeron wrote:

  Hi ya fellas
 
  I am planning to learn Python, and because i have a networking
  background so would like to direct my learning in a way that is
  beneficial to my tasks in the mentioned field, please suggest a couple
  of projects which i can implement so as to accelerate the learning
  process(Python projects in Networking domain, let it be
  big...3 months2 hrs per day)
 
  Really appreciate any help
 
 

I let my students learn on a VERY simple chat program,
UDP only. I think it was less than 50 lines of Python.

I cut my teeth on a message handler, POS application posts
its requests to MySQL via a Python message handler.

Want BIG?
spread.org is very powerful and somewhat complicated.
A python message server, guaranteed orderly delivery
over 1 UDP port, which is a little easier to understand
than spread, would be cool.

Even BIGGER?
Every linux distro has its own set of complex and
nearly unreadable networking scripts and none of them
handle routing and firewalls well.
Be the hero who rights a universal, well documented
python networking script.  Easy to read config file:

ethmodule=
IPADDR=192.168.1.12/24
DEFGATEWAY=192.168.1.1
DNSSERV1=208.208.1.1

or even a GUI with help.


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


Re: python+windows/linux - write stdout text to always on top text?

2005-05-04 Thread flamesrock
hmm... I guess its not possible as I feared :(

thanks anyways

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


Re: How do you convert a string obj to a file obj?

2005-05-04 Thread Esben Pedersen
Matthew Thorley wrote:
 I'm writing a web app whereby a user uploads a tar acrhive which is then
 opened and processed. My web form reads the file like this:
 
 while 1:
 data = value.file.read(1024 * 8) # Read blocks of 8KB at a time
 if not data: break
 
 which leaves me with data as a string obj. The problem that I have is
 that the function that processes the archive expects a file object. So
 far the only solution I have found it to write the file to disk and then
 read it back.
 
 Is there an easy way to convert data, in the example above into a file
 object?
 
 Thanks
 -Matthew

value.file is a file object. Why don't you give that as an argument?

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


Re: Any decent IM protocol implementations (icq or aim)

2005-05-04 Thread Aahz
In article [EMAIL PROTECTED],
Jaime Wyant  [EMAIL PROTECTED] wrote:

Can anyone recommend one?  Google isn't giving me much.

http://twistedmatrix.com/projects/words/
-- 
Aahz ([EMAIL PROTECTED])   * http://www.pythoncraft.com/

It's 106 miles to Chicago.  We have a full tank of gas, a half-pack of
cigarettes, it's dark, and we're wearing sunglasses.  Hit it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bandwith Shaping

2005-05-04 Thread phil
flamesrock wrote:

 Just curious - is there an easy way to shape bandwith in python. If I
 wanted to have a max download speed for instance
 
 -thanks
 
Interesting normally bandwidth shaping is an IP stack function

in the Kernel.

You are receiving a download within a python program?
And want to slow it down?
You could put a sleep(.01) in your receive loop.
That's about as fine as sleep gets, i've read.

But those packets ( I assume TCP ) are going to stack up somewhere,
the sender is gonna keep trying and retrying.  In other words
you are increasing overall load to someone's router and the
network.
Someone correct me if I'm drunk on this.





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


Re: Data smoothing algorithms? - Thank you all

2005-05-04 Thread Bengt Richter
On Wed, 04 May 2005 16:01:07 GMT, Dennis Lee Bieber [EMAIL PROTECTED] wrote:

On Tue, 03 May 2005 16:28:34 GMT, Dennis Lee Bieber
[EMAIL PROTECTED] declaimed the following in comp.lang.python:


  It's not going to be easy, though... G

   Yes, talking to myself... I crawled through one of my texts (at
work) yesterday. This is incomplete -- I wasn't going to copy the entire
chapter -- but may serve as an example of some of the complexity that
goes into some of the entries found in almanacs:

From: Spherical Astronomy [Robin M. Green; 1985 Cambridge University] 

The 1980 theory of nutation contains 106 terms both in longitude and
the obliquity 

Displacement of true celestial pole from mean pole, /principal/ terms
only -- lunar caused nutation

Nutation in longitude = -17.1996 sin omega 
-1.3187 sin (2F - 2D + 2 omega) 
-0.2274 sin (2F - 2 omega) 
Nutation in obliquity = 9.2025 cos omega 
+ 0.5736 cos (2F - 2D + 2 omega) 
+ 0.0927 cos (2F - 2 omega) 

Where: 
omega = mean longitude of the node (I presume of the moon)
F = mean argument from node (moon) 
D = mean elongation from sun (moon) 

Periods of interest: 
18.6 year lunar (movement of the node), 
6 month solar, 
14 day lunar... 

26000 year luni-solar precession 

I wonder why the original post, which I presume was

http://mail.python.org/pipermail/python-list/2005-April/278752.html

doesn't show up in google groups, but can seemingly only be found indirectly
by google search on smoothing algorithms site:python.org giving one main post

http://mail.python.org/pipermail/python-list/2005-April/278871.html

which is a reply with no immediate apparent parent. And then going to the
sorted-by-thread index, where you can find the original.

Maybe it's because there was an html attachment (which I didn't wget to 
investigate)?

Anyway, the original post sounds like the OP was really just looking for better 
numbers
than in some text tables he found, and not really for a way of estimating 
better numbers based
on flawed data (though that was what he apparently thought his best option was, 
using the
rounded text tables as data). I'd bet that is not his best option, especially 
since distributions
of actual roundoff errors can be weird. There must be tons of 
telescope-pointing and planetarium-driving
software out there that can do similar stuff. And if that's not accurate 
enough, the relevant
newsgroup crowd will be able to advise, I'd bet.

Regards,
Bengt Richter
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to write this regular expression?

2005-05-04 Thread James Stroud
Being one who types first and thinks later, I have to give this correction:

 r = 
 re.compile(r^_((\d)|([1-2]\d)|[3][0-1])(_(([4-9]\d+)|([3][1-9])|([1-9](\d){2,}))){,2}$)
 test(r)
_5 type '_sre.SRE_Match'
_10 type '_sre.SRE_Match'
_31 type '_sre.SRE_Match'
_1_50 type '_sre.SRE_Match'
_21_50_100 type '_sre.SRE_Match'
_500 type 'NoneType'
_21_10 type 'NoneType'
_21_50_40 type '_sre.SRE_Match'
_21_50_400 type '_sre.SRE_Match'
_21_50_1000 type '_sre.SRE_Match'
_5_40_100_50 type 'NoneType'
_3_5 type 'NoneType'
_43 type 'NoneType'
_5_43_69_98 type 'NoneType'


James

-- 
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

http://www.jamesstroud.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


  1   2   >