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: python without OO

2005-01-27 Thread Timo Virkkala
[EMAIL PROTECTED] wrote:
I think the OO way is slightly more obscure. It's obvious what x =
reverse(x) does, but it is not clear unless you have the source code
whether x.reverse() reverses x or if it returns a reversed list. If
x.reverse() does the former, a disadvantage relative to the procedural
approach is that a function can be used in an expression. It is clearer
and more concise to write
Sure, it's clear if in written code you see
x = reverse(x)
To me it would also be clear to see
x.reverse()
But what if you just see in some list that there is a reverse(sequence) 
function, or that a sequence has a reverse() method? To me, neither of these is 
clear. Do they return a new, reversed sequence or reverse in place?

When creating a new API, I would probably use a convention where reverse does it 
in place and reversed returns a new. So, in my API,

reverse(x)
y = reversed(x)
x.reverse()
y = x.reversed()
--
Timo Virkkala
--
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: py2exe problem

2005-01-27 Thread Harald Massa
Thomas,

> Would the above (include all encodings stuff by default) be a good
> solution, or do you have other ideas?

I assume a good solution would involve switching pythons default from 
"ASCII" to "UNICODE" :)

But ... as far as py2exe is concerned, yeah, I think it would be helpfull 
to include all encoding by default (undefaultable, of course), or at least 
provide in the very very first simple setup.py example the include 
encodings.* stuff.

Harald Armin
-- 
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: Inherting from object. Or not.

2005-01-27 Thread Nick Coghlan
Frans Englich wrote:
On Wednesday 26 January 2005 21:24, M.E.Farmer wrote:
Hello Frans,
What you are seeing is a step on the path to unification of types and
classes.

I changed all base classes in my project to inherit object. There appears to 
be no reason to not do it, AFAICT.
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).

Cheers,
Nick.
--
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---
http://boredomandlaziness.skystorm.net
--
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=glance&s=books&n=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 
#include 

using namespace std;
using namespace boost::python;

class Rational
{};

ostream& operator<<(ostream& os, Rational r){
return os;
}
BOOST_PYTHON_MODULE(Rational)
{
class_("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_visitor, classT =
boost::python::class_]
':
/usr/include/boost/python/def_visitor.hpp:67:   instantiated from `void
boost::python::def_visitor::visit(classT&) const [with
classT = boost::python::class_, DerivedVisitor =
boost::python::api::object]'
/usr/include/boost/python/class.hpp:225:   instantiated from
`boost::python::class_& boost::python::class_::def(const boost::python::def_visitor&) [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_&) 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

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

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


Re: import hook, overwrite import?

2005-01-27 Thread Steve Holden
Kartic wrote:
Hi Torsten,
If you want to use other methods to import (other than good ole file
system), yes, you can create an importer class and register it as an
importer module, that import will use to search and import.
For example, it is possible to use zip imports (this functionality is
already builtin) to import from a zip archive.
py>>> import zlib # required
py>>> import sys
py>>> sys.path.append('/location/to/zippedmodules.zip')
py>>> import testzip
py>>> testzip.__file__
'/location/to/zippedmodules.zip/testzip,py'
To generally do it, you have to:
1. Create a class that provides a load_module method that returns a
module type.
2.  Install your class as a hook using
sys.path_hooks.append(your_importer_class)
Please take a look at the imp module :
http://docs.python.org/lib/module-imp.html for a complete description
on accessing the import internals. There is also a simple example in
this section.
Is this is what you are looking for?
Thanks,
--Kartic
PS: This about how much I know...the more I find out, I will share :-)
I will just chime in to say I too am looking for information in this 
area. I hope to put some sort of BoF or Open Space event together for 
people wishing to learn about (and teach about) the import system from 
PEP 302 at PyCon this year.

Early bird registration rates are still available today and tomorrow!
regards
 Steve
--
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


Re: Help With Python

2005-01-27 Thread Nick Vargish
"Matt" <[EMAIL PROTECTED]> writes:

> Not to be nit-picky, but you got some issues here ;-).  Never forget
> the importance of "self"!

Teach me to post untested code. *hangs head*

Nick

-- 
#  sigmask  ||  0.2  ||  20030107  ||  public domain  ||  feed this to a python
print reduce(lambda x,y:x+chr(ord(y)-1),' Ojdl!Wbshjti!=obwAcboefstobudi/psh?')
-- 
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
 -- 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
>[email protected]
> 
> 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: [email protected]
> 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: [email protected]
> 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: [email protected]
> 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,
> Basavana

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 s, 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: [email protected]
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 
> 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


Re: On benchmarks, heaps, priority queues

2005-01-27 Thread aaronwmail-usenet

me> PQPython23 - the Lib implementation
me> PQ0 - my insertion sort based variant
me> PQueue - my "heap" based variant
me> (like PQPython23, but different).

Tim D:
> First of all, you should be running these benchmarks using Python
2.4.
> heapq is considerably faster there ... (Raymond Hettinger rewrote it
all
> in C).
> http://www.python.org/2.4/highlights.html
> Tim Delaney

WHOOPS. Okay after getting past my initial embarassment I tried this,
and it turns out it doesn't make much of a difference.  In particular
PQ0 is still always better if you intersperse many deletes with inserts
or in all cases of size <1.  Of course other machines will probably
have different characteristics (and yes my py24 contains the _heapq
extension module).

The nasty behavior of PQ0 for insertBench at >10
I think has to do with large list reallocation.

Hmmm.  This makes me wonder if my bplustree implementation(s) are
faster
than the bsddb modules too...

-- Aaron Watters
===
SOMETHING WENT WRONG IN AIRLINE CRASH, EXPERT SAYS
-- a "real life headline" (that'll be $50,000, please)


ENCLOSURE: Python 2.4 run of
http://xsdb.sourceforge.net/bench/pq3.py on my machine.
===

BENCHMARKS FOR 1000

insertBench
__main__.PQPython23 on 1000 elapsed 0.019809265 got 1000
__main__.PQ0 on 1000 elapsed 0.0099046326 got 1000
__main__.PQueue on 1000 elapsed 0.032098083 got 1000

mixBench
__main__.PQPython23 on 1000 elapsed 0.0 got 502
__main__.PQ0 on 1000 elapsed 0.0099046326 got 502
__main__.PQueue on 1000 elapsed 0.0 got 502

BENCHMARKS FOR 1

insertBench
__main__.PQPython23 on 1 elapsed 0.26017984 got 1
__main__.PQ0 on 1 elapsed 0.21038147 got 1
__main__.PQueue on 1 elapsed 0.35895096 got 1

mixBench
__main__.PQPython23 on 1 elapsed 0.071716614 got 5003
__main__.PQ0 on 1 elapsed 0.050999879837 got 5003
__main__.PQueue on 1 elapsed 0.069332428 got 5003

BENCHMARKS FOR 10

insertBench
__main__.PQPython23 on 10 elapsed 3.26499986649 got 10
__main__.PQ0 on 10 elapsed 7.8814196 got 10
__main__.PQueue on 10 elapsed 4.8161226 got 10

mixBench
__main__.PQPython23 on 10 elapsed 0.65099978447 got 5
__main__.PQ0 on 10 elapsed 0.461000204086 got 5
__main__.PQueue on 10 elapsed 0.66113351 got 5

BENCHMARKS FOR 20

insertBench
__main__.PQPython23 on 20 elapsed 6.9900954 got 20
__main__.PQ0 on 20 elapsed 28.5010001659 got 20
__main__.PQueue on 20 elapsed 10.384905 got 20

mixBench
__main__.PQPython23 on 20 elapsed 1.29099988937 got 11
__main__.PQ0 on 20 elapsed 0.922000169754 got 11
__main__.PQueue on 20 elapsed 1.3420763 got 11

BENCHMARKS FOR 30

insertBench
__main__.PQPython23 on 30 elapsed 11.697267 got 30
__main__.PQ0 on 30 elapsed 70.3009998798 got 30
__main__.PQueue on 30 elapsed 16.884629 got 30

mixBench
__main__.PQPython23 on 30 elapsed 1.9338774 got 15
__main__.PQ0 on 30 elapsed 1.3915995 got 15
__main__.PQueue on 30 elapsed 1.9635913 got 15

BENCHMARKS FOR 40

insertBench
__main__.PQPython23 on 40 elapsed 15.5419998169 got 40
__main__.PQ0 on 40 elapsed 127.25321 got 40
__main__.PQueue on 40 elapsed 23.062638 got 40

mixBench
__main__.PQPython23 on 40 elapsed 2.64399981499 got 20
__main__.PQ0 on 40 elapsed 1.9536866 got 20
__main__.PQueue on 40 elapsed 2.7336758 got 20

BENCHMARKS FOR 50

insertBench
__main__.PQPython23 on 50 elapsed 20.881144 got 50
__main__.PQ0 on 50 elapsed 246.95424 got 50
__main__.PQueue on 50 elapsed 35.960657 got 50

mixBench
__main__.PQPython23 on 50 elapsed 3.5559428 got 25
__main__.PQ0 on 50 elapsed 2.4834005 got 25
__main__.PQueue on 50 elapsed 3.48500013351 got 25

BENCHMARKS FOR 100

insertBench
__main__.PQPython23 on 100 elapsed 44.694057 got 100
__main__.PQ0 on 100 elapsed 1400.5940001 got 100
__main__.PQueue on 100 elapsed 70.661409 got 100

mixBench
__main__.PQPython23 on 100 elapsed 6.6311444 got 51
__main__.PQ0 on 100 elapsed 4.7366104 got 51
__main__.PQueue on 100 elapsed 6.8292371 got 51

-- 
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$",r"localhost\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()
   

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: What's so funny? WAS Re: rotor replacement

2005-01-27 Thread Skip Montanaro
>> 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.  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.

Skip

-- 
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  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 "", 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 "", 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 precisel

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: On benchmarks, heaps, priority queues

2005-01-27 Thread Szabolcs Nagy
hello
nice benchmarks

some time ago i've also done some benchmarking
i sorted 10 random int with differrent heap implementations, bisect
module and with list.sort()
I know that heaps are not for sorting, but i tested their performance
with sorting back then.

my results (sorting algo / time):

myheap: (my dummy heap implementation with non-standard comparison)
4.08311503909
heapdict: (my heapdict able to update/delete arbitrary items:
heap[key]=value)
5.11007613686
priodict:
(http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/117228)
4.96804296435
pyheapq: (heapq from py 2.3)
2.37830548956
cheapq:  (heapq from py 2.4)
0.375011378197
sort:  (list.sort)
0.118014529543
bisect:  (bisect module)
3.88104577077

i didn't made many benchmarks
but bisect is not so fast with larger amount of data (if i saw well
your PQ0 implementation used bisect)
it's not scaleable (not even O(nlog(n))   because inserting in a
python list is not O(1))
however for small amount of data bisect is the fastest

if i used 10 times more data every algorithm scaled well except for
bisect:

myheap:
50.6242882263
heapdict:
67.465409454
priodict:
71.5018580555
pyheapq:
30.9821771082
cheapq:
6.41072844834
sort:
1.58179548464
bisect:
785.215063469

nsz

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


Re: how to pass attribute name via sys.argv

2005-01-27 Thread Felix Hebeler
Wolfram Kraus wrote:
Felix Hebeler wrote:

I need to call an object attribute:
value = object.attrName[0]

Use getattr:
value = getattr(object, attrName)[0]


HTH,
Wolfram
Thanks so much!
Had I known earlier.
Looks so easy...
Now, why did I not find this in the online tutorial, the reference 
manual, or google?
Not that I didn't try... I mean, I would find 'getattr' if I searched, 
but if you don't know what you're looking for..

I find the reference manual extremely (== too) compact to look things up.
A couple of colleages and me agreed that it is much more difficult to 
find solutions and _useful_ tips for Python than e.g. for Java (where 
there's  Javadoc for example). The syntax doc in the reference manual to 
me looks like computer linguists might understand, but unfortunately not 
me. And Python code IS really easy to read, I agree, but what if I can't 
find out how to write it?
I'd appreciate any link to online resources or recommendations for books 
(english/german)!

Chances are I'm a silly/lazy/deprived/stupid bugger, but I try to think 
there's still hope!

again, thank you so much for your quick response (thanks Gilles Lenfant 
too!), I really DO like the Python community ;-)

Cheers
Felix
--
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 nice&simple 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... repl On 
the other hand, implementing something as seemingly simple as a 
"__str__" me

Re: On benchmarks, heaps, priority queues

2005-01-27 Thread aaronwmail-usenet


(re: http://xsdb.sourceforge.net/bench/pq3.py)

nsz> ...bisect is not so fast for large data...

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

===
Hypothetical performance improvements are the root of all evil.
-- Bill Tutt (paraphrased)

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


Re: Point of Sale

2005-01-27 Thread Evan Simpson
Andreas Pauley wrote:
If the network is down each POS station should still be able to function 
without interruption.

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.
You may want to check out the Spread Toolkit, at www.spread.org, whose 
Python wrapper lives at http://www.python.org/other/spread/doc.html. 
It's used by the Zope Replication Service, for example.

Cheers,
Evan @ 4-am
--
http://mail.python.org/mailman/listinfo/python-list


Re: On benchmarks, heaps, priority queues

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

> Hypothetical performance improvements are the root of all evil.
> -- Bill Tutt (paraphrased)

well, after this week, I'd say that

Hypothetical performance limitations are the root of all evil.

 



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


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: Tkinter vs wxPython

2005-01-27 Thread Gabriel Cosentino de Barros
Title: RE: Tkinter vs wxPython





*warning* My very own opinions ahead. no flame intended.


> Try them both out for an hour or two, and go with whichever
> one "feels right".  You very likely won't be making a mistake.


i did that for java+swing, python+tk, python+gtk, python+wxWindow and python+glade


I limited myself in one hour, and at a maximum 2 hours if the docs aren't perfect (i had zero experience at the time with all of them)

The program code was already written, it only needed the gui.


Java took me 3 hours to hook all the ungly hacks for dealing with threads in the AWT... but i will not elaborate on it because it would be kicking a dead horse. now for something completely diferent: python :)

tk: the docs where superberb! done everything in 25min! then spent an hour polishing and adding status bars for everything :)

gtk: had to use the C api docs. wasted some time figuring it out, gave up after one hour and a half and ended up with a window layout that didn't maximezed well.

wx: Almost two hours. Once you get used to the docs and get the knowledge to read some examples all is fine. i liked the result. and liked the api but disliked the sea of constants necessary (i hated it in gtk also)

glade: i gave up after 2hours of reading licenses and dealing with broken libs. Also, i can't run in beOS or tweak widgets. bah! rather go back to visual basic ;)


Now going back on topic: A think that neighter Tk nor wxWindow is a good choice for python. They both suck much of it when it came to abstraction. They're still better than glade or gtk. But could improve a lot. wxWindow has simple an ugly API, and Tk has a huge sin in the syntax to pass actions to the buttons.

But after all, i'm using exclusively TK for now. But things might change as i'm in a project with a huge need of non-ortodox input, so i may be going back to read about wxWindow event handlers or even pygame.

peace,
Gabriel



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


Another scripting language implemented into Python itself?

2005-01-27 Thread ajsiegel

Cameron writes:

>Pronouns quickly overload me.  

On a reread of my post,  me, we and they and I all sympathize.

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

That is what I am saying, admitted not very well.

As it happens, though, I don't particularly finger the technologists 
as the culprits.

Strangely, much of it can be traced to the fallout of Enron, though
of course Enron had nothing to do with this realm of evil in any way.

Most particularly ironic is the fact that is the same strata of the 
business community (broadly speaking I am part of that
community)  that bears a good deal of responsibility for Enron 
that has jumped on the opportunity to cash in on its fallout.

Lovely.

Art





-- 
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
 
]
> 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%5<3" 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: "load"ing 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: Help With Python

2005-01-27 Thread Steven Bethard
Nick Craig-Wood wrote:
Steven Bethard <[EMAIL PROTECTED]> wrote:
py> orders = [Viking().order()] * 7
py> ', '.join(orders)
'Spam, Spam, Spam, Spam, Spam, Spam, Spam'
Thats still one Viking making 7 orders surely?
So you want this...
orders = [ Viking().order() for _ in range(7) ]
Right, right.  Thanks for the correction!  This is why I never use the * 
operator on lists. ;)

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


Re: urllib and proxy

2005-01-27 Thread chris
This was helpful.  After reading this, I realized you can also just add
this atop whatever script imports urllib.  Just add after "import
urllib":

# Disable proxy use.
urllib.getproxies = lambda x = None: {}
-Chris
http://www.fetidcascade.com/

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

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:

Sun
  
  Sun.1

Sun1.1
Sun1.2

  Sun.2

Sun2.1
Sun2.2

  
Kupa
  
  Kupa1
  

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 break), or
calling f.next() instead of f.readline(),
leaves the file's current position at an arbitrary value.  If you want
to switch from using f as an iterator to calling other reading
methods on f, be sure to set the file's current position to a
known value by appropriately calling f.seek.
"""

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


  1   2   >