Execute code after death of all child processes - (corrected posting)

2004-12-25 Thread Markus Franz
Hallo!


I have a problem with this little script written in Python:


import sys, os, time
texts = ['this is text1', 'this is text 2']
for current_text in env_sources[0:]:
 pid = os.fork()
 if pid == 0:
  time.sleep(2)
  print current_text
  break

As you is create some child processes depending on the number of vars
in ?texts?. My problem is: How can I run some code after all child
processes have been finished? (The code should be run only in the
parent process.)

I tried:

import sys, os, time
texts = ['this is text1', 'this is text 2']
for current_text in texts[0:]:
pid = os.fork()
if pid == 0:
time.sleep(2)
print current_text
break
os.waitpid(-1, 0)
print 'this is the end'

But this didn't work, 'this is the end' will be showed several times.

Can you help me?

Tanks.


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


Re: Optional Static Typing - Haskell?

2004-12-25 Thread Alex Martelli
Donn Cave <[EMAIL PROTECTED]> wrote:
   ...
> | making a really modular system work with static typing and inferencing
> | is probably impossible; in practice, the type inferencer must examine
> | all code, or a rather copious summary of it... it can't really work
> | module by module in a nice, fully encapsulated way...).
> 
> Well, I would assume that a modules in a static system would present
> a typed external interface, and inference would apply only within the
> module being compiled.
   ...
> There might be tricky spots, but I imagine the Objective CAML
> folks would object to an assertion like "making a really modular
> system work with static typing and inferencing is probably
> impossible"!

It seems to me that you just restated in the first part I quoted what
you say in the second part OCAML folks would object to.  If you give up
on type inferencing across modules, and only have type inferencing
inside each module, then you're getting little mileage out of the
inferencing if your modules are many and small.

But let me quote Van Roy and Haridi, rather than paraphrasing them, lest
I fail to do them justice -- I think quoting 8 lines out of a book of
over 800 pages is "fair use" (anecdote: my Xmas gift is said book, my
wife's a real-bargain Powerbook 15" Titanium laptop -- yesterday we
weighed them against each other and determined the book's heavier;-)...

"""
Dynamic typing makes it a trivial matter to do separate compilation,
i.e. modules can be compiled without knowing anything about each other.
This allows truly open programming, in which independently written
modules can come together at runtime and interact with each other.  It
also makes program development scalable, i.e., extremely large programs
can be divided into modules that can be recompiled individually without
recompiling other modules.  This is harder to do with static typing
because the type discipline must be enforced across module boundaries.
"""

I see that by paraphrasing and summarizing by heart I was changing their
argument a bit, from 'enforcing the type discipline' (which is what
they're discussing, and is obviously mandatory if you want to talk about
static typing) to 'type inferencing' (which they don't discuss in this
specific paragraph).  Nor do they claim 'probably impossible', since
they're only discussing enforcement, not inferencing -- just 'harder'.

Essentially, to compile a module under static typing you need full type
information for other modules -- the "without knowing anything about
each other" condition of fully separate compilation can't hold, and thus
neither can the "truly open programming" and "scalable development"
consequences.  Mind you, I personally _like_ the concept of describing
an interface separately, even in a different language (Corba's IDL, say)
that's specialized for the task.  But it doesn't seem to be all that
popular... without such separation, modularity plus static checking
appears to imply bottom->up coding: you need to compile modules in some
topologically sorted order compatible with the "X uses Y" relation.


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


Features for a Python package manager?

2004-12-25 Thread Georg Brandl
Hello c.l.py,

what features would you expect of a Python package manager, similar to
CPAN or rubygems?

I am currently planning to write such a thing, at first privately for
myself, and if it's proving useful, I think about releasing it.

I plan to model it after gentoo's portage, with less features of course.
Would this be acceptable?

feel-free-to-comment-ly yours,
Georg
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Lambda going out of fashion

2004-12-25 Thread Andrew Dalke
Benji York wrote:
> They do two different things.  I think you have a spurious * in the call 
> to apply.  The apply above is equivalent to

D'oh!  This cold has definitely made me error prone the last
couple of days.  Yesterday I managed to leave my cell phone
in my pants pocket along with a couple pens.  My new phone has
a color screen and a camera.

Andrew
[EMAIL PROTECTED]

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


Re: Optional Static Typing

2004-12-25 Thread gabriele renzi
Mike Meyer ha scritto:
"John Roth" <[EMAIL PROTECTED]> writes:

<[EMAIL PROTECTED]> wrote in message
This may sound a bit
cynical, but most real uber-programmers have either
Lisp or Smalltalk in their backgrounds, and
frequently both one. Neither of those languages
have static typing, and they simply don't need it.

LISP has type declarations. Everybody I know doing production work in
LISP uses them. It's the only way to get reasonable performance out of
LISP compiled code.
I also think some smalltalk allow you to tag stuff with type hints for 
performance.

Which raises what, to me, is the central question. If we have optional
static typing, can I get a performance enhancement out of it? If not,
why bother?
for documentation and 'crash early' purposes, I'd say.
Btw, why don't we rip out the approach of CL and some schemes that offer 
optional typing ? (not that I understand how those work, anyway)
--
http://mail.python.org/mailman/listinfo/python-list


Re: Lambda going out of fashion

2004-12-25 Thread Andrew Dalke
Terry Reedy wrote:
> Ok, add 'assuming that func and args are a valid callable and sequence 
> respectively.'  Error messages are not part of the specs, and may change 
> for the same code from version to version.

While true, the difference in error messages suggests that the
two approaches use slightly different and possibly exploitable
mechanisms.

> To be equivalent to len(*blah), this should be apply(len, blah), no *.

Oops.  Here's one that really works.  I have an idea of why
there's a difference but would rather someone explain it to me.

import traceback

def YieldTest():
yield "Test"

class Blah:
__len__ = None
__iter__ = YieldTest().__iter__

func = len
args = Blah()

try:
print "apply", apply(func, args)
except TypeError, err:
print "does not work:", err
try:
print "call", func(*args)
except TypeError, err:
print "does not work:", err

The output from running it under Python 2.3 is

apply 4
call does not work: len() takes exactly one argument (0 given)

If I make Blah be a new-style class (ie "class Blah(object):")
I get the opposite success behavior:

apply does not work: apply() arg 2 expected sequence, found Blah
call 4



Andrew
[EMAIL PROTECTED]

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


Re: Features for a Python package manager?

2004-12-25 Thread Nick Coghlan
Georg Brandl wrote:
Hello c.l.py,
what features would you expect of a Python package manager, similar to
CPAN or rubygems?
I am currently planning to write such a thing, at first privately for
myself, and if it's proving useful, I think about releasing it.
I've contemplated such a beast myself, but have never got further than a cursory 
look at "what work has already been done that I should take into account?"

Howevever, it sounds like that info would be useful to you, so here's what I've 
got:
PEP 314 (Metadata for Python Packages v 1.1) details the properties of the 
metadata that the Python repository relies on.

Don't worry about PEP 241 - it has been superceded by PEP 314.
PEP 301 describes PyPI (Python Package Index) - the central index of available 
packages. A running version of it can be found at http://www.python.org/pypi

PEP 243 is probably worth looking at, although I believe it is basically 
superceded by PEP 301.

PEP 262 describes a proposed (local system) installation database. An 
implementation already exists in the nondist section of CPython's CVS 
repository, but further progress is currently stalled due to lack of a champion.

It would also be good to be aware of how distutils currently works (even if 
that's just by reading its documentation). Doing your own trawl through PEP 0 
wouldn't hurt, either (it's possible I missed something relevant). The archives 
of python-dev and the distutils SIG may also provide good info.

If you're serious about doing a good job (i.e. to a "possibly included with the 
standard Python distribution some day" standard), it may be worth posting a 
question on python-dev about it. Just say that you're contemplating writing such 
a tool for your own use, and are interested in any ideas which aren't currently 
documented in the places I mentioned above. You'll find several of the authors 
of the above material frequent python-dev, and will hopefully have some good 
pointers regarding what needs to be done.

> I plan to model it after gentoo's portage, with less features of course.
> Would this be acceptable?
I don't know enough about Portage to answer that question. I do know any package 
manager which made it into the standard distribution would need to work for at 
least the big three platforms (Windows/Mac/*nix) :)

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


Re: Lambda going out of fashion

2004-12-25 Thread Nick Coghlan
Python 2.4 interactive session:
Py> class Blah:
...   def __iter__(self):
... yield "Test"
...
Py> args = Blah()
Py> apply(len, args)
Traceback (most recent call last):
  File "", line 1, in ?
TypeError: apply() arg 2 expected sequence, found instance
Py> len(*args)
4
Py> class Blah(object):
...   def __iter__(self):
... yield "Test"
...
Py> args = Blah()
Py> apply(len, args)
Traceback (most recent call last):
  File "", line 1, in ?
TypeError: apply() arg 2 expected sequence, found Blah
Py> len(*args)
4
And you're right, there is a behavioural difference - apply() expects a real 
sequence, whereas the extended function call syntax accepts any iterable.

However, there's also a bug in your demo code:
Py> def YieldTest():
...   yield "Test"
...
Py> x = YieldTest().__iter__
Py> list(x())
['Test']
Py> list(x())
[]
Your failing case with len(*args) was due to the iterator having already been 
consumed :)

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


Re: Multiple Inheritance __slots__ problem

2004-12-25 Thread Craig Ringer
On Fri, 2004-12-24 at 20:07, Nitin Shukla wrote:
> Hello,
> 
> Can anyone tell why am I getting this error and how to work around this
> problem.
> 
> >>> class Klass(object):
> ...   __slots__ = ( 'x' )
> ...
> >>> class Klass1(object):
> ...   __slots__ = ( 'y' )
> ...
> >>> class Klass(Klass, Klass1):
> ...   __slots__ = ( 'z' )
> ...
> Traceback (most recent call last):
>   File "", line 1, in ?
> TypeError: multiple bases have instance lay-out conflict
> 
> I need to define slots in these classes and also need to inherit them in
> Derived class.

If I recall correctly, the standard advice in this situation is "don't
use __slots__. If you think you need __slots__, still don't use
__slots__."

I've made use of __slots__ once myself for an optimisation when
subclassing `str', but if you're not using it for a serious optimisation
need it's probably best to steer clear.

--
Craig Ringer

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


Re: Clearing the screen

2004-12-25 Thread Craig Ringer
On Sat, 2004-12-25 at 07:43, Ishwor wrote:
> On 24 Dec 2004 15:33:26 -0800, Lars <[EMAIL PROTECTED]> wrote:
> > Hi Iswor,
> > 
> > If I understand you correctly then your program is writing output to a
> > console/terminal window and you want to clear that window.
> > I don't know of any library methods for that, but you might just do:
> 
> well i am not doing any console i/o. Just simple one. i am trying to
> clear the IDLE (one of python IDE distributed with the original
> distribution) screen which is pretty easy but having to do

> >>>import cls
> >>> cls()

> everytime is boring (2 lines of boredom!!) so what i want is to be
> able to do just

> >>>cls()

> and nothing more or even less!! ;-) 

Assuming cls.cls() does the job for you, just add 'from cls import cls'
to your pythonrc ( ${HOME}/.pythonrc on UNIX , NFI on windows ).

On a side note, it'd be easier to read your post if you'd use the shift
key more often :-P

--
Craig Ringer

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


Re: Lambda going out of fashion

2004-12-25 Thread Andrew Dalke
Nick Coghlan wrote:
> And you're right, there is a behavioural difference - apply() expects a real 
> sequence, whereas the extended function call syntax accepts any iterable.
> 
> However, there's also a bug in your demo code:

I guess I must be getting over this cold -- I'm only 1/2 wrong
this time.  :)

Andrew
[EMAIL PROTECTED]

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


Re: Clearing the screen

2004-12-25 Thread Nick Coghlan
Jeff Epler wrote:
I don't know about idle, but the "real" python supports the
PYTHONSTARTUP environment variable.

I just tried it - IDLE ignores PYTHONSTARTUP, as does PythonWin (I just started 
using PYTHONSTARTUP to switch the standard prompt from '>>>' to "Py>').

I believe PYTHONSTARTUP is handled by CPython's main function before it gets to 
the interactive interpreter.

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


Re: Python To Send Emails Via Outlook Express

2004-12-25 Thread Max M
Steve Holden wrote:
Max M wrote:
Lenard Lindstrom wrote:

So what is this, some kind of competition? If you really though Lenard's 
quoting was a sin (since I took your remarks to be sardonic), how much 
more so was your gratuitous repetition thereof?
I thought that showing by example might have a better effect than just 
grumping.


Far more pleasant to either a) ignore a gaff by a possibly 
less-experienced usenet correspondent than yourself, or b) point out the 
error without repeating it, as I hope I have done here.
You are right.
--
hilsen/regards Max M, Denmark
http://www.mxm.dk/
IT's Mad Science
--
http://mail.python.org/mailman/listinfo/python-list


Re: Execute code after death of all child processes - (corrected posting)

2004-12-25 Thread Jeff Epler
First, you'll want to exit from each forked copy, or else it will reach
the code-after-the-for-loop:
import sys, os, time
texts = ['this is text1', 'this is text 2']
for current_text in texts[0:]:
pid = os.fork()
if pid == 0:
time.sleep(2)
print current_text
raise SystemExit

Next, you'll want to wait for each process you started:
for current_text in texts:
os.waitpid(-1, 0)
print 'this is the end'
 

$ python /tmp/franz.py 
this is text1
this is text 2
this is the end

Jeff


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

Re: Optional Static Typing

2004-12-25 Thread moma
[EMAIL PROTECTED] wrote:
Adding Optional Static Typing to Python looks like a quite complex
thing, but useful too:
http://www.artima.com/weblogs/viewpost.jsp?thread=85551
I have just a couple of notes:
Boo (http://boo.codehaus.org/) is a different language, but I like its
"as" instead of ":" and "->", to have:
def min(a as iterable(T)) as T:
Instead of:
def min(a: iterable(T)) -> T:
I want to introduce a shorter syntax form:
Declare variables
a'int
a'int = 13  
s'string = "Santana"
d'float
def min(a'int,  b'int)'int:
   c'int# Declare a local variable c of type int
   c = a
   ...
*
The (template) notation is very useful.
def min(a'T, b'T)'T:
c'T
c = a

f'float = min(1.2, 2.2)
i'int = min(9, f)  ## of course: comiler adds int(f) type conversion
*
But these 2 should be syntactically wrong. The type of T is not obvious.
def max(a'int, b'int)'T:
   
def max(a, b)'T:
   
*
The big question is how to handle combound data types (container 
objects) ?  lists, tuples, maps...

Can a list contain various data types?
>>> h=['abc', 13, (9,8)]
# Declare h as list of ints
h'int[] = [1, 8, 991]
# These declarations produce syntax errors
h'int = [1, 8, 991]
error: h is a scalar not container
h'int[] = ['abc', 13, (9,8)]
 ^^
error: expecting int value
*
Tuples
A general sequence
t = 1, 3, 4,
A tuple of ints
t'int() = 1, 3, 4,
What about this?
u'int() = t, 6, 7,
Yes, it's OK.  because the basic_scalar_values are ALL ints.
>>>print u
((1,3,4), 6,7)
Maps
.
*
I think the compiler should allow typeless containers even you compile 
with --strict option.  Apply --strict (strictly) to scalar types only.

*
class A:
  pass
def func1(h'A)
 # Expects (instance) A or any subclass of A
  
*
// moma
   http://www.futuredesktop.org/OpenOffice.html

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


Re: Optional Static Typing

2004-12-25 Thread Just
In article <[EMAIL PROTECTED]>,
 moma <[EMAIL PROTECTED]> wrote:

> What about this?
> u'int() = t, 6, 7,

What about this?

u'int() = t, 6, 7,'

...which is valid Python today.

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


Re: Optional Static Typing

2004-12-25 Thread Rahul
I am assuming that optional type checking is being added for easier
debugging only. So if 'expects' are turned on , python raises
warnings(which do not halt the system) but not when they are turned
off. These will enable easier debugging for new people while not
affecting masters. Also,perhaps, it will be easier to accomodate till
type checking mechanism is perfected(if it is implemented at all that
is) so that python does not stop you when it is in fact  python which
might be making some mistake.(This last statement is a guess only...)

It is similar to assert and __debug__=1 in a way.

So the crux is :
1.Expects is only a bridge between type checking and dynamic typing.
2.Type checking is done only as a tool which you are free to override
if you want to.
3.The objective of type checking here is only to make debugging easier
and not speed/optimization.
4.The point is not that 'expects' be a additional keyword.You can go
like this also :
def (int a,int b): or whatever you like. Only that expects make it a
bit clearer IMHO.

sincerely.,
rahul

Scott David Daniels wrote:
> Rahul wrote:
> > 1.def gcd(a,b) expects (int,int)
>
> I presume by this syntax you mean something like:
>  def gcd(a, b) expects (int, int):
>  if b > a:
>  a, b = b, a
>  while a > b > 0:
>  a, b = b, a % b
>  return a
>
> > Here the function is not enforcing type checking. The compiler
should
> > only generate warning when someone passes something which is not an
int
> > and should not generate an error.Maybe the person calling the
function
> > knows what he is doing and wants to pass the unexpected type.
>
> But if this is the case, why is it different from?:
>  def gcd(a, b): # expects (int, int)
>  return a * b
>
> > 2.Another possibility is to let the function decide if the type is
not
> > what it is expecting. Maybe the function recvs some kind of flag
which
> > tells it that the type passed is not what it was expecting. So it
can
> > throw an error if it is really critical.
>
> Again, why make the test at all if you don't want to act on it?
>   assert  aborts if it is checked at all, but with __debug__
> defined as 1, it passes.  Perhaps you are proposing that expects be
> used in that context.
>
> > 3.In my post i am not stressing on adding 'expects' as keyword or
> > something. Only that type should not be enforced and 'expects'
makes
> > this clear.
> You need to explain why anyone would want to write expects at all.
> If you are expecting the code generation to change, you'd better
> enforce, rather than advise, unless you are defining points at which
> to do code specialization on types.
> 
> --Scott David Daniels
> [EMAIL PROTECTED]

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


Re: Keyword arguments - strange behaviour?

2004-12-25 Thread Steven Bethard
Fuzzyman wrote:
It wasn't that part of the example that I thought was over complex.
(although it's not a 'pattern' I use often). You suggested that if we
had dynamic evaluation of default values, you would have to replace it
with :
class foo(object):
   matcher=re.compile(r'...')
   def __new__(self, bar, baz, matcher=None):
   if matcher is None:
   matcher = self.matcher
   ...
   text = matcher.sub(r'...', text)
   ...

Now that I thought was over complex... when all you wanted to do was
put a constant into your default value !
Ahh.  Yeah, the thing above is a bit complex, but it keeps the same 
namespaces -- matcher is only available to foo, not the enclosing 
class/module.  Point taken of course. ;)

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


Re: Optional Static Typing

2004-12-25 Thread Luis M. Gonzalez
> > I don't understand why this discussion on optional static typing
came
> > up right at this moment.
>
> Because Guido made some notes on it.
>
> http://www.artima.com/weblogs/viewpost.jsp?thread=85551
>
> merry christmas.
> Stephen.

Yes, I know Guido did it.
But I wonder why at this moment, just when things seem to be directed
in a complete opposite way and with good chance of success (as I said:
Pypy, Starkiller, etc).

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


Re: IDLE problem :-(

2004-12-25 Thread Steven Bethard
Ishwor wrote:
I don't know if this has been a problem with other people using IDLE
but when i press the home key then the cursor jumps to the beginning
of the line and not after the prompt. If google prints the right
indentation then here how i want the IDLE prompt to work ->
 |>>> |(r,b,g).__class__
 ^  ^
 ^  ^-> want cursor here instead.
cursor
goes
here
Any work around??
If you're on windows, you can try PythonWin instead.  The first time you 
hit home, the cursor will go your second |.  If you then hit home again, 
the cursor will go to your first |.

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


Yahoo! Auto Response

2004-12-25 Thread devanpraburam
Hai devan have receved the mail but have not checked he will reply you sooner




Original Message:


X-YahooFilteredBulk: 61.1.208.116
Authentication-Results: mta296.mail.scd.yahoo.com
  from=python.org; domainkeys=neutral (no sig)
X-Originating-IP: [61.1.208.116]
Return-Path: 
Received: from 61.1.208.116  (EHLO yahoo.com) (61.1.208.116)
  by mta296.mail.scd.yahoo.com with SMTP; Sat, 25 Dec 2004 10:56:24 -0800
From: python-list@python.org
To: [EMAIL PROTECTED]
Subject: 
Date: Sun, 26 Dec 2004 00:25:34 +0530
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="=_NextPart_000_0016=_NextPart_000_0016"
X-Priority: 3
X-MSMail-Priority: Normal

This is a multi-part message in MIME format.

--=_NextPart_000_0016=_NextPart_000_0016
Content-Type: text/plain;
charset="Windows-1252"
Content-Transfer-Encoding: 7bit



 Attachment: No Virus found
 Norton AntiVirus - www.symantec.de


--=_NextPart_000_0016=_NextPart_000_0016
Content-Type: application/octet
_
DO YOU YAHOO!?
Get your free @yahoo.com address at http://mail.yahoo.com

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


Re: Python To Send Emails Via Outlook Express

2004-12-25 Thread David Fraser
[EMAIL PROTECTED] wrote:
Hey guys, I'm just thankful the answer has been found and hope this
helps someone else. To everyone (especially Lenard) that responded to
my request for help, thank you!!
Merry Christmas everyone!!!
God bless
Ian
Thanks Ian, Why not post this to the python-win32 mailing list as well, 
then maybe your changes can be incorporated into pywin32?

Happy christmas
David
--
http://mail.python.org/mailman/listinfo/python-list


Re: Read word tables

2004-12-25 Thread Christian Tismer
Rameshwari wrote:
Hi,
I would like to read a ms-word document using python.
Basically the word document contains number of tables  and the rows 
in each table do not have same number of columns.
If you have Office Professional Edition 2003, you can save
your Word files in XML format. Then, you can use an XML
parser to easily get at any structure. It might be simpler
to use than using all the COM objects directly.
(Well, the structures aren't that easy, of course).
ciao - chris
--
Christian Tismer :^)   
tismerysoft GmbH : Have a break! Take a ride on Python's
Johannes-Niemeyer-Weg 9A :*Starship* http://starship.python.net/
14109 Berlin : PGP key -> http://wwwkeys.pgp.net/
work +49 30 802 86 56  mobile +49 173 24 18 776  fax +49 30 80 90 57 05
PGP 0x57F3BF04   9064 F4E1 D754 C2FF 1619  305B C09C 5A3B 57F3 BF04
 whom do you want to sponsor today?   http://www.stackless.com/
--
http://mail.python.org/mailman/listinfo/python-list


Dr. Dobb's Python-URL! - weekly Python news and links (Dec 25)

2004-12-25 Thread Josiah Carlson
QOTW:  "Python, the language that wraps tightly around a problem and
swallows it whole." -- Raymond Hettinger



Because it is so important, this link is re-posted for the future
(originally appeared in the December 15 Python-Url! posting by
Cameron Laird): Martin Bless summarizes in an extremely valuable
post what you need to know to generate Python-related executable
binaries targeted for Windows*.

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/73f29284d1e031c7

Mark English asks about running a tk GUI using a background thread.

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/1f8d0a962f3fba49

You can register for PyCon DC 2005 on the web.
http://www.python.org/pycon/2005/register.html

A reminder to those who don't restart their editors while running
their scripts:  you are probably looking for reload().

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/9cd52e7b2dc4e278

Pointers to a handful of "graphics drawing" toolkits, hopefully to
result in a learning tool for sorting algorithms in Python.

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/f8ed1f1e9b7e8063

Importing binary modules from ZIPs by Thomas Heller.

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/bf37adb498126c0a

For the masochistic among us, a 120+ message thread on the history
of BASIC, Python, and why BASIC is probably not the first language
one should learn.

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/5730ea9521effd09

timbot exhibits a concrete instance of the long-conjectured 
universal follow-up, that is, a post which mis-answers all
confusion equally well.  Merry Christmas to you, too.

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/a472b72906740e8f

Diez B. Roggisch asks about decorator peculiarities and receives
a clarified version of his decorators in function and class form.

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/079f86a5f2af15a9

Mike Meyer proposes a rational number module for Python.

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/2074c5329e4004eb

Stephen Kellet announces a thread and lock validation tool for
Python and its test-oriented fans.

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/6dfa265b1bd16048

SPE version 0.7.0.a is released.

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/d71e84bb54aa4d9d

PythonCAD 20 appears.

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/af83a14bdbd806e2

Python is now available on NokiaS60 phones.

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/4bb1044d96b83962





Everything Python-related you want is probably one or two clicks away in
these pages:

Python.org's Python Language Website is the traditional
center of Pythonia
http://www.python.org
Notice especially the master FAQ
http://www.python.org/doc/FAQ.html

PythonWare complements the digest you're reading with the
marvelous daily python url
 http://www.pythonware.com/daily  
Mygale is a news-gathering webcrawler that specializes in (new)
World-Wide Web articles related to Python.
 http://www.awaretek.com/nowak/mygale.html 
While cosmetically similar, Mygale and the Daily Python-URL
are utterly different in their technologies and generally in
their results.

comp.lang.python.announce announces new Python software.  Be
sure to scan this newsgroup weekly.

http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python.announce

Brett Cannon continues the marvelous tradition established by 
Andrew Kuchling and Michael Hudson of intelligently summarizing
action on the python-dev mailing list once every other week.
http://www.python.org/dev/summary/

The Python Package Index catalogues packages.
http://www.python.org/pypi/

The somewhat older Vaults of Parnassus ambitiously collects references
to all sorts of Python resources.
http://www.vex.net/~x/parnassus/   

Much of Python's real work takes place on Special-Interest Group
mailing lists
http://www.python.org/sigs/

The Python Business Forum "further[s] the interests of companies
that base their business on ... Python."
http://www.python-in-business.org

Python Success Stories--from air-traffic control to on-line
match-making--can inspire you or decision-makers to whom you're
subject with a vision of what the language makes p

Re: How about "pure virtual methods"?

2004-12-25 Thread Noam Raphael
Mike Meyer wrote:
That's what DbC languages are for. You write the contracts first, then
the code to fullfill them. And get exceptions when the implementation
doesn't do what the contract claims it does.
Can you give me a name of one of them? This is a very interesting thing 
- I should learn one of those sometime. However, I'm pretty sure that 
programming in them is hell, or at least, takes a very long time.

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


Re: IDLE problem :-(

2004-12-25 Thread Ishwor
On Sat, 25 Dec 2004 17:45:02 GMT, Steven Bethard
<[EMAIL PROTECTED]> wrote:
> Ishwor wrote:
> > I don't know if this has been a problem with other people using IDLE
> > but when i press the home key then the cursor jumps to the beginning
> > of the line and not after the prompt. If google prints the right
> > indentation then here how i want the IDLE prompt to work ->
> >
> >  |>>> |(r,b,g).__class__
> >  ^  ^
> >  ^  ^-> want cursor here instead.
> > cursor
> > goes
> > here
> >
> > Any work around??
> 
> If you're on windows, you can try PythonWin instead.  The first time you
> hit home, the cursor will go your second |.  If you then hit home again,
> the cursor will go to your first |.

Yeah  i got the PythonWin and it does what you say but i am so used to
IDLE ( which was created originally by GvR). Its a different kind of
feeling when you are a sort of Python "Evangelist". ;-)
Moreover if i am right, this was mentioned as a sort of #fixme in
Python's source??

Thanks.

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


-- 
cheers,
Ishwor Gurung
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: IDLE problem :-(

2004-12-25 Thread Ishwor
Sorry IDLE's source ...;P
[snip]

-- 
cheers,
Ishwor Gurung
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python To Send Emails Via Outlook Express

2004-12-25 Thread ian
Hi David,
I'd be happy to post it to python-win32 but don't know how. 
Ian

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


Tinkering with py2exe

2004-12-25 Thread Ishwor
Having coded 1.72kb python test file, i decided to convert it to .exe
file using py2exe.
Having succeded doing it, i found the need to distribute the whole
directory including these files ?!!!???
26/12/2004  09:16 AM   203,096 library.zip
26/11/2004  09:16 AM 1,867,776 python24.dll
26/12/2004  09:16 AM11,264 simpletable.exe
26/11/2004  09:16 AM 4,608 w9xpopen.exe
4 File(s)  2,086,744 bytes

i assume w9xpopen.exe does the work around to run the code in windows.
python24.dll (which is massive 1.78mb!!)- has the Python VM i guess.
what does the library.zip do??

Currently to convert such a small script to exe why the nuances of 1.98mb?? 
Thanks 
-- 
cheers,
Ishwor Gurung
-- 
http://mail.python.org/mailman/listinfo/python-list


Non blocking read from stdin on windows.

2004-12-25 Thread barr
Hi
Can any one help.

I am trying to write a python scipt that takes input as args and/or as piped
input ( possibly the output of another program).

I want to read stdin ( the piped  in stuuff ) whcih might be empty without
the script blocking if it is empty.

I understand it is possible to do under unix with the select call. Can some
one please explain how to do this in windows.

thanks in advance.

Barr



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


Re: How about "pure virtual methods"?

2004-12-25 Thread Noam Raphael
Thank you very much for this answer! I learned from you about unit 
tests, and you convinced me that "testing oriented programming" is a 
great way to program.

You made me understand that indeed, proper unit testing solves my 
practical problem - how to make sure that all the methods which should 
be implemented were implemented. However, I'm still convinced that this 
feature should be added to Python, for what may be called "aesthetic 
reasons" - I came to think that it fills a gap in Python's "logic", and 
is not really an additional, optional feature. And, of course, there are 
practical advantages to adding it.

The reason why this feature is missing, is that Python supports building 
a class hierarchy. And, even in this dynamically-typed language, the 
fact that B is a subclass of A means that B is supposed to implement the 
interface of A. If you want to arrange in a class hierarchy a set of 
classes, which all implement the same interface but don't have a common 
concrete class, you reach the concept of an "abstract class", which 
can't be instantiated. And the basestring class is exactly that.

The current Python doesn't really support this concept. You can write in 
the __new__ of such a class something like "if cls == MyAbstractClass: 
raise TypeError", but I consider this as a patch - for example, if you 
have a subclass of this class which is abstract too, you'll have to 
write this exception code again. Before introducing another problem, let 
me quote Alex:

... If you WANT the method in the ABC, for documentation
purposes, well then, that's not duplication of code, it's documentation,
which IS fine (just like it's quite OK to have some of the same info in
a Tutorial document, in a Reference one, AND in a class's docstring!).
If you don't want to have the duplication your unit tests become easier:
you just getattr from the class (don't even have to bother instantiating
it, ain't it great!), and check the result with inspect.
That's actually right - listing a method which should be implemented by 
subclasses, in the class definition is mainly a matter of 
*documentation*. I like the idea that good documentation can be derived 
from my documented code automatically, and even if I provide an external 
documentation, the idea that the code should explain itself is a good 
one. The problem is, that the current convention is not a good 
documentation:

  def frambozzle(self):
 ''' must make the instance frambozzled '''
 raise NotImplementedError
The basic problem is that, if you take this basic structure, it already 
means another thing: This is a method, which takes no arguments and 
raises a NotImplementedError. This may mean, by convention, that this 
method must be implemented by subclasses, but it may also mean that this 
method *may* be implemented by subclasses. I claim that a declaration 
that a method must be implemented by subclass is simply not a method, 
and since Python's "logic" does lead to this kind of thing, it should 
supply this object (I think it should be the class "abstract"). Two of 
Python's principles are "explicit is better than implicit", and "there 
should be (only?) one obvious way to do it". Well, I think that this:

@abstract
def frambozzle(self):
"""Must make the instance frambozzled"""
pass
is better than the previous example, and from
def frambozzle(self):
raise NotImplementedError, "You must implemented this method, and 
it must make the instance frambozzled"

and from
def frambozzle(self):
"""Must make the instance frambozzled.
PURE VIRTUAL
"""
pass
and from maybe other possible conventions. Note also that making this 
explicit will help you write your tests, even if Python would allow 
instantiation of classes which contain abstract methods - you will be 
able to simple test "assert not isinstance(MyClass.frambozzle, abstract)".
(I don't like the solution of not mentioning the method at all, which 
makes the test equally simple, because it doesn't document what the 
method should do in the class definition, and I do like in-code 
documentation.)

To summarize, I think that this feature should be added to Python 
because currently, there's no proper way to write some code which fits 
the "Python way". As a bonus, it will help you find errors even when 
your unit tests are not sufficient.

I plan to raise this issue in python-dev. If you have any additional 
comments, please post them here. (I will probably be able to reply only 
by the weekend.)

Have a good day,
Noam
--
http://mail.python.org/mailman/listinfo/python-list


Re: Non blocking read from stdin on windows.

2004-12-25 Thread Noam Raphael
You can always have a thread which continually reads stdin and stores it 
in a string, or better, in a cStringIO.StringIO object. Then in the main 
thread, you can check whether something new has arrived. This, of course 
will work on all platforms.

I hope this helped a bit,
Noam
--
http://mail.python.org/mailman/listinfo/python-list


Re: Improving Python (was: Lambda going out of fashion)

2004-12-25 Thread Aahz
In article <[EMAIL PROTECTED]>,
Fredrik Lundh <[EMAIL PROTECTED]> wrote:
>
>(I've said it before, and I'll say it again: native unicode and
>generators are the only essential additions I've seen since 1.5.2, with
>properties and sub-classable C types sharing a distant third place.
>the rest of the stuff has had zero impact on my ability to write solid
>code in no time at all, and negative impact on my ability to download
>stuff that others have written and expect it to work in any Python
>version but the latest...)

Hmmm...  I find code much more readable and writable now that apply() is
going away.  And unless you mean "generator" to include iterators in
general, I believe that iterators are another critical addition.

I'm surprised that you don't include garbage collection and augmented
assignment, though.  String methods have been a net gain, I think.

Reviewing the various What's New documents, it appears that we really
have been holding the line since 2.2 on language changes.
-- 
Aahz ([EMAIL PROTECTED])   <*> http://www.pythoncraft.com/

"19. A language that doesn't affect the way you think about programming,
is not worth knowing."  --Alan Perlis
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tinkering with py2exe

2004-12-25 Thread John Machin

Ishwor wrote:
> Having coded 1.72kb python test file, i decided to convert it to .exe
> file using py2exe.
> Having succeded doing it, i found the need to distribute the whole
> directory including these files ?!!!???
> 26/12/2004  09:16 AM   203,096 library.zip
> 26/11/2004  09:16 AM 1,867,776 python24.dll
> 26/12/2004  09:16 AM11,264 simpletable.exe
> 26/11/2004  09:16 AM 4,608 w9xpopen.exe
> 4 File(s)  2,086,744 bytes
>
> i assume w9xpopen.exe does the work around to run the code in
windows.

No, it is required to make the popen* functions work correctly on "w9x"
platforms (Windows 95, 98, & ME).

> python24.dll (which is massive 1.78mb!!)- has the Python VM i guess.
> what does the library.zip do??

(1) Aren't you curious enough to try peeking into it with WinZip or
similar?

(2) Perhaps you should have read all the way through the py2exe home
page:

"""
How does it work?
py2exe uses python's modulefinder to examine your script and find all
python and extension modules needed to run it. Pure python modules are
compiled into .pyc or .pyo files in a temporary directory. Compiled
extension modules (.pyd) are also found and parsed for binary
dependencies.

A zip-compatible archive is built, containing all python files from
this directory. Your main script is inserted as a resource into a
custom embedded python interpreter supplied with py2exe, and the
zip-archive is installed as the only item on sys.path.
"""

>
> Currently to convert such a small script to exe why the nuances of
1.98mb??

It's not compiling and linking, as with (say) C. It's packaging,
providing the minimum (more or less) bundle of resources that you can
distribute to users who want/need to run your script but
can't/don't/shouldn't have a full Python distribution. The overhead of
the pythonXY.dll etc can be spread over multiple scripts.

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


Re: Clearing the screen

2004-12-25 Thread Scott David Daniels
Nick Coghlan wrote:
Jeff Epler wrote:
I don't know about idle, but the "real" python supports the
PYTHONSTARTUP environment variable.
I just tried it - IDLE ignores PYTHONSTARTUP, as does PythonWin (I just 
started using PYTHONSTARTUP to switch the standard prompt from '>>>' to 
"Py>').

I believe PYTHONSTARTUP is handled by CPython's main function before it 
gets to the interactive interpreter.

Cheers,
Nick.
From the Fine Manual:
Command line usage
idle.py [-c command] [-d] [-e] [-s] [-t title] [arg] ...
-c command  run this command
-d  enable debugger
-e  edit mode; arguments are files to be edited
-s  run $IDLESTARTUP or $PYTHONSTARTUP first
-t titleset title of shell window
On Windows, it is likely to be idle.pyw.  So, add a -s to the command
line used in the shortcut to start Idle.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list


Complementary language?

2004-12-25 Thread HackingYodel
Hello all!  I'm learning to program at home.  I can't imagine a better 
language than Python for this.  The ideal situation, for me, would be to 
study two languages at the same time.  Probably sounds crazy, but it 
works out better for me.  Being a newbie, I find almost all languages 
fascinating.  C, D, Objective-C, Ocaml, C++, Lisp, how is a non-tech to 
choose?  Does any single language do a better job in Python's weaker 
areas? Would anyone care to suggest one to supplement Python.  That is, 
if you could only use Python and one other language, which would it be? 
 Thank you for your time and help.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Tinkering with py2exe

2004-12-25 Thread Ishwor
On 25 Dec 2004 16:26:01 -0800, John Machin <[EMAIL PROTECTED]> wrote:
> 
> Ishwor wrote:
> > Having coded 1.72kb python test file, i decided to convert it to .exe
> > file using py2exe.
> > Having succeded doing it, i found the need to distribute the whole
> > directory including these files ?!!!???
> > 26/12/2004  09:16 AM   203,096 library.zip
> > 26/11/2004  09:16 AM 1,867,776 python24.dll
> > 26/12/2004  09:16 AM11,264 simpletable.exe
> > 26/11/2004  09:16 AM 4,608 w9xpopen.exe
> > 4 File(s)  2,086,744 bytes
> >
> > i assume w9xpopen.exe does the work around to run the code in
> windows.
> 
> No, it is required to make the popen* functions work correctly on "w9x"
> platforms (Windows 95, 98, & ME).

okay.. double clicking it returns the same remarks.

> 
> > python24.dll (which is massive 1.78mb!!)- has the Python VM i guess.
> > what does the library.zip do??
> 
> (1) Aren't you curious enough to try peeking into it with WinZip or
> similar?
> 

i didn't find anything to peek. all the files were compiled .pyc's
inside the zip file.. :-(

> (2) Perhaps you should have read all the way through the py2exe home
> page:

yup. i should have read everything from top to bottom but i was
extremely eager to see py2exe in action and just copy pasted the
setup.py and alikes.
 
> 
> """
> How does it work?
> py2exe uses python's modulefinder to examine your script and find all
> python and extension modules needed to run it. Pure python modules are
> compiled into .pyc or .pyo files in a temporary directory. Compiled
> extension modules (.pyd) are also found and parsed for binary
> dependencies.
> 
> A zip-compatible archive is built, containing all python files from
> this directory. Your main script is inserted as a resource into a
> custom embedded python interpreter supplied with py2exe, and the
> zip-archive is installed as the only item on sys.path.
> """
> 
> >
> > Currently to convert such a small script to exe why the nuances of
> 1.98mb??
> 
> It's not compiling and linking, as with (say) C. It's packaging,
> providing the minimum (more or less) bundle of resources that you can
> distribute to users who want/need to run your script but
> can't/don't/shouldn't have a full Python distribution. The overhead of
> the pythonXY.dll etc can be spread over multiple scripts.

Yup reading the page. Thanks heaps for that.. Sorry if i was a bit balmy. :-)

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


-- 
cheers,
Ishwor Gurung
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Mutable objects which define __hash__ (was Re: Why are tuples immutable?)

2004-12-25 Thread Bengt Richter
On Wed, 22 Dec 2004 22:57:01 +1000, Nick Coghlan <[EMAIL PROTECTED]> wrote:

>OK, I think I need to recap a bit before starting my reply (for my own 
>benefit, 
>even if nobody else's). (The rest of this post will also include a fair bit of 
>repeating things that have already been said elsewhere in the thread)
>
>
>The actual rule dictionaries use when deciding whether or not to allow a key 
>is 
>simply 'can I hash it?'. Lists don't provide a hash, and tuples only provide a 
>hash if every item they contain provides a hash.
I take it you are referring to regular python dictionaries, since the 
functionality
of a dictionary does not require hashing at all (as I think I demonstrated in 
the part
of my dict subclass which put unhashable keys and their values in another kind 
of
lookup mechanism (namely parallel lists of unhashable keys and their associated 
values).
More one this follows...
>
>For the dictionary to behave sanely, two keys which compare equal must also 
>hash 
>equal. Otherwise, (key1 == key2) == (d[key1] is d[key2]) may not hold.
Hashing has nothing to do with it. Hashing is just one kind of optimization for 
implementing
what has to be done. Sane dictionaries depend on being able to take a lookup 
key object and
finding a unique dict key object that matches with some equality test. After 
finding the dict's
matching unique effective key object, we can get the object being looked up
(the "value" in d[key] = value), because the dict is representing the 
dict_key_object:value association
-- somehow.

"Somehow" _may_ be with a reference pair in a bucket found by a hashing 
mechanism, but it need not be.
Look again (or the first time ?;-) at what happens in my example dict for 
Antoon when you
use a mutable. The pairing there is maintained by key objects and associated 
value objects
being at the same index in parallel lists. The list.index method is used to 
find a unique
key (the first one found is thus by definition the effective unique key (even 
though other key
values can become equal through mutation, only one will be found equal to a 
lookup key's value,
so the _effective_ keys are unique. Hashing has nothing to do with it. Being 
able to find a
unique matching key object in the state of the dict is what provides the 
functionality. The dict's
effective key object must be comparable via __eq__ or __cmp__ or be coercible 
via __coerce__ to
something that can be compared one way or another, or the default equality test 
of
id(lookupkey)==id(dicteffectivekey) for newstyle user objects is applied (I 
guess ;-) by inheriting
object.__cmp__.

Anyway, what I implemented works for mutables as keys and solves the problem in 
the dict definition
instead of requiring that key objects be wrapped to conform to hashability 
requirements of the base
dict. But I did make a choice as to how to maintain a unique _effective_ set of 
keys for the dict state.
(i.e., prioritizing via list.__index__ when key representations were mutated. 
Note that any subset of keys
that was hashable was allowed to work as usual. Only the mutables were stored 
in the mutable key list.

>
>So the one absolute rule on hashes is that (x == y) must imply that (hash(x) 
>== 
>hash(y)). In other words, the hash operation must not involve any object 
>properties that are not also involved in comparison for equality.
>
If you have decided to implement using hashes, yes, but that's not required. 
And as
Alex pointed out, returning an arbitrary integer constant all the time meets 
the above
requirement, since hash(x) == hash(y) will be true no matter what, so it will 
be true
for x == y) (albeit not really "implied" by the latter).

>The rule recommended for hashes is that a mutable object only define a hash if 
>both the comparison operation and the hash are based on immutable portions of 
>the object (such as it's ID). (The language reference currently recommends 
>something stricter - it suggests that you don't define hash at all if you 
>define 
>a custom comparison method on a mutable object. That's overly strict, though)
>
>Now, and here's the key point: Python's builtin objects are written in 
>accordance with this recommendation, which means the mutable objects like dict 
>and list don't define __hash__ at all.
>
>Antoon Pardon wrote:
>> that it would be handy to use such an object as a key and he has some
>> assurance that those objects are stable while in use as a key, I see
>> nothing wrong with using such mutable objects as keys.
>
>Scarily enough, you're starting to persuade me that the idea isn't 
>*completely* 
>insane. Maybe merely mostly insane ;)
>
>The interesting thing is that allowing mutable objects has keys doesn't 
>require 
>*any* changes to dict. It only requires changes to the mutable objects (e.g. 
>having list adopt tuple's hash method).
>
>Anyway, what are the consequences of a type which has a 'variable hash'?
>
>The only real bad consequence is that the internal state of a dictionary can 
>break if 

Re: Clearing the screen

2004-12-25 Thread Ishwor
On Sat, 25 Dec 2004 16:34:26 -0800, Scott David Daniels
<[EMAIL PROTECTED]> wrote:
> Nick Coghlan wrote:
> > Jeff Epler wrote:
> >
> >> I don't know about idle, but the "real" python supports the
> >> PYTHONSTARTUP environment variable.
> >
> > I just tried it - IDLE ignores PYTHONSTARTUP, as does PythonWin (I just
> > started using PYTHONSTARTUP to switch the standard prompt from '>>>' to
> > "Py>').
> >
> > I believe PYTHONSTARTUP is handled by CPython's main function before it
> > gets to the interactive interpreter.
> >
> > Cheers,
> > Nick.
> > 
> From the Fine Manual:
> Command line usage
> idle.py [-c command] [-d] [-e] [-s] [-t title] [arg] ...
> 
> -c command  run this command
> -d  enable debugger
> -e  edit mode; arguments are files to be edited
> -s  run $IDLESTARTUP or $PYTHONSTARTUP first
> -t titleset title of shell window
> 
> On Windows, it is likely to be idle.pyw.  So, add a -s to the command
> line used in the shortcut to start Idle.

okay since i couldn't find .pythonrc in my computer. what i did in the
idle.bat which starts idle.pyw is added the '-r' switch which
basically runs the script from the file -
@echo off
rem Working IDLE bat for Windows - uses start instead of absolute pathname
start idle.pyw -s -r "C:\Python24\file\Pyfiles\clear.py" %1 %2 %3 %4
%5 %6 %7 %8 %9

and it works fine but i have to do
>>>clear.cls();
instead of just plain
>>> cls();
but i'll walk with that. ;-)

I hope this will be clear as i gradually read the text. It has to do
something with the
__builtins__ probably.
Thanks everyone. ;-)

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


-- 
cheers,
Ishwor Gurung
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Clearing the screen

2004-12-25 Thread Steven Bethard
Scott David Daniels wrote:
Nick Coghlan wrote:
Jeff Epler wrote:
I don't know about idle, but the "real" python supports the
PYTHONSTARTUP environment variable.

I just tried it - IDLE ignores PYTHONSTARTUP, as does PythonWin (I 
just started using PYTHONSTARTUP to switch the standard prompt from 
'>>>' to "Py>').

I believe PYTHONSTARTUP is handled by CPython's main function before 
it gets to the interactive interpreter.

Cheers,
Nick.
 From the Fine Manual:
Command line usage
idle.py [-c command] [-d] [-e] [-s] [-t title] [arg] ...
-c command  run this command
-d  enable debugger
-e  edit mode; arguments are files to be edited
-s  run $IDLESTARTUP or $PYTHONSTARTUP first
-t titleset title of shell window
On Windows, it is likely to be idle.pyw.  So, add a -s to the command
line used in the shortcut to start Idle.
Anyone know if there is a similar option to PythonWin?  I looked around 
a bit, but couldn't find one...

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


Re: Clearing the screen

2004-12-25 Thread Ishwor
On Sun, 26 Dec 2004 01:47:42 GMT, Steven Bethard
<[EMAIL PROTECTED]> wrote:
> Scott David Daniels wrote:
> > Nick Coghlan wrote:
> >
> >> Jeff Epler wrote:
> >>
> >>> I don't know about idle, but the "real" python supports the
> >>> PYTHONSTARTUP environment variable.
> >>
> >>
> >> I just tried it - IDLE ignores PYTHONSTARTUP, as does PythonWin (I
> >> just started using PYTHONSTARTUP to switch the standard prompt from
> >> '>>>' to "Py>').
> >>
> >> I believe PYTHONSTARTUP is handled by CPython's main function before
> >> it gets to the interactive interpreter.
> >>
> >> Cheers,
> >> Nick.
> >>
> >  From the Fine Manual:
> > Command line usage
> > idle.py [-c command] [-d] [-e] [-s] [-t title] [arg] ...
> >
> > -c command  run this command
> > -d  enable debugger
> > -e  edit mode; arguments are files to be edited
> > -s  run $IDLESTARTUP or $PYTHONSTARTUP first
> > -t titleset title of shell window
> >
> > On Windows, it is likely to be idle.pyw.  So, add a -s to the command
> > line used in the shortcut to start Idle.
> 
> Anyone know if there is a similar option to PythonWin?  I looked around
> a bit, but couldn't find one...

i was just tinkering with it actually. ;-)
In your command prompt just do
Pythonwin.exe /run "C:\Python24\file\PyFiles\clear.py"

or if you hate doing that then just create a batch  script (.bat) as such-

@echo off
start "C:\Python24\Lib\site-packages\pythonwin\Pythonwin.exe /run
"C:\Python24\file\PyFiles\clear.py" "

see the pythonwin reference manual for more option ;)
> 
> Steve
> --
> http://mail.python.org/mailman/listinfo/python-list
> 


-- 
cheers,
Ishwor Gurung
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Clearing the screen

2004-12-25 Thread Ishwor
heres the shell i forgot to show 

PythonWin 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit (Intel)] on win32.
Portions Copyright 1994-2004 Mark Hammond ([EMAIL PROTECTED])
- see 'Help/About PythonWin' for further copyright information.
>>> clear.cls()
[40 more lines of "\n"]
>>>


-- 
cheers,
Ishwor Gurung
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Mutable objects which define __hash__ (was Re: Why are tuples immutable?)

2004-12-25 Thread Nick Coghlan
Bengt Richter wrote:
I take it you are referring to regular python dictionaries,
Correct. So I'll skip over the sections talking about alternate lookup 
strategies in my reply.

Anyway, what are the consequences of a type which has a 'variable hash'?
The only real bad consequence is that the internal state of a dictionary can 
break if someone alters the hash of one of its keys. The restriction to 
'constant hashes' is aimed squarely at eliminating this class of programming 
errors. It doesn't actually provide any performance gain.
Why not? It means you only have to compute the hash for any given object 
once,
and you can cache the hash value. That could be a biggie if you had megabyte 
trees
of nested tuples as keys and reused them frequently for lookup.
Allowing mutation doesn't mean abandoning your caching - it just means you need 
a way to tell the dict to update it's key cache (i.e. rehash())

I think, for one thing, it would be more efficient to notice that some keys 
were guaranteed not
to need rehashing... um, maybe by paritioning the key set into immutables and 
mutables ;-)
True, since otherwise rehash() would have to check every key, even the immutable 
ones. However, that only affects the time required for a rehash(), rather than 
general dictionary operation.

For another, it's not just a matter of "moving" keys that hash "incorrectly". 
If keys that
are a part of the state of the dict can mutate outside of dict methods, then 
keys can mutate
to equal each other, and "rehashing" will give equal hashes for previously 
unequal and distinct keys,
and you must choose which of the previous values is to be the value for the two 
keys that have now
become one by equality (however __eq__, __cmp__, __coerce__ and inheritance may 
define equality).
Or resist the temptation to guess, and have rehash() raise an exception :)
OTOH, if KeyError is frequent because of mutation, hashing may be next to useless overhead. IOW, DYFR ;-)
Indeed. I defined my FR based on Antoon's analogy of the sorted list - have the 
dict behave like sorted list, so that if you screw the invariant, it's the 
programmer's job to tell the dictionary to fix it.

The problem is also that you really can't make new immutable objects
I don't understand that one. What do you mean by "new immutable object"?
Bad terminology on Antoon's part, I think - I believe he meant "new immutable 
type".
I gave the Python 2.4's Decimal as an example of something which is 
theoretically immutable, but doesn't actually enforce that immutability properly.

Overriding __setattr__ can give true immutability. It just makes the class a 
serious pain to write :)

That is so different that I don't know how it could be used to debug an app that
uses a mutable key dict. I think Antoon was just asking for a key-mutation 
detector.
I think that's reasonable goal. A deep copy of all keys defined would permit 
that,
at least when dict methods had control. But you couldn't find the code that 
mutated
the originals without something outside the dict to catch it in the act.
The identity keyed dict was based on Antoon's posted use case: he wanted to 
classify mutable objects, and then check for membership in those groups.

You can use lists for this, but the lookup is slow. Conventional dictionaries 
and sets give a fast lookup, but require that the items in use be hashable.

An identity dictionary (or set) solves the 'object classification' problem 
perfectly.

You just need to DYFR ;-)
I really do like this acronym :)
Cheers,
Nick.
--
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---
http://boredomandlaziness.skystorm.net
--
http://mail.python.org/mailman/listinfo/python-list


WxListBox

2004-12-25 Thread LutherRevisited
wxpython.org's onlinedocs are down right now so bear with me.  Here's my
problem, currently I'm using a wxtextctrl to enter output in, I'm running out
of rows with the wxtextctrl so I thought to use a listbox like I would in
another language.  I'm unsure how it is constructed or how to add items to it. 
Here is what I've done with the textctrl, I'm wanting to do something like this
in the listbox:

self.text_ctrl_4 = wx.TextCtrl(self, -1, "", style=wx.TE_MULTILINE)
sizer_1.Add(self.text_ctrl_4, 6, wx.LEFT|wx.RIGHT|wx.EXPAND, 80)
self.text_ctrl_4.AppendText(str(count) + '\t\t' + str(address) + '\t\t'
+ str(pageNumber) + '\t\t' + str(pageArray[pageNumber, 1]) +'\r\n')

That's the jist of what I"m doing which works fine, other than me running out
of room on the textctrl.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Complementary language?

2004-12-25 Thread Nick Coghlan
HackingYodel wrote:
Hello all!  I'm learning to program at home.  I can't imagine a better 
language than Python for this.  The ideal situation, for me, would be to 
study two languages at the same time.  Probably sounds crazy, but it 
works out better for me.  Being a newbie, I find almost all languages 
fascinating.  C, D, Objective-C, Ocaml, C++, Lisp, how is a non-tech to 
choose?  Does any single language do a better job in Python's weaker 
areas? Would anyone care to suggest one to supplement Python.  That is, 
if you could only use Python and one other language, which would it be? 
 Thank you for your time and help.
Python (CPython - aka standard - implementation) and C would be my preferred 
combination.

The reason is that I often work with hardware, and hardware means C (since every 
vendor I have ever dealt with provides a C API for their drivers).

It combines well with the CPython interpreter as that, as you may have guessed 
from the name, is written in C and exports a direct C/API.

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


Re: Clearing the screen

2004-12-25 Thread John Machin

Ishwor wrote:

> i was just tinkering with it actually. ;-)
> In your command prompt just do
> Pythonwin.exe /run "C:\Python24\file\PyFiles\clear.py"

It's not a very good idea to store your own scripts in the PythonXY
directory -- other than tested working modules which you install in
PythonXY\lib\site-packages.
E.g. what will you do when Python 2.5 arrives?

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


Re: Complementary language?

2004-12-25 Thread LutherRevisited
I'm a big fan of C# myself, it kinda takes the good from C++ and Java and
combines them in a way.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Clearing the screen

2004-12-25 Thread Ishwor
On 25 Dec 2004 18:20:39 -0800, John Machin <[EMAIL PROTECTED]> wrote:
> 
> Ishwor wrote:
> 
> > i was just tinkering with it actually. ;-)
> > In your command prompt just do
> > Pythonwin.exe /run "C:\Python24\file\PyFiles\clear.py"
> 
> It's not a very good idea to store your own scripts in the PythonXY
> directory -- other than tested working modules which you install in
> PythonXY\lib\site-packages.
> E.g. what will you do when Python 2.5 arrives?
okay. ;-)
First of all, the question Steve posted was "Anyone know if there is a
similar option to PythonWin?  I looked around a bit, but couldn't find
one..."
Second of all, the script doesn't pollute Python*XY* directory because
it doesn't live there ;-)
I created the pythonwin.bat in C:\ 
Inside the pythonwin.bat i added the following lines
@echo off
start C:\Python24\Lib\site-packages\pythonwin\Pythonwin.exe /run
"C:\Python24\file\PyFiles\clear.py" (sorry i put extra "" in earlier
post. This is the right one)
Thirdly when Python2.5 arrives, i just change the directory in the
batch script. ;-)
Thank you.

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


-- 
cheers,
Ishwor Gurung
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Clearing the screen

2004-12-25 Thread Ishwor
On Sun, 26 Dec 2004 13:07:56 +1030, Ishwor <[EMAIL PROTECTED]> wrote:
> On 25 Dec 2004 18:20:39 -0800, John Machin <[EMAIL PROTECTED]> wrote:
> >
> > Ishwor wrote:
> >
> > > i was just tinkering with it actually. ;-)
> > > In your command prompt just do
> > > Pythonwin.exe /run "C:\Python24\file\PyFiles\clear.py"
> >
> > It's not a very good idea to store your own scripts in the PythonXY
> > directory -- other than tested working modules which you install in
> > PythonXY\lib\site-packages.
> > E.g. what will you do when Python 2.5 arrives?
> okay. ;-)
> First of all, the question Steve posted was "Anyone know if there is a
> similar option to PythonWin?  I looked around a bit, but couldn't find
> one..."
> Second of all, the script doesn't pollute Python*XY* directory because
> it doesn't live there ;-)
> I created the pythonwin.bat in C:\
> Inside the pythonwin.bat i added the following lines
> @echo off
> start C:\Python24\Lib\site-packages\pythonwin\Pythonwin.exe /run
If you mean for the pythonwin.exe then remove the pythonwin package
from the computer and reinstall it for python25 ( ofcourse
pythonwin25.exe or something like that) ;-)
then update the batch script.

> "C:\Python24\file\PyFiles\clear.py" (sorry i put extra "" in earlier
> post. This is the right one)
> Thirdly when Python2.5 arrives, i just change the directory in the
> batch script. ;-)

I mean for my script (clear.py) in short do something like 
C:\Python25\file\PyFiles\clear.py

> Thank you.
> 
> >
> > --
> > http://mail.python.org/mailman/listinfo/python-list
> >
> 
> 
> --
> cheers,
> Ishwor Gurung
> 


-- 
cheers,
Ishwor Gurung
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Optional Static Typing - Haskell?

2004-12-25 Thread Mike Meyer
[EMAIL PROTECTED] (Alex Martelli) writes:

> Mind you, I personally _like_ the concept of describing
> an interface separately, even in a different language (Corba's IDL, say)
> that's specialized for the task.  But it doesn't seem to be all that
> popular... without such separation, modularity plus static checking
> appears to imply bottom->up coding: you need to compile modules in some
> topologically sorted order compatible with the "X uses Y" relation.

Personally, I hate declaring the interface separately, whether in the
same language or another language. On the other hand, generating the
interface information from the code for type checking (and
documentation) purposes makes an incredible amount of sense. A type
inferencing engine to generate that information from Python code -
with possible a bit of human assistance - would make it possible to
use pychecker to catch duck typing errors without having to import an
entire module.

 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: Best GUI for small-scale accounting app?

2004-12-25 Thread McBooCzech
Sorry to bother, but I didn't find the final answer to the question
what is the "Best GUI for small-scale accounting app"?

I am the newbie in Python, so I am trying to find some "usable" GUI as
well. But it looks to me there is a lot developers, beta-versions,
tools etc. I have spent a lot of time trying to find which is the
"best" one tool. But now it looks more confusing to me than at the
beginning.

I do not have time to try/test all of them, it is so time-consuming
and confusing specially for total beginner.

IMHO this is the worst think for the Python community: you can find
one Python only with an excellent support. Great But on the other
hand it is possible to find plenty of GUI tools and for the beginner
(and may be not just for the beginner) it is so hard to choose the
"proper" one! The field of GUI tools is so fragmented that I
am close to give it up and start with some commercial product like
Delphi/Kilyx.

BTW you did not discussed Boa, Wingware and BlackAdde (last two are
commercial) here? Are they bad?

Petr

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


Re: Features for a Python package manager?

2004-12-25 Thread Mike Meyer
Nick Coghlan <[EMAIL PROTECTED]> writes:

> I don't know enough about Portage to answer that question. I do know
> any package manager which made it into the standard distribution would
> need to work for at least the big three platforms (Windows/Mac/*nix) :)

Being written in python - and hopefully integrated into Distutils -
why shouldn't it work on any platform that Python worked on?

  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: Best GUI for small-scale accounting app?

2004-12-25 Thread Paul Rubin
"McBooCzech" <[EMAIL PROTECTED]> writes:
> I am the newbie in Python, so I am trying to find some "usable" GUI as
> well. But it looks to me there is a lot developers, beta-versions,
> tools etc. I have spent a lot of time trying to find which is the
> "best" one tool. But now it looks more confusing to me than at the
> beginning.

If all you want is "usable", use Tkinter.  And if you're a newbie, use
Tkinter.  After you've gotten some experience with Tkinter is the time
to start worrying about "best".
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Complementary language?

2004-12-25 Thread Haibao Tang
At home I almost use python exclusively, the other two languages I can
be productive is C# and C++, I chose C# because I am a Windows
programmer (don't throw tomato at me, I am no troll..) and I choose C++
because the algorithm was implemented in this dialect in school.

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


Re: How about "pure virtual methods"?

2004-12-25 Thread Mike Meyer
Noam Raphael <[EMAIL PROTECTED]> writes:

> Mike Meyer wrote:
>> That's what DbC languages are for. You write the contracts first,
>> then
>> the code to fullfill them. And get exceptions when the implementation
>> doesn't do what the contract claims it does.
>> 
> Can you give me a name of one of them? This is a very interesting
> thing - I should learn one of those sometime. However, I'm pretty sure
> that programming in them is hell, or at least, takes a very long time.

Eiffel. Google for SmartEiffel for a free portable implementation. If
you want an IDE/etc., look for EiffelStudio - though it's only
available in binary form. And the two implement different languages
(EiffelStudio implements things accepted as standard for OOSCv3,
whereas SmartEiffel implements things that are still under
consideration in their own variants, and fails to implement some
critical features), though the DbC parts are identical.

I find Eiffel fun to program in. SmartEiffel's libraries are as
flexible as Python's built in types. And debugging with all the
contract checking turned on causes exceptions for truly obscure bugs.

   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: How about "pure virtual methods"?

2004-12-25 Thread Mike Meyer
Noam Raphael <[EMAIL PROTECTED]> writes:

> The current Python doesn't really support this concept. You can write
> in the __new__ of such a class something like "if cls ==
> MyAbstractClass: raise TypeError", but I consider this as a patch -
> for example, if you have a subclass of this class which is abstract
> too, you'll have to write this exception code again. Before
> introducing another problem, let me quote Alex:

You can do *much* better than that. You can finger the class that the
object is an instance of. You don't need a new language construct to
do it, either:

 >> class A:
 ..  def virtualmethod(self):
 ..raise NotImplementedError("virtualmethod not implemented in class %s" \
   % self.__class__.__name__)
 .. 
 >> class B(A):
   pass
 .. 
 >> b = B()
 >> b.virtualmethod()
Traceback (most recent call last):
  File "", line 1, in ?
  File "", line 3, in virtualmethod
NotImplementedError: virtualmethod not implemented in class B
 >> 

I think that error message pinpoints the class of the instance that's
missing the virtual method, which is as good as your proposal would
do, adequately documents that this method needs to be implemented by
subclasses, and has the advantage that you can instantiate only part
of the interface to an abstract class if you only need part of it.

 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: Complementary language?

2004-12-25 Thread Robert Kern
HackingYodel wrote:
Hello all!  I'm learning to program at home.  I can't imagine a better 
language than Python for this.  The ideal situation, for me, would be to 
study two languages at the same time.  Probably sounds crazy, but it 
works out better for me.  Being a newbie, I find almost all languages 
fascinating.  C, D, Objective-C, Ocaml, C++, Lisp, how is a non-tech to 
choose?  Does any single language do a better job in Python's weaker 
areas? Would anyone care to suggest one to supplement Python.  That is, 
if you could only use Python and one other language, which would it be? 
 Thank you for your time and help.
Depends on what you want to get out of the second language. (Disclosure: 
I only use Python, C, and FORTRAN on a regular basis. Any of my comments 
about other languages should be liberally salted.)

For use *with* Python, C could be helpful. I end up writing a little bit 
of C or C++ every once in a while to speed up my calculations or to use 
some library written in C or C++.

If you do numeric calculations, learning just enough FORTRAN to do loops 
and math can be quite useful. I find that F2PY makes writing FORTRAN 
subroutines for numerical calculations over Numeric arrays much easier 
than C.

If you develop on a Mac, some Objective-C could come in handy. I find 
that it's object model and dynamism are quite close to Python's. The 
lessons you learn in each should reinforce the other's. PyObjC makes 
mixing the two languages dead easy and more convenient than indoor 
plumbing. However, almost all Objective-C texts require knowledge of C 
(which makes sense, since Objective-C is a true superset of C, unlike C++).

For didactic purposes, I suggest picking something distinctly *less* 
like C/Java/Python. Learn something that's going to expand the way you 
think about programming. And when you learn a new paradigm, implement it 
in Python and share it with the rest of us.  :-)  For example, Phillip 
J. Eby took the idea of "generic functions" from the Common Lisp Object 
System and implemented it for us[1]. (BTW, thank you, Phillip.)

Common Lisp might be a good one to learn. It's even more 
"multi-paradigm" than Python. You could very easily learn more 
approaches to programming through Common Lisp than three other 
languages. This book[2] looks promising.

Summary recommendation: Learn Python and a language that complements it 
*pedagogically*. When you are fluent in Python and encounter a problem 
where you want to, for example, use a library written in C, then learn 
some C.

[1] http://dirtsimple.org/2004/11/generic-functions-have-landed.html
[2] http://www.gigamonkeys.com/book/
--
Robert Kern
[EMAIL PROTECTED]
"In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die."
  -- Richard Harter
--
http://mail.python.org/mailman/listinfo/python-list


Jython & IronPython Under Active Development?

2004-12-25 Thread Haibao Tang
This question may be a bit weird but I really want to know if these two
hybrid projects are still active.

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


Re: Optional Static Typing

2004-12-25 Thread Robert Kern
Luis M. Gonzalez wrote:
I don't understand why this discussion on optional static typing came
up right at this moment.
As far as I know, it has been discussed many times in the past, and
there even was a SIG that simply died... but it seems that it never was
something of much interest to python developers (that's my impression,
I might be wrong).
Now, that the Pypy project is steadily advancing (and which is aimed at
making Python faster while keeping it dynamic and simple), why has this
topyc been raised?
Also there's starkiller, which deals with agressive type inference and
compilation to native code. If these projects are serious and are well
headed, then I don't know why we are talking now of static typing.
Lets say that Pypy and/or Starkiller end up as succesful projects, what
would be the advantage of having static typing in Python?
Starkiller would *love* type declarations. In Michael Salib's words (to 
my recollection), "every piece of type information helps." I'm sure that 
PyPy's code generator(s) could use this information to good effect, too.

Automatic type inferencing is great, but sometimes the inference is 
"object". Being able to supply more information about types helps 
Starkiller keep the inferences tight and specific.

--
Robert Kern
[EMAIL PROTECTED]
"In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die."
  -- Richard Harter
--
http://mail.python.org/mailman/listinfo/python-list


Re: gridbaglayout

2004-12-25 Thread Grant Edwards
On 2004-12-24, Ishwor <[EMAIL PROTECTED]> wrote:

> heh? whats this gridbaglayout in Python-list?? Is this what my grandpa
> calls "christmas fever"?? ;-)

heh? what's this top-posting in comp.lang.python?

gridbagsizer is a wxPython/wxWidgets sizer class.  Why shouldn't it be
discussed here?

-- 
Grant Edwards   grante Yow!  With YOU, I can be
  at   MYSELF... We don't NEED
   visi.comDan Rather...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Complementary language?

2004-12-25 Thread Mike Meyer
HackingYodel <[EMAIL PROTECTED]> writes:

> Hello all!  I'm learning to program at home.  I can't imagine a better
> language than Python for this.  The ideal situation, for me, would be
> to study two languages at the same time.  Probably sounds crazy, but
> it works out better for me.  Being a newbie, I find almost all
> languages fascinating.  C, D, Objective-C, Ocaml, C++, Lisp, how is a
> non-tech to choose?  Does any single language do a better job in
> Python's weaker areas? Would anyone care to suggest one to supplement
> Python.  That is, if you could only use Python and one other language,
> which would it be? Thank you for your time and help.

It depends on what your goals are. Python is an excellent language for
learning OO and procedural programming, and makes it possible to learn
functional programming as well.

Part of the Python philosphy is that there should be one obvious way
to do something. That's what makes it an attractive language to
me. Eiffel shares this philosphy, in that every feature of the
language was added to solve a specific problem that programmers
encounter. It does many other things the exact opposite of
Python. It's statically typed, with no loopholes allowed. For cases
where you're not sure that something is conformant with a variable
(meaning it's the same class as the variable or inherits from it in
some way), there's even a "work if you can" assignment operator. So
you see code that looks like:

   a ?= b
   if a /= Void then
  doSomethingWith(a)
   else
  doSomethingElseWith(b)
   end

As you can see, it keywords instead of :. It's pure OO, in that there
are no free-standing functions; every function is a method of a
class. Functions aren't first-class objects, so you can invoke
parameterless methods with just object.method. This allows subclasses
to change such a method to a variable without you having to change any
code anywhere else in the system. It has export rules to control what
features (shorthand for methods and instance/class variables) are
visible to what other classes. Exceptions are handled in a completely
different method as well, with a method having an optional "rescue"
clause that gets invoked when an exception is raised, should repair
things, and then retries the method.

The key feature is "Design by Contract". Each method can have a set of
boolean expressions that must be true when the method is invoked, or
an exception is raised. Likewise, each method has a set of boolean
expressions that must be true when the function exits, or an exception
is raised. Finally, there's a set of expressions that are always true
when an externally-invoked method exits. These are the contracts, and
they make debugging wonderful. You can disable all those checks for
production code.

There are tools to display the the method headers, header comment, and
contracts (short form). There is a tool to display all methods a class
has, including inherited methods (flat form), and of course there's a
tool that displays the shortflat form.

If you want to do GUI programming on Windows, Linux or FreeBSD 5.x,
EiffelStudio is probably your best bet. It comes with a standard GUI
library, an IDE built on that library, and a reasonably
standards-compliant compiler and library. It hasn't yet drifted into
the parts of the language that are undergoing experimental changes.

  http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


list addition methods compared.

2004-12-25 Thread Ishwor
Hi all
I have just wrote a small script to compare the speed of list addition methods.
heres what it looks like.

#listadditioncompare.py
#compare the speeds of 3 different type of list element addition
import time
def method(TYPE):
l1 = [];
l2 = [];
l3 = [];

if TYPE == 1:
finish = 0;
start = 0;
start = time.time();
for y in range(0,3):
for x in range(0,1):
l1 = l1 + [x];# type 1
l1 = [];
finish += time.time();
averageFinish = finish/3;
#m = float(finish-start);
print "Method 1 done in (average finish time(out of 3)) -
%.10f" %(averageFinish-start);

if TYPE == 2:
finish = 0;
start = 0;
start = time.time();
for y in range(0,3):
for x in range(0,1):
l2 = l2 + [x];# type 2
l2 = [];
finish += time.time();
averageFinish = finish/3;
#m = float(finish-start);
print "Method 2 done in (average finish time(out of 3)) -
%.10f" %(averageFinish-start);

if TYPE == 3:
finish = 0;
start = 0;
start = time.time();
for y in range(0,3):
for x in range(0,1):
l3 +=  [x];# type 3
l3 = [];
finish += time.time();
averageFinish = finish/3;
#m = float(finish-start);
print "Method 3 done in (average finish time(out of 3)) -
%.10f" %(averageFinish-start);

print "@@@";
method(1);
method(2);
method(3);
print "@@@";

So far i think it does good. Running it 3 times gives

>>> 
@@@
Method 1 done in (average finish time(out of 3)) - 1.1560001373
Method 2 done in (average finish time(out of 3)) - 1.161409
Method 3 done in (average finish time(out of 3)) - 0.010088
@@@

>>> 
@@@
Method 1 done in (average finish time(out of 3)) - 1.161134
Method 2 done in (average finish time(out of 3)) - 1.125092
Method 3 done in (average finish time(out of 3)) - 0.0156667233
@@@
>>> 

>>> 
@@@
Method 1 done in (average finish time(out of 3)) - 1.1563334465
Method 2 done in (average finish time(out of 3)) - 1.1716668606
Method 3 done in (average finish time(out of 3)) - 0.0106668472
@@@
>>> 

So i can assume that type 3 ( l3 += [x] ) addition is the fastest . Is
there anything i am doing wrong?? Also could this code be beautified
&& shortened??
Thanks.

-- 
cheers,
Ishwor Gurung
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Features for a Python package manager?

2004-12-25 Thread Robert Kern
Mike Meyer wrote:
Nick Coghlan <[EMAIL PROTECTED]> writes:

I don't know enough about Portage to answer that question. I do know
any package manager which made it into the standard distribution would
need to work for at least the big three platforms (Windows/Mac/*nix) :)

Being written in python - and hopefully integrated into Distutils -
why shouldn't it work on any platform that Python worked on?
Assumptions about directory structures, and the like. IIRC, Portage was 
written for the Gentoo project, so it could assume that it was 
installing stuff to a Gentoo system. Package management systems have a 
distressing habit of infecting their *architecture* with these 
assumptions. It makes adapting them difficult.

Also, Portage needs to execute subprocesses, something which is 
notoriously platform dependent. 2.4's subprocess module should probably 
be used here, but I don't think Portage does, yet. OTOH, it's Gentoo, so 
it wouldn't surprise me, either.  :-)

--
Robert Kern
[EMAIL PROTECTED]
"In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die."
  -- Richard Harter
--
http://mail.python.org/mailman/listinfo/python-list


WxListBox

2004-12-25 Thread LutherRevisited
I'm wanting to put a listbox in the place of a textctrl I'm using in my
application because I'm running out of space in my textctrl.  The online
documentation is down at wxpython.org so I have no idea how to construct this
control or anything.  Can someone help me out.  Here's what I'm doing with the
WxTextCtrl:

self.text_ctrl_4 = wx.TextCtrl(self, -1, "", style=wx.TE_MULTILINE)
sizer_1.Add(self.text_ctrl_4, 6, wx.LEFT|wx.RIGHT|wx.EXPAND, 80)
self.text_ctrl_4.AppendText(str(count) + '\t\t' + str(address) + '\t\t'
+ str(pageNumber) + '\t\t' + str(pageArray[pageNumber, 1]) +'\r\n')

I'm wanting to implement something similar with a listbox, any thoughts?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: gridbaglayout

2004-12-25 Thread Ishwor
On 26 Dec 2004 04:05:54 GMT, Grant Edwards <[EMAIL PROTECTED]> wrote:
> On 2004-12-24, Ishwor <[EMAIL PROTECTED]> wrote:
> 
> > heh? whats this gridbaglayout in Python-list?? Is this what my grandpa
> > calls "christmas fever"?? ;-)
> 
> heh? what's this top-posting in comp.lang.python?
> 
> gridbagsizer is a wxPython/wxWidgets sizer class.  Why shouldn't it be
> discussed here?
haha..
I was just fooling around on Christmas eve. I didn't mean to insult
anyone thats why i top -posted it without referencing anyone's msg.
;-)

> 
> --
> Grant Edwards   grante Yow!  With YOU, I can be
>  at   MYSELF... We don't NEED
>   visi.comDan Rather...
> --
> http://mail.python.org/mailman/listinfo/python-list
> 


-- 
cheers,
Ishwor Gurung
-- 
http://mail.python.org/mailman/listinfo/python-list


A Revised Rational Proposal

2004-12-25 Thread Mike Meyer
This version includes the input from various and sundry people. Thanks
to everyone who contributed.

   
Status: Draft
Type: Staqndards
Content-Type: text/x-rst
Created: 16-Dec-2004
Python-Version: 2.5
Post-History: 15-Dec-2004, 25-Dec-2004


Contents


* Abstract
* Motivation
* Rationale
  + Conversions
  + Python usability
* Specification
  + Explicit Construction
  + Implicit Construction
  + Operations
  + Exceptions
* Open Issues
* Implementation
* References


Abstract


This PEP proposes a rational number module to add to the Python
standard library.


Motivation
=

Rationals are a standard mathematical concept, included in a variety
of programming languages already.  Python, which comes with 'batteries
included' should not be deficient in this area.  When the subject was
brought up on comp.lang.python several people mentioned having
implemented a rational number module, one person more than once. In
fact, there is a rational number module distributed with Python as an
example module.  Such repetition shows the need for such a class in the
standard library.
n
There are currently two PEPs dealing with rational numbers - 'Adding a
Rational Type to Python' [#PEP-239] and 'Adding a Rational Literal to
Python' [#PEP-240], both by Craig and Zadka.  This PEP competes with
those PEPs, but does not change the Python language as those two PEPs
do [#PEP-239-implicit]. As such, it should be easier for it to gain
acceptance. At some future time, PEP's 239 and 240 may replace the
``rational`` module.


Rationale
=

Conversions
---

The purpose of a rational type is to provide an exact representation
of rational numbers, without the imprecistion of floating point
numbers or the limited precision of decimal numbers.

Converting an int or a long to a rational can be done without loss of
precision, and will be done as such.

Converting a decimal to a rational can also be done without loss of
precision, and will be done as such.

A floating point number generally represents a number that is an
approximation to the value as a literal string.  For example, the
literal 1.1 actually represents the value 1.1001 on an x86
one platform.  To avoid this imprecision, floating point numbers
cannot be translated to rationals directly.  Instead, a string
representation of the float must be used: ''Rational("%.2f" % flt)''
so that the user can specify the precision they want for the floating
point number.  This lack of precision is also why floating point
numbers will not combine with rationals using numeric operations.

Decimal numbers do not have the representation problems that floating
point numbers have.  However, they are rounded to the current context
when used in operations, and thus represent an approximation.
Therefore, a decimal can be used to explicitly construct a rational,
but will not be allowed to implicitly construct a rational by use in a
mixed arithmetic expression.


Python Usability
-

* Rational should support the basic arithmetic (+, -, *, /, //, **, %,
  divmod) and comparison (==, !=, <, >, <=, >=, cmp) operators in the
  following cases (check Implicit Construction to see what types could
  OtherType be, and what happens in each case):

+ Rational op Rational
+ Rational op otherType
+ otherType op Rational
+ Rational op= Rational
+ Rational op= otherType
* Rational should support unary operators (-, +, abs).

* repr() should round trip, meaning that:

  m = Rational(...)
  m == eval(repr(m))

* Rational should be immutable.

* Rational should support the built-in methods:

+ min, max
+ float, int, long
+ str, repr
+ hash
+ bool (0 is false, otherwise true)

When it comes to hashes, it is true that Rational(25) == 25 is True, so
hash(Rational (25)) should be equal to hash(25).

The detail is that you can NOT compare Rational to floats, strings or
decimals, so we do not worry about them giving the same hashes. In
short:

hash(n) == hash(Rational(n))   # Only if n is int, long or Rational

Regarding str() and repr() behaviour, Ka-Ping Yee proposes that repr() have
the same behaviour as str() and Tim Peters proposes that str() behave like the
to-scientific-string operation from the Spec.


Specification
=

Explicit Construction
-

The module shall be ``rational``, and the class ``Rational``, to
follow the example of the decimal [#PEP-327] module. The class
creation method shall accept as arguments a numerator, and an optional
denominator, which defaults to one.  Both the numerator and
denominator - if present - must be of integer or decimal type, or a
string representation of a floating point number. The string
representation of a floating point number will be converted to
rational without being converted to float to preserve the accuracy of
the number. Since all other numeric types in Python are immutable,
Rational objects will be immutable.  Internally, the representation
will insure that the numerator and den

methods of addition in Python

2004-12-25 Thread Ishwor
As my earlier mail didn't make it c.l.py because it had the heading
"LIST Addition compared", probably it was blocked by the mail server.
;-)
anyway heres it again.. Sorry for people reading it again. Its the same post.

Hi all
I have just wrote a small script to compare the speed of list addition methods.
heres what it looks like.

#listadditioncompare.py
#compare the speeds of 3 different type of list element addition
import time
def method(TYPE):
   l1 = [];
   l2 = [];
   l3 = [];

   if TYPE == 1:
   finish = 0;
   start = 0;
   start = time.time();
   for y in range(0,3):
   for x in range(0,1):
   l1 = l1 + [x];# type 1
   l1 = [];
   finish += time.time();
   averageFinish = finish/3;
   #m = float(finish-start);
   print "Method 1 done in (average finish time(out of 3)) -
%.10f" %(averageFinish-start);

   if TYPE == 2:
   finish = 0;
   start = 0;
   start = time.time();
   for y in range(0,3):
   for x in range(0,1):
   l2 = l2 + [x];# type 2
   l2 = [];
   finish += time.time();
   averageFinish = finish/3;
   #m = float(finish-start);
   print "Method 2 done in (average finish time(out of 3)) -
%.10f" %(averageFinish-start);

   if TYPE == 3:
   finish = 0;
   start = 0;
   start = time.time();
   for y in range(0,3):
   for x in range(0,1):
   l3 +=  [x];# type 3
   l3 = [];
   finish += time.time();
   averageFinish = finish/3;
   #m = float(finish-start);
   print "Method 3 done in (average finish time(out of 3)) -
%.10f" %(averageFinish-start);

print "@@@";
method(1);
method(2);
method(3);
print "@@@";

So far i think it does good. Running it 3 times gives

>>>
@@@
Method 1 done in (average finish time(out of 3)) - 1.1560001373
Method 2 done in (average finish time(out of 3)) - 1.161409
Method 3 done in (average finish time(out of 3)) - 0.010088
@@@

>>>
@@@
Method 1 done in (average finish time(out of 3)) - 1.161134
Method 2 done in (average finish time(out of 3)) - 1.125092
Method 3 done in (average finish time(out of 3)) - 0.0156667233
@@@
>>>

>>>
@@@
Method 1 done in (average finish time(out of 3)) - 1.1563334465
Method 2 done in (average finish time(out of 3)) - 1.1716668606
Method 3 done in (average finish time(out of 3)) - 0.0106668472
@@@
>>>

So i can assume that type 3 ( l3 += [x] ) addition is the fastest . Is
there anything i am doing wrong?? Also could this code be beautified
&& shortened??
Thanks.


-- 
cheers,
Ishwor Gurung
-- 
http://mail.python.org/mailman/listinfo/python-list


Twisted Non-Admin Installation

2004-12-25 Thread Kartic
Hello,

I downloaded the Win32 installer for Twisted 1.3.0, Python 2.3.

The installer, when executed under my login, fails as it requires
administrator rights to install (why they have it as a requirement, I
don't understand).

So I started the installer as the admin user. That too failed because I
have a non-admin install of Python 2.3 on my machine and when I launch
the Twisted installer as admin, it is unable to find a Python
installation for the admin user!

So, can someone let me know how I can install Twisted as a non-admin
user for a non-admin installation of Python? Installing from source is
not an option as I do not have MSVC.

Thank you,
--Kartic

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


Re: Twisted Non-Admin Installation

2004-12-25 Thread Kartic
BTW, I googled using some keywords and found nothing that would solve
my problem. I could also not find a searchable version of the twisted
mailing list.

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


Re: Twisted Non-Admin Installation

2004-12-25 Thread Mike Meyer
"Kartic" <[EMAIL PROTECTED]> writes:

> Hello,
>
> I downloaded the Win32 installer for Twisted 1.3.0, Python 2.3.
>
> The installer, when executed under my login, fails as it requires
> administrator rights to install (why they have it as a requirement, I
> don't understand).
>
> So I started the installer as the admin user. That too failed because I
> have a non-admin install of Python 2.3 on my machine and when I launch
> the Twisted installer as admin, it is unable to find a Python
> installation for the admin user!
>
> So, can someone let me know how I can install Twisted as a non-admin
> user for a non-admin installation of Python? Installing from source is
> not an option as I do not have MSVC.

You can get the MSVC compiler for free, and use that to build from
source. See 

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/73f29284d1e031c7

for details.

  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: Twisted Non-Admin Installation

2004-12-25 Thread Kartic
Thanks. Does this mean I have to upgrade python 2.3.3 to python 2.4 in
order to get this working?

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


Re: Complementary language?

2004-12-25 Thread Hal Rosser

"HackingYodel" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hello all!  I'm learning to program at home.  I can't imagine a better
> language than Python for this.  The ideal situation, for me, would be to
> study two languages at the same time.  Probably sounds crazy, but it
> works out better for me.  Being a newbie, I find almost all languages
> fascinating.  C, D, Objective-C, Ocaml, C++, Lisp, how is a non-tech to
> choose?  Does any single language do a better job in Python's weaker
> areas? Would anyone care to suggest one to supplement Python.  That is,
> if you could only use Python and one other language, which would it be?
>   Thank you for your time and help.

 Java. Because of Jython.
Perfect partners. They can work together.



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.818 / Virus Database: 556 - Release Date: 12/17/2004


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


Re: Jython & IronPython Under Active Development?

2004-12-25 Thread Simon John

Haibao Tang wrote:
> This question may be a bit weird but I really want to know if these
two
> hybrid projects are still active.

they're both by the same guy, and i think jython just had a new
release, although i expect ironpython will turn into microsoft visual
python.net instead of reaching v1.0

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


Configuration Files

2004-12-25 Thread Aaron
Hi,

I'm interested in creating a large number of configuration files which I
have no experience doing in python. The fields will be static for the most
part. But design changes and I might want to add new fields in the future..

My question is - whats the best module for creating, reading, and editing
these files(something like an INI)? I want it to be powerful,
yet simple and minimalistic, not requiring a huge amount of overhead.

I've heard of xml, and have seen it used in both html fashion, and
likewise, without any tags at all- just spaces in between entries; why is
this? CSV is another thing I've seen thrown around on online
documentation. Whats the difference between the two, and which one should
I use(if either)?

-thanks in advance
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Jython & IronPython Under Active Development?

2004-12-25 Thread Robert Kern
Simon John wrote:
Haibao Tang wrote:
This question may be a bit weird but I really want to know if these
two
hybrid projects are still active.

they're both by the same guy, and i think jython just had a new
release, although i expect ironpython will turn into microsoft visual
python.net instead of reaching v1.0
It should be noted that Jim Hugunin no longer works on Jython although 
he did start the project (possibly with others, I'm not sure).

--
Robert Kern
[EMAIL PROTECTED]
"In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die."
  -- Richard Harter
--
http://mail.python.org/mailman/listinfo/python-list


WxButton

2004-12-25 Thread LutherRevisited
I have a simple application in a Frame, in it I have a button that I want to
press when I hit enter.  How can I do this?  I know with textctrl's you have
the EVT_TEXT_ENTER event to do things for you when enter is pressed, can I do
the same with a button.  I know in WxWidgets for C++ you can put it in a
WxDialog and it will do all that anyway, but my version of WxPython doesn't
have that
-- 
http://mail.python.org/mailman/listinfo/python-list


double post

2004-12-25 Thread LutherRevisited
I think I did a double post on WxListBox, my apologies, I wasn't seeing it show
up  and I didn't take into account the holidays...sorry.
-- 
http://mail.python.org/mailman/listinfo/python-list


Please Donate to the PSF

2004-12-25 Thread Stephan Deibel
Hi,

As the holiday season ends and a new year approaches, I would like to take
this opportunity to thank everyone that donated to the Python Software
Foundation (PSF) in the past.  Everyone's support is greatly appreciated.

We now have well over 400 donors, many of whom donate regularly:

http://www.python.org/psf/donations.html

We also have 15 sponsor members that contribute annually to the PSF:

http://www.python.org/psf/

Because of our donors and sponsors, the PSF was able to issue its first   
grants solicitation in 2004.  This was very successful, with many more
quality submissions than we could fund.  Several grants have been approved
for completion in 2005.  With these and future grants, we intend to
continue improving Python.

The PSF also manages the intellectual property rights behind Python and
runs the PyCon developers conference annually:

http://www.python.org/pycon/  

Please consider donating in order to support Python and the PSF.  We are
currently accepting donations via check or PayPal, and will soon begin  
accepting credit cards directly.  Donations can be made starting here:

http://www.python.org/psf/donations.html

The PSF is a registered 501(c)(3) charity so donations are tax-deductible
for US tax payers.  There is still time to make a donation that can be   
deducted in the 2004 tax year.

If you would like to learn more about the PSF, please visit:

http://www.python.org/psf/

Happy New Year!

Sincerely,

Stephan Deibel
Chairman of the Board
Python Software Foundation

http://python.org/psf

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


Re: Configuration Files

2004-12-25 Thread M.E.Farmer
Aaron wrote:
> Hi,
>
> I'm interested in creating a large number of configuration files
which I
> have no experience doing in python. The fields will be static for the
most
> part. But design changes and I might want to add new fields in the
future..
>
> My question is - whats the best module for creating, reading, and
editing
> these files(something like an INI)?

Ummm did you look at the standard library before asking any on this?
If you are a total newbie I'll give you a start it is in the
Python/Lib folder.
Look for a module called ConfigParser.py ;)
I might post a code sample if I am up to itso much turkey, and
cookies.

> I want it to be powerful,
> yet simple and minimalistic, not requiring a huge amount of overhead.
Don't we all!

M.E.Farmer

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


Re: Twisted Non-Admin Installation

2004-12-25 Thread Mike Meyer
"Kartic" <[EMAIL PROTECTED]> writes:

> Thanks. Does this mean I have to upgrade python 2.3.3 to python 2.4 in
> order to get this working?

Whoops. Yeah, the instruction are for using MSVC 7.1, which is what
2.4 is build with. 2.3.x is built with MSVC 6.x. That's no longer even
commercially available.

There may be a way to do what you want without upgrading the
python. I'm not a Windows user, but happened to note that URL in
passing, and posted it to be helpful. I'd wait until after the holiday
to see if anyone has instructions that avoid having to upgrade Python
unless you want to upgrade anyway. Doing so will require rebuilding
all your .dll extensions, though. At least - on Unix upgrading from
2.x to 2.(x+1) requires reinstalling all extensions.

  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: Configuration Files

2004-12-25 Thread Mike Meyer
Aaron <[EMAIL PROTECTED]> writes:

> Hi,
>
> I'm interested in creating a large number of configuration files which I
> have no experience doing in python. The fields will be static for the most
> part. But design changes and I might want to add new fields in the future..
>
> My question is - whats the best module for creating, reading, and editing
> these files(something like an INI)? I want it to be powerful,
> yet simple and minimalistic, not requiring a huge amount of overhead.
>
> I've heard of xml, and have seen it used in both html fashion, and
> likewise, without any tags at all- just spaces in between entries; why is
> this? CSV is another thing I've seen thrown around on online
> documentation. Whats the difference between the two, and which one should
> I use(if either)?

M.E. Farmer already suggested the ConfigParser module, and I have to
concurr with him - it basically handles INI files.

XML is verbose. It allows the construction of complex data structures
(it's been called S-expressions with brokeits). It's primary advantage
is that there are tools for dealing with XML sanely - XML editors,
validators, parsers, and similar things. Without those tools, it can
be a PITA to deal with.  So if your configuration is simple enough to
be captured by an INI file, avoid XML. If not, then googling for "xml
editor windows free" turns up a fair number of hits. For Unix, I used
to use an XML editor called Ted that was written in Python, but can't
turn anything up on google. There are xml editors for both KDE and
Gnome. Personally, I use psgml, which is an emacs package that handles
both xml and it's parent sgml.

CSV stands for Comma Separated Values. It's primarily an interchange
format for spreadsheet programs. While there is a default csv module
(that also handles tab separated values, and other arbitrary
separators), it's not the right tool for use as a config file.

   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: Configuration Files

2004-12-25 Thread M.E.Farmer
Here are two functions that show how to use ConfigParser.

py>def ConfigWrite(key, value, section, cfgpath):
...  import ConfigParser, pprint
...  parser=ConfigParser.ConfigParser()
...  cfg = open(cfgpath,'w')
...  parser.add_section(section)
...  Pretty = pprint.PrettyPrinter()#optional
...  value = Pretty.pformat(value)#optional
...  parser.set(section,key,value)
...  parser.write(cfg)
...  cfg.close()


py>def ConfigReader(key, section, cfgpath):
...  import ConfigParser
...  parser=ConfigParser.ConfigParser()
...  parser.read(cfgpath)
...  return parser.get(section,key)
Hope that helps...now *where* are  those sugar cookies 
M.E.Farmer

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


Re: Features for a Python package manager?

2004-12-25 Thread Georg Brandl
Robert Kern wrote:
> Mike Meyer wrote:
>> Nick Coghlan <[EMAIL PROTECTED]> writes:
>> 
>> 
>>>I don't know enough about Portage to answer that question. I do know
>>>any package manager which made it into the standard distribution would
>>>need to work for at least the big three platforms (Windows/Mac/*nix) :)
>> 
>> 
>> Being written in python - and hopefully integrated into Distutils -
>> why shouldn't it work on any platform that Python worked on?
> 
> Assumptions about directory structures, and the like.

That is already taken care by the distutils. The various PEPs already
describe a simple method how to store package metadata, and I will try
to follow these standards as close as possible. Of course, the PyPI
would have to be adapted for that.

> IIRC, Portage was 
> written for the Gentoo project, so it could assume that it was 
> installing stuff to a Gentoo system. Package management systems have a 
> distressing habit of infecting their *architecture* with these 
> assumptions. It makes adapting them difficult.

> Also, Portage needs to execute subprocesses, something which is 
> notoriously platform dependent. 2.4's subprocess module should probably 
> be used here, but I don't think Portage does, yet. OTOH, it's Gentoo, so 
> it wouldn't surprise me, either.  :-)

That's right, but I would just draw the line at Python's standard
library. What is possible with it, is done, what not, is left out.

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