Re: ? about file() and open()

2005-01-03 Thread Reinhold Birkenfeld
Sean wrote:
> Was wondering if there was any difference between these two functions.
> I have read some text that said file() wasn't introduced until 2.2 and
> that it was synonymous with open().  Does this mean that I should be
> using file() where I used open() before?

FYI, I submitted a patch to correct the docs:
http://www.python.org/sf/1094011

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


Re: Rebinding stdout (was: Re: Python! Is! Truly! Amazing!)

2005-01-03 Thread JanC
Ron Garret schreef:

> But this topic does bring up a legitimate question: I have a bunch of 
> code that generates HTML using PRINT statements.  I need to convert all 
> this code to return strings rather than actually printing them (so I can 
> use the results to populate templates).  In Lisp I could do this:
> 
> (with-output-to-string (s)
>   (let ( (*standard-output* s) )
> (call-html-generating-code)
> s))
> 
> Is there an equivalent Python trick to capture a function call's output 
> as a string?

Something like this:

py> import cStringIO
py> import sys
py>
py> def foo():
... print "test"
...
py> f = cStringIO.StringIO()
py> sys.stdout = f
py> foo()
py> s = f.getvalue()
py> sys.stdout = sys.__stdout__
py> f.close()
py> print s.capitalize()
Test



-- 
JanC

"Be strict when sending and tolerant when receiving."
RFC 1958 - Architectural Principles of the Internet - section 3.9
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Rebinding stdout (was: Re: Python! Is! Truly! Amazing!)

2005-01-03 Thread Just
In article <[EMAIL PROTECTED]>,
 JanC <[EMAIL PROTECTED]> wrote:

> Something like this:
> 
> py> import cStringIO
> py> import sys
> py>
> py> def foo():
> ... print "test"
> ...
> py> f = cStringIO.StringIO()
> py> sys.stdout = f
> py> foo()
> py> s = f.getvalue()
> py> sys.stdout = sys.__stdout__

You should always save stdout instead of using __stdout__. It may not be 
the same! I don't think anyone should *ever* use __stdout__ except when 
debugging. See also:

  http://mail.python.org/pipermail/python-dev/2000-October/010144.html

> py> f.close()
> py> print s.capitalize()
> Test

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


Re: UserDict deprecated

2005-01-03 Thread Wolfgang
Hello,
Alex Martelli wrote:
The DictMixin class from the UserDict module is *not* deprecated -- only
the UserDict class from the same module.  (If you found info saying
otherwise pls provide a URL: the info is wrong and I'll try to get it
fixed -- thanks!).  DictMixin's purpose is exactly as you state: letting
you make a complete mapping class out of one which only supplies the
very basics, by mix-in inheritance.
If UserDict is deprecated why is it still used in the os module ?
(in python V. 2.4)
The std lib should be a good example for python coding, if something
is deprecated it should not be used in the std lib.
Some weeks ago I had ten minutes of spare time and rewrote the 'os' 
module to use dict and there was no problem with it.
But due to lack of time I was not able to run tests and submitted no 
patch. I will try this next week.

bye by Wolfgang
--
http://mail.python.org/mailman/listinfo/python-list


Re: [Twisted-Python] Problem with Echoserver (TCP), Help!

2005-01-03 Thread SeSe
Thanks. I have disabled my firewall. But still failed.
It is a bit strange that echo server UDP works. Only TCP doesn't.
Regards,
SeSe
Kartic wrote:
Hi,
My experience with Twisted is also limited but let me try to help you.
I tried the same combo as you and it worked well with the following
responses:
receive: Hello, world!
receive: What a fine day it is.
receive: Bye-bye!
connection lost: Connection was closed cleanly.
I am sure you started the server before the client.
Do you have some firewall software installed that prevents the client
from connecting to the server?
Thanks
--Kartic
--
http://mail.python.org/mailman/listinfo/python-list


MDaemon Warning - virus found: Error

2005-01-03 Thread l . cubells

*** WARNING **
Este mensaje ha sido analizado por MDaemon AntiVirus y ha encontrado 
un fichero anexo(s) infectado(s).  Por favor revise el reporte de abajo.

AttachmentVirus name   Action taken
--
file.zip  I-Worm.Mydoom.m  Removed


**


This message was not delivered due to the following reason(s):

Your message was not delivered because the destination server was
not reachable within the allowed queue period. The amount of time
a message is queued before it is returned depends on local configura-
tion parameters.

Most likely there is a network problem that prevented delivery, but
it is also possible that the computer is turned off, or does not
have a mail system running right now.

Your message could not be delivered within 2 days:
Host 7.131.94.177 is not responding.

The following recipients did not receive this message:


Please reply to [EMAIL PROTECTED]
if you feel this message to be in error.

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

Re: The Industry choice

2005-01-03 Thread JanC
Paul Rubin schreef:

> The AOL web server also uses tcl as a built-in dynamic content
> generation language (i.e. sort of like mod_python), or at least it
> used to.

It still does:
"""
AOLserver is America Online's Open-Source web server. AOLserver is the 
backbone of the largest and busiest production environments in the world. 
AOLserver is a multithreaded, Tcl-enabled web server used for large scale, 
dynamic web sites.
"""



-- 
JanC

"Be strict when sending and tolerant when receiving."
RFC 1958 - Architectural Principles of the Internet - section 3.9
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Rebinding stdout (was: Re: Python! Is! Truly! Amazing!)

2005-01-03 Thread Simo Melenius
Ron Garret <[EMAIL PROTECTED]> writes:

> (with-output-to-string (s)
>   (let ( (*standard-output* s) )
> (call-html-generating-code)
> s))
>
> Is there an equivalent Python trick to capture a function call's output 
> as a string?

I've sometimes replaced sys.stdout (and/or sys.stderr) to
capture/redirect debugging information in existing code that has
unwisely just "print"ed error and warning messages, instead of using
sys.stderr or error logging modules.

py> def with_output_to_string (func):
... try:
... sys.stdout = StringIO.StringIO ()
... func ()
... return sys.stdout.getvalue ()
... finally:
... sys.stdout = sys.__stdout__
...
py> def printing_code ():
... print "Foobar"
...
py> with_output_to_string (printing_code)
'Foobar\n'
py>


br,
S
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Rebinding stdout (was: Re: Python! Is! Truly! Amazing!)

2005-01-03 Thread Just
In article <[EMAIL PROTECTED]>,
 Simo Melenius <[EMAIL PROTECTED]> wrote:

> I've sometimes replaced sys.stdout (and/or sys.stderr) to
> capture/redirect debugging information in existing code that has
> unwisely just "print"ed error and warning messages, instead of using
> sys.stderr or error logging modules.
> 
> py> def with_output_to_string (func):
> ... try:
> ... sys.stdout = StringIO.StringIO ()
> ... func ()
> ... return sys.stdout.getvalue ()
> ... finally:
> ... sys.stdout = sys.__stdout__

Aargh, I can't believe how widespread this idiom is :-(. See my other 
reply in this thread: DON'T use sys.__stdout__. Ever.

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


Re: Problem remotely shutting down a windows computer with python

2005-01-03 Thread Duncan Booth
Kartic wrote:

> Looks like this is the documented outcome. You could alternatively try
> setting a little XML-RPC app to invoke 'shutdown -s' on the remote PC
> from your PC (e.g. using Twisted Python).
> 

Or invoke 'shutdown -s -m \\machinename' on the local machine to shutdown a 
remote machine.

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


Re: Python! Is! Truly! Amazing!

2005-01-03 Thread jfj
Ron Garret wrote:
In article <[EMAIL PROTECTED]>,
 "Erik  Bethke" <[EMAIL PROTECTED]> wrote:

I have NEVER experienced this kind of programming joy.

Just wait until you discover Lisp!
;-)

I've had it with all those lisp posts lately ;-)
There were functional and non-functional programming languages (the 
first being *much* simpler to implement). There is a *reason* people 
chose C over lisp. It's not that we were all blind and didn't see the 
amazingness of lisp. Procedural languages are simply better, and I'm not 
replying to this flamewar.

Thank you:)
G.
--
http://mail.python.org/mailman/listinfo/python-list


Developing Commercial Applications in Python

2005-01-03 Thread eeykay
Hello All,
I am trying to convince my client to use Python in his new product. He
is worried about the license issues. Can somebody there to point me any
good commercial applications developed using python ?. The licence
clearly says Python can be used for commercial applications. Is there
any other implications like that of GPL to make the source open ?
Thanks for any help.
eeykay

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


Re: emulating an and operator in regular expressions

2005-01-03 Thread Craig Ringer
On Mon, 2005-01-03 at 08:52, Ross La Haye wrote:
> How can an and operator be emulated in regular expressions in Python?
> Specifically, I want to return a match on a string if and only if 2 or more
> substrings all appear in the string.  For example, for a string s = 'Jones
> John' and substrings sg0 = 'Jones' and sg1 = 'John', I want to return a
> match, but for substrings sg0 = 'Jones' and sg2 = 'Frank' I do not want to
> return a match.  Because the expression 'A and B' is logically equivalent to
> 'not (not A or not B)' I thought I could try something along those lines,
> but can't crack it.

My first thought would be to express your 'A and B' regex as:

(A.*B)|(B.*A)

with whatever padding, etc, is necessary. You can even substitute in the
sub-regex for A and B to avoid writing them out twice.

--
Craig Ringer

--
Craig Ringer

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


Re: Developing Commercial Applications in Python

2005-01-03 Thread Craig Ringer
On Mon, 2005-01-03 at 19:00, [EMAIL PROTECTED] wrote:
> Hello All,
> I am trying to convince my client to use Python in his new product. He
> is worried about the license issues. Can somebody there to point me any
> good commercial applications developed using python ?. The licence
> clearly says Python can be used for commercial applications. Is there
> any other implications like that of GPL to make the source open ?

My understanding is that you're dead safe with Python its self, as AFAIK
you can even bundle (possibly modified) the Python sourcecode into your
application. You'd simply need to keep an eye on the licenses of any
extensions you used, like ReportLab, PIL, mx, database interfaces,
twisted, etc. Many are licensed under the same license as Python or an
MIT-like license, but of course some Python extensions are not and you
would need to consider that.

--
Craig Ringer

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


Re: Python! Is! Truly! Amazing!

2005-01-03 Thread Ville Vainio
> "jfj" == jfj  <[EMAIL PROTECTED]> writes:

jfj> There were functional and non-functional programming
jfj> languages (the first being *much* simpler to
jfj> implement). There is a *reason* people chose C over
jfj> lisp. It's not that we were all blind and didn't see the
jfj> amazingness of lisp. Procedural languages are simply better,
jfj> and I'm not replying to this flamewar.

You did already ;). Lisp is not a functional programming language, if
that was the case it would be even less popular than it is now. Lisp
had it's heyday, while pure FP languages didn't even have that much.

Hey, it's 2005, I don't think we've used up our yearly Lisp flamewar
quota yet.

-- 
Ville Vainio   http://tinyurl.com/2prnb
-- 
http://mail.python.org/mailman/listinfo/python-list


Async-signal safe functions in signal handlers (unix)

2005-01-03 Thread Michael Pronath
Hi,

can I make sure that Python uses only async-signal safe glibc
functions in signal handlers?
For example, you must not call malloc or free in signal handlers, see
http://www.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_04.html#tag_02_04_03
The reason is, that if a signal is caught while your program is in the
malloc routine, and the signal handler calls malloc or free again,
then the heap will be corrupted, probably crashing your program.
Using the Python module "signal", I can define signal handlers, but I
guess that many statements like assignments to local variables will
involve calls to functions like malloc or free.
So, is there a) any mechanism inside Python that can detect if the
current code is executed in a signal handler, or b) a list of
statements that must not be used in a Python signal handler in order
to avoid glibc function calls that are not async-signal safe?

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


Re: Python! Is! Truly! Amazing!

2005-01-03 Thread Christopher Koppler
On Mon, 03 Jan 2005 13:05:48 +0200, Ville Vainio wrote:

>> "jfj" == jfj  <[EMAIL PROTECTED]> writes:
> 
> jfj> There were functional and non-functional programming
> jfj> languages (the first being *much* simpler to
> jfj> implement). There is a *reason* people chose C over
> jfj> lisp. It's not that we were all blind and didn't see the
> jfj> amazingness of lisp. Procedural languages are simply better,
> jfj> and I'm not replying to this flamewar.
> 
> You did already ;). Lisp is not a functional programming language, if
> that was the case it would be even less popular than it is now. Lisp
> had it's heyday, while pure FP languages didn't even have that much.
> 
> Hey, it's 2005, I don't think we've used up our yearly Lisp flamewar
> quota yet.

Lisp will strike back! Someday, it will be popular again! When all else is
dust, Lisp will rule the skies!

In the meantime, let's do Python.

-- 
Christopher

[EMAIL PROTECTED] # python
Python inf (day 1) 
[PyPy inf (Pythonix inf)] on pynuxinf
Type "help", "copyright", "credits" or "license" for more information.
>>> from Creation import lux
>>> lux.fiat()

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


Re: Continuations Based Web Framework - Seaside.

2005-01-03 Thread Kendall Clark
On Mon, Jan 03, 2005 at 01:46:54AM -0600, Ian Bicking wrote:
> Kendall Clark wrote:
> >Between this pressure (which isn't new, since as Steve points out, I
> >was talking about this in Python community last year, and I wasn't
> >nearly the first) and the growing popularity of Ruby on Rails, there's
> >some small hint that Ruby is gaining on Python re: non-Java web app
> >mind share. I think that's a v. important niche for Python and would
> >like to see us remain strong there (though I've not *done* much about
> >this, alas).
> 
> I think that's probably true -- at least in terms of mindshare, even 
> though that might not reflect on actual work done.  But, Rails is really 
> not a very experimental framework, and the existance of 
> continuation-based frameworks for Ruby is an aside.  If such frameworks 
> happen at all for Python, I think they will be an aside as well.

There's no sense whatever in which Rails is "experimental" -- who
suggested such a thing? No, Rails hits a sweet spot, for a class (I
suspect) of simple to mediumly-complex web app. Which is what most web
apps *are*, after all.

I don't begrudge Rails any popularity, I just want us to defend our
turf. Sometimes that means ignoring what the other guy does, but
sometimes it means aping him. I suspect in this case some aping would
be a good thing.

As for continuation-based frameworks, as you point out to Steve,
that's largely an implementation technique and similar results may be
achieved with other techniques (though I, unlike you, did *not* favor
Steve's technique, as I recall). Continuations are certainly not
experimental, nor are continuation-based modal web frameworks. The
latter are *en vogue* and being seen to be *en vogue* is often an
important technological virtue, especially for a perceived market
niche leader. 

Kendall Clark
-- 
Sometimes it's appropriate, even patriotic, to be ashamed
of your country. -- James Howard Kunstler
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Async-signal safe functions in signal handlers (unix)

2005-01-03 Thread Diez B. Roggisch
> So, is there a) any mechanism inside Python that can detect if the
> current code is executed in a signal handler, or b) a list of
> statements that must not be used in a Python signal handler in order
> to avoid glibc function calls that are not async-signal safe?

The execution of signal handlers in python is not done really asynchronous -
instead, an incoming signal is noticed and flagged to the interpreters byte
code loop - so the signal gets dealed with when the current bytecode
instruction is termintated. Read section 7.1 in the docs about the signal
module.

In other words: Don't worry, be happy.

-- 
Regards,

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


Re: cosmetic Tkinter question

2005-01-03 Thread harold fellermann
On 26.12.2004, at 16:38, Sean McIlroy wrote:
I've got a bunch of Frames, all packed into the root window with
side=TOP, and in each Frame I've got a Checkbutton packed with
side=LEFT. I expected the Checkbuttons to be flush with the left edge
of the window, but they're not, and it looks a little gross. How do I
get them to align?
if you pack the frames with option fill=X they should be well aligned --
This commands the frame to use all available space in the horizontal
direction:
your_frame.pack(side=TOP,fill=X)
your_button.pack(side=LEFT)
- harold -
--
What is mind? -- Doesn't matter.
What is matter? -- Never mind!
--
--
http://mail.python.org/mailman/listinfo/python-list


Re: Switch statement (was: Lambda going out of fashion)

2005-01-03 Thread TZOTZIOY
On Thu, 23 Dec 2004 19:57:27 GMT, rumours say that rzed
<[EMAIL PROTECTED]> might have written:

[Why did PEP 275 stall?]

>It seems to me that it was regarded as misguidod.

QOTPE +1

(PE=Python Era)

Oncoming Python book: "Hitchhiker's Guido to the Python Language"
-- 
TZOTZIOY, I speak England very best.
"Be strict when sending and tolerant when receiving." (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: UserDict deprecated

2005-01-03 Thread Steve Holden
Wolfgang wrote:
Hello,
Alex Martelli wrote:
The DictMixin class from the UserDict module is *not* deprecated -- only
the UserDict class from the same module.  (If you found info saying
otherwise pls provide a URL: the info is wrong and I'll try to get it
fixed -- thanks!).  DictMixin's purpose is exactly as you state: letting
you make a complete mapping class out of one which only supplies the
very basics, by mix-in inheritance.

If UserDict is deprecated why is it still used in the os module ?
(in python V. 2.4)
The std lib should be a good example for python coding, if something
is deprecated it should not be used in the std lib.
Some weeks ago I had ten minutes of spare time and rewrote the 'os' 
module to use dict and there was no problem with it.
But due to lack of time I was not able to run tests and submitted no 
patch. I will try this next week.

bye by Wolfgang
Good for you! When you've fixed that up, you might want to take a look 
at cgi.py, dumbdbm.py, shelve.py and weakref.py as well ;-)

regards
 Steve
--
Steve Holden   http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/
Holden Web LLC  +1 703 861 4237  +1 800 494 3119
--
http://mail.python.org/mailman/listinfo/python-list


removing comments form a file

2005-01-03 Thread Noud Aldenhoven
Hello everyone,

I was wondering how to remove comments away form a file.
So that's why I made this script.

===
#!/usr/bin/env python

import sys
import string
import time

helptext = "usage: python rmcomment [oldfile] [newfile] [comment]"

def rmcomment(oldfile, newfile, comment):
oldfile = open(oldfile, 'r')
newfile = open(newfile, 'w')
ccount = 0
lcount = 0
for line in oldfile.readlines():
splitline = string.split(line)
pstest = 0
fileline = ""
for word in splitline:
if word[:2] == comment:
pstest = -1
ccount += 1
pass
elif pstest == -1:
pass
else:
fileline += word + " "
if len(fileline) == 0:
pass
else:
newfile.write(fileline + "\n")
lcount += 1
print "Done... in %s seconds\nRemoved comment from %s lines\nWrote %
lines to %s" % (time.time()-start , ccount, lcount, newfile)
raw_input("Push the enter button to quit>")

if __name__ == "__main__":
if sys.argv[1] == "-h" or sys.argv[1] == "-help":
print helptext
else:
start = time.time()
oldfile = sys.argv[1]
newfile = sys.argv[2]
comment = sys.argv[3]
rmcomment(oldfile, newfile, comment)




This script works fine with standard text files. An example is this one:

example.txt:

Hello Fuckin' World //how are you doing today
//I think it delete this sentence and the next sentence too!

But this one not! #Even not this comment

end example.txt

If I use my script, named rmcomment.py I get this:

[EMAIL PROTECTED]:~/programmeren/python/rmcomment$ cat example.txt
Hello Fuckin' World //how are you doing today
//I think it delete this sentence and the next sentence too!

But this one not! #Even not this comment's
[EMAIL PROTECTED]:~/programmeren/python/rmcomment$ python rmcomment.py
example.txt newexample.txt //
Done... in 0.00104999542236 seconds
Removed comment from 2 lines
Wrote  2nes to 
Push the enter button to quit>
[EMAIL PROTECTED]:~/programmeren/python/rmcomment$ cat newexample.txt
Hello Fuckin' World
But this one not! #Even not this comment
[EMAIL PROTECTED]:~/programmeren/python/rmcomment$

works fine... but here's my problem. If I use rmcomment.py also the
whitelines will be removed. And I don't want that to happen. Here's another
example:

[EMAIL PROTECTED]:~/programmeren/python/rmcomment$ cat otherexample.txt
//This shows what whitelines are doing here
   left from me is a nice white line tabs
and here left are at least 3 white line tabs

//and ofcourse, comments will be deleted
[EMAIL PROTECTED]:~/programmeren/python/rmcomment$ python rmcomment.py
otherexample.txt newotherexample.txt //
Done... in 0.0011351108551 seconds
Removed comment form 2 lines
Wrote  2nes to 
Push the enter button to quit>
[EMAIL PROTECTED]:~/programmeren/python/rmcomment$ cat newotherexample.txt
left from me is a nice white line tabs
and here left are at least 3 white line tabs
[EMAIL PROTECTED]:~/programmeren/python/rmcomment$

My beautiful whitelines are gone! And I don't want that!
I've thaught how to fix this for a time, but I can't make it on my own. Too
less programming experiance, I'm afraid.
Could someone help me with this problem? Or fix the script or give a hint or
something?

Thank you at least for reading this post,

Noud Aldenhoven
The Netherlands (In de beurt bij Nijmegen, voor de nieuwschierigen)

ps. Yes, I'm a Dyslextion and can't write correct english. I'm sorry for
that.






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


Re: Advice request for project

2005-01-03 Thread Steve Holden
John French wrote:
I've been interested in Python for a while now but haven't had an 
opportunity to use / learn it.  I'm tasked now with a project at work that 
might be my first opportunity.

 I have to write a ~75 concurrent user document storage app. that allows 
users to scan documents from locally attached scanners and save to a 
database for retrieval.  I also need to be able to call MS Word with 
templates and allow the user to save the file to the database.  I think I 
understand that I can interface MS COM for these, correct?

My interest is in using FreeBSD/Postgresql/Python as a back end and a Python 
GUI app on the XP workstations.  I'm going to end up adding some 
non-database functionality to the project in the future that precludes only 
using odbc to the database.  I'll likely end up with some form of inter-user 
messaging being incorporated before it's over.  Is it better to write one 
server side socket app to handle everything or start via odbc and necessary 
server side apps later?  If anyone can tell me if this project seems 
appropriate to Python and offer suggestions as to an initial architecture, 
I'd appreciate it.  I'm quite interested in the RAD aspect of the language 
but quite lost at the moment.  (I did just sign up for the Tutor mailing 
list).

It sounds like an ideal project, and either approach would work. The 
advantage to avoiding ODBC is that you won't experience any non-local 
driver limitations which might or might not otherwise bite you in the 
ass (my PostgreSQL experience is rather limited).

Look at the Pyrex package to get you started thinking about remote 
execution and client/server communications. This lets a program on one 
machine call methods on objects on another machine.

I'm sure you'll get other suggestions as well, but that'll get you 
started thinking pythonically.

regards
 Steve
--
Steve Holden   http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/
Holden Web LLC  +1 703 861 4237  +1 800 494 3119
--
http://mail.python.org/mailman/listinfo/python-list


Re: The Industry choice

2005-01-03 Thread Peter Dembinski
Peter Hansen <[EMAIL PROTECTED]> writes:

> Roy Smith wrote:
>> "Terry Reedy" <[EMAIL PROTECTED]> wrote:
>>
>>> None has been reserved because there is no known good use for
>>> overriding it.
>> Should I infer from the above that there's a known bad use?
>
> Yes: making None equal to the integer 3.  That's one of
> six known bad uses  it's possible there are more. ;-)

Binding user variables to these names should raise exception
(eg. AreYouInsaneException or WhatAreYouDoingException) :>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Rebinding stdout (was: Re: Python! Is! Truly! Amazing!)

2005-01-03 Thread michele . simionato

Just wrote:
> In article <[EMAIL PROTECTED]>,
>  Simo Melenius <[EMAIL PROTECTED]> wrote:
>
> > I've sometimes replaced sys.stdout (and/or sys.stderr) to
> > capture/redirect debugging information in existing code that has
> > unwisely just "print"ed error and warning messages, instead of
using
> > sys.stderr or error logging modules.
> >
> > py> def with_output_to_string (func):
> > ... try:
> > ... sys.stdout = StringIO.StringIO ()
> > ... func ()
> > ... return sys.stdout.getvalue ()
> > ... finally:
> > ... sys.stdout = sys.__stdout__
>
> Aargh, I can't believe how widespread this idiom is :-(. See my other
> reply in this thread: DON'T use sys.__stdout__. Ever.
> 
> Just

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


Py2exe and extension issues

2005-01-03 Thread kdahlhaus
Is anyone aware of issues with Py2exe and extensions compiled with
cygwin/mingw for Python 2.3?   I have an extension that wraps access to
some C DLLs.  The generated executable always segfaults at startup,
although things work fine when running through the normal python
interpreter.  I had a guess that perhaps the issue stems from my
extension being compiled with cygwin and py2exe compiled with  Visual
C++?

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


Re: cosmetic Tkinter question

2005-01-03 Thread Eric Brunel
Sean McIlroy wrote:
I've got a bunch of Frames, all packed into the root window with
side=TOP, and in each Frame I've got a Checkbutton packed with
side=LEFT. I expected the Checkbuttons to be flush with the left edge
of the window, but they're not, and it looks a little gross. How do I
get them to align?
The standard behaviour for frames is to adapt to their contents, and packing 
them with side=TOP without any other option will center them in their container.

So you have a few solutions to your problem:
- use the anchor option when packing the frames; setting anchor=W should do what 
you want
- use fill=X when packing the frames, as Harold said. This expands the frame to 
the whole width of its container, so this should align the check-buttons (if it 
doesn't work, add the option expand=1 to force the frame to be wider than its 
contents)

A silly question BTW: why do you use frames? If you have only check-buttons in 
them, you do not need them:

from Tkinter import *
root = Tk()
for i in range(0, 101, 20):
  b = Checkbutton(root, text='Option %s' % i)
  b.pack(side=TOP, anchor=W)
root.mainloop()
HTH
--
- Eric Brunel  -
PragmaDev : Real Time Software Development Tools - http://www.pragmadev.com
--
http://mail.python.org/mailman/listinfo/python-list


RE: removing comments form a file

2005-01-03 Thread Batista, Facundo
Title: RE: removing comments form a file





[Noud Aldenhoven]


#- Hello everyone,
#- 
#- I was wondering how to remove comments away form a file.


I remade it:



#!/usr/bin/env python


import sys
import time


helptext = "usage: python rmcomment   "


def rmcomment(oldfilename, newfilename, comment):
    start = time.time()
    oldfile = file(oldfilename, 'r')
    newfile = file(newfilename, 'w')
    ccount = 0
    lcount = 0
    for lin in oldfile:
    pos = lin.find(comment)
    if pos != -1:
    lin = lin[:pos] + "\n"
    ccount += 1
    newfile.write(lin)
    lcount += 1
    print "Done... in %.2f seconds\nRemoved comment from %d lines\nWrote %d lines t
o %s" % (time.time()-start , ccount, lcount, newfilename)


if __name__ == "__main__":
    if sys.argv[1] == "-h" or sys.argv[1] == "-help":
    print helptext
    else:
    oldfile = sys.argv[1]
    newfile = sys.argv[2]
    comment = sys.argv[3]
    rmcomment(oldfile, newfile, comment)



Some issues:


- Used <> instead of [] in the help text, as square brackets mean optional arguments.
- Eliminated the raw_input, as in these kind of scripts the user *never* expect to have interact input.
- Used file instead of open, to don't read the whole file in memory.


But the real change is inside the for loop.


Testing it:


[EMAIL PROTECTED] ~> cat ww


Hello Fuckin' World //how are you doing today
//I think it delete this sentence and the next sentence too!


But this one not! #Even not this comment



[EMAIL PROTECTED] ~> python pru.py ww w2 //
Done... in 0.00 seconds
Removed comment from 2 lines
Wrote 7 lines to w2
[EMAIL PROTECTED] ~> cat w2


Hello Fuckin' World



But this one not! #Even not this comment



[EMAIL PROTECTED] ~>


Regards,


.    Facundo


Bitácora De Vuelo: http://www.taniquetil.com.ar/plog
PyAr - Python Argentina: http://pyar.decode.com.ar/



  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

ADVERTENCIA.


La información contenida en este mensaje y cualquier archivo anexo al mismo, son para uso exclusivo del destinatario y pueden contener información confidencial o propietaria, cuya divulgación es sancionada por la ley.

Si Ud. No es uno de los destinatarios consignados o la persona responsable de hacer llegar este mensaje a los destinatarios consignados, no está autorizado a divulgar, copiar, distribuir o retener información (o parte de ella) contenida en este mensaje. Por favor notifíquenos respondiendo al remitente, borre el mensaje original y borre las copias (impresas o grabadas en cualquier medio magnético) que pueda haber realizado del mismo.

Todas las opiniones contenidas en este mail son propias del autor del mensaje y no necesariamente coinciden con las de Telefónica Comunicaciones Personales S.A. o alguna empresa asociada.

Los mensajes electrónicos pueden ser alterados, motivo por el cual Telefónica Comunicaciones Personales S.A. no aceptará ninguna obligación cualquiera sea el resultante de este mensaje.

Muchas Gracias.



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

Re: Rebinding stdout (was: Re: Python! Is! Truly! Amazing!)

2005-01-03 Thread michele . simionato
(Not sure if my other message arrived)

I am guilty of using this idiom, too.

The standard library
http://www.python.org/dev/doc/devel/lib/module-sys.html#l2h-396

says:

"""
__stdin__
__stdout__
__stderr__
These objects contain the original values of stdin, stderr and
stdout at the start of the program. They are used during finalization,
and could be useful to restore the actual files to known working file
objects in case they have been overwritten with a broken object.
"""

Notice the "during finalization" sentence.
Maybe you should change the doc and explain what __stdout__ is intended
for?

Michele Simionato

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


Re: Lambda as declarative idiom (was RE: what is lambda used for in real code?)

2005-01-03 Thread Roman Suzi

Hi all,

BTW, Alex Martelli and me have created a PEP 312 some time ago (when the
debate of inline if was hot).

I wish lambdas will not be deprecated in Python but the key to that is
dropping the keyword (lambda). If anybody could think of a better syntax for
lambdas _with_ arguments, we could develop PEP 312 further.

I DO like the idea of support for universal declaratives in Python.  (This way
SQL, Prolog, grammar, DTD, lazy expressions, decision tables (advanced switch
statements) etc things could be added in a Pythonic way.)

We only need brief lambdas and lets (for closures), IMHO.


Sincerely yours, Roman Suzi
-- 
[EMAIL PROTECTED] =\= My AI powered by GNU/Linux RedHat 7.3
-- 
http://mail.python.org/mailman/listinfo/python-list


Tkinter zoom box

2005-01-03 Thread Philippe C. Martin
Hi,

I have the following convern: I have Tkinter applications that require a zoom 
box, and have had the following behavior without changing a line of code:

1) Mandrake 10.0/KDE 3.2/Python 2.3: no zoom box 
2) Mandrake 10.0/KDE 3.2/Python 2.4: zoom box shows
3) Mandrake 10.1/KDE 3.3/Python 2.4: no zoom box
4) Mandrake 10.1/Gnome 2.6/Python 2.4: zoom box shows

I know that sounds strange, but I am fairly certain this is what happened.

Is there a way to _force_ that zoom box ?

Regards,

Philippe




-- 
*
Philippe C. Martin
SnakeCard LLC
www.snakecard.com
*
-- 
http://mail.python.org/mailman/listinfo/python-list


Industrial organization (was: The Industry choice)

2005-01-03 Thread Cameron Laird
In article <[EMAIL PROTECTED]>,
Alex Martelli <[EMAIL PROTECTED]> wrote:
>Bulba! <[EMAIL PROTECTED]> wrote:
>
>> True. I have a bit of interest in economics, so I've seen e.g.
>> this example - why is it that foreign branches of companies
>> tend to cluster themselves in one city or country (e.g.
>
>It's not just _foreign_ companies -- regional clustering of all kinds of
>business activities is a much more widespread phenomenon.  Although I'm
>not sure he was the first to research the subject, Tjalling Koopmans, as
>part of his lifework on normative economics for which he won the Nobel
>Prize 30 years ago, published a crucial essay on the subject about 50
>years ago (sorry, can't recall the exact date!) focusing on
>_indivisibilities_, leading for example to transportation costs, and to
>increasing returns with increasing scale.  Today, Paul Krugman is
>probably the best-known name in this specific field (he's also a
>well-known popularizer and polemist, but his specifically-scientific
>work in economics has mostly remained in this field).
.
.
.
clp actually dropped related names back in April http://groups-beta.google.com/group/comp.lang.python/index/browse_frm/thread/ce749b848d1c33da/
 >,
but I think that was during one of your sabbaticals from the
group.

The work of Vernon Smith, the unconventionally conventional 
Nobel co-recipient of 2002, can be viewed as a commentary on
clustering and other non-homogeneities.  Many US readers
have encountered Jane Jacobs, who has made a career (and 
spawned a following) exploring the significance of cities as
economic clusters.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The Industry choice

2005-01-03 Thread Cameron Laird
In article <[EMAIL PROTECTED]>,
Terry Reedy <[EMAIL PROTECTED]> wrote:
>
>"Steve Holden" <[EMAIL PROTECTED]> wrote in message 
>news:[EMAIL PROTECTED]
>> Well clearly there's a spectrum. However, I have previously written that 
>> the number of open source projects that appear to get stuck somewhere 
>> between release 0.1 and release 0.9 is amazingly large, and does imply 
>> some dissipation of effort.
>
>And how do the failure and effort dissipation rates of open source code 
>compare to those of closed source code?  Of course, we have only anecdotal 
>evidence that the latter is also 'amazingly large'.  And, to be fair, the 
>latter should include the one-programmer proprietary projects that 
>correspond to the one-programmer open projects.
>
>Also, what is 'amazing' to one depends on one's expectations ;-).  It is 
>known, for instance, that some large fraction of visible retail business 
>fail within a year.  And that natural selection is based on that fact that 
.
.
.
The usual measurements and estimates are generally between 15% and
30%.  "Desirable" businesses--restaurants, for example, or computing
consultancies--are even more likely to fail.
-- 
http://mail.python.org/mailman/listinfo/python-list


Compiler benefits (was: The Industry choice)

2005-01-03 Thread Cameron Laird
In article <[EMAIL PROTECTED]>,
 <[EMAIL PROTECTED]> wrote:
>Roy Smith wrote:
>>I think you've hit the nail on the head. In awk (and perl, and most
>>shells, and IIRC, FORTRAN), using an undefined variable silently gets
>>you a default value (empty string or zero). This tends to propagate
>>errors and make them very difficult to track down.
>
>You may recall correctly, but Fortran compilers have improved. The
>following Fortran 90 program
>
>integer, parameter :: n = 1
>real :: x,y=2.0,z(n)
>print*,"dog"
>print*,x
>z(n+1) = 1.0
>print*,z
>end
>
>has 3 errors, all detected at compile time by the Lahey/Fujitsu Fortran
>95 compiler, with the proper options:
>
>2004-I: "xundef.f", line 2: 'y' is set but never used.
.
.
.
I wonder how many of Lahey/Fujitsu users ignore the 'I' diagnostics:
"It's not really an error--the program still runs."

I'm a bit grouchy today on the subject of engineering standards.

I think your point was that the checking present in modern Fortran
compilers, or PyCheckers, but absent from core Python, is a net 
benefit.  That I grant.  I'm reluctant to argue for a change in
Python.  I personally prefer to urge PyChecker on developers.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tkinter zoom box

2005-01-03 Thread Eric Brunel
Philippe C. Martin wrote:
Hi,
I have the following convern: I have Tkinter applications that require a zoom 
box, and have had the following behavior without changing a line of code:

1) Mandrake 10.0/KDE 3.2/Python 2.3: no zoom box 
2) Mandrake 10.0/KDE 3.2/Python 2.4: zoom box shows
3) Mandrake 10.1/KDE 3.3/Python 2.4: no zoom box
4) Mandrake 10.1/Gnome 2.6/Python 2.4: zoom box shows

I know that sounds strange, but I am fairly certain this is what happened.
Is there a way to _force_ that zoom box ?
What do you call a "zoom box"? There's no widget with this name in "regular" 
Tkinter widgets, so it must be built with some other one... Which one is it? A 
button, a menubutton, or what else?

If you had some (simple) code showing the problem, that would also help a lot to 
understand what's going on...
--
- Eric Brunel  -
PragmaDev : Real Time Software Development Tools - http://www.pragmadev.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: removing comments form a file

2005-01-03 Thread [EMAIL PROTECTED]
You cold do something like this:

>>> import re
>>> commentpattern = re.compile('.*(?=//)|.*(?!//)')
>>> stringwithcomment = 'Blah di blah // some comment'
>>> match = commentpattern.match(stringwithcomment)
>>> match.group()
'Blah di blah '
>>> stringwithoutcomment = 'Blah di blah'
>>> match = commentpattern.match(stringwithoutcomment)
>>> match.group()
'Blah di blah'
>>> blankline = '\n'
>>> match = commentpattern.match(blankline)
>>> match.group()
''
>>>

and put this in a loop where you iterate over your file.
Martin (The Netherlands, Amsterdam, bij Diemen)

Noud Aldenhoven wrote:
> Hello everyone,
>
> I was wondering how to remove comments away form a file.
> So that's why I made this script.
>
> ===
> #!/usr/bin/env python
>
> import sys
> import string
> import time
>
> helptext = "usage: python rmcomment [oldfile] [newfile] [comment]"
>
> def rmcomment(oldfile, newfile, comment):
> oldfile = open(oldfile, 'r')
> newfile = open(newfile, 'w')
> ccount = 0
> lcount = 0
> for line in oldfile.readlines():
> splitline = string.split(line)
> pstest = 0
> fileline = ""
> for word in splitline:
> if word[:2] == comment:
> pstest = -1
> ccount += 1
> pass
> elif pstest == -1:
> pass
> else:
> fileline += word + " "
> if len(fileline) == 0:
> pass
> else:
> newfile.write(fileline + "\n")
> lcount += 1
> print "Done... in %s seconds\nRemoved comment from %s
lines\nWrote %
> lines to %s" % (time.time()-start , ccount, lcount, newfile)
> raw_input("Push the enter button to quit>")
>
> if __name__ == "__main__":
> if sys.argv[1] == "-h" or sys.argv[1] == "-help":
> print helptext
> else:
> start = time.time()
> oldfile = sys.argv[1]
> newfile = sys.argv[2]
> comment = sys.argv[3]
> rmcomment(oldfile, newfile, comment)
>
>
> 
>
> This script works fine with standard text files. An example is this
one:
>
> example.txt:
>
> Hello Fuckin' World //how are you doing today
> //I think it delete this sentence and the next sentence too!
>
> But this one not! #Even not this comment
>
> end example.txt
>
> If I use my script, named rmcomment.py I get this:
>
> [EMAIL PROTECTED]:~/programmeren/python/rmcomment$ cat example.txt
> Hello Fuckin' World //how are you doing today
> //I think it delete this sentence and the next sentence too!
>
> But this one not! #Even not this comment's
> [EMAIL PROTECTED]:~/programmeren/python/rmcomment$ python rmcomment.py
> example.txt newexample.txt //
> Done... in 0.00104999542236 seconds
> Removed comment from 2 lines
> Wrote  2nes to 
> Push the enter button to quit>
> [EMAIL PROTECTED]:~/programmeren/python/rmcomment$ cat newexample.txt
> Hello Fuckin' World
> But this one not! #Even not this comment
> [EMAIL PROTECTED]:~/programmeren/python/rmcomment$
>
> works fine... but here's my problem. If I use rmcomment.py also the
> whitelines will be removed. And I don't want that to happen. Here's
another
> example:
>
> [EMAIL PROTECTED]:~/programmeren/python/rmcomment$ cat otherexample.txt
> //This shows what whitelines are doing here
>left from me is a nice white line tabs
> and here left are at least 3 white line tabs
>
> //and ofcourse, comments will be deleted
> [EMAIL PROTECTED]:~/programmeren/python/rmcomment$ python rmcomment.py
> otherexample.txt newotherexample.txt //
> Done... in 0.0011351108551 seconds
> Removed comment form 2 lines
> Wrote  2nes to 
> Push the enter button to quit>
> [EMAIL PROTECTED]:~/programmeren/python/rmcomment$ cat newotherexample.txt
> left from me is a nice white line tabs
> and here left are at least 3 white line tabs
> [EMAIL PROTECTED]:~/programmeren/python/rmcomment$
>
> My beautiful whitelines are gone! And I don't want that!
> I've thaught how to fix this for a time, but I can't make it on my
own. Too
> less programming experiance, I'm afraid.
> Could someone help me with this problem? Or fix the script or give a
hint or
> something?
>
> Thank you at least for reading this post,
>
> Noud Aldenhoven
> The Netherlands (In de beurt bij Nijmegen, voor de nieuwschierigen)
>
> ps. Yes, I'm a Dyslextion and can't write correct english. I'm sorry
for
> that.

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


RE: removing comments form a file

2005-01-03 Thread Craig Ringer
On Mon, 2005-01-03 at 11:46 -0300, Batista, Facundo wrote:

> - Used file instead of open, to don't read the whole file in memory.

[EMAIL PROTECTED] ~]$ python
Python 2.3.4 (#1, Oct 26 2004, 16:42:40)
.>>> file is open
True
.>>> print repr(file), repr(open)
 

I'd be interested if you could clarify what you mean there. As far as I
know, the whole file will only be read into memory if you use file.read
() or file.readlines(). If you use an iterator it does internal
readahead, but won't read the lot at once. If you use read() it reads
only what you say.

--
Craig Ringer

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


Re: Rebinding stdout (was: Re: Python! Is! Truly! Amazing!)

2005-01-03 Thread Ron Garret
In article <[EMAIL PROTECTED]>,
 Just <[EMAIL PROTECTED]> wrote:

> In article <[EMAIL PROTECTED]>,
>  Simo Melenius <[EMAIL PROTECTED]> wrote:
> 
> > I've sometimes replaced sys.stdout (and/or sys.stderr) to
> > capture/redirect debugging information in existing code that has
> > unwisely just "print"ed error and warning messages, instead of using
> > sys.stderr or error logging modules.
> > 
> > py> def with_output_to_string (func):
> > ... try:
> > ... sys.stdout = StringIO.StringIO ()
> > ... func ()
> > ... return sys.stdout.getvalue ()
> > ... finally:
> > ... sys.stdout = sys.__stdout__
> 
> Aargh, I can't believe how widespread this idiom is :-(. See my other 
> reply in this thread: DON'T use sys.__stdout__. Ever.

It's helpful to provide an explanation when saying things like this.

In this case, it's best to save the original value of sys.stdout and 
restore that, otherwise nested calls to with_output_to_string can fail, 
e.g.

def f():
  print 123

def g():
  print 456
  x = with_output_to_string(f)
  print 789

with_outupt_to_string(g)  # Will miss the 789

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


RE: Compiler benefits (was: The Industry choice)

2005-01-03 Thread Batista, Facundo
Title: RE: Compiler benefits (was: The Industry choice)





[EMAIL PROTECTED]


#- I think your point was that the checking present in modern Fortran
#- compilers, or PyCheckers, but absent from core Python, is a net 
#- benefit.  That I grant.  I'm reluctant to argue for a change in
#- Python.  I personally prefer to urge PyChecker on developers.


Cameron, I agreed 100% percent with you. But I think that PyChecker should be distributed with Python, but in an external module, as everybody has easy access to it.

This, added to an official evangelization towards it, should eliminate a big percentage of claims about not-static-Python.


.    Facundo


Bitácora De Vuelo: http://www.taniquetil.com.ar/plog
PyAr - Python Argentina: http://pyar.decode.com.ar/



  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

ADVERTENCIA.


La información contenida en este mensaje y cualquier archivo anexo al mismo, son para uso exclusivo del destinatario y pueden contener información confidencial o propietaria, cuya divulgación es sancionada por la ley.

Si Ud. No es uno de los destinatarios consignados o la persona responsable de hacer llegar este mensaje a los destinatarios consignados, no está autorizado a divulgar, copiar, distribuir o retener información (o parte de ella) contenida en este mensaje. Por favor notifíquenos respondiendo al remitente, borre el mensaje original y borre las copias (impresas o grabadas en cualquier medio magnético) que pueda haber realizado del mismo.

Todas las opiniones contenidas en este mail son propias del autor del mensaje y no necesariamente coinciden con las de Telefónica Comunicaciones Personales S.A. o alguna empresa asociada.

Los mensajes electrónicos pueden ser alterados, motivo por el cual Telefónica Comunicaciones Personales S.A. no aceptará ninguna obligación cualquiera sea el resultante de este mensaje.

Muchas Gracias.



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

Tkinter zoom box = maximize/unmaximize box/button

2005-01-03 Thread Philippe C. Martin
By zoom box I meant one of the top right button/box one uses to 
maximize/unmaximize the current window.




-- 
*
Philippe C. Martin
SnakeCard LLC
www.snakecard.com
*
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: removing comments form a file

2005-01-03 Thread Noud Aldenhoven
Ah, 

Thank you, I never thaught about the re module. Now I can do some cool stuf.

Greetings,
Noud Aldenhoven

ps. Zal ik een keer langs komen? ;-P

[EMAIL PROTECTED] wrote:

> You cold do something like this:
> 
 import re
 commentpattern = re.compile('.*(?=//)|.*(?!//)')
 stringwithcomment = 'Blah di blah // some comment'
 match = commentpattern.match(stringwithcomment)
 match.group()
> 'Blah di blah '
 stringwithoutcomment = 'Blah di blah'
 match = commentpattern.match(stringwithoutcomment)
 match.group()
> 'Blah di blah'
 blankline = '\n'
 match = commentpattern.match(blankline)
 match.group()
> ''

> 
> and put this in a loop where you iterate over your file.
> Martin (The Netherlands, Amsterdam, bij Diemen)
> 
> Noud Aldenhoven wrote:
>> Hello everyone,
>>
>> I was wondering how to remove comments away form a file.
>> So that's why I made this script.
>>
>> ===
>> #!/usr/bin/env python
>>
>> import sys
>> import string
>> import time
>>
>> helptext = "usage: python rmcomment [oldfile] [newfile] [comment]"
>>
>> def rmcomment(oldfile, newfile, comment):
>> oldfile = open(oldfile, 'r')
>> newfile = open(newfile, 'w')
>> ccount = 0
>> lcount = 0
>> for line in oldfile.readlines():
>> splitline = string.split(line)
>> pstest = 0
>> fileline = ""
>> for word in splitline:
>> if word[:2] == comment:
>> pstest = -1
>> ccount += 1
>> pass
>> elif pstest == -1:
>> pass
>> else:
>> fileline += word + " "
>> if len(fileline) == 0:
>> pass
>> else:
>> newfile.write(fileline + "\n")
>> lcount += 1
>> print "Done... in %s seconds\nRemoved comment from %s
> lines\nWrote %
>> lines to %s" % (time.time()-start , ccount, lcount, newfile)
>> raw_input("Push the enter button to quit>")
>>
>> if __name__ == "__main__":
>> if sys.argv[1] == "-h" or sys.argv[1] == "-help":
>> print helptext
>> else:
>> start = time.time()
>> oldfile = sys.argv[1]
>> newfile = sys.argv[2]
>> comment = sys.argv[3]
>> rmcomment(oldfile, newfile, comment)
>>
>>
>> 
>>
>> This script works fine with standard text files. An example is this
> one:
>>
>> example.txt:
>>
>> Hello Fuckin' World //how are you doing today
>> //I think it delete this sentence and the next sentence too!
>>
>> But this one not! #Even not this comment
>>
>> end example.txt
>>
>> If I use my script, named rmcomment.py I get this:
>>
>> [EMAIL PROTECTED]:~/programmeren/python/rmcomment$ cat example.txt
>> Hello Fuckin' World //how are you doing today
>> //I think it delete this sentence and the next sentence too!
>>
>> But this one not! #Even not this comment's
>> [EMAIL PROTECTED]:~/programmeren/python/rmcomment$ python rmcomment.py
>> example.txt newexample.txt //
>> Done... in 0.00104999542236 seconds
>> Removed comment from 2 lines
>> Wrote  2nes to 
>> Push the enter button to quit>
>> [EMAIL PROTECTED]:~/programmeren/python/rmcomment$ cat newexample.txt
>> Hello Fuckin' World
>> But this one not! #Even not this comment
>> [EMAIL PROTECTED]:~/programmeren/python/rmcomment$
>>
>> works fine... but here's my problem. If I use rmcomment.py also the
>> whitelines will be removed. And I don't want that to happen. Here's
> another
>> example:
>>
>> [EMAIL PROTECTED]:~/programmeren/python/rmcomment$ cat otherexample.txt
>> //This shows what whitelines are doing here
>>left from me is a nice white line tabs
>> and here left are at least 3 white line tabs
>>
>> //and ofcourse, comments will be deleted
>> [EMAIL PROTECTED]:~/programmeren/python/rmcomment$ python rmcomment.py
>> otherexample.txt newotherexample.txt //
>> Done... in 0.0011351108551 seconds
>> Removed comment form 2 lines
>> Wrote  2nes to  0x403e1c60>
>> Push the enter button to quit>
>> [EMAIL PROTECTED]:~/programmeren/python/rmcomment$ cat newotherexample.txt
>> left from me is a nice white line tabs
>> and here left are at least 3 white line tabs
>> [EMAIL PROTECTED]:~/programmeren/python/rmcomment$
>>
>> My beautiful whitelines are gone! And I don't want that!
>> I've thaught how to fix this for a time, but I can't make it on my
> own. Too
>> less programming experiance, I'm afraid.
>> Could someone help me with this problem? Or fix the script or give a
> hint or
>> something?
>>
>> Thank you at least for reading this post,
>>
>> Noud Aldenhoven
>> The Netherlands (In de beurt bij Nijmegen, voor de nieuwschierigen)
>>
>> ps. Yes, I'm a Dyslextion and can't write correct english. I'm sorry
> for
>> that.

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


Re: Python! Is! Truly! Amazing!

2005-01-03 Thread Ron Garret
In article <[EMAIL PROTECTED]>,
 jfj <[EMAIL PROTECTED]> wrote:

> Ron Garret wrote:
> > In article <[EMAIL PROTECTED]>,
> >  "Erik  Bethke" <[EMAIL PROTECTED]> wrote:
> > 
> > 
> >>I have NEVER experienced this kind of programming joy.
> > 
> > 
> > Just wait until you discover Lisp!
> > 
> > ;-)
> 
> 
> I've had it with all those lisp posts lately ;-)
> 
> There were functional and non-functional programming languages (the 
> first being *much* simpler to implement). There is a *reason* people 
> chose C over lisp. It's not that we were all blind and didn't see the 
> amazingness of lisp. Procedural languages are simply better, and I'm not 
> replying to this flamewar.

Then neither am I.

Yes, there's a reason people choose C over Lisp, just as there is a 
reason that people choose Windows over OS X, the Ford Taurus over the 
Lexus SC400, and Perl over Python.  But I'm pretty sure joy isn't that 
reason.  If joy is part of your quality metric for a programming 
language then Lisp is worth a look.  (And it costs a lot less than a 
Lexus.)

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


Re: Tkinter (OOP?) help

2005-01-03 Thread 3c273

"Mike Meyer" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]

> Every time you call newwindow, you rebind self.new to the window just
> created. So any close button that works will close the last window opened.
>
> You need to create a separate class for new windows, each with it's
> own self.new (or self.window) that it's self.closeme will call destroy
> on.
>
> http://mail.python.org/mailman/listinfo/python-list


How can engineers not understand source-code control? (was: The Industry choice)

2005-01-03 Thread Cameron Laird
In article <[EMAIL PROTECTED]>,
Mark Carter  <[EMAIL PROTECTED]> wrote:
.
.
.
>Don't start me! Dammit, too late ...
>
>I've noticed that they have an overwhelming obsession with GUIs, too. 
>They design wizards for everything. Damn pretty they are, too. Albeit a 
>bit flakey. They seem to conflate pretty interfaces with good interfaces 
>and good software.
>
>I used to joke that since our software wasn't particularly magical, it 
>didn't need wizards. But I think I just ended up sounding bitter.
>
>We once had a bit of software that we thought we'd like to turn into a 
>generic application. The focus on improvements was, predictably enough, 
>that we should design a GUI that could do anything a client would likely 
>to want to do. It was my opinion, though, having seen the very 
>"special-cases" nature required in the original software, that it was 
>almost impossible to predict exactly how a customer might want the 
>product tailored. I suggested that what they really needed was a library 
>(Python would have been good for this, Lisp might have been even better) 
>that could be extended as required. GUIs second, functionality first. 
>But hey, what would I know. Fortunately, the whole thing's been put on 
>the back burner.
>
>And trying to get through to them why source control makes sense, that 
>when more than one person works on a project, some form of coordination 
>is required, that copying and pasting code is evil, and that Excel 
>probably isn't the hammer for every nail.
>
>Honestly, I thought (real) engineers were supposed to be clever.

Let's provisionally assume ignorance rather than unintelligence,
if only on the grounds of parsimony.  Sympathetic colleagues are
available, by the way, at http://www.engcorp.com/acf/ >.
While the Wiki remains *very* quiet, at this point, it's still
quite young.

The subject you raise is precisely at the middle of part of my
excitement about Python's prospects.  I'll sketch the pertinent
propositions:  GUIs are the wrong model; true flexibility involves
a domain-specific, well-designed "little language".  "Scripting
languages" were originally "configuration languages"; return to
those roots is only healthy.  Scientific and engineering software
particularly has been in thrall to the GUI, and deserves rejuve-
nation with "scripting".  Key to the dynamic of dynamic languages
is that they make it cheaper to re-write than to re-use, in some
carefully limited sense.

I've seen the infatuation for Excel (and so on) for years, but
never found it at all tempting myself.  I mostly just ignore the
issue--no, actually, I guess I give them Excel, but show at the
same time that they really want the alternative views that I
also provide.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Lambda as declarative idiom (was RE: what is lambda used for in real code?)

2005-01-03 Thread Dave Benjamin
Roman Suzi wrote:
I wish lambdas will not be deprecated in Python but the key to that is
dropping the keyword (lambda). If anybody could think of a better syntax for
lambdas _with_ arguments, we could develop PEP 312 further.
Well, my vote is still with Ruby-style codeblock syntax, but as a 
compromise, what about the following:

  fun(a, b): a + b
as a replacement for:
  lambda a, b: a + b
Advantages:
  - Doesn't use the l-word
  - Uses parentheses always
  - "fun" is shorter and self-describing
  - Makes Python code more "fun" ;)
Disadvantages:
  - Requires a new keyword, breaking backward compatibility
(I'm assuming we're still talking about Py3k here)
  - (Still) doesn't interface statements with expressions
Dave
--
http://mail.python.org/mailman/listinfo/python-list


Re: Developing Commercial Applications in Python

2005-01-03 Thread It's me
Shaw-PTI (www.pti-us.com) uses Python in their software.   See:
http://www.pti-us.com/pti/news/index.cfm and search "2004 PSS/E User Group
Meeting"

<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hello All,
> I am trying to convince my client to use Python in his new product. He
> is worried about the license issues. Can somebody there to point me any
> good commercial applications developed using python ?. The licence
> clearly says Python can be used for commercial applications. Is there
> any other implications like that of GPL to make the source open ?
> Thanks for any help.
> eeykay
>


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


Re: Is it possible to open a dbf

2005-01-03 Thread Helmut Jarausch
Miklós P wrote:
Paul Rubin wrote:

John Fabiani <[EMAIL PROTECTED]> writes:
I'm wondering if there is a module available that will open a dbf

So far (more than a minute) I have discovered a reader only.  So if you
have
a URL or a search string it would be very helpful.

TIA
John

Yes, "dBase Python" yields only some code for reading dBase ... and lots of
enquires about such a thing...
I've been using
http://www.fiby.at/dbfpy/
without any problems including writing/modifying dbf files.
--
Helmut Jarausch
Lehrstuhl fuer Numerische Mathematik
RWTH - Aachen University
D 52056 Aachen, Germany
--
http://mail.python.org/mailman/listinfo/python-list


Re: Frameworks for "Non-Content Oriented Web Apps"

2005-01-03 Thread mirnazim
Well, I think a we can say that a framework for "Non Content Oriented
Web Apps" is something that can help in
(*) creating N tier data aware web applications
(*) creating data-aware controls (forms etc.).
(*) managing different data sources transparently(ZODB,
MySQL,PostGreSQL, etc).
(*) de-coupling UI, Business Logic and Data Sources from each other.
(*) provide transaction management facilities(am I asking too much).
(*) etc. etc. etc.

Please note that "DATA is not CONTENT" here.

I agree that with a little imagination, we can accomplish that in
context of the content(what most web frameworks are meant for, help in
serving dynamic content), but that requires attention to the details
not related to the problem.

Just as another attempt to clear what I mean by "Non Content Oriented
Web Apps", please consider the following example.

Suppose you are hired to build an ERP system, whose user interface will
be completely web based.

Now let me ask you a few question(humbly).

Q1) What tools would you want to use that can ease up the development
in terms productivity, timeliness, quality, etc?

Q2) Would you not like to think about the ERP system as an ERP system?

Q3) How would it be like if you have to thinking of the ERP system in
context of pages of a web site?

Q4) Will It not be the waste of time in mapping the functionality of
ERP in terms of content(and that is what we do when we develop such an
application to run on web).

Q5) Last(but not definitely the least), will it not be just ugly.

Of course, we can develop the whole ERP with plain cgi and people have
done it and succeeded to a good extent.

Moreover, I recently saw Dabo(http://www.dabodev.com/about), a
framework for developing 3 tier apps with Python and wxPython(and other
supported GUI toolkits). I have not tried it but I think something
similar, but for web-apps, is a close definition of "A Framework for
Non-Content Oriented Web Apps".

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


Re: Tkinter zoom box = maximize/unmaximize box/button

2005-01-03 Thread Eric Brunel
Philippe C. Martin wrote:
By zoom box I meant one of the top right button/box one uses to 
maximize/unmaximize the current window.
This is a known problem in tcl/tk. See http://minilien.com/?7O2BAOm9t0
There is apparently a patch available. Latest tcl/tk versions apparently include 
the correction.

HTH
--
- Eric Brunel  -
PragmaDev : Real Time Software Development Tools - http://www.pragmadev.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: Developing Commercial Applications in Python

2005-01-03 Thread Richards Noah (IFR LIT MET)
> <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > Hello All,
> > I am trying to convince my client to use Python in his new product. He
> > is worried about the license issues. Can somebody there to point me any
> > good commercial applications developed using python ?. The licence
> > clearly says Python can be used for commercial applications. Is there
> > any other implications like that of GPL to make the source open ?
> > Thanks for any help.
> > eeykay
> >
"It's me" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Shaw-PTI (www.pti-us.com) uses Python in their software.   See:
> http://www.pti-us.com/pti/news/index.cfm and search "2004 PSS/E User Group
> Meeting"
>

Begging your pardon, but a better resource would be the brochure available
(http://www.pti-us.com/PTI/company/brochures/PSSE.pdf).  It appears that the
program was probably (originally) written in C/C++ (using MFC for the GUI),
and now employs Python for adding modules and scripting support.  Very
interesting stuff :)


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


Vancouver Python/Zope/Plone Meeting Reminder

2005-01-03 Thread Paul Prescod
Tuesday January 4th is the first Tuesday of the month and the Vancouver 
Python, Zope and Plone user's group will have its monthly meeting at 
ActiveState.

The topic is "What's new in Python 2.4":
Among other things, we will discuss:
* Function/method decorators
* Generator expressions
* Built-in sets
* Unification of integers
More information is available here:
  http://www.vanpyz.org/news
Topics for the next few months have also been tentatively scheduled:
January 4, 2005
What's New in Python 2.4, Paul Prescod
February 1, 2005
Creating OS X Cocoa Applications Using XML and Python, Dethe Elza
March 1, 2005
GNU Radio and Python, Ian Caven
April 5, 2005
Large Scale Python, TBD
 Paul Prescod
--
http://mail.python.org/mailman/listinfo/python-list


Re: How can engineers not understand source-code control? (was: The Industry choice)

2005-01-03 Thread John Roth

In article <[EMAIL PROTECTED]>,
Mark Carter  <[EMAIL PROTECTED]> wrote:
.
.
.
Don't start me! Dammit, too late ...
...
Honestly, I thought (real) engineers were supposed to be clever.
You might want to read this:
http://alistair.cockburn.us/crystal/articles/teoseatsoecg/theendofsoftwareengineering.htm
His thesis is very simple: engineering took a wrong turn after
WW II, and the people who coined the term "software engineering"
didn't have a clue.
Of course, he puts it a bit more diplomatically, but he's
got the data to demonstrate that software engineering
is an oxymoron.
John Roth
--
http://mail.python.org/mailman/listinfo/python-list


Ann: CherryPy-2.0-beta released

2005-01-03 Thread remi
Hello everyone,

I am happy to announce the release of CherryPy-2.0-beta.

CherryPy-2 is a pythonic, object-oriented web development framework.

CherryPy-2 is a redesign of CherryPy-1 (the unpythonic features have
been removed): no more compilation step, pure python source code (no
more "CherryClass")

Here is a sample Hello, World in CherryPy-2:

# from cherrypy import cpg
# class HelloWorld:
# @cpg.expose
# def index(self):
# return "Hello world!"
# cpg.root = HelloWorld()
# cpg.server.start()

Main properties:
- this code starts a multi-threaded HTTP server that dispatches
requests to methods
- requests like "http://domain/dir/page?arg1=val1&arg2=val2"; are
mapped to "dir.page(arg1='val1', arg2='val2')"
- requests are mapped to an object tree that is "mounted" on cpg.root
(for instance: "cpg.root.user", "cpg.root.user.remi", ...)
- method must be explicitely exposed with a decorator "@cpg.expose"
(or "index.exposed = True" for Python-2.3)
- methods can return a generator instead of a string (useful when
generating big pages)

Here is a non-exhaustive list of CherryPy-2 features:
multi-threaded HTTP server, XML-RPC server, sessions, form handling,
authentication, unicode support, gzip-compression, virtual hosting,
WSGI adapter (experimental)

The design of CherryPy-2 allows to easily write/use pluggable "filters"
or "modules":
- filters perform operations on the request/response such as
gzip-compression or string encoding
- modules are web applications (like a blog or a web forum) than can
be easily "mounted" anywhere you want in your website

CherryPy-2 is already used in production by several sites and is
supported by an active community.


Remi.

http://www.cherrypy.org

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


RE: Developing Commercial Applications in Python

2005-01-03 Thread Sells, Fred
At Sunrise Software International, we build commercial applications for
Cabletron and the Florida DMV.  This was ~10 years ago; so no useful docs
available, but we had no problems with license.

-Original Message-
From: Richards Noah (IFR LIT MET) [mailto:[EMAIL PROTECTED]
Sent: Monday, January 03, 2005 12:20 PM
To: python-list@python.org
Subject: Re: Developing Commercial Applications in Python


> <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > Hello All,
> > I am trying to convince my client to use Python in his new product. He
> > is worried about the license issues. Can somebody there to point me any
> > good commercial applications developed using python ?. The licence
> > clearly says Python can be used for commercial applications. Is there
> > any other implications like that of GPL to make the source open ?
> > Thanks for any help.
> > eeykay
> >
"It's me" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Shaw-PTI (www.pti-us.com) uses Python in their software.   See:
> http://www.pti-us.com/pti/news/index.cfm and search "2004 PSS/E User Group
> Meeting"
>

Begging your pardon, but a better resource would be the brochure available
(http://www.pti-us.com/PTI/company/brochures/PSSE.pdf).  It appears that the
program was probably (originally) written in C/C++ (using MFC for the GUI),
and now employs Python for adding modules and scripting support.  Very
interesting stuff :)


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

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


Re: Is Python good for graphics?

2005-01-03 Thread drewp

Esmail Bonakdarian wrote:
>
> Basically, I would like to be able to create some basic animations
> where I can help visualize various sorting algorithms (for instance
>
http://ciips.ee.uwa.edu.au/~morris/Year2/PLDS210/sorting.html#insert_anim)
> or graph searches (coloring nodes as each gets visited). (Something
> like this: http://cs.smith.edu/~thiebaut/java/graph/Welcome.html)

For the sorting algorithms, at least, check out
Demo/tkinter/guido/sortvisu.py in the standard distribution.
I'd recommend Tk for all the other demos you described, too.

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


Re: Frameworks for "Non-Content Oriented Web Apps"

2005-01-03 Thread remi
Have a look a the new CherryPy (http://www.cherrypy.org).

It allows developers to build web applications in much the same way
they would build any other object-oriented Python program.
This might corespond to what you're looking for.

Remi.

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


Re: using HTTP Digest auth with arbitrary HTTP methods?

2005-01-03 Thread John J. Lee
John Reese <[EMAIL PROTECTED]> writes:

> In comp.lang.python, [I] wrote:
[...]
> I instead copied it (to urllib3.py) and made the following changes:
>   a. in AbstractDigestAuthHandler.get_authorization, call
>  req.get_method() instead of req.has_data() and 'POST' or 'GET'
>  (python has a ternary operator, who knew)

(Re ternary operator: Everybody who read this list at certain times in
the past is painfully aware of that fact, and of precisely why it's
not quite true, and of all the syntax alternatives for real ternary
conditionals that will never be part of Python ;-)


>   b. in AbstractHTTPHandler.do_open, call req.get_method instead of the 
>  hard-coded if-logic which is the same as that in req.get_method
> 
> Both of these seem like bugs in urllib2.

Yup, bugs both.


> Then I overrode urllib2.Request and made it possibly to set the method,
> and then passed an instance of my custom Request class (the one that
> shouldn't have to exist, since Request should allow method to be set
> explicitly) to OpenerDirector.open().
> 
> I'd like to see these changes make it into the standard library -- after
> being vetted by whoever's in charge of urllib2.  Anybody know who I
> should talk to?

Nobody is really in charge: just go ahead and submit a patch.  Drop me
an email when you do, and I'll try to review it.  The only reason
urllib2 doesn't already do arbitrary HTTP methods is that nobody has
spent the time to think carefully if a .set_method() really is the
right way to do it, then followed through with the work needed to get
a patch applied.

As always, a precondition for change is that somebody thinks something
through carefully, writes tests, documentation, patch and submits all
three to the SF patch tracker with a brief explanation like the one
you give above.

BTW, Greg Stein started work on adding the stuff you need at the
httplib level (as module httpx).  He seems too busy to finish it, but
see modules httpx and davlib (one or both are in the Python CVS
sandbox).  He thinks httplib is a better place for DAV than urllib2,
and he should know.  But go ahead and fix urllib2 anyway... :-)


John

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


Re: HTTP GET request with basic authorization?

2005-01-03 Thread John J. Lee
Jonas Galvez <[EMAIL PROTECTED]> writes:

> Christopher J.  wrote:
> > I tried this, but it didn't work:
> > conn.request("GET", "/somepage.html", None,
> > {"AUTHORIZATION": "Basic username:password"})
[...]
> import re, base64, urllib2
>  
> userpass = ('user', 'pass')
> url = 'http://somewhere'
> 
> request = urllib2.Request(url)
> authstring = base64.encodestring('%s:%s' % userpass)
> authstring = authstring.replace('\n', '')
> request.add_header("Authorization", "Basic %s" % authstring)
>  
> content = urllib2.urlopen(request).read()

There are handlers in urllib2 to do this for you, you shouldn't need
to do it by hand.  I rarely do, so I won't risk an example...


John

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


Re: What can I do with Python ??

2005-01-03 Thread John J. Lee
Lee Harr <[EMAIL PROTECTED]> writes:
[...]
> I think it looks pretty good. The only problem I see is section 5
> where it says:
> 
> 5. Did we miss your concern?
> 
>  Please add a comment to this page.
> 
> 
> but the page is immutable.


Hopefully one of the site maintainers will read this and demonstrate
that it's actually readonly rather than immutable, then make it
appendable ;-)



John

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


Re: Rebinding stdout (was: Re: Python! Is! Truly! Amazing!)

2005-01-03 Thread JanC
Just schreef:

> You should always save stdout instead of using __stdout__. It may not be 
> the same!

You're right, especially when this code would execute in an (at 
programming time) unknown context.


-- 
JanC

"Be strict when sending and tolerant when receiving."
RFC 1958 - Architectural Principles of the Internet - section 3.9
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Lambda as declarative idiom (was RE: what is lambda used for in real code?)

2005-01-03 Thread Steven Bethard
Roman Suzi wrote:
I wish lambdas will not be deprecated in Python but the key to that is
dropping the keyword (lambda). If anybody could think of a better syntax for
lambdas _with_ arguments, we could develop PEP 312 further.
Some suggestions from recent lambda threads (I only considered the ones 
that keep lambda as an expression):

* Args Before Expression *
Nick Coghlan: def-to syntax [1]
(def (a, b, c) to f(a) + o(b) - o(c))
(def (x) to x * x)
(def () to x)
(def (*a, **k) to x.bar(*a, **k))
((def () to x(*a, **k)) for x, a, k in funcs_and_args_list)
Nick Coghlan: def-arrow syntax [1]
(def (a, b, c) -> f(a) + o(b) - o(c))
(def (x) -> x * x)
(def () -> x)
(def (*a, **k) -> x.bar(*a, **k))
((def () -> x(*a, **k)) for x, a, k in funcs_and_args_list)
Alex Martelli: def-as syntax [2]
(def (a, b, c) as f(a) + o(b) - o(c))
(def (x) as x * x)
(def () as x)
(def (*a, **k) as x.bar(*a, **k))
((def () as x(*a, **k)) for x, a, k in funcs_and_args_list)
Dave Benjamin: fun syntax [7]
(fun(a, b, c): f(a) + o(b) - o(c))
(fun(x): x * x)
(fun(): x)
(fun(*a, **k): x.bar(*a, **k))
((fun(): x(*a, **k)) for x, a, k in funcs_and_args_list)
* Expression Before Args *
Robert Brewer: for (no-parens) syntax [3]
(f(a) + o(b) - o(c) for a, b, c)
(x * x for x)
(x for ())
(x.bar(*a, **k) for *a, **k)
((x(*a, **k) for ()) for x, a, k in funcs_and_args_list)
Nick Coghlan: for syntax [6]
(f(a) + o(b) - o(c) for (a, b, c))
(x * x for (x))
(x for ())
(x.bar(*a, **k) for (*a, **k))
((x(*a, **k) for ()) for x, a, k in funcs_and_args_list)
Nick Coghlan: def-from syntax [4]
(def f(a) + o(b) - o(c) from (a, b, c))
(def x * x from (x))
(def x from ())
(def x.bar(*a, **k) from (*a, **k))
((def x(*a, **k) from ()) for x, a, k in funcs_and_args_list)
Michael Spencer: from-args syntax [5]
(f(a) + o(b) - o(c) from args(a, b, c))
(x * x from args(x))
(x from args())
(x.bar(*a, **k) from args(*a, **k))
((x(*a, **k) from args()) for x, a, k in funcs_and_args_list)
Michael Spencer: for-args syntax [5]
(f(a) + o(b) - o(c) for args(a, b, c))
(x * x for args(x))
(x for args())
(x.bar(*a, **k) for args(*a, **k))
((x(*a, **k) for args()) for x, a, k in funcs_and_args_list)
So there's a bunch of ideas out there.  I don't know if any of them 
could be overwhelmingly preferred over lambda.

Personally, I lean slightly towards the def-from syntax because it uses 
the 'def' keyword to bring your attention to the fact that a function is 
being defined, and it gives the expression precedence over the arglist, 
which makes sense to me for an anonymous function, where (IMHO) the 
expression is really the most important part of the declaration.

OTOH, I think Michael Spencer's args() function, if implementable, could 
have a lot of cool uses, like getting the arguments passed to next 
within a generator.  (See the thread about that[8].)

Steve
[1]http://mail.python.org/pipermail/python-list/2004-December/256859.html
[2]http://mail.python.org/pipermail/python-list/2004-December/256881.html
[3]http://mail.python.org/pipermail/python-list/2004-December/257023.html
[4]http://boredomandlaziness.skystorm.net/2004/12/anonymous-functions-in-python.html
[5]http://mail.python.org/pipermail/python-list/2004-December/257893.html
[6]http://mail.python.org/pipermail/python-list/2004-December/257977.html
[7]http://mail.python.org/pipermail/python-list/2005-January/258441.html
[8]http://mail.python.org/pipermail/python-list/2005-January/258238.html
--
http://mail.python.org/mailman/listinfo/python-list


Re: Developing Commercial Applications in Python

2005-01-03 Thread It's me

"Richards Noah (IFR LIT MET)" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
> Begging your pardon, but a better resource would be the brochure available
> (http://www.pti-us.com/PTI/company/brochures/PSSE.pdf).  It appears that
the
> program was probably (originally) written in C/C++ (using MFC for the
GUI),
> and now employs Python for adding modules and scripting support.  Very
> interesting stuff :)
>
>

It was actually developed in Fortran some 35 years ago.   Then migrated to
F77.   Then added a C/C++ layer to sit ontop.   Then converted to API based.
Then added a Python layer on top.

The only thing unfortunate is that they went with MFC on the newest version.
Yuck!


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


website hosting

2005-01-03 Thread [EMAIL PROTECTED]
here is the place that I host my websites with . 
If your still looking for a good host check out 
http://frontpage-web-hosting.org
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Developing Commercial Applications in Python

2005-01-03 Thread Aahz
In article <[EMAIL PROTECTED]>,
 <[EMAIL PROTECTED]> wrote:
>
>I am trying to convince my client to use Python in his new product. He
>is worried about the license issues. Can somebody there to point me any
>good commercial applications developed using python ?. The licence
>clearly says Python can be used for commercial applications. Is there
>any other implications like that of GPL to make the source open ?

Are you looking to embed Python as a scripting language or to write the
software in Python?
-- 
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: BASIC vs Python

2005-01-03 Thread TZOTZIOY
On 17 Dec 2004 15:53:51 -0800, rumours say that "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> might have written:

>> The BASICs of my youth also supported graphics and sounds.
>>
>>   PLAY "CGFED>CC
>Now wait a minute, shouldn't that be...
>
>PLAY "CGFED>CC': 2.0} # octave modifier

def play(sequence):
"""Play a sequence of notes."""
octave=1.0
for note in sequence:
try: # to play a note
winsound.Beep(int(round(notes[note]*octave)), 200)
except KeyError: # well, it wasn't
octave *= modifiers[note]

if __name__ == "__main__":
play("CGFED>CC" and "<" for example if I got them correctly).


[1] and then I "inherited" a Stride with an 68010 from a student friend
who finished studies and got drafted, who himself had it borrowed from
the company of a friend of his so that he would develop code that could
be used by the company, and in general all my troubles seem to come from
exposure to Unix in my puberty, but that's another story :)
-- 
TZOTZIOY, I speak England very best.
"Be strict when sending and tolerant when receiving." (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


ODBC Connection on Windows XP

2005-01-03 Thread Greg Lindstrom
I am running Python 2.3 on Windows XP and am trying to connect to an 
ODBC datasource.  I have done this many times on this same box but this 
time I get an error message saying

dbi.operation-error: [WSOCK32.DLL]Connection refused, is the host 
listener running? (#10061) in LOGIN

Not having seen this before, and having used the odbc module for about a 
year now, I'm at a quandary; what does this mean and what do I do to fix it?

Thanks!
--greg
--
Greg Lindstrom   501 975.4859
Computer Programmer  [EMAIL PROTECTED]
NovaSys Health
Little Rock, Arkansas
"We are the music makers, and we are the dreamers of dreams."  W.W.

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


Re: Py2exe and extension issues

2005-01-03 Thread John Machin

[EMAIL PROTECTED] wrote:
> Is anyone aware of issues with Py2exe and extensions compiled with
> cygwin/mingw for Python 2.3?   I have an extension that wraps access
to
> some C DLLs.  The generated executable always segfaults at startup,
> although things work fine when running through the normal python
> interpreter.  I had a guess that perhaps the issue stems from my
> extension being compiled with cygwin and py2exe compiled with  Visual
> C++?

Some questions:
1. Did it work before (e.g. with Python 2.2, or an earlier version of
py2exe), or has it never worked?
2. Where at start-up does it "segfault"? Doesn't the "Dr Watson" log
file tell you anything? You may need to sprinkle prints and printfs
around your code.
3. Those C DLLs: supplied by whom -- you or an nth party? compiled with
which compiler?
4. Which version(s) of which Windows are you using?

Some hints:
1. Ask on the py2exe mailing list.
2. Your guess may be correct. The usual cause of such a problem is
getting a run-time-library resource on one side of the chasm and trying
to use it on the other side. When the resource is a pointer to a data
structure whose contents are not defined by some standard, anything can
go wrong, and usually does. Examples: (a) malloc() on one side and
free() on the other (b) fopen() on one side and fanything() on the
other. However I would expect these problems to show up under normal
interpreter use.
3. Using py2exe instead of python may merely be exposing a bug in your
code caused by e.g. an uninitialised variable. (-: When you say "things
work fine" in normal interpreter mode, where does this lie in the
continuum between "it ran regression tests and volume tests happily all
night" and "I fired it up and it didn't fall over"? :-)

HTH,
John

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


Re: Speed ain't bad

2005-01-03 Thread Jeff Shannon
Anders J. Munch wrote:
Another way is the strategy of "it's easier to ask forgiveness than to
ask permission".
If you replace:
if(not os.path.isdir(zfdir)):
os.makedirs(zfdir)
with:
try:
os.makedirs(zfdir)
except EnvironmentError:
pass
then not only will your script become a micron more robust, but
assuming zfdir typically does not exist, you will have saved the call
to os.path.isdir.
... at the cost of an exception frame setup and an incomplete call to 
os.makedirs().  It's an open question whether the exception setup and 
recovery take less time than the call to isdir(), though I'd expect 
probably not.  The exception route definitely makes more sense if the 
makedirs() call is likely to succeed; if it's likely to fail, then 
things are murkier.

Since isdir() *is* a disk i/o operation, then in this case the 
exception route is probably preferable anyhow.  In either case, one 
must touch the disk; in the exception case, there will only ever be 
one disk access (which either succeeds or fails), while in the other 
case, there may be two disk accesses.  However, if it wasn't for the 
extra disk i/o operation, then the 'if ...' might be slightly faster, 
even though the exception-based route is more Pythonic.

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


Re: Developing Commercial Applications in Python

2005-01-03 Thread Richards Noah (IFR LIT MET)

"It's me" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
> "Richards Noah (IFR LIT MET)" <[EMAIL PROTECTED]> wrote in
message
> news:[EMAIL PROTECTED]
> >
> > Begging your pardon, but a better resource would be the brochure
available
> > (http://www.pti-us.com/PTI/company/brochures/PSSE.pdf).  It appears that
> the
> > program was probably (originally) written in C/C++ (using MFC for the
> GUI),
> > and now employs Python for adding modules and scripting support.  Very
> > interesting stuff :)
> >
> >
>
> It was actually developed in Fortran some 35 years ago.   Then migrated to
> F77.   Then added a C/C++ layer to sit ontop.   Then converted to API
based.
> Then added a Python layer on top.
>
> The only thing unfortunate is that they went with MFC on the newest
version.
> Yuck!
>

Hahaha, sounds like a party to me.  And they didn't even throw in a layer of
Lisp for good effort?  Too bad, if you ask me :)


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


Re: Continuations Based Web Framework - Seaside.

2005-01-03 Thread Steve Holden
Ian Bicking wrote:
Steve Holden wrote:
I did actually do some sort-of-related work in this area, which I 
presented at PyCon DC 2004 - you can access the paper at

   http://www.python.org/pycon/dc2004/papers/18/Setting_A_Context.pdf
An audience member mentioned the Smalltalk and Scheme-based work on 
web continuation frameworks, and I was sorry my answer at the time 
seemed unduly dismissive. There are some interesting similarities, and 
though my own implementation is decidedly clunky I like to think the 
paper explains some of the advantages of maintaining state and why the 
"back" button is an obnoxious anachronism :-)

I think the technique you talked about is an easier way to achieve a 
similar goal as the continuation-based frameworks.  While using 
continuations for web applications is an interesting idea, I don't think 
it's been shown to be successful.  It's certainly not something I'd want 
to implement on Python (even given the actual features to make it 
possible), and from what I've read of the Ruby projects that use it 
(Borges and Wee?), they aren't ready to implement production 
applications either.  The technique you present could be implemented on 
any framework, right now, with the expectation that it would work in a 
production situation.

That's true, but there's no denying it's clunky, and there are a few 
problems with it. Despite that, I am still persisting with developemnt, 
albeit slowly due to lack of time, and hope to have something further to 
report.

It's the *ideas* that are important, though, rather than the 
implementation, and my initial hope was to publicise the weakness of 
statelessness on the web as applications become more complex.

regards
 Steve
--
Steve Holden   http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/
Holden Web LLC  +1 703 861 4237  +1 800 494 3119
--
http://mail.python.org/mailman/listinfo/python-list


Re: Developing Commercial Applications in Python

2005-01-03 Thread Terry Reedy

<[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> I am trying to convince my client to use Python in his new product. He
> is worried about the license issues. Can somebody there to point me any
> good commercial applications developed using python ?. The licence
> clearly says Python can be used for commercial applications.

We are in a weird catch-22 type situation here.  Because the license is so 
open, companies that use Python just use it.  No payment, no curtesy 
registration, no verifiable trace unless they care to disclose (and most 
don't).

The license could be paraphrased as "Don't sue us or do anything that would 
cause anyone else to sue us and we won't sue you."  There is a posted 
request for thank you donations but not enough commercial users do so to 
even hire one full time programmer, let alone a lawyer (above the bare 
minimum required for PSF to legally function).  The PSF is about as far 
from the RIAA and MPAA as possible.

There are Python Success Stories at the Python site and elsewhere (try 
Google on the newsgroup.  You could also agree to be responsible for any 
legal action initiated by the PSF not due to obvious malfeance, like trying 
to register a copyright on the Python source.  Or you could suggest that 
they purchase a license with a donation to the PSF.

Terry J. Reedy



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


Re: HELP: Tkinter idiom needed: SOLUTION

2005-01-03 Thread Pekka Niiranen
Hi there,
got it. Note the root.distroy()-command.
-pekka-
- CODE STARTS 
from Tkinter import *
from ScrolledText import ScrolledText
import tkFont
class Message_box:
# Graphical message box for printing unicode texts
def __init__(self, myParent):
self.myContainer1 = Frame(myParent)
self.myContainer1.pack(side=TOP, expand=1, fill=BOTH)
self.button1 = Button(self.myContainer1)
self.button1["text"]= "Close"
self.button1.pack(side=BOTTOM)
self.button1.bind("", self.button1Click)
self.font = tkFont.Font(family="Arial Unicode MS", size=8)
self.text = ScrolledText(self.myContainer1, font=self.font,\
 state=NORMAL, height=40, width=120, wrap=NONE)
self.text.pack(side=TOP, expand=1, fill=BOTH)
def button1Click(self, event):
self.myContainer1.quit()
def write(self,s):
self.text.insert(END, s)
def enable_write(self):
self.text.config(state=NORMAL)
def disable_write(self):
self.text.config(state=DISABLED)
if __name__ == '__main__':
# first window
root = Tk()
print "blah1"
root.title(' Message window')
root.protocol("WM_DELETE_WINDOW", NONE)
widget = Message_box(root)
m = "blah2"
widget.write("%s\n" % m)
widget.disable_write()  
root.mainloop()
root.destroy()
print "blah3"
# second window
root = Tk()
root.title(' Message window')
root.protocol("WM_DELETE_WINDOW", NONE)
widget = Message_box(root)
m = "blah4"
widget.write("%s\n" % m)
widget.disable_write()  
root.mainloop()
root.destroy()
print "blah5"
- CODE ENDS 
Pekka Niiranen wrote:
Hi there,
after reading TkInter/thread -recipe:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/82965
I wondered if it was possible to avoid using threads
for the following problem:
I have script started from W2K console that normally
prints ascii messages to the screen. However, I have
command line "debug" -flag that might cause printing
of UTF-8 data to the screen. This fails occassionally
due to Console encoding, of course.
What I need is Tkinter window where some printouts
are directed when script is run in Debug -mode
(Redirection of stdout is out of question).
While testing, I have got this far already:
---script starts
from Tkinter import *
from ScrolledText import ScrolledText
import os, sys, tkFont, codecs
class Pyg_message_box:
  def __init__(self, parent):
self.myParent = parent
self.myContainer1 = Frame(parent)
self.myContainer1.option_add("*font",\
tkFont.Font(family="Arial Unicode MS", size=8))
self.myContainer1.pack()
self.text = ScrolledText()
self.text.pack()
self.button1 = Button(self.myContainer1, text="Quit",\
 command=self.button1Click)
self.button1.pack(side=LEFT)
self.button1.bind("", self.button1Click)
  def button1Click(self, event):
 self.myContainer1.quit()
  def write(self, s):
self.text.insert(END, s)
root = Tk()
widget = Pyg_message_box(root)
sys.stdout = widget
a = codecs.open("d:\\test.txt", "r", "utf_16").readlines()
for x in a:
  print x
root.mainloop()
---script ends
My questions are:
- Can I open Tk -window without enclosing the whole script
  between "root=Tk()" and "root.mainloop()"?
- What is the idiom of opening Tk -window only when Debug -flag
  is encountered (the script stops running until window is closed)?
Something like:
if not my_debug == "ON":
print "message" # prints to console
else:
# 1) open temporary ScrolledText() Tk -window
# 2) Print stuff to window
# 3) Ask user to close window
I would no like to always open Tkwindows just in case user runs script
with debug -flag on.
-pekka-
--
http://mail.python.org/mailman/listinfo/python-list


Re: Continuations Based Web Framework - Seaside.

2005-01-03 Thread Steve Holden
Kendall Clark wrote:
On Sun, Jan 02, 2005 at 10:03:10AM -0500, Steve Holden wrote:

I did actually do some sort-of-related work in this area, which I 
presented at PyCon DC 2004 - you can access the paper at

  http://www.python.org/pycon/dc2004/papers/18/Setting_A_Context.pdf
An audience member mentioned the Smalltalk and Scheme-based work on web 
continuation frameworks, and I was sorry my answer at the time seemed 
unduly dismissive. 

That was me, actually. I remain surprised that there isn't a move
afoot either to implement something like Seaside or Borges in Python
or to adapt one of the existing web frameworks to be
modal/continuation style.
Ah, glad to make your acquaintance again - I lost your email address in 
a disk crash shortly after PyCon DC 2004.

[...]
There are some interesting similarities, and though 
my own implementation is decidedly clunky I like to think the paper 
explains some of the advantages of maintaining state and why the "back" 
button is an obnoxious anachronism :-)

I'd still like to publish a piece on XML.com about modal web app
style, preferably with a Python example, though Borges would be fine.
Would an adaptation of the PyCon paper be any use in this context?
regards
 Steve
--
Steve Holden   http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/
Holden Web LLC  +1 703 861 4237  +1 800 494 3119
--
http://mail.python.org/mailman/listinfo/python-list


Re: The Industry choice

2005-01-03 Thread Steve Holden
Terry Reedy wrote:
"Steve Holden" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]

Well clearly there's a spectrum. However, I have previously written that 
the number of open source projects that appear to get stuck somewhere 
between release 0.1 and release 0.9 is amazingly large, and does imply 
some dissipation of effort.

And how do the failure and effort dissipation rates of open source code 
compare to those of closed source code?  Of course, we have only anecdotal 
evidence that the latter is also 'amazingly large'.  And, to be fair, the 
latter should include the one-programmer proprietary projects that 
correspond to the one-programmer open projects.

Also, what is 'amazing' to one depends on one's expectations ;-).  It is 
known, for instance, that some large fraction of visible retail business 
fail within a year.  And that natural selection is based on that fact that 
failure is normal.

Well, since everything you say is true, I suppose there's not much 
wriggle room for me.

But when a shop goes belly up, it's most often replaced by another 
business in fairy short order, and proprietary project failures are 
usually hushed up by firing the programmers and promoting the managers.

Whereas the bleached bones of the failed open source projects are 
visible for all to see on the SourceForge beach.

regards
 Steve
--
Steve Holden   http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/
Holden Web LLC  +1 703 861 4237  +1 800 494 3119
--
http://mail.python.org/mailman/listinfo/python-list


Re: website hosting

2005-01-03 Thread Irmen de Jong
[EMAIL PROTECTED] wrote:
[some spam]
Those people don't even provide python hosting, how lame.
(Yes, I know, I shouldn't have clicked the link).
--
http://mail.python.org/mailman/listinfo/python-list


Re: The Industry choice

2005-01-03 Thread Steve Holden
Aahz wrote:
In article <[EMAIL PROTECTED]>,
Steve Holden  <[EMAIL PROTECTED]> wrote:
Aahz wrote:
In article <[EMAIL PROTECTED]>,
Paul Rubin   wrote:
I was pretty skeptical of Java's checked exceptions when I first used
them but have been coming around about them.  There's just been too
many times when I wrote something in Python that crashed because some
lower-level function raised an exception that the upper level hadn't
been expecting, after the program had been in use for a while.  I'd
sure rather find out about that at compile time.
That's funny -- Bruce Eckel talks about how he used to love checked
exceptions but has come to regard them as the horror that they are.
I've learned to just write "throws Exception" at the declaration of
every method.
Pretty sloppy, though, no? And surely the important thing is to have a 
broad handler, not a broad specification of raisable exceptions?

Yes, it's sloppy, but I Don't Care.  I'm trying to write usable code
while learning a damnably under-documented Java library -- and I'm *not*
a Java programmer in the first place, so I'm also fighting with the Java
environment.  Eventually I'll add in some better code.
The road to hell is paved with good intentions.
regards
 Steve
--
Steve Holden   http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/
Holden Web LLC  +1 703 861 4237  +1 800 494 3119
--
http://mail.python.org/mailman/listinfo/python-list


Re: emulating an and operator in regular expressions

2005-01-03 Thread Terry Reedy

"Craig Ringer" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> On Mon, 2005-01-03 at 08:52, Ross La Haye wrote:
>> How can an and operator be emulated in regular expressions in Python?

Regular expressions are designed to define and detect repetition and 
alternatives.  These are easily implemented with finite state machines. 
REs not meant for conjunction.  'And' can be done but, as I remember, only 
messily and slowly.  The demonstration I once read was definitely 
theoretical, not practical.

Python was designed for and logic (among everything else).  If you want 
practical code, use it.

if match1 and match2: do whatever.

Terry J. Reedy



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


Re: Developing Commercial Applications in Python

2005-01-03 Thread It's me
Well, now that they are API based, they can easily add any script language
they so wish through SWIG (www.swig.org).

Maybe not LISP.   SNOBOL would be the right thing to do.  (*NOT*)


"Richards Noah (IFR LIT MET)" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
>
> > It was actually developed in Fortran some 35 years ago.   Then migrated
to
> > F77.   Then added a C/C++ layer to sit ontop.   Then converted to API
> based.
> > Then added a Python layer on top.
> >
> > The only thing unfortunate is that they went with MFC on the newest
> version.
> > Yuck!
> >
>
> Hahaha, sounds like a party to me.  And they didn't even throw in a layer
of
> Lisp for good effort?  Too bad, if you ask me :)
>
>


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


Re: what is lambda used for in real code?

2005-01-03 Thread Jeff Shannon
Steven Bethard wrote:
The only ones that make me a little nervous are examples like:
inspect.py: def formatargspec(args, varargs=None, varkw=None,
  ...
  formatvarargs=lambda name: '*' + name,
  formatvarkw=lambda name: '**' + name,
  formatvalue=lambda value: '=' + repr(value),
where the lambdas are declaring functions as keyword arguments in a def. 
At least in this case, a number of these can be handled with curry / 
partial(), I think --

...
formatvarargs = partial(operator.add, '*'),
formatvarkw = partial(operator.add, '**'),
...
The last is a bit more complicated, since it's got an extra (deferred) 
function call, so I'm not sure exactly how to deal with that cleanly.

Actually, in this specific case, since these are all creating strings, 
it'd be pretty trivial to simply do this manipulation inside of the 
function body rather than inside of the arglist:

def formatargspec(..., formatvarargs,
   formatkwargs,
   formatvalue, ...):
formatvarargs = '*' + formatvarargs
formatvarkw = '**' + formatvarkw
formatvalue = '=' + repr(value)
This has the disadvantage of having names typed multiple times, which 
is definitely a minus, but it's arguably a bit more clear to 
explicitly manipulate the strings within the function body rather than 
burying that manipulation somewhere in the argument list.  Personally 
I'd call this a wash, though I expect that others will disagree with 
me. ;)  And whatever the merits of this particular case, similar cases 
may not be so easy to avoid in this fashion...

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


Re: Developing Commercial Applications in Python

2005-01-03 Thread vincent wehren
[EMAIL PROTECTED] wrote:
Hello All,
I am trying to convince my client to use Python in his new product. He
is worried about the license issues. Can somebody there to point me any
good commercial applications developed using python ?. The licence
clearly says Python can be used for commercial applications. Is there
any other implications like that of GPL to make the source open ?
Thanks for any help.
eeykay
At CSB-System AG, we use Python extensively as embedded scripting 
language throughout the ERP system we develop (fields of application: 
system automation, GUI scripting, programmable user exits, reporting, 
data access/replication, autotests, and apart from that, everywhere we 
need something done fast ;-).

I'm sure that its liberal license was among the main drivers to use it 
in the first place!

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


Re: Developing Commercial Applications in Python

2005-01-03 Thread Stephen Waterbury
It's me wrote:
Shaw-PTI (www.pti-us.com) uses Python in their software.
... but the "Python Powered" logo is conspicuous by its
absence from their site.  Too bad that some commercial
exploiters of Python don't advertise that fact more often.
Every little bit helps!
Steve
--
http://mail.python.org/mailman/listinfo/python-list


Bad Interpreter

2005-01-03 Thread RajaSrinivasan
I have seen some previous messages about such a problem. I have this
problem but it is not clear what the solution really was.

I am running FC2, python 2.3.3

the script i have sock.py runs if i say something like :

python sock.py

but ./sock.py results in a :bad interpreter error
how do i troubleshoot something like this?

regards

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


Re: Ann: CherryPy-2.0-beta released

2005-01-03 Thread andybak
I'm a great believer that avoiding query strings in URL's is good
practise ( http://www.holloway.co.nz/book/9 for good arguments why).

How tricky is it to remap URL's to query strings in cherryPy? Also how
much does it complicate matters to run cherryPy under an existing
webserver? Is any functionality lost?

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


Re: The Industry choice

2005-01-03 Thread Stephen Waterbury
Steve Holden wrote:
Aahz wrote:
In article <[EMAIL PROTECTED]>,
Steve Holden  <[EMAIL PROTECTED]> wrote:
Aahz wrote:
In article <[EMAIL PROTECTED]>,
Paul Rubin   wrote:
I was pretty skeptical of Java's checked exceptions when I first used
them but have been coming around about them.  [...]
That's funny -- Bruce Eckel talks about how he used to love checked
exceptions but has come to regard them as the horror that they are.
I've learned to just write "throws Exception" at the declaration of
every method.
Pretty sloppy, though, no? And surely the important thing is to have 
a broad handler, not a broad specification of raisable exceptions?
Yes, it's sloppy, but I Don't Care.  I'm trying to write usable code
while learning a damnably under-documented Java library -- and I'm *not*
a Java programmer in the first place, so I'm also fighting with the Java
environment.  Eventually I'll add in some better code.
The road to hell is paved with good intentions.
Hmm ... those must be what my bucket keeps bumping over!  :)
Steve W.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Speed ain't bad

2005-01-03 Thread John Machin
Anders J. Munch wrote:
> Another way is the strategy of "it's easier to ask forgiveness than
to
> ask permission".
> If you replace:
> if(not os.path.isdir(zfdir)):
> os.makedirs(zfdir)
> with:
> try:
> os.makedirs(zfdir)
> except EnvironmentError:
> pass
>
> then not only will your script become a micron more robust, but
> assuming zfdir typically does not exist, you will have saved the call
> to os.path.isdir.

1. Robustness: Both versions will "crash" (in the sense of an unhandled
exception) in the situation where zfdir exists but is not a directory.
The revised version just crashes later than the OP's version :-(
Trapping EnvironmentError seems not very useful -- the result will not
distinguish (on Windows 2000 at least) between the 'existing dir' and
'existing non-directory' cases.


Python 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit (Intel)] on
win32
>>> import os, os.path
>>> os.path.exists('fubar_not_dir')
True
>>> os.path.isdir('fubar_not_dir')
False
>>> os.makedirs('fubar_not_dir')
Traceback (most recent call last):
File "", line 1, in ?
File "c:\Python24\lib\os.py", line 159, in makedirs
mkdir(name, mode)
OSError: [Errno 17] File exists: 'fubar_not_dir'
>>> try:
...os.mkdir('fubar_not_dir')
... except EnvironmentError:
...print 'trapped env err'
...
trapped env err
>>> os.mkdir('fubar_is_dir')
>>> os.mkdir('fubar_is_dir')
Traceback (most recent call last):
File "", line 1, in ?
OSError: [Errno 17] File exists: 'fubar_is_dir'
>>>

2. Efficiency: I don't see the disk I/O inefficiency in calling
os.path.isdir() before os.makedirs() -- if the relevant part of the
filesystem wasn't already in memory, the isdir() call would make it so,
and makedirs() would get a free ride, yes/no?

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


Re: Developing Commercial Applications in Python

2005-01-03 Thread Roy Smith
Stephen Waterbury  <[EMAIL PROTECTED]> wrote:
>> Shaw-PTI (www.pti-us.com) uses Python in their software.
>
>... but the "Python Powered" logo is conspicuous by its
>absence from their site.  Too bad that some commercial
>exploiters of Python don't advertise that fact more often.

Companies use all sorts of technologies to produce their products.  I
have no idea who Shaw-PTI is or what they do, but I'm sure they also
use other languages, and web servers, and operating systems, and
telephones and office furniture and pencil sharpeners.  They're all
just tools.  You don't expect a company to waste space on their web
site advertising which brand of pencil sharpener they use, so why
would you expect they would do so for a programming language?

Sometimes you see web sites with "Powered by IBM" or "Powered by Sun"
or whatever.  I'm sure behind every one of those is a deal cut with
the supplier to promote their name in return for some favorable terms
on a contract.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What can I do with Python ??

2005-01-03 Thread Steve Holden
John J. Lee wrote:
Lee Harr <[EMAIL PROTECTED]> writes:
[...]
I think it looks pretty good. The only problem I see is section 5
where it says:
5. Did we miss your concern?
Please add a comment to this page.
but the page is immutable.


Hopefully one of the site maintainers will read this and demonstrate
that it's actually readonly rather than immutable, then make it
appendable ;-)

To be even more pedantic, I believe it's possible to gain editing 
privileges on the Wiki by authenticating yourself to the engine at

http://www.python.org/moin/UserPreferences
The point is to be able to track changes and thereby discourage 
defacement, which was starting to happen of a depressingly regular basis.

regards
 Steve
--
Steve Holden   http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/
Holden Web LLC  +1 703 861 4237  +1 800 494 3119
--
http://mail.python.org/mailman/listinfo/python-list


Re: Bad Interpreter

2005-01-03 Thread Craig Ringer
On Mon, 2005-01-03 at 12:24 -0800, [EMAIL PROTECTED] wrote:
> I have seen some previous messages about such a problem. I have this
> problem but it is not clear what the solution really was.
> 
> I am running FC2, python 2.3.3
> 
> the script i have sock.py runs if i say something like :
> 
> python sock.py
> 
> but ./sock.py results in a :bad interpreter error
> how do i troubleshoot something like this?

You probably have Windows-style line endings in the file. The kernel
sees the ^M at the end of the line and gets all confused.

--
Craig Ringer

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


Re: Bad Interpreter

2005-01-03 Thread Richards Noah (IFR LIT MET)
<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I have seen some previous messages about such a problem. I have this
> problem but it is not clear what the solution really was.
>
> I am running FC2, python 2.3.3
>
> the script i have sock.py runs if i say something like :
>
> python sock.py
>
> but ./sock.py results in a :bad interpreter error
> how do i troubleshoot something like this?
>
> regards
>

What does the first line of your script look like?  It needs to be pointing
to the python interpreter binary, which you can locate with:

which python

(on the command line).  Check and make sure it is.  If it is and you are
still getting this problem, post some code and the complete error.

HTH.


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


How do I make Windows Application with Python ?

2005-01-03 Thread BOOGIEMAN
Well that's it, how do I make Windows Application with Python ???
Is there simple way that works 100% ? How can I rework visual design
done in VS 2003 to use it for my python program ?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bad Interpreter

2005-01-03 Thread Christopher Koppler
On Mon, 03 Jan 2005 12:24:09 -0800, RajaSrinivasan wrote:

> I have seen some previous messages about such a problem. I have this
> problem but it is not clear what the solution really was.
> 
> I am running FC2, python 2.3.3
> 
> the script i have sock.py runs if i say something like :
> 
> python sock.py
> 
> but ./sock.py results in a :bad interpreter error
> how do i troubleshoot something like this?
> 

Check the first line of your script - it should set the path to the Python
interpreter. It should look something like this:
#!/usr/bin/python

or
#!/usr/bin/env python

which doesn't explicitly set the path to the interpreter, but checks the
environment variable called python for that path. If your python
executable lives somewhere the first line or the environment variable 
doesn't point to, you'll need to correct that.

-- 
Christopher

OutOfSigError

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


Re: Developing Commercial Applications in Python

2005-01-03 Thread Steve Holden
[EMAIL PROTECTED] wrote:
Hello All,
I am trying to convince my client to use Python in his new product. He
is worried about the license issues. Can somebody there to point me any
good commercial applications developed using python ?. The licence
clearly says Python can be used for commercial applications. Is there
any other implications like that of GPL to make the source open ?
Thanks for any help.
eeykay
No. The Python license explicitly allows you to distribute derived works 
(i.e. Python applications including the standard compiler, or modified 
versions of the compiler) without obliging you to disclose the source 
code in the way that the GPL does.

The only obligation the license places on you are
a) You must retain the original copyright notices and
b) If you *do* distribute modified versions, you must include a brief 
description of your modifications.

I believe the Python License Version 2, as found at
  http://www.python.org/moin/PythonSoftwareFoundationLicenseV2Easy
is about as simple as a license can get, yet still the Foundation 
receives inquiries from people whose lawyers are unconvinced there are 
no hidden problems. Of course, IANAL, so the lawyers could be right, but 
at least the INTENT is pretty obvious.

Also beware if you plan to use "The Python License" for your own 
software, and read

  http://www.python.org/moin/PythonSoftwareFoundationLicenseFaq
if you are thinking of doing so. Of course, there are many contributions 
which were licensed to the Foundation for inclusion in the distribution. 
The Foundation is currently in the process of regularizing the "license 
stack" thus created, by negotiating with individual contributors to 
ensure that a compatible license is initially granted to the PSF.

Nothing is currently believed to prohibit the Foundation from licensing 
current releases on the terms that it does, but I should include a 
disclaimer that this is *not* an official statement from the 
Foundation, rather an explanation from one of its directors (an 
all-too-fallible human being) about what's lately been happening in the 
licensing space.

regards
 Steve
--
Steve Holden   http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/
Holden Web LLC  +1 703 861 4237  +1 800 494 3119
--
http://mail.python.org/mailman/listinfo/python-list


Re: Ann: CherryPy-2.0-beta released

2005-01-03 Thread remi
> I'm a great believer that avoiding query strings in URL's is good
> practise ( http://www.holloway.co.nz/book/9 for good arguments why).

CherryPy also supports that out of the box:

class Book:
def default(self, categoryName, bookId):
...
cpg.root.book = Book()

If you go to "http://domain/book/science/9";, CherryPy will call
book.default('science', '9')

> Also how
> much does it complicate matters to run cherryPy under an existing
> webserver? Is any functionality lost?

Well, you can easily run CherryPy behind Apache (see
http://trac.cherrypy.org/cgi-bin/trac.cgi/wiki/BehindApache).
Since CherryPy provides a WSGI interface (although it's still
experimental), you can also run your CherryPy app with any
WSGI-compatible HTTP server (although I don't really see any advantage
to doing this).

Remi

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


Re: Python! Is! Truly! Amazing!

2005-01-03 Thread Steve Holden
Ron Garret wrote:
In article <[EMAIL PROTECTED]>,
 jfj <[EMAIL PROTECTED]> wrote:

Ron Garret wrote:
In article <[EMAIL PROTECTED]>,
"Erik  Bethke" <[EMAIL PROTECTED]> wrote:

I have NEVER experienced this kind of programming joy.

Just wait until you discover Lisp!
;-)

I've had it with all those lisp posts lately ;-)
There were functional and non-functional programming languages (the 
first being *much* simpler to implement). There is a *reason* people 
chose C over lisp. It's not that we were all blind and didn't see the 
amazingness of lisp. Procedural languages are simply better, and I'm not 
replying to this flamewar.

Then neither am I.
Yes, there's a reason people choose C over Lisp, just as there is a 
reason that people choose Windows over OS X, the Ford Taurus over the 
Lexus SC400, and Perl over Python.  But I'm pretty sure joy isn't that 
reason.  If joy is part of your quality metric for a programming 
language then Lisp is worth a look.  (And it costs a lot less than a 
Lexus.)
Well, in the Computer Programming for Everyone stakes I'm pretty sure 
that LISP and its derivatives don't stand a chance, simply because of 
the rebarbative syntax one must use to express even relatively simple 
algorithms and data structures.

While the language has a lot going for it in the hands of an experienced 
and determined LISPer, the average programmer just isn't going to "get it".

regards
 Steve
--
Steve Holden   http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/
Holden Web LLC  +1 703 861 4237  +1 800 494 3119
--
http://mail.python.org/mailman/listinfo/python-list


Re: Bad Interpreter

2005-01-03 Thread Simon John
[EMAIL PROTECTED] wrote:

> the script i have sock.py runs if i say something like :
>
> python sock.py
>
> but ./sock.py results in a :bad interpreter error
> how do i troubleshoot something like this?

sounds like you've been editting the script on a windows machine, and
it's inserted it's evil linefeeds.

on the unix machine run 'dos2unix sock.py', or load sock.py into vi and
remove the ^M characters

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


Re: Zope newsgroups? Need help with POSKeyError

2005-01-03 Thread Dan Stromberg
On Sat, 01 Jan 2005 10:47:41 +1100, richard wrote:

> Bob Horvath wrote:
>> I have a Zope/Plone combination that I have been having POSKeyErrors
>> with for a while now.  Are there any newsgroups that deal with Zope?
> 
> No, but there is a mailing list - see zope.org
> 
> Also, try google searching for POSKeyError.
> 
> 
> Richard

You could also see if the zeop mailing list is gatewayed to nntp on gmane.
 They have a huge number of FLOSS development mailing lists on that nntp
 server.  Google should be able to find it easily.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The Industry choice

2005-01-03 Thread Aahz
In article <[EMAIL PROTECTED]>,
Steve Holden  <[EMAIL PROTECTED]> wrote:
>Aahz wrote:
>> In article <[EMAIL PROTECTED]>,
>> Steve Holden  <[EMAIL PROTECTED]> wrote:
>>>Aahz wrote:

That's funny -- Bruce Eckel talks about how he used to love checked
exceptions but has come to regard them as the horror that they are.
I've learned to just write "throws Exception" at the declaration of
every method.
>>>
>>>Pretty sloppy, though, no? And surely the important thing is to have a 
>>>broad handler, not a broad specification of raisable exceptions?
>> 
>> Yes, it's sloppy, but I Don't Care.  I'm trying to write usable code
>> while learning a damnably under-documented Java library -- and I'm *not*
>> a Java programmer in the first place, so I'm also fighting with the Java
>> environment.  Eventually I'll add in some better code.
>
>The road to hell is paved with good intentions.

So's the road to unfinished software projects.  The question, as always,
becomes how best to balance the competing requirements and resources.
-- 
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: Ann: CherryPy-2.0-beta released

2005-01-03 Thread Ian Bicking
[EMAIL PROTECTED] wrote:
Well, you can easily run CherryPy behind Apache (see
http://trac.cherrypy.org/cgi-bin/trac.cgi/wiki/BehindApache).
Since CherryPy provides a WSGI interface (although it's still
experimental), you can also run your CherryPy app with any
WSGI-compatible HTTP server (although I don't really see any advantage
to doing this).
In the future when more WSGI environments are deployed, I think the 
benefits will be nice.  For instance, under WSGIKit 
(http://svn.colorstudy.com/trunk/WSGIKit) you should be able to create a 
file:

  # cherry_app.py:
  from cherrypy import cpg, wsgiapp
  from my_cherry_app import root_instance
  cpg.root = root_instance
  wsgiapp.init()
  # This variable name is automatically picked up:
  application = wsgiapp.wsgiApp
Then your application would be available under cherry_app/ (wherever you 
happened to put that file in the URL space).  Note that WSGIKit isn't a 
server itself, just a set of middleware that delegates to different 
applications.

It occurs to me that it would be considerably cleaner if it looked more 
like this:

  from cherrypy import wsgiapp
  from my_cherry_app import root_instance
  application = wsgiapp.Application(my_cheery_app)
Otherwise you can only run one CherryPy application in a process...? 
That would be very limiting.

Anyway, the idea is you can deploy a CherryPy-based application fairly 
easily alongside other WSGI Python web applications.  The particulars 
still need some work -- I don't like the little Python file used to put 
the pieces together -- but I think it's a good direction.

--
Ian Bicking  /  [EMAIL PROTECTED]  /  http://blog.ianbicking.org
--
http://mail.python.org/mailman/listinfo/python-list


Re: Rebinding stdout (was: Re: Python! Is! Truly! Amazing!)

2005-01-03 Thread Simo Melenius
Just <[EMAIL PROTECTED]> writes:

> In article <[EMAIL PROTECTED]>,
>  Simo Melenius <[EMAIL PROTECTED]> wrote:
> > ... sys.stdout = sys.__stdout__
> Aargh, I can't believe how widespread this idiom is :-(. See my other 
> reply in this thread: DON'T use sys.__stdout__. Ever.

It probably does the right thing, if someone is copypasting code off
the Usenet and tries it out at the Python prompt (and possibly gets
stuck in getting nothing printed on his tty).

If we're talking about real code it might be advisable to start by
first introducing the import statements omitted from the above
snippet, then worry about someone copypasting code into a serious
program instead of copythinkpasting it. :)

br,
S
-- 
http://mail.python.org/mailman/listinfo/python-list


  1   2   >