ANNOUNCE: SpamBayes release 1.0.1

2005-01-27 Thread Tony Meyer
The SpamBayes team is pleased to announce release 1.0.2 of SpamBayes.

As is now usual, this is both a release of the source code and of an
installation program for all Microsoft Windows users.

This is a bug-fix release that fixes a number of minor issues with the 1.0.1
release, but includes no new functionality, and is entirely compatible with
the 1.0 release.  A 1.1a1 release, including many new features, will
probably be released soon (probably within a few weeks).

This release fixes a couple of bugs with the sb_server/sb_imapfilter web
interface which are particularly annoying, so we strongly recommend all such
users upgrade.

This release also includes the first binary built with Python 2.4 - as a
result, malformed email should no longer be a problem.

Details about the bugs that have been fixed in this release can be found at

https://sourceforge.net/project/shownotes.php?release_id=285346

You can get the release via the 'Download' page at

http://spambayes.org/download.html

Enjoy the new release and your spam-free mailbox :-)

As always, thanks to everyone involved in this release, and, as always, the
Python development team, particularly Barry, Anthony and the rest of the
team responsible for email 3.0.

Tony.
(on behalf of the SpamBayes team)

--- What is SpamBayes? ---

The SpamBayes project is working on developing a Bayesian (of sorts)
anti-spam filter (in Python), initially based on the work of Paul Graham,
but since modified with ideas from Robinson, Peters, et al.

The project includes a number of different applications, all using the same
core code, ranging from a plug-in for Microsoft Outlook, to a POP3 proxy, to
various command-line tools.

The Windows installation program will install either the Outlook add-in (for
Microsoft Outlook users), or the SpamBayes server program (for all other
POP3 mail client users, including Microsoft Outlook Express). All Windows
users (including existing users of the Outlook add-in) are encouraged to use
the installation program.

If you wish to use the source-code version, you will also need to install
Python - see README.txt in the source tree for more information.

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

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


[ANNOUNCE] Twenty-second release of PythonCAD now available

2005-01-27 Thread Art Haas
I'm pleased to announce the twenty-second development release of PythonCAD,
a CAD package for open-source software users. As the name implies,
PythonCAD is written entirely in Python. The goal of this project is
to create a fully scriptable drafting program that will match and eventually
exceed features found in commercial CAD software. PythonCAD is released
under the GNU Public License (GPL).

PythonCAD requires Python 2.2 or newer. The interface is GTK 2.0
based, and uses the PyGTK module for interfacing to GTK. The design of
PythonCAD is built around the idea of separating the interface
from the back end as much as possible. By doing this, it is hoped
that both GNOME and KDE interfaces can be added to PythonCAD through
usage of the appropriate Python module. Addition of other PythonCAD 
interfaces will depend on the availability of a Python module for that
particular interface and developer interest and action.

The twenty-second release contains primarily internal code enhancements
in regards to the Python language. PythonCAD running under PyGTK releases
after the 2.4.0 release will now utilize the gtk.ComboBox and the
gtk.ColorButton widgets, while PythonCAD running under older releases
will still utilize the same widgets as before. This change removes
the DeprecatationWarning users with the newer PyGTK release would see.
A problem where restoring a deleted TextBlock entity was fixed, and a variety
of other fixes and improvements are also included in this release.

A mailing list for the development and use of PythonCAD is available.
Visit the following page for information about subscribing and viewing
the mailing list archive:

http://mail.python.org/mailman/listinfo/pythoncad

Visit the PythonCAD web site for more information about what PythonCAD
does and aims to be:

http://www.pythoncad.org/

Come and join me in developing PythonCAD into a world class drafting
program!

Art Haas
-- 
Man once surrendering his reason, has no remaining guard against absurdities
the most monstrous, and like a ship without rudder, is the sport of every wind.

-Thomas Jefferson to James Smith, 1822
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

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


Re: building Python: up arrow broken on SuSE Linux 8.2

2005-01-27 Thread Peter Otten
Erik Johnson wrote:

 the Apple Python distribution the OP was asking about.  I now notice this
 in the output of configure:
 
 checking for rl_pre_input_hook in -lreadline... no
 checking for rl_completion_matches in -lreadline... no
 
 
 My system has /lib/libreadline.so.4.3.   I guess it does not define
 these newer functions and so that is why the readline module was not
 configured in Setup to start with? That is the presumption I am working
 on.

Have you ensured (with yast) that readline-devel is actually installed?

Peter


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


Re: tkinter socket client ?

2005-01-27 Thread Tonino
great - thanks ;)

Tonino

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


Re: python without OO

2005-01-27 Thread michele . simionato
Davor wrote:
 Thanks,

 I do not hate OO - I just do not need it for the project size I'm
 dealing with - and the project will eventually become open-source and
 have additional developers - so I would prefer that we all stick to
 simple procedural stuff rather than having to deal with a developer
 that will be convincing me that his 50 layers inheritance hierarchy
is
 good since it exists in some weird pattern that he saw somewhere on
 some Java design patterns discussion board :-) and other proper OO
 design issues... Once I opted for C++ in a very small project and
 believed everyone will stick with C subset + better type checking
 offered through C++ - but I simply could not manage to keep them off
 using OO stuff which was just making program more complicated than it
 should have been. (note, I am not an experienced developer, nor the
 others I'll be working with (even though some think they are:-)), so
I
 prefer preemptively dealing with issue of everyone showing off their
OO
 design skills)


I think Davor is making an important point here: Python has grown in
the last 14 years, and it is no more the simple scripting language
it used to be. In particular, it evolved a lot of OOP cruft
(static/classmethods, properties, the __new__ method, super, the new
MRO, descriptors,metaclasses, etc.) and there is more than a learning
curve issue coming with the added complexity. Davor is right: even if
you do not want to use it, the stuff is *there* and somebody in your
team will. So definitely there is an audience of programmers that just
do not have an use for all the sophistication and actually are
penalized by it.

There is not much than can be done at the Python level. But I would
see with interest a Python spinoff geared towards simplicity. Few
months ago there was the Prothon proposal (by all means a terrible
proposal) but the goal that motivated it (simplification, trying
to remove classes) was in my opinion worthwhile.

Now, *how* to remove (or simplify) classes is not at all clear to me,
not I am convinced that prototypes are the right way to go, but still I
feel that there is something wrong with inheritance. Maybe
protocols are the solution, who knows? But in any case I think it
is important to keep searching for semplicity. I do not believe
Python is the definitive language, and it is probabily possible
to introduce something better. It is just that nothing of the
kind appeared until now, but I keep watching at the horizon ;)
Michele Simionato

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


Re: python without OO

2005-01-27 Thread Timo Virkkala
Davor wrote:
Timo Virkkala wrote:
This guy has got to be a troll. No other way to understand.
not really - it was not my intention at all - but it seems people get 
upset whenever this OO stuff is mentioned - and what I did not expect at 
all at this forum as I believed Python people should not be so OO 
hardcore (seems not all as quite a few have indicated in their 
replies)... Nevertheless, I think the discussion has several quite good 
points!
Yes, sorry about that. I posted too soon. After posting I read more of your 
posts and realized that you really mean it, so I tried to cancel my message, but 
apparently it got through (news message canceling has never been that reliable..).

I believe that if you take the time to do some Python programming, you can find 
out that OO, when used correctly, is not the huge monster your previous 
languages had led you to believe it is. In Python, you can use just the right 
amount of OO to make things easier and more sensible, without complicating 
things with huge inheritance trees and unnecessary polymorphism.

Again, sorry about my premature judgement.
--
Timo Virkkala
--
http://mail.python.org/mailman/listinfo/python-list


Re: string.atoi and string.atol broken? [OT]

2005-01-27 Thread Peter Otten
Christos TZOTZIOY Georgiou wrote:

 In current Greek hexadecimal is  (dekaexadikon).

I borrowed Guido's time machine to fix the above (hopefully) :-)

The Latin part escaped me.
 
 By Latin I suppose you jokingly mean the Greek parts... :)

I thought it was a well-known fact that speakers of the awful German
language have absolutely no humour.

My first assumption was that hexadecimal is Greek and then I modified that
to a Greek/Latin combo decimal.

 Just in case it didn't show up correctly in your ng/mail client, it does
 on groups.google.com (the post was in UTF-8, dammit! --excuse my romance
 language)

It did show up correctly, but was garbled in the response through technical
incompetence of the poster.

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


Re: String Fomat Conversion

2005-01-27 Thread Dennis Benzinger
mcg wrote:
 Investigating python day 1:
 
 Data in file:
 x   y
 1   2
 3   4
 5   6
 
 
 Want to read file into an array of pairs.
 
 in c: scanf(%d %d,x,y)---store x y in array, loop.
 
 How do I do this in python??
 In the actual application, the pairs are floating pt i.e. -1.003
 

Either do what the other posters wrote, or if you really like scanf
try the following Python module:

Scanf --- a pure Python scanf-like module
http://hkn.eecs.berkeley.edu/~dyoo/python/scanf/

Bye,
Dennis
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: String Fomat Conversion

2005-01-27 Thread Stephen Thorne
On Thu, 27 Jan 2005 00:02:45 -0700, Steven Bethard
[EMAIL PROTECTED] wrote:
 Stephen Thorne wrote:
  f = file('input', 'r')
  labels = f.readline() # consume the first line of the file.
 
  Easy Option:
  for line in f.readlines():
x, y = line.split()
x = float(x)
y = float(y)
 
  Or, more concisely:
  for line in f.readlines():
x, y = map(float, line.split())
 
 Somewhat more memory efficient:
 
 lines_iter = iter(file('input'))
 labels = lines_iter.next()
 for line in lines_iter:
  x, y = [float(f) for f in line.split()]
 
 By using the iterator instead of readlines, I read only one line from
 the file into memory at once, instead of all of them.  This may or may
 not matter depending on the size of your files, but using iterators is
 generally more scalable, though of course it's not always possible.

I just did a teensy test. All three options used exactly the same
amount of total memory.

I did all I did in the name of clarity, considering the OP was on his
first day with python. How I would actually write it would be:

inputfile = file('input','r')
inputfile.readline()
data = [map(float, line.split()) for line in inputfile]

Notice how you don't have to call iter() on it, you can treat it as an
iterable to begin with.

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


Re: Which is faster?

2005-01-27 Thread Peter Otten
Aggelos I. Orfanakos wrote:

 Any idea which of the following is faster?
 
 'a/b/c/'[:-1]
 
 or
 
 'a/b/c/'.rstrip('/')

Don't ask for the speed, decide whether you want to transform

a/b/c -- a/b/c
a/b/c// -- a/b/c

or

a/b/c -- a/b/
a/b/c// -- a/b/c/

That is much more important.

Peter

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


Re: python without OO

2005-01-27 Thread Peter Maas
Terry Reedy schrieb:
But if the class method syntax were 
manditory, there would be class and/or class hierarchy bloat due to the 
unlimited number of possible functions-of-a-float and large number of 
actual such functions that have been written.
You are right. I'm not an OO purist, I just wanted to convince Davor,
that anti-OO purism can be harmful too. It's good for programmers to
have a choice.
Your Four Steps to Python Object Oriented Programming - vars, lists, dicts, 
and finally classes is great.
I'm glad you like it :)
--
---
Peter Maas,  M+R Infosysteme,  D-52070 Aachen,  Tel +49-241-93878-0
E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64')
---
--
http://mail.python.org/mailman/listinfo/python-list


Re: Classical FP problem in python : Hamming problem

2005-01-27 Thread Nick Craig-Wood
Francis Girard [EMAIL PROTECTED] wrote:
  Thank you Nick and Steven for the idea of a more generic imerge.

You are welcome :-)  [It came to me while walking the children to school!]

[snip]
  class IteratorDeiterator:
def __init__(self, iterator):
  self._iterator = iterator.__iter__()
  self._firstVal = None ## Avoid consuming if not requested from outside
## Works only if iterator itself can't return None

You can use a sentinel here if you want to avoid the can't return
None limitation.  For a sentinel you need an object your iterator
couldn't possibly return.  You can make one up, eg

   self._sentinel = object()
   self._firstVal = self._sentinel

Or you could use self (but I'm not 100% sure that your recursive
functions wouldn't return it!)

def __iter__(self): return self
 
def next(self):
  valReturn = self._firstVal
  if valReturn is None:

and
   if valReturn is self._sentinel:

valReturn = self._iterator.next()
  self._firstVal = None

   self._firstVal = self._sentinel

etc..

[snip more code]

Thanks for some more examples of fp-style code.  I find it hard to get
my head round so its been good exercise!
-- 
Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python memory blow out

2005-01-27 Thread Nick Coghlan
Simon Wittber wrote:
Does anyone have ideas on why this is occuring, or how I might
otherwise prevent memory blow out?
The first thing to check is whether you might be accidentally keeping a 
reference to the result set alive somewhere.

If that's not the case, then try to find out if the result set is created by one 
big allocation or lots of little ones (If the latter, other responses have 
pointed out how it may cause your problem).

There's also a chance of a problem with the database API wrapper, so it may be 
worth checking with an API specific list.

Cheers,
Nick.
--
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---
http://boredomandlaziness.skystorm.net
--
http://mail.python.org/mailman/listinfo/python-list


Re: python without OO

2005-01-27 Thread Peter Maas
Davor schrieb:
I browsed docs a bit today, and they also confirm what I have believed - 
that OO is totally secondary in Python.
OO is not secondary in Python. It's secondary for you :) And Python
leaves the choice to you.
In fact, 
object/classes/metaclasses are nothing but *dictionaries with identity* 
in python.
Eliminating nothing but makes this a true statement :)

Love this approach. In fact, you can very easily implement 
your own *OO model* completely separate of Python's OO model... Now I 
actually strongly believe that Python's author has introduced the whole 
OO model just to attract and make happy OO population... 
I believe that your belief is wrong :) Guido van Rossum has introduced
OO to Python because it's a useful concept.
and you can definitely be more productive using Python's structured 
programming than Java/C++ OO programming :-)... and Python is probably 
the best example why we should have skipped OO all together..
Sigh. Proceed as you like but be aware that dogmatism - OO as well as
anti-OO is always a poor guide. OO wasn't invented as a marketing buzz
but to support programming styles that emerged in non-OO languages to
control the increasing complexity of programs.
so you get a nice program with separate data structures and functions 
that operate on these data structures, with modules as containers for 
both (again ideally separated). Very simple to do and maintain no matter 
what OO preachers tell you...
The bad thing about OO preachers is not OO but preaching. And you
are preaching, too ;)
--
---
Peter Maas,  M+R Infosysteme,  D-52070 Aachen,  Tel +49-241-93878-0
E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64')
---
--
http://mail.python.org/mailman/listinfo/python-list


Re: python without OO

2005-01-27 Thread Nick Coghlan
[EMAIL PROTECTED] wrote:
Then why was C++ invented? What you have described can be done in C,
Pascal, and Fortran 90, all of which are generally classified as
procedural programming languages. As Lutz and Ascher say in Learning
Python, in object-based programming one can pass objects around, use
them in expressions, and call their methods. To qualify as being truly
object-oriented (OO), though, objects need to also participate in
something called an inheritance hierarchy.
Again, behavioural inheritiance is something which can be done manually via 
delegation or function tables.

What a language with OO support adds is special syntax for something that you 
could have done anyway - the OO support just makes it easier and clearer (well, 
C++ aside).

Cheers,
Nick.
--
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---
http://boredomandlaziness.skystorm.net
--
http://mail.python.org/mailman/listinfo/python-list


Re: python without OO

2005-01-27 Thread Nick Coghlan
Davor wrote:
data structures
 and
 functions that operate on these data structures
Eh? What do you think a class is?
Py data = range(10)
Py list.extend(data, range(5))
Py list.sort(data)
Py print data
[0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 6, 7, 8, 9]
The fact that data.extend(range(5)) and data.sort() are alternative spellings 
for the second and third lines doesn't change the fact that a class is just a 
data structure grouped with a bunch of functions that operate on that data 
structure.

Cheers,
Nick.
--
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---
http://boredomandlaziness.skystorm.net
--
http://mail.python.org/mailman/listinfo/python-list


Re: python without OO

2005-01-27 Thread Peter Maas
[EMAIL PROTECTED] schrieb:
Davor is right: even if
you do not want to use it, the stuff is *there* and somebody in your
team will. So definitely there is an audience of programmers that just
do not have an use for all the sophistication and actually are
penalized by it.
No, because Python does not enforce using advanced concepts. You
can write programs that are as simple as in 1991. A group of developers
always has to find some kind of common style with a chance that some
are penalized. This can happen with every language.
There is not much than can be done at the Python level. But I would
see with interest a Python spinoff geared towards simplicity.
I think this would be useless because advanced concepts exist for
a reason. A simplified spin-off would aquire advanced concepts
over time and would just become a clone of Python.
--
---
Peter Maas,  M+R Infosysteme,  D-52070 Aachen,  Tel +49-241-93878-0
E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64')
---
--
http://mail.python.org/mailman/listinfo/python-list


Re: HAVE YOU HEARD THE GOOD NEWS!

2005-01-27 Thread Alex Hunsley
[EMAIL PROTECTED] wrote:
Good News!
Do you know how simple it is to go to Heaven after this life has ended?
Some people believe that belonging to a local church, temple, mosque or
synagogue will get them to Heaven.
Others believe that water baptism, obeying the ten commandments or just
being a good person will get them to Heaven.
There are many other beliefs as well, but the good news about God's way
to Heaven is found in the Holy Bible.
Boy, are you going to be sorry when Thor sends thunderbolts into your arse.
--
http://mail.python.org/mailman/listinfo/python-list


Re: python without OO

2005-01-27 Thread Nick Coghlan
[EMAIL PROTECTED] wrote:
Furthermore, if in Python the algorithm for the reverse function
applies to many kinds of objects, it just needs to be coded once,
whereas a reverse method would have to provided for each class that
uses it (perhaps through inheritance).
Indeed, this is why Python not only provides the list.reverse() method to 
reverse a list in place, but also provides the reversed() function to reverse 
any sequence:

Py lst = list(ABCDEFGHIJ)
Py lst.reverse()
Py print .join(lst)
JIHGFEDCBA
Py print .join(reversed(lst))
ABCDEFGHIJ
Ditto list.sort() and sorted().
Cheers,
Nick.
--
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---
http://boredomandlaziness.skystorm.net
--
http://mail.python.org/mailman/listinfo/python-list


ANN: Tao Scripting Language 0.8.5 beta released!

2005-01-27 Thread Limin Fu
Dear all,

I am glad to announce in this mailing list that the lastest version
of a new scripting language has come out.

Welcome to try it out.

Comments are welcome.

Suggestions are appreciated.

===
Here are some details:
===

Design Goals:
1. Simple and efficient.
2. Integrate nice features of other languages whenever possible.

Implementation language: C++ with STL.

Designer: Fu Limin
Email: fu [dot] limin [dot] tao [at] gmail.com

Key features have been supported:

1. Dynamic-typing variables, supporting complex data structures 
   such as array/list, hash/dictionary and matrix etc.

2. Object-oriented programming ( multi-inheritance not supported 
   yet ).

3. Basic string regular expression matching.

4. Automatic garbage collection capable of collecting cyclically
   referenced objects.

5. Numeric data types: complex number and matrix, and their basic 
   operations.

6. Convenient namespacing and dynamic creation of subroutines and 
   classes.

7. Dynamic loading of C/C++ modules ( not complete, but enough for 
   playing with it ^_^ ).

8. An embedded tiny XML parser.

ToBeDone:
More string operations, multi-inheritance of classes, improvements 
on C/C++ module loading, more on regular expression matching and 
possible optimizations etc.

Documentation:
  
http://taoscript.sourceforge.net/brief_tao.php

Sample scripts:
  
http://taoscript.sourceforge.net/sample.php

Download:
http://taoscript.sourceforge.net/downloads.php

Best regards,

Limin

-- 
Homepage for Tao Language:
http://taoscript.sourceforge.net

Tao Language project at sourceforge.net:
http://sourceforge.net/projects/taoscript
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python without OO

2005-01-27 Thread michele . simionato
Peter Maas:
[EMAIL PROTECTED] schrieb:

 Davor is right: even if
 you do not want to use it, the stuff is *there* and somebody in your
 team will. So definitely there is an audience of programmers that
just
 do not have an use for all the sophistication and actually are
 penalized by it.

No, because Python does not enforce using advanced concepts. You
can write programs that are as simple as in 1991. A group of
developers
always has to find some kind of common style with a chance that some
are penalized. This can happen with every language.

No. In theory C++ could be kept as simple as C but in practice it is
not.

 There is not much than can be done at the Python level. But I would
 see with interest a Python spinoff geared towards simplicity.

I think this would be useless because advanced concepts exist for
a reason. A simplified spin-off would aquire advanced concepts
over time and would just become a clone of Python.

And then we will need another simplified spinoff ;)
There is always a fight between simplificity and complexity.
Some complexity is not needed, and I am sure even in Python
something could be dropped. But it is difficult to find what can
be removed. Remember that Saint-Exupery quote? Something
like a work of art is finished when there is nothing left to remove?
M.S.

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


Re: python module in webmin

2005-01-27 Thread moma
sam wrote:
Hi,
Had anyone written any python module for webmin?
Since  webmin is written in perl, but I want to write a python 
app/module used by webmin. If you know the detail of writing a python 
module for use in perl webmin, please drop me some guideline.

Perhaps It is better off to find/write a python version of webmin first.
Thanks
Sam.
Some tips.
0)
 Webmin API-spesification  (search for Python word)
 http://www.webmin.com/modules.html
1)
Read:
 http://www.cendio.se/~peter/python-webmin/
 Read README and Webmin.py.
 It says that 25% of API is converted to Python.
 It's normal CGI scripting and HTML. So you can easily
 write a real Webmin-module in Python.
 Maybe you can help to make Webmin.py more complete :)?
2)
Search for Python here
 http://webmin.thirdpartymodules.com/?page=Search
 Find any modules written in Python?
// moma
   http://www.futuredesktop.org/OpenOffice.html
   http://www.futuredesktop.org/hpc_linux.html





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


Re: subprocess.Popen() redirecting to TKinter or WXPython textwidget???

2005-01-27 Thread paul koelle
Ivo Woltring wrote:
The output of mencoder is not readable with readlines (i tried it) because
after the initial informational lines You don't get lines anymore (you get a
linefeed but no newline)
The prints are all on the same line (like a status line)
something like
Pos:   3,1s 96f ( 0%)  42fps Trem:   0min   0mb  A-V:0,038 [171:63]
Have you tried popen3 with stdout and stderr?
hth
 Paul
--
http://mail.python.org/mailman/listinfo/python-list


tkinter: Can You Underline More Than 1 Char In A Menu Title

2005-01-27 Thread Tim Daneliuk
I am currently underling the first character of a menu title (to indicate
its shortcut/accelerator key) like this:
   self.WildBtn = Menubutton(self.mBar, text=WILDMENU, underline=0, 
state=DISABLED)
However, I intend to actually have two separate keys invoke this menu
to have it behave differently in different circumstances.
Is it possible to underline more than a single character as I am doing
with the 'underline=0' above. I tried 'underline=(0,2)' but that didn't
work.
Ideas?
TIA,
--

Tim Daneliuk [EMAIL PROTECTED]
PGP Key: http://www.tundraware.com/PGP/
--
http://mail.python.org/mailman/listinfo/python-list


Re: how to pass attribute name via sys.argv

2005-01-27 Thread Wolfram Kraus
Felix Hebeler wrote:
Hi all, I am doing some Python scripting for a while, but I'm not too
deep into it yet. So I have a problem I can't solve.
I need to call an object attribute:
value = object.attrName[0]
the problem is, that the attribute name can only be specified at
runtime.
So what I have is something like
attrName = sys.argv[1] attrName
'cellsize'
and I need to pass it on so I can call
value = object.cellsize[0]
Use getattr:
value = getattr(object, attrName)[0]
Can this be done using Python?
Thanks for any hints
Cheers Felix
HTH,
Wolfram
--
http://mail.python.org/mailman/listinfo/python-list


Re: how to pass attribute name via sys.argv

2005-01-27 Thread Gilles Lenfant
Felix Hebeler a écrit :
Hi all,
I am doing some Python scripting for a while, but I'm not too deep into 
it yet. So I have a problem I can't solve.

I need to call an object attribute:
value = object.attrName[0]
the problem is, that the attribute name can only be specified at runtime.
So what I have is something like
  attrName = sys.argv[1]
  attrName
'cellsize'
and I need to pass it on so I can call
value = object.cellsize[0]
Can this be done using Python?
Thanks for any hints
Cheers
Felix
The builtin setattr is your friend.
object is now a reserved (builtin) name, use objekt instead.
class Foo(object):
pass
objekt = Foo()
attrName = sys.argv[1]
values = ['foo', 'bar', 'whatever']
setattr(objekt, attrName, values)
HTH
--
Gilles
--
http://mail.python.org/mailman/listinfo/python-list


Re: Please suggest on the book to follow

2005-01-27 Thread Satchidanand Haridas
Hi,
Probably the best resources for learning Python are available online. 
Here are a few sites that you might find helpful:

1. http://byteofpython.info/ 

2. http://www.diveintopython.org/   -- Writted by Mark Pilgrim, covers 
many advanced material. The site says /Dive into Python/  is a Python 
book for experienced programmers.

3. http://gnosis.cx/TPiP/  -- Site for Text Processing in Python, a 
book by David mertz. You will find many other very good Python related 
material on his website.


regards,
Satchit

Satchidanand Haridas (sharidas at zeomega dot com)
ZeOmega (www.zeomega.com)
Open  Minds' Open Solutions
#20,Rajalakshmi Plaza,
South End Road,
Basavanagudi,
Bangalore-560 004, India

santanu wrote:
Hi all,
I know a little python (not the OOP part) learnt by studying the online
tutorial. Now I would like to learn it more thoroughly.
I have access to 'Programming Python' which I liked (on flipping
through the
pages), but the problem is it deals only with version 2.0 of Phython.
So, I would be glad if you could suggest me whether it would be really
a good
idea to learn from this book. In other words, will I have to unlearn
too much
after I complete this book (by the time I am done with this book, I
believe
we will be having Python 2.6 or so).
Please suggest.
Regards,
Santanu
 

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


Re: redirect of standard output of jython to JTextArea

2005-01-27 Thread Jan Gregor
problem solved.
in class:
   sys.stdout = StdOutRedirector(self)
class StdOutRedirector:
def __init__(self, console):
self.console = console
def write(self, data):
#print  sys.stderr, %s % data
if data != '\n':
# This is a sucky hack.  Fix printResult
self.console.textArea.append(data)
Jan
Jan Gregor wrote:
Hello
 I want to redirect output of jython's functions print and println to 
JTextArea component. Is it possible ?

I tried this (swingConsole.textArea is instance):
In my class
 self.printStream= MyPrintStream(System.out)
System.setOut(self.printStream)

class MyPrintStream (PrintStream):
def println (str):
swingConsole.textArea.append(str)
def print (str):
swingConsole.textArea.append(str)
Output is still directed to standard output.
Thanks for help,
Jan
--
http://mail.python.org/mailman/listinfo/python-list


Point of Sale

2005-01-27 Thread Andreas Pauley
Hi,
My company has given me a rather cool project:
I have to provide them with an open-source python-based point-of-sale / 
cash register system that can integrate with their existing ERP backend.

The project will include development to ensure that the features they 
require are included in the open-source POS system.

Can you recommend anything that I can use?
Regards,
Andreas
--
http://mail.python.org/mailman/listinfo/python-list


Re: Please suggest on the book to follow

2005-01-27 Thread Ola Natvig
santanu wrote:
Hi all,
I know a little python (not the OOP part) learnt by studying the online
tutorial. Now I would like to learn it more thoroughly.
I have access to 'Programming Python' which I liked (on flipping
through the
pages), but the problem is it deals only with version 2.0 of Phython.
So, I would be glad if you could suggest me whether it would be really
a good
idea to learn from this book. In other words, will I have to unlearn
too much
after I complete this book (by the time I am done with this book, I
believe
we will be having Python 2.6 or so).
Please suggest.
Regards,
Santanu
I realy would recomend Practival Python it's a wery good book which I 
think it's written for 2.2 or 2.3, but it's got all the basic modern 
python aspects like new style classes.

http://www.amazon.com/exec/obidos/tg/detail/-/1590590066/qid=1106830797/sr=8-1/ref=sr_8_xs_ap_i1_xgl14/104-9460635-7128701?v=glances=booksn=507846
--
--
 Ola Natvig [EMAIL PROTECTED]
 infoSense AS / development
--
http://mail.python.org/mailman/listinfo/python-list


a question about boost.python

2005-01-27 Thread Li Daobing
I can't use .def(str(self))
I write a simple example, without `str', I can build it well, but with
this one, I can't build

//Rational.cpp
#include boost/python.hpp
#include iostream

using namespace std;
using namespace boost::python;

class Rational
{};

ostream operator(ostream os, Rational r){
return os;
}
BOOST_PYTHON_MODULE(Rational)
{
class_Rational(Rational)
.def(str(self)) // __str__
;
}
// end.

I don't know how to write Jamfile, so I write a Makefile, it works if i
don't use .def(str(self))

# Makefile
CC = g++

CFLAGS = -Wall -W -fPIC -I/usr/include/boost \
-I/usr/include/python2.3 -DBOOST_PYTHON_DYNAMIC_LIB \
-O2

LDFLAGS = -L/usr/local/lib -lboost_python -L/usr/lib/python2.3 \
-Wl,-rpath-link,.  -fPIC


CXXFLAGS = $(CFLAGS)

SLIB = hello.so Rational.so

all: $(SLIB)

%.so : %.o
/usr/bin/objcopy --set-section-flags .debug_str=contents,debug
$^
$(CC) $(LDFLAGS) $^ -shared -o $@

clean :
rm -f $(WORLD) $(OBJS)
# end.

or a simple setup.py, it also works if I don't use `str'

# setup.py
from distutils.core import setup, Extension

ext_modules = [Extension('Rational', ['Rational.cpp'],
define_macros=[('BOOST_PYTHON_DYNAMIC_LIB',
None)],
libraries=['boost_python'])]


setup(name=itcc,
version=0.2.2,
author='Li Daobing',
author_email='[EMAIL PROTECTED]',
ext_modules = ext_modules
)
# end.

This is the error message:
$ make
g++ -Wall -W -fPIC -I/usr/include/boost -I/usr/include/python2.3
-DBOOST_PYTHON_DYNAMIC_LIB -O2   -c -o Rational.o Rational.cpp
Rational.cpp: In function `std::ostream operator(std::ostream,
Rational)':
Rational.cpp:10: warning: unused parameter `Rational r'
/usr/include/boost/python/def_visitor.hpp: In static member function
`static
void boost::python::def_visitor_access::visit(const V, classT)
[with V =
boost::python::def_visitorboost::python::api::object, classT =
boost::python::class_Rational,
boost::python::detail::not_specified,
boost::python::detail::not_specified,
boost::python::detail::not_specified]
':
/usr/include/boost/python/def_visitor.hpp:67:   instantiated from `void
boost::python::def_visitorDerivedVisitor::visit(classT) const [with
classT = boost::python::class_Rational,
boost::python::detail::not_specified,
boost::python::detail::not_specified,
boost::python::detail::not_specified, DerivedVisitor =
boost::python::api::object]'
/usr/include/boost/python/class.hpp:225:   instantiated from
`boost::python::class_T, X1, X2, X3 boost::python::class_T, X1, X2,
X3::def(const boost::python::def_visitorDerived) [with Derived =
boost::python::api::object, W = Rational, X1 =
boost::python::detail::not_specified, X2 =
boost::python::detail::not_specified, X3 =
boost::python::detail::not_specified]'
Rational.cpp:15:   instantiated from here
/usr/include/boost/python/def_visitor.hpp:31: error: no matching
function for
call to
`boost::python::api::object::visit(boost::python::class_Rational,
boost::python::detail::not_specified,
boost::python::detail::not_specified,
boost::python::detail::not_specified) const'
make: *** [Rational.o] Error 1

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


Re: What's so funny? WAS Re: rotor replacement

2005-01-27 Thread Lucas Raab
snip
As long as we are discussing cryptography, what's wrong with m2crypto?
http://sandbox.rulemaker.net/ngps/m2/ 

Why not incorporate it into the standard distribution?
Or, what about Andrew Kuchling's crypto toolkit?
http://www.amk.ca/python/code/crypto.html
snip
Umm, is it just me or did we just discuss the legal issues of that??
--
http://mail.python.org/mailman/listinfo/python-list


Re: exclude binary files from os.walk

2005-01-27 Thread Mark McEahern
The OP wrote:
 Is there an easy way to exclude binary files (I'm working on Windows 
XP) from the file list returned by os.walk()?

Sure, piece of cake:
#!/usr/bin/env python
import os
def textfiles(path):
   include = ('.txt', '.csv',)
   for root, dirs, files in os.walk(path):
   for name in files:
   prefix, ext = os.path.splitext(name)
   if ext.lower() not in include:
   continue
   filename = os.path.join(root, name)
   yield filename
path = os.getcwd()
for name in textfiles(path):
   print name
;-)
// m
--
http://mail.python.org/mailman/listinfo/python-list


redirect of standard output of jython to JTextArea

2005-01-27 Thread Jan Gregor
Hello
 I want to redirect output of jython's functions print and println to 
JTextArea component. Is it possible ?

I tried this (swingConsole.textArea is instance):
In my class
 self.printStream= MyPrintStream(System.out)
System.setOut(self.printStream)

class MyPrintStream (PrintStream):
def println (str):
swingConsole.textArea.append(str)
def print (str):
swingConsole.textArea.append(str)
Output is still directed to standard output.
Thanks for help,
Jan
--
http://mail.python.org/mailman/listinfo/python-list


parsing WSDL

2005-01-27 Thread Alessandro Crugnola
Hi to all.
Is there a way, maybe using 4suite, to read a wsdl file and find for
every method all the input/output params and their type?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python without OO

2005-01-27 Thread Alex Martelli
[EMAIL PROTECTED] wrote:
...
 Some complexity is not needed, and I am sure even in Python
 something could be dropped. But it is difficult to find what can
 be removed. Remember that Saint-Exupery quote? Something
 like a work of art is finished when there is nothing left to remove?

Saint-Éxupery was an engineer (and a pioneer of flight) and so he was
referring to a designer (and no doubt had in mind those planes...), not
to an artist (not his fault if he's better remembered as a novelist;-).

As for what can be removed from Python, one could start at
http://www.python.org/peps/pep-3000.html -- while each of us will find
there some complexity one loves and uses often (be it lambda, buffer,
reload, ...), it's a good start.


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


Re: Python-list Digest, Vol 16, Issue 457

2005-01-27 Thread Eduardo Henriquez A.
On Thu, 27 Jan 2005 14:20:25 +0100 (CET),
[EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 Send Python-list mailing list submissions to
python-list@python.org
 
 To subscribe or unsubscribe via the World Wide Web, visit
http://mail.python.org/mailman/listinfo/python-list
 or, via email, send a message with subject or body 'help' to
[EMAIL PROTECTED]
 
 You can reach the person managing the list at
[EMAIL PROTECTED]
 
 When replying, please edit your Subject line so it is more specific
 than Re: Contents of Python-list digest...
 
 
 Today's Topics:
 
   1. how to pass attribute name via sys.argv (Felix Hebeler)
   2. Re: how to pass attribute name via sys.argv (Wolfram Kraus)
   3. Re: how to pass attribute name via sys.argv (Gilles Lenfant)
   4. Re: Please suggest on the book to follow (Satchidanand Haridas)
   5. Re: redirect of standard output of jython to JTextArea
  (Jan Gregor)
   6. Point of Sale (Andreas Pauley)
   7. Re: Please suggest on the book to follow (Ola Natvig)
   8. a question about boost.python (Li Daobing)
   9. Re: What's so funny? WAS Re: rotor replacement (Lucas Raab)
  10. Re: exclude binary files from os.walk (Mark McEahern)
  11. Re: import hook, overwrite import? (Steve Holden)
 
 
 
 -- Forwarded message --
 From: Felix Hebeler [EMAIL PROTECTED]
 To: python-list@python.org
 Date: Thu, 27 Jan 2005 13:48:28 +0100
 Subject: how to pass attribute name via sys.argv
 Hi all,
 I am doing some Python scripting for a while, but I'm not too deep into
 it yet. So I have a problem I can't solve.
 
 I need to call an object attribute:
 
 value = object.attrName[0]
 
 the problem is, that the attribute name can only be specified at runtime.
 
 So what I have is something like
 
  attrName = sys.argv[1]
  attrName
 'cellsize'
 
 and I need to pass it on so I can call
 
 value = object.cellsize[0]
 
 Can this be done using Python?
 
 Thanks for any hints
 
 Cheers
 Felix
 
 
 
 -- Forwarded message --
 From: Wolfram Kraus [EMAIL PROTECTED]
 To: python-list@python.org
 Date: Thu, 27 Jan 2005 13:53:26 +0100
 Subject: Re: how to pass attribute name via sys.argv
 Felix Hebeler wrote:
  Hi all, I am doing some Python scripting for a while, but I'm not too
  deep into it yet. So I have a problem I can't solve.
 
  I need to call an object attribute:
 
  value = object.attrName[0]
 
  the problem is, that the attribute name can only be specified at
  runtime.
 
  So what I have is something like
 
  attrName = sys.argv[1] attrName
  'cellsize'
 
  and I need to pass it on so I can call
 
  value = object.cellsize[0]
 Use getattr:
 value = getattr(object, attrName)[0]
 
 
  Can this be done using Python?
 
  Thanks for any hints
 
  Cheers Felix
 
 HTH,
 Wolfram
 
 
 
 -- Forwarded message --
 From: Gilles Lenfant [EMAIL PROTECTED]
 To: python-list@python.org
 Date: Thu, 27 Jan 2005 13:57:02 +0100
 Subject: Re: how to pass attribute name via sys.argv
 Felix Hebeler a écrit :
  Hi all,
  I am doing some Python scripting for a while, but I'm not too deep into
  it yet. So I have a problem I can't solve.
 
  I need to call an object attribute:
 
  value = object.attrName[0]
 
  the problem is, that the attribute name can only be specified at runtime.
 
  So what I have is something like
 
attrName = sys.argv[1]
attrName
  'cellsize'
 
  and I need to pass it on so I can call
 
  value = object.cellsize[0]
 
 
  Can this be done using Python?
 
  Thanks for any hints
 
  Cheers
  Felix
 
 The builtin setattr is your friend.
 object is now a reserved (builtin) name, use objekt instead.
 
 class Foo(object):
 pass
 objekt = Foo()
 attrName = sys.argv[1]
 values = ['foo', 'bar', 'whatever']
 setattr(objekt, attrName, values)
 
 HTH
 
 --
 Gilles
 
 
 
 -- Forwarded message --
 From: Satchidanand Haridas [EMAIL PROTECTED]
 To: santanu [EMAIL PROTECTED]
 Date: Thu, 27 Jan 2005 18:34:17 +0530
 Subject: Re: Please suggest on the book to follow
 Hi,
 
 Probably the best resources for learning Python are available online.
 Here are a few sites that you might find helpful:
 
 1. http://byteofpython.info/
 
 2. http://www.diveintopython.org/   -- Writted by Mark Pilgrim, covers
 many advanced material. The site says /Dive into Python/  is a Python
 book for experienced programmers.
 
 3. http://gnosis.cx/TPiP/  -- Site for Text Processing in Python, a
 book by David mertz. You will find many other very good Python related
 material on his website.
 
 regards,
 Satchit
 
 
 Satchidanand Haridas (sharidas at zeomega dot com)
 
 ZeOmega (www.zeomega.com)
 Open  Minds' Open Solutions
 
 #20,Rajalakshmi Plaza,
 South End Road,
 Basavanagudi,
 Bangalore-560 004, India
 
 santanu wrote:
 
 Hi all,
 
 I know a little python (not the OOP part) learnt by studying the online
 
 tutorial. Now I would like to learn it more thoroughly.
 
 I have access to 'Programming Python' which I liked (on flipping
 through the
 

Re: python without OO

2005-01-27 Thread Alex Martelli
PA [EMAIL PROTECTED] wrote:

 Yes. But even with the best tool and the best intents, projects 
 still fail. In fact, most IT projects are considered failures:
 
 http://www.economist.com/business/PrinterFriendly.cfm?Story_ID=3423238

The main thesis of the article you quote (although it acknowledges that
other think differently) is that better tools (including iterative, NOT
waterfall, development; and, agile programming approaches, more
generally) are the way to mitigate that horrid track record.


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


Re: What's so funny? WAS Re: rotor replacement

2005-01-27 Thread Skip Montanaro
 Finally, what if, saints be preserved, your whizbang new module is

phr It is not a whizbang module.  It is a stripped-down, basic
phr implementation of a well-accepted set of standards that are being
phr used in thousands of other applications in other languages.

Then there should be a library already out there already.  All you should
need to do is wrap it (manually, with SWIG, whatever).

 included in the core distribution and it's just not as popular as was
 first thought?

phr There is demand for it.  Look at how this thread started: some
phr crypto user noticed that rotor was gone and wanted to know what to
phr do instead.

Yes, and putting rotor back would be the wrong thing to do.

phr The issue of whether there's enough desire for a crypto module to
phr warrant including one in the stdlib was decided a long time ago.
phr The proof of that somebody decided to accept the rotor module into
phr the distro.

No, rotor was added in Python's early days (July 1992).  Times have changed.

As long as we are discussing cryptography, what's wrong with m2crypto?

http://sandbox.rulemaker.net/ngps/m2/ 

Why not incorporate it into the standard distribution?

Or, what about Andrew Kuchling's crypto toolkit?

http://www.amk.ca/python/code/crypto.html

I believe both have been around awhile.  If crypto-in-the-core is really
what's needed why not see if one of them is ready to go?  

phr The rotor module is gone (and good riddance).  That's how this
phr thread started, remember?  It shows that bogus modules can be
phr removed.

Yeah, but it was there for over 10 years.

phr Have you ever used a crypto library in a serious way?  

Nope, never directly.  Don't make this about me.  I'm interested in the
Python development process and how you'd like to turn it on its head.

 When it's the category king and there is substantial community
 support for inclusion,

phr It's already the category king, because there are precisely zero
phr other entrants in the category.  

See my above references.  Note, I don't use crypto at all, yet I was aware
of both of these (no Googling required).  My guess would be they are
substantially more mature than your proposed module.

phr I read those as saying that no crypto module will be considered for
phr inclusion whether or not it's the category king, because any such
phr module might conflict with crypto regulations in some countries.

That may be a problem, sure.  I'm not sure how the discussion here changes
that.  That's just life as we know it.

phr So tell me again what to do after writing and releasing a C module.
phr There's just no reason to write one, if the module can't go into
phr the stdlib.  

Why in the heck is inclusion in the standard library a requirement for you
to write this thing?  If it's useful to you, write it and get on with your
life.

 Python is popular in part because of its fairly conservative
 development strategy.  That goes for the libraries as well as the
 language itself.

phr Tell me again how rotor got into the distribution.

Okay.  It was 1992.  Bill Clinton had recently been elected president.  It
was pretty much pre-WWW as we know it.  Definitely pre-comp.lang.python and
pre-Google (heck, pre-Yahoo, pre-Win98 and pre-Mac OSX as well).  Pre-string
methods.  Pre-triple-quoted strings.  Pre-spammers.  Pre-DSL.  Pre-lots of
stuff.  There was an Emacs python-mode and winks, both thanks to Tim.
People opined about Python's performance, just as they do today.  Python's
version number was around 0.9.4, definitel  1.0.  Guido was the only person
with direct repository access.  Including something in the distribution was
probably the only convenient way to make new modules available.  If nothing
else, the rotor module (along with anything else included in the
distribution back then) may have been a good exercise in and demonstration
of writing extension modules, so it probably served a useful non-crypto
purpose.  Python's user community was probably a few hundred people.  Guido
likely had no thoughts of world domination with the little language that
could.  Times have changed.  You seem think there was a PEP process and
distutils and Wikis.  I suspect some of the algorithms one might include in
a robust crypto toolkit today weren't even invented in 1992.

So throw away the rotor crutch and put your money where your mouth is.

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


Re: python without OO

2005-01-27 Thread beliavsky
[EMAIL PROTECTED] wrote:

  There is not much than can be done at the Python level. But I
would
  see with interest a Python spinoff geared towards simplicity.

 I think this would be useless because advanced concepts exist for
 a reason. A simplified spin-off would aquire advanced concepts
 over time and would just become a clone of Python.

 And then we will need another simplified spinoff ;)
 There is always a fight between simplificity and complexity.
 Some complexity is not needed, and I am sure even in Python
 something could be dropped. But it is difficult to find what can
 be removed. Remember that Saint-Exupery quote? Something
 like a work of art is finished when there is nothing left to
remove?
 M.S.

Perfection is achieved, not when there is nothing more to add, but
when there is nothing left to take away.

I know this quote because it is the motto of the F programming language
http://www.fortran.com/F/ , a simplified spinoff of Fortran 95.

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


Re: Point of Sale

2005-01-27 Thread Peter Hansen
Andreas Pauley wrote:
My company has given me a rather cool project:
I have to provide them with an open-source python-based point-of-sale / 
cash register system that can integrate with their existing ERP backend.
Do you have information about the interface to the ERP back end?
It could be anything just about anything...
The project will include development to ensure that the features they 
require are included in the open-source POS system.
I read that as will include automated acceptance tests, but perhaps
you meant something else?
Can you recommend anything that I can use?
There's a good chance you'll need to use PySerial, if the
cash registers are connected via RS-232, but beyond that
there's not much to say without more info.  I believe I
heard somebody talking about a Python POS system before
in this newsgroup, but I'm not sure: check the archives?
-Peter
--
http://mail.python.org/mailman/listinfo/python-list


how to pass attribute name via sys.argv

2005-01-27 Thread Felix Hebeler
Hi all,
I am doing some Python scripting for a while, but I'm not too deep into 
it yet. So I have a problem I can't solve.

I need to call an object attribute:
value = object.attrName[0]
the problem is, that the attribute name can only be specified at runtime.
So what I have is something like
 attrName = sys.argv[1]
 attrName
'cellsize'
and I need to pass it on so I can call
value = object.cellsize[0]
Can this be done using Python?
Thanks for any hints
Cheers
Felix
--
http://mail.python.org/mailman/listinfo/python-list


RE: Point of Sale

2005-01-27 Thread Gabriel Cosentino de Barros
Title: RE: Point of Sale





Hi, i'm curently doing a POS. But mine is a small scale and stand alone.


Are you planing on developing in house and then opening? develop at open or simple use open source tools and keep it closed?

I'm going to post my progress at source forge next week when i finish proof reading the design docs.


i'm curently focused in the HCI layer (primarily using only plain tk) and haven't gave much tought to the 'external' stuff, like integrating wire money cards and such

Gabriel


-Original Message-
From: Andreas Pauley [mailto:[EMAIL PROTECTED]]
Sent: quinta-feira, 27 de janeiro de 2005 11:08
To: python-list@python.org
Subject: Point of Sale



Hi,


My company has given me a rather cool project:
I have to provide them with an open-source python-based point-of-sale / 
cash register system that can integrate with their existing ERP backend.


The project will include development to ensure that the features they 
require are included in the open-source POS system.


Can you recommend anything that I can use?


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



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

Re: Please suggest on the book to follow

2005-01-27 Thread Cameron Laird
In article [EMAIL PROTECTED],
Fuzzyman [EMAIL PROTECTED] wrote:
We've only just had Python 2.4. Based on previous experience that means
it will be about 18 months before python 2.5.

I learned to program from 'Programming Python'. Particularly the stuff
on Tkinter is very helpful. I don't think you'll have much to
'unlearn', although obviously there is stuff it doesn't cover (like new
style classes).
.
.
.
Python is considerate of programmers.  While experience with commercial
products might lead to an expectation that 2.0 and 2.4 differ greatly,
in fact it's quite feasible to learn from books aimed at 1.5 or even
before, and have your results work perfectly well under 2.4.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Point of Sale

2005-01-27 Thread Cameron Laird
In article [EMAIL PROTECTED],
Andreas Pauley  [EMAIL PROTECTED] wrote:
Hi,

My company has given me a rather cool project:
I have to provide them with an open-source python-based point-of-sale / 
cash register system that can integrate with their existing ERP backend.

The project will include development to ensure that the features they 
require are included in the open-source POS system.

Can you recommend anything that I can use?
.
.
.
Research.  I think you're expecting an answer of the I used
open-source openPOS project, and it worked great for me, but
I suspect all that is premature.  What does POS mean to you?
What are your platform constraints?  Does your company have
expectations about how POS will work?  What access (CORBA?
RMI?  SOAP? ...) is there to the ERP?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Please suggest on the book to follow

2005-01-27 Thread Fuzzyman
We've only just had Python 2.4. Based on previous experience that means
it will be about 18 months before python 2.5.

I learned to program from 'Programming Python'. Particularly the stuff
on Tkinter is very helpful. I don't think you'll have much to
'unlearn', although obviously there is stuff it doesn't cover (like new
style classes).
Regards,


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

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


Re: how to comment out a block of code

2005-01-27 Thread Duncan Booth
Xah Lee wrote:

 
 is there a syntax to comment out a block of code? i.e. like html's !--
 comment --
 or perhaps put a marker so that all lines from there on are ignored?
 thanks.
 

The simplest way is to select the block of code in your editor and use the 
'comment-region' command. If this doesn't work, upgrade your editor.

Most editors have a command to do this although obviously the name will 
vary slightly: Idle calls it 'Comment Out Region', SciTe calls it 'Block 
Comment', emacs calls it 'comment-region'.
-- 
http://mail.python.org/mailman/listinfo/python-list


Please suggest on the book to follow

2005-01-27 Thread santanu
Hi all,

I know a little python (not the OOP part) learnt by studying the online

tutorial. Now I would like to learn it more thoroughly.

I have access to 'Programming Python' which I liked (on flipping
through the
pages), but the problem is it deals only with version 2.0 of Phython.

So, I would be glad if you could suggest me whether it would be really
a good
idea to learn from this book. In other words, will I have to unlearn
too much
after I complete this book (by the time I am done with this book, I
believe
we will be having Python 2.6 or so).

Please suggest.

Regards,
Santanu

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


Re: python without OO

2005-01-27 Thread michele . simionato
 Perfection is achieved, not when there is nothing more to add, but
 when there is nothing left to take away.

Thanks, that was it! ;)

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


Freeze with wxpython on python 2.3 or python 2.4 on Win32 with Thread

2005-01-27 Thread Tsubasa[Hokage]
Hello i have a problem with thread and wxpython on WIN32.

With this script :

I would like to SetValue to my gauge widget in a thread.
I can GetValue without a hitch but if I SetValue it freezing.

Try following script and go to AF-Tools Menu and click install

Normally in the install thread, I wrote yo in the console and I
SetValue of the gauge passed to the thread.

from wxPython.wx import *
from wxPython.wizard import *
from os import *
#import  os
#import win32wnet, win32netcon
#import wmi
#import win32api
#import _winreg
import time
#import win32com,win32com.client
import sys
import shutil
import dircache
import struct, socket
from optparse import OptionParser

#import thread
import threading
#import Queue

__auteur__=FLFRSPA


def map_drive(local, remote, username, password):
###self.map_drive(Z:,
\\\L00438\c$,rlocalhost\administrator,)###
return win32wnet.WNetAddConnection2(win32netcon.RESOURCETYPE_DISK,local,
remote, None,username, password,0)

class InstallThread(threading.Thread):
###La classe recoit
login,password,workstation,checkboxdomaine,domaine,self.log,self.g1,package
 def 
__init__(self,login,password,workstation,checkboxdomaine,domaine,log,gauge,package):
 threading.Thread.__init__(self)
 self.result = None
 self.i=0
 self.login=login
 self.password=password
 self.workstation=workstation
 self.package=package
 self.checkboxdomaine=checkboxdomaine
 self.domaine=domaine
 self.log=log
 self.gauge=gauge

 def run(self):
self.result=1
print yo
self.gauge.SetValue(10)
self.result=1
return

class main_PyXrunAS(wx.Frame):
def __init__(self, *args, **kwds):
kwds[style] = wx.DEFAULT_FRAME_STYLE
wx.Frame.__init__(self, *args, **kwds)
sizer = wxBoxSizer(wxVERTICAL)
self.SetSizer(sizer)
menuBar = wx.MenuBar()
# 1st menu from left
menu1 = wx.Menu()
#menu1.Append(101, Options, Options de la LoFBOX)
menu1.Append(102, Quitter, Quitter)
#self.Bind(wx.EVT_MENU, self.quit, id=102)
menu1.AppendSeparator()
menuBar.Append(menu1, Fichier)
# 2st menu from left
menu2 = wx.Menu()
menu2.Append(201, Test Connection, Effectue un test de
connection sur la machine distante)
#self.Bind(wx.EVT_MENU, self.aide_dialog, id=201)
self.Bind(wx.EVT_MENU, self.query_freespace, id=201)
menu2.Append(202, Reboot Distant, Effectue le reboot d'une
machine)
self.Bind(wx.EVT_MENU, self.query_reboot, id=202)
#self.Bind(wx.EVT_MENU, self.Apropos, id=202)
menu2.Append(202, Wake On Lan, Effectue le démarrage
distant d'une machine)
menu2.Append(203, Install, Install le package
selectionné)
self.Bind(wx.EVT_MENU, self.install_thread, id=203)
menu2.AppendSeparator()
menuBar.Append(menu2, AF-Tools)
self.SetMenuBar(menuBar)
###Logo Titre
self.remlogo = wx.StaticBitmap(self, -1,
wx.Bitmap(data/remote_logo.jpg, wx.BITMAP_TYPE_ANY),pos=(5,5))
sizer.AddWindow(self.remlogo, 0, wxALIGN_CENTRE|wxALL, 5)
sizer.AddWindow(wxStaticLine(self, -1), 0, wxEXPAND|wxALL, 5)
###Creation de la liste des packages
self.a=dircache.listdir('Package/')
self.a=self.a[:] # Copy the return value so we can change 'a'
t1=wx.Choice(self, -1, (60, 60), choices = self.a)
self.tc1 = t1
self.Bind(wx.EVT_CHOICE, self.Evtpackage, t1)
t1.Bind(wx.EVT_TEXT, self.Evtpackage)
l1 = wx.StaticText(self, -1, Package: ,pos=(5,60))
l1.SetBackgroundColour(white)
###Jauge d'evolution
self.g1 = wx.Gauge(self, -1, 50, (220, 210), (190, 25))
self.g1.SetBezelFace(3)
self.g1.SetShadowWidth(3)
self.g1.SetBackgroundColour(White)
###Label progression
label_pro = wx.StaticText(self, -1, Progression:
,pos=(220,190))
label_pro.SetBackgroundColour(white)
###Multiline log
label_log = wx.StaticText(self, -1, Log: ,pos=(220,60))
label_log.SetBackgroundColour(white)
self.log = wx.TextCtrl(self, -1, , size=(250,
100),pos=(220,80),
style = wx.TE_MULTILINE
#| wx.TE_RICH
| wx.TE_RICH2
)
###Setmachine
self.workstation = wx.TextCtrl(self, -1, , size=(105,
-1),pos=(60,100))
label_workstation = wx.StaticText(self, -1, Poste:
,pos=(6,100))
label_workstation.SetBackgroundColour(white)
#self.workstation.SetInsertionPoint(0)
self.workstation.Bind(wx.EVT_TEXT, self.EvtChar)
###Bouton pour tester la connection
#self.workstation_connect = wx.Button(self, -1, Test
Connection, (210,55))
#self.workstation_connect.Disable()
#self.label_freespace = wx.StaticText(self, -1,
,pos=(270,102))

Re: Tao Scripting Language 0.8.5 beta released!

2005-01-27 Thread Claudio Grondi
Dear Limin,

Tao Script with its 300 KByte of code is so small,
that one just must love it forgiving all its baby
troubles.

After changes (see below) to the code in taoModule.cpp
necessary because my compiler claimed repeated definition
of 'ref' e.g. in the section:
if(TaoReference *ref2a=inNameSpace-findDataShared(name) ){
 myData[name]=ref2a;
 outNameSpace-nsData[name]=ref2a;
}else{
 TaoShareRefer*ref2b=new TaoShareRefer();
 myData[name]=ref2b;
 outNameSpace-nsDataShared[name]=ref2b;
 outNameSpace-nsData[name]=ref2b;
}
I was able to compile the code with
Microsoft Visual C++ .NET 2003 on W2K
(create an empty .NET project, add all source
code files, compile and be happy :-)

Trying the examples provided on the
homesite of Tao Script which run ok as they
are, I found, that print(### \n) failes due to
the way the Lexer works beeing not able to
proper handle string literals.
One just can't probably use any of #' // /*
in strings because the lexer strips the
comments before it analyses the source
to handle content of the string literals.

Hope this comment helps you to continue
the well done work on it.
I had fun with it because of its size, so
from my point of view please try to
keep the project as small as possible, so
that it remains easy to check out the entire
code.
Maybe it is even a good idea to keep
the problem with the strings as a feature
in order to keep the Lexer as simple as
possible?

Best regards

Claudio

Limin Fu [EMAIL PROTECTED] schrieb im Newsbeitrag
news:[EMAIL PROTECTED]
 Dear all,

 I am glad to announce in this mailing list that the lastest version
 of a new scripting language has come out.

 Welcome to try it out.

 Comments are welcome.

 Suggestions are appreciated.

 ===
 Here are some details:
 ===

 Design Goals:
 1. Simple and efficient.
 2. Integrate nice features of other languages whenever possible.

 Implementation language: C++ with STL.

 Designer: Fu Limin
 Email: fu [dot] limin [dot] tao [at] gmail.com

 Key features have been supported:

 1. Dynamic-typing variables, supporting complex data structures
such as array/list, hash/dictionary and matrix etc.

 2. Object-oriented programming ( multi-inheritance not supported
yet ).

 3. Basic string regular expression matching.

 4. Automatic garbage collection capable of collecting cyclically
referenced objects.

 5. Numeric data types: complex number and matrix, and their basic
operations.

 6. Convenient namespacing and dynamic creation of subroutines and
classes.

 7. Dynamic loading of C/C++ modules ( not complete, but enough for
playing with it ^_^ ).

 8. An embedded tiny XML parser.

 ToBeDone:
 More string operations, multi-inheritance of classes, improvements
 on C/C++ module loading, more on regular expression matching and
 possible optimizations etc.

 Documentation:

 http://taoscript.sourceforge.net/brief_tao.php

 Sample scripts:

 http://taoscript.sourceforge.net/sample.php

 Download:
 http://taoscript.sourceforge.net/downloads.php

 Best regards,

 Limin

 --
 Homepage for Tao Language:
 http://taoscript.sourceforge.net

 Tao Language project at sourceforge.net:
 http://sourceforge.net/projects/taoscript


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


Re: Please suggest on the book to follow

2005-01-27 Thread santanu
Thanks for the reply.
From your suggestions, I guess I would have no problems
learning from Programming Python. I didn't like Core Python
Programming and such books. I like to read cover to cover
and the chapters on data structures and such elementary things
put me to sleep. I already have an idea of those things.
I have a fair knowledge of C and some Perl.

From what you and Fyzzyman said, I guess when I am done with
Programming Python, graduating to the latest features would
be quite easy. Isn't it?

Regards,
Santanu

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


python IIS cgi working but loading extremely slow

2005-01-27 Thread smartin
python IIS cgi loading extremely slow

I recently uninstalled python 1.5.2 and installed python 2.3 on a
Windows 2000 server running IIS 5.0. The issue is that when submitting
a cgi request to a python script, it takes about 1 minute to process
the python (2.3 code) and load the page on this particular server.
Running a simple print hi script takes at least a minute. I have
tested the uninstall and reinstall on a test Windows 2000 server and
did not have any performance issues. I have tried the uninstall and
reinstall twice, including removing all registry entries of the
previous 1.5.2 python install.
I have reverted back to python 1.52 and my 1.5.2 code and it runs
slower than it did before the uninstall but not as slow as the 2.3.4
code.

Has anyone every experienced this issue with speed?

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


Re: Point of Sale

2005-01-27 Thread Andreas Pauley

On Thu, 27 Jan 2005, Cameron Laird wrote:
In article [EMAIL PROTECTED],
Andreas Pauley  [EMAIL PROTECTED] wrote:
Hi,
My company has given me a rather cool project:
I have to provide them with an open-source python-based point-of-sale /
cash register system that can integrate with their existing ERP backend.
The project will include development to ensure that the features they
require are included in the open-source POS system.
Can you recommend anything that I can use?
.
.
.
Research.  I think you're expecting an answer of the I used
open-source openPOS project, and it worked great for me, but
I suspect all that is premature.  What does POS mean to you?
What are your platform constraints?  Does your company have
expectations about how POS will work?  What access (CORBA?
RMI?  SOAP? ...) is there to the ERP?
Very well, I guess a little more detail would help.
Platform: Cross-platform, although deployment would typically be done on 
Linux.
My company typically expects that each POS station will have it's own 
database with all sales items and other info on it.
The maintenance of sales items, prices etc. should however be done at a 
central location, and then be replicated to each POS station.
The reason for this is that we will typically deploy such a system in 
deep-dark-africa where stable network connectivity cannot be taken for 
granted.
If the network is down each POS station should still be able to function 
without interruption.

These requirements is probably not available in a typical POS system, but 
I'm hoping for a general POS front-end for which I can develop a custom 
backend to plug in.
At the moment the current POS system uses an inhouse developed message 
queing system to communicate with the ERP/Retail backend. A POS station 
submits each transaction (and other relevant messages) to a local queue, 
from where it is sent to the back-end system. If the network is down the 
messages just stay queued until the network is back up again.
The central backend system uses the same queing technique to submit price 
updates etc. to each POS station.

I'm not sure what protocol will be used to communicate with the backend.
I might have SOAP available.
The backend is written using Appservers from Progress Software Corporation 
(a proprietary database company).
The Progress developers would probably be willing to help, so I'm 
relatively positive that we'll be able to figure out a solution there.

The user interface for the current system is character-based.
For the new POS we should ideally be able to use different user-interfaces 
that all access the same business logic, although I would primarily focus 
on a non-mouse driven GUI interface.

I hope the above answers your question, if not feel free to ask again.
Regards,
Andreas Pauley
--
http://mail.python.org/mailman/listinfo/python-list


Re: Point of Sale

2005-01-27 Thread Andreas Pauley

On Thu, 27 Jan 2005, Peter Hansen wrote:
Andreas Pauley wrote:
My company has given me a rather cool project:
I have to provide them with an open-source python-based point-of-sale / 
cash register system that can integrate with their existing ERP backend.
Do you have information about the interface to the ERP back end?
It could be anything just about anything...
See my reply to Cameron.

The project will include development to ensure that the features they 
require are included in the open-source POS system.
I read that as will include automated acceptance tests, but perhaps
you meant something else?
Actually I just mean that I'm not looking for a 100% feature-fit, if I get 
a 70% fit I'll jump in and develop the other 30%.


Can you recommend anything that I can use?
There's a good chance you'll need to use PySerial, if the
cash registers are connected via RS-232, but beyond that
there's not much to say without more info.  I believe I
heard somebody talking about a Python POS system before
in this newsgroup, but I'm not sure: check the archives?
Thanks, I'll keep PySerial in mind.
Up to now I've googled a bit, and looked at Sourceforge projects.
(I also did a search on the 51664 messages in my local Python-list folder)
At the moment I found a POS in GNU Enterprise, a project named custom 
and another project named Auto Auction.
I'm not sure what the features of each system are, I'm busy checking them 
out one by one.
Then there's also 3 or 4 Python systems which haven't released any files 
yet.
Currently I'm evaluating GNU Enterprise.

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


Re: Tao Scripting Language 0.8.5 beta released!

2005-01-27 Thread Limin Fu
Dear Claudio,

Thank you for your kind testing, suggestions and encourages.
I'm glad that you like it. 

For that problem in the Lexer, it can be corrected without increasing
the size. I will do it soon.

Best regards,

Limin


On Thu, 27 Jan 2005 15:32:13 -, Claudio Grondi
[EMAIL PROTECTED] wrote:
 Dear Limin,
 
 Tao Script with its 300 KByte of code is so small,
 that one just must love it forgiving all its baby
 troubles.
 
 After changes (see below) to the code in taoModule.cpp
 necessary because my compiler claimed repeated definition
 of 'ref' e.g. in the section:
 if(TaoReference *ref2a=inNameSpace-findDataShared(name) ){
  myData[name]=ref2a;
  outNameSpace-nsData[name]=ref2a;
 }else{
  TaoShareRefer*ref2b=new TaoShareRefer();
  myData[name]=ref2b;
  outNameSpace-nsDataShared[name]=ref2b;
  outNameSpace-nsData[name]=ref2b;
 }
 I was able to compile the code with
 Microsoft Visual C++ .NET 2003 on W2K
 (create an empty .NET project, add all source
 code files, compile and be happy :-)
 
 Trying the examples provided on the
 homesite of Tao Script which run ok as they
 are, I found, that print(### \n) failes due to
 the way the Lexer works beeing not able to
 proper handle string literals.
 One just can't probably use any of #' // /*
 in strings because the lexer strips the
 comments before it analyses the source
 to handle content of the string literals.
 
 Hope this comment helps you to continue
 the well done work on it.
 I had fun with it because of its size, so
 from my point of view please try to
 keep the project as small as possible, so
 that it remains easy to check out the entire
 code.
 Maybe it is even a good idea to keep
 the problem with the strings as a feature
 in order to keep the Lexer as simple as
 possible?
 
 Best regards
 
 Claudio
 
 Limin Fu [EMAIL PROTECTED] schrieb im Newsbeitrag
 news:[EMAIL PROTECTED]
  Dear all,
 
  I am glad to announce in this mailing list that the lastest version
  of a new scripting language has come out.
 
  Welcome to try it out.
 
  Comments are welcome.
 
  Suggestions are appreciated.
 
  ===
  Here are some details:
  ===
 
  Design Goals:
  1. Simple and efficient.
  2. Integrate nice features of other languages whenever possible.
 
  Implementation language: C++ with STL.
 
  Designer: Fu Limin
  Email: fu [dot] limin [dot] tao [at] gmail.com
 
  Key features have been supported:
 
  1. Dynamic-typing variables, supporting complex data structures
 such as array/list, hash/dictionary and matrix etc.
 
  2. Object-oriented programming ( multi-inheritance not supported
 yet ).
 
  3. Basic string regular expression matching.
 
  4. Automatic garbage collection capable of collecting cyclically
 referenced objects.
 
  5. Numeric data types: complex number and matrix, and their basic
 operations.
 
  6. Convenient namespacing and dynamic creation of subroutines and
 classes.
 
  7. Dynamic loading of C/C++ modules ( not complete, but enough for
 playing with it ^_^ ).
 
  8. An embedded tiny XML parser.
 
  ToBeDone:
  More string operations, multi-inheritance of classes, improvements
  on C/C++ module loading, more on regular expression matching and
  possible optimizations etc.
 
  Documentation:
 
  http://taoscript.sourceforge.net/brief_tao.php
 
  Sample scripts:
 
  http://taoscript.sourceforge.net/sample.php
 
  Download:
  http://taoscript.sourceforge.net/downloads.php
 
  Best regards,
 
  Limin
 
  --
  Homepage for Tao Language:
  http://taoscript.sourceforge.net
 
  Tao Language project at sourceforge.net:
  http://sourceforge.net/projects/taoscript
 
 --
 http://mail.python.org/mailman/listinfo/python-list
 


-- 
Homepage for Tao Language:
http://taoscript.sourceforge.net

Tao Language project at sourceforge.net:
http://sourceforge.net/projects/taoscript
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: exclude binary files from os.walk

2005-01-27 Thread Alex Martelli
rbt [EMAIL PROTECTED] wrote:

 Grant Edwards wrote:
  On 2005-01-26, rbt [EMAIL PROTECTED] wrote:
  
 Is there an easy way to exclude binary files (I'm working on
 Windows XP) from the file list returned by os.walk()?
  
  Sure, assuming you can provide a rigorous definition of 'binary
  files'.  :)
 
 non-ascii

The only way to tell for sure if a file contains only ASCII characters
is to read the whole file and check.  You _are_, however, using a very
strange definition of binary.  A file of text in German, French or
Italian, for example, is likely to be one you'll define as binary --
just as soon as it contains a vowel with accent or diaeresis, for
example.  On the other hand, you want to consider non-binary a file
chock full of hardly-ever-used control characters, just because the
American Standard Code for Information Interchange happened to
standardize them once upon a time?  Most people's intuitive sense of
what binary means would rebel against both of these choices, I think;
calling a file binary because its contents are, say, the string
'El perro de aguas español.\n' (the n-with-tilde in español
disqualifies it from being ASCII), while another whose contents are 32
bytes all made up of 8 zero bits each (ASCII 'NUL' characters) is to be
considered non-binary.

In any case, since you need to open and read all the files to check them
for being binary, either by your definition or whatever heuristics you
might prefer, you would really not ``excluded them from os.walk'', but
rather filter os.walk's results by these criteria.


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


Re: exclude binary files from os.walk

2005-01-27 Thread Alex Martelli
Craig Ringer [EMAIL PROTECTED] wrote:

 That's not really safe when dealing with utf-8 files though, and IIRC
 with UCS2 or UCS4 as well. The Unicode BOM its self might (I'm not sure)
 qualify as ASCII.

Nope, both bytes in the BOM have the high-order bit set -- they're 0xFF
and 0xFE -- so they definitely don't qualify as ASCII.


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


leo editor

2005-01-27 Thread Gabriel Cosentino de Barros
Title: leo editor





A co-worker was trying to convince me that Leo[1] is the better editor of all since it outline the code and let you easily document algoritms and logic.

He was writting php code with it. I use jEdit or vi to write my python and my php


Then after a day of debates I ended up convincing him that abstracting every algorith and complex logic into a separate class and using the doc inside the class the python way was exactly the same thing that Leo does, if not better hence you don't need an IDE for that.

But then, I realised that maybe it's just that we don't get it yet. So, the question i drop here is if anyone uses or is forced to use Leo for bigger projects, does it help or get in the way? Does the project management capabilities pay off the tangling/untangling hassle? Does it make it easier to work if the group is bigger?

Thanks!
Gabriel



[1] http://webpages.charter.net/edreamleo/front.html




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

Transparent (redirecting) proxy with BaseHTTPServer

2005-01-27 Thread paul koelle
Hi list,
My ultimate goal is to have a small HTTP proxy which is able to show a 
message specific to clients name/ip/status then handle the original 
request normally either by redirecting the client, or acting as a proxy.

I started with a modified[1] version of TinyHTTPProxy postet by Suzuki 
Hisao somewhere in 2003 to this list and tried to extend it to my needs. 
It works quite well if I configure my client to use it, but using 
iptables REDIRECT feature to point the clients transparently to the 
proxy caused some issues.

Precisely, the self.path member variable of baseHTTPRequestHandler is 
missing the command and the host (i.e www.python.org) part of the 
request line for REDIRECTed connections:

without iptables REDIRECT:
self.path - GET http://www.python.org/ftp/python/contrib/ HTTP/1.1
with REDIRECT:
self.path - GET /ftp/python/contrib/ HTTP/1.1
I asked about this on the squid mailing list and was told this is normal 
and I have to reconstuct the request line from the real destination IP, 
the URL-path and the Host header (if any). If the Host header is sent 
it's an (unsafe) nobrainer, but I cannot for the life of me figure out 
where to get the real destination IP. Any ideas?

thanks
 Paul
[1] HTTP Debugging Proxy
 Modified by Xavier Defrang (http://defrang.com/)
--
http://mail.python.org/mailman/listinfo/python-list


[ANN] Movable Python, linky and Techie Blog

2005-01-27 Thread fuzzyman
Minor news first :

'linky' a local link checker is available.
http://www.voidspace.org.uk/python/programs.shtml#linky

linky will check your website for dead links (within the website) as
well as comparing it to the website on your filesystem, to check for
case errors that might not be picked up if you test your website on
windows. It can also report files that don't appear to be linked to -
for finding  redundant images etc.

linky uses BeautifulSoup to do the hard work.


The Voidspace Techie Blog has moved. My (mainly python related blog)
now lives at :
http://www.voidspace.org.uk/python/weblog/index.shtml
It is created using firedrop - the excellent blog tool by Hans Nowak

MOVABLE PYTHON
http://www.voidspace.org.uk/python/movpy
http://sourceforge.net/projects/movpy

Version 0.4.5 is now available, hurrah.

There are now prebuilt distributions for Python 2.2, 2.3, *and* 2.4.

This is a bugifx/update release. The distributions it produces are very
*similar* to version 0.4.4 distributions, but there are a couple of
issues resolved. See
http://www.voidspace.org.uk/python/movpy/changelog.html for details.

*Most* of the changes relate to the PyDistFrreeze.py in the 'source'
package. This is the code that creates the frozen distributions. There
have been several simplifications and improvements. Again, see the
CHANGELOG for details.


Version 0.5.0

Bruno Thoorens has provided me with the code for the GUI for
PyDistFreeze.py When I have integrated it with PyDistFreeze.py it will
form the 0.5.0 release. This should be in the next couple of weeks time
permitting. The GUI is *excellent* :-)


Movable Python is a Python runtime that can run scripts without the
need for Python to be installed. With the inclusion of wxPython and SPE
editor it is a portable (movable) development environment. Also useful
for testing scripts with several different python versions. The source
version will build frozen environments (using py2exe - so Windoze only
currently), this can include whichever extension modules/packages you
choose.
Regards,

Michael Foord
http://www.voidspace.org.uk/python/index.shtml

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


Re: Help With Python

2005-01-27 Thread Nick Craig-Wood
Steven Bethard [EMAIL PROTECTED] wrote:
  Nick Vargish wrote:
  # this is one viking making one order repeated 511 times. if you want
  # 511 vikings making seperate orders, you'll have to write a loop.
 
  No need to write a loop:
 
  py class Viking(object):
  ... def order(self):
  ... return 'Spam'
  ...
  py v = Viking()
  py orders = [v.order()] * 7
  py ', '.join(orders)
  'Spam, Spam, Spam, Spam, Spam, Spam, Spam'
  py orders = [Viking().order()] * 7
  py ', '.join(orders)
  'Spam, Spam, Spam, Spam, Spam, Spam, Spam'

Thats still one Viking making 7 orders surely?

Eg

 vikings = [Viking()] * 7
 vikings[0] is vikings[1]
True

whereas

 vikings = [Viking() for _ in range(7)]
 vikings[0] is vikings[1]
False

So you want this...

 orders = [ Viking().order() for _ in range(7) ]

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


Re: Inherting from object. Or not.

2005-01-27 Thread Nick Craig-Wood
Nick Coghlan [EMAIL PROTECTED] wrote:
  Exactly. My advice is to use new-style classes unless you have a
  reason not to (if you're inheriting from a builtin type, then there
  is no need to inherit from object as well - the builtin types
  already have the correct basic type).

Except for Exception!

Exception and anything that inherits from it is an old style class.

I discovered the other day that you can't throw a new style class as
an exception at all, eg

 class MyException(object): pass
... 
 raise MyException
Traceback (most recent call last):
  File stdin, line 1, in ?
TypeError: exceptions must be classes, instances, or strings (deprecated), not 
type
 

(not a terribly helpful message - took me a while to work it out!)

wheras old style works fine...

 class MyOldException: pass
... 
 raise MyOldException
Traceback (most recent call last):
  File stdin, line 1, in ?
__main__.MyOldException: __main__.MyOldException instance at 0xb7df4cac
 

After that I recalled a thread on python-dev about it

  http://mail.python.org/pipermail/python-dev/2004-August/046812.html

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


Re: XOR on string

2005-01-27 Thread Nick Craig-Wood
Peter Hansen [EMAIL PROTECTED] wrote:
  snacktime wrote:
  I need to calculate the lrc of a string using an exclusive or on each
  byte in the string.  How would I do this in python?
 
  lrc == Linear Redundancy Check?  or Longitudinal?  Note that
  such terms are not precisely defined... generally just acronyms
  people make up and stick in their user manuals for stuff. :-)
 
  import operator
  lrc = reduce(operator.xor, [ord(c) for c in string])

Or for the full functional programming effect...

  lrc = reduce(operator.xor, map(ord, string))

which is slightly faster and shorter...

$ python2.4 -m timeit -s'import operator; string = 
abcdefghij13123kj12l3k1j23lk12j3l12kj3' \
  'reduce(operator.xor, [ord(c) for c in string])'
1 loops, best of 3: 20.3 usec per loop

$ python2.4 -m timeit -s'import operator; string = 
abcdefghij13123kj12l3k1j23lk12j3l12kj3' \
  'reduce(operator.xor, map(ord, string))'
10 loops, best of 3: 15.6 usec per loop

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


Re: What's so funny? WAS Re: rotor replacement

2005-01-27 Thread phr
Skip Montanaro [EMAIL PROTECTED] writes:
 phr It is not a whizbang module.  It is a stripped-down, basic
 phr implementation of a well-accepted set of standards that are being
 phr used in thousands of other applications in other languages.
 
 Then there should be a library already out there already.  All you
 should need to do is wrap it (manually, with SWIG, whatever).

I'm currently using something wrapped with SWIG, but my understanding
is that core modules are not supposed to depend on SWIG.  So a core
module will likely use some existing primitives wrapped by hand.  That
is what I've offered to do, along with providing a somewhat more
Pythonic interface (though still a straightforward one) than directly
wrapping a C library intended for use from C applications.

 phr There is demand for it.  Look at how this thread started: some
 phr crypto user noticed that rotor was gone and wanted to know what to
 phr do instead.
 
 Yes, and putting rotor back would be the wrong thing to do.

Correct.  The right thing is to replace rotor with something
reasonable that follows standards.

 phr The issue of whether there's enough desire for a crypto module to
 phr warrant including one in the stdlib was decided a long time ago.
 phr The proof of that somebody decided to accept the rotor module into
 phr the distro.
 
 No, rotor was added in Python's early days (July 1992).  Times have changed.

I don't see that.  There's surely even more demand for crypto now than
there was in 1992.

 As long as we are discussing cryptography, what's wrong with m2crypto?
 
 http://sandbox.rulemaker.net/ngps/m2/ 

It's a good package but it's pretty heavyweight.  It depends on both
SWIG and OpenSSL.  I think it's still under development--there's an
occasional flurry of messages about it on python-crypto, but I haven't
been following it closely.  I'd have a hard time making a case for
accepting it into the core given the difficulty I'm having making the
case for something as simple as a block cipher wrapper.
m2crypto+OpenSSL is at least 100 times as much code as the module I've
proposed.  I think the Python lib should someday have its own
pure-Python SSL/TLS implementation sort of like the one Java has.  But
if m2crypto went into the lib, I'd use it.

 Why not incorporate it into the standard distribution?

I don't have the authority to incorporate anything into the standard
distribution.  All I can do is offer to contribute stuff that I write,
and let the distro maintainers decide whether to incorporate it.

I don't have the authority to offer m2crypto, since I'm not the author.
Only the authors can do that.  They haven't done so, as far as I know.

 Or, what about Andrew Kuchling's crypto toolkit?
 
 http://www.amk.ca/python/code/crypto.html

This is perhaps more suitable than m2crypto but as far as I know,
Andrew hasn't offered to contribute it.  Whatever his reasons are, I
have to respect them.  I think it has more stuff than a core crypto
module really needs (e.g. numerous semi-obsolete algorithms that
aren't in widespread use so aren't needed for interoperability) but
the extra stuff doesn't really get in the way.  If it were in the
core, it would completely fulfill my desires and I would be
transported with ecstacy.  But I've never seen any indication that
it's headed there.

 I believe both have been around awhile.  If crypto-in-the-core is
 really what's needed why not see if one of them is ready to go?

I don't think m2crypto is the answer, though maybe I'm wrong.  And if
Andrew's package is the answer, he would have submitted it already.

 phr Have you ever used a crypto library in a serious way?  
 
 Nope, never directly.  Don't make this about me.  I'm interested in the
 Python development process and how you'd like to turn it on its head.

Either you're the one turning the actual process on its head, or else
it's already on its head and needs to be turned rightside up.  Either
way, the existing process has certainly been a total failure so far at
producing good crypto support in the lib.

 phr It's already the category king, because there are precisely zero
 phr other entrants in the category.  
 
 See my above references.  Note, I don't use crypto at all, yet I was aware
 of both of these (no Googling required).

The authors have not offered to contribute them, so they're not in the
category.  The category consists of crypto modules that have actually
been offered.  As I keep saying, I'd love it if someone else offered
one.  I'm not eager for this headache.  I just saw that somebody
really ought to do it, and nobody was doing it, so I decided I was
elected.

 My guess would be they are substantially more mature than your
 proposed module.

This may sound a little strange, since my module is not yet written,
but if we take maturity to mean lower future maintenance needs, then I
wouldn't say m2crypto is precisely more mature.  m2crypto uses SWIG
and is 

Re: Tuple slices

2005-01-27 Thread jfj
Nick Coghlan wrote:
1. Applies only if you are making large slices, or a lot of slices with 
each containing at least 3 elements.
  A view can also *cost* memory, when it looks at a small piece of a 
large item. The view will keep the entire item alive, even though it 
needs only a small piece.
That is correct.
2. Hell no. The *elements* aren't copied, pointers to the elements are. 
If you *don't* copy the pointers, then every item access through the 
view involves an indirection as the index into the original sequence 
gets calculated.
If you have
x=(1,2,...11)
y=x[:-1]
then you copy 10 pointers AND you INCREF them AND you DECREF them
when y dies.
The unfortunate case by (1) would be:
x=(1,2,...11)
x=x[:1]
So views *may* save memory in some applications, but are unlikely to 
save time in any application (except any saving resulting from the 
memory saving).

They do. If tp_dealloc of a tuple view doesn't decref the pointers.
We should look for what is the most common case.
Gerald
-PS: the PEP for the removal ought to have a :) at the end.
--
http://mail.python.org/mailman/listinfo/python-list


Re: What's so funny? WAS Re: rotor replacement

2005-01-27 Thread phr
Skip Montanaro [EMAIL PROTECTED] writes:
  As long as we are discussing cryptography, what's wrong with
  m2crypto?  Or, what about Andrew Kuchling's crypto toolkit?
 
 Lucas Umm, is it just me or did we just discuss the legal issues of
 Lucas that??
 
 You may have.  Whether or not there are legal issues with them is of little
 relevance to the point I was making.  Anything Paul writes would probably
 have the same legal entanglements.

Andrew's toolkit does incorporate some patented algorithms, but those
aren't critical and could be removed from a stdlib version.

 I was simply pointing out that maybe, just maybe, there are already
 suitable candidates from a technical standpoint and that he doesn't
 need to write anything.

There really don't appear to be any that are both technically
suitable, and that the authors are willing to contribute to PSF.  I'd
be delighted to be wrong.  Of course that still leaves the legal
issue.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Please suggest on the book to follow

2005-01-27 Thread phr
santanu [EMAIL PROTECTED] writes:
 I know a little python (not the OOP part) learnt by studying the online
 tutorial. Now I would like to learn it more thoroughly.

I think there's supposed to be a new version of Python in a Nutshell
coming.  That's a more serious book than Learning Python.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Another scripting language implemented into Python itself?

2005-01-27 Thread Cameron Laird
In article [EMAIL PROTECTED],
Arthur  [EMAIL PROTECTED] wrote:
.
.
.
As long as we include the cost of treating adults as children, and
take it seriously as the kind of cost it is, I'm OK.

I think Terry's point covers a wide range of the real world
situations. Though certainly not all.

My real life is in the mid-market business world, not as a geometry
software developer.  And I see a sort of hysteria descending, in this
realm on this subject. Of theY2k ilk, but with actually, it seems to
me, less substance.  Family businesses out on the limb, as a business,
in a myriad of ways - because they are after all in business, focusing
on remote scenarios because they are somehow becoming convinced that
is what business people do (they don't), and demoralizing folks in the
process.  Folks who know that if they wanted to hurt this business
they could have done so a hundred times in a hundred ways over the
years.  But it wouldn't be by screwing with their computer system
because they wouldn't know how. So isn't it funny that is what the
boss is so concerned about - all of a sudden? 

(They always knew they were smarter then him. More proof)

Art

 

Pronouns quickly overload me.  If you're saying that there's hysteria
afoot, much of it about the harm that might come through use of
computers left unprotected from evildoers, well, yes, I'm with you.
Most people have far more important hazards in their lives and work
than security violations as we technologists generally conceive them.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python without OO

2005-01-27 Thread Dave Benjamin
Davor wrote:
Is it possible to write purely procedural code in Python, or the OO
constructs in both language and supporting libraries have got so
embedded that it's impossible to avoid them? Also, is anyone aware of
any scripting language that could be considered as Python minus OO
stuff? (As you can see I'm completely new to Python and initially
believed it's a nicesimple scripting language before seeing all this
OO stuff that was added in over time)
Many people have answered your question already, but I thought I would 
share my opinion as well, since I think I understand where you are 
coming from.

What attracted me to Python was not OO at all but the fact that it was 
somewhat similar to PHP (which I was using heavily at the time) but 
allowed me to encode certain higher-order programming techniques that 
PHP simply could not express. In short, I had become interested in 
functional programming after reading David Mertz's Charming Python 
tutorials, and after x attempts at trying to port the ideas to PHP, I 
finally gave up in frustration and started learning Python.

At the time, I was decidedly anti-OO. I grew up around a very liberal, 
punk-rock, nonconformist culture, and the amount of hype around OO made 
it too easy to hate (and, I suppose, it still does). PHP at the time was 
90% procedural; the prevaling attitude (which seems to have changed with 
the advent of PHP5) was that procedural code is all you need to solve 
most problems. With web scripting, it kind of makes sense, because 
(IMHO) objects really don't have much value unless you can hold onto 
them long enough for them to be useful, and many web scripts just pipe 
data from one place to another. Packing the data into objects is kind of 
like putting your possessions into boxes so that you can move them from 
one room to another and immediately unpack.

So, I guess you could say, I learned Python in spite of its rich support 
for OO. =)

It wasn't until I had to implement a large (to me), complex, graphical 
user interface, that I finally had to get off of my soapbox and realize 
that I had no better way to create sophisticated GUIs than OO. There are 
surely non-OO ways to build fancy GUIs, like functional-reactive 
programming, but a) I don't understand them, and b) I had to get my 
project done, and used the tools I had and the techniques I knew.

At that time, I started learning about Smalltalk and Alan Kay's emphasis 
on the messaging aspect of OO, and it started making a lot more sense. 
One of the most difficult tasks sometimes is getting various parts of 
the screen to update when the user changes a field or clicks a 
button--in a way that is manageable and doesn't devolve into spaghetti.

Aside from GUIs, however, I am rarely confronted with a task where I 
*need* OO. As a method for encoding abstract data types, it works, but 
it seems like more fashion than substance. As many have pointed out, the 
difference between method(obj, args) and obj.method(args) is subtle, 
and often inconsequential. In Python, you can program with just modules 
and functions/procedures, and never bother with the fact that you are 
using objects. Sure, a module is an object, and so is a procedure, but 
it's not all up in your face like, say, Java's arcane restriction that 
everything belong to some class.

It has been said of Perl programmers that they often dislike 
abstraction. Sometimes, I really sympathize with this viewpoint. I hate 
having to use a class that offers no value to the problem whatsoever, 
merely because an API is hard-wired to use instances of that class. No 
abstraction can often be better than a bad abstraction, and when it 
comes to debugging, the last thing you want is a bunch of black boxes.

These days, I do use classes and objects in Python, but mainly as a code 
organization technique, and only when I actually want my code organized 
that way. I tend to start with the problem at hand, building procedures 
to remove redundancy and keep my code small and simple. If I start 
noticing that a lot of procedures revolve around a particular data 
structure, I refactor them into a class. This way, I avoid creating 
abstractions that don't fit. It's much more mechanical than any feigned 
attempt at modeling the real world.

I think that functional programming (FP) is a very powerful methodology 
that can solve a lot of the same problems as OO, and does some things a 
lot better. FP and OO can live in harmony to some extent, but there are 
some places where they contradict each other. For instance, FP offers a 
mind-blowingly powerful tool called pattern matching, which is like a 
switch/case statement on steroids. OO dogma insists that this violates 
encapsulation, and that any form of switch/case is evil... replace 
conditional with polymorphism... replace conditional with 
polymorphism... replace conditional with polymorphism... replhic On 
the other hand, implementing something as seemingly simple as a 
__str__ method in 

Entirely off-topic personal grumble unrelated to original poster (was: Point of Sale)

2005-01-27 Thread Cameron Laird
In article [EMAIL PROTECTED],
Andreas Pauley  [EMAIL PROTECTED] wrote:
.
.
.
Actually I just mean that I'm not looking for a 100% feature-fit, if I get 
a 70% fit I'll jump in and develop the other 30%.
.
.
.
I keep winning contracts where something is a 70% fit, and
all I have to do is finish the other 85%.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Please suggest on the book to follow

2005-01-27 Thread Cameron Laird
In article [EMAIL PROTECTED],
santanu [EMAIL PROTECTED] wrote:
.
.
.
From what you and Fyzzyman said, I guess when I am done with
Programming Python, graduating to the latest features would
be quite easy. Isn't it?
.
.
.
Yes.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: parsing WSDL

2005-01-27 Thread Holger Duerer
 Alessandro == Alessandro Crugnola [EMAIL PROTECTED] writes:
Alessandro Is there a way, maybe using 4suite, to read a wsdl
Alessandro file and find for every method all the input/output
Alessandro params and their type?

Have you had a look at the Python WS tools?  They do have some sort of
WSDL support, so I assume you could get the info from those classes.

http://pywebsvcs.sf.net/


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


Re: ANN: Tao Scripting Language 0.8.5 beta released!

2005-01-27 Thread Rocco Moretti
Limin Fu wrote:
Dear all,
I am glad to announce in this mailing list that the lastest version
of a new scripting language has come out.
Since you chose to announce it in this mailing list/newsgroup, may I 
suggest that a comparison with Python is in order?

Since it is a new scripting language, I'm not suggesting a language war, 
but rather a simple statement of how Tao differs from Python, and what 
itch you were trying to scratch when you designed your new language. 
Basically, how does your design philosophy differ from that of Guido?
Where did you go left when Python went right?

(Congrats on beating the technical challenge of designing and 
implementing a programming language - now's your chance to sell us on 
it. :-)
--
http://mail.python.org/mailman/listinfo/python-list


Re: python memory blow out

2005-01-27 Thread jfj
Stephen Thorne wrote:
On Thu, 27 Jan 2005 09:08:59 +0800, Simon Wittber
[EMAIL PROTECTED] wrote:
According to the above post:
a) If the allocation is  256 bytes, call the system malloc.
b) If the allocation is  256, use its own malloc implementation, which
allocates memory in 256 kB chunks and never releases it.
I imagine this means that large memory allocations are eventually
released back to the operating system. However, in my case, this
appears to be not happening.

There was a recent patch posted to python-dev list which allows python
to release memory back to the operating system once the 256kb chunk is
no longer used.
The policy is that the memory allocated for those things is as much as 
the maximum number of them where needed during the program.

This is bad in rare cases:
A program which
- at some point, while normally needs 10-20 integers, it peaks its 
requirements and allocates 1000 integers.
- which does not terminate after that peak but keeps running for a long 
time without ever needing again many integers.

Such programs are rather rare. Moreover, the OS will happily swap out 
the unused int blocks after a while. A more pathetic situation would
be, in the above scenario to release all the 1 integers except 
from every 1000th. Assuming those ints left are accessed frequently,
the OS can't even swap out the pages!

But such programs, unless intentionally constructed are, **very** rare 
and it's supposed to be better to have a faster python in the general case.

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


Re: On benchmarks, heaps, priority queues

2005-01-27 Thread Tim Peters
[EMAIL PROTECTED], on
 http://xsdb.sourceforge.net/bench/pq3.py
]
 Yes I know in theory the insertion sort approach should be bad for
 large enough values, but the weird thing is that if you mix inserts and
 deletes (with enough deletes) even 1M elements is not a large enough
 value.  Anyway, for 10K or less the insertion sort priority queue
 implementation seems to always be better.

 Weird.  -- Aaron Watters

It's the distribution of queue sizes that matters here, not the total
number of elements thrown at the queue.  Your code mixes self and
this seemingly at random, and the __len__ methods in particular
often don't agree about which is in use.  If you repair that, and
instrument mixBench() to keep track of queue size statistics, you'll
find that even at 100, the queue at the top of the loop never
exceeds 30 entries, and has a mean size less than 3.  If you expect
your queues to have only a couple elements on average, then sure, the
simplest thing that could possibly work may be the fastest too.  And
if your queues never exceed 30 entries, then the poor O() behavior of
interior list insertion doesn't matter either.

The n%53 part should be true about 60% of the time if n were truly
random, which is a strong bias in mixBench pushing toward keeping the
queue very small.  Can't guess how close n is to being random, but the
random-number generator is suspect (the multiplier is extremely
small).  Suspect it's more the strong bias than the dubious generator
accounting for the almost-always near-trivial queue sizes in
mixBench(), though.

Note that in 2.4, bisect.insort() is also coded in C, so moving to 2.4
gives a boost to all the builtin gimmicks used here.

On my box (with self-vs-this straightened out, and mixBench()
instrumented to track queue size stats), using Python 2.4, PQPython23
wins maxBench 100 anyway:

BENCHMARKS FOR 100

mixBench
queue min 0 mean 2.517008 max 30
__main__.PQPython23 on 100 elapsed 4.5463134 got 51
queue min 0 mean 2.517008 max 30
__main__.PQ0 on 100 elapsed 4.7963134 got 51
queue min 0 mean 2.517008 max 30
__main__.PQueue on 100 elapsed 6.5463134 got 51
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Question: loading a shared object in python

2005-01-27 Thread Rick L. Ratzel
Pro Grammer [EMAIL PROTECTED] writes:

 Hello, all,
 I am not sure if this is the right place to ask, but could you kindly tell me
 how to load a shared object (like libx.so) into python, so that the methods 
 in
 the .so can be used? That too, given that the shared object was written in 
 c++,
 compiled with g++ ?
 Thanks,
 Pro Grammer

   Will the dl standard library module help you?  From the Python docs at:

http://docs.python.org/lib/module-dl.html

Example:

 import dl, time
 a=dl.open('/lib/libc.so.6')
 a.call('time'), time.time()
(929723914, 929723914.498)

   I'm guessing that there might be some C++ issues, but maybe it's worth
looking into.

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


Re: String Fomat Conversion

2005-01-27 Thread Steven Bethard
Stephen Thorne wrote:
I did all I did in the name of clarity, considering the OP was on his
first day with python. How I would actually write it would be:
inputfile = file('input','r')
inputfile.readline()
data = [map(float, line.split()) for line in inputfile]
Notice how you don't have to call iter() on it, you can treat it as an
iterable to begin with.
Beware of mixing iterator methods and readline:
http://docs.python.org/lib/bltin-file-objects.html
next(  	)
...In order to make a for loop the most efficient way of looping 
over the lines of a file (a very common operation), the next() method 
uses a hidden read-ahead buffer. As a consequence of using a read-ahead 
buffer, combining next() with other file methods (like readline()) does 
not work right.

I haven't tested your code in particular, but this warning was enough to 
make me generally avoid mixing iter methods and other methods.

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


Re: Please suggest on the book to follow

2005-01-27 Thread Alex Martelli
[EMAIL PROTECTED] wrote:

 santanu [EMAIL PROTECTED] writes:
  I know a little python (not the OOP part) learnt by studying the online
  tutorial. Now I would like to learn it more thoroughly.
 
 I think there's supposed to be a new version of Python in a Nutshell

Just a 2nd edition.  I'm just starting to write it.  By the time it's
done and out in print, say six months if you're a VERY optimistic guy,
I'm pretty sure santanu will be an experienced Pythonista and quite
ready to take advantage, if he chooses, of the Nutshell's 2nd edition as
a convenient desktop reference, which is its main intended role.

 coming.  That's a more serious book than Learning Python.

Speaking as the author of the Nutshell, and a TR for Learning, I think
I'm reasonably unbiased (or, equally biased in favor of both;-), and I
don't think of Learning as ``less serious'' -- it does have a different
role, of course.

If a book whose title is Learning X (for any X) does its job well,
then when you're done with it you can probably put it aside -- as
Wittgenstein said of the learner, he must so to speak throw away the
ladder, after he has climbed up on it.

A book that is meant mostly as a convenient reference, if _it_ does its
job, keeps being useful for a longer time.  On the other hand, using the
Nutshell for the purpose of learning Python, while certainly feasible if
you're well skilled in computer programming (in other languages), may
not be as easy as using Learning Python for that purpose!

All in all, while I'm of course gladder the more copies of the Nutshell
are sold, I still think that, for the _learning_ part, most people might
be better served by Learning Python -- or, for that matter, the
already recommended Practical Python (it has many significant
completely worked-out example programs -- I was a TR for it, too) or
Dive into Python (VERY fast and meant for already-experienced
programmers -- I wasn't a TR for it, but, my _wife_ was...;-)


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


HTML Tree View with ol and a href

2005-01-27 Thread Gregor Horvath
Hi,
Before I reinvent the wheel I`d like to ask if someone has done this 
before since I did not find an advice at Google.

The goal is to create a dynamic Tree View in HTML.
Say I have a data strucure like this:
structList = 
{'Sun':{'Sun.1':['Sun1.1','Sun1.2'],'Sun.2':['Sun2.1','Sun2.2']},'Kupa':['Kupa1']}

I want to transform this into HTML:
ol
lia href=?a=SunSun/a/li
  ol
  lia href=?a=Sun.1Sun.1/a/li
ol
lia href=?a=Sun1.1Sun1.1/a/li
lia href=?a=Sun1.2Sun1.2/a/li
/ol
  lia href=?Sun.2Sun.2/a/li
ol
lia href=?a=Sun2.1Sun2.1/a/li
lia href=?a=Sun2.2Sun2.2/a/li
/ol
  /ol
lia href=?a=KupaKupa/a/li
  ol
  lia href=?a=Kupa1Kupa1/a/li
  /ol
/ol
If the user clicks on a branch-link say 'Sun.1' then the branch below 
opens/closes (not printed by the servlet). Like a tree view control in 
an native GUI app.

Has this, or a similar approach, been done before in python ( I am using 
webware/cheetah)?

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


Re: String Fomat Conversion

2005-01-27 Thread Alex Martelli
Steven Bethard [EMAIL PROTECTED] wrote:
   ...
 Beware of mixing iterator methods and readline:

_mixing_, yes.  But -- starting the iteration after some other kind of
reading (readline, or read(N), etc) -- is OK...


 http://docs.python.org/lib/bltin-file-objects.html
 
 next( )
  ...In order to make a for loop the most efficient way of looping
 over the lines of a file (a very common operation), the next() method
 uses a hidden read-ahead buffer. As a consequence of using a read-ahead
 buffer, combining next() with other file methods (like readline()) does
 not work right.
 
 I haven't tested your code in particular, but this warning was enough to
 make me generally avoid mixing iter methods and other methods.

Yeah, I know... it's hard to explain exactly what IS a problem and what
isn't -- not to mention that this IS to some extent a matter of the file
object's implementation and the docs can't/don't want to constrain the
implementer's future freedom, should it turn out to matter.  Sigh.

In the Nutshell (2nd ed), which is not normative and thus gives me a tad
more freedom, I have tried to be a tiny bit more specific, taking
advantage, also, of the fact that I'm now addressing the 2.3 and 2.4
implementations, only.  Quoting from my current draft (pardon the XML
markup...):


interrupting such a loop prematurely (e.g., with cbreak/c), or
calling rf/rc.next()/c instead of rf/rc.readline()/c,
leaves the file's current position at an arbitrary value.  If you want
to switch from using rf/r as an iterator to calling other reading
methods on rf/r, be sure to set the file's current position to a
known value by appropriately calling rf/rc.seek/c.


I hope this concisely indicates that the problem (in today's current
implementations) is only with switching FROM iteration TO other
approaches to reading, and (if the file is seekable) there's nothing so
problematic here that a good old 'seek' won't cure...


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


Re: On benchmarks, heaps, priority queues

2005-01-27 Thread aaronwmail-usenet
re http://xsdb.sourceforge.net/bench/pq3.py

Tim Peters:
 If you repair that, and
 instrument mixBench() to keep track of queue size statistics, you'll
 find that even at 100, the queue at the top of the loop never
 exceeds 30 entries, and has a mean size less than 3.

Aha.  Now that is embarrassing :(.   If I fix it then I do see greater
differences
at sizes of 10+.  Below that, PQ0 still looks better on my machine,
which I
still consider weird.  Thanks!
-- Aaron Watters

War dims hope for peace  -- a real life headline

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


Re: String Fomat Conversion

2005-01-27 Thread Steven Bethard
Alex Martelli wrote:
Steven Bethard [EMAIL PROTECTED] wrote:
   ...
Beware of mixing iterator methods and readline:

[snip]
I hope this concisely indicates that the problem (in today's current
implementations) is only with switching FROM iteration TO other
approaches to reading, and (if the file is seekable) there's nothing so
problematic here that a good old 'seek' won't cure...
Thanks for the clarification!
Steve
--
http://mail.python.org/mailman/listinfo/python-list


Re: python without OO

2005-01-27 Thread Jeff Shannon
Davor wrote:
so you get a nice program with separate data structures and functions 
that operate on these data structures, with modules as containers for 
both (again ideally separated). Very simple to do and maintain [...]
Replace modules with classes in the above quote, and you have the 
very essence of object-oriented programming.

(What you describe here *is* object-oriented programming, you're just 
trying to avoid the 'class' statement and use module-objects where 
'traditional' OO would use class instances.)

Jeff Shannon
Technician/Programmer
Credit International
--
http://mail.python.org/mailman/listinfo/python-list


Re: inherit without calling parent class constructor?

2005-01-27 Thread Christian Dieterich
On Dé Céadaoin, Ean 26, 2005, at 17:02 America/Chicago, Steven Bethard 
wrote:

Just a note of clarification:
The @deco syntax is called *decorator* syntax.
Classes with a __get__ method are called *descriptors*.
Okay, I think I get the idea. I didn't know about the @deco syntax, but 
it seems to be straightforward. And I got myself updated a little bit 
on descriptors and static methods.

On Dé Céadaoin, Ean 26, 2005, at 17:09 America/Chicago, Jeff Shannon 
wrote:

You could try making D a container for B instead of a subclass:
Thank you for the solution. I'll need to have a closer look at it. 
However it seems like the decision whether to do some expensive 
calculation or not is delegated to the exterior of class D. Different 
classes that instanciate D would need to know what has been going on 
elsewhere. That might complicate things.

I'll go ahead and try with the descriptors first.
Thanks for all the help,
Christian
--
http://mail.python.org/mailman/listinfo/python-list


Re: Classical FP problem in python : Hamming problem

2005-01-27 Thread Francis Girard
Le jeudi 27 Janvier 2005 10:30, Nick Craig-Wood a crit:
 Francis Girard [EMAIL PROTECTED] wrote:
   Thank you Nick and Steven for the idea of a more generic imerge.

 You are welcome :-)  [It came to me while walking the children to school!]


Sometimes fresh air and children purity is all what it takes. Much better than 
coffee, cigarrette and flat screen.

 [snip]

   class IteratorDeiterator:
 def __init__(self, iterator):
   self._iterator = iterator.__iter__()
   self._firstVal = None ## Avoid consuming if not requested from
  outside ## Works only if iterator itself can't return None

 You can use a sentinel here if you want to avoid the can't return
 None limitation.  For a sentinel you need an object your iterator
 couldn't possibly return.  You can make one up, eg


Great idea. I'll use it.

self._sentinel = object()
self._firstVal = self._sentinel

 Or you could use self (but I'm not 100% sure that your recursive
 functions wouldn't return it!)

 def __iter__(self): return self
 
 def next(self):
   valReturn = self._firstVal
   if valReturn is None:

 and

if valReturn is self._sentinel:
 valReturn = self._iterator.next()
   self._firstVal = None

self._firstVal = self._sentinel

 etc..

 [snip more code]

 Thanks for some more examples of fp-style code.  I find it hard to get
 my head round so its been good exercise!

Introduction to functional programming
Richard Bird and Philip Wadler
Prentice Hall
1988

This is the very best intro I ever read. The book is without hype, doesn't 
show its age and is language neutral.
Authors are world leaders in the field today. Only really strong guys have the 
kindness to do understandable introductions without trying to hide the 
difficulties (because they are strong enough to face them with simplicity).

It's been a real pleasure.

Regards,

Francis Girard
FRANCE


 --
 Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick

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


Re: how to comment out a block of code

2005-01-27 Thread Jeff Shannon
Xah Lee wrote:
is there a syntax to comment out a block of code? i.e. like html's !--
comment --
or perhaps put a marker so that all lines from there on are ignored?
thanks.
Of course -- this feature is so important that all computer 
manufacturers worldwide have made a special button on the computer 
case just for this!

Normally it's a large round button, with perhaps a green backlight. 
Press the button and hold it in for about 3 seconds, and the rest of 
your code/writing will be ignored just as it should be.

Jeff Shannon
Technician/Programmer
Credit International
--
http://mail.python.org/mailman/listinfo/python-list


Re: python without OO

2005-01-27 Thread Joe Francia
Timo Virkkala wrote:
This guy has got to be a troll. No other way to understand.
--
Timo Virkkala
Not a troll, just another case of premature optimization run amok.
--
http://mail.python.org/mailman/listinfo/python-list


Question about 'None'

2005-01-27 Thread flamesrock
Well, after playing with python for a bit I came across something
weird:

The statement (1  None) is false (or any other value above 0). Why is
this?


(The reason I ask is sortof unrelated. I wanted to use None as a
variable for which any integer, including negative ones have a greater
value so that I wouldn't need to implement any tests or initializations
for a loop that finds the maximum of a polynomial between certain x
values. Anything is greater than nothing, no?)

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


gnuplot on Canvas widget

2005-01-27 Thread Blues
Hey,

I have used two great models - Tkinter and Gnuplot.py - for a while.  I
can display an image on a Canvas widget using Tkinter and I can also
generate a gnuplot from Python on the fly in a separate window.  Does
anyone know how to display such a gnuplot on the Canvas widget with an
image in it?  Thanks.

Michael

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


Re: Question about 'None'

2005-01-27 Thread Fredrik Lundh
flamesrock [EMAIL PROTECTED] wrote:

 The statement (1  None) is false (or any other value above 0). Why is
 this?

http://docs.python.org/ref/comparisons.html

The operators , , ==, =, =, and != compare the values of
two objects. The objects need not have the same type. If both
are numbers, they are converted to a common type. Otherwise,
objects of different types always compare unequal, and are
ordered consistently but arbitrarily.

(This unusual definition of comparison was used to simplify the
definition of operations like sorting and the in and not in
operators. In the future, the comparison rules for objects of
different types are likely to change.)

/F 



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


Re: limited python virtual machine (WAS: Another scripting language implemented into Python itself?)

2005-01-27 Thread Dieter Maurer
Steven Bethard [EMAIL PROTECTED] writes on Tue, 25 Jan 2005 12:22:13 -0700:
 Fuzzyman wrote:
 ...
   A better (and of course *vastly* more powerful but unfortunately only
   a dream ;-) is a similarly limited python virutal machine.

I already wrote about the RestrictedPython which is part of Zope,
didn't I?

Please search the archive to find a description...


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


Re: subprocess.Popen() redirecting to TKinter or WXPython textwidget???

2005-01-27 Thread Jeff Shannon
Ivo Woltring wrote:
The output of mencoder is not readable with readlines (i tried it) because
after the initial informational lines You don't get lines anymore (you get a
linefeed but no newline)
The prints are all on the same line (like a status line)
something like
Pos:   3,1s 96f ( 0%)  42fps Trem:   0min   0mb  A-V:0,038 [171:63]
Hm, I'm inferring that what you mean is that you get a carriage return 
(ASCII 0x0C) but no linefeed (ASCII 0x0A) -- CR returns you to the 
beginning of the current line, and LF advances you to the next line.

Rather than using readlines(), you could simply read() a few 
characters (or a single character) at a time, buffering it yourself 
and passing it on when you see the CR.

You're likely to run into I/O blockage issues no matter how you do 
this, though -- even if you're reading a single character at a time, 
read(1) won't return until you've read that character, and if the 
program on the other end of the pipe isn't writing anything, then your 
app is stuck.  The simple way to do this is by using an i/o thread, 
which does something like this:

buffer = []
while 1:
char = outpipe.read(1)
if char == '\0x0A':
notify_gui_thread( ''.join(buffer) )
buffer = []
else:
buffer.append(char)
if StopEvent.IsSet():
raise CustomStopException
Note that you don't want to try to update your GUI widgets directly 
from the worker (i/o) thread -- very few GUI toolkits are threadsafe, 
so you need to make all GUI calls from a single thread.

Jeff Shannon
Technician/Programmer
Credit International

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


Re: Question about 'None'

2005-01-27 Thread Steven Bethard
flamesrock wrote:
The statement (1  None) is false (or any other value above 0). Why is
this?
What code are you executing?  I don't get this behavior at all:
py 100  None
True
py 1  None
True
py 0  None
True
py -1  None
True
py -100  None
True
(The reason I ask is sortof unrelated. I wanted to use None as a
variable for which any integer, including negative ones have a greater
value so that I wouldn't need to implement any tests or initializations
for a loop that finds the maximum of a polynomial between certain x
values. Anything is greater than nothing, no?)
Yup, that's the behavior I get with None.
Steve
--
http://mail.python.org/mailman/listinfo/python-list


Re: String Fomat Conversion

2005-01-27 Thread Jeff Shannon
Stephen Thorne wrote:
On Thu, 27 Jan 2005 00:02:45 -0700, Steven Bethard
[EMAIL PROTECTED] wrote:
By using the iterator instead of readlines, I read only one line from
the file into memory at once, instead of all of them.  This may or may
not matter depending on the size of your files, but using iterators is
generally more scalable, though of course it's not always possible.
I just did a teensy test. All three options used exactly the same
amount of total memory.
I would presume that, for a small file, the entire contents of the 
file will be sucked into the read buffer implemented by the underlying 
C file library.  An iterator will only really save memory consumption 
when the file size is greater than that buffer's size.

Actually, now that I think of it, there's probably another copy of the 
data at Python level.  For readlines(), that copy is the list object 
itself.  For iter and iter.next(), it's in the iterator's read-ahead 
buffer.  So perhaps memory savings will occur when *that* buffer size 
is exceeded.  It's also quite possible that both buffers are the same 
size...

Anyhow, I'm sure that the fact that they use the same size for your 
test is a reflection of buffering.  The next question is, which 
provides the most *conceptual* simplicity?  (The answer to that one, I 
think, depends on how your brain happens to see things...)

Jeff Shannon
Technician/Programmer
Credit International
--
http://mail.python.org/mailman/listinfo/python-list


[perl-python] 20050127 traverse a dir

2005-01-27 Thread Xah Lee
# -*- coding: utf-8 -*-
# Python

suppose you want to walk into a directory, say, to apply a string
replacement to all html files. The os.path.walk() rises for the
occasion.

© import os
© mydir= '/Users/t/Documents/unix_cilre/python'
© def myfun(s1, s2, s3):
©  print s2 # current dir
©  print s3 # list of files there
©  print '--==(^_^)==--'
© os.path.walk(mydir, myfun, 'somenull')


--
os.path.walk(base_dir,f,arg) will walk a dir tree starting at
base_dir, and whenever it sees a directory (including base_dir), it
will call f(arg,current_dir,children), where the current_dir is the
string of the current directory, and children is a *list* of all
children of the current directory. That is, a list of strings that are
file names and directory names. Try the above and you'll see.

now, suppose for each file ending in .html we want to apply function
g to it. So, when ever myfun is called, we need to loop thru the
children list, find files and ending in html (and not a directory),
then call g. Here's the code.

© import os
© mydir= '/Users/t/web/SpecialPlaneCurves_dir'
© def g(s): print g touched:, s
© def myfun(dummy, dirr, filess):
©  for child in filess:
©  if '.html' == os.path.splitext(child)[1] \
©  and os.path.isfile(dirr+'/'+child):
©  g(dirr+child)
© os.path.walk(mydir, myfun, 3)

note that os.path.splitext splits a string into two parts, a portion
before the last period, and the rest in the second portion. Effectively

it is used for getting file suffix. And the os.path.isfile() make sure
that this is a file not a dir with .html suffix... Test it yourself.

one important thing to note: in the mydir, it must not end in a
slash. One'd think Python'd take care of such trivia but no. This took
me a while to debug.

also, the way of the semantics of os.path.walk is nice. The myfun can
be a recursive function, calling itself, crystalizing a program's
semantic.

---
# in Perl, similar program can be had.
# the prototypical way to traverse a dir
# is thru File::Find;

use File::Find qw(find);
$mydir= '/Users/t/web/SpecialPlaneCurves_dir';
find(\wanted, $mydir);
sub g($){print shift, \n;}
sub wanted {
if ($_ =~/\.html$/  -T $File::Find::name) { g $File::Find::name;}
$File::Find::name;
}

# the above showcases a quick hack.
# File::Find is one of the worst module
# there is in Perl. One cannot use it
# with a recursive (so-called) filter
# function. And because the way it is
# written, one cannot make the filter
# function purely functional. (it relies
# on the $_) And the filter function
# must come in certain order. (for
# example, the above program won't work
# if g is moved to the bottom.)  ...

# the quality of modules in Perl are
# all like that.
Xah
 [EMAIL PROTECTED]
 http://xahlee.org/PageTwo_dir/more.html

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


PythonWin (build 203) for Python 2.3 causes Windows 2000 to grind to a halt?

2005-01-27 Thread Chris P.
I've been having a problem with PythonWin that seemed to start
completely spontaneously and I don't even know where to START to find
the answer.  The only thing I can think of that marks the point
between PythonWin works fine and PythonWin hardly every works fine
was that I changed the size of my Virtual Paging file, noticing that
it was too small (I currently have a P4 with 1G of RAM).  I tried
returning it to its original (smaller) size, but it didn't fix the
problems.

The first time I noticed it, I was using PythonWin and then
right-clicked on My Computer to use Explore.  Instead of the usual
full listing (approx 10 items), I got a mini-listing of 4 items. 
Then, after clicking Explore, I either don't get a new window at all
OR I get a strange file explorer that won't let me look at files,
won't let me copy files, etc.  The mini-lising thing also happens if
I click the Start button while PythonWin is open.

Another problem is trying to open another program while PythonWin is
running - generally, the program will not start, but I also don't get
any kind of error popping up on the screen.  My request is just
ignored (although I sometimes get a system beep.)  If I already have
other programs open and then open PythonWin, my menu bar might refuse
to function.  Is it significant that, when the menu bar IS working,
the drop-down menu fades in quite slowly, instead of popping up
immediately?

At the end of this message, I've pasted a screen dump of a message I
get when I try to open a file and I've got other apps open (note that
I can have very few, non-memory intensive apps open and I still get
it).

Thanks for any help you can give,

- Chris

[SCREEN DUMP AFTER I TRY TO OPEN A .PY FILE]
  File C:\Python23\Lib\site-packages\pythonwin\pywin\mfc\docview.py,
line 91, in CreateNewFrame
wnd.LoadFrame(self.GetResourceID(), -1, None, context)  # triggers
OnCreateClient...
win32ui: LoadFrame failed

win32ui: CreateNewFrame() virtual handler (bound method
SyntEditTemplate.CreateNewFrame of
pywin.framework.editor.color.coloreditor.SyntEditTemplate instance at
0x01193F30) raised an exception
TypeError: PyCTemplate::CreateNewFrame must return a PyCFrameWnd
object.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: inherit without calling parent class constructor?

2005-01-27 Thread Jeff Shannon
Christian Dieterich wrote:
On Dé Céadaoin, Ean 26, 2005, at 17:09 America/Chicago, Jeff Shannon wrote:
You could try making D a container for B instead of a subclass:

Thank you for the solution. I'll need to have a closer look at it. 
However it seems like the decision whether to do some expensive 
calculation or not is delegated to the exterior of class D. Different 
classes that instanciate D would need to know what has been going on 
elsewhere. That might complicate things.
True, in the sense that B is instantiated as soon as a message is sent 
to D that requires B's assistance to answer.  If the decision is a 
case of only calculate this if we actually want to use it, then this 
lazy-container approach works well.  If the decision requires 
consideration of other factors, then it's a bit more complex -- though 
one could write that logic into D, and have D throw an exception (or 
return a sentinel) if it decides not to instantiate B at that time. 
This then requires a bit more checking on the client side, but the 
actual logic is encapsulated in D.

And really, I don't see where the container approach shifts the 
decision any more than the descriptor approach does.  In either case, 
the calculation happens as soon as someone requests D.size ...

(However, from your other descriptions of your problem, it does sound 
like a property / descriptor is a better conceptual fit than a 
contained class is.  I mostly wanted to point out that there are other 
ways to use OO than inheritance...)

Jeff Shannon
Technician/Programmer
Credit International
--
http://mail.python.org/mailman/listinfo/python-list


Re: [perl-python] 20050127 traverse a dir

2005-01-27 Thread Chris Mattern
Xah Lee wrote:

snip
 
 # the above showcases a quick hack.
 # File::Find is one of the worst module
 # there is in Perl. One cannot use it
 # with a recursive (so-called) filter
 # function. And because the way it is
 # written, one cannot make the filter
 # function purely functional. (it relies
 # on the $_) And the filter function
 # must come in certain order. (for
 # example, the above program won't work
 # if g is moved to the bottom.)  ...
 
 # the quality of modules in Perl are
 # all like that.

Is it just me, or is the disappointing lack of flamewars
slowly ratcheting up the level of vitriol in his posts?

-- 
 Christopher Mattern

Which one you figure tracked us?
The ugly one, sir.
...Could you be more specific?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Question about 'None'

2005-01-27 Thread Francis Girard
Le jeudi 27 Janvier 2005 20:16, Steven Bethard a écrit :
 flamesrock wrote:
  The statement (1  None) is false (or any other value above 0). Why is
  this?

 What code are you executing?  I don't get this behavior at all:

 py 100  None
 True
 py 1  None
 True
 py 0  None
 True
 py -1  None
 True
 py -100  None
 True


Wow ! What is it that are compared ? I think it's the references (i.e. the 
adresses) that are compared. The None reference may map to the physical 0x0 
adress whereas 100 is internally interpreted as an object for which the 
reference (i.e. address) exists and therefore greater than 0x0.

Am I interpreting correctly ?

  (The reason I ask is sortof unrelated. I wanted to use None as a
  variable for which any integer, including negative ones have a greater
  value so that I wouldn't need to implement any tests or initializations
  for a loop that finds the maximum of a polynomial between certain x
  values. Anything is greater than nothing, no?)

 Yup, that's the behavior I get with None.

 Steve

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


  1   2   >