Zope 3.1.0c1 released!

2005-08-03 Thread Stephan Richter
The Zope 3 development team is proud to announce Zope 3.1.0 candidate 1.

Zope 3 is the next major Zope release and has been written from scratch based
on the latest software design patterns and the experiences of Zope 2.

It is in our opinion that Zope 3.1 is more than ready for production use,
which is why we decided to drop the 'X' for experimental from the name. We
will also continue to work on making the transition between Zope 2 and Zope 3
as smooth as possible. As a first step, Zope 2.8 includes Zope 3 features in
the form of Five.

Please test this release carefully and send us any feedback! In particular, we
have tried very hard to keep backward-compatibility with the previous X3 3.0
release, so please let us know if the new release breaks your code.


Downloads

  http://zope.org/Products/Zope3/

  Installation instructions for both Windows and Un*x/Linux are now available
  in the top level 'README.txt' file of the distribution. The binary installer
  is recommended for Windows.

  Zope 3.1 requires Python 2.3.5 or 2.4.1 to run. You must also have zlib
  installed on your system.

Important Changes Since 3.1.0b1

  All of the outstanding issues in the to-do list were completed, which 
included
  many bugfixes and the removal of all outstanding XXX comments. There was 
also 
  a lot of work done in fixing many places that were not translatable.

Most Important Changes Since 3.0

  - New Pluggable Authentication Utility (PAU), which is similar in
philosophy to the Zope 2 PAS. The following features are available in
the in the basic PAU facility:

+ Credentials Plugins: Basic HTTP Auth, Session

+ Authenticator Plugins: Principal Folder, Group Folder

For a detailed description of the pluggable authentication utility,
see 'zope/app/authentication/README.txt'.

  - Major simplifications to the component architecture:

+ Removal of the concept of a service. All outstanding services were
  converted to utilities: Error Reporting, FSSync, Authentication.

+ Site Managers are global and local now; adapters and utilties are
  directly registered with the site manager. Now global and local
  component registration and lookup behaves very similar.

+ Local registrations can now only have two states: active and
  inactive. This simplified the code so much, that 'zope.app.utility',
  'zope.app.registration' and 'zope.app.site' were all merged into
  'zope.app.component'.

+ Implemented menus as utilities. The API also supports sub-menus now.

+ Implemented views as adapters. Skins and layers are now simply
  interfaces that the request provides.

  - Added an integer-id facility for assigning integer identifiers
to objects.

  - Added basic catalog and index frameworks.

  - Added sources, which are like vocabularies except that they
support very large collections of values that must be
searched, rather than browsed.

  - Created a new granting UI that allows advanced searching of
principal sources.

  - Implemented a generic user preferences systsem that was designed to be
easily used in TALES expressions and via Python code. Preferences can be
edited via 'http://localhost:8080/++preferences++/'. A demo of the
preferences can be found at::

  http://svn.zope.org/Zope3/trunk/src/zope/app/demo/skinpref/

  - ZCML now supports conditional directives using the 'zcml:condition'
attribute. The condition is of the form verb argument. Two verbs, 'have
feature' and 'installed module' are currently implemented. Features can be
declared via the 'meta:provides' directive.

  - Improved API doctool: Code Browser now shows interfaces, text files and
ZCML files; the new Book Module compiles all available doctext files into
an organized book; the new Type Module lets you browser all interface
types and discover interfaces that provide types; views are shown in the
interface details screen; views and adapters are categorized into
specific, extended and generic; user preferences allow you to customize
certain views; 3rd party modules can now be added to the Code Browser.

  - Improved I18n-based number and datetime formatting by integrating 'pytz'
for timezone support, implementing all missing format characters, and
reinterpreting the ICU documentation to correctly parse patterns.

  - Added '++debug++' traversal adapter that allows you to turn on
debugging flags in 'request.debug'. Currently the following flags
are defined: source, tal, errors.

  - Improved logout support.

  - Added the HTTP request recorder, which lets you inspect raw HTTP requests
and responses.  It can be used to create functional doctests without
requiring third-party tools such as TCPWatch.

  - Developed a generic 'browser:form' directive. It is pretty much the
same as the 'browser:editform' directive, except that the data is
not stored on some context or adapted context but sent 

dnspython 1.3.4

2005-08-03 Thread Bob Halley
dnspython 1.3.4 has been released.

New since 1.3.3:

The source address and port may now be specified when calling
dns.query.{udp,tcp,xfr}.

The resolver now does exponential backoff each time it runs
through all of the nameservers.

Rcodes which indicate a nameserver is likely to be a
permanent failure for a query cause the nameserver to be removed
from the mix for that query.

This release fixes all known bugs.

See the ChangeLog file for more detailed information on changes since
the prior release.

For the latest in releases, documentation, and information, visit the
dnspython home page at

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

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


Fredericksburg, VA ZPUG August 10: .Net, functional testing

2005-08-03 Thread Gary Poster
Please join us August 10, 7:30-9:00 PM, for the third meeting of the  
Fredericksburg, VA Zope and Python User Group (ZPUG).

This meeting has four features of note.

- Brian Lloyd, the author of Python for .Net (http://www.zope.org/ 
Members/Brian/PythonNet/) and the Zope Corporation VP of Engineering,  
will discuss his .Net platform and give a brief .Net overview.

- Benji York, Zope Corp Senior Software Engineer, will discuss  
current functional testing practices on Zope 3, including using  
Selenium on Zope 3, using demo storage for functional testing, and  
using his own compelling new functional test package.  Note that the  
majority of this discussion has strong applicability to automated  
testing of all web frameworks and applications.

- We will serve the now-usual geek-chic fruit, cheese, and soft drinks.

- Fred Drake, Zope Corp Senior Software Engineer, Python core  
developer, Python documentation maintainer and editor, and co-author  
of the O'Reilly book Python  XML will give two of his books (http:// 
www.amazon.com/exec/obidos/tg/detail/-/0596001282/) to new  
attendees.  Upon pressure, he admitted that he would be willing to  
autograph them if bribed with fruit, cheese, and soft drinks.

Note that we are eager to have non-Zope-Corporation employees give  
presentations. :-)

We had three new attendees last meeting, for a total of ten.  Please  
come and bring friends!

More information http://www.zope.org/Members/poster/ 
fxbgzpug_announce_3 and below.

Hope to see you there!

Gary

General ZPUG information

When: second Wednesday of every month, 7:30-9:00.

Where: Zope Corporation offices. 513 Prince Edward Street;  
Fredericksburg, VA 22408 (tinyurl for map is http://tinyurl.com/duoab).

Parking: Zope Corporation parking lot; entrance on Prince Edward Street.

Topics: As desired (and offered) by participants, within the  
constraints of having to do with Python.

Contact: Gary Poster ([EMAIL PROTECTED])



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

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


Parallel port programming on windows XP/2000?

2005-08-03 Thread Novice Experl
I'd like to write a simple application that interfaces with the parallel port, 
and changes the data on it according to keyboard input. I hope I can get it to 
run under windows xp and / or windows 2000.

How can I do this? What do I need to know? It doesn't look like the standard 
library (the one under my pillow) has that feature. In addition, I've heard 
that with newer versions of windows don't let you communicate with the port 
directly, instead requiring interfacing with some driver?

I came across this:
http://pyserial.sourceforge.net/pyparallel.html
but it seems to only be used for direct access (would it work with XP?), and 
hasn't been updated for a couple of years. In addition, it requires something 
called  Java Communications (JavaComm) extension for Java/Jython, doesn't 
provide a link to it, and when I google it - google returns the page I came 
from!

To add to the confusion, I hope I can provide a py2exe executable of my script 
instead of forcing a complete installation.


--=  Posted using GrabIt  =
--=  Binary Usenet downloading made easy =-
-=  Get GrabIt for free from http://www.shemes.com/  =-

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


Python 2.3.3 Exceptions

2005-08-03 Thread Saravanan
Hello,

Im using Python 2.3.3 along with Win32all (163).
Currently my python application runs as Windows Service. Im using
Win32all Service Framework to run the Python Code as a Windows Service.

The following error has been reported to event viewer sparadically.
Reporting queued error: faulting application PythonService.exe,
version 2.3.0.163, faulting module python23.dll, version 2.3.3150.1012,
fault address 0x0005c202.

Due to that, my service does not stops or crashes.

Can anybody guess what is the problem?

I have checked the Python Code, the crash always points to static int
default_3way_compare(PyObject *v, PyObject *w) function in object.c

As of now my project does not allow me to upgrade to higher version of
Python.

Thanks in Advance

Saravanan D

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


Re: Printing Docstrings Without Importing

2005-08-03 Thread Fuzzyman

Bengt Richter wrote:
 On 1 Aug 2005 06:50:23 -0700, Fuzzyman [EMAIL PROTECTED] wrote:

 This seems to scratch several people's itches.
 
 Care to develop/maintain it ?
 
 Are you talking to me? ;-)

 (My news server is having some problem. I saw my post on google groups
 but my normal news client isn't seeing it.)

 Assuming you are talking to me, there's a bug, naturally, in trying to
 escape None as a doc string. It was twenty minutes of hacking and a half hour
 of trying to choose html colors, so there's not that much there ;-)
 But what did you have in mind? Javascript menu rollovers for popup docs of
 functions and classes and methods etc? Full help info access? Optional pdf 
 output?

 That would take more than another hour, but I did fix the mentioned bug and 
 put
 a table of clickable module names at the top with the file date stamps and 
 paths
 so you can navigate down to the spcific module docstring output quickly if 
 you have
 a lot of them. Of course, I think I'd put styling in the header rather than 
 hack
 more raw html if I were to go another round.

 I'll post the latest once I can see my postings in context with my own 
 newsreader again.


Hello Brengt,

Sorry - I know it was a very terse reply. The state of automatic API
documentation generating tools is not very good in Python. Epydoc is
the best - but *seems* to be unmaintained. Many people find they can't
use it, because it imports code. Your approach of compiling the code
and introspecting the objects seems like the best alternative.

Some people argue against automatic API documentation *anyway* - but if
you write your docstrings intending them to be useful then it can save
a lot of work. However for a medium sized project, something like
Epydoc that shows the relationship between objects and links the doc
pages appropriately, can be very useful.

This is obviously a lot more work than just generating output for a
single modules.

Anyway - it's a subject that comes up regularly, and I haven't looked
into all the issues. There was some discussion on doc-sig about it a
while back.

All the best,


Fuzzy
http://www.voidspace.org.uk/python

 Regards,
 Bengt Richter

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


Re: Art of Unit Testing

2005-08-03 Thread Christoph Zwerschke
Benjamin Niemann wrote:
 The unittest module is a 'port' of the JUnit framework for Java which has a
 certain wellknown API and semantics. The same API is available for many
 other languages, so it is probably a good idea to stick with it in order to
 make people coming from other language feel more comfortable with Python.

Ok, that's a good reason. I just had a look at the JUnit homepage. It 
seems like unittest has only implemented a part of JUnit. But you're 
right, even JUnit lacks setUpOnce and tearDownOnce. I found the 
following excuse and workaround in the JUnit FAQ:
http://junit.sourceforge.net/doc/faq/faq.htm#organize_3

 Some (many?) people don't like the unittest module, because it is not very
 pythonic - nothing to wonder as it has its root in the Java world. That's
 probably one of the reasons why there are other (more pythonic) unittesting
 frameworks for Python out there.

So I think it would have been better that unittest had been named 
PUnit to make clear that it is a JUnit port and to allow a more 
pythonic testing framework to be added to the Python's standard lib.

 I prefer to use unittest (because this was the API the textbook was using
 that introduced me to this topic) and I also had the problem of heavy setup
 costs. I deal with it by using a script around my testsuite (instead of
 calling just unittest.main()) that does the setup/teardown of the
 environment.

Yes, I think that's the simplest solution.

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


Re: Setting a drive's volume label

2005-08-03 Thread Reinhold Birkenfeld
Bob Greschke wrote:
 Looks like the label system command will do it in Windows.  That's good 
 enough for this exercise.  So, in Linux...???

mlabel in the mtools package will do what you need. mkfs.vfat can also
be given a volume label, but it will not allow you to set the label without
creating a new filesystem :)

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


Re: Art of Unit Testing

2005-08-03 Thread Christoph Zwerschke
Peter Hansen wrote:
 What's wrong with using Python's existing global support, and just 
 having your test case setUp() call a global setup routine which checks 
 whether that global setup work has already been done and, if not, does 
 it once and sets a flag to say that it has now been done?  I've done 
 this easily in the few cases where I've wanted this behaviour.  It 
 doesn't seem complex enough to warrant adding to the standard unit test 
 support.

Actually I already thought about doing it that way, but then I thought 
it is so ugly, there must be a simpler solution ;-)

 If you're going to quote XP rules of thumb, the tests should be 
 independent and very fast, and if you have a setup code that is taking a 
 long time, it's likely a code smell of some kind, and you should be 
 fixing the design which prevents you writing these tests with minimal 
 and quick setup.  Are these really like acceptance tests?  If they 
 were unit tests, they should take only a few minutes to run, total, and 
 you should be running them all *many* times a day, not twice.

You're right. I think wanting to have a more global initialization 
indicates that you are acutally not wanting to do a unit test, but a 
more global test of the overall system, something like an acceptance or 
integration test, i.e. you are trying to abuse unittest for something it 
was not intended to be used for.

Maybe since unittest is the only testing framework included with the 
standard lib, people tend to use it for all testing purposes. If you 
only have a hammer, everything looks like a nail.

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


Re: pygettext ?

2005-08-03 Thread Jon Hewer
Hi

I'm pretty new to Python, and recently been working my way through
Dive Into Python, and I'm currently writing a really simple rss reader
purely to get familiarised with the language.  I want to move onto
something a little more challenging, but I'm stuck for ideas on what
to do.

I'm after a project that can start quite simple, but has lots of room
for expansion when I get more confident with Python.  Ideally
something which would start as a command line program, and then when I
feel adventurous I could build a GUI for it.

I have just bought the Foundations of Python Network Programming book,
so maybe something network related would be good?

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


Re: pygettext ?

2005-08-03 Thread Jon Hewer
That was sent with the wrong title, doh!

On 8/3/05, Jon Hewer [EMAIL PROTECTED] wrote:
 Hi
 
 I'm pretty new to Python, and recently been working my way through
 Dive Into Python, and I'm currently writing a really simple rss reader
 purely to get familiarised with the language.  I want to move onto
 something a little more challenging, but I'm stuck for ideas on what
 to do.
 
 I'm after a project that can start quite simple, but has lots of room
 for expansion when I get more confident with Python.  Ideally
 something which would start as a command line program, and then when I
 feel adventurous I could build a GUI for it.
 
 I have just bought the Foundations of Python Network Programming book,
 so maybe something network related would be good?
 
 Cheers
 Jon

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


Ideas for Python project?

2005-08-03 Thread Jon Hewer
Hi

I'm pretty new to Python, and recently been working my way through
Dive Into Python, and I'm currently writing a really simple rss reader
purely to get familiarised with the language.  I want to move onto
something a little more challenging, but I'm stuck for ideas on what
to do.

I'm after a project that can start quite simple, but has lots of room
for expansion when I get more confident with Python.  Ideally
something which would start as a command line program, and then when I
feel adventurous I could build a GUI for it.

I have just bought the Foundations of Python Network Programming book,
so maybe something network related would be good?

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


Administrative prohibition error when sending email

2005-08-03 Thread Lad
I use a new webhosting provider and I can not send an email from my
script.
This is the script that I use to test the connection

###
import smtplib,poplib,

#I first login to my POP3 account
M=poplib.POP3('www.mywebh.com')
M.user('MYWeb)
M.pass_('12345')
print M.pass_ #check if you login successfully

#next send a message
fromaddr = [EMAIL PROTECTED]
toaddrs  = [EMAIL PROTECTED]
msg=This is a test
server = smtplib.SMTP('www.ebayworldstuff.com:25')

server.set_debuglevel(1)
server.sendmail(fromaddr, toaddrs, msg)
server.quit()
#

It ends with SMTP error 550: Administrative prohibition

Where can be a problem?
Lad.

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


distutils package_dir newbie

2005-08-03 Thread peter
Hello all,

I've have following problem

the layout of my program is the following:
setup.py
project_dev/__init__.py
project_dev/someModule.py

now I want to make a source-installer so python setup.py install will
give the following directory stucture:

site-packages/project_user/__init__.py
site-packages/project_user/someModule.py

notice the namechange from project_dev to project_user

how do I achieve a namechange from project_dev to project_user???

I've tried several different versions of command package_dir options in
the setup function:
package_dir = {'project_user': 'project_dev'}
also package_dir = {'project_dev':'project_user'}
both without any success.  (relatively unintuitive option this is)

Can anybody give the correct way to achieve a directory-renaming when
creating an installer?

kind regards

Peter

keywords: renaming, directory, sdist, distutils, package_dir

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


Re: Art of Unit Testing

2005-08-03 Thread Benjamin Niemann
Christoph Zwerschke wrote:

 Benjamin Niemann wrote:
 Some (many?) people don't like the unittest module, because it is not
 very pythonic - nothing to wonder as it has its root in the Java world.
 That's probably one of the reasons why there are other (more pythonic)
 unittesting frameworks for Python out there.
 
 So I think it would have been better that unittest had been named
 PUnit to make clear that it is a JUnit port and to allow a more
 pythonic testing framework to be added to the Python's standard lib.

It was called PyUnit before it was integrated into the stdlib. Dunno why it
was renamed...

-- 
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Parallel port programming on windows XP/2000?

2005-08-03 Thread jkn

Novice Experl wrote:
 I'd like to write a simple application that interfaces with the parallel 
 port, and changes the data on it according to keyboard input. I hope I can 
 get it to run under windows xp and / or windows 2000.

 How can I do this? What do I need to know? It doesn't look like the standard 
 library (the one under my pillow) has that feature. In addition, I've heard 
 that with newer versions of windows don't let you communicate with the port 
 directly, instead requiring interfacing with some driver?

 I came across this:
 http://pyserial.sourceforge.net/pyparallel.html
 but it seems to only be used for direct access (would it work with XP?), and 
 hasn't been updated for a couple of years. In addition, it requires something 
 called  Java Communications (JavaComm) extension for Java/Jython, doesn't 
 provide a link to it, and when I google it - google returns the page I came 
 from!

 To add to the confusion, I hope I can provide a py2exe executable of my 
 script instead of forcing a complete installation.


 --=  Posted using GrabIt  =
 --=  Binary Usenet downloading made easy =-
 -=  Get GrabIt for free from http://www.shemes.com/  =-

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


Re: distutils package_dir newbie

2005-08-03 Thread Robert Kern
peter wrote:
 Hello all,
 
 I've have following problem
 
 the layout of my program is the following:
 setup.py
 project_dev/__init__.py
 project_dev/someModule.py
 
 now I want to make a source-installer so python setup.py install will
 give the following directory stucture:
 
 site-packages/project_user/__init__.py
 site-packages/project_user/someModule.py
 
 notice the namechange from project_dev to project_user
 
 how do I achieve a namechange from project_dev to project_user???
 
 I've tried several different versions of command package_dir options in
 the setup function:
 package_dir = {'project_user': 'project_dev'}
 also package_dir = {'project_dev':'project_user'}
 both without any success.  (relatively unintuitive option this is)
 
 Can anybody give the correct way to achieve a directory-renaming when
 creating an installer?

Works just fine for me.

from distutils.core import *

setup(name='somePackage',
   packages = ['project_user'], # - Are you sure you have this?
   package_dir = {'project_user': 'project_dev'},
)

-- 
Robert Kern
[EMAIL PROTECTED]

In the fields of hell where the grass grows high
  Are the graves of dreams allowed to die.
   -- Richard Harter

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


Re: Art of Unit Testing

2005-08-03 Thread Christoph Zwerschke
rafi wrote:
 'should' may be too strong, 'may' may be better. In the meantime I found:
 http://python-mock.sourceforge.net/

Thanks for the link. Björn also pointed to http://pmock.sourceforge.net

Using mock objects sounds like a good idea.

A problem with mock objects may be that they make writing tests for the 
occasional programmer yet another bit more difficult, and that you 
always have to ensure your mock objects really mock the real objects 
perfectly, so you have to write another test for that. The behavior and 
the API of the real objects may change every now and then.

Let me summarize some good answers in this thread:

- unittest is deliberately intended to be a JUnit implementation
- unittest is for *unit* testing (only) ;-)
- use mock objects to mimic the behaviour of external components like 
databases
- other more pythonic testing frameworks are out there

I think it would be good to have these remarks added to the unittest 
documentation in the Python library reference.

Also, if one of the more pythonic unit testing modules will be mature 
enough and widely accepted, I think it would be good to make it Python's 
standard (lib) testing framework and rename the current unittest back to 
pyunit or punit.

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

Re: distutils package_dir newbie

2005-08-03 Thread peter
thx for answering is such short notice.

I recieve the following error when I use your setup:
error: package directory 'project_user' does not exist
(the complete error is added at the end of this document)

I'm using python 2.3.5 (build by activeState) based on python 2.3.5

Do you have an idea what could have happened here?

kind regards

Peter

ps.
complete error
running sdist
warning: sdist: missing required meta-data: url
warning: sdist: missing meta-data: either (author and author_email) or
(maintain
er and maintainer_email) must be supplied
warning: sdist: manifest template 'MANIFEST.in' does not exist (using
default fi
le list)
warning: sdist: standard file not found: should have one of README,
README.txt
error: package directory 'project_user' does not exist

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


Re: distutils package_dir newbie

2005-08-03 Thread Robert Kern
peter wrote:
 thx for answering is such short notice.
 
 I recieve the following error when I use your setup:
 error: package directory 'project_user' does not exist
 (the complete error is added at the end of this document)
 
 I'm using python 2.3.5 (build by activeState) based on python 2.3.5
 
 Do you have an idea what could have happened here?

No. Works just fine on Python 2.3.5 on OS X. Did you copy-and-paste the 
setup.py file I gave? or did you type it yourself? Could you please give 
the full setup.py that you used?

(And please do some kind of quoting of the message you are responding to.)

-- 
Robert Kern
[EMAIL PROTECTED]

In the fields of hell where the grass grows high
  Are the graves of dreams allowed to die.
   -- Richard Harter

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


Re: pygettext ?

2005-08-03 Thread Jarek Zgoda
cantabile napisał(a):

 Hi, I'm trying to write an internationalized app. I'm learning python 
 and read that pygettext would help me, but I found elsewhere it was 
 obsolete (??)
 So, what's the correct and up to date tool to i18n python ?
 Is there a tutorial somewhere (python docs has nothing really usable : 
 I'd like at least an example!)

Here's a page from wxPython wiki, but I think it may be usable also with 
other GUI toolkits, as it contains many generic introductory 
informations: http://wiki.wxpython.org/index.cgi/Internationalization

Also, check sources of some existing application that has good i18n 
implementation, Gajim (http://www.gajim.org/) comes first to my mind.

-- 
Jarek Zgoda
http://jpa.berlios.de/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Programming Contest: First results

2005-08-03 Thread Brian Quinlan
Brian Quinlan wrote:
 Tomi Kyöstilä wrote:
 
Why don't I see my solution (__author__ = dOb) in the results? I'm 
sure that you got it as you replied to my mail.

Your solution is now included. See: 
http://www.sweetapp.com/pycontest/contest1/results.html

Good job!

Cheers,
Brian
-- 
http://mail.python.org/mailman/listinfo/python-list


Re[4]: 2-player game, client and server at localhost

2005-08-03 Thread Michael Rybak
I was a bit unhappy to read this, because what you describe here is
just what I've tried yesterday in my test-game with 2 balls, so if
I've pointed that out, you wouldn't have to say I
DLB don't understand threading either, it appears.
:'(

Thank you very much for putting so much effort in making things clear
to me, *this* email of your made everything clear as never. Still I
have problems, and hope you still don't mind me asking.

Some comments:

  while 1:
  render()

  inp = get_player_input()
  thread.start_new(send_inp, (inp,))
  thread.start_new(accept_opponents_inp, ())

DLB You don't understand threading either, it appears. Here you are
DLB starting a new thread for each input you want...
and

  while still_no_opponents_input_from_previous_iteration()
time.sleep(0.05)
DLB You're still focused on a turn based system, it looks like...

Now, that's *not* how I'm tending to do it; that's what I was thinking
of while trying the turn-based approach, and describing here;
Christopher Subich asked how it was done initially, so I brought my
hanging system out of shame again, and added something I was thinking
about to improve it, while I already realize that's not the way to go
- from your previous comprehensive posts.


DLB There should just be AN input thread, started at the very beginning,
DLB and it should just wait for input, then update the global state so
DLB the update step can do whatever.

As stated above, that's how I'm trying it right now. Still, if doing
it turn-base, I would have to create a new thread every time.
   I have some other questions though - please see below.

DLB Also, recommend you use threading, not thread as the module.
Surely will, why?

DLB SERVER
DLB An input thread would look something like:

DLB while True:
DLB data = socket.read() #assumes both clients write to same socket
DLB #otherwise use a select(client_socket_list)
DLB #followed by socket.read for the flagged socket(s)
DLB parse data
DLB lock global
DLB save in global state variables
DLB unlock global

Now, few questions. Do I need to time.sleep(0.xxx) in any of these
while True: loops, not to overwhelm CPU? I can measure the time at
beginning and end of each iteration to make things happen fixed number
of times per second, but should I? And another: do I get it right that
instead of lock global you mean:
  while global.locked:
  time.sleep(0.001)
  lock global
And I also wonder how do I make sure that 2 threads don't pass this
while loop simultaneously and both try locking global. There is a
probability, not?

 Now, for update thread:

DLB That is all

DLB Update thread
DLB while True:
DLB lock global
DLB copy state variables to local
DLB unlock global
DLB compute new world state (check for collisions -- bullet hits)
DLB for c in client_list
DLB send world state to c

In my yesterday experiment, I have a separate thread for each of 2
clients, and what I do there is:

def thr_send_status(player_sock):
while 1:
t, sub_addr = player_sock.recvfrom(128) #player ready to accept
player_sock.sendto(encode_status(g.get_status()), sub_addr)

I'm reading 1 byte from client every time before sending new update to
him. OK, Ok, I know that's not good, ok. Now, I like your idea much
more, where you say we first measure the processing speed of each
client, and send data to every client as often as he can process it:

DLB Slow client receives the first at T0, but the last (packet 100) comes in
DLB at T0+60. Fast client receives all packets in T0+10...

DLB It took 60 seconds to receive 10 seconds of data. Client sends
DLB back to server a rate of 6. Other client sends back rate of 1.

DLB Server now uses a modulo function on packet sends...

DLB for c in client
DLB if t mod c.rate  = 0
DLB send current world packet to client


Yes, this I great, but what if speed changes? Should I retest this
around every 10 seconds? I mean, server sending too much data to a
client is ok for server, but very bad for a client, since it starts
hanging and loses synchronization, unless I use a timestamp to throw
away late states (I think I need to re-read all your previous posts,
you've explained about synchronizing already).
 While thinking about this, I've decided to go the wrong way, and to
wait for confirmation from client before sending next pack.

Still, it shouldn't slow anything a lot, because client does this:

def thr_get_status(self, g, player_sock, player_id):
while 1:
player_sock.sendto(!, addr) #ready
self.local_status = decode_status(player_sock.recvfrom(128)[0])
g.set_status(self.local_status)


So they simply exchange data all the time in separate threads, even

Re: pygettext ?

2005-08-03 Thread Reinout van Schouwen
Hi,

On Wed, 3 Aug 2005, cantabile wrote:

 Hi, I'm trying to write an internationalized app. I'm learning python and 
 read that pygettext would help me, but I found elsewhere it was obsolete (??)
 So, what's the correct and up to date tool to i18n python ?

Short answer: the functionality of pygettext has been incorporated in 
the main gettext tool, so pygettext is obsolete.

regards,

-- 
Reinout van Schouwen   ***  student of Artifical Intelligence
email: [EMAIL PROTECTED]*** mobile phone: +31-6-44360778
www.vanschouwen.info   ***  help mee met GNOME vertalen: nl.gnome.org
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: trying to parse non valid html documents with HTMLParser

2005-08-03 Thread florent
 AFAIK not with HTMLParser or htmllib. You might try (if you haven't done
 yet) htmllib and see, which parser is more forgiving.

Thanks, I'll try htmllib.
In other case, I found a solution. Feeding data to the HTMLParser by 
chunks extracted from the string using string.split(), will allow me 
to loose only one tag at a time when an exception is raised !
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Programming Contest: First results

2005-08-03 Thread Tomi Kyöstilä
Brian Quinlan wrote:
 Brian Quinlan wrote:
 
 Tomi Kyöstilä wrote:

 Why don't I see my solution (__author__ = dOb) in the results? I'm 
 sure that you got it as you replied to my mail.
 
 
 Your solution is now included. See: 
 http://www.sweetapp.com/pycontest/contest1/results.html
 
 Good job!
 
 Cheers,
 Brian

Thanks! :)

Any idea when the next competition is coming? (it hasn't been quite 
weekly as you hoped, eh? ;)

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


Re: trying to parse non valid html documents with HTMLParser

2005-08-03 Thread florent
  From http://www.crummy.com/software/BeautifulSoup/:
 
 You didn't write that awful page. You're just trying to get
 some data out of it. Right now, you don't really care what
 HTML is supposed to look like.
 
 Neither does this parser.

True, I just want to extract some data from html documents. But the 
problem is the same. The parser looses the position he was in the string 
when he encounters a bad tag.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Programming Contest: First results

2005-08-03 Thread Brian Quinlan
Tomi Kyöstilä wrote:
 Any idea when the next competition is coming? (it hasn't been quite 
 weekly as you hoped, eh? ;)

Uh no. It turns out that I have less time than I thought, though a big 
chunk of it should be freed-up after this weekend. I do have an idea... :-)

Cheers,
Brian
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: JBUS and Python which way

2005-08-03 Thread Alan Kennedy
[mjekl]
  My aim is to have an idea of the alternatives technologies for
  accessing information produced by a machine with a JBUS interface
  (RS232) and how to access this information realtime in Python
  (connecting a PC locally via serial port).
 
  I'm aware of pyserial but I wonder if there is a library/module that
  takes care of accessing/interpreting JBUS protocol. I've searched for
  this without results.

A possibility you may not have considered is to use a Java library for 
Modbus/JBus, and then use jython to control that. The following looks 
like a likely candidate.

http://sourceforge.net/projects/jamod/

I imagine that writing your own cpython implementation wouldn't be that 
difficult. I did some modbus work in C back in the 90s, and it was 
pretty straightforward, but requiring a lot of finicky bit-twiddling. 
I'm pretty certain that writing a python implementation would be a snap.

  I also searched the net looking for some information so that I could
  have a birds-eye-view on this subject and got the impression that a
  possibility is to have the communication (JBUS protocol / buffering)
  managed by some hardware component. Is this so? Can some-one give me
  some pointers/resources on this subject. Would it still be possible
  to work with Python.

Well, if you do find some hardware component that manages the JBus 
interface, you've then turned your problem into How to talk between the 
PC and the JBus instrument-manager rather than How to talk between the 
PC and JBus instruments. Depending on the protocol used by the 
instrument-manager, you may be able to use python to control that.

HTH,

-- 
alan kennedy
--
email alan:  http://xhaus.com/contact/alan
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python IDE's

2005-08-03 Thread bruno modulix
Jon Hewer wrote:
 I do use Vim a lot.  I am currently using it for some PHP development
 i'm doing.  I'm been using it so much recently that i keep pressing
 ESC and typing vi commands out of vi.
 
 But, if i use Vi, then whenever i want to test some code i have to
 open up python, import the necessary modules and run it - I like the
 idea of developing python in an IDE and just hitting a run button.

the Emacs + python-mode combo solve this problem - and in fact gives
much more than the common run and print results feature of most IDEs,
since you can run either the whole script or any part of it in an
(embedded) interactive python shell - just as if you had copy/pasted the
code in the python shell... This is very useful for exploring/quick
testing.

-- 
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: distutils package_dir newbie

2005-08-03 Thread peter
hello Robert

I've tried your setup.py file and now it seems to work...
I've made the following fault in the setup:
I did use:
setup(..., packages = ['project_dev'], ...) instead of the correct one:
setup(..., packages = ['project_user'], ...)

you have been a great help

Peter

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


wmi addprinterdriver for remote PC

2005-08-03 Thread future_retro
Hi all, cannot work this one out at all...

import win32com.client
WBEM =
win32com.client.GetObject(rwinmgmts:{impersonationLevel=impersonate}!\\
+ servername + r\root\cimv2)
WBEM.Security_.Privileges.AddAsString(SeLoadDriverPrivilege)
drv = WBEM.Get(Win32_PrinterDriver)
drv.Properties_('Name').Value = HP Color LaserJet 8550 PCL 5C
drv.Properties_('SupportedPlatform').Value = Windows NT x86
drv.Properties_('Version').Value = 3
drv.Properties_('DriverPath').Value =
C:\\Printdrivers\\clj8550pcl5cwin2kxp
drv.Properties_('InfName').Value =
C:\\Printdrivers\\clj8550pcl5cwin2kxp\\hpbf401i.inf
method = drv.Methods_('AddPrinterDriver')
InParms = method.InParameters
InParms.Properties_.Item('DriverInfo').Value = drv
drv.ExecMethod_('AddPrinterDriver',InParms)

If servername is . the driver loads.  If it is a remote machine the
script runs without any errors but no printerdriver is created.  As far
as can tell its not a privilege issue and when running through
pythonwin it looks like the object is created but it doesn't show up in
server properties.  It also runs too quickly so I'm pretty sure its not
doing anything.  I've tried different drivers but no joy.

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


Re: wmi addprinterdriver for remote PC

2005-08-03 Thread future_retro
soz I missed the glaring error.  The file paths need to be to a UNC
location of have to exist on the remote PC.

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


Re: Parallel port programming on windows XP/2000?

2005-08-03 Thread Neil Benn
Novice Experl wrote:

I'd like to write a simple application that interfaces with the parallel port, 
and changes the data on it according to keyboard input. I hope I can get it to 
run under windows xp and / or windows 2000.

How can I do this? What do I need to know? It doesn't look like the standard 
library (the one under my pillow) has that feature. In addition, I've heard 
that with newer versions of windows don't let you communicate with the port 
directly, instead requiring interfacing with some driver?

I came across this:
http://pyserial.sourceforge.net/pyparallel.html
but it seems to only be used for direct access (would it work with XP?), and 
hasn't been updated for a couple of years. In addition, it requires something 
called  Java Communications (JavaComm) extension for Java/Jython, doesn't 
provide a link to it, and when I google it - google returns the page I came 
from!

To add to the confusion, I hope I can provide a py2exe executable of my script 
instead of forcing a complete installation.


--=  Posted using GrabIt  =
--=  Binary Usenet downloading made easy =-
-=  Get GrabIt for free from http://www.shemes.com/  =-

  

Here's teh link to jaavx.comm - 
http://java.sun.com/products/javacomm/index.jsp.

The interface stuff, hmm I'm not quite sure what you are on about you 
access ports through the win32 API which is the 'driver' - you could 
probably bypass this and start playing around with assembly code but 
there's no point!!

Cheers,

Neil

-- 

Neil Benn
Senior Automation Engineer
Cenix BioScience
BioInnovations Zentrum
Tatzberg 47
D-01307
Dresden
Germany

Tel : +49 (0)351 4173 154
e-mail : [EMAIL PROTECTED]
Cenix Website : http://www.cenix-bioscience.com

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


Re: trying to parse non valid html documents with HTMLParser

2005-08-03 Thread Benji York
florent wrote:
 True, I just want to extract some data from html documents. But the 
 problem is the same. The parser looses the position he was in the string 
 when he encounters a bad tag.

Are you saying that Beautiful Soup can't parse the HTML?  If so, I'm 
sure the author would like an example so he can fix it.
--
Benji York


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


Re: Parallel port programming on windows XP/2000?

2005-08-03 Thread Benji York
Novice Experl wrote:
 I'd like to write a simple application that interfaces with the parallel port

Use pyParallel.  You don't have to worry about the Java stuff unless
you're using Jython.  Just follow the instructions on the page
(download, unarchive, python setup.py install).

After that you have to understand how the parallel port works, but I'll
assume you already do or can use the web to figure it out.
--
Benji York



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


Re: Art of Unit Testing

2005-08-03 Thread phil hunt
On Tue, 02 Aug 2005 21:11:52 +0200, Christoph Zwerschke [EMAIL PROTECTED] 
wrote:
Thanks for the link, Grig. I wasn't aware of the py lib so far. The 
possibility to create fixtures at the three different scopes is exactly 
what I was looking for.

Anyway, I think it would be nice to have that feature in the standard 
lib unittest as well. It should not be too hard to add setUpOnce and 
tearDownOnce methods in addition to setUp and tearDown. Actually, I am 
wondering that there doesn't seem to be any development progress since 
unittest was included in the standard lib of Python 2.1 in August 2001. 
I had expected that such an important module would be continually 
improved and maintained. How come? So few people using unit tests? Or do 
most people write their own testing code or use py.test?

I can answer this question, at least for myself.

I use regression testing a lot, and have done so since before 
Python's unittest was written.

Originally I just used my own code, which didn't use classes just 
functions that called other functions. later on I decided to have a 
look at unittest. I found two problems with it. 

Firstly it didn't 
stop when it reached an error, it continued doing the rewsr of the 
tests. This wasn't what i wanted: most of the time when a test 
fails, I want to look at what's happening. I don't want unnecessary 
information about other tests, I want to concentrate on that one 
thing.

Also, the log of information sent to stdout about each test was less 
informative than I wanted (and which my old system provided).

So I had a look at unittest to see if I could modify it to fix these 
problems. However, I found the code to be rather complex and hard to 
understand so I decided it would be quicker to write my own testing 
framework. Which I did.


-- 
Email: zen19725 at zen dot co dot uk


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


Re: Art of Unit Testing

2005-08-03 Thread phil hunt
On Tue, 02 Aug 2005 19:02:09 +0200, Björn Lindström [EMAIL PROTECTED] wrote:
Christoph Zwerschke [EMAIL PROTECTED] writes:

 Would it make sense to add globaleSetup and globalTearDown methods
 to the TestCase class? I think at least it would not harm
 anybody. Where should such proposals be submitted?

In general that's not such a good idea. If you build your tests like
that, it gets hard to know which test really went wrong,

No it isn't, provided you've coded your setup code and tests well.

And if you haven't coded your setup code and tests well, you're 
fucked anyway.

Programming languages and libraries should assume the programmers is 
competent and knows what he's doing. People who disagree should 
stick to Java or Pascal or something.

 and you might
get the situation where the whole set of tests works, but depend on each
other in some way. (This can also happen for more obscure reasons, and
is worth looking out for whichever way you do it.)

Sure. And if the programmer is competent, he'll bear that in mind 
when he's writing the tests.

So, rebuilding the environment for the each before every single test is
generally worth the overhead.

Note generally. Sometimes it isn't.

-- 
Email: zen19725 at zen dot co dot uk


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


Re: Art of Unit Testing

2005-08-03 Thread phil hunt
On Tue, 02 Aug 2005 21:26:28 +0200, Christoph Zwerschke [EMAIL PROTECTED] 
wrote:
Björn Lindström wrote:
Would it make sense to add globaleSetup and globalTearDown methods
to the TestCase class?
 In general that's not such a good idea.

I completely agree and I think it makes a lot of sense that unittest 
calls setUp and tearDown for every single test. However, the fact that 
this is *generally* the best way doesn't exclude the fact that there are 
*exceptions* when it makes sense to setUp and tearDown not for every 
test, e.g. when it is absolutely sure that the fixture cannot be 
destroyed by the individual tests or when creating the fixture takes too 
much time. I already gave the example of creating database connections 
or even creating/importing whole databases. My question was, how do I 
handle these cases with the standard lib unittest?

According to the extreme programming paradigm, testing should be done 
several times a day. So a requirement for extreme programm is that tests 
are fast enough. If the testing needs too much time, people are 
discouraged to test often.

Indeed. Running the tests should ideally take less than a few 
seconds. Any longer, and people won't use them so often.

-- 
Email: zen19725 at zen dot co dot uk


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


Re: Art of Unit Testing

2005-08-03 Thread phil hunt
On Tue, 02 Aug 2005 23:13:08 +0200, rafi [EMAIL PROTECTED] wrote:

 According to the extreme programming paradigm, testing should be done 
 several times a day. So a requirement for extreme programm is that tests 
 are fast enough. If the testing needs too much time, people are 
 discouraged to test often.

Well as I said above, a unit test is dedicated to a single function or 
method. So wehn you update a function / method, you should test the 
whole class or module, but maybe not the whole application

Often this is true. However sometimes the application is complex 
with all sorts of dependencies between different parts of it (I 
know, these should be kept to a minimum), and changes in one thing 
can break stuff in another module. When that happens, you want to 
know about it sooner rather than later.

-- 
Email: zen19725 at zen dot co dot uk


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


Re: ANN: Kamaelia 0.2.0 released!

2005-08-03 Thread phil hunt
On Tue, 02 Aug 2005 11:05:16 +0100, Michael Sparks [EMAIL PROTECTED] wrote:
Phil Hunt wrote:

 Kamaelia seems it might be an interesting project. However, I don't
 think the project is well served by this announcement -- which I 
 find vague and hard to understand. Which is a shame, because it
 means that other people probably don't understand it very well
 either, which means less people will use it.

It is a shame, and thanks for mentioning this. Let me have another
go :-) (ripping to shreds welcome :)

OK, here's a better go. (It's always difficult to think where to pitch
this sort of thing)
---START---
The project aims to make it simple to build networked multimedia
systems (eg audio, video, interactive systems),

There's plenty of software that facilitates networking, for example 
Python already has software for tcp and http clients/servers, and 
for xmlrpc remote procedure calls.

So what does Kamaelia do that's extra? I imagine it's to to with 
streaming large amounts of data. For example, a streaming video or 
audio player. Or VoIP, perhaps.

 which are naturally
componentised and naturally concurrent allowing quick and fast reuse in
the same way as Unix pipelines do. 

OK, so what do the components in the pipelines do? What sort of data 
do they hold? Unix pipelines act on ascii files; I assume you are 
do this on audio and visual data. What langauage will the ele,ments 
in thne pipelines be written it? I assume some will be in C/C++ for 
speed.

It is designed as a practical toolkit, such that you can build systems
such as:

When you say you who do you mean? Is the audience programmers or 
less technical people? A project that allows non-technical people 
to build complex network applications is an ambitious one, but not 
impossible (I'd find it very impressive and very exciting, 
particularly if it runs on devices such as mobile phones).

   * Ogg Vorbis streaming server/client systems (via vorbissimple)
   * Simple network aware games (via pygame)
   * Quickly build TCP based network servers and clients

What sort of servers and clients? Serving what? Could I use it, for 
example, to build a

   * Quickly build Multicast based network servers and clients

Serving what? Could I use it, for example, to build an n-player 
encrypted (I mean proper encryption here, the sort GCHQ or the NSA 
can't break) VoIP server to allow people to do conference calls over 
the Internet?

It runs on Linux, Window, Mac OS X with a subset running on Series 60
phones.

The basic underlying metaphor of a component us like an office worker
with inboxes and outboxes, with deliveries occuring between desks,
offices, and depts. The component can thus do work anyway it likes but
only communicates with these inboxes and outboxes. Like office workers,
components run in parallel, and to achieve this are generally
implemented using python generators, but can also used threads.

That metaphor brings up an image (at least to me) that the sorts of
data that can be communicated are things like documents,
spreadsheets, business graphs, memos. Also the metaphor doesn't 
indicate any sense of real-time-ness; stuff on an in tray isn't 
immediately processed and moved to the out tray.I'm pretty certain 
that's not what you have in mind. 

May I suggest a different metaphor? Consider a hi-fi system where 
you plug cables in to control the dataflow. For example, an 
unamplified audio signal goes into an amp, the amp has various dials 
and buttons on it, and an amplified signal comes out. Note that the 
signal processing is done in real time. 

Is that the sort of thing you are working on?

The rationale behind the project is to provide a toolkit enabling the
development of new protocols, including streaming, for large scale
media delivery.

OK, I get the straming part of it. But what asbout non-streaming 
stuff? What other protocols are necessary?

 The license essentially allows use in proprietary
systems without change, but all changes to the system itself must be
shared.

Fair enough.

---END---

Is that clearer ? 

A short summary of all that could be:

Kamaelia is a networking/communications infrastructure for innovative
multimedia systems. Kamaelia uses a component architecture designed to
simplify creation and testing of new protocols and large scale media
delivery systems.

Hopefully that's clearer than:

Kamaelia is a collection of Axon components designed for network
protocol experimentation in a single threaded, select based
environment. Axon components are python generators are augmented by
inbox and outbox queues (lists) for communication in a communicating
sequential processes (CSP) like fashion.

[ which you noted I really have very little idea what this means. ]

Sort of. But it's still a bit vague. For example:

networking/communications infrastructure can mean a lot of things.
It doesn't even specify whether it is hardware or software.

innovative. This actually has two meanings. One is is new /
allows new things to be 

Re: Art of Unit Testing

2005-08-03 Thread phil hunt
On Wed, 03 Aug 2005 09:35:08 +0200, Christoph Zwerschke [EMAIL PROTECTED] 
wrote:

 Some (many?) people don't like the unittest module, because it is not very
 pythonic - nothing to wonder as it has its root in the Java world. That's
 probably one of the reasons why there are other (more pythonic) unittesting
 frameworks for Python out there.

So I think it would have been better that unittest had been named 
PUnit to make clear that it is a JUnit port and to allow a more 
pythonic testing framework to be added to the Python's standard lib.

Not a bad idea.


-- 
Email: zen19725 at zen dot co dot uk


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


Re: ANN: Kamaelia 0.2.0 released!

2005-08-03 Thread phil hunt
On Tue, 2 Aug 2005 12:53:29 +0100, Tim Golden [EMAIL PROTECTED] wrote:
[Michael Sparks]
| Phil Hunt wrote:
| 
|  Kamaelia seems it might be an interesting project. However, I don't
|  think the project is well served by this announcement -- which I 
|  find vague and hard to understand. Which is a shame, because it
|  means that other people probably don't understand it very well
|  either, which means less people will use it.
| 
| It is a shame, and thanks for mentioning this. Let me have another
| go :-) (ripping to shreds welcome :)
| 
| OK, here's a better go. (It's always difficult to think where to pitch
| this sort of thing)

[... snip ...]

I just wanted to say that I find the ideas behind Kamaelia
interesting, and I only wish I had an application for it!
Because I'm not especially into media-streaming, I'm more
interested in it from the point of view of the generator-based
architecture.

What prompted me to write now was in appreciation of Michael's
taking the effort to recast his words into a form which might
well be understood better by others (including me) when he
might well have simply huffed a bit and told the other poster 
to read the words on the site and stop complaining about the HTML!

I'd second that!

I'm not trying to be critical, honestly, I'm trying to understand
something that looks like it could be very cool indeed.

(And on a more general level to improve the average quality of 
documentation for open source projects. Something which is bvery 
often deficient.)

-- 
Email: zen19725 at zen dot co dot uk


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


Re: Art of Unit Testing

2005-08-03 Thread phil hunt
On Tue, 02 Aug 2005 18:44:01 +0200, Christoph Zwerschke [EMAIL PROTECTED] 
wrote:
In August 2001, there was a thread about the Art of Unit Testing:
http://groups.google.com/group/comp.lang.python/browse_frm/thread/aa2bd17e7f995d05/71a29faf0a0485d5

Paul Moore asked the legitimate question why there is no hook for a 
global fixture code that is run only once for the whole TestCase, as 
opposed to the normal setUp and tearDown code that is run for every 
single test in the TestCase. A global fixture would be preferable 
whenever creating the fixture is time consuming, e.g. you have to create 
a database connection or even a whole database.

What would be the preferred solution for such global fixtures? Simply 
create the database, run the TestCase, and drop the database?

Would it make sense to add globaleSetup and globalTearDown methods 
to the TestCase class? I think at least it would not harm anybody. Where 
should such proposals be submitted?

I think this cowuld be very useful. As to the name, do other xUnit 
testing frameworks have a common name? If not, may I suggest 
setupAll() and tearDownAll(). 


-- 
Email: zen19725 at zen dot co dot uk


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


Re: ANN: Kamaelia 0.2.0 released!

2005-08-03 Thread Sergei Organov
[EMAIL PROTECTED] (phil hunt) writes:
[...]
 Unix pipelines act on ascii files;

No, they don't.

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


Re: Art of Unit Testing

2005-08-03 Thread phil hunt
On Wed, 03 Aug 2005 10:19:05 +0200, Christoph Zwerschke [EMAIL PROTECTED] 
wrote:
rafi wrote:
 'should' may be too strong, 'may' may be better. In the meantime I found:
 http://python-mock.sourceforge.net/

Thanks for the link. Björn also pointed to http://pmock.sourceforge.net

Using mock objects sounds like a good idea.

A problem with mock objects may be that they make writing tests for the 
occasional programmer yet another bit more difficult, and that you 
always have to ensure your mock objects really mock the real objects 
perfectly, so you have to write another test for that. The behavior and 
the API of the real objects may change every now and then.

Let me summarize some good answers in this thread:

- unittest is deliberately intended to be a JUnit implementation
- unittest is for *unit* testing (only) ;-)

I use regression testing (using my lintest module, which is 
functionally similar to unittest) on the whole application. I really 
see no reason why the concept should be limited to testing 
individual modules (or roughly similar-sized pieces).

-- 
Email: zen19725 at zen dot co dot uk


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


Re: Art of Unit Testing

2005-08-03 Thread phil hunt
On Tue, 02 Aug 2005 17:18:51 -0400, Peter Hansen [EMAIL PROTECTED] wrote:

If you're going to quote XP rules of thumb, the tests should be 
independent and very fast, and if you have a setup code that is taking a 
long time, it's likely a code smell of some kind, and you should be 
fixing the design which prevents you writing these tests with minimal 
and quick setup.  Are these really like acceptance tests?  If they 
were unit tests, they should take only a few minutes to run, total,

Eek! Seconds, more like.

-- 
Email: zen19725 at zen dot co dot uk


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


Re: Art of Unit Testing

2005-08-03 Thread Peter Hansen
Christoph Zwerschke wrote:
 - unittest is for *unit* testing (only) ;-)

Why would you say that?  We've used it extensively for a wide ranging of 
testing, not limited to unit tests.

 - use mock objects to mimic the behaviour of external components like 
 databases

...when doing unit testing.  If you mock while doing higher level 
testing, you'll eventually regret it in most cases.

 Also, if one of the more pythonic unit testing modules will be mature 
 enough and widely accepted, I think it would be good to make it Python's 
 standard (lib) testing framework and rename the current unittest back to 
 pyunit or punit.

What, and break all the code that currently does import unittest?

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


Re: Wheel-reinvention with Python

2005-08-03 Thread Mike Meyer
Cliff Wells [EMAIL PROTECTED] writes:

 On Tue, 2005-08-02 at 20:17 -0400, Mike Meyer wrote:

 Um - you're not answering the question I asked. I asked What app do I
 use to bundle my applications for Unix, ala py2exe (or whatever it is)
 for Windows? You're telling me how to install wxPython on those
 platforms.
 I know how to install wxPython. What I want to know is how to build an
 application bundle for all those Unix systems for a Python app I use
 that includes wxPython - or any other third party libraries I may be
 using.

 Sorry, I assumed you'd know about distutils:

Cliff, please quit being an ass. You keep assuming that because some
tool isn't the answer to my question that I don't know about
it. That's simply rude. It would be *much* more polite to ask What's
wrong with distutils rather than saying So you don't know about
distutils.

 http://www.python.org/doc/current/dist/
 http://www.python.org/doc/current/dist/built-dist.html

 distutils can go so far as to build an rpm for you, but you'll need to
 package things like .debs yourself.

I've very familiar with distutils. It doesn't do what I asked for, in
that it only bundles up *my* code. It doesn't bundle the things I
depend on the way py2exe does. It's patently *not* the answer to the
question I asked.

For those who want .deb's out of distutils, there's a PR on
sourceforge that includes a patch to make it generate .debs that works
quite well.

Of course, anyone who built a .deb (or an RPM, or a port, or whatever)
that bundled up everything it needed would be doing *the wrong
thing*. Those formats are designed for packaging single distributions,
not applications. They include dependency information that is used to
fetch the dependencies and install them. From my standpoint, the
problem here is that you then have to get the dependencies into the
repository before you can put your application there and have it
work. For instance, my port of bicyclerepairman is stuck at an old
version because I haven't gotten a port PyMac accepted yet (it also
has to do with bugs in the xemacs port, but that's another story).

I'm surprised you haven't mentioned eggs yet. Those work across all
the platforms I named. Of course, they aren't the answer to my
question either, because, like PRMs et al, they only reference
external dependencies, they don't include them.


 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: Art of Unit Testing

2005-08-03 Thread Peter Hansen
Christoph Zwerschke wrote:
 I think wanting to have a more global initialization 
 indicates that you are acutally not wanting to do a unit test, but a 
 more global test of the overall system, something like an acceptance or 
 integration test, i.e. you are trying to abuse unittest for something it 
 was not intended to be used for.

As I mentioned in another post just now, we use unittest for acceptance 
testing and other kinds of high level testing.  We also try very very 
hard to follow XP rules of thumb in terms of keeping our setup code 
short and fast.  As a result, we generally don't need to do what you are 
finding you need to do, and unittest is quite adequate.  Don't try to 
make the point that unittest cannot do acceptance testing; it's _your_ 
acceptance tests which are the issue here, and I agree unittest was not 
designed specifically to do exactly what you want.  It also wasn't 
designed to prevent it, but really just to be uninvolved in this issue.

The whole JUnit family wasn't designed to solve all testing problems, 
but (I infer, from long use) to be a fairly simple and therefore general 
approach.  It doesn't have a huge array of features supporting all 
possible approaches to testing, but it's simple enough not to prevent 
you from doing what you need to do in most cases.

If you want a test framework with built-in support for what you need, 
that's fine.  In programming, one size doesn't fit all.

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


Re: Art of Unit Testing

2005-08-03 Thread Peter Hansen
phil hunt wrote:
 On Tue, 02 Aug 2005 21:26:28 +0200, Christoph Zwerschke [EMAIL PROTECTED] 
 wrote:
According to the extreme programming paradigm, testing should be done 
several times a day. So a requirement for extreme programm is that tests 
are fast enough. If the testing needs too much time, people are 
discouraged to test often.
 
 Indeed. Running the tests should ideally take less than a few 
 seconds. Any longer, and people won't use them so often.

That's probably too general a statement to be very useful, and I don't 
think it's probably helpful to a newcomer who is seeking guidance.

If one makes the XP-style distinction between unit and acceptance 
tests, then the acceptance test *suite* should take no more than some 
number of minutes.  I believe ten minutes absolute max is a commonly 
offered rule of thumb, but I've found even eight minutes a little too 
long.  Five seems to be just fine, and less if of course wonderful.

For unit tests, the entire suite should take only a minute or two, max, 
if possible, and preferably well under a minute.  If you're doing 
test-driven development (TDD), you will want to be able to run unit 
tests (though maybe not all of them) sometimes a couple of times per 
minute!  If the overhead is fifteen seconds, you can't type much new 
code in between running the tests.

Still, in a large project (and especially one written in Python, with 
the overhead of interpreter startup and the cost of executing bytecode) 
the suite can get fairly long if you have many hundreds of tests.  In 
that case, there's nothing that says you can't run individual test 
files, or even individual test cases, when you are focused on one small 
area of the code.  That should let you run tests in only a couple of 
seconds, as phil just recommended, in almost any case.

Having your code organized nicely into packages can help as well.  If 
you have a helpful test runner utility which scans subdirectories for 
test cases, you can easily run all the tests in a given package 
independently of the rest of the app while you are working on that one 
package, reducing the risk inherent in running only a subset of your 
full test suite.

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


COM makepy problem

2005-08-03 Thread Alexander Eisenhuth
Hello together,

My system:
ActivePython 2.4.1
Windows XP

I write a COM Server in VC++ 6.0 using ATL. So far so good. While I 
develop I got sometimes strange behaviour with makepy utility. Today 
again. :-(

What I do on the python (COM client) side.
1) Register COM server
2) Use COM makepy utility
3) Create com client object using win32com.client.Dispatch(...)

The generated file in

c:\python24\lib\site-packages\win32com\gen_py\{...}\IinterfaceName.py

seem not work corectly.

 From the traceback, when i do
myObj = win32com.client.Dispatch(ProgId)
--
[...]
__import__(win32com.gen_py. + dir_name + . + child)
   File 
c:\Python24\lib\site-packages\win32com\gen_py\D0BC1B38-B4AC-480A-86B0-81
DA572765CDx0x1x0\IDssInterface.py, line 125
IDssInterface_vtables_ = [dispatch_ = 1
^
SyntaxError: invalid syntax

file IDssInterface.py (starting at line 123)

[...]
LCID = 0x0

IDssInterface_vtables_dispatch_ = 1
IDssInterface_vtables_ = [
[...]

Now I change the file IDssInterface.py by hand to:
--
[...]
LCID = 0x0
IDssInterface_vtables_dispatch_ = 1
IDssInterface_vtables_ = [
[...]

and everything works fine !!!

Does anybody have a suggestion/idea/hint on that ???

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


Re: Art of Unit Testing (Acceptance Tests)

2005-08-03 Thread John Roth
Christoph Zwerschke [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Peter Hansen wrote:
 What's wrong with using Python's existing global support, and just 
 having your test case setUp() call a global setup routine which checks 
 whether that global setup work has already been done and, if not, does it 
 once and sets a flag to say that it has now been done?  I've done this 
 easily in the few cases where I've wanted this behaviour.  It doesn't 
 seem complex enough to warrant adding to the standard unit test support.

 Actually I already thought about doing it that way, but then I thought it 
 is so ugly, there must be a simpler solution ;-)

 If you're going to quote XP rules of thumb, the tests should be 
 independent and very fast, and if you have a setup code that is taking a 
 long time, it's likely a code smell of some kind, and you should be 
 fixing the design which prevents you writing these tests with minimal and 
 quick setup.  Are these really like acceptance tests?  If they were 
 unit tests, they should take only a few minutes to run, total, and you 
 should be running them all *many* times a day, not twice.

 You're right. I think wanting to have a more global initialization 
 indicates that you are acutally not wanting to do a unit test, but a 
 more global test of the overall system, something like an acceptance or 
 integration test, i.e. you are trying to abuse unittest for something it 
 was not intended to be used for.

 Maybe since unittest is the only testing framework included with the 
 standard lib, people tend to use it for all testing purposes. If you only 
 have a hammer, everything looks like a nail.

An excellent point, even though it's somewhat blunted by the
inclusion of doctest in the core.

Another point to ponder is that the originators of xUnit, Kent
Beck and Erich Gamma, did not intend it to be used for acceptance
testing. That ecological niche is filled by FIT. The Python port of
Fit can be acquired from the file libraries of the FitNessse or
Extremeprogramming Yahoo mailing lists. I'll get it onto the
CheeseShop (what used to be the Python Package Index) one
of these days Real Soon Now. (Arlo gave me a good shove at
Agile2005 in that direction.)

The FIT developers are working on standardizing the specs,
and expensive setups and teardown are definitely on the agenda.
In fact, that's one of my work items...

Unit testing usually does not require expensive setups and teardowns,
at least if you're not working on real tangled legacy code.
Acceptance testing does.

Meanwhile, there's a book and two web sites: fit.c2.com and
www.fitnesse.org to look at.

John Roth
Python Fit

 -- Christoph 

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


Re: HELP:sorting list of outline numbers

2005-08-03 Thread Scott David Daniels
Delaney, Timothy (Tim) wrote:
 Scott David Daniels wrote:
For 2.3: (using DSU -- Decorate, Sort, Undecorate)
...
 lst = ['1', '1.2', '1.12', '1.1', '3.1']
 decorated = [(numparts(txt), txt) for txt in lst]
 decorated.sort()
 lst[:] = [txt for code, txt in decorated]
 
 Slightly better to do::
  ...
  lst = ['1', '1.2', '1.12', '1.1', '3.1']
  decorated = [(numparts(txt), i, txt) for i, txt in enumerate(lst)]
  decorated.sort()
  lst[:] = [txt[-1] for d in decorated]

In the particular case given, I don't think it matters.

In general, however, I agree the latter is a better idea.  Just
so someone hopping in here is clear about what is better, and
explicitly _not_ because I think Tim misunderstands the issue,
The latter version, in the case of a match on the decorated
version compares first the key, and then, if the keys match,
it compares the position in the list.  In no case does it actually
compare the original list elements.  The 2.4 version (just using the
key= form of sort) does the same kind of thing; it avoids comparing
the element and only compares keys.  The reason you care about this
is that is can be arbitrarily expensive to compare elements, or the
elements themselves may be incomparable (think of complex numbers).

--Scott David Daniels
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pygettext ?

2005-08-03 Thread cantabile
Reinout van Schouwen a écrit :
 Hi,
 
 On Wed, 3 Aug 2005, cantabile wrote:
 
 Hi, I'm trying to write an internationalized app. I'm learning python 
 and read that pygettext would help me, but I found elsewhere it was 
 obsolete (??)
 So, what's the correct and up to date tool to i18n python ?
 
 
 Short answer: the functionality of pygettext has been incorporated in 
 the main gettext tool, so pygettext is obsolete.
 
 regards,
 
Thanks for the answer.
Is there a good tutorial somewhere ?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pygettext ?

2005-08-03 Thread cantabile
Jon Hewer a écrit :
 Hi
 
 I'm pretty new to Python, and recently been working my way through
 Dive Into Python, and I'm currently writing a really simple rss reader
 purely to get familiarised with the language.  I want to move onto
 something a little more challenging, but I'm stuck for ideas on what
 to do.
 
 I'm after a project that can start quite simple, but has lots of room
 for expansion when I get more confident with Python.  Ideally
 something which would start as a command line program, and then when I
 feel adventurous I could build a GUI for it.
 
 I have just bought the Foundations of Python Network Programming book,
 so maybe something network related would be good?
 
 Cheers
 Jon
Excuse me but what has this answer to do with my question ?
-- 
http://mail.python.org/mailman/listinfo/python-list


cut paste text between tkinter widgets

2005-08-03 Thread William Gill
Is there a simple way to cut and paste from a tkinter text widget to an 
entry widget?  I know I could create a mouse button event that triggers 
a popup (message widget) prompting for cut/paste in each of the widgets 
using a temp variable to hold the text, but I don't wnat to reinvent the 
wheel if there already is something that does the job.

Thanks,

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


Re: 2-player game, client and server at localhost

2005-08-03 Thread Christopher Subich
Michael Rybak wrote:

 As stated above, that's how I'm trying it right now. Still, if doing
 it turn-base, I would have to create a new thread every time.
I have some other questions though - please see below.

No, you should never need to create a new thread upon receiving input. 
What you want is inter-thread communication, a synchronous queue.

A synchronous queue is a thread-safe queue.  You'd push event updates to 
it from the communication thread, and in the update thread, WHICH IS 
ALWAYS RUNNING, you'd check the queue each loop to see if there was 
anything new.

 Now, few questions. Do I need to time.sleep(0.xxx) in any of these
 while True: loops, not to overwhelm CPU? I can measure the time at
 beginning and end of each iteration to make things happen fixed number
 of times per second, but should I? And another: do I get it right that
 instead of lock global you mean:
   while global.locked:
   time.sleep(0.001)
   lock global
 And I also wonder how do I make sure that 2 threads don't pass this
 while loop simultaneously and both try locking global. There is a
 probability, not?

You have the right idea, that locking's important, but when the 
grandparent poster said lock global, he meant lock global.  Locks 
are low-level primitives in any threading system, they can also be 
called mutexes.

Attempting to acquire a lock returns immediate if the lock can be 
acquired; if it can't (and it's set to block, which is the default) the 
thread will wait until it -can- acquire the lock -- the entire thrust of 
your 'time.sleep' loop, only good.

See thread.acquire and threading.Lock for python built-in locks.

 In my yesterday experiment, I have a separate thread for each of 2
 clients, and what I do there is:
 
 def thr_send_status(player_sock):
 while 1:
 t, sub_addr = player_sock.recvfrom(128) #player ready to accept
 player_sock.sendto(encode_status(g.get_status()), sub_addr)
 
 I'm reading 1 byte from client every time before sending new update to
 him. OK, Ok, I know that's not good, ok. Now, I like your idea much
 more, where you say we first measure the processing speed of each
 client, and send data to every client as often as he can process it:

Just how much data are you sending in each second? Testing client speed 
and managing updates that way is relatively advanced, and I'd argue that 
it's only necessary when your data has the potential to swamp a network 
connection.

  While thinking about this, I've decided to go the wrong way, and to
 wait for confirmation from client before sending next pack.

No, you definitely don't need to do this.  TCP is a reliable protocol, 
and so long as the connection stays up your client will receive data 
in-order with guaranteed arrival.

If you were using UDP, then yes you'd need (possibly) to send 
confirmation, but you'd probably need a more advanced version to handle 
missing / out-of-order packets.

  I'm also almost sure it's wrong to have separate sockets and threads
 for each player, you say I should select()/dispatch instead, but I'm
 afraid of that some *thing* being wrong with select() for Windows.
 Somehow, I'm doing a lot of thins the wrong way :(

Just use the Twisted library.  It abstracts that away, and not touching 
sockets is really much nicer.

 Before describing another problem I've encountered, I thought I'd
 remind you of what my test game is: each player controls it's ball by
 moving mouse pointer, towards which his ball starts moving; that's it.

What's the nature of your evend update? Do you say mouse moved N or 
mouse moved to (123,456)?  If it's the latter, then without motion 
prediction there's no way that either simulation should have the ball 
overshoot the mouse.  Synchronization, however, will still be an issue.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: HELP:sorting list of outline numbers

2005-08-03 Thread Christopher Subich
Felix Collins wrote:
 Using Decorate, Sort , Undecorate...
 
 works like a charm.

As a one-liner, you can also deconstruct and rebuild the outline numbers:

new_outline = ['.'.join(v) for v in (sorted([k.split('.') for k in
old_outline]))]
-- 
http://mail.python.org/mailman/listinfo/python-list


HTML/text formatting question

2005-08-03 Thread Dr. Who
I have a tool that outputs data in either html or text output.

Currently I'm writing chucnks like:

if html:
print 'htmlbody bgcolor=CC'
print 'table border=1 bgcolor=FF width=800'
print 'trtd colspan=2h2'
print 'Differences %s: %s' % (htypestr, lbl1)
if html:
...

This seems clunky and my next step was going to be to define generic
functions which would generate the surrounding html tags only when
passed the proper argument.  I was wondering if there was a better way
to do this with a standard Python library.  It looked like formatter
might but that it also might be too low-level.

Any help is appreciated,
Jeff

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


Re: MySQL help

2005-08-03 Thread [EMAIL PROTECTED]
Hey Dennis thanks for the tips I haven't had a chance to take another
stab at that code yet but I think I may try some of your suggestions.
The SQL statements are valid but something doesn't appear to work right
I may try and switch them to what you're suggesting and see if that
helps with my problem.

Thanks,

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


Re: cut paste text between tkinter widgets

2005-08-03 Thread Christopher Subich
William Gill wrote:
 Is there a simple way to cut and paste from a tkinter text widget to an 
 entry widget?  I know I could create a mouse button event that triggers 
 a popup (message widget) prompting for cut/paste in each of the widgets 
 using a temp variable to hold the text, but I don't wnat to reinvent the 
 wheel if there already is something that does the job.

1) TKinter text and entry widgets should already have proper event 
bindings for cut/copy/paste.  Test first with your system-default 
keyboard shortcuts (^C, ^X, ^V on Windows).  I haven't tried it myself, 
but I think those events bind to 'Cut', 'Copy', and 'Paste', 
so generating them should Do The Right Thing with selected text.

2) If you need to do any processing on the clipboard data, look at 
widget.selection_get [so named because of the way that X handles its 
clipboard]
-- 
http://mail.python.org/mailman/listinfo/python-list


pain

2005-08-03 Thread Mage
  Hello,

I started to learn python some months ago. Mostly for fun, but I 
replaced php to python in many tools at my company in the last weeks.

Because of our boss decision now I have to learn java. I can tell java 
is one of the worst things including WW2. Even after seeing the light I 
may vomit when I write java code.

Look at this tutorial from java.com:

public class BasicsDemo {
public static void main(String[] args) {
int sum = 0;
for (int current = 1; current = 10; current++) {
sum += current;
}
System.out.println(Sum =  + sum);
}
}

It is print sum(range(11)) in python.

I just had to tell this, sorry for the bandwith. I suggest you to feel 
lucky if you may use python at your work.

   Mage


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


Re: Py: a very dangerous language

2005-08-03 Thread Tom Anderson
On Mon, 1 Aug 2005, Peter Otten wrote:

 Harald Massa wrote:

 Always go to bed exactly when you want to write the first lambda.

 Eureka. The Twentieth Pythonic Thesis has finally surfaced.

So what does it mean that i do much of my programming in bed?

tom

-- 
non, scarecrow, forensics, rituals, bacteria, scientific instruments, ..
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: using httplib for authentication

2005-08-03 Thread Fuzzyman

James Stroud wrote:
 Hello All,

 I want to use python to download files from sites where authentication is
 required. The page appears to send a form with the login and pass by post. I
 would like to log in and keep this session open within python and
 download a number of files automatically. Could anyone kindly point me in the
 right direction? I have discovered httplib and read the documentation and
 looked at the examples, but they don't seem helpful for this.


Hello James,

httplib is built on top of the socket module - but is still a library
meant for doing fairly low level http operations. For fetching URLs,
urllib2 is probably the way to go. It handles GET and POST with ease.

If you think this will do the job then you could try reading the
urllib2 tutorial at :

http://www.voidspace.org.uk/python/articles.shtml#http

You might wnat to look at other extension modules too - ClientCookie
for handling cookies, ClientForm for automatically filling in the
forms, BeautifulSoup for parsing HTML pages

All the Best,

Fuzzy
http://www.voidspace.org.uk/python

 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


Re: trying to parse non valid html documents with HTMLParser

2005-08-03 Thread florent
 AFAIK not with HTMLParser or htmllib. You might try (if you haven't done
 yet) htmllib and see, which parser is more forgiving.

You were right, the HTMLParser of htmllib is more permissive. He just 
ignores the bad tags !
-- 
http://mail.python.org/mailman/listinfo/python-list


socket and os.system

2005-08-03 Thread mfaujour

I HAVE THIS PYTHON PROGRAMM:
 
 
[test]$ cat socpb.py
import BaseHTTPServer, SocketServer, os, socket, threading
 
 
# the server initialisation
server = SocketServer.TCPServer((socket.gethostname(),
8088),BaseHTTPServer.BaseHTTPRequestHandler)
t=threading.Thread(target=server.serve_forever)
t.setDaemon(1)
t.start()
 
 
# the command
os.system(sleep 3600)
[test]$
 
 
 
 
 
 
I LAUNCH IT:
 
 
[test]$ python socpb.py
 
 
[1]+  Stopped python socpb.py
[test]$ bg
[1]+ python socpb.py 
 
 
 
 
 
 
I LOOK THE PORT IT USE -- OK:
 
 
[test]$ netstat -taupe | grep 8088
tcp  0  0 test:8088   *:*   LISTEN  mik   32481   14092/python
 
 
 
 
 
 
I KILL THE PYTHON PROGRAMM (OR IT STOP BY ANOTHER WAY):
 
 
[test]$ kill 14092
[test]$
[1]+  Terminated  python socpb.py
 
 
 
 
 
 
I LOOK THE PORT -- NOK, I EXPECTED THAT THE PORT WAS FREED BUT SLEEP
IS LISTENING AND IF I TRY TO LAUNCH MY PROGRAMM, IT FAIL:
 
 
[test]$ netstat -taupe | grep 8088
tcp  0 0 test:8088  *:* LISTEN   mik   32481   14094/sleep
[test]$ python socpb.py
Traceback (most recent call last):
  File socpb.py, line 4, in ?
server = SocketServer.TCPServer((socket.gethostname(),
8088),BaseHTTPServer.BaseHTTPRequestHandler)
  File /usr/local/lib/python2.3/SocketServer.py, line 330, in __init__
self.server_bind()
  File /usr/local/lib/python2.3/SocketServer.py, line 341, in
server_bind
self.socket.bind(self.server_address)
  File string, line 1, in bind   
 
 
 

socket.error: (98, 'Address already in use')
 
 


IF I KILL THE SLEEP, ALL COME BACK FINE:
 
 
[test]$ kill 14094
[test]$ netstat -taupe | grep 8088
[test]$ python socpb.py
 
 

Re: trying to parse non valid html documents with HTMLParser

2005-08-03 Thread florent
 Are you saying that Beautiful Soup can't parse the HTML?  If so, I'm 
 sure the author would like an example so he can fix it.

I finally use the htmllib module wich is more permissive than the 
HTMLParser module when parsing bad html documents.
Anyway, where can I find the author's contact informations ?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Dabo in 30 seconds?

2005-08-03 Thread Tom Anderson
On Mon, 1 Aug 2005, Benji York wrote:

 Cliff Wells wrote:

 As I mentioned earlier, programming is half brains and half
 tenacity.

 +1 QOTY (quote of the year)

Personally, i'd say it was 50% brains, 40% tenacity and 20% basic 
arithmetic.

8)

tom

-- 
non, scarecrow, forensics, rituals, bacteria, scientific instruments, ..
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Dabo in 30 seconds?

2005-08-03 Thread Adriano Varoli Piazza
Tom Anderson ha scritto:
 On Mon, 1 Aug 2005, Benji York wrote:
 
 Cliff Wells wrote:

 As I mentioned earlier, programming is half brains and half
 tenacity.


 +1 QOTY (quote of the year)
 
 
 Personally, i'd say it was 50% brains, 40% tenacity and 20% basic 
 arithmetic.
 
 8)
 
 tom
 

The famed 110% efficiency/commitment/etc every manager wants and talks 
about comes from this?

-- 
Adriano Varoli Piazza
The Inside Out: http://moranar.com.ar
MSN: [EMAIL PROTECTED]
ICQ: 4410132
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Art of Unit Testing

2005-08-03 Thread phil hunt
On Wed, 03 Aug 2005 09:51:49 -0400, Peter Hansen [EMAIL PROTECTED] wrote:
phil hunt wrote:
 On Tue, 02 Aug 2005 21:26:28 +0200, Christoph Zwerschke [EMAIL PROTECTED] 
 wrote:
According to the extreme programming paradigm, testing should be done 
several times a day. So a requirement for extreme programm is that tests 
are fast enough. If the testing needs too much time, people are 
discouraged to test often.
 
 Indeed. Running the tests should ideally take less than a few 
 seconds. Any longer, and people won't use them so often.

That's probably too general a statement to be very useful, and I don't 
think it's probably helpful to a newcomer who is seeking guidance.

I did say ideally; if the test have to take longer, so be it.

If one makes the XP-style distinction between unit and acceptance 
tests, then the acceptance test *suite* should take no more than some 
number of minutes.  I believe ten minutes absolute max is a commonly 
offered rule of thumb, but I've found even eight minutes a little too 
long.  Five seems to be just fine, and less if of course wonderful.

I think we might be talking at cross purposes here. To me 
acceptance test suite means a test suite that has to be passed 
each time before a new version of the software is released to the 
users. I don't see that 10 minutes is a sensible limit here, unless 
you are releasing more often that once a day. (I once had an 
acceptance test suite that ran for 12 hours; I used to run it 
nightly).

If you're doing 
test-driven development (TDD), you will want to be able to run unit 
tests (though maybe not all of them) sometimes a couple of times per 
minute! 

That's what I often do.

Still, in a large project (and especially one written in Python, with 
the overhead of interpreter startup and the cost of executing bytecode) 
the suite can get fairly long if you have many hundreds of tests.

I'm currently running one with 227 assertions in 38 test functions.
It runs in 1 second on an AMD 3000+.


-- 
Email: zen19725 at zen dot co dot uk


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


Re: ANN: Kamaelia 0.2.0 released!

2005-08-03 Thread phil hunt
On 03 Aug 2005 17:30:31 +0400, Sergei Organov [EMAIL PROTECTED] wrote:
[EMAIL PROTECTED] (phil hunt) writes:
[...]
 Unix pipelines act on ascii files;

No, they don't.

Nitpicker.

I would have thought it was perfectly obvious, in context, what I 
meant.

-- 
Email: zen19725 at zen dot co dot uk


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


Re: time.clock() or time.time()

2005-08-03 Thread Shane Hathaway
Magnus Lycka wrote:
 Shane Hathaway wrote:
 
time.time() measures real time, while time.clock() measures the time the 
CPU dedicates to your program. 
 
 
 I suppose that varies with the platform... help(time.clock) says:
 
 Help on built-in function clock:
 
 clock(...)
  clock() - floating point number
 
  Return the CPU time or real time since the start of the process or 
 since
  the first call to clock().  This has as much precision as the 
 system records.
 
 Another thing to notice is that depending on OS, either time.time() or
 time.clock() might have much higher precision than the other.

I didn't notice that.  Thanks.

However, isn't this thoroughly un-Pythonic?  No wonder people have to 
ask.  Wouldn't it be better to have:

   time.time() - real time, with as much precision as the platform
 provides.  Does not wrap around.

   time.cputime() - CPU time, or real time on platforms that don't
 measure CPU time separately from real time.  May wrap around in
 long-running processes.

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


Re: Art of Unit Testing

2005-08-03 Thread Christoph Zwerschke
 - unittest is for *unit* testing (only) ;-)
 Why would you say that?  We've used it extensively for a wide ranging...

That was actually only a quote from this thread that summarizes some of 
the answers I got: unittest has no support for global fixtures, 
because it is intended for unit testing, not for global tests.

 What, and break all the code that currently does import unittest?

Just insert the two words punit as between import and unittest, 
and the code will run as before...

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


Re: HTML/text formatting question

2005-08-03 Thread Steven Bethard
Dr. Who wrote:
 I have a tool that outputs data in either html or text output.
 
 Currently I'm writing chucnks like:
 
 if html:
 print 'htmlbody bgcolor=CC'
 print 'table border=1 bgcolor=FF width=800'
 print 'trtd colspan=2h2'
 print 'Differences %s: %s' % (htypestr, lbl1)
 if html:
   ...

I'd create two Formatter classes, one for HTML and one for text.  It 
looks like, in your case, the HTML one should inherit from the text one. 
  Something like:

py class TextFormatter(object):
... def print_differences(self, htypestr, lbll):
... print 'Differences %s: %s' % (htypestr, lbll)
...
py class HTMLFormatter(TextFormatter):
... def print_differences(self, htypestr, lbll):
... print 'htmlbody bgcolor=CC'
... print 'table border=1 bgcolor=FF width=800'
... print 'trtd colspan=2h2'
... super(HTMLFormatter, self).print_differences(htypestr, lbll)
... print '/h2/td/tr/table/body/html'
...
py formatter = TextFormatter()
py formatter.print_differences('test', 'one')
Differences test: one
py formatter = HTMLFormatter()
py formatter.print_differences('test', 'one')
htmlbody bgcolor=CC
table border=1 bgcolor=FF width=800
trtd colspan=2h2
Differences test: one
/h2/td/tr/table/body/html

Using this strategy, you would replace all your print statements with 
calls to a formatter object.  Which formatter you use would be 
determined wherever you currently set 'html' to True or False.

HTH,

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


Re: trying to parse non valid html documents with HTMLParser

2005-08-03 Thread Steve M
You were right, the HTMLParser of htmllib is more permissive. He just
ignores the bad tags !

The HTMLParser on my distribution is a she. But then again, I am using
ActivePython on Windows...

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


Re: ANN: Kamaelia 0.2.0 released!

2005-08-03 Thread Michael Sparks
I've reordered the q's slightly to avoid repetition... Also by answering
this question first, it may put the rest of the answer into context
better.

phil hunt wrote:

 At what stage of completion is it? 

This is something we deliberately try to reflect in the version number.
Yes, you can build network servers and new protocols relatively simply
at the moment. Yes, you can integrate with pygame in a limited useful
fashion at present. Yes we have audio playback.

However we don't have yet... (some examples)
   * Decent GUI integration yet. 
   * /Full/ pygame integration. 
   * Nice integration with pymedia
   * Direct support for Dirac.
Which aside from other things means you can't build (say) a video
 SMIL playback system trivially, yet.

As a result that's why the version number is 0.2 - whilst you /can/ do a
lot, there's a lot more to do. Clearly that also naturally implies that
we don't expect any end user to be looking at the site. (The low
version number will normally scare them away)

The project aims to make it simple to build networked multimedia
systems (eg audio, video, interactive systems),
 
 There's plenty of software that facilitates networking, for example
 Python already has software for tcp and http clients/servers, and
 for xmlrpc remote procedure calls.

There is indeed.

 So what does Kamaelia do that's extra? I imagine it's to to with
 streaming large amounts of data. For example, a streaming video or
 audio player. Or VoIP, perhaps.

It's designed to make bolting things together to make these sorts of
system simpler and easier. At the same time it's designed to encourage
writing code in a way that makes it simpler. The natural side effect of
this is the  system might make it easier to take advantage of multiple
CPU systems as they come online, since it makes a system naturally
concurrent. As the original announcement said Kamaelia is designed as
a testbed. And by testbed I mean testbed as it testing out new ideas,
see if they work and see if they pan out. (Not as in a testing suite)

Probably the best way of describing the difference is this... After my
talk about Kamaelia at Europython, I had an long chat with Tommi
Virtinan about integration between Kamaelia and Twisted. I haven't had
a chance to follow up with him yet regarding how this would work, though
I have set a line in the sand aiming to have easy integration between
Kamaelia and Twisted before Kamaelia hits version 1.0.0. The impression
I got from Tommi was that he was most interested in the communications
aspect - the fact we can bolt together systems in a manner directly
akin to Unix pipelines, though I suspect he found the graphines aspect
more interesting. 

Or as someone asking a similar question at Open Tech exclaimed after
I finally managed to explain it better to them Ooooh - you're trying
to make concurrency EASY!.

 OK, so what do the components in the pipelines do?  What sort of data
 do they hold? Unix pipelines act on ascii files; I assume you are
 do this on audio and visual data. What langauage will the ele,ments
 in thne pipelines be written it? I assume some will be in C/C++ for
 speed.

Components are object instances of python classes. The data passed
between components are object instances. Clearly these python classes
can be written in python, C, C++, pyrex etc. Currently all of Kamaelia's
components are python based. Some existing components make calls
into some related C libraries via python bindings.. An example of
writing a component using Pyrex can be found here:
   * http://kamaelia.sourceforge.net/PyrexComponents.html

It is designed as a practical toolkit, such that you can build systems
such as:
 When you say you who do you mean? 

Generally I expect the readership of c.l.p/python-list@python.org to be
programmers. Python is generally easy to pick up and having asked
someone who's not done much programming beforehand (beyond
a small amount of VB and Access), and is pre-university to use the
system to build a simple streaming system prototyping visualising PVR
content on a mobile (and watching them succeed), they seem
relatively reasonable examples.

At some point, the ability to allow non-programmers to bolt together
Kamaelia systems would be desirable, but a first step is making it
simpler for programmers to bolt together systems. We currently have an
interactive visualisation tool(*), and the logical extension of that is
a tool that allows systems to be bolted together without knowing any
code.
   (*) http://kamaelia.sourceforge.net/AxonVisualiser.html

It'd be an interesting side project for someone to take forward, and
might be low hanging fruit in terms of projects. (Especially if viewed
initially as a tool for assisting development, rather than replacing
development)

 Is the audience programmers or
 less technical people? A project that allows non-technical people
 to build complex network applications is an ambitious one, but not
 impossible (I'd find it very impressive and very 

Re: finding sublist

2005-08-03 Thread Johan Lindberg
 thanks everyone. only a question. there is a way to advantage of binary
 sequences?

I doubt you'll find any way to optimize the code that somehow only
applies to binary sequences. You still have to find each possible
subsequence of minimum length within the sequence and compare it to all
other possible subsequences and that's what's going to take most of the
time.

If you haven't already, check out psyco
(http://psyco.sourceforge.net/). It will most definitely make your code
run faster.

BR
Johan Lindberg
[EMAIL PROTECTED]

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


In-place decorate-sort-undecorate - best implementation?

2005-08-03 Thread Tom Anderson
Subtitle: the war on temporary objects continues!

The page on python performance tips on the python.org wiki 
(http://wiki.python.org/moin/PythonSpeed/PerformanceTips) suggests the 
following code for sorting a list using decorate-sort-undecorate, but 
doing it in-place:

def sortby_inplace(somelist, n):
somelist[:] = [(x[n], x) for x in somelist]
somelist.sort()
somelist[:] = [val for (key, val) in somelist]

Doesn't the use of list comps there generate two temporary lists? Isn't 
that quite inefficient? Wouldn't it be better to use a good old fashioned 
loop?

def sortby_inplace(somelist, n):
for i in xrange(len(somelist)):
somelist[i] = (somelist[i][n], somelist[i])
somelist.sort()
for i in xrange(len(somelist)):
somelist[i] = somelist[i][1]

Testing this on a 10k-element list of (float, float, float, 
float) tuples gives me a speedup of 35%. On a million-element list it's 
only 4%, but hey, who sorts million-element lists anyway?

I don't have python 2.4; anyone care to check how they compare there? I 
used the following timer function:

import time
import random
n = 1
r = random.random
l = [(r(), r(), r(), r()) for i in xrange(n)]

def time(sorter):
l2 = []
l2.extend(l)
t0 = time.time()
sorter(l2, 2)
t1 = time.time()
return t1 - t0

tom

-- 
No hay banda
-- 
http://mail.python.org/mailman/listinfo/python-list


Secure email

2005-08-03 Thread whisper
I need to write a .cgi that will take the content of an https GET or 
POST and send it securely as email to an Outlook client.

I think that OpenSSL is somewhere in this, but I'm not even sure how to 
create the right certificate, how to use it to encrypt mail and how to 
install a certificate in Outlook (= 2000).

Code snippets and pointers to tutorials greatly appreciated. I've got a 
week to deploy this!

Thanks!

Dave LeBlanc
Seattle, WA USA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: In-place decorate-sort-undecorate - best implementation?

2005-08-03 Thread Benji York
Tom Anderson wrote:
 I don't have python 2.4; anyone care to check how they compare there? I 
 used the following timer function:

I think on 2.4 the new key option to list.sort would be the fastest 
way to accomplish what you want.
--
Benji York


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


Re: pain

2005-08-03 Thread Michael Hoffman
Mage wrote:

 Look at this tutorial from java.com:
 
 public class BasicsDemo {
public static void main(String[] args) {
int sum = 0;
for (int current = 1; current = 10; current++) {
sum += current;
}
System.out.println(Sum =  + sum);
}
 }

And then you have to compile it and set up your classpath...

 It is print sum(range(11)) in python.

I would have used print sum(xrange(11)) myself. This probably has almost 
zero measurable performance impact, but I think using xrange() instead 
of range() is usually a good habit. As you know, xrange() generates ints 
as it is called rather than all at once, which can be quite helpful with 
large ranges.

  I suggest you to feel lucky if you may use python at your work.

Every day.
-- 
Michael Hoffman
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Art of Unit Testing

2005-08-03 Thread Michael Hoffman
Benjamin Niemann wrote:
 Christoph Zwerschke wrote:
 
 
Benjamin Niemann wrote:

Some (many?) people don't like the unittest module, because it is not
very pythonic - nothing to wonder as it has its root in the Java world.
That's probably one of the reasons why there are other (more pythonic)
unittesting frameworks for Python out there.

So I think it would have been better that unittest had been named
PUnit to make clear that it is a JUnit port and to allow a more
pythonic testing framework to be added to the Python's standard lib.
 
 
 It was called PyUnit before it was integrated into the stdlib. Dunno why it
 was renamed...

unittest describes exactly what it does.

pyunit says that it is in Python (duh), and that it has something to do 
with units, which could be a whole number of things.

I'm thankful that logging is called logging as well, rather than log4py.
-- 
Michael Hoffman
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Parallel port programming on windows XP/2000?

2005-08-03 Thread c d saunter
Novice Experl ([EMAIL PROTECTED]) wrote:
: I'd like to write a simple application that interfaces with the parallel 
port, and changes the data on it according to keyboard input. I hope I can get 
it to run under windows xp and / or windows 2000.

: How can I do this? What do I need to know? It doesn't look like the standard 
library (the one under my pillow) has that feature. In addition, I've heard 
that with newer versions of windows don't let you communicate with the port 
directly, instead requiring interfacing with some driver?

I always use DLPortIO, makes life almost as simple as GWBasic and a DOS 
box...  You can either create a custom extension around this or use 
ctypes.  Generally speaking a custom .dll is only needed if you are your 
lpt transactions are bidirectional, highly interleaved and high bandwidth.

DLPortIO: http://www.driverlinx.com/DownLoad/DlPortIO.htm
ctypes: http://starship.python.net/crew/theller/ctypes/

Note that DLPortIO is not a Python thing, it's a generic Windows .dll with 
C and VB examples, and needs installing, so it can't be packaged with 
py2exe.  I'd guess this is the same for other parallel port accesing 
tools - I think you need admin privilidges on a Windows NT/2K/XP box to 
install  DLPortIO, but not to use it.  

If you decide this is the best route for you and find yourself stuck, drop 
me an email for some example code.

---

cds

: I came across this:
: http://pyserial.sourceforge.net/pyparallel.html
: but it seems to only be used for direct access (would it work with XP?), and 
hasn't been updated for a couple of years. In addition, it requires something 
called  Java Communications (JavaComm) extension for Java/Jython, doesn't 
provide a link to it, and when I google it - google returns the page I came 
from!

: To add to the confusion, I hope I can provide a py2exe executable of my 
script instead of forcing a complete installation.


: --=  Posted using GrabIt  =
: --=  Binary Usenet downloading made easy =-
: -=  Get GrabIt for free from http://www.shemes.com/  =-

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


Re: Parallel port programming on windows XP/2000?

2005-08-03 Thread c d saunter
Forgot to say - under OS' derived from Windows NT (i.e. NT 3.5, NT4, 2K, 
XP and future) it is not possible to directly access the parallel port, 
this has to be done by a kernel driver, hence the need to install 
something like DLPortIO, which parly exists in the kernel to access the 
hardware, and partly in userland to allow your programs to talk to the 
kernel part.

I find it very annoying just how far PCs have regressed in terms of 
simple IO - back in the 8 bit days it was easy to hook sensors and 
actuators up to a computer without much knowledge and program something 
with them in Basic.  These days it's almost impossible without special kit 
and lots of know how.  Heck, the old BBC Mirco had raw IO capabilites as 
fast as an IBM parallel port, and more flexible to boot.

Progress.  A real pain for rd types.

---

cds

c d saunter ([EMAIL PROTECTED]) wrote:
: Novice Experl ([EMAIL PROTECTED]) wrote:
: : I'd like to write a simple application that interfaces with the parallel 
port, and changes the data on it according to keyboard input. I hope I can get 
it to run under windows xp and / or windows 2000.

: : How can I do this? What do I need to know? It doesn't look like the 
standard library (the one under my pillow) has that feature. In addition, I've 
heard that with newer versions of windows don't let you communicate with the 
port directly, instead requiring interfacing with some driver?

: I always use DLPortIO, makes life almost as simple as GWBasic and a DOS 
: box...  You can either create a custom extension around this or use 
: ctypes.  Generally speaking a custom .dll is only needed if you are your 
: lpt transactions are bidirectional, highly interleaved and high bandwidth.

: DLPortIO: http://www.driverlinx.com/DownLoad/DlPortIO.htm
: ctypes: http://starship.python.net/crew/theller/ctypes/

: Note that DLPortIO is not a Python thing, it's a generic Windows .dll with 
: C and VB examples, and needs installing, so it can't be packaged with 
: py2exe.  I'd guess this is the same for other parallel port accesing 
: tools - I think you need admin privilidges on a Windows NT/2K/XP box to 
: install  DLPortIO, but not to use it.  

: If you decide this is the best route for you and find yourself stuck, drop 
: me an email for some example code.

: ---

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


Re: Dabo in 30 seconds?

2005-08-03 Thread Fernando Perez
Paul McNett wrote:

 I've done things like this in the past, in my own Visual Foxpro
 framework. In that situation, I had enough control over the deployment
 to also ship a small smtp client, and automatically email the error
 without requiring any interaction at all. Clients were impressed when
 I'd already have a fix for the problem before they even notified me of
 the issue!

Well, I thought about doing the same, which is easy since python already has
smtplib built into the stdlib.  I was just lazy and didn't do it.  Though I
would not implement it to send things silently without user acknowledgement. 
Since ipython is not installed by me on user machines (your situation was
obviously different), I prefer to notify users of things about to be done
first, in case they'd rather not have it 'call home'.

But it would be a nice enhancement to add the option for auto-emailing in case
of trouble.



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


Re: Printing Docstrings Without Importing

2005-08-03 Thread Jaime Wyant
On 1 Aug 2005 06:50:23 -0700, Fuzzyman [EMAIL PROTECTED] wrote:
 This seems to scratch several people's itches.


Has anyone tried this doxygen filter: http://i31www.ira.uka.de/~baas/pydoxy/

I really like doxygen but am not sure if this is worth the trouble.

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


Re: time.clock() or time.time()

2005-08-03 Thread Nelson Minar
[EMAIL PROTECTED] [EMAIL PROTECTED] writes:
 I'm trying to benchmark some function calls for Zope project

Other folks have explained time() vs. clock(), so I'll leave that.

But rather than roll your own timer functions, consider using timeit.

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


Re: using httplib for authentication

2005-08-03 Thread James Stroud
Thank you Fuzzy, I will look into these things. Maybe the site is setting a 
cookie, as you have suggested. I have never delved into the ways of http 
except to configure apache and write some very bare-bones web pages, so I 
have to say that some very obvious things do not occur to me.

James

On Wednesday 03 August 2005 08:41 am, Fuzzyman wrote:
 Hello James,

 httplib is built on top of the socket module - but is still a library
 meant for doing fairly low level http operations. For fetching URLs,
 urllib2 is probably the way to go. It handles GET and POST with ease.

 If you think this will do the job then you could try reading the
 urllib2 tutorial at :

 http://www.voidspace.org.uk/python/articles.shtml#http

 You might wnat to look at other extension modules too - ClientCookie
 for handling cookies, ClientForm for automatically filling in the
 forms, BeautifulSoup for parsing HTML pages

 All the Best,

 Fuzzy
 http://www.voidspace.org.uk/python
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Art of Unit Testing

2005-08-03 Thread Peter Hansen
Christoph Zwerschke wrote:
 - unittest is for *unit* testing (only) ;-)

 Why would you say that?  We've used it extensively for a wide ranging...
 
 That was actually only a quote from this thread that summarizes some of 
 the answers I got: unittest has no support for global fixtures, 
 because it is intended for unit testing, not for global tests.

Fair enough, as a quote, but it's still an inaccurate statement as I 
hoped I've made clear in the last several posts.  The need to do 
global fixtures is most definitely not inherent in acceptance-type 
testing, so it's incorrect to say unittest is limited to unit testing.

 What, and break all the code that currently does import unittest?
 
 Just insert the two words punit as between import and unittest, 
 and the code will run as before...

No thanks.  I have hundreds upon hundreds of test files and no desire to 
change them.  Luckily there's roughly a zero chance of this actually 
happening, so no problem. :-)

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


Re: Windows command line problem

2005-08-03 Thread [EMAIL PROTECTED]
considering that all the command lines are in sys.argv, it's very
simple.

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


Re: Art of Unit Testing

2005-08-03 Thread Peter Hansen
phil hunt wrote:
 I think we might be talking at cross purposes here. To me 
 acceptance test suite means a test suite that has to be passed 
 each time before a new version of the software is released to the 
 users. I don't see that 10 minutes is a sensible limit here, unless 
 you are releasing more often that once a day. (I once had an 
 acceptance test suite that ran for 12 hours; I used to run it 
 nightly).

We're clearly on different wavelengths.  I thought Extreme Programming 
was sort of the context, where the acceptance tests actually *are* run 
many times during the day, as well as before each new release.  (A new 
release could technically occur more than once in a day as well, so it's 
a good thing if the tests take less than 12 hours.)

Still, in a large project (and especially one written in Python, with 
the overhead of interpreter startup and the cost of executing bytecode) 
the suite can get fairly long if you have many hundreds of tests.
 
 I'm currently running one with 227 assertions in 38 test functions.
 It runs in 1 second on an AMD 3000+.

That's a nice start. ;-)

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


Re: pain

2005-08-03 Thread Mandus
Wed, 03 Aug 2005 17:45:34 +0200 skrev Mage:
   Hello,

 I started to learn python some months ago. Mostly for fun, but I 
 replaced php to python in many tools at my company in the last weeks.

 Because of our boss decision now I have to learn java. I can tell java 
[snip]

maybe you can use jython, and tell your boss it's Java. A boss forcing
people to learn and use Java probably have no interest at all ever read
the code himself, so you will probably get away with it. I mean, a
clueless boss...

or just find another place to work?

Don't code Java, be happy :-)

mvh,
-- 
Mandus - the only mandus around.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: socket and os.system

2005-08-03 Thread Mandus
Wed, 03 Aug 2005 15:46:50 - skrev mfaujour:

 I HAVE THIS PYTHON PROGRAMM:
  
[snip]

welcome to usenet!

Maybe you get an answer if you doesn't shout that much. Or maybe you
just have a problem with you Caps Lock?


-- 
Mandus - the only mandus around.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Art of Unit Testing

2005-08-03 Thread Benjamin Niemann
Michael Hoffman wrote:

 Benjamin Niemann wrote:
 Christoph Zwerschke wrote:
 
 
Benjamin Niemann wrote:

Some (many?) people don't like the unittest module, because it is not
very pythonic - nothing to wonder as it has its root in the Java world.
That's probably one of the reasons why there are other (more pythonic)
unittesting frameworks for Python out there.

So I think it would have been better that unittest had been named
PUnit to make clear that it is a JUnit port and to allow a more
pythonic testing framework to be added to the Python's standard lib.
 
 
 It was called PyUnit before it was integrated into the stdlib. Dunno why
 it was renamed...
 
 unittest describes exactly what it does.
 
 pyunit says that it is in Python (duh), and that it has something to do
 with units, which could be a whole number of things.

XUnit (with X being the preferred prefix for the programming language) is a
common and wellknown name for a certain kind of unittesting framework. Of
course there are some people around who know what unittesting is but never
heard of JUnit and it decendents. But a quick textsearch on the TOC of the
library reference would reveal it.
Anyway, it too late now.

 I'm thankful that logging is called logging as well, rather than log4py.

If someone is heavily using log4j and thinks about moving to Python, she
will be happy to see that her preferred logging API is available for Python
without even leaving the TOC of the library reference. log4X is a similar
case as XUnit.
(Is logging an implementation of the log4X API? Never used log4X...)

-- 
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: socket and os.system

2005-08-03 Thread Peter Hansen
mfaujour wrote:
 I HAVE THIS PYTHON PROGRAMM:
[snip]

 socket.error: (98, 'Address already in use')
  
 DOES SOMEONE HAS AN IDEA ?

PLEASE learn to format your questions more appropriately!  Your post is 
simply _awful_ to read.  At the very least, ALL CAPS is considered to be 
shouting, though I can see why you had to use them since it would have 
been impossible to see the questions amongst all the code.

In any case, assuming I've been able to guess at the specific problem 
based on the above lines, which isn't certain, you need to use a line 
something like this in your code to allow your server socket to bind to 
an address that was previously in use:

server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

For more background, I suggest a Google search on python so_reuseaddr.

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


Re: trying to parse non valid html documents with HTMLParser

2005-08-03 Thread Benjamin Niemann
Steve M wrote:

You were right, the HTMLParser of htmllib is more permissive. He just
 ignores the bad tags !
 
 The HTMLParser on my distribution is a she. But then again, I am using
 ActivePython on Windows...

Although building parsers is for some strange reason one of my favourite
programming adventures, I do not have such a personal relationship with my
classes ;)

-- 
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: Kamaelia 0.2.0 released!

2005-08-03 Thread phil hunt
On Wed, 03 Aug 2005 16:57:34 +0100, Michael Sparks [EMAIL PROTECTED] wrote:
I've reordered the q's slightly to avoid repetition... Also by answering
this question first, it may put the rest of the answer into context
better.

phil hunt wrote:

 At what stage of completion is it? 

This is something we deliberately try to reflect in the version number.
Yes, you can build network servers and new protocols relatively simply
at the moment. Yes, you can integrate with pygame in a limited useful
fashion at present. Yes we have audio playback.

However we don't have yet... (some examples)
   * Decent GUI integration yet. 
   * /Full/ pygame integration. 
   * Nice integration with pymedia
   * Direct support for Dirac.
Which aside from other things means you can't build (say) a video
 SMIL playback system trivially, yet.

Isn't SMIL something that's goinhg to go into web browsers? In which 
case, you'd presumably not want to build one yourself, I imagine?

 There's plenty of software that facilitates networking, for example
 Python already has software for tcp and http clients/servers, and
 for xmlrpc remote procedure calls.

There is indeed.

 So what does Kamaelia do that's extra? I imagine it's to to with
 streaming large amounts of data. For example, a streaming video or
 audio player. Or VoIP, perhaps.

It's designed to make bolting things together to make these sorts of
system simpler and easier. 

What you say bolting things together do you mean writing Python 
code? Or will there be some other way?

What I have in mind is something like a project I worked on some 
time ago, where a program could be written by drawing boxes on a GUI 
application, and drawing lines (representing data flow) to connect 
the boxes. So one half of a VoIP application might look like:

  +--+ ++ +---+
  | listen   | | convert to | | volume|
  | on udp   || audio  || control + |
  | port 600 | | stream | | output|
  +--+ ++ +---+

With something like this novel multimedia apps could be prototyped 
quickly (though making them into useful apps would take extra work 
-- in the case of a VoIP application you'd want a phonebook, for 
example).

At the same time it's designed to encourage
writing code in a way that makes it simpler. 

Examples would be useful here. Both of what it can do now, and what 
it will be able to do eventually.

The natural side effect of
this is the  system might make it easier to take advantage of multiple
CPU systems as they come online, since it makes a system naturally
concurrent. As the original announcement said Kamaelia is designed as
a testbed. And by testbed I mean testbed as it testing out new ideas,
see if they work and see if they pan out. (Not as in a testing suite)

So what it will eventually do is not cast in stone?

Probably the best way of describing the difference is this... After my
talk about Kamaelia at Europython, I had an long chat with Tommi
Virtinan about integration between Kamaelia and Twisted. I haven't had
a chance to follow up with him yet regarding how this would work, though
I have set a line in the sand aiming to have easy integration between
Kamaelia and Twisted before Kamaelia hits version 1.0.0. The impression
I got from Tommi was that he was most interested in the communications
aspect - the fact we can bolt together systems in a manner directly
akin to Unix pipelines, though I suspect he found the graphines aspect
more interesting. 

Or as someone asking a similar question at Open Tech exclaimed after
I finally managed to explain it better to them Ooooh - you're trying
to make concurrency EASY!.

 OK, so what do the components in the pipelines do?  What sort of data
 do they hold? Unix pipelines act on ascii files; I assume you are
 do this on audio and visual data. What langauage will the ele,ments
 in thne pipelines be written it? I assume some will be in C/C++ for
 speed.

Components are object instances of python classes. The data passed
between components are object instances. 

What sort of objects? For example, if an application is audio 
straming, what sort of objects will be passed? Will there be onre 
object passed for each 10 ms or so of sound, or will there be a 
continuously-set-up object that passes the data throught it a byte 
at a time?

And if it's written in Python, will it run fast enough?

Clearly these python classes
can be written in python, C, C++, pyrex etc. Currently all of Kamaelia's
components are python based. Some existing components make calls
into some related C libraries via python bindings.. An example of
writing a component using Pyrex can be found here:
   * http://kamaelia.sourceforge.net/PyrexComponents.html

My thought on this example:

  cdef class test(Axon.Component.component):
def mainBody(self):
  if self.dataReady(inbox):
data = self.recv(inbox)

Re: pain

2005-08-03 Thread Mage
Mandus wrote:

Wed, 03 Aug 2005 17:45:34 +0200 skrev Mage:
  

  Hello,

I started to learn python some months ago. Mostly for fun, but I 
replaced php to python in many tools at my company in the last weeks.

Because of our boss decision now I have to learn java. I can tell java 


[snip]

maybe you can use jython, and tell your boss it's Java. A boss forcing
people to learn and use Java probably have no interest at all ever read
the code himself, so you will probably get away with it. I mean, a
clueless boss...
  

Thank you, I will check this out. My company will switch to a jsp site. 
Isn't jython slower (I mean performance) than java? As well as I 
understand jython code will be interpreted twice.

or just find another place to work?
  

Acceptable but I have some reasons to stay.

Don't code Java, be happy :-)
  

I would be surprised if there were more than five python jobs in my 
country but have to look around.

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


Re: pain

2005-08-03 Thread Grant Edwards
On 2005-08-03, Mage [EMAIL PROTECTED] wrote:

 Isn't jython slower (I mean performance) than java? As well as
 I understand jython code will be interpreted twice.

Jython gets compiled into Java byte code just like Java gets
compiled into Java byte code.  Then whatever platform you're
using either interprets the Java byte code or uses some variant
of JIT compilation into native object code.

-- 
Grant Edwards   grante Yow!  HELLO, little boys!
  at   Gimme a MINT TULIP!! Let's
   visi.comdo the BOSSA NOVA!!
-- 
http://mail.python.org/mailman/listinfo/python-list


  1   2   >