Guppy-PE: A Python Programming Environment

2005-11-25 Thread [EMAIL PROTECTED]
I would like to announce Guppy-PE 0.1

The first version of Guppy-PE, a programming environment providing
object and heap memory sizing and analysis and comes with a
prototypical specification language that can be used to formally
specify aspects of Python programs and generate tests and
documentation from a common source.

License: MIT

For more information, see:

http://guppy-pe.sourceforge.net

Best Regards,

Sverker Nilsson
[EMAIL PROTECTED]

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

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


Re: ftplib question - ftp.dir() returns something and ftp.nlst() does not

2005-11-25 Thread Nico Grubert
 add
 
 ftp.set_debuglevel(3)
 
 so you can see what the goes on the wire (without that information, it's hard
 to tell if it's a bug in the library or a glitch in your server).
 
 /F 

Hello Fredrik ,

thank you for your reply. I did a ftp.set_debuglevel(3) and ftp.nlst() 
now prints:

  ftp.nlst()
*cmd* 'TYPE A'
*put* 'TYPE A\r\n'
*get* '200 Type set to I.\r\n'
*resp* '200 Type set to I.'
*cmd* 'PORT 10,30,1,31,128,129'
*put* 'PORT 10,30,1,31,128,129\r\n'
*get* '200 PORT command Ok.\r\n'
*resp* '200 PORT command Ok.'
*cmd* 'NLST'
*put* 'NLST\r\n'
*get* '150 About to open data connection.\r\n'
*resp* '150 About to open data connection.'
*retr* ''
*get* '226 Transfer complete.\r\n'
*resp* '226 Transfer complete.'
[]
 

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


Re: defining the behavior of zip(it, it) (WAS: Converting a flatlist...)

2005-11-25 Thread Fredrik Lundh
Steve Holden wrote:

 Now, see, that's the thing. The more ways there are to write the same
 program, the harder any given program will be to understand.

 This is indeed a fairly deliberate approach in the Python world, and
 contrasts with languages where readability is low because of the
 multiple different ways of expressing the same idea.

you can express ideas in many ways in Python (just witness all the web
frameworks and xml toolkits ;-).  the deliberate approach you're referring
to is more about using a consistent spelling.

seriously, if anyone has a job so boring that his only way to express his
creativity is to be able call a trivial library operation in many different
ways somewhere deep inside his program, his problems are a lot more
fundamental than the choice of programming language.

(in a way, this is related to what creative programmers sometimes refer
to as python's pencil-like qualities; the fact that once you've grokked
python's way to do things, the language pretty much disappears from
sight.  *your* ideas is what matters.  see e.g. the venners interview
with bruce eckel:

http://www.artima.com/intv/aboutme.html
http://www.artima.com/intv/prodperf.html
http://www.artima.com/intv/typing.html
http://www.artima.com/intv/tipping.html

for more on this.

here's the keynote they're referring to, btw:

http://www.mindview.net/FAQ/FAQ-012

/F



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


Re: defining the behavior of zip(it, it) (WAS: Converting a flat list...)

2005-11-25 Thread Steve Holden
Magnus Lycka wrote:
 [EMAIL PROTECTED] wrote:
 
Oh, find a need to shut other up ?

 
 Oh, find a need to get the last word?
 
 /Magnus
 
 P.S. Yes, this *is* a test.

Looks like you hooked him, Magnus ;-)
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006  www.python.org/pycon/

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


Re: Why is dictionary.keys() a list and not a set?

2005-11-25 Thread [EMAIL PROTECTED]

Duncan Booth wrote:
 [EMAIL PROTECTED] wrote:

  As for the (k,v) vs (v,k), I still don't think it is a good example. I
  can always use index to access the tuple elements and most other
  functions expect the first element to be the key. For example :
 
  a=d.items()
  do something about a
  b = dict(a)
 
  But using the imaginary example :
 
  a = zip(d.values(), d.keys())
  do something about a
  b = dict(a) # probably not what I want.
 

 The typical use case for the (v,k) tuple would be when you want sort the
 contents of a dictionary by value. e.g. counting the number of occurrences
 of each word in a document.

 a = zip(d.values(), d.keys())
 a.sort()
 a.reverse()
 print Today's top 10:
 print str.join(',', [ k for (v,k) in a[:10]])

 Ok, so today you can do that another way, but before there was a key
 parameter to sort you had to build the tuple somehow:

 print str.join(',', sorted(a.iterkeys(),
key=a.__getitem__, reverse=True)[:10])

 and the advantage of the latter is of course that it works even when you've
 been counting the number of occurences of complex numbers in a document :)

Thanks, so for newer python(2.3+?, don't know when the sort has been
enhanced), this (v,k) is again there for historical reason but not a
real use case any more.

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


Re: Why are there no ordered dictionaries?

2005-11-25 Thread Fuzzyman

Christoph Zwerschke wrote:
 Fuzzyman schrieb:
  d.keys() will still return a copy of the list, so d.keys()[i] will
  still be slower than d.sequence[i]

 Right, I forgot that.  Bengt suggested to implement __call__ as well as
 __getitem__ and __setitem__ for keys, values and items.

 In this case, you could very effectively access it as d.values[i].


That means making keys, values, and items custom objects.
Creating a new instance would have the overhead of creating 4 new
objects instead of just 1. Is the added convenience worth it ? (Plus
the extra layers of method calls for each access).

I'm not sure. It's a nice idea in terms of using it (we could just
leave the sequence attribute as an alias for the new keys attribute -
for backwards compatibility).

All the best,



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

 -- Christoph

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


Re: Draw a triangle...

2005-11-25 Thread Fredrik Lundh
The Eternal Squire wrote:

 PyGame is your best bet for pure graphics.  Simple shapes can be done
 in just a few statements.

the same applies to Tkinter, of course.

from Tkinter import *

# set things up
c = Canvas(); c.pack()

# draw stuff
c.create_polygon((0, 100, 50, 0, 100, 100), fill=red)

# get things going
mainloop()

at the draw a triangle level, the main difference is mostly that
Tkinter is a bit more likely to be installed on your machine...

/F



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


Re: Python as Guido Intended

2005-11-25 Thread Antoon Pardon
Op 2005-11-24, Mike Meyer schreef [EMAIL PROTECTED]:
 Antoon Pardon [EMAIL PROTECTED] writes:
 The usual response is That's not the Python way. That's not calling
 someone dumb, just pointing out that they don't yet fully understand
 the Python way.
 That is not the Python way, is just saying Python doesn't have it
 in other words. So it can't be the answer to why python can't have
 something.

 No, it isn't. At least, it isn't when I use it. A language is more
 than just an accumulation of features. Well, a good language is more
 than just an accumulation of features - there's a philosophy
 underlying the language, that guides what features are added and what
 features aren't. Other languages have other philosophies, and wind up
 being good for other things.

But how this philosophy influences design is not straight forward.

The ternary operator was thought of to go against the philosopy,
and now seems to be at least compatible with the philosophy.

So when someone asks why it is not in python, saying It is not
the python way still doesn't answer the question, because the
person would probably still like to know what in his proposal
is against the python philosophy and why.

 When I say That's not the Python way, I mean that such a feature
 runs counter to my vision of Python's underlying philosophy.

Fine, but it would help if you could support this with arguments
or at least give an explanation of why you think this is so.

 My vision
 isn't perfect - I've changed my mind about things: I used to want real
 macros, and I initially disliked list comprehensions. My vision
 doesn't agree with the developers - notably including Guido's - a lot
 of the time. On the other hand, they haven't done anything that
 strikes me as so wrong that I want to spend the time required working
 on Python rather than in Python to allow me to get it fixed.

I see nothing wrong with that. But I would apreciate it, should
you be more open about something being your personal vision.
To me something like: That is not the python way comes accross
as: You just don't understand about python, if you ask/propose
something like that It gives me the feeling the person is
saying something like: Python is like this, I like it this
way, so nobody better suggests this changes.

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


Re: defining the behavior of zip(it, it) (WAS: Converting a flat list...)

2005-11-25 Thread [EMAIL PROTECTED]

Steve Holden wrote:
 Magnus Lycka wrote:
  [EMAIL PROTECTED] wrote:
 
 Oh, find a need to shut other up ?
 
 
  Oh, find a need to get the last word?
 
  /Magnus
 
  P.S. Yes, this *is* a test.
 
 Looks like you hooked him, Magnus ;-)
and he is permenantly hooked

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


Re: Why are there no ordered dictionaries?

2005-11-25 Thread Christoph Zwerschke
Le ruego me perdone.

replace('haber', random.choice('tener', 'hacer', 'lograr'))

Mi espanol es peor que mi python.

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


Re: return in loop for ?

2005-11-25 Thread Steve Holden
Steven D'Aprano wrote:
 On Thu, 24 Nov 2005 12:51:34 +, Duncan Booth wrote:
 
 
Steven D'Aprano wrote:


While outwardly they apear to offer a technique for making software
more reliable there are two shortcomings I'm leery of. First, no
verification program can verify itself; 

That's not a problem if there exists a verification program A which
can't verify itself but can verify program B, which in turn also can't
verify itself but will verify program A.


That is logically equivalent to the first case, so it doesn't get you 
anywhere. (Just combine A and B into a single program which invokes A 
unless the input is A when it invokes B instead.)
 
 
 Then there you go, there is a single program which can verify itself.
 
 I think you are confabulating the impossibility of any program which can
 verify ALL programs (including itself) with the impossibility of a program
 verifying itself. Programs which operate on their own source code do not
 violate the Halting Problem. Neither do programs which verify some
 subset of the set of all possibly programs.
 
 
There seems to have been some misattribution in recent messages, since I 
believe it was *me* who raised doubts about a program verifying itself. 
This has nothing to do with the Halting Problem at all. A very simple 
possible verification program is one that outputs True for any input. 
This will also verify itself. Unfortunately its output will be invalid 
in that and many other cases.

I maintain that we cannot rely on any program's assertions about its own 
formal correctness.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006  www.python.org/pycon/

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


Re: ftplib question - ftp.dir() returns something and ftp.nlst() does not

2005-11-25 Thread Fredrik Lundh
Nico Grubert wrote:

 *cmd* 'NLST'
 *put* 'NLST\r\n'
 *get* '150 About to open data connection.\r\n'
 *resp* '150 About to open data connection.'
 *retr* ''
 *get* '226 Transfer complete.\r\n'
 *resp* '226 Transfer complete.'
 []
  

it's not obvious how Python could translate '' to anything other
than an empty list, so it sure looks like a server issue.

(or is a problem with running in passive mode?  can you test with-
out using passive mode on the same server?)

/F



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


Re: Python as Guido Intended

2005-11-25 Thread Antoon Pardon
Op 2005-11-24, Mike Meyer schreef [EMAIL PROTECTED]:
 [EMAIL PROTECTED] writes:
 Mike Meyer [EMAIL PROTECTED] writes:
 [EMAIL PROTECTED] writes:
  Different programming styles are appropriate for different
  tasks, different times and different places, different people.
  And like morality, government, or economics, I do not believe
  that one style of programming fits all situations.
 If I read you right, what you're saying is that hammmers aren't good
 at driving screws. I don't think anyone would argue about that.
 No, the analogy is more like this.  Python is hammer that comes
 in green or blue.  The hammer's developers say (perhaps with
 some reason) that cool colors like green and blue are the best
 colors because they promote calm when used.  Calm hammerers
 are more productive and less violent.  My work is
 repairing the inside of dark water tanks.  It is hard to see blue
 and green hammers, and to find them if I put them down.
 I suggest that Python have the option of red hammers.

 So you're suggesting a fundamental change to the nature of
 Python. It's inherently a blue/green language. Making it available in
 Red violates the spirit and philosphy of the language, which is why:

Well this is, is one thing I have a problem with.

The python people seem to be more concerned with fighting things
that could be used counter the python philosophy, than search for
things that enable working in the python philosophy.

Why did it take so long before a ternary operator was introduced?
Because it was thought it could be too easily abused. The fact
that there was also good use for a ternary operator within the
spirit of Python was regarded as less important.

 The Python people respond with horror, pointing out the problems
 with red hammers.

 In other words, there are reasons that python doesn't come in red, and
 they will gladly tell you what they are.

 Regarding the differences between hammers and screwdrivers...
 When a screwdriver is appropriate I use a screwdriver.  If I
 need to write code that does a large amount of CPU intensive
 number crunching, I use C, not Python.

 Yes. And if you need a red hammmer, you should get a red hammer, not
 use red spray paint on one that wasn't designed to be red. Just
 because *you* don't see how providing a red option violates the
 philosophy of python doesn't mean that it doesn't do so.

Well this seems to be the main conflict between those who would
like Python to go a bit further and those that oppose it.

Should the priority be to enable python's philosophy or should
it be the priority to limit python to only allow it's philosophy.

One groups seems to think that python's spirit is not broken
by allowing things that seem counter to it, as long as people
can without much trouble, work within that spirit.

An other group seems to think that any allowance to disgress
from python's spirit is an assault on it.

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


Re: Python as Guido Intended

2005-11-25 Thread Antoon Pardon
Op 2005-11-24, Delaney, Timothy (Tim) schreef [EMAIL PROTECTED]:

 And this is the crux of it - the majority of such proposals come from
 people who apparently haven't actually used python that much, and are
 trying to impose things from other languages onto it. There's nothing
 wrong with bringing concepts across from other languages (look at the
 generators history), but you need to understand how it will fit with
 python before proposing it as a new feature.

Why?

To propose generators in Python (before they were present) would seem to
me a valuable suggestion even if the proposer didn't understand how it
will fit.

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


Re: Why are there no ordered dictionaries?

2005-11-25 Thread Fuzzyman
Sure - that was just an example of mutating the keys list without
having direct access to it.

If keys was implemented as an object (with a ``__call__`` method) then
we could also implement sequence methods on it - making it easier to
mutate the keys/values/items directly.

All the best,

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

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


problem compiling executable with py2exe

2005-11-25 Thread tim
I wrote this very simple program that checks a directory and makes a
list of files that surpass a given size.
I tried to compile it using py2exe.
I used py2exe before with more complex programs without any problem.
Now, although my program works fine when I run it from PythonWin, it
won't compile to an executable.

here's the program:

#
import os

blacklist=[]
d=raw_input('path')
s=int(raw_input('maxsize (in bytes):'))
f = os.listdir(d)
outfile = open(d + r'\filelist_for_this_location.txt', 'wb')
outfile.write('files found in ' + d + '\n'+ 'checking maximum filesize:
' + str(s) + ' bytes...\n')
for n in f:
filepath = os.path.join(d,n)
if os.path.isfile(filepath):
outfile.write(n + '\n')
currsize = int(os.path.getsize(filepath))
if currsize = s:
outfile.write(' is too big\n')
blacklist.append(filepath)
outfile.write('\n'+'\n'+ 'blacklist\n')
for bl in blacklist:
outfile.write(bl + '\n')
outfile.close()
##

here's the py2exe error log:

Traceback (most recent call last):
  File filesizechecker.py, line 4, in ?
EOFError: EOF when reading a line

any idea?

Tim



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


Re: Guification of console app

2005-11-25 Thread Steve Holden
metiu wrote:
 Say I have a console app that does something in three steps:
 - opens a file
 - transfers the file through a serial port
 - does some elaborations
 
 and I want to build a GUI around it that, for example, sets the file
 name to open or starts the different steps.
 
 I started using wxPython (actually boa-constructor) to build a frame
 with everything I want.
 The problem is: when the console app method is working, the GUI is
 locked...
 
 How can the console app communicate with the GUI in order to make it
 tick (think of status messages, progress bars, log messages...)?
 If I use threads and events, or wxYield, or EVT_IDLE, I'm tweaking the
 console app so that it won't work just in console anymore.
 
 How do you do that?
 
 Thanks!
 
I've achieved this in the past by having the GUI trigger the console app 
in a separate thread and then use a Queue.Queue to send output from the 
console app to the GUI. As long as the GUI portion is careful never to 
block on an empty Queue this can work quite well.

There's also a cookbook recipe by Jacob Hallen that shows you how to 
keep a Tkinter GUI running with parallel worker threads.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006  www.python.org/pycon/

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


Re: Python as Guido Intended

2005-11-25 Thread [EMAIL PROTECTED]

Antoon Pardon wrote:
 Op 2005-11-24, Mike Meyer schreef [EMAIL PROTECTED]:
  [EMAIL PROTECTED] writes:
  Mike Meyer [EMAIL PROTECTED] writes:
  [EMAIL PROTECTED] writes:
   Different programming styles are appropriate for different
   tasks, different times and different places, different people.
   And like morality, government, or economics, I do not believe
   that one style of programming fits all situations.
  If I read you right, what you're saying is that hammmers aren't good
  at driving screws. I don't think anyone would argue about that.
  No, the analogy is more like this.  Python is hammer that comes
  in green or blue.  The hammer's developers say (perhaps with
  some reason) that cool colors like green and blue are the best
  colors because they promote calm when used.  Calm hammerers
  are more productive and less violent.  My work is
  repairing the inside of dark water tanks.  It is hard to see blue
  and green hammers, and to find them if I put them down.
  I suggest that Python have the option of red hammers.
 
  So you're suggesting a fundamental change to the nature of
  Python. It's inherently a blue/green language. Making it available in
  Red violates the spirit and philosphy of the language, which is why:

 Well this is, is one thing I have a problem with.

 The python people seem to be more concerned with fighting things
 that could be used counter the python philosophy, than search for
 things that enable working in the python philosophy.

 Why did it take so long before a ternary operator was introduced?
 Because it was thought it could be too easily abused. The fact
 that there was also good use for a ternary operator within the
 spirit of Python was regarded as less important.

  The Python people respond with horror, pointing out the problems
  with red hammers.
 
  In other words, there are reasons that python doesn't come in red, and
  they will gladly tell you what they are.
 
  Regarding the differences between hammers and screwdrivers...
  When a screwdriver is appropriate I use a screwdriver.  If I
  need to write code that does a large amount of CPU intensive
  number crunching, I use C, not Python.
 
  Yes. And if you need a red hammmer, you should get a red hammer, not
  use red spray paint on one that wasn't designed to be red. Just
  because *you* don't see how providing a red option violates the
  philosophy of python doesn't mean that it doesn't do so.

 Well this seems to be the main conflict between those who would
 like Python to go a bit further and those that oppose it.

 Should the priority be to enable python's philosophy or should
 it be the priority to limit python to only allow it's philosophy.

 One groups seems to think that python's spirit is not broken
 by allowing things that seem counter to it, as long as people
 can without much trouble, work within that spirit.

 An other group seems to think that any allowance to disgress
 from python's spirit is an assault on it.

And exactly what is python's spirit/philosophy ? It seems to me that
they are often used in a liberal way, just to support one's argument
that whatever is not in the CURRENT python should not be there.

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


Re: Why is dictionary.keys() a list and not a set?

2005-11-25 Thread Christoph Zwerschke
[EMAIL PROTECTED] schrieb:

 And this, again from the doc(about mapping objects):
 A mapping object maps immutable values to arbitrary objects.
 Seems that is questionable too.
 a=(1,[])
 d={}
 d[a]=1
 again would give TypeError, list object are unhashable.

That's a good example showing that the term 'mutable' is not so 
well-defined as it may seem.

If you set b=[]; a=(1,b); should a be considered mutable (because you 
can change its value by changing b), or should it be considered 
immutable (because it is a tuple)?

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


Re: Guification of console app

2005-11-25 Thread metiu
Yes, I'll try to give you an example:
you have a compression utility that works as a standard *nix filter, so
it takes something from stdin and gives it back compressed to stdout
you like to use it as such, because it's nice to call it from the
command line

now someone finds your utility quite nice, and says it would be nice to
have a GUI that shows you, for example, how long it will take to
compress...

one way for sure it would be to fork your app, but this would be a
waste of time

you'd like to reuse the compression library you've already written for
your GUI and your console, but:
- you'd like to have your console app clean and simple, such as:

import sys
import CompressLib

data = sys.stdin.read()
cdata = CompressLib.compress(data)
print cdata

but you'd like the GUI to show some progress and status info.

I guess the way is still to make the compress call split in microsteps
and have the app call it, so you can use an EVT_IDLE call from the GUI,
but maybe there's a better way...

Thanks again



Peter Hansen ha scritto:

 metiu wrote:
  Say I have a console app that does something in three steps:
  - opens a file
  - transfers the file through a serial port
  - does some elaborations
 
  and I want to build a GUI around it that, for example, sets the file
  name to open or starts the different steps.
 
  I started using wxPython (actually boa-constructor) to build a frame
  with everything I want.
  The problem is: when the console app method is working, the GUI is
  locked...
 
  How can the console app communicate with the GUI in order to make it
  tick (think of status messages, progress bars, log messages...)?
  If I use threads and events, or wxYield, or EVT_IDLE, I'm tweaking the
  console app so that it won't work just in console anymore.

 Could you please explain what makes this a console app, specifically?
   You are proposing wrapping a GUI around it, which would make it not a
 console app (by definition), so it would help if you specified exactly
 what elements (which functions, etc.) cause you to label it a console
 app.  (For example, maybe it calls msvcrt.kbhit/getch or something...)

 The reason for asking is that the specifics of your answer will make it
 easier to describe how to modify this console so that the relevant
 parts work equally well as a _real_ console app (no GUI) or with the
 GUI.  We could describe it in more general terms, but it might not be
 apparent how to adapt that to your own case.
 
 -Peter

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


Problem with HtmlWindow and Widgets

2005-11-25 Thread radek_ne
Hello

 I have problem with HtmlWindow and Widgets (wxPython).
When I put on HtmlWindow TextCtrl all is ok, but when I try 
to use ComboBox then all controls not refresh.

Where is problem?

Thenks for help and sorry for my english ;)

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


Re: Why are there no ordered dictionaries?

2005-11-25 Thread Fuzzyman

Alex Martelli wrote:
 Fuzzyman [EMAIL PROTECTED] wrote:

  There is already an update method of course. :-)
 
  Slicing an ordered dictionary is interesting - but how many people are
  actually going to use it ? (What's your use case)

 I detest and abhor almost-sequences which can't be sliced (I consider
 that a defect of collections.deque).  If the ordered dictionary records
 by its sequencing the time order of key insertion, being able to ask for
 the last 5 keys entered or the first 3 keys entered seem to me to be
 perfectly natural use cases, and most naturally accomplished by slicing
 of course, d[-5:] and d[:3] respectively.


If you slice an ordered dictionary, I assume you would expect to get an
ordered dictionary back ?

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

 
 Alex

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


Re: sending all key events to wx.panel?

2005-11-25 Thread Steve Holden
KvS wrote:
 Hi all,
 
 I have a wxPython GUI consisting of a wxWindow - wxPanel - set of
 widgets. I need to catch pressed keys no matter which widget has focus,
 so I've attached an event handler to the panel but I can't seem to find
 a way to do some kind of collective sending through of the key event
 from all the widgets on the panel to that handler in case the panel
 doesn't have focus. Is there some way to do this?
 
 Thanks in advance!
 
 - Kees
 
Why not just attach the event handler to the wxWindow containing the 
panel? If the panel ignores keyboard events they'll just rise to the 
containing window, won't they?

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006  www.python.org/pycon/

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


Re: Why are there no ordered dictionaries?

2005-11-25 Thread Fuzzyman
Sure - that was just an example of mutating the keys list without
having direct access to it.

If keys was implemented as an object (with a ``__call__`` method) then
we could also implement sequence methods on it - making it easier to
mutate the keys/values/items directly.

All the best,

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

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


Re: Draw a triangle...

2005-11-25 Thread [EMAIL PROTECTED]

Fredrik Lundh wrote:
 The Eternal Squire wrote:

  PyGame is your best bet for pure graphics.  Simple shapes can be done
  in just a few statements.

 the same applies to Tkinter, of course.

 from Tkinter import *

 # set things up
 c = Canvas(); c.pack()

 # draw stuff
 c.create_polygon((0, 100, 50, 0, 100, 100), fill=red)

 # get things going
 mainloop()

 at the draw a triangle level, the main difference is mostly that
 Tkinter is a bit more likely to be installed on your machine...
Out of curiousity :

why not :
  c = Canvas()
  c.pack()

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


Re: Making immutable instances

2005-11-25 Thread Paul Rubin
Mike Meyer [EMAIL PROTECTED] writes:
 There isn't a standard serialize method in Python, so I don't know how
 you want to define it.

Well, consider pickle, for example.

 I can think of perfectly reasonable definitions
 of serialize where obj.serialize() won't always return the same string
 on an immutable object, even if you don't allow adding attributes.

Fair enough.  How's this:

   a = ImmutableObject()
   b = deepcopy(a)
   assert a == b  # a and b start out equal
    do stuff 
   # since a and b are immutable, they should still be equal
   # no matter what has happened above
   assert a == b

If you've added attributes to a but not to b, they should compare
unequal, breaking immutability.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Making immutable instances

2005-11-25 Thread [EMAIL PROTECTED]

Paul Rubin wrote:
 Fair enough.  How's this:

a = ImmutableObject()
b = deepcopy(a)
assert a == b  # a and b start out equal
 do stuff 
# since a and b are immutable, they should still be equal
# no matter what has happened above
assert a == b

 If you've added attributes to a but not to b, they should compare
 unequal, breaking immutability.

How about this ?

a=(1,[])
b=copy.deepcopy(a)
assert a==b # True
a[1].append(1)
assert a!=b

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


Re: return in loop for ?

2005-11-25 Thread Steve Holden
Steven D'Aprano wrote:
 On Thu, 24 Nov 2005 12:51:34 +, Duncan Booth wrote:
 
 
Steven D'Aprano wrote:


While outwardly they apear to offer a technique for making software
more reliable there are two shortcomings I'm leery of. First, no
verification program can verify itself; 

That's not a problem if there exists a verification program A which
can't verify itself but can verify program B, which in turn also can't
verify itself but will verify program A.


That is logically equivalent to the first case, so it doesn't get you 
anywhere. (Just combine A and B into a single program which invokes A 
unless the input is A when it invokes B instead.)
 
 
 Then there you go, there is a single program which can verify itself.
 
 I think you are confabulating the impossibility of any program which can
 verify ALL programs (including itself) with the impossibility of a program
 verifying itself. Programs which operate on their own source code do not
 violate the Halting Problem. Neither do programs which verify some
 subset of the set of all possibly programs.
 
 
There seems to have been some misattribution in recent messages, since I 
believe it was *me* who raised doubts about a program verifying itself. 
This has nothing to do with the Halting Problem at all. A very simple 
possible verification program is one that outputs True for any input. 
This will also verify itself. Unfortunately its output will be invalid 
in that and many other cases.

I maintain that we cannot rely on any program's assertions about its own 
formal correctness.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006  www.python.org/pycon/

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


Re: Why is dictionary.keys() a list and not a set?

2005-11-25 Thread Christoph Zwerschke
As a general note, I think it would be good to place the exact 
description in a footnote, since speaking about hashable objects, 
__hash__ and __cmp__ will certainly frighten off newbies and make it 
hard to read even for experienced users. The main text may lie/simplyfy 
a little bit.

Or as Donald Knuth once recommended:

Simplify. Lie, if it helps. You can add the correct details later on, 
but it is essential to present the reader with something straightforward 
to start off with. So don’t be afraid to bend the facts initially where 
this leads to a useful simplification and then pay back the debt to 
truth later by gradual elaborations.

However, since the Python docs are a reference and not a textbook or 
manual, I think the debt should not be payed back later, but 
immediately in a footnote.

The docs already follow this principle very well, e.g.:
http://docs.python.org/lib/typesmapping.html

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


Re: Guification of console app

2005-11-25 Thread Fredrik Lundh
metiu wrote:

 you have a compression utility that works as a standard *nix filter, so
 it takes something from stdin and gives it back compressed to stdout
 you like to use it as such, because it's nice to call it from the
 command line

 now someone finds your utility quite nice, and says it would be nice to
 have a GUI that shows you, for example, how long it will take to
 compress...

 one way for sure it would be to fork your app, but this would be a
 waste of time

 you'd like to reuse the compression library you've already written for
 your GUI and your console, but:
 - you'd like to have your console app clean and simple, such as:

 import sys
 import CompressLib

 data = sys.stdin.read()
 cdata = CompressLib.compress(data)
 print cdata

 but you'd like the GUI to show some progress and status info.

here's a simple, stupid, and portable solution.  the first script simulates
your compression utility:

# compress.py (simulator)

import time, sys

for i in range(100):
sys.stdout.write(.)
sys.stderr.write(%d%% done\r % i)
sys.stderr.flush()
time.sleep(0.1)

(it prints N% done messages to stderr during the compression)

the second script simulates your GUI.  the stuff in the while loop should
be run by a timer/alarm function, at regular intervals:

import re, subprocess, time, os

class monitor:
# looks for N% done messages in the output stream
def __init__(self, tfile):
# could use dup/reopen instead
self.file = open(tfile.name, r)
def poll(self):
pos = self.file.tell()
data = self.file.read()
if data:
data = re.findall((\d+)% done, data)
if not data:
self.file.seek(pos)
else:
return int(data[-1])
def close(self):
self.file.close()

ifile = open(in.txt, rb)
ofile = open(out.dat, wb)
tfile = open(out.tmp~, wb)

p = subprocess.Popen(
python compress.py,
stdin=ifile, stdout=ofile, stderr=tfile,
)

m = monitor(tfile)

while 1:
# this should be placed in a background task that's called
# every second or so
if p.poll() is not None:
print DONE
break
status = m.poll()
if status is not None:
# update status monitor
print status, PERCENT DONE
# wait a while before calling the background task again
print .
time.sleep(0.5)

# clean up
ifile.close()
ofile.close()
m.close()
name = tfile.name
tfile.close()
os.remove(name)

if you limit yourself to Unix only, you can simplify things quite a bit (e.g.
using a pipe instead of the temporary file and use select to poll it, or use
dup/reopen tricks to avoid opening the temporary file twice; if you do
the latter, you can also use safe tempfile creation methods (see the
tempfile method for details.  etc).

hope this helps!

/F



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


Re: Writing big XML files where beginning depends on end.

2005-11-25 Thread Ben Sizer
Magnus Lycka wrote:

 This won't help if we have problems keeping the whole
 structure / call graph in memory at one time.

Ah, I had assumed that the main problem was just that the resulting DOM
was too big. Still, I don't think there would be a problem if you just
constructed a very small tree and then wrote out XML based upon that,
instead of using an external library for this. For example, if your
only elements are node and leaf, you can store that distinction in 1
bit, as opposed to a library's naive implementation using the strings
node and leaf, probably 40 bits in each case. Similarly you can
calculate the aggregate attributes on the fly when it comes to
outputting the tree instead of storing them.

-- 
Ben Sizer

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


Re: ftplib question - ftp.dir() returns something and ftp.nlst() does not

2005-11-25 Thread Nico Grubert
  it's not obvious how Python could translate '' to anything other
  than an empty list, so it sure looks like a server issue.

  (or is a problem with running in passive mode?  can you test with-
  out using passive mode on the same server?)


I thought using ftp.set_pasv(0) sets active mode so I can use 
ftp.anyMethod() wihtout using passive mode?

I tried:

  ftp.set_pasv(0)
  ftp.nlst()
*cmd* 'TYPE A'
*put* 'TYPE A\r\n'
*get* '200 Type set to I.\r\n'
*resp* '200 Type set to I.'
*cmd* 'PORT 10,30,1,31,128,19'
*put* 'PORT 10,30,1,31,128,19\r\n'
*get* '200 PORT command Ok.\r\n'
*resp* '200 PORT command Ok.'
*cmd* 'NLST'
*put* 'NLST\r\n'
*get* '150 About to open data connection.\r\n'
*resp* '150 About to open data connection.'
*retr* ''
*get* '226 Transfer complete.\r\n'
*resp* '226 Transfer complete.'
[]
  ftp.dir()
-r--r--r--   1 ownergroup  121984 Nov 24 12:13 member.dat
-r--r--r--   1 ownergroup 115 Nov 24 15:53 status.dat
-r--r--r--   1 ownergroup 339 Nov 24 15:53 debug.txt
 


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


Re: Python as Guido Intended

2005-11-25 Thread Ben Sizer
Delaney, Timothy (Tim) wrote:
 It is without a doubt though incumbent on anyone proposing new
 *features* to have a solid understanding of what they are proposing,
 what it would affect, any backwards incompatibilities, and whether it
 fits into the python philosophy (import this).

Sure. However, I wasn't just thinking about feature suggestions, but
about times when people are asking about the best algorithm to use or
why Python doesn't have something they used to rely upon in another
language.

 And this is the crux of it - the majority of such proposals come from
 people who apparently haven't actually used python that much, and are
 trying to impose things from other languages onto it.

The problem you get, is that the only people who are ever likely to
need to ask questions, are those who don't fully understand Python, by
definition. Often the answer they get is unintuitive to anyone not
familiar with Python, but occasionally you are additionally treated as
if you should have known and that thinking otherwise is a bit stupid,
which is a bit unfair.

In some cases, the question is quite valid, but the Python community
has ossified around their own particular approach, which is not
necessarily optimal but seems to be enough for all concerned. (eg. the
proliferation of web frameworks that holds Python back as a platform in
that area.)

-- 
Ben Sizer

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


Re: Why are there no ordered dictionaries?

2005-11-25 Thread Christoph Zwerschke
Fuzzyman wrote:

 That means making keys, values, and items custom objects.
 Creating a new instance would have the overhead of creating 4 new
 objects instead of just 1. Is the added convenience worth it ? (Plus
 the extra layers of method calls for each access).

I'm not sure about that either. But since you are using odict for 
convenience reasons anyway, and not for performance reasons, it would be 
consequential. Performance testing should be made anyway, so this could 
be tested as well. I think that creating these 3 additional objects will 
not matter much if the dict has more than a handful of items. And the 
extra layers will be only called if you really access these keys, values 
or items attributes which will not happen very frequently. Normally, you 
just loop over an ordered directory and acess keyed values.

 I'm not sure. It's a nice idea in terms of using it (we could just
 leave the sequence attribute as an alias for the new keys attribute -
 for backwards compatibility).

Yes, you could make it a deprecated feature.

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


books: Dive into Python vs Beginning Python

2005-11-25 Thread Franz Mueller
Hi,

which of the following books would you recommend:
Dive into Python or Beginning Python: From Novice to Professional?

I'm an experienced C++-programmer who wants to take a look at Python.

Thanks,
Franz 


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


How to use _ in interactive mode

2005-11-25 Thread pythonic
Hi,

I use '_' for localization in my program. The problem is when testing
the program using python intractive mode I lose _ function.
One solution is put following in PYTHONSTARTUP file.
--
import readline
def __enforce_underscore__ (): __builtins__._ = str
readline.set_pre_input_hook (__enforce_underscore__)
--

My program in startup imports a module which customize the env.
Putting above in that module doesn't solve the problem.  Any
cleaner/better way?
Honestly, I was expecting once overriden _ in builtins it would be honored.

This how I reproduce the problem.

Python 2.3.3 (#1, May  7 2004, 10:31:40)
 def localizer(s): return str(s)
 __builtins__.__dict__['_'] = localizer
 _
function localizer at 0xb7f6e844
 _('some text')
'some text'
 _
'some text'
 _('some text')
Traceback (most recent call last):
  File stdin, line 1, in ?
TypeError: 'str' object is not callable

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


Python book for a non-programmer

2005-11-25 Thread Simon Brunning
I have a non-programming friend who wants to learn Python. It's been
so long since I've been in her shoes that I don't feel qualified to
judge the books aimed at people in her situation. I know of two such
books:

http://www.freenetpages.co.uk/hp/alan.gauld/
http://www.ibiblio.org/obp/thinkCSpy/

Any recommendations, or otherwise?

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python as Guido Intended

2005-11-25 Thread Fredrik Lundh
Ben Sizer wrote:

 The problem you get, is that the only people who are ever likely to
 need to ask questions, are those who don't fully understand Python, by
 definition.

really?  I'd say that most people that ask questions on comp.lang.python
do understand Python pretty well, and just needs help with some esoteric
detail, or some part of a library that they haven't used before.  And the
most common response is oh, that's cool.  thanks.  The I'm personally
offended by the very design of the feature you just pointed me to kind of
person is not very common; most people don't have that kind of ego pro-
blem, and even those who do usually don't have time for that kind of crap.

Fact is, most people see Python as a tool, use it where it fits, and focus on
the problems they need the tool for.

And yes, most Python users never gets anywhere near comp.lang.python.

/F 



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


Re: Python book for a non-programmer

2005-11-25 Thread shane . mitchell
http://www.python.org/doc/Intros.html

and two great texts when she has covered the basics are:

http://diveintopython.org/

http://www.mindview.net/Books/TIPython

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


Re: problem compiling executable with py2exe

2005-11-25 Thread Fredrik Lundh
tim [EMAIL PROTECTED] wrote:

 I used py2exe before with more complex programs without any problem.
 Now, although my program works fine when I run it from PythonWin, it
 won't compile to an executable.

are you sure you're generating a console executable?  your program needs
access to the console:

 d=raw_input('path')
 s=int(raw_input('maxsize (in bytes):'))

but

 Traceback (most recent call last):
  File filesizechecker.py, line 4, in ?
 EOFError: EOF when reading a line

indicates that it doesn't have one.

/F 



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


Re: Python book for a non-programmer

2005-11-25 Thread BartlebyScrivener

Simon Brunning wrote:
 I have a non-programming friend who wants to learn Python. It's been
 so long since I've been in her shoes that I don't feel qualified to
 judge the books aimed at people in her situation. I know of two such
 books:

 http://www.freenetpages.co.uk/hp/alan.gauld/
 http://www.ibiblio.org/obp/thinkCSpy/

 Any recommendations, or otherwise?

 --
 Cheers,
 Simon B,
 [EMAIL PROTECTED],
 http://www.brunningonline.net/simon/blog/

If you want real (dead-tree) books, you will find Chris Fehily's Visual
Quickstart Guide recommended by others here  (though it's ageing -
2002). I'm about 2/3 through and it's been great for me:

http://www.amazon.com/exec/obidos/asin/0201748843/richarddooling/

And a brand new one which I just ordered: Beginning Python (Programmer
To Programmer) which despite the title has a great intro to programming
before it quickly accelerates:

http://www.amazon.com/exec/obidos/asin/0764596543/richarddooling/

Cheers,

bs

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


Re: sending all key events to wx.panel?

2005-11-25 Thread KvS
I've tried, by setting

self.Bind(wx.EVT_CHAR, self.handleKeybEv, self)

in the top level frame, but still this only works if the panel has
focus and not if e.g. a button on the panel has focus while a key is
pressed...

In the meantime I found this:

In some cases, it might be desired by the programmer to get a certain
number of system events in a parent window, for example all key events
sent to, but not used by, the native controls in a dialog. In this
case, a special event handler will have to be written that will
override ProcessEvent() in order to pass all events (or any selection
of them) to the parent window.

in wxPython docupart on event handling. Anybody who has done something
like that before?

- Kees

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


Stealing focus: emacs, and PIL, in Windows

2005-11-25 Thread damonwischik
I'm using GNU Emacs 21.3.1 with python-mode 1.0alpha under Windows XP.
Whenever I execute a command in an edit window (with
py-execute-region), the output window steals the focus. How can I stop
this happening?

I don't know any lisp, but I hacked together this routine so that that
when I press ctrl+return the entire current block is executed.

(defun py-execute-paragraph (vis)
  Send the current paragraph to Python
Don't know what vis does.
  (interactive P)
  (save-excursion
(forward-paragraph)
(let ((end (point)))
  (backward-paragraph)
  (py-execute-region (point) end 
(global-set-key [(ctrl return)] 'py-execute-paragraph)

It seems to me (though I could well be wrong) that the focus stays in
the edit window during the execution of this command (thanks to
save-excursion); but the focus shifts to the command window whenever
there is output, in this case a new prompt , in the routine
py-comint-output-filter-function. I commented out the command
  (pop-to-buffer (current-buffer))
and now the command window no longer steals focus. But I don't know if
this has any other side effects, or it there's a better way to prevent
focus being stolen.

Damon.

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


Stealing focus: PIL

2005-11-25 Thread damonwischik
I'm using the Python Image Library (PIL) for Python 2.4.

If I have an image and I show it
  from PIL import Image
  im = Image.new('RGB',100,100)
  im.show()
then the output window steals focus. It's very handy to use
an image to show the progress of execution for my program,
but the computer is unusable when focus keeps on being stolen
every few seconds. How can I prevent Image.show() from stealing
focus?

Damon.

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


Re: Guification of console app

2005-11-25 Thread metiu
I like it! Thanks!

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


Re: books: Dive into Python vs Beginning Python

2005-11-25 Thread bruno at modulix
Franz Mueller wrote:
 Hi,
 
 which of the following books would you recommend:
 Dive into Python or Beginning Python: From Novice to Professional?

I can't recommand the second since I've never read it. But you can
freely make your own opinion on the first, since it's freely available
online.


 I'm an experienced C++-programmer who wants to take a look at Python.

Then I'd say that Dive into Python may be a good choice.

Welcome BTW

-- 
bruno desthuilliers
python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in '[EMAIL PROTECTED]'.split('@')])
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python book for a non-programmer

2005-11-25 Thread Simon Brunning
On 25 Nov 2005 03:23:33 -0800, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:
 http://www.python.org/doc/Intros.html

 and two great texts when she has covered the basics are:

 http://diveintopython.org/

 http://www.mindview.net/Books/TIPython

I wouldn't have thought either of those was suitable for a
non-programmer. Great for cross-trainers, yes, but neither is intended
as a programming tutorial.

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python book for a non-programmer

2005-11-25 Thread Luis M. Gonzalez
Read my reply here from another thread:
http://groups.google.com/group/comp.lang.python/browse_thread/thread/25aada3c22ce6e66/cc69fd0c78384e5b?q=luis+cogliati'srnum=1#cc69fd0c78384e5b

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


Singleton and C extensions

2005-11-25 Thread Emmanuel Briot

I am participating in the development of a GPL IDE
   https://libre2.adacore.com/gps/

It is written in Ada, but provides an extensive extensibility through
Python.

I am not really good at python, but I was trying to implement the
singleton design pattern in C, so that for instance calling the constructor

   ed = Editor (foo)

would either return an existing instance of Editor currently editing
foo, or would create a new instance. Basically, one python instance is
stored inside each of the visual windows representing an editor, and I
want to get that instance if it already exists, instead of creating a
new one each time.

I basically would like
ed = Editor (foo)
ed.attribute = whatever
print Editor (foo).attribute

to print whatever


Has any one an example on how to do that in C, or maybe even at the
python level itself, and I will try to adapt it ?

Thanks in advance

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


Re: Guification of console app

2005-11-25 Thread Chris Mellon
On 11/25/05, Fredrik Lundh [EMAIL PROTECTED] wrote:
 metiu wrote:

  you have a compression utility that works as a standard *nix filter, so
  it takes something from stdin and gives it back compressed to stdout
  you like to use it as such, because it's nice to call it from the
  command line
 
  now someone finds your utility quite nice, and says it would be nice to
  have a GUI that shows you, for example, how long it will take to
  compress...
 
  one way for sure it would be to fork your app, but this would be a
  waste of time
 
  you'd like to reuse the compression library you've already written for
  your GUI and your console, but:
  - you'd like to have your console app clean and simple, such as:
 
  import sys
  import CompressLib
 
  data = sys.stdin.read()
  cdata = CompressLib.compress(data)
  print cdata
 
  but you'd like the GUI to show some progress and status info.

 here's a simple, stupid, and portable solution.  the first script simulates
 your compression utility:

 # compress.py (simulator)

 import time, sys

 for i in range(100):
 sys.stdout.write(.)
 sys.stderr.write(%d%% done\r % i)
 sys.stderr.flush()
 time.sleep(0.1)

 (it prints N% done messages to stderr during the compression)

 the second script simulates your GUI.  the stuff in the while loop should
 be run by a timer/alarm function, at regular intervals:

 import re, subprocess, time, os

 class monitor:
 # looks for N% done messages in the output stream
 def __init__(self, tfile):
 # could use dup/reopen instead
 self.file = open(tfile.name, r)
 def poll(self):
 pos = self.file.tell()
 data = self.file.read()
 if data:
 data = re.findall((\d+)% done, data)
 if not data:
 self.file.seek(pos)
 else:
 return int(data[-1])
 def close(self):
 self.file.close()

 ifile = open(in.txt, rb)
 ofile = open(out.dat, wb)
 tfile = open(out.tmp~, wb)

 p = subprocess.Popen(
 python compress.py,
 stdin=ifile, stdout=ofile, stderr=tfile,
 )

 m = monitor(tfile)

 while 1:
 # this should be placed in a background task that's called
 # every second or so
 if p.poll() is not None:
 print DONE
 break
 status = m.poll()
 if status is not None:
 # update status monitor
 print status, PERCENT DONE
 # wait a while before calling the background task again
 print .
 time.sleep(0.5)

 # clean up
 ifile.close()
 ofile.close()
 m.close()
 name = tfile.name
 tfile.close()
 os.remove(name)

 if you limit yourself to Unix only, you can simplify things quite a bit (e.g.
 using a pipe instead of the temporary file and use select to poll it, or use
 dup/reopen tricks to avoid opening the temporary file twice; if you do
 the latter, you can also use safe tempfile creation methods (see the
 tempfile method for details.  etc).

 hope this helps!

 /F



If you are using wxPython, you can skip writing this scaffolding
yourself and use wx.Execute and wx.Process, which will allow you to
execute other processes and re-direct thier input and output. The
wxPython demo has an example.


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

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


Persist a class (not an instance)

2005-11-25 Thread Kent Johnson
Is there a way to persist a class definition (not a class instance, the actual 
class) so it can be restored later? A naive approach using pickle doesn't work:

  import pickle
  class Foo(object):
 ...   def show(self):
 ... print I'm a Foo
 ...
  p = pickle.dumps(Foo)
  p
'c__main__\nFoo\np0\n.'

Hmm, doesn't look too promising. In a new interpreter:

  import pickle
  p='c__main__\nFoo\np0\n.'
  Foo = pickle.loads(p)
Traceback (most recent call last):
  File stdin, line 1, in ?
  File C:\Python24\lib\pickle.py, line 1394, in loads
return Unpickler(file).load()
  File C:\Python24\lib\pickle.py, line 872, in load
dispatch[key](self)
  File C:\Python24\lib\pickle.py, line 1104, in load_global
klass = self.find_class(module, name)
  File C:\Python24\lib\pickle.py, line 1140, in find_class
klass = getattr(mod, name)
AttributeError: 'module' object has no attribute 'Foo'

The idea is to persist classes that are created and modified at runtime.

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


Re: Python book for a non-programmer

2005-11-25 Thread Shane
Simon Brunning wrote:
 I wouldn't have thought either of those was suitable for a
 non-programmer. Great for cross-trainers, yes, but neither is intended
 as a programming tutorial.

I agree, I just thought that the other replies had provided more than
enough resources to cover the basics, so I was just suggesting some
material that could be used when the basics had been absorbed.

Sorry about the confusion.

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


How to get started in GUI Programming?

2005-11-25 Thread peter . mosley
I am trying to learn GUI programming in Python, but have to confess I
am finding it difficult.

I am not an experienced programmer - just someone who from time to
time writes small programs for my use.  Over the years I have moved
from GWBASIC to QBASIC to Visual Basic, and now trying to move across
to a Linux platform.  Python seems to be the best compromise between
the limitations of command line basic programming and the total
incomprehensibility of C.

Googling around it seems the best GUI is either Tkinter or PyGtk.  I
found a book which recommended PyGtk, as it had a graphical design
option,  Glade.  Coming from a VB background I latched onto that and
bought the book (Beginning Python, Wrox), but it was a disappointment
(or more accurately a complete waste of money) - there was
insufficient detail in the text.

I've found the tutorial and reference manual on the PyGtk web site,
but although I've made some progress, I keep reaching points where I
have insufficient background to understand them. Currently I'm stuck
on dialog boxes (the code seems immensely complex for the equivalent of
  MsgBox(Do you really want to do this ,vbYesNo) and I haven't
got it to work properly yet) and loading graphical images in anything
other than their original size, but every new step brings another
struggle

I've seen reference to a Tkinter book - something like 'Python
and Tkinter Programming' but it seems to be out of print and
unavailable.

Can anyone offer any suggestions as to the least painful way forwards?

(Email address was valid once but has long since been abandoned to
spam. Please rely via newsgroup)

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


Re: Singleton and C extensions

2005-11-25 Thread Fredrik Lundh
Emmanuel Briot wrote:

 I am participating in the development of a GPL IDE
   https://libre2.adacore.com/gps/

 It is written in Ada, but provides an extensive extensibility through
 Python.

 I am not really good at python, but I was trying to implement the
 singleton design pattern in C, so that for instance calling the constructor

   ed = Editor (foo)

 would either return an existing instance of Editor currently editing
 foo, or would create a new instance. Basically, one python instance is
 stored inside each of the visual windows representing an editor, and I
 want to get that instance if it already exists, instead of creating a
 new one each time.

 I basically would like
ed = Editor (foo)
ed.attribute = whatever
print Editor (foo).attribute

 to print whatever

 Has any one an example on how to do that in C, or maybe even at the
 python level itself, and I will try to adapt it ?

use a factory function instead of the class, and let the function create an 
editor
instance when needed:

_editors = {}

def Editor(name):
try:
editor = _editors[name]
except KeyError:
editor = _editors[name] = EditorImplementation()
editor.setname(name)
...
return editor

if you really need singleton, click here:

http://www.google.com/search?q=python+borg+pattern

/F 



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


Re: How to get started in GUI Programming?

2005-11-25 Thread Sybren Stuvel
[EMAIL PROTECTED] enlightened us with:
 Googling around it seems the best GUI is either Tkinter or PyGtk.

I'd go for wxPython ;-)

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


Re: wxPython Licence vs GPL

2005-11-25 Thread Paul Boddie
Ed Jensen wrote:

[On proprietary ports of Python...]

 Show me the harm done.

We'll have to wait and see what happens. There's a risk that versions
of Python with different semantics or characteristics to the original
could cause the development of parallel communities, instead of
everyone working on/with the same project. The harm done is
adequately described by paraphrasing your comment on licences: think
how much farther along free software could be if all this energy and
concern weren't expended on separate and sometimes proprietary code
bases.

 Because I think a lot of well meaning software developers writing free
 software don't performance due diligence to determine the true
 motivation behind, and the chilling effect of, the GPL.

Well, despite your protestations, I think the GPL and LGPL are fairly
easy and safe choices for a lot of developers who know enough about
Free Software (ie. haven't just seen the name and thought that's the
thing for me), know what the characteristics of those licences are,
and who don't have the time or legal experience to performance due
diligence.

Meanwhile, all this hippie and chilling effect talk is, I imagine,
like having a discussion on software licensing with some cold war
propagandist.

Paul

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


Help need

2005-11-25 Thread sr_sutar
HI group,

During doing some codeing with python i got the inline error,


def my_word( offset ):
try:
j = ord(t[offset]) + 256*ord(t[offset+1])# + 65536*ord(t
[offset+2]) + 16777216*ord(t[offset+3])
#return j
except IndexError:
#   print Exception
return j
def my_bpp( mode ):
if mode  0xF800:
return 1  ( ( (mode  27)  31 ) - 1 )
if mode==20 or mode==27:
return 4
return 0



File ../../../source/ant//tools/scripts/python/sprites.py, line 31
j = ord(t[offset]) + 256*ord(t[offset+1])# + 65536*ord(t
[offset+2]) + 16777216*ord(t[offset+3])
^
IndentationError: expected an indented block
make[2]: *** [swapped.out] Error 1
make[1]: *** [ant_final_target] Error 2
make: *** [rest] Error 2


Any Help?

With Best Regards,
Soumya



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


Re: Persist a class (not an instance)

2005-11-25 Thread Sybren Stuvel
Kent Johnson enlightened us with:
 Is there a way to persist a class definition (not a class instance,
 the actual class) so it can be restored later?

From the docs:

Similarly, classes are pickled by named reference, so the same
restrictions in the unpickling environment apply. Note that none of
the class's code or data is pickled [...]

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


Re: How to get started in GUI Programming?

2005-11-25 Thread Thomas Guettler
Am Fri, 25 Nov 2005 06:02:40 -0800 schrieb peter.mosley:

 I am trying to learn GUI programming in Python, but have to confess I
 am finding it difficult.

Yes, if you come from Visual Basic you might be missing something.
I developed with Visual Basic some time ago and like some parts of it.


 I've found the tutorial and reference manual on the PyGtk web site,
 but although I've made some progress, I keep reaching points where I
 have insufficient background to understand them. Currently I'm stuck
 on dialog boxes (the code seems immensely complex for the equivalent of
   MsgBox(Do you really want to do this ,vbYesNo)

search for yesNoDialog here:
http://guettli.sourceforge.net/gthumpy/src/editMetadata.py

 and I haven't
 got it to work properly yet) and loading graphical images in anything
 other than their original size, but every new step brings another
 struggle

search for scale2pixbuf in the link.
 
 Can anyone offer any suggestions as to the least painful way forwards?

Only the beginning is painful. After some time you don't miss anything
from Visual Basic anymore.

 Happy Learning,
  Thomas


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

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


Re: Python as Guido Intended

2005-11-25 Thread Paul Boddie
[EMAIL PROTECTED] wrote:
 And exactly what is python's spirit/philosophy ? It seems to me that
 they are often used in a liberal way, just to support one's argument
 that whatever is not in the CURRENT python should not be there.

Yes, those contentious terms pythonic and unpythonic which, as
someone recently pointed out, appear to be convenient tools to
respectively label one's own work as acceptable and someone else's work
as deficient.

I certainly don't have much time for people who, after the most cursory
inspection of Python, proclaim that it is substandard for not having
static typing or for employing indentation to organise source code, but
I do believe that people shouldn't be given the brush-off on more
subtle topics by some Zen of Python remark (probably not even
supported by the classic Tim Peters text). It should be noted that Zope
eventually experienced something of a backlash by encouraging such a
culture of obscure wisdom, and sometimes Python risks experiencing some
of the same. More documentation, explanation and objective discussion
help to bring the newcomer to understanding, rather than alienating
them with some kind of opaque, elitist retort which gives them no clue
as to how they may reach such understanding.

Paul

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


Accessing Outlook Public Folders

2005-11-25 Thread Bob
Hi,

I'm new to Python and I want to create a script that will import 
contactitems into an Outlook Public Folder.
Therefore I've installed the Python for Windows Extensions.

This way I can access my personal contacts

code
import win32com.client

OutlookObj = win32com.client.Dispatch(Outlook.Application)

Nms = OutlookObj.GetNameSpace(MAPI)
# Personal contacts folder
custs = Nms.GetDefaultFolder(10).Items

print custs.count

for i in range(custs.count):
 cust = custs[i]
 print cust.FullName +  -  + cust.FileAs
/code


But when I try to access contacts in the public folder 'klanten' with 
this code I get an error.

code
import win32com.client

OutlookObj = win32com.client.Dispatch(Outlook.Application)

Nms = OutlookObj.GetNameSpace(MAPI)
# Folder Klanten from public folders
custs = Nms.Folders.Item(Public Folders).Folders.Item(All Public 
Folders).Folders[Klanten].Items

print custs.count

for i in range(custs.count):
 cust = custs[i]
 print cust.FullName +  -  + cust.FileAs
/code

error
Traceback (most recent call last):
   File D:\PythonScripts\tp2outlook.py, line 13, in -toplevel-
 print cust.FullName +  -  + cust.FileAs
   File D:\Python23\Lib\site-packages\win32com\client\dynamic.py, line 
489, in __getattr__
 raise AttributeError, %s.%s % (self._username_, attr)
AttributeError: unknown.FullName
/error

Anyone an idea how I can access those contactitems?

Thanks,

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


Re: How to get started in GUI Programming?

2005-11-25 Thread Peter Decker
On 11/25/05, Sybren Stuvel [EMAIL PROTECTED]

 I'd go for wxPython ;-)

I'd go for Dabo, which is a Pythonic wrapper around wxPython. They are
even working on a visual design tool to lay out your UI, much as you
would in Visual Basic.

--

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


Re: Python book for a non-programmer

2005-11-25 Thread Kent Johnson
Simon Brunning wrote:
 I have a non-programming friend who wants to learn Python. It's been
 so long since I've been in her shoes that I don't feel qualified to
 judge the books aimed at people in her situation. 

Python Programming for the absolute beginner
http://premierpressbooks.com/ptr_detail.cfm?group=Programmingisbn=1%2D59200%2D073%2D8

Python Programming: An Introduction to Computer Science
http://www.fbeedle.com/99-6.html

And the Introductory Books page in the wiki lists many:
http://wiki.python.org/moin/IntroductoryBooks

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


Re: How to get started in GUI Programming?

2005-11-25 Thread Szabolcs Nagy
have you tried gtk.MessageDialog ?

http://www.pygtk.org/pygtk2reference/class-gtkmessagedialog.html

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


Re: Help need

2005-11-25 Thread Steve Holden
sr_sutar wrote:
 HI group,
 
 During doing some codeing with python i got the inline error,
 
 
 def my_word( offset ):
 try:
 j = ord(t[offset]) + 256*ord(t[offset+1])# + 65536*ord(t
 [offset+2]) + 16777216*ord(t[offset+3])
 #return j
 except IndexError:
 #   print Exception
 return j
 def my_bpp( mode ):
 if mode  0xF800:
 return 1  ( ( (mode  27)  31 ) - 1 )
 if mode==20 or mode==27:
 return 4
 return 0
 
 
 
 File ../../../source/ant//tools/scripts/python/sprites.py, line 31
 j = ord(t[offset]) + 256*ord(t[offset+1])# + 65536*ord(t
 [offset+2]) + 16777216*ord(t[offset+3])
 ^
 IndentationError: expected an indented block
 make[2]: *** [swapped.out] Error 1
 make[1]: *** [ant_final_target] Error 2
 make: *** [rest] Error 2
 
 
 Any Help?
 
The except clause requires an indented suite, which you've commented 
out. You might also want to look at the struct modlue if you want to 
convert 4 bytes into an integer.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006  www.python.org/pycon/

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


Re: Python book for a non-programmer

2005-11-25 Thread Steve
I recommend The Quick Python Book by Daryl Harms.  What makes it
different from all other introductory books is that it is actually
*readable*.  You can just sit down and read it like a novel and enjoy
it.

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


Re: How to get started in GUI Programming?

2005-11-25 Thread Steve
 Can anyone offer any suggestions as to the least painful way forwards?

http://www.ferg.org/easygui/index.html

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


Re: Persist a class (not an instance)

2005-11-25 Thread Kent Johnson
Sybren Stuvel wrote:
 Kent Johnson enlightened us with:
 
Is there a way to persist a class definition (not a class instance,
the actual class) so it can be restored later?
 
 
 From the docs:
 
 Similarly, classes are pickled by named reference, so the same
 restrictions in the unpickling environment apply. Note that none of
 the class's code or data is pickled [...]

OK that confirms that pickle won't work. Is there another approach that will?

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


Dynamic classes

2005-11-25 Thread Dave Rose
Hello all.
  I was wondering if creating classes could be dynamic.  I want to know if I 
can make a class Person, then read in a list of names (say people's names) 
so then I can have a class instance created for each name in the list?

  Why do I want to do this?  I was just thinking if I had a name on the 
list, Dave, I could then be able to read the name in the list, and assign 
Maria.birthday =  and all the other attributes I would want to use a class 
for, except this is dynamic.  I don't know how to iterate thru the list to 
assign the different attributes yet, but this seemed reasonable to want to 
do, and thought I could learn from this.

Thanks!
Dave 


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


Re: How to get started in GUI Programming?

2005-11-25 Thread UrsusMaximus
Hello Peter,

I am going to recommend EasyGui which can be found at
http://www.ferg.org/easygui/ because it is (by far) the easiest
possible GUI creation tool using Python.

If (or when) your needs require more complex options than easygui
provides, you might try looking at my GUI toolkits page,
http://www.awaretek.com/toolkits.html which has short descriptions of
and links to several Python GUI toolkits. Among these, my personal
favorite is PythonCard which is a framework that uses a visual GUI
creation tool and uses the wxPython widgets. I have found PythonCard to
be much easier to get started with than Glade.

I also did a podcast describing Python's GUI options, from a beginner's
point of view, which can be found on my Python podcasts page,
http://www.awaretek.com/python/index.html (scroll down to near the
bottom to find the Choose Your GUI Toolkit podcast from back in July.


But by all means don't forget to check out Easygui. Steve Ferg has made
a tool that is incredibly simple to learn and use, and sometimes it
sure is nice to get instant gratification by achieving quick success
and useful results. ;-)))

Ron Stephens
a href=http://www.awaretek.com/plf.html;Python Learning
Foundation/a

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


Re: How to get started in GUI Programming?

2005-11-25 Thread pdalet
If you come from visual basic, I suggest to use pythoncard GUI, which
is
very simple to develop with a Ressource Editor (create a panel, see
labwindows, visual basic ..).

https://sourceforge.net/projects/vb2py/
a package to transform VB to pythoncard

http://www.linux2000.com/pimp.html
a pythoncard application


Philippe DALET
Lyp champollion
46100 FIGEAC
FRANCE


[EMAIL PROTECTED] a écrit :

 I am trying to learn GUI programming in Python, but have to confess I
 am finding it difficult.

 I am not an experienced programmer - just someone who from time to
 time writes small programs for my use.  Over the years I have moved
 from GWBASIC to QBASIC to Visual Basic, and now trying to move across
 to a Linux platform.  Python seems to be the best compromise between
 the limitations of command line basic programming and the total
 incomprehensibility of C.

 Googling around it seems the best GUI is either Tkinter or PyGtk.  I
 found a book which recommended PyGtk, as it had a graphical design
 option,  Glade.  Coming from a VB background I latched onto that and
 bought the book (Beginning Python, Wrox), but it was a disappointment
 (or more accurately a complete waste of money) - there was
 insufficient detail in the text.

 I've found the tutorial and reference manual on the PyGtk web site,
 but although I've made some progress, I keep reaching points where I
 have insufficient background to understand them. Currently I'm stuck
 on dialog boxes (the code seems immensely complex for the equivalent of
   MsgBox(Do you really want to do this ,vbYesNo) and I haven't
 got it to work properly yet) and loading graphical images in anything
 other than their original size, but every new step brings another
 struggle

 I've seen reference to a Tkinter book - something like 'Python
 and Tkinter Programming' but it seems to be out of print and
 unavailable.

 Can anyone offer any suggestions as to the least painful way forwards?

 (Email address was valid once but has long since been abandoned to
 spam. Please rely via newsgroup)

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


Re: Python as Guido Intended

2005-11-25 Thread EP

 Should the priority be to enable python's philosophy or should
 it be the priority to limit python to only allow it's philosophy.
 
 One groups seems to think that python's spirit is not broken
 by allowing things that seem counter to it, as long as people
 can without much trouble, work within that spirit.
 
 An other group seems to think that any allowance to disgress
 from python's spirit is an assault on it.

This seems to assume a background philosophy of TMTOWTDI

versus 

YWKTMTOWTDIBIPFCEMS = .join([Yes we know,TMTOWTDI,But in Python fewer 
choices equals more simplicity)


There should be one-- and preferably only one --obvious way to do it.

Although that way may not be obvious at first unless you're Dutch.


Maybe what makes Python most different is its philosophy; I would not argue it 
is the ultimate philosophy --- I could not embrace a government which held such 
views --- it is nothing like Democratic --- but the people in Pythonia tend to 
be fairly nice, and the tax rate is outstandingly low.  Of course that's silly, 
Python is a tool, not a country.  Python's philosophy, however, seems to run 
counter to adding a phillips head, flat head, and hex head screwdriver blade to 
its hammer.

In life and society I hope we embrace a great multiplicity of perspectives and 
lifestyles.  This, however, is not that.

What is the philosophy?  I'm not the one to answer that, but I do use import 
this for reference, and it seems to answer some of the points in this thread:

 import this
The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
 


EP

Criminy, I didn't realize that drat ternary operator was going to creep in.  
Ugh.  Drat, drat, drat!

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


Re: FTP over TLS

2005-11-25 Thread David Isaac

Carl Waldbieser [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Does anyone know of any good examples for writing client side code to
upload
 files over a secure FTP connection?

http://trevp.net/tlslite/

Alan Isaac


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


Re: How to get started in GUI Programming?

2005-11-25 Thread flamesrock
The best, in my opinion is wxPython.

I recommend getting wxGlade and just fiddling around. You should be
able to produce some interesting GUI's fairly easily.

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


Re: Persist a class (not an instance)

2005-11-25 Thread Sybren Stuvel
Kent Johnson enlightened us with:
 OK that confirms that pickle won't work. Is there another approach
 that will?

Well, since the classes are created at runtime as well, you could
compile them using the appropriate API and call exec() on them.

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


Modifying Unix ReadKey Code

2005-11-25 Thread Dustan
I found this site that has code for readkey for Windows, Unix, and
in an updated version, Mac:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/134892 .  The
Mac object returns a character whether or not a key was pressed.  I
modified the Windows object to do the same when I downloaded it, but I
have no idea how to make the Unix object to do the same. Any help???
Not to be pushy, but I would like an answer soon.

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


Re: How to get started in GUI Programming?

2005-11-25 Thread BartlebyScrivener
Search this group for PythonCard and wxPython for gobs of opinions. For
descriptions of other resources, try:

http://www.fredshack.com/docs/python.html

bs

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


Re: (newbie) N-uples from list of lists

2005-11-25 Thread [EMAIL PROTECTED]
This is my attempt :

def cross(seq):
 r=[[]]
for x in seq:
r = [ a + b for a in r for b in [[i] for i in x ]]
return r

It is not very efficient though as it would loop through the
intermediate list produced multiple times.

[EMAIL PROTECTED] wrote:
 Hello,

 i think it could be done by using itertools functions even if i can not
 see the trick. i would like to have all available n-uples from each
 list of lists.
 example for a list of 3 lists, but i should also be able to handle any
 numbers of items (any len(lol))

 lol = (['a0', 'a1', 'a2'], ['b0', 'b1'], ['c0', 'c1', 'c2', 'c3'])

 =


 [('a0', 'b0', 'c0'), ('a0', 'b0', 'c1'), ('a0', 'b0', 'c2'), ('a0',
 'b0', 'c3'), ('a0', 'b1', 'c0'), ('a0', 'b1', 'c1'), ('a0', 'b1',
 'c2'), ('a0', 'b1', 'c3'), ('a1', 'b0', 'c0'), ('a1', 'b0', 'c1'),
 ('a1', 'b0', 'c2'), ('a1', 'b0', 'c3'), ('a1', 'b1', 'c0'), ('a1',
 'b1', 'c1'), ('a1', 'b1', 'c2'), ('a1', 'b1', 'c3'), ('a2', 'b0',
 'c0'), ('a2', 'b0', 'c1'), ('a2', 'b0', 'c2'), ('a2', 'b0', 'c3'),
 ('a2', 'b1', 'c0'), ('a2', 'b1', 'c1'), ('a2', 'b1', 'c2'), ('a2',
 'b1', 'c3')]

 maybe tee(lol, len(lol)) can help ?

 it could be done by a recursive call, but i am interested in using and
 understanding generators.

 i also have found a convenient function, here :
 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65285 (paste
 below)
 but i am curious of how you will do it or refactorize this one with
 generators...

 def permuteflat(*args):
 outs = []
 olen = 1
 tlen = len(args)
 for seq in args:
 olen = olen * len(seq)
 for i in range(olen):
 outs.append([None] * tlen)
 plq = olen
 for i in range(len(args)):
 seq = args[i]
 plq = plq / len(seq)
 for j in range(olen):
 si = (j / plq) % len(seq)
 outs[j][i] = seq[si]
 for i in range(olen):
 outs[i] = tuple(outs[i])
 return outs
 
 many thanx

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


Re: Python as Guido Intended

2005-11-25 Thread Bryan

 But suppose someone came up with a Python compiler.  It
 would compile any Python program but there would be no
 speed benefit unless you carefully wrote the code to not use
 many of Python's dynamic features, so that either by type
 inferencing or programmer supplied static declarations, the
 compiler could generate efficient native machine code
 that executes at near C speeds.
 Obviously this would require changes (mostly additions?)
 to the Python language, though these changes would still
 allow today's style dynamic code to be written and run
 (though just as slow as today's runs).
 The payout would be that things written as C-extensions
 today, would be writable in (a restricted form of) Python.
 Would the Python orthodoxy favor such a development?
 Or would that be turning Python into a screwdriver?
 


i agree with you... pyrex should be part of the python distribution :)

bryan

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


Re: wxPython Licence vs GPL

2005-11-25 Thread Ed Jensen
Paul Boddie [EMAIL PROTECTED] wrote:
 We'll have to wait and see what happens. There's a risk that versions
 of Python with different semantics or characteristics to the original
 could cause the development of parallel communities, instead of
 everyone working on/with the same project. The harm done is
 adequately described by paraphrasing your comment on licences: think
 how much farther along free software could be if all this energy and
 concern weren't expended on separate and sometimes proprietary code
 bases.

I think free software/open source has existed long enough and with
enough varied licenses (GPL, LGPL, modified LGPL (see wxWidgets), BSD,
X11, MIT, Apache, etc.) that we'd basically know without question if
less restritive licenses (like BSD) were causing projects to fail vs.
projects that use very heavy handed licenses (like GPL).  Apache and
Python are two of my favorite examples, followed by the *BSD operating
systems.

 Well, despite your protestations, I think the GPL and LGPL are fairly
 easy and safe choices for a lot of developers who know enough about
 Free Software (ie. haven't just seen the name and thought that's the
 thing for me), know what the characteristics of those licences are,
 and who don't have the time or legal experience to performance due
 diligence.

To be honest, I don't dislike the LGPL that much.  The static vs.
dynamic linking issues bother me somewhat (which is why I like the
modified LGPL used by wxWidgets), but all in all, I can live (albeit
uncomfortably) with LGPL.  It seems much more sane.  Whereas including
one line of GPL code into your 10,000,000,000 line project can have
disasterous consequences (which I find ridiculous), at least with LGPL
you're only asked to share the changes you've made to that particular
library.

 Meanwhile, all this hippie and chilling effect talk is, I imagine,
 like having a discussion on software licensing with some cold war
 propagandist.

Sorry for my initial post on this subject being flamey.  I must've
been cranky that day, and I'm glad we were able to continue the
discussion.  :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to get started in GUI Programming?

2005-11-25 Thread David Boddie
[EMAIL PROTECTED] wrote:
 I am trying to learn GUI programming in Python, but have to confess I
 am finding it difficult.

 I am not an experienced programmer - just someone who from time to
 time writes small programs for my use.  Over the years I have moved
 from GWBASIC to QBASIC to Visual Basic, and now trying to move across
 to a Linux platform.  Python seems to be the best compromise between
 the limitations of command line basic programming and the total
 incomprehensibility of C.

 Googling around it seems the best GUI is either Tkinter or PyGtk.

You might also want to try PyQt:

http://www.riverbankcomputing.co.uk/pyqt/

I'm sure fans of wxWidgets will also point you in the direction of
their favourite bindings. ;-)

David

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


Re: wxPython Licence vs GPL

2005-11-25 Thread Christophe
Ed Jensen a écrit :
Well, despite your protestations, I think the GPL and LGPL are fairly
easy and safe choices for a lot of developers who know enough about
Free Software (ie. haven't just seen the name and thought that's the
thing for me), know what the characteristics of those licences are,
and who don't have the time or legal experience to performance due
diligence.
 
 
 To be honest, I don't dislike the LGPL that much.  The static vs.
 dynamic linking issues bother me somewhat (which is why I like the
 modified LGPL used by wxWidgets), but all in all, I can live (albeit
 uncomfortably) with LGPL.  It seems much more sane.  Whereas including
 one line of GPL code into your 10,000,000,000 line project can have
 disasterous consequences (which I find ridiculous), at least with LGPL
 you're only asked to share the changes you've made to that particular
 library.

If you don't like the GPL, then by all means, *do not use GPL code !*

Please, I mean, when you use without authorisation some code in your 
project, you are in trouble, no matter what licence the code was using.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why are there no ordered dictionaries?

2005-11-25 Thread Alex Martelli
Fuzzyman [EMAIL PROTECTED] wrote:
   ...
 If you slice an ordered dictionary, I assume you would expect to get an
 ordered dictionary back ?

That would be helpful, yes, though there are precedents for types whose
slicing doesn't return an instance of that type (e.g. slices of an mmap
are instances of str, not of mmap, if I recall correctly), most
sliceable sequences do follow that pattern.


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


Re: Dynamic classes

2005-11-25 Thread Alex Martelli
Dave Rose [EMAIL PROTECTED] wrote:

 Hello all.
   I was wondering if creating classes could be dynamic.  I want to know if I
 can make a class Person, then read in a list of names (say people's names)
 so then I can have a class instance created for each name in the list?

Yes, but what you're asking for in your second sentence is different
from what you're wondering about in your first one.

You can create a class dynamically.
You can create dynamically an instance of a class.
The two things are quite separate issues.

You create a new class each time you execute a 'class' statement, or
call 'type' (or other custom metaclass) with suitable arguments.  You
can do either or both in the body of a loop over a list of names, say.

You create a new instance of a class each time you call the class.
Again, of course you can do this in a loop's body.

Creating new classes is a reasonably rare need, creating new instances
is a very common need.  Perhaps you can clarify which one you mean?


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


Re: Persist a class (not an instance)

2005-11-25 Thread Alex Martelli
Kent Johnson [EMAIL PROTECTED] wrote:

 Is there a way to persist a class definition (not a class instance, the
 actual class) so it can be restored later? A naive approach using pickle
 doesn't work:

You can use copy_reg to customize pickling behavior.  In this case,
you'd need a custom metaclass to use as the type for your picklable
classes.  Moreover, if the class has attributes that you also want to
pickle, such as methods or properties, you'll have to arrange for custom
pickling of *them*, too.  So, yes, there are ways, but not simple ones.


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


Re: books: Dive into Python vs Beginning Python

2005-11-25 Thread Aahz
In article [EMAIL PROTECTED],
Franz Mueller [EMAIL PROTECTED] wrote:

which of the following books would you recommend:
Dive into Python or Beginning Python: From Novice to Professional?

I'm an experienced C++-programmer who wants to take a look at Python.

Another option: just use the on-line tutorial at python.org
-- 
Aahz ([EMAIL PROTECTED])   * http://www.pythoncraft.com/

If you think it's expensive to hire a professional to do the job, wait
until you hire an amateur.  --Red Adair
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: books: Dive into Python vs Beginning Python

2005-11-25 Thread Sebastien Douche
On 11/25/05, Franz Mueller [EMAIL PROTECTED] wrote:
 Hi,

Hi Franz! :)

 which of the following books would you recommend:
 Dive into Python or Beginning Python: From Novice to Professional?

Both are very good books but I suggest the latter because more recent.
Beginning Python talk python 2.3 and 2.4 : set data structure,
generator, iterator...



--
Sébastien Douche [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Dynamic classes

2005-11-25 Thread Piet van Oostrum
 Dave Rose [EMAIL PROTECTED] (DR) wrote:

DR Hello all.
DR   I was wondering if creating classes could be dynamic. I want to know
DR if I can make a class Person, then read in a list of names (say
DR people's names) so then I can have a class instance created for each
DR name in the list?

If you have the class Person, you are not creating it dynamically. And of
course you can create instances dynamically as you describe.

DR   Why do I want to do this?  I was just thinking if I had a name on the 
DR list, Dave, I could then be able to read the name in the list, and
DR assign Maria.birthday =  and all the other attributes I would want
DR to use a class for, except this is dynamic. I don't know how to
DR iterate thru the list to assign the different attributes yet, but this
DR seemed reasonable to want to do, and thought I could learn from this.

If I understand you correctly, you want to create a variable with name
'Maria' when you read the name Maria. Creating variables dynamically is
possible in Python but is almost always the wrong thing to do. Instead it
is usually better to use a dictionary.

class Person:
  def __init__(self, name):
  self.name = name

persons = {}

now you have a loop that reads persons' names, say in name.

myperson = persons[name] = Person(name)

Now I suppose you want to read additional attributes, while the list of
possible attributes is in principle open.

So suppose you have read the attribute name in attr and the value in val.
The you can dynamically create an instance attribute with:

setattr(myperson, attr, val)
-- 
Piet van Oostrum [EMAIL PROTECTED]
URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4]
Private email: [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to get started in GUI Programming?

2005-11-25 Thread Thomas Guettler
Am Fri, 25 Nov 2005 06:02:40 -0800 schrieb peter.mosley:

 I am trying to learn GUI programming in Python, but have to confess
I
 am finding it difficult.
 
Yes, if you come from Visual Basic you might be missing something.
I developed with Visual Basic some time ago and like some parts of it.


 I've found the tutorial and reference manual on the PyGtk web site,
 but although I've made some progress, I keep reaching points where I
 have insufficient background to understand them. Currently I'm stuck
 on dialog boxes (the code seems immensely complex for the equivalent
of
 MsgBox(Do you really want to do this ,vbYesNo)
 
search for yesNoDialog here:
http://guettli.sourceforge.net/gthumpy/src/editMetadata.py

 and I haven't
 got it to work properly yet) and loading graphical images in
anything
 other than their original size, but every new step brings another
 struggle
 
search for scale2pixbuf in the link.
 
 Can anyone offer any suggestions as to the least painful way
forwards?
 
Only the beginning is painful. After some time you don't miss anything
from Visual Basic anymore.

 Happy Learning,
  Thomas


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

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


Re: How to get started in GUI Programming?

2005-11-25 Thread malv
I suggest you take a look at Qt3, much superior to Tkinter or PyGtk.
With Python, you have to use PyQt bindings.

[EMAIL PROTECTED] wrote:
 I am trying to learn GUI programming in Python, but have to confess I
 am finding it difficult.

 I am not an experienced programmer - just someone who from time to
 time writes small programs for my use.  Over the years I have moved
 from GWBASIC to QBASIC to Visual Basic, and now trying to move across
 to a Linux platform.  Python seems to be the best compromise between
 the limitations of command line basic programming and the total
 incomprehensibility of C.

 Googling around it seems the best GUI is either Tkinter or PyGtk.  I
 found a book which recommended PyGtk, as it had a graphical design
 option,  Glade.  Coming from a VB background I latched onto that and
 bought the book (Beginning Python, Wrox), but it was a disappointment
 (or more accurately a complete waste of money) - there was
 insufficient detail in the text.

 I've found the tutorial and reference manual on the PyGtk web site,
 but although I've made some progress, I keep reaching points where I
 have insufficient background to understand them. Currently I'm stuck
 on dialog boxes (the code seems immensely complex for the equivalent of
   MsgBox(Do you really want to do this ,vbYesNo) and I haven't
 got it to work properly yet) and loading graphical images in anything
 other than their original size, but every new step brings another
 struggle

 I've seen reference to a Tkinter book - something like 'Python
 and Tkinter Programming' but it seems to be out of print and
 unavailable.

 Can anyone offer any suggestions as to the least painful way forwards?

 (Email address was valid once but has long since been abandoned to
 spam. Please rely via newsgroup)

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


Re: books: Dive into Python vs Beginning Python

2005-11-25 Thread Franck PEREZ
On 11/25/05, Sebastien Douche [EMAIL PROTECTED] wrote:
 On 11/25/05, Franz Mueller [EMAIL PROTECTED] wrote:
  Hi,

 Hi Franz! :)

  which of the following books would you recommend:
  Dive into Python or Beginning Python: From Novice to Professional?

 Both are very good books but I suggest the latter because more recent.
 Beginning Python talk python 2.3 and 2.4 : set data structure,
 generator, iterator...


Dive into Python actually mentions generators :
http://diveintopython.org/dynamic_functions/stage6.html

And it's a very well written book btw.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why is dictionary.keys() a list and not a set?

2005-11-25 Thread Mike Meyer
Christoph Zwerschke [EMAIL PROTECTED] writes:

 As a general note, I think it would be good to place the exact
 description in a footnote, since speaking about hashable objects,
 __hash__ and __cmp__ will certainly frighten off newbies and make it
 hard to read even for experienced users. The main text may
 lie/simplyfy a little bit.

Good point.

 However, since the Python docs are a reference and not a textbook or
 manual, I think the debt should not be payed back later, but
 immediately in a footnote.

Ok, how about this for dictionaries/sets:

Any hashable object can be used as a dictionary key (set member). Immutable
objects, except for tuples that contain a non-hashable object, are
hashable. Python classes are normally hashable(1).

And the footnote is:

Instances of Python classes are hashable if they define a __hash__
method, or if they don't define either __cmp__ or __eq__.

mike
-- 
Mike Meyer [EMAIL PROTECTED]  http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python as Guido Intended

2005-11-25 Thread Mike Meyer
Antoon Pardon [EMAIL PROTECTED] writes:
 Op 2005-11-24, Mike Meyer schreef [EMAIL PROTECTED]:
 Antoon Pardon [EMAIL PROTECTED] writes:
 The usual response is That's not the Python way. That's not calling
 someone dumb, just pointing out that they don't yet fully understand
 the Python way.
 That is not the Python way, is just saying Python doesn't have it
 in other words. So it can't be the answer to why python can't have
 something.

 No, it isn't. At least, it isn't when I use it. A language is more
 than just an accumulation of features. Well, a good language is more
 than just an accumulation of features - there's a philosophy
 underlying the language, that guides what features are added and what
 features aren't. Other languages have other philosophies, and wind up
 being good for other things.

 But how this philosophy influences design is not straight forward.

 The ternary operator was thought of to go against the philosopy,

By who?

 and now seems to be at least compatible with the philosophy.

 So when someone asks why it is not in python, saying It is not
 the python way still doesn't answer the question, because the
 person would probably still like to know what in his proposal
 is against the python philosophy and why.

Sometimes, such things are easy to explain, and they'll generally get
that explanation. Sometimes they aren't, so you're reduced to
pointing out similar - but more obvious - things that aren't in the
language, and import this, and suggesting that they try it for a
while and see how it works

 My vision
 isn't perfect - I've changed my mind about things: I used to want real
 macros, and I initially disliked list comprehensions. My vision
 doesn't agree with the developers - notably including Guido's - a lot
 of the time. On the other hand, they haven't done anything that
 strikes me as so wrong that I want to spend the time required working
 on Python rather than in Python to allow me to get it fixed.

 I see nothing wrong with that. But I would apreciate it, should
 you be more open about something being your personal vision.
 To me something like: That is not the python way comes accross
 as: You just don't understand about python, if you ask/propose
 something like that

That's essentially true. In some cases, the reasons can be explained
without understanding about python. In some cases, they can't.

 It gives me the feeling the person is saying something like: Python
 is like this, I like it this way, so nobody better suggests this
 changes.

You're carrying things a step to far, going from explaining an overly
brief statement to imagining a motive for said statement.

  mike
-- 
Mike Meyer [EMAIL PROTECTED]  http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Singleton and C extensions

2005-11-25 Thread Scott David Daniels
Emmanuel Briot wrote:
 I am participating in the development of a GPL IDE
https://libre2.adacore.com/gps/
 I am not really good at python, but I was trying to implement the
 singleton design pattern in C, so that for instance calling the constructor
ed = Editor (foo)

Fredrik's advice is probably better, but if you must:

class Editor(object):
 table = {}
 def __new__(klass, name):
 try:
 return klass.table[name]
 except KeyError:
 klass.table[name] = super(Singled, klass).__new__(klass)
 return klass.table[name]

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


Re: How to get started in GUI Programming?

2005-11-25 Thread BartlebyScrivener
Search this group for PythonCard and wxPython for many posts on this
subject. Also see the following link for descriptions of other
alternatives:

http://www.fredshack.com/docs/python.html

bs

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


Re: Python as Guido Intended

2005-11-25 Thread Mike Meyer
Antoon Pardon [EMAIL PROTECTED] writes:
 Well this is, is one thing I have a problem with.

 The python people seem to be more concerned with fighting things
 that could be used counter the python philosophy, than search for
 things that enable working in the python philosophy.

And what's wrong with that?
 Yes. And if you need a red hammmer, you should get a red hammer, not
 use red spray paint on one that wasn't designed to be red. Just
 because *you* don't see how providing a red option violates the
 philosophy of python doesn't mean that it doesn't do so.

 Well this seems to be the main conflict between those who would
 like Python to go a bit further and those that oppose it.

 Should the priority be to enable python's philosophy or should
 it be the priority to limit python to only allow it's philosophy.

Those two statements say the same thing. Part of the Python philosphy,
from import this, is that there should only be one obvious way to do
it. By enabling that part of Python's philosphy, you're automatically
limiting python to not allow other - specifically non-pythonic - ways
to do the same thing.

   mike
-- 
Mike Meyer [EMAIL PROTECTED]  http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Which License Should I Use?

2005-11-25 Thread mojosam
I've been watching the flame war about licenses with some interest.
There are many motivations for those who participate in this sector, so
disagreements over licenses reflect those agendas.

I don't have an agenda, at least not right now.  I do plan on writing a
few programs.

These will be tools I need for firmware testing.  They will be
relatively simple things like tools for breaking down data by its
structure for easy viewing, sending commands/macros over serial ports,
etc.  Similar things exist, but they don't do everything I need.  These
will also be excellent learning opportunities for me, since I'm still
pretty shaky on Python.

How do I decide on a license?  Are there any web sites that summarize
the pros and cons?  I guess I don't care too much about how other
people use it.  These things won't be comprehensive enough or have
broad enough appeal that somebody will slap a new coat of paint on them
and try to sell them.  I guess I don't care if somebody incorporates
them into something bigger.  If somebody were to add features to them,
it would be nice to get the code and keep the derivative work as open
source, but I don't think that matters all that much to me.  If
somebody can add value and find a way of making money at it, I don't
think I'd be too upset.

I will be doing the bulk of the coding on my own time, because I need
to be able to take these tools with me when I change employers.
However, I'm sure that in the course of using these tools, I will need
to spend time on the job debugging or tweaking them.  I do not want my
current employer to have any claim on my code in any way.  Usually if
you program on company time, that makes what you do a work for hire.
I can't contaminate my code like that.  Does that mean the GPL is the
strongest defense in this situation?

I'm open to suggestions as to which licenses to consider.  However,
please try to keep the conversation to the decision process or what
sounds like it is best for this purpose.  Let's keep the broader issue
of which license will bring about the fall of Western Civilization on
the other thread.

Ron Britton

(The gibberish on the next line really is my email address.)
nk67v8o02
at
sneakemail.com

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


Re: How to get started in GUI Programming?

2005-11-25 Thread Bill
[EMAIL PROTECTED] wrote:
 I am trying to learn GUI programming in Python, but have to confess I
 am finding it difficult.

 Googling around it seems the best GUI is either Tkinter or PyGtk.

This statement is, and has been subject to much debate. If you ask 10
people on this newsgroup you'll probably get 12 opinions.

If you're having trouble at this early stage, you might want to
reconsider and take another look at either QT or wxWidgets. I've been
through the QT tutorial and was quite satisfied with it, although I'll
admit I was not a GUI newby at the time. I also found the tutorial
accompanying Boa Constructor (http://boa-constructor.sourceforge.net/)
to be a good start at creating a wxWidgets GUI.

Bill

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


Re: Making immutable instances

2005-11-25 Thread Mike Meyer
Paul Rubin http://[EMAIL PROTECTED] writes:
 Mike Meyer [EMAIL PROTECTED] writes:
 There isn't a standard serialize method in Python, so I don't know how
 you want to define it.
 I can think of perfectly reasonable definitions
 of serialize where obj.serialize() won't always return the same string
 on an immutable object, even if you don't allow adding attributes.
 Fair enough.  How's this:

a = ImmutableObject()
b = deepcopy(a)
assert a == b  # a and b start out equal
 do stuff 
# since a and b are immutable, they should still be equal
# no matter what has happened above
assert a == b

 If you've added attributes to a but not to b, they should compare
 unequal, breaking immutability.

Why should they compare unequal just because you add an attribute?
Nothing says all attributes have to be involved in an equality
comparison. In fact, Python classes by default ignore all attributes
when doing an equality comparison. In order to compare attributes, you
have to provide an __eq__ method (or __cmp__, but we'll ignore
that). It can't mention your new attribute, because it doesn't exist
unless you add it. So your final assertion will be true even after
adding a new attribute.

Of course, there's a fundamental flaw in your definition of
immutable, in that there are immutable objects - tuples - for which
the condition t1 == t2 is *not* a constant. Tuples can hold mutable
objects, meaning you can change those. Doing so will make a tuple not
compare equal to a copy of the state prior to changing the contents of
the tuple.

mike
-- 
Mike Meyer [EMAIL PROTECTED]  http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why are there no ordered dictionaries?

2005-11-25 Thread Tom Anderson
On Wed, 23 Nov 2005, Christoph Zwerschke wrote:

 Alex Martelli wrote:

 However, since Christoph himself just misclassified C++'s std::map as 
 ordered (it would be sorted in this new terminology he's now 
 introducing), it seems obvious that the terminological confusion is 
 rife.

 Speaking about ordered and sorted in the context of collections is 
 not a new terminology I am introducing, but seems to be pretty common in 
 computer science

This is quite true. I haven't seen any evidence for 'rife' 
misunderstanding of these terms.

That said ...

 Perhaps Pythonists are not used to that terminology, since they use the 
 term list for an ordered collection. An ordered dictionary is a 
 dictionary whose keys are a (unique) list. Sometimes it is also called a 
 sequence

Maybe we should call it a 'sequenced dictionary' to fit better with 
pythonic terminology?

tom

-- 
YOU HAVE NO CHANCE TO ARRIVE MAKE ALTERNATIVE TRAVEL ARRANGEMENTS. --
Robin May
-- 
http://mail.python.org/mailman/listinfo/python-list


  1   2   >