ftputil 2.1 released

2006-03-31 Thread Stefan Schwarzer
ftputil 2.1 is now available from
http://ftputil.sschwarzer.net/download .

Changes since version 2.0
-

- Added new methods to the FTPHost class, namely makedirs, walk,
  rmtree.

- The FTP server directory format (Unix vs. Windows) is now set
  automatically (thanks to Andrew Ittner for testing it).

- Border cases like inaccessible login directories and whitespace in
  directory names, are now handled more gracefully (based on input
  from Valeriy Pogrebitskiy, Tommy Sundström and H. Y. Chu).

- The documentation was updated. It's also on the website at
  http://ftputil.sschwarzer.net/trac/wiki/Documentation .

- A Russian translation of the documentation (currently slightly
  behind) was contributed by Anton Stepanov. It's also on the website
  at http://ftputil.sschwarzer.net/trac/wiki/RussianDocumentation .

- New website, http://ftputil.sschwarzer.net/ with wiki, issue tracker
  and Subversion repository (thanks to Trac!)

  Please enter not only bugs but also enhancement request into
  the issue tracker!

Possible incompatibilities:

- The exception hierarchy was changed slightly, which might break
  client code. See http://ftputil.sschwarzer.net/trac/changeset/489
  for the change details and the possibly necessary code changes.

- FTPHost.rmdir no longer removes non-empty directories. Use the new
  method FTPHost.rmtree for this.

What is ftputil?


ftputil is a high-level FTP client library for the Python programming
language. ftputil implements a virtual file system for accessing FTP
servers, that is, it can generate file-like objects for remote files.
The library supports many functions similar to those in the os,
os.path and shutil modules. ftputil has convenience functions for
conditional uploads and downloads, and handles FTP clients and servers
in different timezones.

License
---

ftputil 2.1 is Open Source software, released under the revised BSD
license (see http://www.opensource.org/licenses/bsd-license.php ).

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

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


ANN: Ajaxterm a web based terminal

2006-03-31 Thread Antony Lesuisse
Ajaxterm is a web based terminal, totally inspired by anyterm.org.

Ajaxterm written in python (and some AJAX javascript for client side).

It works almost exactly like http://anyterm.org/ (but feels faster IMHO).
However by being only dependent on python it is much more easier to install.

Homepage: http://antony.lesuisse.org/qweb/trac/wiki/AjaxTerm

-- 
Antony Lesuisse
al AT udev.org

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

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


ANNOUNCE: Zenoss 0.19.3 Available

2006-03-31 Thread Bill Karpovich

Version 0.19.3 of Zenoss is available for download.

This version fixes several bugs and switches to Zope-2.8.6.

To download:
http://www.zenoss.org/download
http://dev.zenoss.org/downloads/zenoss-0.19.3.tar.gz

Release Notes:
http://dev.zenoss.org/trac/wiki/zenoss-0.19

List of Closed Tickets:
http://dev.zenoss.org/trac/query?status=closedmilestone=zenoss-0.19.3

---
Project Blurb: 

Zenoss is a powerful network and systems monitoring application written in
Python/Zope.  Zenoss provides monitoring of organization-wide infrastructure
in an integrated product. 

Key features include: 
  - Monitoring across layers (network, servers, apps, environment...)
  - Monitoring across platforms (windows, linux, unix...)
  - Monitoring across perspectives (availability, perf, events, config)
  - Support for various collection methods (SNMP, WMI, SSH, Telnet, ICMP)
  - Automated modeling of the IT environment
  - Role-based access/management through web portal
  - GPL License

Enjoy,

Bill

Bill Karpovich
[EMAIL PROTECTED]

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

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


Re: proposed proposal: set.values()

2006-03-31 Thread Paul Rubin
Fredrik Lundh [EMAIL PROTECTED] writes:
  Nobody says you shouldn't use list(s) if you know you're dealing with
  a set.  The idea of s.values() is so you can duck-type between dicts
  and sets.
 
 if y is a dict, x in y looks for a matching key, not for a
 matching value.

Good point, the duck typing mismatches on x in y and there's nothing
that can be done about that.  

Imagine a Bag (multiset) object; it can have multiple occurrences of a
single value.  A keys() operation on it should return unique items,
but values() should return the multiple occurrences.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Doc suggestions (was: Why class exceptions are not deprecated?)

2006-03-31 Thread Fredrik Lundh

 1) dear lazyweb/lazynet: does anyone have some time to spare on figuring
 out how to log into infogami from a simple python script.  standard library
 only, preferrably.

nevermind.  the hack that didn't work yesterday did did work today.  must
have been a bad cookie day.

/F



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


Re: New Python website, new documentation ?

2006-03-31 Thread Tim Parkin
John J. Lee wrote:
 
 How about the desktop icon used on Windows boxes?  Will we see the shy
 tadpoles replacing the squiggly green pixellated Python snake in 2.5?
 If not, why not? -- is this not a branding excercise?  (I don't
 personally like the tadpoles, FWLIW, but inconsistency seems worse)
 
 John

I presume so. It's not really up to me though. Someone has created some
new icons based on the new logo that have received some positive
feedback and that I like a lot.

Tim Parkin


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


Re: How to debug python code?

2006-03-31 Thread bruno at modulix
[EMAIL PROTECTED] wrote:
 hi,
I am new to Python programming.I am not getting exactly pdb.Can
 anyone tell me effective  way to debug python code?

(automated) unit tests + print statements + the interactive shell are
usually enough. I almost never used pdb in 5+ years of Python programming.

-- 
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: Best IDE for Python?

2006-03-31 Thread bruno at modulix
Fredrik Lundh wrote:
 Dennis Lee Bieber wrote:
 
 
  I want to know which is the best IDE for python.Please if
possible mention the features of the IDE.

The best IDE is the one that YOU can be most productive in. What /I/
find useful may not be of interest to /you/.
 
 
 nonsense.  emacs is the best tool for everyone!

Nonsense ! *Ed* is the the standard editor !

http://www.gnu.org/fun/jokes/ed.msg.html

-- 
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: Best IDE for Python?

2006-03-31 Thread Fredrik Lundh
bruno wrote:

 Nonsense ! *Ed* is the the standard editor !

 http://www.gnu.org/fun/jokes/ed.msg.html

unless you're on Windows, where edlin is the true standard editor.

as you can see, Microsoft's usability team has made some massive
improvements (note how well it deals with the eat flaming death
command):

C:\ edlin
Filename missing.

C:\ edlin spam
New file.
*help
Syntax error.
*quit
Do you want to abort (Yes=Y, No=N)? n
Syntax error.
*exit

C:\edlin spam
End of input file.
*hello?
Syntax error.
*eat flaming death

C:\edlin foo
End of input file.

*^C

*^C

*^D
Syntax error.
*^Z
Syntax error.

*^C

*^C



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


Re: Doc suggestions (was: Why class exceptions are not deprecated?)

2006-03-31 Thread Ed Singleton
On 30 Mar 2006 16:30:24 -0800, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

 Fredrik Lundh wrote:
  [EMAIL PROTECTED] wrote
   write a tutorial as good as what is already there.  But what I can
   do is report problems I find when using it, and make suggestions
   about how to avoid those problems.
 
  There's no shortage of ideas -- nor people who can write a tutorial
  that's better than the current one (which is far from optimal, mostly
  thanks to a zillion peephole edits over the years).  There's a shortage
  of volunteer time, though.  That's why the I'm just the idea guy,
  someone else will have to provide the hundreds of hours required
  to implement my idea arguments are so offensively meaningless.

 What are you saying?  Ideas must come only from those
 with the time and skill to implement them?  No one else
 need apply?

Ideas can come from anyone and they do come from anyone all the time,
and as such they are fairly worthless unless acted upon.  If you want
someone else to do the acting upon for you, for free (and probably for
no thanks), then it has to be one hell of an amazing idea that no one
else has ever had (which, trust me, you won't have, and neither,
probably, will I).

Everyone knows how to improve open source software, but what good is
that to anyone?  Making the improvements is worth hell of a lot and
that's why the people who do develop a lot of kudos in the community
(it's about the only payment they get for it, and they do deserve it).

If you have an idea, then good for you, but make some small attempt to
do something about it yourself.

I'm not much of an expert in anything yet, but I had an idea, and then
managed to put the documents in a wiki, which was at least trying to
do something.  Fredrik beat me to it and did a much better job, but
even so I feel quite proud that I did something and tried to move
things on, rather than just post to a mailing list and hope someone
else does it.

 Whenever anyone criticizes anything about free software
 there are three automatic responses:

 1. You are an idiot if you can't understand / have a problem with that.
 2. Its free so you should be grateful and shutup.
 3. You have the source, change it yourself, you lazy whiner.

Whenever people are rude to you, it's quite useful to stop and think
why.  Quite often you'll find that it's something you're doing wrong. 
If it happens every single time you make a criticism, then it's
definitely something you are doing wrong.

 You could save everyone time and bandwidth by just
 responding with #3!!!

 Sorry Fredrik, truth is truth.  If there is a problem then people
 are right to point it out.  If that is really a big problem for
 you then I suggest setting up a forum or mailing list on
 python.org where you can delete improper messages,
 and ban posters who have incorrect attitudes.

Unfortunately just saying truth is truth doesn't make something
true.  If you really feel that people are right to point out problems
whenever they see them without making any attempt to correct them,
then at least attempt to prove your point with some sort of argument.

Do you think I would be right to point out every time I saw a problem
with your attitude or personality?  Of course I wouldn't.

If someone came to me with a gift, should I take it and start pointing
out all it's flaws and demanding that they fix the flaws?

Imagine that free software is a gift to you that has taken many
thousands of hours to create.  If you're going to ask the giver to do
a better job of the gift that they've given you, you better ask in a
very, very, very nice way and you should probably show that you've at
least made some effort to correct the problem yourself, (and really
you'd be better of just asking how to fix the problem yourself. 
People are quite responsive to that.  They always want more helpers).

  Come up with an idea that *reduces* the overall work needed to write
  and maintain a good manual, and people might start listening to what
  you have to say.

 What makes you think there is such a way?  Don't you
 think publishers have been looking for that way for years?
 Do you think it possible that a good manual might just
 require good writers, and good editors, and it would make
 sense to encourage those who might be interested, rather
 than posting put-downs of anyone who misreads or
 misinterprets the docs?

If you think that publishers are the apex of discovering new ways to
write docs then you don't have much experience of the real world.  Any
business process like that tends to be quite a good distance (around
5-10 years) behind the head of the pack.  And if you think we have
somehow reached perfection in the process of creating documents...

Fredrik does encourage people who might be interested.  Go back and
read this thread again.  Maybe he knows that you're not actually
interested in contributing.



  Or come up with some money.  If you can fund a technical writer for
  one year, there are lots of things that 

Re: any() and all() on empty list?

2006-03-31 Thread Antoon Pardon
Op 2006-03-30, Paul McGuire schreef [EMAIL PROTECTED]:

 Antoon Pardon [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
 Op 2006-03-30, Steven D'Aprano schreef [EMAIL PROTECTED]:

  So, these flying elephants -- are they pink or not?

 They are both.


 That would make them Schrödinger elephants!

Every member of the empty set is a Schrödinger element.

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


Re: Why are so many built-in types inheritable?

2006-03-31 Thread Antoon Pardon
Op 2006-03-31, Georg Brandl schreef [EMAIL PROTECTED]:
 Antoon Pardon wrote:
 Op 2006-03-30, Michele Simionato schreef [EMAIL PROTECTED]:
 I cannot find the reference now, but I remember Tim Peters saying some
 time ago that the only
 reason why FunctionType is not subclassable is that nobody bothered to
 write a patch for it.
 
 The question then is, why is there a need for such a patch?
 
 I mean when types and classes became unified and ints, lists ... became
 subclassable one would think that in all those new code that had to be
 written, it wouldn't have been that difficult to see to it that all
 types became subclassable. I find it hard to believe that in the
 unification period the decision to make one type subclassable and
 an other not was made solely on the basis that a patch was submitted
 for the first but not for the other.

 It's not that hard to understand, is it?

That depends.

 Whoever made the builtin types new-
 style types didn't add the BASETYPE flag to function or slice. Apparently
 he thought it wasn't worth the effort as he couldn't imagine a use case for 
 it.

Well that looks somewhat short sighted to me. It is also why python
seems to throws so many surprises at people.

My impression is that quite frequently people come here with a question
about why something doesn't work, that normally could be expected to
work.

The reason why it doesn't work then seems to boil down to the
developpers not taking the trouble of implementing something
in general but only for the cases for which they could imagine
a use case. Which means that when someone comes up with a use
case later he is stuck.

I know about practicality beating purity, but purity has it
practical aspects too. If the python people had been willing
to work a bit more at purity, that would have been a lot
of more practical for those who found something not working
as expected, although they had no reason to suspect so.

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


Re: Best IDE for Python?

2006-03-31 Thread Duncan Booth
Fredrik Lundh wrote:

 as you can see, Microsoft's usability team has made some massive
 improvements (note how well it deals with the eat flaming death
 command):

I especially like the way running it messes up the prompt:

C:\Documents and Settings\Duncanedlin
File name must be specified

C:\DOCUME~1\Duncan

Yup, wanting to run something that archaic means you must also want to not 
see those fancy filenames.
-- 
http://mail.python.org/mailman/listinfo/python-list


Can I control Video Card by using Python under linux?

2006-03-31 Thread LUK
Hi, I have a video card based on cx2388 chip to catch video and do the
other thing.
There's already a V4L2 driver for it, but it is too hard for me to
program in C.
Can I use Python do the job?
Does Python has simpler APIs?
Please gvie me some suggestion.
Thanks!

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


Re: C++ and Python

2006-03-31 Thread Roman Yakovenko
On 30 Mar 2006 23:01:21 -0800, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:
 I've been learning to write VST plugins in C++ and would like to switch
 back to Python.  The first step of writing the plugin is to import the
 C++ header files from the Steinberg SDK.  How can I do this in Python.
 I've tried looking at SWIG but didn't really understand what it was
 trying to do.Should I be using SWIG to create Python versions of
 the classes and then go from there or does it create glue code to talk
 to the classes.

Hi. My advice is try to use boost.python library.
http://www.boost.org/libs/python/doc/tutorial/doc/html/index.html
There are also few code generators available for it: pyplusplus and Pyste.

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



--
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
-- 
http://mail.python.org/mailman/listinfo/python-list


[ANN] pycdio 0.11

2006-03-31 Thread R. Bernstein
pycdio is an OO Python interface to libcdio.  The libcdio package
contains a library for CD-ROM and CD image access. Applications
wishing to be oblivious of the OS- and device-dependent properties of
a CD-ROM or of the specific details of various CD-image formats may
benefit from using this library. 

In this release, a library for working with ISO 9660 filesystems or
filesystem images was added. A number of bugs have been fixed and
issues in compiling on a number of platforms has been addressed. SWIG
is no longer required to build. Anyone who was using the previous
release should upgrade to this one.

ftp://ftp.gnu.org:/pub/gnu/libcdio/pycdio-0.11.tar.gz
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why are so many built-in types inheritable?

2006-03-31 Thread Georg Brandl
Antoon Pardon wrote:

 Well that looks somewhat short sighted to me. It is also why python
 seems to throws so many surprises at people.
 
 My impression is that quite frequently people come here with a question
 about why something doesn't work, that normally could be expected to
 work.

 The reason why it doesn't work then seems to boil down to the
 developpers not taking the trouble of implementing something
 in general but only for the cases for which they could imagine
 a use case. Which means that when someone comes up with a use
 case later he is stuck.

I think you're overgeneralizing here. Do you have other examples of
such a strategy resulting in something that doesn't work although
it should?

Nota bene: Often developers run into a limitation that is the result
of a deliberate design choice, such as why aren't strings mutable?

 I know about practicality beating purity, but purity has it
 practical aspects too. If the python people had been willing
 to work a bit more at purity, that would have been a lot
 of more practical for those who found something not working
 as expected, although they had no reason to suspect so.

I've told you already: if a developer wants a feature not currently
implemented, he/she can
 - ask on python-dev why
 - submit a feature request
 - submit a patch

If he/she's not able to do one of these, he/she can at least convince some
other Python developer if the use case is strong enough.

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


Re: How to debug python code?

2006-03-31 Thread Ravi Teja
1.) Print statements
2.) IDEs

Most Python IDEs provide visual debuggers so that you don't have to use
command line ones such as pdb.

As with all languages that allow to be executated as a script as well,
print statements usually get the job done quite well in most cases.

Please read the Python FAQ (as you should for any new language you
learn) in its entirety.
http://www.python.org/doc/faq/
It answers your IDE question you posted in the other thread as well as
many of your future questions quite well.

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


CGIHTTPServer threading problems

2006-03-31 Thread Alvin A. Delagon
I'm a simple python webserver based on CGIHTTPServer module:

import CGIHTTPServer
import BaseHTTPServer
import SocketServer
import sys
import SQL,network
from config import *

class 
ThreadingServer(SocketServer.ThreadingMixIn,BaseHTTPServer.HTTPServer):
pass

cfg = params()
print XBOX Server started on port %s. Press Ctrl+C to kill Server % 
cfg.port
server = 
ThreadingServer((cfg.name,cfg.port),CGIHTTPServer.CGIHTTPRequestHandler)
try:
while 1:
sys.stdout.flush()
server.handle_request()
except KeyboardInterrupt:
print Server killed


The my cgi scripts are stored in the cgi-bin folder. One cgi script in 
particular implements multi-threading and is supposed to be asynchronous 
but it's not working. The browser that requests on the cgi script tends 
to wait until the cgi script is done. I checked multi-threaded cgi 
script but I'm 100% percent sure that it has no problem since it worked 
as a mod_python script before. Anyone came across with this problem?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: any() and all() on empty list?

2006-03-31 Thread Ant
I don't think that there will be any valid examples.

all(list) simply means every element of the list evaluates to True.
This is trivially true in the case of the empty list. This is logically
equivalent to There are no elements in the list which evaluate to
False.

any(list) simply means at least one element of the list evaluates to
true. This is trivially false for the empty list - there are no
elements to be true.

These are logical functions and should be mathematically sound. It's
possible to add all sorts of problems if we just arbitrarily decide
what for all x should mean. We may just as well decide that for
convenience: math.pi == 3.

-- 
Ant...

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


Copy files

2006-03-31 Thread ChengGong
How can I copy a file from one folder to another(subfolder) without
change and property. I work on zope.

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

Re: Connecting to gnuplot with Popen?

2006-03-31 Thread Anton81
 Hi Anton,
 
 here is a little snippet using os.popen:

Unfortunately I'm having more problem getting the output from Gnuplot, which
I'd like to examine for error messages and settings of options.

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


Re: proposed proposal: set.values()

2006-03-31 Thread http://phr.cx
Terry Reedy [EMAIL PROTECTED] writes:
 1. It is pure duplication that *adds* keystrokes.
 
Nobody says you shouldn't use list(s) if you know you're dealing with
a set.  The idea of s.values() is so you can duck-type between dicts
and sets.

 2. It copies the wrong aspect of dict.  A set is like dict.keys (no
 duplicates, hashable), not dict.values (duplicates and non-hashables
ok).
 
I'd say keys is incorrect, since sets don't have keys:

 import sets
 s=sets.Set((1,2,3))
 s[1]
 Traceback (most recent call last):
  File stdin, line 1, in ?
TypeError: unindexable object

I don't think it's important that some values that can occur in dicts
(e.g. non-hashables) can't occur in sets.  There are similarly values
for complex numbers that can't be expressed as floats, but that
doesn't mean __add__ shouldn't work on both.

 3. It copies a workaround.  Conceptually, dict.keys() and
dict.items()
 should each be a set, not list, and would have been if Python had
had sets
 at birth.  Dict.values() should be a multiset or bag.  The order of
any is
 purely artificial and random.  Set.keys() or set.values() should be
the set
 itself.
 
I guess it's ok if sets.items() is the same as sets.values().  Sets
don't have keys.  dict.values() is what it is for historical reasons
as you state, and would be hard to change, so it makes sense for
set.values() to work the same way.

 4. The workaround will change or even better go away.  In 3.0,
,keys,
 .values and .items not be lists.  The initial proposal was to
replace them
 with iterators (the current iterkeys, etc).  A current proposal
(still in
 development) is for an iterable set- or multiset-like view on the
 underlying dict.
 
I hadn't heard of this but it does make some sense.  However,
sets.values (and maybe sets.items) should be treated the same way,
under my proposed proposal.

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


Re: Best IDE for Python?

2006-03-31 Thread bruno at modulix
Duncan Booth wrote:
 Fredrik Lundh wrote:
 
 
as you can see, Microsoft's usability team has made some massive
improvements (note how well it deals with the eat flaming death
command):
 
 
 I especially like the way running it messes up the prompt:
 
 C:\Documents and Settings\Duncanedlin
 File name must be specified
 
 C:\DOCUME~1\Duncan
 
 Yup, wanting to run something that archaic means you must also want to not 
 see those fancy filenames.

Fancy filenames ? WHO needs fancy filenames ? FANCYF~1.EXT filenames
should be enough for anybody !-)

-- 
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: ldap usage

2006-03-31 Thread Michael Ströder
Jed Parsons wrote:
 
 Which LDAP server are you using? You can switch off this behaviour
 with OpenLDAP. See man 5 slapd.conf, allow features.
 
 I don't have anything other than user access.  Good to know about this
 feature, though.

In case you're programming for different LDAP servers it's good to catch
empty passwords at the client-side anyway and not rely on server-side
features.

 Can you recommend any favorite books or sites where I can learn more
 about ldap?

Better consult LDAP link farms. After doing several years of LDAP
consulting I can't remember how I learned it. ;-)

But IMHO you're on the right track. Programming a LDAP client and
carefully examining the results different LDAP server products are
producing is probably the best you can do. That's how web2ldap
started... :-)

Ciao, Michael.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why are so many built-in types inheritable?

2006-03-31 Thread Antoon Pardon
Op 2006-03-31, Georg Brandl schreef [EMAIL PROTECTED]:
 Antoon Pardon wrote:

 Well that looks somewhat short sighted to me. It is also why python
 seems to throws so many surprises at people.
 
 My impression is that quite frequently people come here with a question
 about why something doesn't work, that normally could be expected to
 work.

 The reason why it doesn't work then seems to boil down to the
 developpers not taking the trouble of implementing something
 in general but only for the cases for which they could imagine
 a use case. Which means that when someone comes up with a use
 case later he is stuck.

 I think you're overgeneralizing here. Do you have other examples of
 such a strategy resulting in something that doesn't work although
 it should?

That is a very subjective question. I'm sure some will think
there is no reason why subclassing slices or functions should
work and so will not even consider this as something that
doesn't work but should.

But I will give you one example.

Consider the following:

  lst[3:7:2]

What does it do? It constructs a slice object which is then used
as an index in lst.

So why doesn't this work:

  fun(3:7:2)

What is wrong with expecting that a slice object would be constructed
here which would then be used as an argument for the function call?

 Nota bene: Often developers run into a limitation that is the result
 of a deliberate design choice, such as why aren't strings mutable?

Well that is fine, but in this case I haven't seen such a design
choice explained. On the contrary the only thing that I have
heard in this case is that is wasn't implemeted because noone
submitted a patch. So it seems hardly the result of a deliberate
design choice in this case.

 I know about practicality beating purity, but purity has it
 practical aspects too. If the python people had been willing
 to work a bit more at purity, that would have been a lot
 of more practical for those who found something not working
 as expected, although they had no reason to suspect so.

 I've told you already: if a developer wants a feature not currently
 implemented, he/she can
  - ask on python-dev why
  - submit a feature request
  - submit a patch

 If he/she's not able to do one of these, he/she can at least convince some
 other Python developer if the use case is strong enough.

Yes you told this already, and it ignores completely the point
I am trying to make. There is a point here beside convincing
the devolopers to implement this.

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


Re: Connecting to gnuplot with Popen?

2006-03-31 Thread Laurent Pointal
Anton81 a écrit :
 Hi,
 
 it seems to be a FAQ, but I still haven't found a solution. I want to
 control gnuplot with a python program. The following at least gives me the
 gnuplot output:

Unless you absolutely need to write your own code, you should try:
http://gnuplot-py.sourceforge.net/

A+

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


Re: Why are so many built-in types inheritable?

2006-03-31 Thread Georg Brandl
Antoon Pardon wrote:
 Op 2006-03-31, Georg Brandl schreef [EMAIL PROTECTED]:
 Antoon Pardon wrote:

 Well that looks somewhat short sighted to me. It is also why python
 seems to throws so many surprises at people.
 
 My impression is that quite frequently people come here with a question
 about why something doesn't work, that normally could be expected to
 work.

 The reason why it doesn't work then seems to boil down to the
 developpers not taking the trouble of implementing something
 in general but only for the cases for which they could imagine
 a use case. Which means that when someone comes up with a use
 case later he is stuck.

 I think you're overgeneralizing here. Do you have other examples of
 such a strategy resulting in something that doesn't work although
 it should?
 
 That is a very subjective question. I'm sure some will think
 there is no reason why subclassing slices or functions should
 work and so will not even consider this as something that
 doesn't work but should.
 
 But I will give you one example.
 
 Consider the following:
 
   lst[3:7:2]
 
 What does it do? It constructs a slice object which is then used
 as an index in lst.

Which wasn't true in older versions of Python. lst[x:y] was a special
syntax construct calling a special method __getslice__. Slice objects
were merely introduced to simplify index handling.

 So why doesn't this work:
 
   fun(3:7:2)
 
 What is wrong with expecting that a slice object would be constructed
 here which would then be used as an argument for the function call?

Point taken, now that slicing creates slice objects this would be
consistent. IIRC, there was indeed a PEP suggesting to introduce a range
literal which would have made this possible.

 Nota bene: Often developers run into a limitation that is the result
 of a deliberate design choice, such as why aren't strings mutable?
 
 Well that is fine, but in this case I haven't seen such a design
 choice explained. On the contrary the only thing that I have
 heard in this case is that is wasn't implemeted because noone
 submitted a patch. So it seems hardly the result of a deliberate
 design choice in this case.
 
 I know about practicality beating purity, but purity has it
 practical aspects too. If the python people had been willing
 to work a bit more at purity, that would have been a lot
 of more practical for those who found something not working
 as expected, although they had no reason to suspect so.

 I've told you already: if a developer wants a feature not currently
 implemented, he/she can
  - ask on python-dev why
  - submit a feature request
  - submit a patch

 If he/she's not able to do one of these, he/she can at least convince some
 other Python developer if the use case is strong enough.
 
 Yes you told this already, and it ignores completely the point
 I am trying to make. There is a point here beside convincing
 the devolopers to implement this.

Being? I mean, developer time isn't available en masse, and an overly
strict view on purity might sometimes actually prevent a feature being
implemented.

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


............這些您極可能不知道..........

2006-03-31 Thread
您辛苦了,休息一下,聽幾首歌好嗎?
http://kuso.cc/qWo
http://kuso.cc/vMt
http://jschang.myweb.hinet.net/dontforget.wma
http://jschang.myweb.hinet.net/ueyes.wma




一、請問:
美國諾貝爾獎得主大部分是哈佛大學畢業的嗎?不是!
那大部分是麻省理工畢業的?不是!
還是大多為耶魯大學畢業生?不是!
請注意,歷年來美國諾貝爾獎得主最少來自於六十個不同的大學!
也就是說,美國最少有六十所不同大學的畢業生或教授得過諾貝爾獎!
各位若不相信,可以去調查統計看看。
英國?德國?法國?
跟美國一樣!
這些國家的諾貝爾獎得主都是來自很多不同大學的教授,而不是一兩所大學而已!

美國能這麼強盛,是因為有很多很多的好大學隨時都在競爭,
這些大學都有很多很多很有潛力的教授和學生,
美國有很多很多好大學隨時都極可能有驚人的發現及驚人的研發突破!
請注意,美國的一流學生並不是集中在一兩所大學,
而是分散在很多很多的大學之中!
請注意,美國得到諾貝爾獎的教授是來自60所不同的大學!
因此,可以得到一個結論:
讓一國之內有很多所好大學,讓優秀學生分散到很多大學去,
讓各校做良性競爭,讓百家爭鳴,讓百花齊開,爭奇鬥豔,
才能經常有驚人的發現和出現大突破,
這才是美國強盛的主因!

而台灣從以前到現在都是想把全國菁英盡量集中在一所大學,
讓一所大學獨大,最少台大一直是這樣想這麼做,
政府好像也樂觀其成很配合!
可是這種作法,只會害慘台灣,絕非良策!
希望教育部以及為政者、決策者,應仔細想清楚!

二、接下來我想談大學聯考的考題:

我覺得每年大學聯考的考題都太難,考的題目都很『台大』,
亦即這些考題只是為了鑑別出可以進入台大的頂尖考試高手而已!

台大為了招收到最好的學生(但是其實是最會考試的學生而已),
因此主張考題應該越難越好,因為很難的考題是最能鑑別出程度在最前面5%的考生。
考題難只能鑑別出極優秀,優秀,和中等以下,
至於佔考生95%以上,中等能力程度以及中等以下,其實是鑑別不太出來的,
因此大學聯考的鑑別率其實還不到10%呢!

國家每年都需要非常多的人才投入各行各業,這樣國家才能持續進步興盛,
而且有12萬考生的大學聯考的錄取率約有80%之情況下,
從公平的角度,或是從國家需要很多人才的角度來看,
這種鑑別率實在太低了,
鑑別率會這麼低關鍵原因是台大自私自利造成的結果!
一個有12萬考生參與的大學聯考,為了台大一校,
只想把前6000名頂尖學生排序鑑別出來,
其他11萬多名學生沒有鑑別出來大家卻都無所謂,這種現象不是很奇怪?

因為國家需要的人才極多,為了整個國家的長期發展,
應該學學美國,把優秀學生分散到很多大學去才對!
而且為了符合繳比較多錢的學生,應該學到較多,資源也應該較多,
前途應該也較好的公義社會,一樣必須學學美國的作法。
我認為我們應該這麼做:
1.大考中心應遷離台灣大學,出題方向以及難易程度不應該受台大所掌控,
  而往後的出題委員應找私立大學老師負責出題!
2.大學聯考考題務必簡單化,讓50%的考生都能考60分以上的題目才合理。
  頂尖學生沒鑑別出來沒關係,這樣很多學校才能收到很多頂尖的學生,
  由於即將有很多所很好的大學可選擇,
學生比較能適才適所,就學後也較能發揮潛能。
3.提高國立大學學生的學雜費(或者降低私立大學的學雜費)。
  例如現在台大學生的學雜費,每學期最少要提高至私立大學學生學雜費的兩倍,
  這樣才符公義,而且很多優秀學生才會去私立大學唸。
4.降低私立大學學生學雜費。例如,私立大學的學雜費為台大學生學雜費的一半,
  私大若因此虧損,在過渡期,例如前10年由國家補足。
  我想十年後大學市場會漸趨正常化,那時再開放自由訂定學費,自由競爭。
5.考題或考試方式要讓有補習的人佔不到便宜,讓所有學生都不必補習,
  讓補習課業的補習班消失無蹤,才是子孫之福。

三、最後我針對『補習』說說我的看法:

我認為台灣真正的全民運動是:補習!
不管是國小生,國中生,還是高中生,
我敢說連全國第一名的那位學生也在補習!
亦即從最厲害的學生到程度最差的學生無一倖免,
都被捲入台灣的最大特色--補習這個行業當中。
而全國學生都補習的運動,其實是變相的否定國高中教學的結果,不是嗎?
這表示校內老師教給學生考科知識還不足,
學生還必須到補習班去補習才能學好考科知識,不是嗎?

我建議舉行一次全國大會考,然後調查一下,
排名在前10%的學生當中有多少人沒有補習?
我敢說沒補習的一定是極少數!
難道台灣的國中小和高中的學校教育都不好或不足?
我認為不是!我認為已經足夠了!
那為何全國的學生家長硬要花一大筆錢,寧願浪費學生很多青春美好時光,
以及寧願磨損掉子女的創新能力去補補補...習呢?
難道讓子女很苦很累的去重複唸、重複練習類同的問題,
對於子女一生的工作升遷和生活幸福快樂真的有幫助嗎?
有嗎?有幫助嗎?有嗎?我認為沒有!我真的認為沒有!
其實全民大補習的現象,是我們的錯誤價值觀和不良思想行為養成的社會風氣,
一般的家長只好也只能依循著做,
全民大補習的現象,其實也是補習業為了永續經營,
灌輸學生和家長務必這樣做才會有前途,政府又默不吭聲所造成的。

為了使全國第一名到最後一名的學生,亦即所有學生都必須進補習班,
於是全國明星學校被補習業及有心人士塑造出來了,
被強化,被神化了,而且還不准消失咧,
於是幾十年來都有全國好學校大排名,考生依此填志願,而且還不准消失咧,
因此那個學校第一,那個第二...那個學校第五...烙印在所有台灣人的心中,
而且非排不可的鐵律恆久不變。
其實大學好壞排序,萬家補習班欣欣向榮和很會唸書考試的學生創新能力不足,
都是同一個原因造成的啊。

其實不管家長要求或者學生自動去補習,骨子裡並不是要讓學生更有實力,
去補習最關鍵的原因是想到補習班去學習考高分的考試能力!不是嗎?
大家都是這麼想:實力有沒有增長不是最重要之事,
分數有沒有考得越來越高才是唯一關心之事啊,不是嗎?
這麼做對子弟好嗎?這麼做國家會強盛嗎?
這樣追趕先進國家會追得上?還是越追距離越遠?

若想要去除名校迷思,去除浪費青春、金錢又痛苦的無謂補習,
以及找回我們子孫各方面的創新能力,
我認為必須這麼做:
1.各大學自己招收學生(招收也不一定要用考試的方式),
  必須禁止各大學聯合招生考試。
2.提高國立大學學雜費為私立大學的兩倍,或三倍、四倍...
  讓全國各地有很多實力都差不多的好大學,
3.各大學不准排序,而且真的沒有排序。

能夠這麼做,我想課業補習班很快就會從台灣消失不見,
我想我們的子孫在學校的求學階段,亦即6歲到22歲將會是充實又快樂的學習過程,
而且我們子孫的各方面創新潛力一定會因此激發顯現出來的!

..
聲仔,我想告訴你:當你有難時,我一定不會離開你!
http://0rz.net/e8176
http://0rz.net/7217Y
http://0rz.net/6f17K
http://0rz.net/f517a

..
下面幾篇文章供您參考:
http://jschang.myweb.hinet.net/reversed.htm
http://jschang.myweb.hinet.net/70years.htm
http://jschang.myweb.hinet.net/payyouself.htm
http://jschang.myweb.hinet.net/50.htm
http://jschang.myweb.hinet.net/20060321.htm
http://www.wretch.cc/album/cpraed95
http://www.taconet.com.tw/jscha/

..
這是他的網站 http://myurl.com.tw/48bl
這是他的照片 http://myurl.com.tw/glkl
這是他的生活影片  http://myurl.com.tw/82na
--
夫兵者不祥之器物或惡之故有道者不處君子居則貴左用兵則貴右兵者不祥之器非君子
之器不得已而用之恬淡為上勝而不美而美之者是樂殺人夫樂殺人者則不可得志於天下
矣吉事尚左凶事尚右偏將軍居左上將軍居右言以喪禮處之殺人之眾以哀悲泣之戰勝以
喪禮處之道常無名樸雖小天下莫能臣侯王若能守之萬物將自賓天地相合以降甘露民莫
之令而自均始制有名名亦既有夫亦將知止知止 220-140-38-39.dynamic.hinet.net海
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: How to debug python code?

2006-03-31 Thread Kent Johnson
[EMAIL PROTECTED] wrote:
 hi,
I am new to Python programming.I am not getting exactly pdb.Can
 anyone tell me effective  way to debug python code?

I too rely mostly on unit tests and print statements for debugging, but 
occasionally I use winpdb which is a pretty nice GUI debugger.
http://www.digitalpeers.com/pythondebugger/

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


Re: Why are so many built-in types inheritable?

2006-03-31 Thread Antoon Pardon
Op 2006-03-31, Georg Brandl schreef [EMAIL PROTECTED]:
 Antoon Pardon wrote:
 Op 2006-03-31, Georg Brandl schreef [EMAIL PROTECTED]:
 Antoon Pardon wrote:

 If he/she's not able to do one of these, he/she can at least convince some
 other Python developer if the use case is strong enough.
 
 Yes you told this already, and it ignores completely the point
 I am trying to make. There is a point here beside convincing
 the devolopers to implement this.

 Being? I mean, developer time isn't available en masse, and an overly
 strict view on purity might sometimes actually prevent a feature being
 implemented.

That there are different reasons why something is not implemented.
Something not implemented can be the result of a design choice.
This is how we want the language to look like, as a result something
like that will never be implemeted.

Or it can be the result of time constraints, yes we think this
should be implemented but unless someone else does it, this
is item 367 on out todo list.

Or it may be the result of an oversigth or something totally
different.


Before I'm considering going to py-dev and bother them with
an idea of mine, I would at least like to know that the
idea would be accepted as a good design choice within the
python philosophy.

So when argueing about good/bad design it doesn't help if
you already point to the next step.

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


How to search HUGE XML with DOM?

2006-03-31 Thread Sullivan WxPyQtKinter
a relation database has admiring search efficiency when the database is
very big (several thousands or tens of thousands of records). But my
current project is based on XML, for its tree-like data structure has
much more flexibility; and DOM, which could be manipulated just like a
tree. However, how to establish such a XML data base for search when it
contains 10,000 records (One record usually contain 10~30 tags) or
more?

My search needs:
1. Search and return all the record (an element) with specific id.
2. Search and return all the record whose child nodes has a specific id
or attribute.

the xml.dom.minidom object is too slow when parsing such a big XML file
to a DOM object. while pulldom should spend  quite a long time going
through the whole database file. How to enhance the searching speed?
Are there existing solution or algorithm? Thank you for your
suggetion...

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


Working with files in a SimpleXMLRPCServver

2006-03-31 Thread Jose Carlos Balderas Alberico
I'm setting up a server accepting XML-RPC callsusing the SimpleXMLRPCServer class. Basically, what I have to do is send a zip-compressed file to the server, have the server unzip it and process it, after processing it the server is supposed to zip the file again, and send it back to the client.


I found a solution, but wanted to ask you if you think there's an easier way of doing this.

What I do at the client first is to compress the file (which is a .txt) using os.system(zip blah blah.txt). Then I obtain the name of the compressed file (let's assume it is blah.zip). Once I have the name of the zip file, I do the following:


fd = open(blah.zip, 'r')bin = xmlrpclib.Binary(fd.read())
server.process(bin)

I obtain a file descriptor, read the data and stuff it in a Binary object, and send it to the server as a parameter to the process method.

Then, at the server script,I create a file, and write into it the data contained in that Binary object using the attribute .data. That way I'll have a new file with the data passed to the server. Then again I use os.system
(...) to unzip the data and recover the original content.

When I need to send content back to the client, the whole process is repeated.

My question is: do you think this is an appropiate way to exchange files between client and server? I'm relativately new to Python, and the task of the file exchange has been assigned to me. I haven't been able to find documentation on the subject, so any help would be appreciated.


If you need any more information about what I'm trying to do, just ask.

Thank you so much for your attention :)

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

Re: How to search HUGE XML with DOM?

2006-03-31 Thread Diez B. Roggisch
 the xml.dom.minidom object is too slow when parsing such a big XML file
 to a DOM object. while pulldom should spend  quite a long time going
 through the whole database file. How to enhance the searching speed?
 Are there existing solution or algorithm? Thank you for your
 suggetion...

I've told you that before, and I tell you again: RDBMS is the way to go.
There might be XML-parsers that work faster - I suppose cElementTree can
gain you some speed - but ultimately the problems are inherent in the
representation as DOM: no type-information, no indices, no nothing. Just a
huge pile of nodes in memory.

So all searches are linear in the number of nodes. Of course you might be
able to create indices yourself, even devise a clever scheme to make using
them as declarative as possible. But that would in the end mean nothing but
re-creating RDBMS technology - why do that, if it's already there?

Maybe there are frameworks out there that support you in this, but the very
nature of XML makes that for sure a more tedious task than just defining a
simple SQL-Schema. If I'd have to search for some XML-tools that go beyond
DOM, I'd go for uche ogbuji's 4suite as a starter and work my way down from
there - maybe AMARA is what you need?

Now having said that: I'm not a SQL-bigot. Just use the right tool for the
job.

Regards,

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


Re: How to search HUGE XML with DOM?

2006-03-31 Thread bruno at modulix
Sullivan WxPyQtKinter wrote:
 a relation database has admiring search efficiency when the database is
 very big (several thousands or tens of thousands of records). But my
 current project is based on XML, for its tree-like data structure has
 much more flexibility; and DOM, which could be manipulated just like a
 tree. However, how to establish such a XML data base for search when it
 contains 10,000 records (One record usually contain 10~30 tags) or
 more?
 
 My search needs:
 1. Search and return all the record (an element) with specific id.
 2. Search and return all the record whose child nodes has a specific id
 or attribute.
 
 the xml.dom.minidom object is too slow when parsing such a big XML file
 to a DOM object. while pulldom should spend  quite a long time going
 through the whole database file. How to enhance the searching speed?
 Are there existing solution or algorithm? Thank you for your
 suggetion...

- have a look at cElementTree ?
- store your XML as persistant objects in a ZODB instance, then use ZODB
catalog for queries ?
- index relevant data in a DB (RDBMS, Berkeley, whatever...) ?
- have a look at 4suite (http://4suite.org/index.xhtml) ?

My 2 cents...
-- 
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


invalid syntax - problems with CR (0x0a)

2006-03-31 Thread cesare
hi,
i'm very new to python and am experiencing the following problem:

an identical program that runs on certain computers crashes on other 
machines due to Carriage Returns (CR; 0x0a) that
now appear in the source code. I guess it's some kind of character encoding 
issue, i.e. ways of saving the source files...
I spent a lot of time trying to fix the problem but wasn't successful until 
now.

Can somebody help me?

Cheers,
Cesare


error message inside the log file:

Traceback (most recent call last):
  File 
S:\P037_Gewerbeverband\Programm\Testumgebung\meta_search_download_scheduler.py,
 
line 132, in instanceMP
exec 'import %s' % mp
  File string, line 1, in ?
  File S:\P037_Gewerbeverband\Programm\Testumgebung\weisseseiten.py, line 
87
 s = s.replace('.-', ' CHF')
s = s.replace(';', ' ')
^
 SyntaxError: invalid syntax 



== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet 
News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ 
Newsgroups
= East and West-Coast Server Farms - Total Privacy via Encryption =
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Copy files

2006-03-31 Thread v0id
I haven't tested this, but i maybe think it works?

import shutil
try:
  copy(your_file.txt, your_subfolder)
  print Done!
except:
  print Failed!

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


Re: how to comment lot of lines in python

2006-03-31 Thread Eric Deveaud
[EMAIL PROTECTED] wrote:
  Like in C we comment like
  /*
  Bunch of lines of code
  */
 
  Should we use docstring  

I would say NO.
docstring are displayed by pydoc, thus a pydoc on your code will display some
inconsistent information ;-)

  Or there is something else too ??

some moderns editors allow you to comment/uncomment  a selected Bunch 
of lines of code

Eric
-- 
 afin de parfaire mon apprentissage de linux,je cherche sur lille et sa
 périphérie une nana tout linux
  JPH in Guide du linuxien pervers : Connaître le système
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: any() and all() on empty list?

2006-03-31 Thread Gerard Flanagan
Steve R. Hastings wrote:

 Therefore, I propose that all() should work as if it were written this way:

 def all(S):
 ret_val = False

 for x in S:
 ret_val = True
 if not x:
 return False

 return ret_val

 Comments?

Ant wrote:

 all(list) simply means every element of the list evaluates to True.
 This is trivially true in the case of the empty list. This is logically
 equivalent to There are no elements in the list which evaluate to
 False.

 any(list) simply means at least one element of the list evaluates to
 true. This is trivially false for the empty list - there are no
 elements to be true.

 These are logical functions and should be mathematically sound. It's
 possible to add all sorts of problems if we just arbitrarily decide
 what for all x should mean. We may just as well decide that for
 convenience: math.pi == 3.


I agree.

Some amateur maths - applying the identities of a 'two-element Boolean
algebra' found here:

 http://en.wikipedia.org/wiki/Two-element_Boolean_algebra

def any(S):
for x in S:
if x:
return True
return False

def all(S):
for x in S:
if not x:
return False
return True

#the identities don't hold if you use the alternative
##def all(S):
##ret_val = False
##
##for x in S:
##ret_val = True
##if not x:
##return False
##
##return ret_val

empty = []
universe = [ 0, 1 ]

one = all(empty)
zero = any(empty)

assert (one or one) == one
assert (one or zero) == one
assert (zero or one) == one
assert (zero or zero) == zero
assert (zero and zero) == zero
assert (zero and one) == zero
assert (one and zero) == zero
assert (one and one) == one
assert (not one) == zero
assert (not zero) == one

#on the other hand
one = all(universe)
zero = any(universe)

#de Morgan - swap 'and' and 'or' and complement the result
assert not(one and one) != one
assert not(one and zero) != one
assert not(zero and one) != one
assert not(zero and zero) != zero
assert not(zero or zero) != zero
assert not(zero or one) != zero
assert not(one or zero) != zero
assert not(one or one) != one
assert not(not one) != zero
assert not(not zero) != one

--

Gerard

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


Re: Working with files in a SimpleXMLRPCServver

2006-03-31 Thread Brian Quinlan
Jose Carlos Balderas Alberico wrote:
 I'm setting up a server accepting XML-RPC calls using the 
 SimpleXMLRPCServer class. Basically, what I have to do is send a 
 zip-compressed file to the server, have the server unzip it and process 
 it, after processing it the server is supposed to zip the file again, 
 and send it back to the client.

Using an XML-RPC server is overkill if you are just sending a single 
file and processing the result. You could just use a HTTP server.

And Python has a library for doing zip processing (zlib), so you don't 
need to bother creating a file just to unzip your data.

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


re.sub problem

2006-03-31 Thread veracon
I'm trying to make a (tiny) template system (Cheetah and like have far
more than what I need), but I've run into a problem. To simplify
everything, I've decided to make for loops matching the indentation
level of the open and close statements; it appears to work fine, but
apparently it chokes once there are empty lines inside the string being
replaced in.

It's a bit hard to explain, so I'll just show an example:
stm = re.compile('\n(\s+)\{\{for (.+?) in
(.+?)\}\}\n?(.+?)\n\\1\{\{end for\}\}', re.M)
data = re.sub(stm, self.handle_for, data)

I do have a self.handle_for, and I can see that it's not called if I
give it the following string:
[... (not beginning of actual string) ]
  {{for baz in bar}}
  pfoo:{baz}/p
b

  {{end for}}

There, nothing is matched; if there wasn't an empty line, it would
match something.

What am I doing wrong?

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


Re: re.sub problem

2006-03-31 Thread veracon
Actually, it happens in general when there is more than one linebreak
between the open and close statements; not only when there are empty
lines.

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


Re: How to search HUGE XML with DOM?

2006-03-31 Thread Paul Boddie
Diez B. Roggisch wrote:
  the xml.dom.minidom object is too slow when parsing such a big XML file
  to a DOM object. while pulldom should spend  quite a long time going
  through the whole database file. How to enhance the searching speed?
  Are there existing solution or algorithm? Thank you for your
  suggetion...

 I've told you that before, and I tell you again: RDBMS is the way to go.

We've lost some context from the original post that may be relevant
here, but if populating what the original questioner calls the
database is an infrequent operation, then an RDBMS probably is the way
to go, in general. On the other hand, if a lot of parsing has to happen
in order to perform a search, such parsing would probably incur a lot
of overhead from SQL inserts that wouldn't be particularly desirable.

 There might be XML-parsers that work faster - I suppose cElementTree can
 gain you some speed - but ultimately the problems are inherent in the
 representation as DOM: no type-information, no indices, no nothing. Just a
 huge pile of nodes in memory.

Well, I would hope that W3C DOM operations like getElementById would be
supported by some index in the implementation: that would make some of
the searches mentioned by the questioner fairly rapid, given enough
memory.

 So all searches are linear in the number of nodes. Of course you might be
 able to create indices yourself, even devise a clever scheme to make using
 them as declarative as possible. But that would in the end mean nothing but
 re-creating RDBMS technology - why do that, if it's already there?

I agree that careful usage of RDBMS technology would solve the general
problems of searching large amounts of data, but the stated queries
should involve indexes and be fairly quick.

Paul

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


Re: How to debug python code?

2006-03-31 Thread Thomas Guettler
Am Thu, 30 Mar 2006 21:18:50 -0800 schrieb sushant.sirsikar:
 hi,
I am new to Python programming.I am not getting exactly pdb.Can
 anyone tell me effective  way to debug python code?

Hi,

I try to debug the code while I type: Use assert.

Then if you get an AssertionError you can insert print statements or 
  raise(var=%s var2=%s % (var, var2))
to narrow down the problem. I never used pdb.

 HTH,
  Thomas

-- 
Thomas Güttler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de
Spam Catcher: [EMAIL PROTECTED]

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


Re: Very stupid question.

2006-03-31 Thread Juha-Matti Tapio
Peter Hansen [EMAIL PROTECTED] wrote:
   from path import path
   path('foobar').getsize()
 12345L
 (But note that it's just a nice wrapper around the scattered builtin 
 ways of doing the same thing, in this case the os.stat().st_size 
 approach mentioned above.  That's not a bad thing, though, IMHO.)

Also if the file in question is already open, it can be done like this:

os.fstat(fileobject.fileno()).st_size

This form avoids some race condition scenarious with the file being changed 
between stat and open.

I think file sizes should be used carefully and only for visual reasons. 
For code logic it is almost always better to go the it's easier to ask 
forgiveness than ask permission -route. Therefore looking up the file size 
is done only rarely and it is not worthy to be a file-object method.

-- 
Juha-Matti Tapio - fil.yo. - +358-50-5419230
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Best IDE for Python?

2006-03-31 Thread Ant
On a more useful note, I'll assume you're not already a vim or emacs
zealot, since you are asking the question ;-) and give my tips:

SPE seems to be the best (free) python IDE out there at the moment,
though the text editor component is pretty basic. I personally use
jEdit, since it has a superb editor component, and Python plugins which
make developing in python very comfortable, such as a (cpython and
jython) debugger, and a Jython plugin which allows scripting of jEdit
in python (well, jython - so you'll miss a few of the newer language
features when scripting jEdit itself.

None of the pure python IDE's/editors out there come close to the likes
of jEdit, vim or emacs in terms of pure editing power.

-- 
Ant...

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


Can I export my datas in pickle format safely ?

2006-03-31 Thread DurumDara
Hi !

I want to create a database from datas.
I want to store my datas in lists/dicts/normal variables.

I thinking about that I can use the pickle to serialize/load my datas 
from the file.

But: I remember that in the year of 2004(?) I tried this thing. I store 
my CD informations in pickled objects (in files).
And when I changed my python version from ??? to 2.3(?), and I get some 
error messages...

So: I want to store datas in the simply as possible, but I don't want to 
get error messages in the future, when I upgrade a new python version.

I see that the Gnosis project have pickle tools that can dump objects to 
XML.
XML is compatible in any future versions, I can read it, etc.

So. Anyone can help me: pickle module have problems when I want to load 
older dumped objects, or I can use it for dev. my application ?
Or any tool I need to use ?

Thanks for the advance:
dd
-- 
http://mail.python.org/mailman/listinfo/python-list


The Net's #1 Joke e-Book!

2006-03-31 Thread Expert Humor
That's Comedy - Over 460 Pages of Little Snickers, 
Medium-Sized Chuckles, and Great Big Belly Laughs:

http://www.ExpertHumor.com/That'sComedy.htm





*** Free account sponsored by SecureIX.com ***
*** Encrypt your Internet usage with a free VPN account from 
http://www.SecureIX.com ***
-- 
http://mail.python.org/mailman/listinfo/python-list


@@@@GET MORE CHICKS............LEARN GUITAR.............

2006-03-31 Thread Expert Humor
Chicks dig guitar players.
So get more chicks!
Learn how to play guitar!

http://www.ExpertHumor.com/LearnGuitar.htm












*** Free account sponsored by SecureIX.com ***
*** Encrypt your Internet usage with a free VPN account from 
http://www.SecureIX.com ***
-- 
http://mail.python.org/mailman/listinfo/python-list


wx.checklistbox

2006-03-31 Thread luca72
Hello
I write one file using:...(i think that is ok for write all the
lines of my list)
luca = open('/tmp/luca', 'w')
luca.writelines(list)

when i open the application again i use:

leggi = open('/tmp/luca', 'r')
leggi.readlines()

How can i store this line in to a wx.checkbox.

Thanks Luca

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


Re: How to determine COM objects/functions

2006-03-31 Thread M�ta-MCI
Hi!

COM browsers, Makepy, and other tools run only for statics COM servers.
For dynamic-COM-servers, there are ... only ... documentation.

@-salutations

Michel Claveau



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


Re: Best IDE for Python?

2006-03-31 Thread kbperry
I have recently been trying out NewEdit, and it is a pretty good IDE
for Python.

The reason that I have it in quotes is because I haven't really found a
true IDE (like the way Eclipse behaves for Java) for python.  (I
realize that Eclipse has a plug-in for Python, too).

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


Re: wx.checklistbox

2006-03-31 Thread Philippe Martin
Not sure I understand: a wx.CheckBox has up to three states (on, off ...
does not apply/greyed)

Is that what you read from your file ?

Philippe



luca72 wrote:

 Hello
 I write one file using:...(i think that is ok for write all the
 lines of my list)
 luca = open('/tmp/luca', 'w')
 luca.writelines(list)
 
 when i open the application again i use:
 
 leggi = open('/tmp/luca', 'r')
 leggi.readlines()
 
 How can i store this line in to a wx.checkbox.
 
 Thanks Luca

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


packaging question - documentation

2006-03-31 Thread schwehr
Hi All,

I am rearranging the layout of one of my python projects so that it
more closely conforms to how most python projects seem to work.   I now
have a structure like this:

seismic-py
   - setup.py
   - seismic
- bulk of the code
   - scripts
- programs that go in bin

I am using OptionParser, help2man, groff and man2html to provide man
pages.  Everything was sitting in the top level directory, so it was
clear where to put these, but where do I put the foo.help2man files
that contain extra text for the man pages?   If I put it in scripts,
that is pretty easy to cope with, but I was thinking about a docs
directory, but then the build process might be more difficult.  Or
should I be putting in another string in each executable that contains
this extra man page info?  Then it would show up in epydoc as well.
Maybe something like

__help2man__ = '''
[AUTHOR]
Kurt Schwehr

[SEE ALSO]
segysql.py

[DESCRIPTION]
.PP

The --coord-unit option is designed to allow use of databases that
exclude the CoordUnit field.  This field is probably the same for all
traces in the majority of SEGY data files, so most segy-py drivers
will want to exclude coordunit from the short list (see segysql.py).
The values are taken from page 14 of the SEG-Y Rev 1 specification

  -1 = Follow field 89-90 of the trace header
   1 = Length (meters or feet) [NOT supported]
   2 = Seconds of arc
   3 = Degrees, minutes, seconds (DMS) [NOT SUPPORTED]
'''

I am still in the middle of shuffling the tree about, but it is
available here...

https://cowfish.unh.edu/projects/seismic-py/

Any thoughts would be greatly appreciated!  I am still trying to
understand the best practices for python packaging.

Thanks!
-kurt

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


cgi error

2006-03-31 Thread s99999999s2003
hi
I have a little function to use ftputil module to get a file from a
server

def getfile(filename):
import ftputil
host = ftputil.FTPHost(svr, usr,pswd)
host.chdir(/somewhere)
try:
host.download(filename,filename,a)
except ftputil.FTPError,v:
print v

It works fine when i run it in python , but it won't run when i run my
cgi script
It says AttributeError: 'module' object has no attribute 'FTPHost'
what could be a possible cause? thanks.

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


%%%%HOW TO BE FUNNY!%%%%

2006-03-31 Thread Expert Humor
You too can learn to be funny in just 7 days flat:

http://www.ExpertHumor.com/HowToBeFunny.htm








*** Free account sponsored by SecureIX.com ***
*** Encrypt your Internet usage with a free VPN account from 
http://www.SecureIX.com ***
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to comment lot of lines in python

2006-03-31 Thread olsongt

Eric Deveaud wrote:
 [EMAIL PROTECTED] wrote:
   Like in C we comment like
   /*
   Bunch of lines of code
   */
 
   Should we use docstring  

 I would say NO.
 docstring are displayed by pydoc, thus a pydoc on your code will display some
 inconsistent information ;-)


docstrings are a bit of a magical construct.  Not all strings in a
function are docstrings.

 def foo():
... real docstring
... 
... x=1
... 
... print x
...
 help(foo)
Help on function foo in module __main__:

foo()
real docstring



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


Spawn/Kill Process

2006-03-31 Thread david brochu jr
I need to write a script that starts an exe and then continues throughthe script. I am able to start the exe file but my script doesn'tcontinue because the process I start runs in the background of Windows(as it is supposed to). I have tried using both 
os.system and os.popento get around this but still no luck. It seems as if Python does notmove to the next line of code UNTIL the program spawned completes(which this one never will as it is supposed to continuously run in
the background). Does anyone know of a way around this so I can spawnthe program and continue through my script?
-- 
http://mail.python.org/mailman/listinfo/python-list

QOTW... (was: Doc suggestions (was: Why class exceptions are not deprecated?))

2006-03-31 Thread skip

 Ed == Ed Singleton [EMAIL PROTECTED] writes:

Ed Go to the wiki, make the changes you want, and feel good about
Ed yourself for once.

+1 QOTW.

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


Re: Can I control Video Card by using Python under linux?

2006-03-31 Thread Mike C. Fletcher
LUK wrote:
 Hi, I have a video card based on cx2388 chip to catch video and do the
 other thing.
 There's already a V4L2 driver for it, but it is too hard for me to
 program in C.
 Can I use Python do the job?
 Does Python has simpler APIs?
 Please gvie me some suggestion.
 Thanks!
   
You are probably looking for the gstreamer package.  It has Python 
bindings available.

HTH,
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: wx.checklistbox

2006-03-31 Thread luca72
Sorry Philippe 
is a Wx.checklistbox

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


Re: Can I export my datas in pickle format safely ?

2006-03-31 Thread Sybren Stuvel
DurumDara enlightened us with:
 I want to create a database from datas.

Just nitpicking: 'data' is already plural, a single is called 'datum'.

 I thinking about that I can use the pickle to serialize/load my
 datas from the file.

Sure you can. Be very, very careful though, since unpickling data can
result in that data taking over your Python.

 And when I changed my python version from ??? to 2.3(?), and I get
 some error messages...

Which is exactly as documented in the pickle module.

 So: I want to store datas in the simply as possible, but I don't
 want to get error messages in the future, when I upgrade a new
 python version.

Without knowing more about your data, I can't help you out. You could
try an SQLite database.

 I see that the Gnosis project have pickle tools that can dump
 objects to XML.  XML is compatible in any future versions, I can
 read it, etc.

Don't be too sure that it's compatible for the indefinite future. XML
is just as future-proof as any other format.

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: cgi error

2006-03-31 Thread v0id
I'm not sure, but in your CGI script, where you have
import cgi
or
import cgi
import cgitb; cgitb.enable()
there sometimes come error if place any other modules over it.
I don't now if it is that, 'cus i don't have seen more of your code.
so if your code is:
importFTPHost
import cgi
import cgitb; cgitb.enable()
#Some code here
# and here
.. then prove this:
import cgi
import cgitb; cgitb.enable()
import FTPHost
#Some code here
# and here

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


Re: Best IDE for Python?

2006-03-31 Thread Fabio Zadrozny
On 31 Mar 2006 06:46:35 -0800, kbperry [EMAIL PROTECTED] wrote:
I have recently been trying out NewEdit, and it is a pretty good IDEfor Python.The reason that I have it in quotes is because I haven't really found atrue IDE (like the way Eclipse behaves for Java) for python.(I
realize that Eclipse has a plug-in for Python, too).
So, why wouldn't you consider Pydev (the python plugin for Eclipse) a Python IDE? 
--http://mail.python.org/mailman/listinfo/python-list

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

Re: how to comment lot of lines in python

2006-03-31 Thread Eric Deveaud
[EMAIL PROTECTED] wrote:
 
  Eric Deveaud wrote:
  [EMAIL PROTECTED] wrote:
Like in C we comment like
/*
Bunch of lines of code
*/
  
Should we use docstring  
 
  I would say NO.  docstring are displayed by pydoc, thus a pydoc on your
  code will display some inconsistent information ;-)
 
 
  docstrings are a bit of a magical construct.  Not all strings in a
  function are docstrings.


yep fogotten that triple quotted strings are considered as docstring
only if they are the first lines of the module/fonction/class/method 
excluding the comments lines.

my bad

Eric

-- 
SYBEX ORIGINAL SOFTWARE
NOUVEAU KIT LINUX REDHAT 5.2 POUR WIN 95/98
-+- Sybex in Guide du linuxien pervers - L'incompétance en action -+-
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to debug python code?

2006-03-31 Thread Grant Edwards
On 2006-03-31, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

I am new to Python programming.I am not getting exactly pdb.Can
 anyone tell me effective  way to debug python code?

1) Read your code.  Think.

2) Add some print statements.

3) goto 1)

-- 
Grant Edwards   grante Yow!  Where's th' DAFFY
  at   DUCK EXHIBIT??
   visi.com
-- 
http://mail.python.org/mailman/listinfo/python-list


member variables in python

2006-03-31 Thread PyPK
hi how do I write this better with member variables rather than global
as you see below.

eg:

test-flag = 0

class AA:
   def __init__(...):

  def methos(self,...):
   global test-flag
   test-flag = xx

instead of something like above ..how do i put it i terms of member
variables?

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


Re: Best IDE for Python?

2006-03-31 Thread Keith B. Perry
To me, it just doesn't behave the same way as Eclipse for java. I have used the plug-in, and I usually use it on my home machine ( I am still a student). For example, in Java eclipse, if you import a module like math, then if you want to use a math function, you just type math + period, and then all the functionspop up in a scroll menu. I love this. I am not searching through online documentation...etc just to find some stupid method/function that I know is there. It doesn't seem to behave like this for PythonI wish it did.


I still love programming in Python, though.
On 3/31/06, Fabio Zadrozny [EMAIL PROTECTED] wrote:


On 31 Mar 2006 06:46:35 -0800, kbperry [EMAIL PROTECTED]
 wrote: 
I have recently been trying out NewEdit, and it is a pretty good IDEfor Python.
The reason that I have it in quotes is because I haven't really found atrue IDE (like the way Eclipse behaves for Java) for python.(I realize that Eclipse has a plug-in for Python, too).
So, why wouldn't you consider Pydev (the python plugin for Eclipse) a Python IDE? 
--
http://mail.python.org/mailman/listinfo/python-list 
-- 
http://mail.python.org/mailman/listinfo/python-list

cd burning

2006-03-31 Thread DK
i was wondering if there had been any recent development of python
modules that enables cd writing capabilities.

specifically, i'm looking to produce audio cds from ogg files on a
win32 envrionment.

any leads will be greatly appreciated...

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


Re: cgi error

2006-03-31 Thread Richard Brodie

[EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]

 It works fine when i run it in python , but it won't run when i run my
 cgi script.

 It says AttributeError: 'module' object has no attribute 'FTPHost'
 what could be a possible cause? thanks.

Perhaps you called your script 'ftputil'. If so, 'import ftputil' won't
import the standard library version. 


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


Re: Best IDE for Python?

2006-03-31 Thread kbperry
To me, it just doesn't behave the same way as Eclipse for java.  I have
used the plug-in, and I usually use it on my home machine ( I am still
a student).  For example, in Java eclipse, if you import a module like
math, then if you want to use a math function, you just type math +
period, and then all the functions pop up in a scroll menu.  I love
this.  I am not searching through online documentation...etc just to
find some stupid method/function that I know is there.  It doesn't seem
to behave like this for PythonI wish it did.
 
I still love programming in Python, though.

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


Re: Python plug-in

2006-03-31 Thread Terry Hancock
toto wrote:

I'm trying to find some howto, tutorial in order to create a python program
that will allow plug-in programming. I've found various tutos on how to
write a plug-in for soft A or soft B but none telling me how to do it in my
own programs. Do you have any bookmarks ?
  

There is more than one way to accomplish this, but one of the
simplest is to provide a directory where plugins are loaded, and
put an __init__.py in it which automatically finds files in the directory
that conform to some standard, and imports them (or tries to).

Here's a snippet from one of my projects:

import sys, os
from Operators import Operator, operate, Ops

# Find and load all available plugin modules:

operator_path = os.path.abspath(__path__[0])
for module_file in filter(
lambda n: n[-3:]=='.py' and n not in ('__init__.py', 'Operators.py'),
os.listdir(operator_path)):
#print Loading %s % module_file
f, e = os.path.splitext(module_file)
__import__(f, globals(), locals(), [])


(Operators.py is in the same directory and includes general purpose
code that the plugins use -- I think it might be better design to put
that in the parent directory. But that's awkward until Python
introduces relative import notation -- supposed to be coming in v2.5).

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


Re: Best IDE for Python?

2006-03-31 Thread Doug Bromley
You may find the IDE review at Straw Dogs worth a look: http://www.straw-dogs.co.uk/blog/python-ide-reviewOn 3/31/06, 
Keith B. Perry [EMAIL PROTECTED] wrote:
To me, it just doesn't behave the same way as Eclipse for java. I have used the plug-in, and I usually use it on my home machine ( I am still a student). For example, in Java eclipse, if you import a module like math, then if you want to use a math function, you just type math + period, and then all the functionspop up in a scroll menu. I love this. I am not searching through online documentation...etc just to find some stupid method/function that I know is there. It doesn't seem to behave like this for PythonI wish it did.


I still love programming in Python, though.
On 3/31/06, Fabio Zadrozny [EMAIL PROTECTED]
 wrote:


On 31 Mar 2006 06:46:35 -0800, kbperry [EMAIL PROTECTED]
 wrote: 
I have recently been trying out NewEdit, and it is a pretty good IDEfor Python.
The reason that I have it in quotes is because I haven't really found atrue IDE (like the way Eclipse behaves for Java) for python.(I realize that Eclipse has a plug-in for Python, too).
So, why wouldn't you consider Pydev (the python plugin for Eclipse) a Python IDE? 
--

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

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

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

Re: member variables in python

2006-03-31 Thread Kent Johnson
PyPK wrote:
 hi how do I write this better with member variables rather than global
 as you see below.
 
 eg:
 
 test-flag = 0
 
 class AA:
def __init__(...):
 
   def methos(self,...):
global test-flag
test-flag = xx
 
 instead of something like above ..how do i put it i terms of member
 variables?

class AA:
def __init__(...):
   self.test_flag = 0

   def methos(self,...):
self.test_flag = xx

Note 'test-flag' is not a valid name.

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


Re: Convert Word .doc to Acrobat .pdf files

2006-03-31 Thread kbperry
The question is where is the API?

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


Re: Best IDE for Python?

2006-03-31 Thread Fabio Zadrozny
Well, in pydev you surely can have code-completion on 'math.'

I think you got some wrong configuration... Have you read the
getting started manual?
(http://www.fabioz.com/pydev/manual_101_root.html)
On 31 Mar 2006 07:44:38 -0800, kbperry [EMAIL PROTECTED] wrote:
To me, it just doesn't behave the same way as Eclipse for java.I haveused the plug-in, and I usually use it on my home machine ( I am stilla student).For example, in Java eclipse, if you import a module like
math, then if you want to use a math function, you just type math +period, and then all the functions pop up in a scroll menu.I lovethis.I am not searching through online documentation...etc just tofind some stupid method/function that I know is there.It doesn't seem
to behave like this for PythonI wish it did.I still love programming in Python, though.--http://mail.python.org/mailman/listinfo/python-list

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

Re: Best IDE for Python?

2006-03-31 Thread Keith B. Perry
You are probably right, and I will definitely take a look at the starter manual. Hopefully it also works well on classes that I create? You got some nice docs there.

Thanks for the tip!
On 3/31/06, Fabio Zadrozny [EMAIL PROTECTED] wrote:

Well, in pydev you surely can have code-completion on 'math.'I think you got some wrong configuration... Have you read the getting started manual? (
http://www.fabioz.com/pydev/manual_101_root.html)

On 31 Mar 2006 07:44:38 -0800, kbperry 
[EMAIL PROTECTED] wrote:


To me, it just doesn't behave the same way as Eclipse for java.I haveused the plug-in, and I usually use it on my home machine ( I am stilla student).For example, in Java eclipse, if you import a module like
math, then if you want to use a math function, you just type math +period, and then all the functions pop up in a scroll menu.I lovethis.I am not searching through online documentation...etc just tofind some stupid method/function that I know is there.It doesn't seem 
to behave like this for PythonI wish it did.I still love programming in Python, though.
--http://mail.python.org/mailman/listinfo/python-list 



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

Re: wx.checklistbox

2006-03-31 Thread luca72
I have solved with appen.items()
Regards

Luca

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


Re: CGIHTTPServer threading problems

2006-03-31 Thread infidel

Alvin A. Delagon wrote:
 I'm a simple python webserver based on CGIHTTPServer module:

 import CGIHTTPServer
 import BaseHTTPServer
 import SocketServer
 import sys
 import SQL,network
 from config import *

 class
 ThreadingServer(SocketServer.ThreadingMixIn,BaseHTTPServer.HTTPServer):
 pass

 cfg = params()
 print XBOX Server started on port %s. Press Ctrl+C to kill Server %
 cfg.port
 server =
 ThreadingServer((cfg.name,cfg.port),CGIHTTPServer.CGIHTTPRequestHandler)
 try:
 while 1:
 sys.stdout.flush()
 server.handle_request()
 except KeyboardInterrupt:
 print Server killed


 The my cgi scripts are stored in the cgi-bin folder. One cgi script in
 particular implements multi-threading and is supposed to be asynchronous
 but it's not working. The browser that requests on the cgi script tends
 to wait until the cgi script is done. I checked multi-threaded cgi
 script but I'm 100% percent sure that it has no problem since it worked
 as a mod_python script before. Anyone came across with this problem?

CGI doesn't run asynchronously.  All you've done with a multithreaded
CGI server is have each CGI script run on a separate thread.  But that
doesn't change the fact that a browser is going to sit there and wait
as the CGI script runs to completion (which is how the server knows
it's done).

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


Re: How to debug python code?

2006-03-31 Thread R. Bernstein
[EMAIL PROTECTED] writes:

 hi,
I am new to Python programming.I am not getting exactly pdb.Can
 anyone tell me effective  way to debug python code?
Please give me any example.
Looking for responce.
Thank You.
 Sushant

Well, I guess (in addition to the other good suggestions in this
thread) this is an obvious place to plug pydb
http://bashdb.sourceforge.net/pydb

If you are using pdb, I think you'll find pydb, um, better.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: member variables in python

2006-03-31 Thread PyPK
ok I reason I was going with globals is that i use this variable in
another class something like this along with above

testflag = 0

class AA:
   def __init__(...):

  def methos(self,...):
   global testflag
   testflag = xx

class BB:
def __init__(...):

   def method2(..):
   if testflag:
   print do this
is there a better way to access this if we go with what you mentioned
in another class ..
I wanted to avoid globals thats the reason i am looking for better
solution ..

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


Re: How to debug python code?

2006-03-31 Thread R. Bernstein
Dennis Lee Bieber [EMAIL PROTECTED] writes:

 On 30 Mar 2006 21:18:50 -0800, [EMAIL PROTECTED] declaimed the
 following in comp.lang.python:
 
  hi,
 I am new to Python programming.I am not getting exactly pdb.Can
  anyone tell me effective  way to debug python code?
 
   I think I toyed with pdb back around 1993... Never needed it...
 
   Of course, with so many different languages and debuggers in my
 life, I've never found time to master any but the old VMS debugger
 (which is nothing more than a very complex error handler G)

That's one reason why in my bash and GNU make debugger (and in
extending pdb), I've stuck to the gdb command set: the effort that is
spent mastering gdb can be transfered in the GNU Make, Bash, *AND*
Python debuggers.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to debug python code?

2006-03-31 Thread pruebauno
[EMAIL PROTECTED] wrote:
 hi,
I am new to Python programming.I am not getting exactly pdb.Can
 anyone tell me effective  way to debug python code?
Please give me any example.
Looking for responce.
Thank You.
 Sushant

If you are having issues you also might want to try:
http://pychecker.sourceforge.net/
and see if it finds your problem. You might get lucky.

Or just make the bigger install:
http://stani.be/python/spe/blog/
that one already includes pychecker and a python debugger.

Sorry for the noise if you were just looking for instructions for pdb.

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


Re: cd burning

2006-03-31 Thread RunLevelZero
I am hopeing something has developed myself.  I have been waiting
awhile.  I simply don't want to use cdrecord or cdrdao.  If I had the
know how I would be working on it but I believe this is a massive
undertaking and rather hard to accomplish.  I do hope this happens very
soon though.  Libburn might be of some use to you? I know FreeBSD
compiled some binding for python but the main libburn site only seems
to officially have ruby binding atm.  http://icculus.org/burn/.

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


Re: member variables in python

2006-03-31 Thread Grant Edwards
On 2006-03-31, PyPK [EMAIL PROTECTED] wrote:

 hi how do I write this better with member variables

Sorry, I don't know what member variables are.

 rather than global as you see below.

What you did below isn't global.  It's scope is limited to the
module containing the class.  If you got something that's used
by multiple classes in the module, then module-scope seems like
the logical choice.

 eg:

 test-flag = 0

 class AA:
def __init__(...):

   def methos(self,...):
global test-flag
test-flag = xx

 instead of something like above ..how do i put it i terms of member
 variables?

Dunno.  What are member varibles?

-- 
Grant Edwards   grante Yow!  Don't SANFORIZE me!!
  at   
   visi.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to search HUGE XML with DOM?

2006-03-31 Thread bayerj
Mind, that XML documents are not more flexible than RDBMS.

You can represent any XML document in a RDBMS. You cannot represent any
RDBMS in an XML document. RDBMS are (strictly spoken) relations and XML
documents are trees. Relations are superior to trees, at least
mathematically speaking.

Once you have set up your system in a practicable way (e.G. not needing
to create a new table via SQL Queries for a new type of node, which
would be a pain) SQL is far superior to XML.

Anyway, cElementTree seems to be the best way to go for you now. Its
performance is untopped by any other python xml library, as far as I
know.

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


Re: member variables in python

2006-03-31 Thread Fredrik Lundh
PyPK wrote:

 hi how do I write this better with member variables rather than global
 as you see below.

 eg:

 test-flag = 0

 class AA:
def __init__(...):

   def methos(self,...):
global test-flag
test-flag = xx

 instead of something like above ..how do i put it i terms of member
 variables?

you mean something like

class AA:

def __init__(self):
self.test_flag = 0 # initialize

def methods(self, value):
self.test_flag = value

# ...

aa = AA()
aa.methods(1)
print aa.test_flag

?

/F



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


Re: Find similar images using python

2006-03-31 Thread Terry Hancock
Thomas W wrote:

How can I use python to find images that looks quite similar? Thought
I'd scale the images down to 32x32 and convert it to use a standard
palette of 256 colors then compare the result pixel for pixel etc, but
it seems as if this would take a very long time to do when processing
lots of images.

Any hint/clue on this subject would be appreciated.
  

This really depends on what is meant by quite similar.

If you mean to the human eye, the two pictures are identical,
as in the case of a tool to get rid of trivially-different duplications,
then you can use the technique you propose.  I don't imagine that
you can save any time over that process.  You'd use something
like PIL to do the comparisons, of course -- I suspect you want to
do something like:

1) resize both
2) quantize the colors
3) subtract the two images
4) resize to 1x1
5) threshhold the result (i.e. we've used PIL to sum the differences)

strictly speaking, it might be more mathematically ideal to take
the sum of the difference of the squares of the pixels (i.e. compute
chi-square).  This of course, avoids the painfully slow process of
comparing pixel-by-pixel in a Python loop, which would, of course
be painfully slow.

This is conceptually equivalent to using an epsilon to test equality
of floating point numbers.

The more general case of matching images with similar content (but
which would be recognizeably different to the human eye), is a much
more challenging cutting-edge AI problem, as has already been
mentioned -- but I was going to mention imgSeek myself (I see someone's
already given you the link).



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


Re: Best IDE for Python?

2006-03-31 Thread Fabio Zadrozny
On 3/31/06, Keith B. Perry [EMAIL PROTECTED] wrote:
You are probably right, and I will
definitely take a look at the starter manual. Hopefully it also
works well on classes that I create? You got some nice docs there.
Surely does ;-) 


Cheers,

Fabio

Thanks for the tip!
On 3/31/06, Fabio Zadrozny 
[EMAIL PROTECTED] wrote:

Well, in pydev you surely can have code-completion on 'math.'I think you got some wrong configuration... Have you read the getting started manual? (

http://www.fabioz.com/pydev/manual_101_root.html)

On 31 Mar 2006 07:44:38 -0800, kbperry 

[EMAIL PROTECTED] wrote:


To me, it just doesn't behave the same way as Eclipse for java.I haveused the plug-in, and I usually use it on my home machine ( I am stilla student).For example, in Java eclipse, if you import a module like
math, then if you want to use a math function, you just type math +period, and then all the functions pop up in a scroll menu.I lovethis.I am not searching through online documentation...etc just tofind some stupid method/function that I know is there.It doesn't seem 
to behave like this for PythonI wish it did.I still love programming in Python, though.
--http://mail.python.org/mailman/listinfo/python-list 





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

Re: wx.checklistbox

2006-03-31 Thread luca72
sorry
appenditems

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


Re: re.sub problem

2006-03-31 Thread RunLevelZero
Okay I just woke up and haven't had enough coffee so if I'm off here
please forgive me.  Are you saying that if there is an emptly line then
it borks?  If so just use re.S ( re.DOTALL ) and that should take care
of it.  It will treat the ( . ) special.  Otherwise it ignores new
lines.

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


Re: member variables in python

2006-03-31 Thread PyPK
I see that.But here in my case the testflags is computed inside the
member function something like

class AA:

def __init__(self):
self.test_flag = 0 # initialize

def methods(self, value):
save_value = _munge(value)
self.test_flag = save_value

Now basically I want use this self.test_flag in another class ..
Basically I wanted to know if there is a better way than what i did
before..not necessarly a member variable way ..just looking for a more
eligant way if there is any..

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


best way to index numerical data ?

2006-03-31 Thread Jack
Hi I have a lot of data that is in a TEXT file which are numbers does
anyone have a good suggestion for indexing TEXT numbers (zip codes,
other codes, dollar amounts, quantities, etc). since Lucene and other
indexers are really optimized for Alpha character indexing. What
approaches are typically taken in computer science for example to index
text numbers..hash maps or something else ??

Thanks,

Jack

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


Re: member variables in python

2006-03-31 Thread bruno at modulix
PyPK wrote:
 ok I reason I was going with globals is that i use this variable in
 another class something like this along with above
 
 testflag = 0
 
 class AA:
def __init__(...):
 
   def methos(self,...):
global testflag
testflag = xx
 
 class BB:
 def __init__(...):
 
def method2(..):
if testflag:
print do this

Seems that you're looking for a logging package (hint: there's one in
the standard lib).

 is there a better way to access this if we go with what you mentioned
 in another class ..
 I wanted to avoid globals thats the reason i am looking for better
 solution ..
 

A general solution would be a combination of
1/ a Singleton or Monostate (for storing application-wide settings) and
2/ a method decorator managing additionnal responsabilities according to
the values of 1.

There are examples of Singleton/Borg/Monostate/whatnot in the Python
cookbook and elsewhere - as usual, google is your friend - and a QD
example of decorator doing this kind of jobs in the decorator library
http://wiki.python.org/moin/PythonDecoratorLibrary

My 2 cents
-- 
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: Spawn/Kill Process

2006-03-31 Thread Daniel Nogradi
 I need to write a script that starts an exe and then continues through
 the script. I am able to start the exe file but my script doesn't
 continue because the process I start runs in the background of Windows
 (as it is supposed to). I have tried using both os.system and os.popen
 to get around this but still no luck. It seems as if Python does not
 move to the next line of code UNTIL the program spawned completes
 (which this one never will as it is supposed to continuously run in
 the background). Does anyone know of a way around this so I can spawn
 the program and continue through my script?

You might want to try the spawn* family of functions and pass the
P_NOWAIT mode parameter. You can read all things spawn* here:

http://docs.python.org/lib/os-process.html
-- 
http://mail.python.org/mailman/listinfo/python-list


base64 memory question

2006-03-31 Thread Michele Petrazzo
Hi ng,
I see that after en encoding with base64, the memory used for the
variable that I use for store the encoded data, after deleted, python
keep a part of that memory:

#ls -lh on /tmp/test_zero
#-rw-r--r--  1 michele michele 9,8M 2006-03-31 18:32 /tmp/test_zero


michele:~$ python2.4
Python 2.4.2 (#2, Nov 20 2005, 17:04:48)
[GCC 4.0.3 2005 (prerelease) (Debian 4.0.2-4)] on linux2
Type help, copyright, credits or license for more information.
 import base64

# Now top say me:
6217 michele   15   0  4412 2536 3336 S  0.0  0.3   0:00.01 python2.4

 b = base64.encodestring(open(/tmp/test_zero, rb).read())

#top:
6217 michele   15   0 39156  36m 3376 S 19.6  4.8   0:00.60 python2.4

 del base64, b

#top
6217 michele   15   0 25644  23m 3376 S  0.0  3.1   0:00.61 python2.4

So like I can read from the top, python forgot to free that part of
memory. Is this normal? Is there a solution for free that memory?

P.s. The same happen on my win2k machine with py 2.4.2

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


Re: how to comment lot of lines in python

2006-03-31 Thread Michael Hobbs
Eric Deveaud wrote:
 [EMAIL PROTECTED] wrote:
   
  Eric Deveaud wrote:
 
 [EMAIL PROTECTED] wrote:
   
  Like in C we comment like
  /*
  Bunch of lines of code
  */

  Should we use docstring  
 
 I would say NO.  docstring are displayed by pydoc, thus a pydoc on your
 code will display some inconsistent information ;-)

   
  docstrings are a bit of a magical construct.  Not all strings in a
  function are docstrings.
 


 yep fogotten that triple quotted strings are considered as docstring
 only if they are the first lines of the module/fonction/class/method 
 excluding the comments lines.
   
The official rule is that if *any* string is the first line of a 
function/etc, it is considered a docstring. It's just standard 
convention to use the triple quotes for docstrings. As you mentioned, 
you can use triple quotes for any string; likewise, you can use standard 
quotes ( ' or  ) for docstrings as well.

- Mike


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


Re: How to search HUGE XML with DOM?

2006-03-31 Thread Ivan Vinogradov

On 31-Mar-06, at 11:17 AM, bayerj wrote:

 Mind, that XML documents are not more flexible than RDBMS.

 You can represent any XML document in a RDBMS. You cannot represent  
 any
 RDBMS in an XML document. RDBMS are (strictly spoken) relations and  
 XML
 documents are trees. Relations are superior to trees, at least
 mathematically speaking.

 Once you have set up your system in a practicable way (e.G. not  
 needing
 to create a new table via SQL Queries for a new type of node, which
 would be a pain) SQL is far superior to XML.

 Anyway, cElementTree seems to be the best way to go for you now. Its
 performance is untopped by any other python xml library, as far as I
 know.

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

If I may hijack this thread for a bit, I'd like to dig deeper into  
this issue :)

Currently my simulation program produces an XML log file with events  
represented as nodes.
Often those files grow to multiple GB size. I like this setup because  
the format is open
and easily parse-able with a variety of tools. So I have a bunch I  
scripts that can analyze
different aspects of the simulation.

I have not much clue about databases, except that they exist,  
somewhat complex, and often
use proprietary formats for efficiency. So any points on whether RDBM- 
based setup
would be better would be greatly appreciated.

Even trivial aspects, such as whether to produce RDBM during the  
simulation, or convert the complete XML log file into one, are not  
entirely clear to me. I gather that RDBM would be much better suited  
for analysis, but what about portability ? Is database file a  
separate entity that may be passed around?

Apologies if this seems like a selfish question, perhaps consider it  
a full disclosure, different set-ups/examples would be appreciated as  
well.

--
Cheers, Ivan

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


Re: re.sub problem

2006-03-31 Thread veracon
Thanks a lot! Compiling with re.DOTALL did fix my problem for the most
part; there still are a few problems with my code, but I think I can
fix those myself.

Again, thanks!

 Okay I just woke up and haven't had enough coffee so if I'm off here
 please forgive me.  Are you saying that if there is an emptly line then
 it borks?  If so just use re.S ( re.DOTALL ) and that should take care
 of it.  It will treat the ( . ) special.  Otherwise it ignores new
 lines.

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


Re: member variables in python

2006-03-31 Thread Kent Johnson
PyPK wrote:
 ok I reason I was going with globals is that i use this variable in
 another class something like this along with above
 
 testflag = 0
 
 class AA:
def __init__(...):
 
   def methos(self,...):
global testflag
testflag = xx
 
 class BB:
 def __init__(...):
 
def method2(..):
if testflag:
print do this
 is there a better way to access this if we go with what you mentioned
 in another class ..

1. Tell BB about the AA instance when it is created:

class BB:
   def __init__(self, aa):
 self.aa = aa

   def method(self):
 if self.aa.testflag:

2. Pass the flag to BB.method() directly:

   def method(self, testflag):
 if testflag:

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


  1   2   3   >