ANN: pyparsing-1.3.3 released

2005-09-13 Thread Paul McGuire
Pyparsing 1.3.3 contains mostly bugfixes and minor enhancements over
previous releases, including some improvement in Unicode support.  Here
are the change notes:

Version 1.3.3 - September 12, 2005
--
- Improved support for Unicode strings that would be returned using
  srange.  Added greetingInKorean.py example, for a Korean version of
  Hello, World! using Unicode. (Thanks, June Kim!)

- Added 'hexnums' string constant (nums+ABCDEFabcdef) for defining
  hexadecimal value expressions.

- NOTE: ===THIS CHANGE MAY BREAK EXISTING CODE===
  Modified tag and results definitions returned by makeHTMLTags(),
  to better support the looseness of HTML parsing.  Tags to be
  parsed are now caseless, and keys generated for tag attributes are
  now converted to lower case.

  Formerly, makeXMLTags(XYZ) would return a tag with results
  name of startXYZ, this has been changed to startXyz.  If this
  tag is matched against 'XYZ Abc=1 DEF=2 ghi=3', the
  matched keys formerly would be Abc, DEF, and ghi; keys are
  now converted to lower case, giving keys of abc, def, and
  ghi.  These changes were made to try to address the lax
  case sensitivity agreement between start and end tags in many
  HTML pages.

  No changes were made to makeXMLTags(), which assumes more rigorous
  parsing rules.

  Also, cleaned up case-sensitivity bugs in closing tags, and
  switched to using Keyword instead of Literal class for tags.
  (Thanks, Steve Young, for getting me to look at these in more
  detail!)

- Added two helper parse actions, upcaseTokens and downcaseTokens,
  which will convert matched text to all uppercase or lowercase,
  respectively.

- Deprecated Upcase class, to be replaced by upcaseTokens parse
  action.

- Converted messages sent to stderr to use warnings module, such as
  when constructing a Literal with an empty string, one should use
  the Empty() class or the empty helper instead.

- Added ' ' (space) as an escapable character within a quoted
  string.

- Added helper expressions for common comment types, in addition
  to the existing cStyleComment (/*...*/) and htmlStyleComment
  (!-- ... --)
  . dblSlashComment = // ... (to end of line)
  . cppStyleComment = cStyleComment or dblSlashComment
  . javaStyleComment = cppStyleComment
  . pythonStyleComment = # ... (to end of line)



Download pyparsing at http://pyparsing.sourceforge.net.

-- Paul




Pyparsing is a pure-Python class library for quickly developing
recursive-descent parsers.  Parser grammars are assembled directly in
the calling Python code, using classes such as Literal, Word,
OneOrMore, Optional, etc., combined with operators '+', '|', and '^'
for And, MatchFirst, and Or.  No separate code-generation or external
files are required.  Pyparsing can be used in many cases in place of
regular expressions, with shorter learning curve and greater
readability and maintainability.  Pyparsing comes with a number of
parsing examples, including:
- Hello, World! (English and Korean)
- chemical formulas
- configuration file parser
- web page URL extractor
- 5-function arithmetic expression parser
- subset of CORBA IDL
- chess portable game notation
- simple SQL parser
- Mozilla calendar file parser
- EBNF parser/compiler

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

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


ANN: MayaVi-1.5 released

2005-09-13 Thread prabhu_r
Hi,

This is to announce the availability of the MayaVi Data Visualizer
version 1.5.

MayaVi is a free, easy to use, scientific data visualizer.  It is
written in Python, uses the Visualization Toolkit (VTK) for the
graphics and provides a GUI written using Tkinter.  MayaVi is
distributed under a BSD license.  It is also cross platform and should
run on any platform where both Python and VTK are available (this
includes Linux, Windows and Mac OSX).  Also bundled with MayaVi is a
VTK pipeline browser written in Python and a utility module that makes
using VTK easier from the Python interpreter.  For more information,
sources, binaries, screenshots, installation instructions,
documentation etc. visit the MayaVi home page at:

Home page: http://mayavi.sourceforge.net
SourceForge:   http://sourceforge.net/projects/mayavi
Download:

 http://sourceforge.net/project/showfiles.php?group_id=27020release_id=356146


New in this release
---

* Added new LUT editor contributed by Gerald Knizia and Arnd
  Baecker.  The LUT editor allows one to edit the colors in RGB or
  HSV mode.  The editor can also be used standalone.

* Added support to easily add user defined sources (works just
  like the user defined modules and filters).  Contributed by Ross
  Harder.

* Support for VolumeProMapper contributed by Daniel James White
  and Heikki Uuksulainen.

* Added a Vorticity filter (contributed by Gareth Clay) that
  computes the vorticity of input vector data.

* Updated MayaVi and vtkPipeline to work with VTK-CVS and VTK-5.x.
  Support for VTK versions  4.0 has been removed.  MayaVi and the
  pipeline browser will continue to work with VTK-4.x.

* Added a utility vtk_doc.py script that allows one to search the
  VTK class docs using a GUI.

* Fixed severe bug in opening data files belonging to a
  time-series under Windows.

* Fixed various other bugs (details in full changelog).


Acknowledgements


 Many thanks to SourceForge for their continued support in hosting
 MayaVi.  Thanks also to various the users who provided feature
 improvements, patches, bug reports, support and suggestions.


Have fun!
prabhu

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

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


BayPIGgies: DATE CHANGE September 15, 7:30pm (Google)

2005-09-13 Thread Aahz
The next meeting of BayPIGgies will be Thurs, September 15 at 7:30pm at
Google, Bldg 40, room Temp Tech Talk.  You need to go to the lobby of
Bldg 43 first to get a badge.

Ben Bangert will do SQLObject  FormEncode, A Practical Introduction
 - Using SQLObject to integrity check legacy databases
 - FormEncodes use for validation and data coercion
 - Easy web front-ends to databases
 - Fully abstracted database access for easy portability

BayPIGgies meetings alternate between IronPort (San Bruno, California)
and Google (Mountain View, California).  For more information and
directions, see http://www.baypiggies.net/


Before the meeting, we sometimes meet at 6pm for dinner.  Discussion of
dinner plans is handled on the BayPIGgies mailing list.  

Advance notice: The meeting agenda for October 13 and December 8 has been
set.  We've got some options on the plate for November but haven't
settled anything yet.  Please send e-mail to [EMAIL PROTECTED] if
you want to suggest an agenda (or volunteer to give a presentation).
-- 
Aahz ([EMAIL PROTECTED])   * http://www.pythoncraft.com/

The way to build large Python applications is to componentize and
loosely-couple the hell out of everything.
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

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


Re: Premature wakeup of time.sleep()

2005-09-13 Thread Nick Craig-Wood
Erich Schreiber [EMAIL PROTECTED] wrote:
  In the Python Library Reference the explanation of the time.sleep()
  function reads amongst others:
 
  The actual suspension time may be less than that requested because 
  any caught signal will terminate the sleep() following execution 
  of that signal's catching routine. Also, the suspension time may 
  be longer than requested by an arbitrary amount because of the 
  scheduling of other activity in the system.
 
  I don't understand the first part of this passage with the premature
  wakeup. What signals would that be?

If someone sent your process a signal.  Say you pressed CTRL-C - that
generates the INT signal which python translates to the
KeyboardInterrupt exception - and which does interrupt the sleep()
system call.

This probably isn't happening to you though.

  In the logs I see a about 1% of the wake-up delays beeing negative
  from -1ms to about -20ms somewhat correlated with the duration of the
  sleep. 20 minute sleeps tend to wake-up earlier then sub-second
  sleeps. Can somebody explain this to me? 

Sleep under linux has a granularity of the timer interrupt rate (known
as HZ or jiffies in linux-speak).

Typically this is 100 Hz, which is a granularity of 10ms.  So I'd
expect your sleeps to be no more accurate than +/- 10ms.  +/- 20ms
doesn't seem unreasonable either.

(Linux 2.4 was fond of 100Hz. Its more configurable in 2.6 so could be
1000 Hz. Its likely to be 100 Hz or less in a virtual private server.)

I'm not sure the best way of finding out your HZ, here is one (enter
it all on one line)

start=`grep timer /proc/interrupts | awk '{print $2}'`; sleep 1;
end=`grep timer /proc/interrupts | awk '{print $2}'`; echo $(($end-$start))

Which prints a number about 1000 on my 2.6 machine.

-- 
Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to protect Python source from modification

2005-09-13 Thread Robert Kern
Frank Millman wrote:
 Steven D'Aprano wrote:
 
On Mon, 12 Sep 2005 08:33:10 -0700, Frank Millman wrote:

My problem is that, if someone has access to the network and to a
Python interpreter, they can get hold of a copy of my program and use
it to knock up their own client program that makes a connection to the
database. They can then execute any arbitrary SQL command.

Why is that your problem, instead of the company's problem? It is their
database server, yes? If they want to connect to it and execute arbitrary
SQL commands on their own database, (1) who are you to tell them they
can't? and (2) they hardly need your program to do it.

--
Steven
 
 If they choose to give the userid and password to an individual, they
 are obviously giving him permission to execute any command.
 
 On the other hand, they can reasonably expect to set up users without
 giving them direct access to the database, in which case I think they
 would be upset if the users found this restriction easy to bypass.

Certainly, but that access control *shouldn't happen in the client*
whether the source is visible or not.

-- 
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: How to protect Python source from modification

2005-09-13 Thread Bryan Olson
Steve M wrote:
[...]
  1. Based on your description, don't trust the client. Therefore,
  security, whatever that amounts to, basically has to happen on the
  server.

That's the right answer. Trying to enforce security within your
software running the client machine does not work. Forget the
advice about shipping .py's or packaging the client in some way.

  The server should be designed with the expectation that any
  input is possible, from slightly tweaked variants of the normal
  messages to a robotic client that spews the most horrible ill-formed
  junk frequently and in large volumes. It is the server's job to decide
  what it should do. For example, consider a website that has a form for
  users to fill out. The form has javascript, which executes on the
  client, that helps to validate the data by refusing to submit the form
  unless the user has filled in required fields, etc. This is client-side
  validation (analagous to authentication). It is trivial for an attacker
  to force the form to submit without filling in required fields. Now if
  the server didn't bother to do its own validation but just inserted a
  new record into the database with whatever came in from the form
  submission, on the assumption that the client-side validation was
  sufficient, this would constitute a serious flaw. (If you wonder then
  why bother putting in client-side validation at all - two reasons are
  that it enhances the user experience and that it reduces the average
  load on the server.)

Good advice.


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


Re: which is more 'pythonic' / 'better' ?

2005-09-13 Thread gabor
Terry Reedy wrote:
 Will McGugan [EMAIL PROTECTED] wrote in message 
 news:[EMAIL PROTECTED]
 
You may be right. I always use plural nouns for collections.
 
 
 ditto
 
To me 'line' would suggest there was just one of them,
so I assumed it was string.
 
 
 I did too.
 

i'm sorry ;) it was  a list of strings...

the code was something like:

for line in open('x.y'):
line = line.split('\t')


a better naming would be better it seems :)

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


Re: OCR librarys

2005-09-13 Thread Josef Meile
Hi Timothy

 i'm looking for ocr librarys with reasonably free licensing and the 
 ablity to use python with them. c library's that i can call from python 
 are acceptable.
This thread may give you an start:
http://groups.google.ch/group/comp.lang.python/browse_frm/thread/362ac64a3c3aece2/

It mentioned how to call simpleocr, which according to the website:
http://www.simpleocr.com

it is Royalty Free. I haven't tried it, so, I can say how accurate it
is.

Regards,
Josef


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


Get Mac OSX Version

2005-09-13 Thread rbt
Is there a similar function to sys.getwindowsversion() for Macs?

Many thanks!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: First release of Shed Skin, a Python-to-C++ compiler.

2005-09-13 Thread Fuzzyman

Mark Dufour wrote:
 In general it's considered quite pythonic to catch exceptions :-)
 It's a particularly useful way of implementing duck typing for example.
 I'm not sure if I've got *any* code that doesn't use exceptions
 somewhere

 Hehe. Okay. It will probably always be the case that you have to lose
 some Python features if you want the code to run really fast. I
 suppose PyPy's restricted Python subset doesn't support duck typing
 either. Luckily not all code is performance critical, or you could
 just try and optimize some performance critical part. But anyway, I'm
 starting to understand that Shed Skin should probably support
 exceptions wherever possible :-)



Ok - the point I was trying to make was that exceptions were pretty
integral to Python. I accept that losing the more dynamic features of
Python for 'compilation' is a possibly worthwhile tradeoff.

How easy is it going to be to call your c++ code from Python (and vice
versa) ?


Fuzzyman
http://www.voidspace.org.uk/python/index.shtml

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


Re: read stdout/stderr without blocking

2005-09-13 Thread Jacek Popławski
Grant Edwards wrote:
 On 2005-09-12, Jacek Pop?awski [EMAIL PROTECTED] wrote:
 
ready = select.select(tocheck, [], [], 0.25) ##continues after 0.25s
for file in ready[0]:
try:
text = os.read(file, 1024)

How do you know here, that you should read 1024 characters?
What will happen when output is shorter?
 
 
 It will return however much data is available.

My tests showed, that it will block.

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


Re: read stdout/stderr without blocking

2005-09-13 Thread Jacek Popławski
Only solution which works for now is to redirect stderr to stdout, and 
read stdout on thread.
Code without thread or with read() or read(n) (when n1) can block.
Code with select() and read(1) works, but it is very slow.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Get Mac OSX Version

2005-09-13 Thread Robert Kern
rbt wrote:
 Is there a similar function to sys.getwindowsversion() for Macs?

platform.mac_ver()

(And while we're at it: platform.win32_ver() might be prefered to
sys.getwindowsversion())

-- 
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: Simplifying imports?

2005-09-13 Thread Reinhold Birkenfeld
Terry Hancock wrote:
 On Monday 12 September 2005 10:09 pm, [EMAIL PROTECTED] wrote:
 I like to keep my classes each in a separate file with the same name of
 the class. The problem with that is that I end up with multiple imports
 in the beginning of each file, like this:
 
 from foo.Bar import Bar
 from foo.Blah import Blah
 from foo.Zzz import Zzz
 
 What I'd like to do would be to replace it all by a single line:
 
 from foo.* import *
 
 Of course, that doesn't work, but is there a way to do something like
 that?
 
 Apparently foo is already a package defined using __init__.py,
 so you know about that part already.
 
 Just change its contents to read:
 
 from Bar import Bar
 from Blah import Blah
 from Zzz import Zzz
 
 Then whenever you need to use these classes, you only need:
 
 from foo import Bar, Blah, Zzz
 
 or
 
 from foo import *

Or, if the Bar, Blah and Zzz classes are small enough, there's no need to
put each of them in separate modules. Just put them in foo.py.

Concise structuring of classes and modules is not easy. Structure too much,
and you will not see the wood for the trees. Structure too little, and you
won't find things anymore. IMO, the Twisted project is an example of
excellent Python structuring.

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


Re: improvements for the logging package

2005-09-13 Thread Thomas Heller
Vinay Sajip [EMAIL PROTECTED] writes:

 OK, it's not right at the top of the docs, but the example at

 http://docs.python.org/lib/minimal-example.html

 has been there for a while, and if you think it can be made clearer,
 please suggest how.

Maybe I'm missing something, but the code from the example doesn't work
for me:


 import logging

 logging.basicConfig(level=logging.DEBUG,
... format='%(asctime)s %(levelname)s %(message)s',
... filename='/tmp/myapp.log',
... filemode='w')
Traceback (most recent call last):
  File stdin, line 4, in ?
TypeError: basicConfig() takes no arguments (4 given)

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


Re: Simplifying imports?

2005-09-13 Thread bruno modulix
[EMAIL PROTECTED] wrote:
 I like to keep my classes each in a separate file with the same name of
 the class. 

Let me guess: you have a C++ or Java background ?-)

-- 
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: PyGTK or wXPython?

2005-09-13 Thread Alessandro Bottoni
Rod W wrote:

 I'm just starting out on Python but my primary goal is to provide
 applications with some user interface (GUI).
 
 Can someone point me to a good comparison of whether I should use
 wxPython (with wxGlade I assume) or PyGTK (with Glade I assume)?
 
 I'd prefer open source (not necessarily GPL though) tools.
 
 Rod

Both the wxWidgets and the GTK web sites have some good comparison sheet
and/or a why I should use this platform page. Many reviews and articles
can be found on the web by searching for PyGTK wxPython comparison or
Python GUI toolkits.

Anyway, the main difference between PyGTK and wxPython is the type of GUI
that is generated on Windows. PyGTK uses the Windows porting of GTK and has
its own LookFeel (similar to Gnome, I could say). wxPython, like
wxWidgets, uses the native MFC widgets and have the same LookFeel of any
other MFC application (indistiguishable from any other native Windows app).
On Linux, PyGTK and wxPython are equivalent because both use GTK for
rendering the GUI. (I do not use/program/own any McOS system, so I cannot
tell you anything about the Apple Platform).

Beside this, wxPython (and wxWidgets) is often told to be more complete, 
better documented and better supported than GTK/PyGTK.

HTH
---
Alessandro Bottoni
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: improvements for the logging package

2005-09-13 Thread Peter Otten
Thomas Heller wrote:

 OK, it's not right at the top of the docs, but the example at

 http://docs.python.org/lib/minimal-example.html

 has been there for a while, and if you think it can be made clearer,
 please suggest how.
 
 Maybe I'm missing something, but the code from the example doesn't work
 for me:
 
 
 import logging

 logging.basicConfig(level=logging.DEBUG,
 ... format='%(asctime)s %(levelname)s %(message)s',
 ... filename='/tmp/myapp.log',
 ... filemode='w')
 Traceback (most recent call last):
   File stdin, line 4, in ?
 TypeError: basicConfig() takes no arguments (4 given)


Are you perhaps trying to teach the 2.3 library a trick from the 2.4 docs?

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


Re: How to protect Python source from modification

2005-09-13 Thread Frank Millman
Dennis Lee Bieber wrote:
 On 12 Sep 2005 08:33:10 -0700, Frank Millman [EMAIL PROTECTED]
 declaimed the following in comp.lang.python:

 
  My problem is that, if someone has access to the network and to a
  Python interpreter, they can get hold of a copy of my program and use
  it to knock up their own client program that makes a connection to the
  database. They can then execute any arbitrary SQL command.
 
   If your DBMS is directly accessible on the net, you're vulnerable
 even without Python. Especially if you have authentication logic being
 done at the client end. There is nothing to prevent someone using a
 compatible query browser or command-line utility to make connection
 attempts to the server, followed by classical username/password cracking
 stuff.


Right - this is the conclusion I have come to.

 
  The server program is currently programmed to accept a number of
  message types from the client program. Each message's data string
  starts with a numeric prefix, which indicates the type of message,
  followed by a pickled tuple of arguments. The server program reads the
  string, extracts the numeric prefix, and passes the rest of the string
  to the appropriate function using a subthread.
 
   Ah, okay -- you /do/ already have something running in the middle.


It is more on the side than in the middle at present - the client
connects to my server program, but also connects directly to the
database. My proposed change is to put it really in the middle - the
client connects to my server, and my server connects to the database.

  For example, I keep track of who is currently logged in. On startup,
  the client connects to my server and sends a '1' followed by their
  userid and other information. The server receives this and passed the
  data to a 'login' function, which uses a Python dictionary to store the
  information. If the server detects that the user is already logged in,
  it sends back an error code and the client program displays a message
  and terminates. Otherwise it sends back an 'ok' code, and the client
  can continue. When the client logs off, it sends a '2' followed by
  their userid, which the server receives and passes it to a 'logoff'
  function, which deletes the entry from the dictionary.
 
   Obscuring the Python stuff will only be a minor delay factor in
 breaking that -- someone really serious could probably stick in a packet
 sniffer and record a transaction sequence, eventually reverse mapping
 back to the types of operations each code represents.


Would using SSL be a solution? This is on my to do list.

   Database security? First step would be to USE the DBMS privilege
 system to limit operations to only those SQL statements, tables, and
 data columns that are needed for your client program; since you appear
 to be using user/password information already, each such user could have
 different privileges, limiting some to retrieval only, for example. As
 for your server, I'd probably start a thread for each connected user,
 so that thread handles all communication. Your description sounds more
 like a rudimentary proxy adding in a counting scheme, but not really
 isolating separate client connections.
 --

A number of replies have indicated that I should be using the DBMS
itself to manage security. I think there are some benefits to managing
it via the application. Admittedly I did not think it through when I
started, but now that I have a reasonable security model working, I
would not want to give it up. Here are some examples of what I can do.

1. Users and groups can be maintained by anyone using my app (with the
correct permissions, of course). You do not have to go through the
database adminstrator with all the complication or red tape that could
arise.

2. I am a great believer in 'field-by-field' validation when doing data
entry, instead of filling in the entire form, submitting it, and then
being informed of all the errors. I can inform a user straight away if
they try to do something they are not entitled to.

3. I can cater for the situation where a user may not have permission
to do something, but they can call a supervisor who can override this.
I have seen solutions which involve prompting for a password, but this
has to be programmed in at every place where it might be required. I
allow the supervisor to enter their userid and password, and my program
reads in their permissions, which become the active ones until
cancelled. I create a flashing red border around the window to warn
them not to forget.

There is some support for this approach given by MS SQL Server, which
has the concept of an Application Role. 'Application roles contain no
users, though you can still assign permissions to application roles.
They are designed to let an application take over the job of
authenticating users from SQL Server.'

Thanks for the interesting comments.

Frank

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


TKinter, Entry objects and dynamic naming

2005-09-13 Thread Ian Vincent
I am hoping someone may be able to help.

I am using Python and TKinter to create a GUI program that will 
eventually create an XML file for a project I am working on. Now, the XML 
file contents changes depending on the type of file it represents - so I 
am dynamically creating the TK Entry boxes. The problem is, I want the 
variable assigned to each of these boxes to be dynamically assigned as 
well but I cannot see how to do this (if it is indeed possible).

Example

If the file the XML is to represent is a spreadsheet - I want the first 
entry box to be:

spreadsheetField = StringVar()
value = Entry(root, relief=SUNKEN, justify=LEFT, 
textvariable=spreadsheetField)

however, if the file is a document - I want the first entry box to be:

documentField = StringVar()
value = Entry(root, relief=SUNKEN, justify=LEFT, 
textvariable=documentField)

I have quite a few Entry boxes for each file type (about 10) and a lot of 
filetypes (over 80), so I do not want to have a custom function for each 
filetype if I can help it.

I have looked at using a dictionary but I cannot get my head around how 
to do that either.

If anyone can give me any ideas, I would be very grateful.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to protect Python source from modification

2005-09-13 Thread Frank Millman
Bugs wrote:
 As a side question Frank, how was your experiences using wxPython for
 your GUI?
 Any regrets choosing wxPyton over another toolkit?
 Was it very buggy?
 How was it to work with in general?
 Any other real-world wxPython feedback you have is appreciated.

 Frank Millman wrote:
  I am writing a multi-user accounting/business system. Data is stored in
  a database (PostgreSQL on Linux, SQL Server on Windows). I have written
  a Python program to run on the client, which uses wxPython as a gui,
  and connects to the database via TCP/IP.
 
 snip

Difficult to give a balanced answer, but I will try.

wxPython more or less chose itelf. I need the gui to work on Windows
and Linux. Alternatives were Tkinter and PyQt. I got the impression
from reading other comments that Tkinter is a bit old-fashioned and
does not have a native look and feel, and PyQt is not free on Windows.
That left wxPython. I did not evaluate the others, so I cannot compare
directly, but do I have any regrets - no.

Some things that I thought would be difficult I found amazingly easy.
Other things that should have been simple gave me endless trouble.
Understanding the concept of 'sizers' (for laying out the widgets on
the screen) took me a while to grasp, and it is still not 100% clear,
but I can get it to do most of what I want.

The cross-platform capability is very good, but there were times when I
got something to work on one platform and not the other. After much
experimenting I usually managed to get it to work on both, often with a
surprising side-effect - the code I eventually used was often cleaner
and felt more correct than my original attempt, and therefore if I had
been more experienced and done it the 'right' way in the first place, I
may not have had a problem.

Documentation is not perfect, though it is being worked on. The primary
source is the documentation for wxWidgets, which is written in C++.
Some people have commented that they do not understand the format, as
the C++ function calls are not quite the same as Python's, but
personally I did not find this a problem. A bigger problem is that the
documentation does not keep up to date with the product, so there are
often new features available that are not apparent. I have got into the
habit of doing a dir() on most of the objects, to see if they have any
methods that are not listed in the docs - quite often they do. Work has
started on proper wxPython documentation, and apparently it looks quite
good, but I have not used it. There is also a book in the pipeline.

Support from the wxPython community is exceptional. There is a very
willing and helpful mailing list, and a wiki with a lot of useful
stuff. The main developer of wxPython, Robin Dunn, is a regular
contributor to the mailing list, and is the authoritative source of up
to date information. Unfortunately he has been tied up with personal
business for a few months, and his absence from the list is quite
noticeable. I am sure I speak for the entire list when I say I am
really hoping that he returns soon - it makes us realise how dependent
we are on him.

Overall, I have found the experience frustrating from time to time, but
I am happy with what I have achieved. I have shown samples of my app to
a few people, and the appearance has never even raised a question - it
just looks and feels like a modern gui application, and I can get on
with demonstrating the functionality, which is as it should be.

My 2.5c

Frank

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


Re: How to protect Python source from modification

2005-09-13 Thread Frank Millman
Steve M wrote:
 This is a heck of a can of worms. I've been thinking about these sorts
 of things for awhile now. I can't write out a broad, well-structured
 advice at the moment, but here are some things that come to mind.


[snip lots of interesting stuff]

Thanks for the reply, Steve. My thinking has followed a similar path to
yours, so it is good to have some validation.

I have decided that my next step will be to set up a server program as
discussed, and move all my authentication and business logic there,
then get a client program working using the same gui as at present, but
communicating with the server for most of the database stuff instead of
doing it by itself.

I am aware of Dabo, but I have not looked at it yet. I got my own
framework working before Dabo came along, and it works well enough for
my purposes, so I don't really want to go back and reinvent that wheel
at the moment.

Frank

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


Re: Using Python with COM to communicate with proprietary Windows software

2005-09-13 Thread Thomas Heller
Andrew MacIntyre [EMAIL PROTECTED] writes:

 On Fri, 09 Sep 2005 08:36:00 +0200, Thomas Heller [EMAIL PROTECTED]
 wrote:

 {...}

(I have released and announced this 3 weeks ago, but haven't got a
single feedback.  So it seems the need to access custom interfaces is
very low.)

 I have downloaded it and am trying to find the time to play with it
 (unsuccessfully so far).

 As someone working with a large, complex, COM library with minimal
 IDispatch support, I'm really looking forward to this.

 However, at the moment I'm limited to Python 2.2 and ctypes 0.6.3
 (which is allowing me to get the job done!!).

 Regardless, I thank you for what you have released!

I knew there are fans out there ;-)

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


Re: Using Python with COM to communicate with proprietary Windows software

2005-09-13 Thread Thomas Heller
Joakim Persson [EMAIL PROTECTED] writes:

 On Fri, 09 Sep 2005 08:36:00 +0200, Thomas Heller [EMAIL PROTECTED]
 wrote:

Sounds like a perfect job for comtypes, which is a COM library
implemented in pure Python, based on ctypes.  comtypes should make it
easy to access custom (non-dispatch derived) com interfaces, or the
vtable based part of dual interfaces - it would be good however, if you
have a type library for the interfaces.

http://sourceforge.net/projects/comtypes/

No docs yet, but there are tests included which should get you started.

(I have released and announced this 3 weeks ago, but haven't got a
single feedback.  So it seems the need to access custom interfaces is
very low.)

Thommas

 After some testing today, it does seem to do exactly what I wanted --
 I can now access the custom but IDispatch-like COM interface that I
 couldn't access with win32com (or with Java + jawin). It might be
 possible in other ways, but using comtypes was definitely the most
 painfree way (everything, including the return values from the
 methods, worked as expected). Thank you very much. 

 Of course, this does not complete my task -- although I can now use my
 interface to send messages and commands to the big log tool, I still
 need to implement a COM server and pass a pointer to its interface
 through one of the messages to the com server to be able to receive
 data: 

 BridgeInterface.StartLogging(filename)   --- works fine, didn't work
 before
 BridgeInterface.Advise(ptr)  --- Now, I need to create a new
 interface for receiving the data sent from the log application, so
 that I can (at first) print it

 This _shouldn't_ be too difficult -- I know which methods must be
 implemented (basically just some kind of event handling to deal with
 randomly arriving log points, should be implemented as onMsg() on my
 COM server side, and some other similar methods), but I don't really
 know how. I have tried doing simple COM servers using win32com, but is
 it equally possible to implement such a simple thing in comtypes? I
 didn't find any server side examples in comtypes, but perhaps there is
 a way?

There is not yet any server support in comtypes, but it will be added.
In the meantime you could use the ctypes.com package that is included in
ctypes itself, there are even samples.

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


Checked tree in wxpython (windows)

2005-09-13 Thread geire
I'm trying to make a checked tree based on TreeCtrl. I've subclassed
the control such that checkmarks appear in the left hand side of the
treeitems. So far so good. The challenge appears when I programmaly
want to check the tree items since I don't know the hitem id which I
should send an update to (using SendMessage). I only get access to a
proxy of wxTreeItemId and not the hItem id itself. Any ideas of how I
can get this id?


Thanks in advance.

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


Re: py2app without a mac?

2005-09-13 Thread Tony Meyer
 I don't want to require the users to have python installed so I  
 don't think distutils would work here.

Recent versions of OS X include Python - there's a pretty good chance  
that the users have Python already, so you could possibly use  
distutils after all.

=Tony.Meyer
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Need help with C extension module

2005-09-13 Thread Ken Seehart
chris wrote:
 This is my first attempt at undertaking a C extension module.  I want
 to wrap an existing C library so I can call the functions from Python.
 There are only two functions I'm interested in calling.  I did mess
 with Pyrex a bit and Swig, to no avail, so I turned to doing it by
 hand.  Using the example in Programming Python, I did get the easier of
 the two functions working--only takes a string parameter.  I'm stuck
 now on the other function and not sure how to wrap it, because it
 involves some structs.  Here's a simplified version of the C:
 
 struct In
 {
   int x;
   char* s;
   ... (only primitive data types)
 };
 
 struct Out
 {
   int y;
   char* s;
   ... (only primitive data types)
 };
 
 Out* func(In* x, Out* y);
 
 So the function takes pointers to the two structs, and fills out the
 output struct and also returns the pointer to it.  I would envision the
 Python looking like
 
 in = In()
 in.y = 1
 in.s = abc
 ...
 
 out = func(in)
 
 maybe?  Just no idea how to deal with the structs in the C extension
 module code.
 
 Any tips appreciated.
 
 Thanks,
 Chris
 

Since others have responded about Pyrex, I'll just add my two cents,
which may or not apply to you.

The idea of filling in a struct, passing it to a function, then
returning a struct, is a typical c-ism.  If the only purpose of the
structs is to pass data to the function and receive the result, read on.
  On the other hand, if the structures represent things in the
object-oriented sense, just ignore what I am saying.

I would wrap the function such that the python code simply takes a set
of parameters and returns a tuple.  This is much more pythonic, and much
easier to code.

y,s,... = func(x,s,...)

My untested pseudocode would look something like this:

static PyObject *map_sweep(map__object *self, PyObject *args)
{
   In input;
   Out output;

   if (PyArg_ParseTuple(args, is..., (In.x), (In.s), ...))
   {
 return NULL;
   }

   func(In, Out);

   return Py_BuildValue(is..., Out.y, Out.s, ...);
}



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


Python for ARM7?

2005-09-13 Thread Ken Seehart
Hello.  Where might I find python binaries for ARM7 (Linux 2.4)?

I don't have an ARM7 compiler, and I probably don't have enough disk
space (about 3MB of flash available) for the complete build anyway.

My plan is to just copy the files I need.  This approach seems to work
on Windows XP, where I have a working python executable with the
libraries I need (python.exe, SimpleHTTPServer.py and dependencies), all
in about 1 MB.  The application is basically a web server.

If I absolutely have to build my own python, I would probably use a
cygwin (or maybe linux) cross-compiler for ARM7, but that seems like a
daunting task.  I'd much rather find someone who has already done it who
has the binaries :)

I'm pretty sure the only files I actually need are the python executable
and the _socket shared library.

Thanks,
- Ken


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


Re: improvements for the logging package

2005-09-13 Thread Thomas Heller
Peter Otten [EMAIL PROTECTED] writes:

 Thomas Heller wrote:

 OK, it's not right at the top of the docs, but the example at

 http://docs.python.org/lib/minimal-example.html

 has been there for a while, and if you think it can be made clearer,
 please suggest how.
 
 Maybe I'm missing something, but the code from the example doesn't work
 for me:
 
 
 import logging

 logging.basicConfig(level=logging.DEBUG,
 ... format='%(asctime)s %(levelname)s %(message)s',
 ... filename='/tmp/myapp.log',
 ... filemode='w')
 Traceback (most recent call last):
   File stdin, line 4, in ?
 TypeError: basicConfig() takes no arguments (4 given)


 Are you perhaps trying to teach the 2.3 library a trick from the 2.4 docs?

Yes, it seems so.  Although I would have expected the documentation to
inform me about incompatible changes in the api.

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


Using Shed Skin under Windows or OSX

2005-09-13 Thread Mark Dufour
Hello all,

My apologies to everyone who has tried Shed Skin under Windows or OSX,
and could not get it to run. I have to stress that it really is
experimental software, and certainly not ready for production use at
this point. However, that is not an excuse for a vague and/or too
difficult installation prodedure. I hope to find and spend some time
behind Windows and OSX boxes this week, to fix any problems and
hopefully make it easy to install the compiler on them.

For now, two very helpful persons have posted instructions on how to
get Shed Skin sort of working under either operating system (there are
still some problems with the unit tests..)

http://mail.python.org/pipermail/python-list/2005-September/298697.html
http://www.blogger.com/comment.g?blogID=14063458postID=112636132130703717


thanks!
mark.


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


Re: TKinter, Entry objects and dynamic naming

2005-09-13 Thread Eric Brunel
On 13 Sep 2005 08:51:47 +0100, Ian Vincent [EMAIL PROTECTED] wrote:

 I am hoping someone may be able to help.

 I am using Python and TKinter to create a GUI program that will
 eventually create an XML file for a project I am working on. Now, the XML
 file contents changes depending on the type of file it represents - so I
 am dynamically creating the TK Entry boxes. The problem is, I want the
 variable assigned to each of these boxes to be dynamically assigned as
 well but I cannot see how to do this (if it is indeed possible).

 Example

 If the file the XML is to represent is a spreadsheet - I want the first
 entry box to be:

 spreadsheetField = StringVar()
 value = Entry(root, relief=SUNKEN, justify=LEFT,
 textvariable=spreadsheetField)

 however, if the file is a document - I want the first entry box to be:

 documentField = StringVar()
 value = Entry(root, relief=SUNKEN, justify=LEFT,
 textvariable=documentField)

 I have quite a few Entry boxes for each file type (about 10) and a lot of
 filetypes (over 80), so I do not want to have a custom function for each
 filetype if I can help it.

Your requirements are not very precise here. What do represent the entry 
fields? How do you build them? Are they always strings or can they be integers, 
or floats, or anything else? Do you have only entry fields or other widgets as 
well (check buttons, radio buttons, ...)? How do you know the format of the 
dialog you build?

 I have looked at using a dictionary but I cannot get my head around how
 to do that either.

This is the way I would go, but without answering the questions above, I won't 
be able to give you much advice. Supposing you have only entry fields accepting 
strings, a mapping file type - field name - StringVar may be a good solution.

HTH
-- 
python -c print ''.join([chr(154 - ord(c)) for c in 
'U(17zX(%,5.zmz5(17;8(%,5.Z65\'*9--56l7+-'])
-- 
http://mail.python.org/mailman/listinfo/python-list


First release of Shed Skin, a Python-to-C++ compiler.

2005-09-13 Thread Mark Dufour
 Hehe. Okay. It will probably always be the case that you have to lose
 some Python features if you want the code to run really fast. I
 suppose PyPy's restricted Python subset doesn't support duck typing
 either. Luckily not all code is performance critical, or you could
 just try and optimize some performance critical part. But anyway, I'm
 starting to understand that Shed Skin should probably support
 exceptions wherever possible :-)

Ok - the point I was trying to make was that exceptions were pretty
integral to Python. I accept that losing the more dynamic features of
Python for 'compilation' is a possibly worthwhile tradeoff.

Shed Skin's main use will be in algorithmic-like code, which is also
in most need of optimization. Typically such code is not very dynamic,
or uses many exceptions, if any. It may be the case that most programs
written in Python are not algorithmic-like at this point, which would
be logical, since Python is traditionally not one of the fastest
languages.. In that case applying Shed Skin to existing programs may
not be very useful in most cases.

But in any case, exceptions are not really dynamic (I think..) so,
yeah, they should be supported..

How easy is it going to be to call your c++ code from Python (and vice
versa) ?

I haven't really thought deeply about this, but I guess it shouldn't
be too hard to use existing C++/Python bridges there. However, I have
no experience at all in this area.. (hint hint)


thanks!
mark.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PyGTK or wXPython?

2005-09-13 Thread Wolfgang Keller
 (I do not use/program/own any McOS system, so I cannot
 tell you anything about the Apple Platform).

WxPython _can_ give you a native Mac look and feel, if you are 
willing to take into account certain issues (such as e.g. menu bars not 
tied to windows, no MDI, no multi-pane etc.). It is afaik _not_ 
automatic.

PyGTK uses X. There are window managers available which try to emulate 
an Aqua look, but there's afaik no way to detach the menu bar from 
the window etc...

If you are willing to GPL your own applications, PyQt is another 
option.

Sincerely,

Wolfgang Keller


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


Re: TKinter, Entry objects and dynamic naming

2005-09-13 Thread Ian Vincent
Ian Vincent [EMAIL PROTECTED] wrote in
news:[EMAIL PROTECTED]: 
 
 I have looked at using a dictionary but I cannot get my head around
 how to do that either.

I have tried this now but the Entry field just does not seem to work:

def add_variable(self, root, varname):
 Label(root, text=varname + ': ').grid(row=self.row, column=0, 
sticky=E)
 self.properties[varname] = StringVar()
 value = Entry(root, relief=SUNKEN, justify=LEFT, 
textvariable=self.properties[varname])
 value.grid(row=self.row, column=1, sticky=E+W)
 self.row = self.row + 1
 return value


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


Re: Python for ARM7?

2005-09-13 Thread Sybren Stuvel
Ken Seehart enlightened us with:
 Hello.  Where might I find python binaries for ARM7 (Linux 2.4)?

Check http://www.vanille.de/projects/python.spy

 If I absolutely have to build my own python, I would probably use a
 cygwin (or maybe linux) cross-compiler for ARM7, but that seems like a
 daunting task.

It is. From the above URL:

: The build process of Python compiles a core part of it (the parser
: generator pgen) and tries to execute that later in the build
: process. This - of course - doesn't work for cross compiling.

Sybren
-- 
The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself? 
 Frank Zappa
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: First release of Shed Skin, a Python-to-C++ compiler.

2005-09-13 Thread Brian Quinlan
Mark Dufour wrote:

 You're right, I don't feel safe about that. It's a bad example. I just
 prefer error codes, because the code usually becomes cleaner (at least
 to me). I would really like it if I could do something like this:
 
 f = file(name) 
 if not f:
 print 'error opening file %s: %s', name, str(f.error)
 sys.exit()

I think you meant:
print 'error opening file %s: %s' % (name, str(f.error))

You forgot to check for an error when:
o when you wrote f.error [attribute error might not exist e.g. f is
   None]
o you called str(f.error) [might contain unicode characters that can't
be converted to a string using the default
encoding]
o when you used the % operator [format string might be wrong]

And, of course, pretty much every expression can result in a memory error.

Exception handling is a boon because almost EVERY expression that you 
write can result in a error and checking each one is tedious in the 
extreme. So people forget and then their programs exhibit very odd 
behavior that is very difficult to debug.

If you look at the Python C source, you'll notice that probably 50% of 
the code is devoted to error handling (that was a guess).

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


Re: ZPT and incompatible version None error :(

2005-09-13 Thread Jaroslaw Zabiello
Dnia Mon, 12 Sep 2005 16:51:48 +0200, Jaroslaw Zabiello napisał(a):

 Another ZPT file try to fill one slot:
 
 div metal:use-macro=context/base
   div metal:fill-slot=goraSearch|Read|Compare|History/div
 /div
 
 When I try to open it, I get the error mentioned above. Any idea?

Solution was trivial

div metal:use-macro=context/base/macros/content
  div metal:fill-slot=goraSearch|Read|Compare|History/div
/div

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


Re: First release of Shed Skin, a Python-to-C++ compiler.

2005-09-13 Thread Mark Dufour
 You forgot to check for an error when:
 o when you wrote f.error [attribute error might not exist e.g. f is
None]
 o you called str(f.error) [might contain unicode characters that can't
 be converted to a string using the default
 encoding]
 o when you used the % operator [format string might be wrong]
 And, of course, pretty much every expression can result in a memory error.

I don't mind the program bailing out in such a case and telling me
where it went wrong, so I can fix the problem. I just don't really see
the need for catching exceptions yourself. Especially not in
well-tested code, potentially to be compiled.

 Exception handling is a boon because almost EVERY expression that you
 write can result in a error and checking each one is tedious in the
 extreme. So people forget and then their programs exhibit very odd
 behavior that is very difficult to debug.

What do you mean odd behaviour? If they don't catch exceptions, the
program will bail out, showing what went wrong, yeah?

 If you look at the Python C source, you'll notice that probably 50% of
 the code is devoted to error handling (that was a guess).

That's a lot of error handling..


thanks!
mark.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Checked tree in wxpython (windows)

2005-09-13 Thread Franz Steinhaeusler
On 13 Sep 2005 01:16:52 -0700, geire [EMAIL PROTECTED] wrote:

I'm trying to make a checked tree based on TreeCtrl. 
[...]

Not directly an answer, but:
there exists already such a CheckTreeCtrl.
I have uploaded it at:
http://mitglied.lycos.de/drpython/CheckTreeCtrl.tar

HTH

I've subclassed
the control such that checkmarks appear in the left hand side of the
treeitems. So far so good. The challenge appears when I programmaly
want to check the tree items since I don't know the hitem id which I
should send an update to (using SendMessage). I only get access to a
proxy of wxTreeItemId and not the hItem id itself. Any ideas of how I
can get this id?


Thanks in advance.

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


Re: First release of Shed Skin, a Python-to-C++ compiler.

2005-09-13 Thread Robert Kern
Mark Dufour wrote:

[Brian Quinlan wrote:]
You forgot to check for an error when:
o when you wrote f.error [attribute error might not exist e.g. f is
   None]
o you called str(f.error) [might contain unicode characters that can't
be converted to a string using the default
encoding]
o when you used the % operator [format string might be wrong]
And, of course, pretty much every expression can result in a memory error.
 
 I don't mind the program bailing out in such a case and telling me
 where it went wrong, so I can fix the problem. I just don't really see
 the need for catching exceptions yourself. Especially not in
 well-tested code, potentially to be compiled.

grep the standard library. Tons of use-cases. It really is fundamental
to the way most of us code Python.

Exception handling is a boon because almost EVERY expression that you
write can result in a error and checking each one is tedious in the
extreme. So people forget and then their programs exhibit very odd
behavior that is very difficult to debug.
 
 What do you mean odd behaviour? If they don't catch exceptions, the
 program will bail out, showing what went wrong, yeah?

He was referring to the error code method of error handling. People
forget to check the error code (or else wrongly assume that nothing
wrong can happen). Uncaught exceptions *do* make the program bail out at
the point of bogosity (more or less).

If you look at the Python C source, you'll notice that probably 50% of
the code is devoted to error handling (that was a guess).
 
 That's a lot of error handling..

It's code that needs to be robust but can't avail itself of exceptions.

-- 
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: ZPT and incompatible version None error :(

2005-09-13 Thread bruno modulix
Jaroslaw Zabiello wrote:
 Dnia Mon, 12 Sep 2005 16:51:48 +0200, Jaroslaw Zabiello napisał(a):
 
 
Another ZPT file try to fill one slot:

div metal:use-macro=context/base
  div metal:fill-slot=goraSearch|Read|Compare|History/div
/div

When I try to open it, I get the error mentioned above. Any idea?
 
 
 Solution was trivial
 
 div metal:use-macro=context/base/macros/content

Duh ! I should have spotted this one :(


-- 
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: improvements for the logging package

2005-09-13 Thread skip

Vinay Well, it seems a little too late now, for unittest, threading, 
logging
Vinay and probably a few more.

Correct, as I indicated.

 I realize I'm playing the devil's advocate here  Still, a dual
 naming scheme with the non-PEP-8 names deprecated should be possible.

Vinay The breakage in my own usage of the module, and that of some
Vinay existing users of the logging module in its pre-stdlib days,
Vinay seemed to me to be good enough reason to leave the naming
Vinay alone.

That's fine, but once your code works its way into the core, it effectively
serves a different master.  Many people use code in the core as examples of
how to write Python.

As for renaming/deprecating, that mechanically seems pretty straightforward
to me:

def basic_config(...):
blah blah blah
basicConfig = basic_config

Then you go through the official deprecation process (pending deprecation in
2.N, deprecation in 2.N+1, remove it in 2.N+2).

Vinay Certainly, I was aware that the stdlib at that time contained
Vinay both naming styles. Certainly the package did not have a long and
Vinay stable life before coming into stdlib, but neither was it written
Vinay from scratch for inclusion in the core.

My apologies.  I thought it was.

Vinay What would you suggest for threading, unittest etc. in terms of
Vinay binding more unix_like_names and deprecating existing ones? It
Vinay seems a lot of work for not very much benefit, beyond consistency
Vinay for its own sake.

No, while consistency is the hobgoblin of little minds I think we should
strive for consistency within the core code, simply because it tends to be
used as an informal educational tool.  As for the others (and logging as
well, for that matter), maybe it's just been too long to make changes and
they should only be changed in Py3K.

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


Re: First release of Shed Skin, a Python-to-C++ compiler.

2005-09-13 Thread Steve Holden
Mark Dufour wrote:
You forgot to check for an error when:
o when you wrote f.error [attribute error might not exist e.g. f is
   None]
o you called str(f.error) [might contain unicode characters that can't
be converted to a string using the default
encoding]
o when you used the % operator [format string might be wrong]
And, of course, pretty much every expression can result in a memory error.
 
 
 I don't mind the program bailing out in such a case and telling me
 where it went wrong, so I can fix the problem. I just don't really see
 the need for catching exceptions yourself. Especially not in
 well-tested code, potentially to be compiled.
 
 
Exception handling is a boon because almost EVERY expression that you
write can result in a error and checking each one is tedious in the
extreme. So people forget and then their programs exhibit very odd
behavior that is very difficult to debug.
 
 
 What do you mean odd behaviour? If they don't catch exceptions, the
 program will bail out, showing what went wrong, yeah?
 
 
If you look at the Python C source, you'll notice that probably 50% of
the code is devoted to error handling (that was a guess).
 
 
 That's a lot of error handling..
 
Mark:

You have achieved so much with the first release of Shed Skin that it's 
strange to see you apparently trying to argue that exceptions aren't 
necessary when in fact they are such a fundamental part of Python's 
philosophy.

Their real value is in removing the necessity to perform explicit error 
checking after each operation in a program. For example, when I write

 try:
 func1(...)
 func2(...)
 except SomeException:
 handle the exception

the authors of func1()) and func2() don't have to worry about explicitly 
  returning control if some condition they can't handle occurs. They 
just write

 raise SomeException

knowing that this will immediately cause all calling contexts to be 
unstacked until the context is reached that is prepared to handle the 
exception.

Without such an ability the logic of the functions tends to look 
something like

 if (errorCondition1):
 return SomeErrorFlag1
 elif (errorCondition2):
 return SomeErrorFlag2
 else:
 perform normal computation
 return Value

and the calling code then has to check for the flags before handling the 
return value.

So basically exceptions allow simplification of program structure with 
more effective and simpler error handling. If you read through (for 
example) the code you'll find in the standard library and you'll get a 
better feel for the usefulness of exceptions.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/

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


Re: popen in thread on QNX

2005-09-13 Thread Jacek Popławski
Laszlo, I can't reply your mails, your address doesn't work, please try 
jacekpoplawski-at-gmail.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Zope, ZPT and slots

2005-09-13 Thread Jaroslaw Zabiello
I would like to lauch macro from another zpt file. It is easy, of course,
but the problem is I would like the macro could has access to title_or_id
attribute of its caller. I read API, tried template/id, context/id and
container/id but without results.

span tal:content=template/id/ displays only own id, not its caller :(

span tal:content=context/id/ displays only id of the folder where this
zpt file and its macro is located. The same is for
tal:content=container/id/  ;(

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


Re: read stdout/stderr without blocking

2005-09-13 Thread Peter Hansen
Jacek Popławski wrote:
 Grant Edwards wrote:
 
 On 2005-09-12, Jacek Pop?awski [EMAIL PROTECTED] wrote:

ready = select.select(tocheck, [], [], 0.25) ##continues 
 after 0.25s
for file in ready[0]:
try:
text = os.read(file, 1024)


 How do you know here, that you should read 1024 characters?
 What will happen when output is shorter?

 It will return however much data is available.
 
 My tests showed, that it will block.

Not if you use non-blocking sockets, as I believe you are expected to 
when using select().

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


Re: Python for ARM7?

2005-09-13 Thread Ken Seehart
Sybren Stuvel wrote:
 Ken Seehart enlightened us with:
 
Hello.  Where might I find python binaries for ARM7 (Linux 2.4)?
 
 
 Check http://www.vanille.de/projects/python.spy
 
 
If I absolutely have to build my own python, I would probably use a
cygwin (or maybe linux) cross-compiler for ARM7, but that seems like a
daunting task.
 
 
 It is. From the above URL:
 
 : The build process of Python compiles a core part of it (the parser
 : generator pgen) and tries to execute that later in the build
 : process. This - of course - doesn't work for cross compiling.
 
 Sybren

Wow thanks!

Two more questions:

1. How do I know whether to use sharprom or modern?

2. What do I do with ipk files?  I surfed around and found that in one 
example, the command is ipkg install foo.ipk, but ipkg doesn't seem to 
exist on my hardware.

Thanks again!
- Ken

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


using filedescriptors in SIGINT signal handler

2005-09-13 Thread Bram Stolk
Hello,

I catch SIGINT signals with a handler.
In the handler, I use fd's to write some data to a child process.

Is this valid?
Because the data never arrives, and I wonder what I'm doing wrong.

Can filedescriptors still be used when you're in the signal
handling of SIGINT?

Thanks,

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


Re: Checked tree in wxpython (windows)

2005-09-13 Thread geire
Fits perfectly to my needs! Thanks. :-)


Geir Arne

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


ANN: pyparsing-1.3.3 released

2005-09-13 Thread Paul McGuire
Pyparsing 1.3.3 contains mostly bugfixes and minor enhancements over
previous releases, including some improvement in Unicode support.  Here
are the change notes:

Version 1.3.3 - September 12, 2005
--
- Improved support for Unicode strings that would be returned using
  srange.  Added greetingInKorean.py example, for a Korean version of
  Hello, World! using Unicode. (Thanks, June Kim!)

- Added 'hexnums' string constant (nums+ABCDEFabcdef) for defining
  hexadecimal value expressions.

- NOTE: ===THIS CHANGE MAY BREAK EXISTING CODE===
  Modified tag and results definitions returned by makeHTMLTags(),
  to better support the looseness of HTML parsing.  Tags to be
  parsed are now caseless, and keys generated for tag attributes are
  now converted to lower case.

  Formerly, makeXMLTags(XYZ) would return a tag with results
  name of startXYZ, this has been changed to startXyz.  If this
  tag is matched against 'XYZ Abc=1 DEF=2 ghi=3', the
  matched keys formerly would be Abc, DEF, and ghi; keys are
  now converted to lower case, giving keys of abc, def, and
  ghi.  These changes were made to try to address the lax
  case sensitivity agreement between start and end tags in many
  HTML pages.

  No changes were made to makeXMLTags(), which assumes more rigorous
  parsing rules.

  Also, cleaned up case-sensitivity bugs in closing tags, and
  switched to using Keyword instead of Literal class for tags.
  (Thanks, Steve Young, for getting me to look at these in more
  detail!)

- Added two helper parse actions, upcaseTokens and downcaseTokens,
  which will convert matched text to all uppercase or lowercase,
  respectively.

- Deprecated Upcase class, to be replaced by upcaseTokens parse
  action.

- Converted messages sent to stderr to use warnings module, such as
  when constructing a Literal with an empty string, one should use
  the Empty() class or the empty helper instead.

- Added ' ' (space) as an escapable character within a quoted
  string.

- Added helper expressions for common comment types, in addition
  to the existing cStyleComment (/*...*/) and htmlStyleComment
  (!-- ... --)
  . dblSlashComment = // ... (to end of line)
  . cppStyleComment = cStyleComment or dblSlashComment
  . javaStyleComment = cppStyleComment
  . pythonStyleComment = # ... (to end of line)



Download pyparsing at http://pyparsing.sourceforge.net.

-- Paul




Pyparsing is a pure-Python class library for quickly developing
recursive-descent parsers.  Parser grammars are assembled directly in
the calling Python code, using classes such as Literal, Word,
OneOrMore, Optional, etc., combined with operators '+', '|', and '^'
for And, MatchFirst, and Or.  No separate code-generation or external
files are required.  Pyparsing can be used in many cases in place of
regular expressions, with shorter learning curve and greater
readability and maintainability.  Pyparsing comes with a number of
parsing examples, including:
- Hello, World! (English and Korean)
- chemical formulas
- configuration file parser
- web page URL extractor
- 5-function arithmetic expression parser
- subset of CORBA IDL
- chess portable game notation
- simple SQL parser
- Mozilla calendar file parser
- EBNF parser/compiler

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


Re: using filedescriptors in SIGINT signal handler

2005-09-13 Thread jepler
If you're talking about a Python function registered as a handler by
signal.signal, then there should not be any restrictions on what you do
in that function.

Here's a small program I wrote:
#
import os, signal, time

def h(*args): os.write(fd, data\n);

print my pid is, os.getpid()
subproc = os.popen(cat -n, w)
fd = subproc.fileno()
 
signal.signal(signal.SIGINT, h)

while 1:
time.sleep(1)
#

I ran this and in another terminal I repeatedly typed 'kill -INT ',
where  is the pid printed by my program.  Each time, another line is
output by 'cat'.

When I try to deliver the signal by hitting ctrl-c in that terminal, the
first time nothing happens and the second time I get the message
OSError: [Errno 32] Broken pipe
in this case, I believe that the first signal was delivered to cat,
causing it to exit.  The second signal was delivered to the python
program, which obviously couldn't write to the stdin of a process that
had exited.

Jeff


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

round() wrong in Python 2.4?

2005-09-13 Thread Nils Grimsmo
Why did round() change in Python 2.4?

$ python2.3
Python 2.3.5 (#2, Jun 19 2005, 13:28:00)
[GCC 3.3.6 (Debian 1:3.3.6-6)] on linux2
 round(0.0225, 3)
0.023
 %.3f % round(0.0225, 3)
'0.023'

$ python2.4
Python 2.4.1 (#2, Jul 12 2005, 09:22:25)
[GCC 4.0.1 (Debian 4.0.1-1)] on linux2
 round(0.0225, 3)
0.021999
 %.3f % round(0.0225, 3)
'0.022'


(Is this due to the different GCC used?)

How do you correctly output floating-point numbers in 2.4?

I do not like the print number + EPS solution, as you would need
different EPS for different exponent sizes. In C you could get it by
taking integer 1, and -ing in the right exponent, and then casting to
double via void*. This would not be very portable, though.


Klem fra Nils

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


Re: round() wrong in Python 2.4?

2005-09-13 Thread Jeremy Sanders
Nils Grimsmo wrote:

 Why did round() change in Python 2.4?

It the usual floating point representation problem. 0.0225 cannot be
represented exactly:

xpc20:~ python
Python 2.3.4 (#1, Mar 14 2005, 16:47:22)
[GCC 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)] on linux2
Type help, copyright, credits or license for more information.
 0.0225
0.022499

See
http://www.python.org/doc/current/tut/node13.html#SECTION001380

If you need exact maths, then you're better off using integers or decimal
arithmetic.

Jeremy

-- 
Jeremy Sanders
http://www.jeremysanders.net/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python for ARM7?

2005-09-13 Thread Sybren Stuvel
Ken Seehart enlightened us with:
 1. How do I know whether to use sharprom or modern?

If it works, use it.

 2. What do I do with ipk files?  I surfed around and found that in
 one example, the command is ipkg install foo.ipk, but ipkg doesn't
 seem to exist on my hardware.

ipkg doesn't have anything to do with your hardware. It's just a shell
script. Anyway, an ipkg file is nothing more than a tarball with a
certain content.

Sybren
-- 
The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself? 
 Frank Zappa
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: using filedescriptors in SIGINT signal handler

2005-09-13 Thread Bram Stolk
[EMAIL PROTECTED] wrote:
 If you're talking about a Python function registered as a handler by
 signal.signal, then there should not be any restrictions on what you do
 in that function.
 
 Here's a small program I wrote:
 #
 import os, signal, time
 
 def h(*args): os.write(fd, data\n);
 
 print my pid is, os.getpid()
 subproc = os.popen(cat -n, w)
 fd = subproc.fileno()
  
 signal.signal(signal.SIGINT, h)
 
 while 1:
 time.sleep(1)
 #
 
 I ran this and in another terminal I repeatedly typed 'kill -INT ',
 where  is the pid printed by my program.  Each time, another line is
 output by 'cat'.
 
 When I try to deliver the signal by hitting ctrl-c in that terminal, the
 first time nothing happens and the second time I get the message
   OSError: [Errno 32] Broken pipe
 in this case, I believe that the first signal was delivered to cat,
 causing it to exit.  The second signal was delivered to the python
 program, which obviously couldn't write to the stdin of a process that
 had exited.

Ah!
ofcourse...

It makes sense now to me.
I, indeed, used Ctrl-C, and assumed it would go to python, not
the child process. Wrong assumption ofcourse.

Thanks.

   Bram

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


Re: PyGTK or wXPython?

2005-09-13 Thread TPJ
 Beside this, wxPython (and wxWidgets) is often told to be more complete,
 better documented and better supported than GTK/PyGTK.

Is wxPython often told to be more documented? By who?

Several months ago I wanted to choose a nice GUI for Python (Tkinter
was out of question). I choosed PyGTK for one reason - it was much,
much better documented than wxPython.

I have tried to write programs using wxPython and I have always ended
looking for some details in wxPython's docs for hours. I think that
wxPython has more widgets (and therefore one can say it's more
complete) - but it's an advantage only when these extra widgets are
needed. It has also another advantage over PyGTK - the native look and
feel. Write a program in wxPython and it will look natively on the
system it will be run. But the documentation of wxPython is just ugly
in comparison to the documentation of PyGTK. (Well - it was so in June
this year.)

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


Re: Python for ARM7?

2005-09-13 Thread garabik-news-2005-05
Ken Seehart [EMAIL PROTECTED] wrote:
 
 2. What do I do with ipk files?  I surfed around and found that in one 
 example, the command is ipkg install foo.ipk, but ipkg doesn't seem to 
 exist on my hardware.

ipk files are basically in two flavours, one of them is a plain tar.gz
file, use tar xvzj to upnack it
the second is an ar archive, use ar x to unpack it
(you mentioned cygwin - assuming you are working under MS windows,
either use the cygwin commands, or try to open the ipk with winzip or
something similar)

once unpacked, you find data.tar.gz inside containing all the necessary
binary files, and control.tar.gz containing some information and
installation scripts (in most cases, you can ignore them)

-- 
 ---
| Radovan Garabík http://kassiopeia.juls.savba.sk/~garabik/ |
| __..--^^^--..__garabik @ kassiopeia.juls.savba.sk |
 ---
Antivirus alert: file .signature infected by signature virus.
Hi! I'm a signature virus! Copy me into your signature file to help me spread!
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: read stdout/stderr without blocking

2005-09-13 Thread Grant Edwards
On 2005-09-13, Jacek Pop³awski [EMAIL PROTECTED] wrote:

ready = select.select(tocheck, [], [], 0.25) ##continues after 0.25s
for file in ready[0]:
try:
text = os.read(file, 1024)

How do you know here, that you should read 1024 characters?
What will happen when output is shorter?
 
 It will return however much data is available.

 My tests showed, that it will block.

You're right.  I must have been remembering the behavior of a
network socket.  Apparently, you're supposed to read a single
byte and then call select() again.  That seems pretty lame.

-- 
Grant Edwards   grante Yow!  Psychoanalysis?? I
  at   thought this was a nude
   visi.comrap session!!!
-- 
http://mail.python.org/mailman/listinfo/python-list


python/SSL/Certificate.

2005-09-13 Thread Vanessa PARISSE
In my website, the user connect in HTTPS whith a client certificate.
I would like to get the email in the certificate.
I'm trying to get the client certificate presented to the server.

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


Re: read stdout/stderr without blocking

2005-09-13 Thread Jacek Popławski
Grant Edwards wrote:
 You're right.  I must have been remembering the behavior of a
 network socket.  Apparently, you're supposed to read a single
 byte and then call select() again.  That seems pretty lame.

I created another thread with single read(), it works, as long as I have 
  only one PIPE (i.e. stderr is redirected into stdout).
I wonder is it Python limitation or systems one (I need portable solution)?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to upgrade to 2.4.1 on Mac OS X tiger

2005-09-13 Thread dario
Hi Dennis, unfortunately I can only use SER class and not 'serial'
class.
This because my emebedded phyton version don't show any import
possibility to this class. It run on the Trizium modem.
Serial I attached above, was coming from the 'simulator' code installed
on my PC.
How I can simulate your code without serial class?  It is better with
SER.read()  than SER.readbyte() because I have to read a string.

Thanks.

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


Re: Redundant code in multiple methods

2005-09-13 Thread Rob Conner
Genius!
Thanks guys that was exactly the help I was looking for. I'll be
implementing this later today. I don't forsee any problems, so if I
don't post anything else, thank you so much for the help.

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


Re: read stdout/stderr without blocking

2005-09-13 Thread Grant Edwards
On 2005-09-13, Jacek Pop?awski [EMAIL PROTECTED] wrote:
 Grant Edwards wrote:
 You're right.  I must have been remembering the behavior of a
 network socket.  Apparently, you're supposed to read a single
 byte and then call select() again.  That seems pretty lame.

 I created another thread with single read(), it works, as long
 as I have only one PIPE (i.e. stderr is redirected into
 stdout). I wonder is it Python limitation or systems one (I
 need portable solution)?

Not sure what you mean.  Here is my test program that blocks on
the read(1024) call:

#!/usr/bin/python
import os,select

p = os.popen(while sleep 2; do date; done,r)
print p

while 1:
r,w,e = select.select([p],[],[],1)
if r:
d = r[0].read(1024)
print len(d),repr(d)
else:
print timeout

It also blocks if the call is changed to read().  This seems
pretty counter-intuitive, since that's not the way read()
usually works on pipes.

Here's the corresponding C program that works as I
expected (read(1024) returns available data):

#include unistd.h
#include stdlib.h
#include stdio.h
#include sys/select.h

unsigned char buffer[1024];
int main(void)
{
  fd_set readfds, writefds, exceptfds;
  struct timeval tv;
  FILE *fp;
  int fd;
  
  fp = popen(while sleep 2; do date; done,r);
  if (!fp)
{
  perror(popen);
  exit(1);
}
  fd = fileno(fp);
  
  FD_ZERO(readfds);
  FD_ZERO(writefds);
  FD_ZERO(exceptfds);
  
  while (1)
{
  int s;
  FD_SET(fd,readfds);
  tv.tv_sec = 1;
  tv.tv_usec = 0;
  s = select(fd+1,readfds,writefds,exceptfds,tv);
  if (s==0)
printf(timeout\n);
  else if (s0)
{
  perror(select);
  exit(2);
}
  else
{
  if FD_ISSET(fd,readfds)
{
  int n = read(fd,buffer,(sizeof buffer)-1);
  buffer[n] = '\0';
  printf(read %d: '%s'\n,n,buffer);
}
}
}
}


-- 
Grant Edwards   grante Yow!  Does that mean
  at   I'm not a well-adjusted
   visi.comperson??
-- 
http://mail.python.org/mailman/listinfo/python-list


appended crontab entries with py script

2005-09-13 Thread rbt
How can I safely append a crontab entry to a crontab file
progammatically with Python?

I need to handle crontabs that currently have entries and crontabs that
are empty. Also, I'd like this to work across Linux and BSD systems.

Any pointers?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: round() wrong in Python 2.4?

2005-09-13 Thread Robert Kern
Jeremy Sanders wrote:
 Nils Grimsmo wrote:
 
Why did round() change in Python 2.4?
 
 It the usual floating point representation problem. 0.0225 cannot be
 represented exactly:

That's not what he's asking about. He's asking why his Python 2.3 rounds
0.0225 *up* to 0.023 while his Python 2.4 rounds *down* to 0.022. It's
the change in behavior that he's concerned with and isn't just the usual
floating point problem.

I'm going to suggest that it's a platform issue, possibly the change in
compiler. I get identical results on OS X with both versions of Python
both compiled by gcc-3.3 .

[~]$ python2.3
Python 2.3.5 (#1, Mar 20 2005, 20:38:20)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1809)] on darwin
Type help, copyright, credits or license for more information.
 0.0225
0.022499
 round(0.0225, 3)
0.023

[~]$ python2.4
Python 2.4.1 (#2, Mar 31 2005, 00:05:10)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1666)] on darwin
Type help, copyright, credits or license for more information.
 0.0225
0.022499
 round(0.0225, 3)
0.023


-- 
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


help in simplification of code [string manipulation]

2005-09-13 Thread John

How could I simplify the code to get libs out of LDFLAGS
or vice versa automatically in the following python/scons code?

if sys.platform[:5] == 'linux':
env.Append (CPPFLAGS = '-D__LINUX')
env.Append (LDFLAGS  = '-lglut -lGLU -lGL -lm')
env.Append(CPPPATH=['include', 'include/trackball'])
libs = ['glut', 
'GLU',
'GL',
'm',]


Thanks,
--j

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


Re: help in simplification of code [string manipulation]

2005-09-13 Thread Kent Johnson
John wrote:
 How could I simplify the code to get libs out of LDFLAGS
 or vice versa automatically in the following python/scons code?
 
 if sys.platform[:5] == 'linux':
   env.Append (CPPFLAGS = '-D__LINUX')
   env.Append (LDFLAGS  = '-lglut -lGLU -lGL -lm')
   env.Append(CPPPATH=['include', 'include/trackball'])
   libs = ['glut', 
   'GLU',
   'GL',
   'm',]

  LDFLAGS  = '-lglut -lGLU -lGL -lm'
  libs = [flag[2:] for flag in LDFLAGS.split()]
  libs
['glut', 'GLU', 'GL', 'm']

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


Re: PyGTK or wXPython?

2005-09-13 Thread Peter Decker
On 9/13/05, Rod W [EMAIL PROTECTED] wrote:
 I'm just starting out on Python but my primary goal is to provide
 applications with some user interface (GUI).
 
 Can someone point me to a good comparison of whether I should use
 wxPython (with wxGlade I assume) or PyGTK (with Glade I assume)?
 
 I'd prefer open source (not necessarily GPL though) tools.

I looked at both, and preferred wxPython's look. I hated its C-like
feeling, with some very un-Pythonic code that failed to hide its C
roots very well, but I used it because the results were so good.

Since then I've discovered Dabo, which is a complete application
framework, and which wraps wxPython for its UI. Apparently, the
authors of Dabo also didn't like the style of wxPython code, and have
created their own classes that expose a cleaner, much more Pythonic
API. I've been using Dabo for some small GUI apps, and I still can't
believe how much easier it is to create the UI with Dabo than with
plain wxPython. You should definitely check it out if you decide to go
the wxPython route.

-- 

# p.d.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: help in simplification of code [string manipulation]

2005-09-13 Thread Christophe
John a écrit :
 How could I simplify the code to get libs out of LDFLAGS
 or vice versa automatically in the following python/scons code?
 
 if sys.platform[:5] == 'linux':
   env.Append (CPPFLAGS = '-D__LINUX')
   env.Append (LDFLAGS  = '-lglut -lGLU -lGL -lm')
   env.Append(CPPPATH=['include', 'include/trackball'])
   libs = ['glut', 
   'GLU',
   'GL',
   'm',]
 
 
 Thanks,
 --j
 

Why don't you use the LIBS var in the environment instead of the LDFLAGS 
? And what use would be the libs var for you ?

if sys.platform[:5] == 'linux':
libs = ['glut',
'GLU',
'GL',
'm',]
env.Append (CPPFLAGS = '-D__LINUX')
env.Append (LIBS = Split(libs))
env.Append(CPPPATH=['include', 'include/trackball'])
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: py2app without a mac?

2005-09-13 Thread Gregory Piñero
That's an interesting idea, Tony. My program uses things like
wxPython, PythonCard, etc, so would distutils know to package that
stuff? Do you know what distutils commands I would use? If
not, I'll look it up later today.

Thanks,

Greg
Recent versions of OS X include Python - there's a pretty good chance
that the users have Python already, so you could possibly usedistutils after all.=Tony.Meyer-- Gregory PiñeroChief Innovation OfficerBlended Technologies
(www.blendedtechnologies.com)
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: [OT] Zope, ZPT and slots

2005-09-13 Thread bruno modulix
Jaroslaw Zabiello wrote:
 I would like to lauch macro from another zpt file. 

(snip - tech answer in private)

Please stop posting Zope and ZPT related questions here. There are
mailing-lists dedicated to Zope. That's where you'll get the good answers.

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


Re: PyGTK or wXPython?

2005-09-13 Thread Christophe
Peter Decker a écrit :
 On 9/13/05, Rod W [EMAIL PROTECTED] wrote:
 
I'm just starting out on Python but my primary goal is to provide
applications with some user interface (GUI).

Can someone point me to a good comparison of whether I should use
wxPython (with wxGlade I assume) or PyGTK (with Glade I assume)?

I'd prefer open source (not necessarily GPL though) tools.
 
 
 I looked at both, and preferred wxPython's look. I hated its C-like
 feeling, with some very un-Pythonic code that failed to hide its C
 roots very well, but I used it because the results were so good.
 
 Since then I've discovered Dabo, which is a complete application
 framework, and which wraps wxPython for its UI. Apparently, the
 authors of Dabo also didn't like the style of wxPython code, and have
 created their own classes that expose a cleaner, much more Pythonic
 API. I've been using Dabo for some small GUI apps, and I still can't
 believe how much easier it is to create the UI with Dabo than with
 plain wxPython. You should definitely check it out if you decide to go
 the wxPython route.
 

There's Wax which is a cleaner pythonic API on top of wxPython.

Myself, I would go the PyQT way because the API is very clean and 
there's one less abstraction layer on top of it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Redundant code in multiple methods

2005-09-13 Thread bruno modulix
Rob Conner wrote:
 Genius!

Nope. Just common Python idioms...

 Thanks guys that was exactly the help I was looking for. I'll be
 implementing this later today. I don't forsee any problems, so if I
 don't post anything else, thank you so much for the help.

You're welcome.

-- 
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: round() wrong in Python 2.4?

2005-09-13 Thread Sion Arrowsmith
Nils Grimsmo [EMAIL PROTECTED] wrote:
Why did round() change in Python 2.4?

$ python2.3
Python 2.3.5 (#2, Jun 19 2005, 13:28:00)
[GCC 3.3.6 (Debian 1:3.3.6-6)] on linux2
 round(0.0225, 3)
0.023
 %.3f % round(0.0225, 3)
'0.023'

$ python2.4
Python 2.4.1 (#2, Jul 12 2005, 09:22:25)
[GCC 4.0.1 (Debian 4.0.1-1)] on linux2
 round(0.0225, 3)
0.021999
 %.3f % round(0.0225, 3)
'0.022'


(Is this due to the different GCC used?)

That would look like a good guess to me:

$ python
Python 2.4.1 (#2, May  5 2005, 11:32:06)
[GCC 3.3.5 (Debian 1:3.3.5-12)] on linux2
Type help, copyright, credits or license for more information.
 round(0.0225, 3)
0.023
 %.3f % round(0.0225, 3)
'0.023'


Is that python2.4 of yours from the python2.4 package or one
you compiled up yourself?

-- 
\S -- [EMAIL PROTECTED] -- http://www.chaos.org.uk/~sion/
  ___  |  Frankly I have no feelings towards penguins one way or the other
  \X/  |-- Arthur C. Clarke
   her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: PyGTK or wXPython?

2005-09-13 Thread Grant Edwards
On 2005-09-13, Peter Decker [EMAIL PROTECTED] wrote:

[regarding wxGTK vs wxPython]

 I looked at both, and preferred wxPython's look. I hated its
 C-like feeling, with some very un-Pythonic code that failed to
 hide its C roots very well, but I used it because the results
 were so good.

 Since then I've discovered Dabo, which is a complete
 application framework, and which wraps wxPython for its UI.
 Apparently, the authors of Dabo also didn't like the style of
 wxPython code, and have created their own classes that expose
 a cleaner, much more Pythonic API.

Yea, the wxPython API is pretty clunky in a few areas due to
the fact that it's a pretty thin wrapper around a C API.  Don't
get me started about that silly ID parameter.  I've been using
wxPython for 3-4 years, and have _never_ passed an ID other
than -1.  That tells you something in the API is fundamentally
wrong.  The whole bit-mapped flag parameter is nasty as well
(not to mention the fact that since it contains more than one
boolean value the parameter should have been named 'flags'
rather than 'flag'.

Anyway, there are some lighter-weight wrappers that make the
API more Pythonic and hide the nasty stuff like the id and flag
parameters.  I tried wax a while back and it looked
promising.

 I've been using Dabo for some small GUI apps, and I still
 can't believe how much easier it is to create the UI with Dabo
 than with plain wxPython. You should definitely check it out
 if you decide to go the wxPython route.

-- 
Grant Edwards   grante Yow!  Here I am at the flea
  at   market but nobody is buying
   visi.commy urine sample bottles...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: improvements for the logging package

2005-09-13 Thread Mike C. Fletcher
[EMAIL PROTECTED] wrote:

Vinay Well, it seems a little too late now, for unittest, threading, 
 logging
Vinay and probably a few more.

Correct, as I indicated.
  

...

Vinay What would you suggest for threading, unittest etc. in terms of
Vinay binding more unix_like_names and deprecating existing ones? It
Vinay seems a lot of work for not very much benefit, beyond consistency
Vinay for its own sake.

No, while consistency is the hobgoblin of little minds I think we should
strive for consistency within the core code, simply because it tends to be
used as an informal educational tool.  As for the others (and logging as
well, for that matter), maybe it's just been too long to make changes and
they should only be changed in Py3K.
  

I would strongly support the assertion that changing the interfaces on 
deployed modules just to match the style guide is not something that 
should happen before Py3K (that is to say, it should not happen until we 
simply don't care about being able to run old Python code, which is to 
say, a very long time).

There's no reason whatsoever to break *every* piece of code that ever 
used a service just to support consistency in naming.  Especially when 
you're dealing with these modules that are used in probably the majority 
of projects it's just a *huge* make-work project to go removing the 
original service (API).  If someone really wants the newly-named 
version, create a different entry-point (module) and allow them to use 
that.  See how popular the renamed version is as a stand-alone module 
where the barrier to entry is copying it in (which is far less than 
revising hundreds of projects to deal with a deprecation).  If it flies, 
consider adding it to the standard library and eventually deprecating 
the current version.

Consistency in the standard library is good.  We *should* strive for it 
as we improve the library.  But reworking elements in the standard 
library *just* to support consistency, at the expense of complete API 
incompatibility, just doesn't have a good cost/benefit ratio for the 
*users* of Python.  A note in the docstring and documentation noting the 
inconsistency in naming due to historic factors would seem to be more 
appropriate if we're worried about emulation by users.

Anyway, I realise Skip probably was using in Py3K in the some 
unimaginably far-off time sense, but just in case he wasn't I felt I 
should pipe up...
Mike

-- 

  Mike C. Fletcher
  Designer, VR Plumber, Coder
  http://www.vrplumber.com
  http://blog.vrplumber.com

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


Re: py2app without a mac?

2005-09-13 Thread Robert Kern
Gregory Piñero wrote:
 That's an interesting idea, Tony.  My program uses things like wxPython,
 PythonCard, etc, so would distutils know to package that stuff?  Do you
 know what distutils commands I would use?  If not, I'll look it up later
 today.

Sure. bdist_mpkg, which is provided with py2app. And so the circle is
complete

Again, it's probably not going to work without some major surgery on
py2app. And if you don't have a Mac to test on, you probably won't get far.

-- 
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

FTP Error: Windows AS/400

2005-09-13 Thread Tim G.
I am trying to use Win Python to ftp files from an AS/400 IFS directory
down to my Windows machine.

I seem to get stuck when I am trying to send a command to the AS/400 to
switch file systems from native to IFS and then to issue a cd to my
folder.  I get the error below.

If anyone has had experience trying to ftp from a 400, I would greatly
appreciate any info on the topic.


Code:

import ftplib, os

filename=''
path = jde7333
os.chdir('c:\\ftp_jde400')

ftp = ftplib.FTP('test400')
ftp.login('oneworld', 'onew0r1d')
#ftp.sendcmd('quote site namefmt 1')
ftp.sendcmd('site namefmt 1')
ftp.cwd(path)
#remotefiles = ftp.nlst()
#ftp.retrlines('LIST')
#for filename in remotefiles:
#file = open(filename, 'wb')
#ftp.retrbinary('RETR ' + filename, file.write, 1024)
#file.close()

ftp.quit()


Error:

Traceback (most recent call last):
  File C:\Python24\Tools\scripts\ftp400.py, line 10, in ?
ftp.cwd(path)
  File C:\Python24\lib\ftplib.py, line 494, in cwd
return self.voidcmd(cmd)
  File C:\Python24\lib\ftplib.py, line 246, in voidcmd
return self.voidresp()
  File C:\Python24\lib\ftplib.py, line 221, in voidresp
resp = self.getresp()
  File C:\Python24\lib\ftplib.py, line 214, in getresp
raise error_perm, resp
ftplib.error_perm: 501 Unknown extension in database file name.

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


http://www.paysatwarning.com

2005-09-13 Thread bayvision
http://www.paysatwarning.com

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


Re: Simplifying imports?

2005-09-13 Thread chapolim-colorado
bruno modulix wrote:
Let me guess: you have a C++ or Java background ?

You're right, I come from Java :). I'm still learning the Pythonic
approach. Thank you guys

Chapolim

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


Sorting Unix mailboxes

2005-09-13 Thread [EMAIL PROTECTED]
I'm writing a program in python to sort the mail in standard Unix
email boxes. In my prof of concept example I am coping a letter to a
second mailbox if the letter was send from a particular email
address. When I read the destination mailbox with cat, I can see that
something is getting copied to it, but the mail program does not
recognize any new letters in the destination mailbox. It would seam
that the OutFile.write(Message.get_unixfrom()) line is
essential. However if I run with this line uncommented then I get an
the following error. TypeError: argument 1 must be string or
read-only character buffer, not None. I created this program by
following an example posted somewhere on the Internet, that I can't
seam to find anymore. At one time I was able to get Python to put new
letters in a mailbox.

Also, I was wondering is there were a way to use Python to delete items
from a mailbox. I could create I temp box of non-deleted then copy to
the source box, but that seams messy.

Here is my example program..


def CopyToBox(Source,Address,Destination):
AddressRE=re.compile(
   ([a-zA-Z0-9._-]+)@([a-zA-Z0-9._-]+)\.([a-zA-Z0-9]+))
InFile = open(/home/stevef/mail/%s % Source)
OutFile = open(/home/stevef/mail/%s % Destination,a)
Box = mailbox.PortableUnixMailbox(InFile)
Envelope=Box.next()
while 1:
Envelope=Box.next()
if Envelope  == None:
break
print Envelope.getallmatchingheaders(from)[0]
Match=AddressRE.search(
 Envelope.getallmatchingheaders(from)[0])
if Match:
Set=Match.groups()
if [EMAIL PROTECTED] % Set == Address:
print Copy letter from  [EMAIL PROTECTED] % Set
Message = email.message_from_file(Envelope.fp)
#OutFile.write(Message.get_unixfrom()) ##error
OutFile.write(\n)
OutFile.write(Message.as_string())
InFile.close()
OutFile.close()
return

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


Re: make sure entire string was parsed

2005-09-13 Thread Steven Bethard
Paul McGuire wrote:
 I still don't know the BNF you are working from

Just to satisfy any curiosity you might have, it's the Penn TreeBank 
format: http://www.cis.upenn.edu/~treebank/
(Except that the actual Penn Treebank data unfortunately differs from 
the format spec in a few ways.)

 1. I'm surprised func_word does not permit numbers anywhere in the
 body.  Is this just a feature you have not implemented yet?  As long as
 func_word does not start with a digit, you can still define one
 unambiguously to allow numbers after the first character if you define
 func_word as
 
 func_word = _pp.Word(func_chars,func_chars+_pp.nums)

Ahh, very nice.  The spec's vague, but this is probably what I want to do.

 2. Is coord an optional sub-element of a func?

No, functions, coord and id are optional sub-elements of the tags string.

 You might also add a default value for coord_tag if none is supplied,
 to simplify your parse action?

Oh, that's nice.  I missed that functionality.

 It's not clear to me what if any further help you are looking for, now
 that your initial question (about StringEnd()) has been answered.

Yes, thanks, you definitely answered the initial question.  And your 
followup commentary was also very helpful.  Thanks again!

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


FTP Windows AS/400

2005-09-13 Thread Tim G.
I am trying to execute a win python script that connects to an AS/400;
changes from the native lib to the IFS file system; then, changes to a
directory in IFS; gets a file.

Any help would be greatly appreciated.

I cannot get the script to switch from native to IFS.  I get the
following error:

Traceback (most recent call last):
  File C:\Python24\Tools\scripts\ftp400.py, line 9, in ?
ftp.cwd(path)
  File C:\Python24\lib\ftplib.py, line 494, in cwd
return self.voidcmd(cmd)
  File C:\Python24\lib\ftplib.py, line 246, in voidcmd
return self.voidresp()
  File C:\Python24\lib\ftplib.py, line 221, in voidresp
resp = self.getresp()
  File C:\Python24\lib\ftplib.py, line 214, in getresp
raise error_perm, resp
ftplib.error_perm: 501 Unknown extension in database file name.

here is the script:

import ftplib, os

filename=''
path = directory
os.chdir('c:\\ftp_jde400')

ftp = ftplib.FTP('server', 'user', 'password')
ftp.sendcmd('site namefmt 1')
ftp.cwd(path)
#remotefiles = ftp.nlst()
#ftp.retrlines('LIST')
#for filename in remotefiles:
#file = open(filename, 'wb')
#ftp.retrbinary('RETR ' + filename, file.write, 1024)
#file.close()

ftp.quit()

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


Re: FTP Windows AS/400

2005-09-13 Thread Brendan Bispham
Hi Tim,
On Tuesday 13 September 2005 17:31, Tim G. wrote:

 I cannot get the script to switch from native to IFS. 

Yes you can...

 Traceback (most recent call last):
   File C:\Python24\Tools\scripts\ftp400.py, line 9, in ?
 ftp.cwd(path)

It's the cwd which is having a problem

 here is the script:

 import ftplib, os

 filename=''
 path = directory

Change the path to an absolute path, eg:
 ftp.sendcmd('site namefmt 1')
'250  Now using naming format 1.'
 ftp.cwd('/home')
'250 /home is current directory.'

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


Re: How to protect Python source from modification

2005-09-13 Thread Bugs
Thanks Frank, I appreciate the feedback.
-- 
http://mail.python.org/mailman/listinfo/python-list


time.strptime intolerant on weekday string length?

2005-09-13 Thread Robert
A certain DAV server reports a time stamp as Tues, 30 Aug 2005 20:48:31
( but not Tue, ...  as usual)

This produces the error below.

 time.strptime(Tue, 30 Aug 2005 20:48:31,%a, %d %b %Y %H:%M:%S)
(2005, 8, 30, 20, 48, 31, 1, 242, -1)
 time.strptime(Tues, 30 Aug 2005 20:48:31,%a, %d %b %Y %H:%M:%S)
Traceback (most recent call last):
  File interactive input, line 1, in ?
  File C:\Python23\lib\_strptime.py, line 425, in strptime
raise ValueError(time data did not match format:  data=%s  fmt=%s %
ValueError: time data did not match format:  data=Tues, 30 Aug 2005 20:48:31
fmt=%a, %d %b %Y %H:%M:%S



I also don't see how to alter the pattern for strptime to be tolerante for
more long weekday strings?
Any ideas?
Shouldn't it be possible to insert real regexp-like stuff in the pattern?

Robert


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


Re: How to protect Python source from modification

2005-09-13 Thread Magnus Lycka
Frank Millman wrote:
 Hi all
 
 I am writing a multi-user accounting/business system. 
Good!

 The client program contains all the authentication and business logic.
Not good. You lose...if it's *only* in the client.

Of course, there is no such thing as a safe system, and you need
a pragmatic approach to deciding a level of security.

For a system like this, I'd certainly prefer to design the system
so that it's immune to modifications in any software running on a
machine that isn't safe, such as a typical end user PC. IOW, no
direct DB access allowed (at least not with anything but select
permissions) and all authentication and security related verifications
etc in a server process which isn't available to ordinary users.

However, such schemes aren't immune to flaws. First of all, there
might be mistakes in the implementations (how ever cleverly they
are made) and there are always people who have access to servers
and databases.

You need audits and checks on various levels to handle such things.
You can probably get transaction logs for the database system to
be stored on some other server, which might make it more difficult
for someone who manipulates the system to hide their tracks. All
external transactions (especially payments from the system) need
to be audited and scanned for irregularities. Can all payments be
traced back to valid business transactions? Are there patterns in
payments that stick out, such as many small transactions to the
same receiver? Security checks like these should probably be made
completely outside your accounting/business software, and by people
who have nothing to do with your main system.

Regardless of your intentions, there is no way you can stop people
from hurting themselves. The customer of the system will basically set
a ceiling for the security of the system, depending on how ambitious
they are, and what kind of infrastructure they can provide etc.
Small customers might well demand perfect security, but they probably
don't want to pay for it.

 It has dawned on me that anyone can bypass this by modifying the
 program. As it is written in Python, with source available, this would
 be quite easy. My target market extends well up into the mid-range, but
 I do not think that any CFO would contemplate using a program that is
 so open to manipulation.

Just distribute zipped library instead of .py files, and you've raised
the bar to the same level as if you've written it in Java. I.e. it's as
if you send your mail in envelopes (just not glued together) instead of
in postcards. No one will accidentally see the source code, but the
persistent user can.

 There is the question of where state should be maintained. If on the
 server, I would have to keep all the client/server connections open,
 and maintain the state of all the sessions, which would put quite a
 load on the server. 

Really? How many users do you imagine? How would you plan to organize
your servers? One process per connection, one thread per connection or
asynchronous processing in one thread as in Twisted or asyncore? Perhaps
you should have a look at Twisted ot asyncore?

 This raises the question of whether I should even bother with a gui
 client, or bite the bullet and only have a browser based front end.
 Judging from recent comments about new technologies such as Ajax, a lot
 of the disadvantages have been overcome, so maybe this is the way to
 go.

It's still a big difference, isn't it? Have you seen a web based
accounting system that you thought was good enough?

 It would be a shame to scrap all the effort I have put into my
 wxPython-based front end. On the other hand, it would be pointless to
 continue with an approach that is never going to give me what I want.
 Any advice which helps to clarify my thinking will be much appreciated.

A wxPython client and a Twisted server might well be a useful combo. If
you have well written Python modules for validating data etc, you might
just run them in both client and server to achieve instant feedback on
the client without lowering the security bar.

A budget solution if you want to keep a simple fat client / thin server
solution is to run the clients on a box that the end users can't
manipulate. Just let them access that box via VNC and only run this
client program there. It's not completely trivial to set up such a safe
environment though, but it basically gives you an application server and
very thin clients that still give you the same rich UI as wxPython on
their desktops. They'll have to get used to a non-Windows GUI though,
unless you choose to run Citrix instead of VNC (or use one application
server per user :).

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


Re: Launching Python programs from Linux shell script

2005-09-13 Thread Magnus Lycka
Ernesto wrote:
 Thanks!  How do you add Python in Linux to the path? 

This works out of the box in most modern Linux distributions.

If you're open to suggestions, I'd suggest that you have a
look at Ubuntu. It's a user friendly Linux distribution with
rather close ties to the Python community.

Anyway, if Python is installed in a non-standard location on
your machine, you might need to set up two things:

PATH to the directory containing the python binary.
PYTHONPATH to the directories containing Python modules and
packages.

How to do this has nothing to do with Python, it just depends
on what shell(s) you use in Linux, and this is frankly not the
forum for that.

See e.g. http://docs.python.org/tut/node4.html and
http://www.python.org/doc/tut/node8.html for more about PATH
and PYTHONPATH--actually, it might be a good idea to read the
whole tutorial if you're a beginner.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: FTP Error: Windows AS/400

2005-09-13 Thread Peter A.Schott
I've used DOS FTP to hit AS/400 systems before and usually have to completely
qualify the file name or ensure that I'm in the correct directory.  When you use
command-line FTP to get the file, do these commands mimic your commands?

What version of python are you using?

If you issue PWD on the FTP site, what is returned when you're in the correct
folder? Can you use the sendcmd() function to mimic the functionality of cwd()
for this purpose?

I don't have easy access to an AS/400 with which to test, but maybe there's an
idea or two here that's worth trying.

-Pete

Tim G. [EMAIL PROTECTED] wrote:

 I am trying to use Win Python to ftp files from an AS/400 IFS directory
 down to my Windows machine.
 
 I seem to get stuck when I am trying to send a command to the AS/400 to
 switch file systems from native to IFS and then to issue a cd to my
 folder.  I get the error below.
 
 If anyone has had experience trying to ftp from a 400, I would greatly
 appreciate any info on the topic.
 
 
 Code:
 
 import ftplib, os
 
 filename=''
 path = jde7333
 os.chdir('c:\\ftp_jde400')
 
 ftp = ftplib.FTP('test400')
 ftp.login('oneworld', 'onew0r1d')
 #ftp.sendcmd('quote site namefmt 1')
 ftp.sendcmd('site namefmt 1')
 ftp.cwd(path)
 #remotefiles = ftp.nlst()
 #ftp.retrlines('LIST')
 #for filename in remotefiles:
 #file = open(filename, 'wb')
 #ftp.retrbinary('RETR ' + filename, file.write, 1024)
 #file.close()
 
 ftp.quit()
 
 
 Error:
 
 Traceback (most recent call last):
   File C:\Python24\Tools\scripts\ftp400.py, line 10, in ?
 ftp.cwd(path)
   File C:\Python24\lib\ftplib.py, line 494, in cwd
 return self.voidcmd(cmd)
   File C:\Python24\lib\ftplib.py, line 246, in voidcmd
 return self.voidresp()
   File C:\Python24\lib\ftplib.py, line 221, in voidresp
 resp = self.getresp()
   File C:\Python24\lib\ftplib.py, line 214, in getresp
 raise error_perm, resp
 ftplib.error_perm: 501 Unknown extension in database file name.
-- 
http://mail.python.org/mailman/listinfo/python-list


What XML lib to use?

2005-09-13 Thread Kalle Anke
I'm confused, I want to read/write XML files but I don't really understand 
what library to use.

I've used DOM-based libraries in other languages, is PyXML the library to 
use?

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


Re: Ctypes Install in Linux

2005-09-13 Thread Ernesto
THANKS !!!

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


Re: Simplifying imports?

2005-09-13 Thread George Sakkis
Terry Hancock [EMAIL PROTECTED] wrote:

 On Monday 12 September 2005 10:09 pm, [EMAIL PROTECTED] wrote:
  I like to keep my classes each in a separate file with the same name of
  the class. The problem with that is that I end up with multiple imports
  in the beginning of each file, like this:
 
  from foo.Bar import Bar
  from foo.Blah import Blah
  from foo.Zzz import Zzz
 
  What I'd like to do would be to replace it all by a single line:
 
  from foo.* import *
 
  Of course, that doesn't work, but is there a way to do something like
  that?

 Apparently foo is already a package defined using __init__.py,
 so you know about that part already.

 Just change its contents to read:

 from Bar import Bar
 from Blah import Blah
 from Zzz import Zzz

If you do this often or have lots of classes you want to import this
way, you could automate it:

# Foo.py 
class Foo(object):
pass

# Bar.py 
class Bar(object):
pass

# test.py 
from autoimport import autoimport
autoimport(Foo,Bar)

if __name__ == '__main__':
print Foo
print Bar

# output:
# class 'Foo.Foo'
# class 'Bar.Bar

# autoimport.py 
import sys

def autoimport(*modulenames):
'''
Perform the equivalent of from XXX import XXX for every
module XXX in modulenames. In case of packaged modules, it is
equivalent to from XXX.YYY.ZZZ import ZZZ
'''
caller_frame = sys._getframe(1)
caller_locals = caller_frame.f_locals
# import every module XXX and add the XXX.XXX object
# to the caller's locals
for name in modulenames:
# in case of packaged modules A.B.C, make sure to import C
module = __import__(name, caller_frame.f_globals,
caller_locals, [name])
# extract 'C' from 'A.B.C'
attribute = name[name.rfind('.')+1:]
if hasattr(module,attribute):
caller_locals[attribute] = getattr(module,attribute)

#==

Or even better, forget about the braindead java restriction of one
class per file and organize your code as it makes more sense to you.

HTH,
George

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


wxPython StyledTextCtrl and tabs?

2005-09-13 Thread Lonnie Princehouse
Does anyone know of a way to make the wxPython StyledTextCtrl expand
tabs into spaces?   (yes, I'm trying to use it to edit Python code :P)

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


Re: which is more 'pythonic' / 'better' ?

2005-09-13 Thread Terry Reedy

gabor [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 i'm sorry ;) it was  a list of strings...

 the code was something like:

 for line in open('x.y'):
 line = line.split('\t')

 a better naming would be better it seems :)

Like 'fields', for a list of fields ;-?

Or your question could have either included the code above or simply 
specified what 'line' was.  Asking clear questions is a learning process.

Terry J. Reedy



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


Re: time.strptime intolerant on weekday string length?

2005-09-13 Thread Fredrik Lundh
Robert wrote:

A certain DAV server reports a time stamp as Tues, 30 Aug 2005 20:48:31
 ( but not Tue, ...  as usual)

 I also don't see how to alter the pattern for strptime to be tolerante for
 more long weekday strings?
 Any ideas?

why bother parsing the day name at all?  (just split the string at the first
command and use strptime on the rest)

 Shouldn't it be possible to insert real regexp-like stuff in the pattern?

if you need an RE, use an RE.  no need to use strptime if you don't what
that behaviour (to convert the RE result to a time value, use time.mktime,
calender.timegm, or the datetime module, depending on what you want)

/F 



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


Re: Unfortunate newbie questions!

2005-09-13 Thread Chris Lasher
I would have to say that never having done any OO programming before in
my life, I found _Learning_Python_ by Lutz  Ascher had a great couple
of chapters on it. The diagrams about inheritance and subclassing
really helped a lot and they describe the purpose of using OOP quite
well. I see you already have that book, so perhaps you are not far
enough into it yet to hit those chapters. I think they did a great job
getting me off to a good start.

For a follow-up book, I second the recommendation of Mark Hammond's
_Dive_Into_Python_, which is mentioned above. It's a wonderful way to
learn by example. I absolutely ate up the chapters about Unit Testing.

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


Re: Simplifying imports?

2005-09-13 Thread Steven D'Aprano
On Mon, 12 Sep 2005 20:09:31 -0700, chapolim-colorado wrote:

 I like to keep my classes each in a separate file with the same name of
 the class. The problem with that is that I end up with multiple imports
 in the beginning of each file, like this:
 
 from foo.Bar import Bar
 from foo.Blah import Blah
 from foo.Zzz import Zzz
 
 What I'd like to do would be to replace it all by a single line:
 
 from foo.* import *
 
 Of course, that doesn't work, but is there a way to do something like
 that?

Doctor, it hurts when I do this.

Then don't do that.

If putting one class per file causes you pain, then don't put one class
per file. The idea of packages is to make things easier for you, not
harder -- if you are having to fight the import mechanism, then perhaps
you need to rethink your design.

eg if you have a good reason for requiring one class per file, then one
possible work around would be to define a single header module
containing all those from foo.Bar import Bar statements, and then in
your actual module(s) call from header import *. Watch out for circular
imports though.


-- 
Steven.

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


Re: Python and file locking - NFS or MySQL?

2005-09-13 Thread Christopher DeMarco
Fredrik Lundh wrote:

os.link(tempfile, lockfile) # atomic!

Fredrik, thanks for replying - I monitored python-list but didn't see
anything.  Gotta get a proper Usenet feed...

Are you sure os.link() will be atomic over NFS?

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


Re: Python and file locking - NFS or MySQL?

2005-09-13 Thread Christopher DeMarco
Thanks for the reply; I somehow missed this entire thread in
python-list.  I'm going to give it a whirl, after digging a bit into
the status quo of Linux' NFSv3 implementation.

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


Re: Simplifying imports?

2005-09-13 Thread Terry Hancock
On Tuesday 13 September 2005 12:46 pm, George Sakkis wrote:
 Terry Hancock [EMAIL PROTECTED] wrote:
  On Monday 12 September 2005 10:09 pm, [EMAIL PROTECTED] wrote:
   I like to keep my classes each in a separate file with the same name of
   the class. 
  Apparently foo is already a package defined using __init__.py,
  so you know about that part already.
 
  Just change its contents to read:
 
  from Bar import Bar
  from Blah import Blah
  from Zzz import Zzz
 
 If you do this often or have lots of classes you want to import this
 way, you could automate it:

(nice)

 [...]
 Or even better, forget about the braindead java restriction of one
 class per file and organize your code as it makes more sense to you.

While this is good sound Python advice, there are good Human-readability
reasons for keeping a small number of classes per module. Python classes
certainly may not tend to blossum into the verbosity of their Java
counterparts, but I've still seen some pretty chunky classes (e.g. in
the Zope sources).   So, the __init__.py approach and packaging is
still a good idea.

I particularly like the ability of __init__.py to craft the interface
layout of the module, independently of the file-structure that you
choose, as the best layout for the user may not be the best layout
for the developer.

I personally wouldn't favor automating this process unless you are
actually working with some kind of plugin design pattern. It's nicer
to have the fine control over the interface and be able to pick and
choose how things should be laid out. And the __init__.py code then
serves as a map for the developer to figure out where things are stored
(yes, they could also use grep, but every little bit helps).


--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks  http://www.anansispaceworks.com

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


  1   2   >