Re: Python mail filter

2005-02-08 Thread Tim Roberts
"Mailer" <[EMAIL PROTECTED]> wrote:
>
>(P.S. I am very much aware of the existence of procmail, TMDA etc. My
>requirements are very specific and requires integration with another
>program, so I am only interested in getting a custom solution).

But are you aware that a procmail recipe can feed a message through a
filter, and then pass the results of that filter back in to the e-mail
system for further processing?

It seems to me that you should consider letting procmail do what it is good
at, and use your Python solution for the things that are beyond it.
-- 
- Tim Roberts, [EMAIL PROTECTED]
  Providenza & Boekelheide, Inc.
-- 
http://mail.python.org/mailman/listinfo/python-list


RELEASED Python 2.3.5, final

2005-02-08 Thread Anthony Baxter

On behalf of the Python development team and the Python community, I'm
happy to announce the release of Python 2.3.5 (final).

Python 2.3.5 is a bug-fix release. See the release notes at the website
(also available as Misc/NEWS in the source distribution) for details of
the bugs squished in this release.

Python 2.3.5 contains an important security fix for SimpleXMLRPCServer -
for more, see the announcement of PSF-2005-001 at:

http://www.python.org/security/PSF-2005-001/ 

Python 2.3.5 is the last planned release in the Python 2.3 series, and
is being released for those people who still need to run Python 2.3.
Python 2.4 is a newer release, and should be preferred if possible. From
here, bugfix releases are switching to the Python 2.4 branch - 2.4.1
will be the next Python release.

For more information on Python 2.3.5, including download links for
various platforms, release notes, and known issues, please see:

http://www.python.org/2.3.5

Highlights of this new release include:

  - Bug fixes. According to the release notes, more than 50 bugs 
have been fixed, including a couple of bugs that could cause 
Python to crash. 

Highlights of the previous major Python release (2.3) are available 
from the Python 2.3 page, at

http://www.python.org/2.3/highlights.html

Enjoy the new release,
Anthony

Anthony Baxter
[EMAIL PROTECTED]
Python Release Manager
(on behalf of the entire python-dev team)


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

Re: python connect to server using SSH protocol

2005-02-08 Thread Martin Franklin
Simon Anders wrote:
Hi
Laszlo Zsolt Nagy wrote:
[EMAIL PROTECTED] wrote:
How can python connect to server which use SSH protocol?

There should be a better way.
   Simon
There is : pexpect!  http://pexpect.sourceforge.net/


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


Re: Is Python as capable as Perl for sysadmin work?

2005-02-08 Thread Max M
Jeff Epler wrote:
No.
Unlike Perl, Python implements only a *finite turning machine* model of
computation.  An easy way to see this limitation is in the following
code:
>>> 1.0 / 10.0
0.10001
In an infinite Turning machine, there would be an unbounded number of
zeros before the second 1, giving the exact result, not a numeric
approximation.
Another thing is that in Perl it turns left, while in Python it turns 
right. hence the .rfind() string method.


Well, if you ever
have to threaten Python, just keep in mind that '... or die' just plain
won't work.  You have to suggest that it 'try ... except', which is
really offensive.  If I want to beg my computer to run programs, I know
where to find Intercal with its "PLEASE" and "DO PLEASE" constructions.
Wasn't there talk about a "try harder" recently?
try:
statement
tryharder:
statement
--
hilsen/regards Max M, Denmark
http://www.mxm.dk/
IT's Mad Science
--
http://mail.python.org/mailman/listinfo/python-list


Re: Name of type of object

2005-02-08 Thread Randall Smith
Jive Dadson wrote:
The traceback routine prints out stuff like,
NameError: global name 'foo' is not defined
NameError is a standard exception type.
What if I want to print out something like that?
I've determined that "global name 'foo' is not defined" comes 
from the __str__ member of the exception object.
Where does it find the string "NameError"?  In general, if I have 
an object, is there a way to obtain the name of the type of the object?

Thankee.
type(object) ?
Randall
--
http://mail.python.org/mailman/listinfo/python-list


Re: Loop in list.

2005-02-08 Thread Caleb Hattingh
Hi Fredrik

*sigh*  I think I will stop writing mini-tutorials :)

You are, of course, correct.  And I really like your method of
explaining how to mentally juggle the LC into explicit loops.

I shudder to think how mnay people I confused with my incorrect
examples - I really should have tested them first.

Thanks again
Caleb

> (to translate a list comprehension to nested statements, remove
> the result expression, insert colons and newlines between the for/if
> statement parts, and put the append(result expression) part inside
> the innermost statement)
> 
> 

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


Re: Python versus Perl ?

2005-02-08 Thread Caleb Hattingh
Hi Adam

Thanks for your comments.

> I think the expression you seek is "comparing virtue among whores."

Sure, that's what I was saying, but not quite in as colourfil a manner
:)

> >
> > The problem domains in which I do most of my work (chemical process

> > modelling and simulation) really do require speed.  That's why I
mostly
> > use Delphi (i.e. reasonably fast code) at work.   I believe I know
when
> > speed is and is not an issue, and (by far) most of the time, my
experience
> > is that it is *not*.  So I use Delphi for numerical code and python
for
> > everything else.
>
> Why don't you use C for the numerical work?  Then you can do your
number
> crunching within a c-based python module.  Have your cake and ...

As you might imagine, I think about this constantly.  However, there
are many other issues that make it complicated, such as having to work
in a team where the average guy knows pascal well (we're just a bunch
of chemical engineers), but has never even heard of python.  Plus, were
I to go this type of route, I would almost definitely code the binary
modules in Delphi or FreePascal, make a DLL and use ctypes to call it.
I do not know C and have no desire to learn now :)On the other
hand, I know pascal quite well.

keep well
Caleb

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


Re: python code with indention

2005-02-08 Thread EP

> Original Message
> From: "Xah Lee" <[EMAIL PROTECTED]>

> is it possible to write python code without any indentation?

Perhaps our zen-like response to this question should have been:

>>>pass


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


Re: Python versus Perl ?

2005-02-08 Thread Harlin
If you give it a good go, you will be amazed at how the text processing
is so much better than Perl's. The same with the object orientation
(what oop in Perl?? none... at least none worth mentioning :-) It's
been said before by many Python users... Python allows newbies to
program and wizards to be even more wizardly... or something to that
effect.

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


Re: variable declaration

2005-02-08 Thread Eric Pederson
Arthur artfully argued:

> What if:
> 
> There was a well conducted market survey conclusive to the effect that
> adding optional strict variable declaration would, in the longer run,
> increase Python's market share dramatically.


It's always good to examine one's objectives and motives.  I am an enthusiast 
for marketing Python, but why?  Would I get something out of Python being the 
language du jour?  If everyone starts using Python when I am an old hand with 
the language, will it elevate me?  Is a world where people use a programming 
language called "Python" necessarily a better world?

For me the answer to those questions is no.

So what would I like?

Just the option to use Python when and where it suits me and my tasks  - and 
the continued excellent quality development and maintenance of Python and 
Python libraries.


> It just would. 

Right!

All the cool kids (and if you want to be popular you need to):

smoke/smoke dope/get tatoo'd/fight/climb the water tower/get pierced/get 
drunk/call their girlsfriends a b!#ch/shop lift/ditch school/put their fingers 
into an electrical outlet


Declare variables?

Hey, what's one more compromise to get popular?!


(I shudder thinking where that slippery slope leads)




[Nothing above is meant to imply I haven't done stupid things; rather perhaps 
that I've already done more than enough to know better; and, by the way, I'm 
still not "popular".  I'd hope GvR and the crew "keep Python Python"]




Eric Pederson
http://www.songzilla.blogspot.com

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


Name of type of object

2005-02-08 Thread Jive Dadson
The traceback routine prints out stuff like,

NameError: global name 'foo' is not defined

NameError is a standard exception type.

What if I want to print out something like that?
I've determined that "global name 'foo' is not defined" comes 
from the __str__ member of the exception object.
Where does it find the string "NameError"?  In general, if I have 
an object, is there a way to obtain the name of the type of the object?

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


ANN: Constrict 0.1.0 DNS message parsing library

2005-02-08 Thread Jason Smith
This message is to announce a new Python module, Constrict, which is
useful for examining DNS messages that you receive either from a network
capture or from a socket.  While other DNS-related Python projects
exist, none provide flexible message parsing and inspection.

  http://www.oes.co.th/projects/Constrict

Constrict is BIND for Python: it is a Python library for parsing DNS
messages using ISC's libbind. Constrict allows you to see DNS messages
in two ways:

  * Direct access to the libbind parsing functions
  * A Python object with various meaningful attributes

This software is available under the GNU General Public License, version
2.

This is the initial release.  Constrict evolved from an internal project
development, so it has already seen much real-world testing.  The
wrapper to the BIND C API is thorough enough for most development, and
the object-oriented view is quite intuitive for day-to-day queries and
responses.

Constrict is known to work with Python 2.3 and BIND 9 on Linux/i386 and
Linux/ppc.

-- 
Jason Smith
Open Enterprise Systems
Bangkok, Thailand
http://www.oes.co.th

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


Re: Definitive documentation on newstyle classes? (WAS: Pickling and inheritance are making me hurt)

2005-02-08 Thread Michele Simionato
> It would be good to have a clear exposition of the pros and cons of
> __new__ usage.

It is there mostly because __init__ would not work on immutable types.
OTOH, you probably do not want to use __new__ on mutable types
(once I was caught by this trap, google for "overriding list.__new__"
if you are interested).
 
   Michele Simionato

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


Re: variable declaration

2005-02-08 Thread Elspeth Thorne
Alexander Zatvornitskiy wrote:
> You may say: give better names for your variables! Ha, I'am often don't
> understand that they mean! They are written for me by an engineer!
Hang on, though - if you don't understand what you are programming, then 
how can you check if it's correct? Regardless of variable names, 
declarations, or anything else. And besides which - is/was there 
anything preventing you from using different variable names within the 
code (which are understandable to you), then  displaying different names 
to the user (eg an engineer) when an error occurs?

You'd hit the same issues (precisely the same issues) with any language, 
if you flat-out do not know what you are doing - or trying to do.

Admittedly, I have somewhat limited experience, so my word is not 
gospel, or even necessarily well-informed.

But it seems to me that declaring your variables would not fix the 
underlying problem here - the programmer's lack of understanding of the 
task.

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


Re: A ListComp that maintains its own state (Was: Re: turing machine in an LC)

2005-02-08 Thread Michael Spencer
Carl Banks wrote:
Pay attention, chief.  I suggested this days ago to remove duplicates
from a list.
from itertools import *
[ x for (x,s) in izip(iterable,repeat(set()))
  if (x not in s,s.add(x))[0] ]
;)
Sorry,  I gave up on that thread after the first 10 Million* posts.  Who knows 
what other pearls I may have missed?

Anyway, the good news is that you appear to have identified a new design 
pattern, and will soon become very famous:

According to:
http://www.cmcrossroads.com/bradapp/docs/patterns-nutshell.html#Patterns_What
A "pattern" is ...
* An abstraction from a concrete form which keeps recurring in specific, 
non-arbitrary contexts. [twice in one week]

* A recurring solution to a common problem [perl-python spam] in a given 
context and system of forces.

* A named "nugget" of instructive insight, conveying the essence of a 
proven solution to a recurring problem in a given context amidst competing 
concerns. [who could doubt it?]

* A successfully recurring "best practice" that has proven itself in the 
"trenches". [of this list anyway]

* A literary format for capturing the wisdom and experience of expert 
designers, and communicating it to novices [I think we're 5 for 5]

So, I would get the book out without further delay, before some other 
Johnny-come-lately lays claim.

BTW, Do you have a 1-line-LC-wiki yet?
Michael
* with due respect to Marvin
--
http://mail.python.org/mailman/listinfo/python-list


Re: negative integer division

2005-02-08 Thread Mike Meyer
Jive Dadson <[EMAIL PROTECTED]> writes:

> Python does it right.  C is allowed to do it anyway it likes, which was
> a stupifyingly horrible decision, IMHO.

C only does it wrong if you think that C is a high level language. It
isn't - it's a portable assembler. As such, low level things (like
this, or what happens on integer overflow, or ...) are left up to the
implementation, so it can do what's most natural for the underlying
hardware. This means that when you don't care - which I'd argue is
most of the time - you get the fastest thing the machine will do. When
you do care, you have to take care of it yourself. Of course, if you
care, you probably shouldn't be writing in assembler, you should
probably be writing in a high level language - which will make sure
the low level things get done right, irregardless of what the
underlying machine does.

Now, I'll agree with you if you want to argue that some machines do
negative integer division in stupifyingly horrible ways.

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


Re: negative integer division

2005-02-08 Thread Dan Bishop
Mark Jackson wrote:
> Imbaud Pierre <[EMAIL PROTECTED]> writes:
> > integer division and modulo gives different results in c and
python,
> > when negative numbers
> > are involved. take gdb as a widely available c interpreter
> >   print -2 /3
> > 0 for c, -1 for python.
> > more amazing, modulos of negative number give negative values! (in
c).
> > from an algebraic point of view, python seems right, but I thought
> > python conformity to the underlying c compiler was a strong
commitment,
>
> AIUI the C standard is silent on the issue, and hence the C behavior
is
> implementation-dependent.

The *original* C standard is silent on the issue, but the current
standard requires the wrong behavior.

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


Re: interactive execution

2005-02-08 Thread Jive Dadson
Yeah.  I got it.

exec "foo = 555" in globals(), locals() does the trick.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: An Ode To My Two Loves

2005-02-08 Thread Mike Meyer
[EMAIL PROTECTED] (Aahz) writes:

> In article <[EMAIL PROTECTED]>, Mike Meyer  <[EMAIL PROTECTED]> wrote:
>>
>>COM is dominant on Windows because MS pushes it. CORBA isn't dominant
>>on Unix because there are a slew of extensible/embeddable languages to
>>pick from instead - assuming the apps in question came up with a
>>solution better than rolling their own. See >http://www.mired.org:8080/home/mwm/scripting/ > for my thoughts on the
>>matter before I learned better.
>
> "Unable to connect to host"

My bad. That should be http://www.mired.org/home/mwm/scripting/ .

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


Re: Which IDE supports python and wxpython?

2005-02-08 Thread Jim Smith
Selfimprover wrote:
Hello all,
Is there a good IDE on the market which supports python and wxpython. Goal
is to use it in a big distributed project.
Greetings
Try wxDesigner!
http://www.roebling.de/
--
http://mail.python.org/mailman/listinfo/python-list


Re: interactive execution

2005-02-08 Thread Jive Dadson


Jeff Shannon wrote:
> 
> Jive Dadson wrote:
> 
> > How does one execute arbitrary text as code within a module's context?
> >
> > I've got some code that compiles some text and then executes it.  When
> > the string is "print 'Hello'", it prints "Hello".  I get no exception
> > when I compile and execute "foo = 555".  If I then compile and exec
> > "print foo", I get a name error. The variable foo is undefined. My
> > assumption is that the "exec" command created a new namespace, put "foo"
> > in that namespace, and then threw the namespace away.  Or something.
> 
> You can do
> 
> exec codestring in globaldict, localdict
> 
> (Or something like that, this is from unused memory and is untested.)
>   The net effect is that exec uses the subsequent dictionaries as its
> globals and locals, reading from and writing to them as necessary.
> 
> (Note that this doesn't get you any real security, because malicious
> code can still get to __builtins__ from almost any object...)
> 
> Jeff Shannon
> Technician/Programmer
> Credit International

Promising, but,

Traceback (most recent call last):
  File "F:/C++ Projects/zardude/temp.py", line 9, in -toplevel-
exec "foo = 555" in globaldict, localdict
NameError: name 'globaldict' is not defined
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Learning Python - resources and ideas

2005-02-08 Thread Luis M. Gonzalez
Regarding rec.photo.equipment.35mm... this is not his fault.
Yesterday I tried posting to comp.lang.python and, for some strange
reason, it was posted momentarily to this group.

Regarding Cody's question:
If you are an absolute newby, try Josh Cogliati's python tutorial for
non-programmers (google this).
I learned the basics with it.

Then you can try any of the other resources listed in www.python.org.
If you're willing to buy a book, try "Learning Python 2nd.Ed" by Mark
Lutz or "Core Python" by Wesley Chun.

Regards,
Luis

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


Re: WYSIWYG wxPython "IDE"....?

2005-02-08 Thread Jim Smith
Simon John wrote:
I'm writing my 2nd large wxPython program, and after the problems I
found doing the first's layout in code, I'd like to look at using a
'WYSIWYG' IDE, like VisualStudio does for MFC.
I've tried a few that I found, wxGlade is probably the best, although
it seems to be not 100% WYSIWYG (like the widgets in the preview are
not much like the final program), wxDesigner has a horrid GUI for a GUI
designer! VisualWX gave me the 'now what?' feeling when I started a new
project.
I find the sizer layout thing is what's holding these programs back, is
there another wxWidgets layout system, so that I could just drag'n'drop
widgets wherever I want in a window, more like Qt or MFC?
I'd like to just put a TextCtrl with a few buttons underneath it
without having to create two boxsizers or a gridsizer!
I'd like to create something like the main XMMS (or Winamp) window:
http://xmms.org/files/Skins/images/winamp_x_xmms.png
But that would be a 3-way vertical sizer, a 2-way horizontal and a
2-way vertical at least just for the main (top left) window.

I have tried all the GUI tools for wx and I think wxDesigner is the 
best.  It is commercial, but worth it.

http://www.roebling.de/
--
http://mail.python.org/mailman/listinfo/python-list


Re: An Ode To My Two Loves

2005-02-08 Thread Aahz
In article <[EMAIL PROTECTED]>, Mike Meyer  <[EMAIL PROTECTED]> wrote:
>
>COM is dominant on Windows because MS pushes it. CORBA isn't dominant
>on Unix because there are a slew of extensible/embeddable languages to
>pick from instead - assuming the apps in question came up with a
>solution better than rolling their own. See http://www.mired.org:8080/home/mwm/scripting/ > for my thoughts on the
>matter before I learned better.

"Unable to connect to host"
-- 
Aahz ([EMAIL PROTECTED])   <*> http://www.pythoncraft.com/

"The joy of coding Python should be in seeing short, concise, readable
classes that express a lot of action in a small amount of clear code -- 
not in reams of trivial code that bores the reader to death."  --GvR
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: interactive execution

2005-02-08 Thread George Yoshida
Jive Dadson wrote:
I've got some code that compiles some text and then executes it.  When
the string is "print 'Hello'", it prints "Hello".  I get no exception
when I compile and execute "foo = 555".  If I then compile and exec
"print foo", I get a name error. The variable foo is undefined. My
assumption is that the "exec" command created a new namespace, put "foo"
in that namespace, and then threw the namespace away.  Or something.
I know it must be possible to do this, because it's exactly what
programs like IDLE do.
  exec statement in name_space
will do the trick.
>>> d = {}
>>> exec 'foo=555' in d
>>> d['foo']
555
>>> exec "print foo" in d
555
- george
--
http://mail.python.org/mailman/listinfo/python-list


Re: Pypy - Which C modules still need converting to py?

2005-02-08 Thread Luis M. Gonzalez
Also you can browse the Pypy-Dev archives here:
http://codespeak.net/pipermail/pypy-dev/
and post messages here: pypy-dev@codespeak.net

regards,
Luis

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


Re: A ListComp that maintains its own state (Was: Re: turing machine in an LC)

2005-02-08 Thread Carl Banks
Michael Spencer wrote:
> > Jeremy Bowers <[EMAIL PROTECTED]> writes:
> >
> >
> >>On Tue, 08 Feb 2005 17:36:19 +0100, Bernhard Herzog wrote:
> >>
> >>>Nick Vargish <[EMAIL PROTECTED]> writes:
> >>>
> "Xah Lee" <[EMAIL PROTECTED]> writes:
> 
> >is it possible to write python code without any indentation?
> 
> Not if Turing-completeness is something you desire.
> >>>
> Bernhard Herzog wrote:
> 
> a Turing Machine in one line plus assignments - nice!  Turns out that
pypy is more
> verbose than strictly necessary ;-)
> ...
>
>
> BTW, I realized that it is indeed possible for a LC to maintain its
own state
> without being passed an external mutable.  The trick is to use
itertools.repeat
> to return the same mutable object on each iteration.

Pay attention, chief.  I suggested this days ago to remove duplicates
from a list.

from itertools import *
[ x for (x,s) in izip(iterable,repeat(set()))
  if (x not in s,s.add(x))[0] ]

;)

There is a way to even avoid repeat if you're feeling EVIL.

[ x for x in iterable if x not in locals()['_[1]'].__self__ ]

Turning this into a turing machine is left as an exercise.  The recipe
in effect:

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/204297


-- 
CARL BANKS

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


Re: interactive execution

2005-02-08 Thread Jeff Shannon
Jive Dadson wrote:
How does one execute arbitrary text as code within a module's context?
I've got some code that compiles some text and then executes it.  When
the string is "print 'Hello'", it prints "Hello".  I get no exception
when I compile and execute "foo = 555".  If I then compile and exec
"print foo", I get a name error. The variable foo is undefined. My
assumption is that the "exec" command created a new namespace, put "foo"
in that namespace, and then threw the namespace away.  Or something.
You can do
   exec codestring in globaldict, localdict
(Or something like that, this is from unused memory and is untested.) 
 The net effect is that exec uses the subsequent dictionaries as its 
globals and locals, reading from and writing to them as necessary.

(Note that this doesn't get you any real security, because malicious 
code can still get to __builtins__ from almost any object...)

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


Re: variable declaration

2005-02-08 Thread Arthur
On Sat, 5 Feb 2005 17:00:15 +0100, [EMAIL PROTECTED] (Alex Martelli)
wrote:

>Alexander Zatvornitskiy
><[EMAIL PROTECTED]> wrote:
>   ...
>>  AM> The fact that in Python there are ONLY statements, NO declarations,
>> ===
>> def qq():
>>  global z
>>  z=5
>> ===
>> What is "global"? Statement? Ok, I fill lack of "var" statement:)
>
>'global' is an ugly wart, to all intents and purposes working "as if" it
>was a declaration.  If I had to vote about the one worst formal defect
>of Python, it would surely be 'global'.

Venturing in - again - over my head. Brave or stupid.  

But the fact that I cannot dissect Python byte code, doesn't mean I
can't follow the logic or illogic of an argument. Or hear, or
interpret reasonably well what I hear.

I will accept that global is a horribly wart for reasons that I don't
understand.  (worse than print>> for more reasons I don't understand
as well ?)

But making the argument that it is a wart *because* it is declarative,
and therefore a violation  of Python's purity is hard for me. 

"""
The fact that in Python there are ONLY statements, NO declarations, is
a completely different LEVEL of issue -- a totally deliberate design
choice taken in full awareness of all of its implications.  
"""

Global is there. It was put there by someone who presumably knows his
declaratives. So simply as a matter of logic, your assertion doesn't
hold up.

And as we learn, what is true of Python today is not necessarily what
is true of Python tomorrow.  And my understanding of the arguments
surrounding the decorator debate suggested to me that there is
decently strong sentiment among a segment of the folks who represent
"the community" much better than do I, that if there indeed has been
any purist stricture about the use of declaratives in the kanguage, it
may be wise to loosen it.

Why is it logical to believe that a language that is purely anything
will best do.  Python prides itself on being multi-paradigm, thought
I. Except Ales says no declarations allowed, with great authority. 

Do they belong in any language? Solve problems in any language?

If so, why is that Python is denied them?

Ultimately I don't think Guido chooses to be restricted by these kinds
of notions of purity.  And suspect that if and when declarations best
solve real problems, they will brought to bare - without regard to
such notions.

I am sure you could if you wanted provide a highly competent - OK
brilliant - answer to why given this and that aspect of Python it
can't and won't and shouldn't be.. 

But you are a polemicist at heart, it seems to me - on observation
from non-techncial discussion.

So all my technical limitations aside, I still don't think I could
decipher where polemics ends, and analysis begins.

Squash me like a bug, it you like. But I am not - just so you know -
meaning to be even unfriendly, much less hostile.


Art


>
>Fortunately, it's reasonably easy to avoid the ugliness, by avoiding
>rebinding (within functions) global variables, which tend to be easy. 
>
>What you keep demanding is a way to inject far worse ugliness, and in a
>context in which the typical behavior of pointy-haired bosses will be to
>make it unavoidable for many of the people who work with Python.  I am
>strongly convinced that, if you had your wish, the total amount of
>happiness in the world would be quite substantially diminished, and I
>will do anything I can to stop it from happening.
>
>
>>  >> Fine! Let interpreter never show us errors like division by zero,
>>  >> syntax errors, and so on. If file not found, library don't need to
>>  >> say it. Just skip it!!! Because every, even simple, test will find
>>  >> such bugs. Once you have unit tests, the added value of 
>>  >> is tiny, and their cost remains.
>>  AM> Another false assertion, and a particularly ill-considered one in ALL
>>  AM> respects. Presence and absence of files, for example, is an
>   ...
>> Here, you take one detail and bravely fight with it. Just try to understand
>> meaning of my sentence, in all. It will help:)
>
>I tear ONE of your examples to pieces in gory detail, because it's not
>worth doing the same over and over again to every single piece of crap
>you filled that sentence with -- very similar detailed arguments show
>how utterly inane the whole assertion is.
>
>There IS no meaning to your (several) sentences above-quoted, that it
>can help anybody to "try to undestand": it's simply an insanely bad
>attempt at totally invalid parallels.
>
>>  AM> In brief: you're not just wrong, you're so totally, incredibly,
>>  AM> utterly and irredeemably wrong that it's not even funny.
>> Hey, take it easy! Relax, reread that piece of text. It was written with 
>> smile
>> on my lips. Here it is for your convenience:
>
>Do yourself a favor: don't even _try_ to be funny in a language you have
>so much trouble with.  Your communication in English is badly enough
>impaired even without such lame attempts at humor: don't made bad things
>even worse -- th

Re: negative integer division

2005-02-08 Thread Jive Dadson
Python does it right.  C is allowed to do it anyway it likes, which was
a stupifyingly horrible decision, IMHO.

Way back when, there was a language named Pascal.  I lobbied the Pascal
standards committee to define the modulus operator correctly, which they
eventually did.  To my astonishment, they proceded to define the
division operator backwards to the modulus operator, so that division
and mod did not play together correctly.  Duh.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: An Ode To My Two Loves

2005-02-08 Thread Mike Meyer
Peter Maas <[EMAIL PROTECTED]> writes:

> Jorgen Grahn schrieb:
>> It's something that worries me frequently -- I feel guilty when I introduce
>> Python into ("force Python upon") an organization. Because I hate having
>> /other/ people's favorite toy languages forced down /my/ throat ...
>
> The solution is a multi language glue layer. Software interfaces are
> defined in a  language independent way so that they can be used by
> many  languages.I wonder why COM is so dominant on Windows and most
> Unixish systems don't use CORBA (with GNOME as an exception).
> Microsoft's .net takes this one step further by defining a multi
> language implementation layer.

COM is dominant on Windows because MS pushes it. CORBA isn't dominant
on Unix because there are a slew of extensible/embeddable languages to
pick from instead - assuming the apps in question came up with a
solution better than rolling their own. See http://www.mired.org:8080/home/mwm/scripting/ > for my thoughts on the
matter before I learned better.

> I hope these ideas will become more influential in Unix like systems
> as well just to stop this resource wasting source code issue.

XMLRPC seems to be displacing CORBA for interobject
communications. It's not clear it's becoming an intercommunications
tool for scripting applications.

In any case, Plan 9 has a much better solution than COM, CORBA or
XMLRPC. I can script plan 9 applications with the shell. I can't do
that with CORBA (well, my quick search failed to turn up CORBA
bindings for sh. It can probably be done with XMLRPC, but it would be
ugly. The problem is that this requires fundamental changes in the
underlying OS (by adding per-process mount points), but there's
mention of experiments with that for Linux.

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


Re: Lambda

2005-02-08 Thread Alan McIntyre
e wrote:
Question: WHAT IS LAMBDA? I can't figure out what it does from any 
documentation i've found anywhere. i doubt i need it but i still want to 
know what the heck it is/does/fixes/whatever! 
Here's something:
http://docs.python.org/tut/node6.html#SECTION00675
Hope this helps,
Alan McIntyre
ESRG LLC
http://www.esrgtech.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: What's wrong with `is not None`?

2005-02-08 Thread Jive Dadson


Frans Englich wrote:
> 
> That's what PyChecker tells me, at least.
> 
> A line of:
> 
> if testReport is not None:
> 
> results in:
> 
> runner.py:587: Using is not None, may not always work
> 
> In what circumstances can `is not None` fail? How and why does it fail?
> 
> What is the equivalent expression which is more secure; `!= None`?

Yeah, that'll do it.

Incredibly, Microsoft has patented the "isnot" operator.  I kid you not.
They are amassing an incredible number of patents, many with no more
merit than the "isnot" one.  I'll leave it to your imagination as to
why.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Lambda

2005-02-08 Thread Tim Leslie
Short answer:

lambda is a python keyword which allows you to create anonymous
functions which may be considered a useful thing to have in certain
cases*.

Long answer:

To be provided by someone else who isn't meant to be working right now.

Tim

* There is much debate as to just how useful lambda functions are and
they are likely to be removed from the language in the distant futute
(python 3)


On Tue, 8 Feb 2005 17:43:32 -0800, e <[EMAIL PROTECTED]> wrote:
> Question: WHAT IS LAMBDA? I can't figure out what it does from any
> documentation i've found anywhere. i doubt i need it but i still want to
> know what the heck it is/does/fixes/whatever!
> 
> 
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Lambda

2005-02-08 Thread e
Question: WHAT IS LAMBDA? I can't figure out what it does from any 
documentation i've found anywhere. i doubt i need it but i still want to 
know what the heck it is/does/fixes/whatever! 


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


Lambda

2005-02-08 Thread e
here's what is probably an unusual question: 


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


interactive execution

2005-02-08 Thread Jive Dadson
How does one execute arbitrary text as code within a module's context?

I've got some code that compiles some text and then executes it.  When
the string is "print 'Hello'", it prints "Hello".  I get no exception
when I compile and execute "foo = 555".  If I then compile and exec
"print foo", I get a name error. The variable foo is undefined. My
assumption is that the "exec" command created a new namespace, put "foo"
in that namespace, and then threw the namespace away.  Or something.

I know it must be possible to do this, because it's exactly what
programs like IDLE do.

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


Re: Big development in the GUI realm

2005-02-08 Thread Mike Meyer
"Gabriel B." <[EMAIL PROTECTED]> writes:

>> >>Considering the fact that the Qt DLL exist by themselves, that the
>> >>version used is the one provided by Qt, and that the EXE uses a
>> >>standard, open way to communicate with it, the above does seem to say
>> >>this use would be valid.
>> >>
>> >>
>> >
>> >http://www.gnu.org/licenses/gpl-faq.html#MereAggregation
>> >
>> >"/.../ If modules are designed to run linked together in a shared 
>> > address
>> >space, that almost surely means combining them into one program.
>> >
>> >By contrast, pipes, sockets and command-line arguments are
>> >communication mechanisms normally used between two separate
>> >programs. So when they are used for communication, the modules
>> >normally are separate programs. But if the semantics of the
>> >communication are intimate enough, exchanging complex internal
>> >data structures, that too could be a basis to consider the two parts
>> >as combined into a larger program."
>> >
>> >
>
> This is odd. They claim it's a GPL'ed version, but it's a trolltech
> license that forces you to release your code under gpl even tought
> their's not!
>
> I'm not against a company getting it's share with their product.
> that's what motivated them in the first place. but DONT LIE! don't
> call it gpl when it's not.
>
> Gpl make it very explicity it deals with the program as a whole, in
> the meaning of a executable code. What they're trying to achive here
> is that, by adding this paragraph, they will cover the "dll use" under
> the gpl.
>
> By that cover-all definition they came up, i can't use Internet
> Explorer to see a site hosted with a gpl'ed server! i can't even use a
> BSD program to grep a file!

Now the latter isn't true, because the BSD license isn't viral.

On the other hand, you're conflating data and code. If that stands,
then you'd be only be allowed to distribute code written with GNU
Emacs under the GPL, which is goes against long-standing position of
the FSF on GNU Emacs.

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


Re: Dumb glob question

2005-02-08 Thread Python Dunce
Michael Hoffman <[EMAIL PROTECTED]> wrote in comp.lang.python:

> Python Dunce wrote:
> 
>> So if I happen 
>> to be processing 'foo [bar].par2'
>> 
>> glob.glob(filename[:-5]+'.*par2')
>> 
>> doesn't return anything.  Using
>> win32api.FindFiles(filename[:-5]+'.*par2') works perfectly, but I don't
>> want to rely on win32api functions.  I hope that made more sense :).
> 
> If you look in the source for glob.py, you will find that it calls the
> fnmatch module, and this is the docstring for fnmatch.translate():
> 
>  """Translate a shell PATTERN to a regular expression.
> 
>  There is no way to quote meta-characters.
>  """
> 
> So you cannot do what you want with glob.
> 
> You can replace [] with ? in your glob string, if you are sure that
> there won't be other characters there. That's a bit of a hack, and I
> wouldn't do it.
> 
> In my mind it would probably be best to do:
> 
> re_vol = re.compile(re.escape(startpart) + ".*vol.*")
> lst = [filename for filename in os.listdir(".") if
> re_vol.match(filename)] 
> 
> I changed "list" to "lst" because the former shadows a built-in.

Thanks, that should do the trick!  I had tried basically the same thing 
once but I was getting back empty lists.  I think it was just a brain fart 
involving a case sensitive regex that didn't match the files I was testing 
it on :/.
-- 
http://mail.python.org/mailman/listinfo/python-list


tcl/tk naming scheme vs python's

2005-02-08 Thread Gabriel B.
I got my self writting nested objects to hold Tk references, then i
realizes that i was working in python and not tcl, so i switched to
flat vars... and in no time i was using more then 7 words separated by
captalization in the names... i was able to rethink my scheme to use
5... no less.

i'm i exagerating or do you people also comes to this some times?
The other choice i think i had was to use semantic names instead of
semantic and hierarchical ones.

Gabriel

PS: i resisted the force of make an example using
ButtonSpamSpamSpamSpamSpamEggsSpam
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: tk global bindings

2005-02-08 Thread Gabriel B.
> Oh and you of course __must__ look at the (recently updated!) New Mexico
> Tech tkinter document at:
> http://infohost.nmt.edu/tcc/help/pubs/tkinter.pdf
> 
> See page 75 and follwing for more info on keyboard bindings...

Thanks, i was looking down that doc because the first thing i looked
into it was the pack method and it talked about the grid only

...i'm still using "practical programing in Tcl and Tk" for my tk needs :)

thanks again,
Gabriel
-- 
http://mail.python.org/mailman/listinfo/python-list


win32 service and sockets

2005-02-08 Thread Tom Brown
Hi,

I created a win32 service for XPPro called N4010ATestService.py (see below). 
The service runs as a particular user with administrative rights. It starts a 
thread that creates a simple socket server (N4010ASocketServer.py -- also 
below) that just waits for 20 character string. When I run the socket server 
by itself the test client can connect to the server and send a 20 character 
string just fine. When I run the service, the server will bind to the port 
but the client cannot connect. I verified the server was listening on the 
given port using netstat -an. The client eventually times out. Why isn't the 
server accepting connections when run in a service?

Thanks,
Tom

N4010ATestService.py:
-
import win32serviceutil
import win32service
import win32event
import N4010ASocketServer
from thread import start_new_thread

class N4010ATestService(win32serviceutil.ServiceFramework):
  _svc_name_ = "N4010ATestService"
  _svc_display_name_ = "N4010A Test Service"
  def __init__(self, args):
win32serviceutil.ServiceFramework.__init__(self, args)

  def SvcDoRun(self):
 start_new_thread(N4010ASocketServer.main, ())
 N4010ASocketServer.waitfor()

  def SvcStop(self):
# Before we do anything, tell the SCM we are starting the stop process.
self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
N4010ASocketServer.stop()

if __name__ == '__main__':
  win32serviceutil.HandleCommandLine(N4010ATestService)


N4010ASocketServer.py:
--
from socket import socket
from select import select
from time import sleep
import win32evtlogutil

applicationName = 'N4010ASocketServer'
messageDll = 'C:\Python24\Lib\site-packages\win32\pythonservice.exe'
running = True
stopped = False

def registerWithEventViewer():
  win32evtlogutil.AddSourceToRegistry(applicationName, messageDll)

def stop():
  import servicemanager
  servicemanager.LogInfoMsg('stopping')
  global running
  running = False

def waitfor():
  while not stopped:
sleep(0.5)

def main():
  import servicemanager
  registerWithEventViewer()
  servicemanager.LogInfoMsg('creating socket')
  sock = socket()
  servicemanager.LogInfoMsg('binding to port 48777')
  sock.bind(('0.0.0.0', 48777))
  servicemanager.LogInfoMsg('listening')
  sock.listen(5)
  while running:
servicemanager.LogInfoMsg('Waiting for connection.')
readyRead, readyWrite, inerror = select([sock], [], [], 0)
while (not readyRead) and running:
  sleep(0.5)
  readyRead, readyWrite, inerror = select([sock], [], [], 0)
if running:
  conn, address = sock.accept()
  msg = conn.recv(20)
  servicemanager.LogInfoMsg('Recvd msg: %s' % msg)
  conn.close()
  global stopped
  stopped = True
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Java Integer.ParseInt translation to python

2005-02-08 Thread jose isaias cabrera
Ok, so this,
buffer[0] = (byte)Integer.parseInt(string,16);
in java is, partly, this
buffer[0] = int(string, 16)
in python.  But here is my problem.  When I call this java subroutine,
 byte[] decodeKey(String inString)
 {
   if (inString == null)
   return null;
   System.out.println("StringLength = " + inString.length());
   byte[] retBuf = new byte[inString.length()/2];
   // The string has two hex characters per byte.
   for (int index = 0; index < retBuf.length; index++)
   {
 System.out.print(inString.substring(2*index, 2*index+2));
 System.out.println(" " +
   Integer.parseInt(inString.substring(2*index, 2*index+2), 16) + " " +
   (byte)Integer.parseInt(inString.substring(2*index, 2*index+2), 16));
 retBuf[index] =
   (byte)Integer.parseInt(inString.substring(2*index, 2*index+2), 16);
   }
   System.out.println(retBuf);
   return retBuf;
 }
I get this output:
StringLength = 40
c1 193 -63
7c 124 124
e1 225 -31
86 134 -122
ab 171 -85
94 148 -108
ee 238 -18
b0 176 -80
de 222 -34
8a 138 -118
e3 227 -29
b5 181 -75
b7 183 -73
51 81 81
a7 167 -89
c4 196 -60
d8 216 -40
e9 233 -23
ed 237 -19
eb 235 -21
[EMAIL PROTECTED]
But, here is what I have for python,
def PrepareHash(HashStr):
 while len(HashStr) > 0:
   byte = HashStr[0:2]
   print byte,int(byte,16),byte(int(byte,16)) # & 0xff
   HashStr = HashStr[2:]
 return byte
def Main():
 HashStr = "c17ce186ab94eeb0de8ae3b5b751a7c4d8e9edeb"
 HashStr = PrepareHash(HashStr)
 print "Prepared HashStr :",HashStr
Main()
and it results to,
mulo 19:32:06-> python test.py
c1 193 Á
7c 124 |
e1 225 á
86 134
ab 171 «
94 148
ee 238 î
b0 176 °
de 222 Þ
8a 138
e3 227 ã
b5 181 µ
b7 183 ·
51 81 Q
a7 167 §
c4 196 Ä
d8 216 Ø
e9 233 é
ed 237 í
eb 235 ë
which is not even close, and yes, I know that it's not the same code.  So, 
the question is, how can I make this java (byte) call in python? so that the 
result would be the right one, "[EMAIL PROTECTED]"

Thanks.
josé

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


Re: PHP Embedded In Python

2005-02-08 Thread Do Re Mi chel La Si Do
And :

http://lesuisse.net/pyphp-0.1.tgz

?


@-salutations
-- 
Michel Claveau


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


Re: Big development in the GUI realm

2005-02-08 Thread Robert Kern
Kent Johnson wrote:
Fredrik Lundh wrote:
Robert Kern wrote:

Fair enough. The only time I've seen it in dead-tree print was in 
Heinlein's _Time Enough For Love_, unattributed to anyone else.

Amazon.com "search inside the book" finds no hits for "malice" in this 
book.
http://www.amazon.com/gp/reader/0441810764/102-7636110-6481700?v=search-inside&keywords=malice 
Hooray for technology!
In that case, I have no idea why I thought it was from Heinlein. The 
similar quote[1] that *is* from Heinlein, but an entirely different 
formulation, is from "Logic of Empire", which I know I have not read.

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


Re: Choosing the right parser for parsing C headers

2005-02-08 Thread John Machin

Jean  de Largentaye wrote:
> Hi,
>
> I need to parse a subset of C (a header file), and generate some unit
> tests for the functions listed in it. I thus need to parse the code,
> then rewrite function calls with wrong parameters. What I call
"shaking
> the broken tree" :)

I was thinking "cdecl", and googling brought up this:

http://arrowtheory.com/software/python/

Another option, which I used recently when I had to parse a whole bunch
of Oracle 'create table' scripts [with semi-structured comments which
had to be mined for additional info]: write a recursive descent parser
-- but maybe the grammar of C function declarations is too complicated
for this.

HTH,
John

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


Re: What's wrong with `is not None`?

2005-02-08 Thread Leif K-Brooks
Frans Englich wrote:
runner.py:587: Using is not None, may not always work
It's a PyChecker bug relating to None being a constant in 2.4: 
.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Loop in list.

2005-02-08 Thread Roy Smith
Jim <[EMAIL PROTECTED]> wrote:
> Thanks for the help.  Python is somewhat mysterious to an old fortan
> programer.

You might appreciate http://www.python.org/doc/Humor.html#habits
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Big development in the GUI realm

2005-02-08 Thread John Lenton
On Tue, Feb 08, 2005 at 09:19:58PM -0200, Gabriel B. wrote:
> > However, imagine simple situation:
> > 1. I write proprietary program with open plugin api. I even make the api
> > itself public domain. Program works by itself, does not contain any
> > GPL-ed code.
> 
> No need to continue. You write something that uses a plugin, Eolas
> sues you. Don't have to mind about trolltech

not if you live in a sane country.

-- 
John Lenton ([EMAIL PROTECTED]) -- Random fortune:
Preserve wildlife -- pickle a squirrel today!


signature.asc
Description: Digital signature
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Big development in the GUI realm

2005-02-08 Thread Gabriel B.
> However, imagine simple situation:
> 1. I write proprietary program with open plugin api. I even make the api
> itself public domain. Program works by itself, does not contain any
> GPL-ed code.

No need to continue. You write something that uses a plugin, Eolas
sues you. Don't have to mind about trolltech
-- 
http://mail.python.org/mailman/listinfo/python-list


What's wrong with `is not None`?

2005-02-08 Thread Frans Englich

That's what PyChecker tells me, at least. 

A line of:

if testReport is not None:

results in:

runner.py:587: Using is not None, may not always work

In what circumstances can `is not None` fail? How and why does it fail?

What is the equivalent expression which is more secure; `!= None`?


Cheers,

Frans

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


Downloadable python-dev archive February 2005 contains only one mail?

2005-02-08 Thread Dennis Benzinger
Hi!

I just downloaded the archive of the python-dev mailing list for
February 2005 from

http://mail.python.org/pipermail/python-dev/2005-February.txt.gz

and there is only one mail in it.

Did anyone have this problem, too?

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


Re: Python versus Perl ?

2005-02-08 Thread Adam DePrince
On Tue, 2005-02-08 at 22:44, Caleb Hattingh wrote:
> Hi m
> 
> Speed is a contentious issue here.  Point is, if you really need raw  
> speed, why stop only at Perl and Python?  There are plenty of statically  
> compiled languages that will produce native binaries.
> 
> The relative difference in speed between Perl and Python, whatever it is,  
> is completely washed out by the enormous jump using, say, C for example  
> [please, everyone else, I am aware of all the mitigating circumstances  
> regarding, e.g. parts of the standard library written in C, etc.  That is  
> not my point.]

I think the expression you seek is "comparing virtue among whores."  

Now we can all acknowledge that there is a spectrum in the programmer
time vs machine time trade-off.  (Voice reader users: Please forgive my
ASCII art ... imagine a data set that loosely fits a linear relationship
with a negative slope.)

ASCII art start 

 +
M|*
A|  *  *
C|*
H| * "STUPID"
I|   * *
N|  *
E|  *
 | *
C| * *
O| "Holy *
S|  Grail"   *
T|  *
 0- +
   PROGRAMMER COST

ASCII art stop

This metric is actually in two dimensions, but we usually consider it in
one dimension with High Machine cost and low programmer cost at one
extreme and low machine cost and high programmer cost at the other
extreme.

ASCII art start

High Machine  <---> High Programmer Cost

ASCII art stop

because there is a high inverse correlation between programmer and
machine costs.  Only a fool would use a programing language in the
"stupid" area of the above chart (both costs high).  Likewise, nobody
gets to use the language that does not exist in the "Holy Grail" area of
the chart (both costs low.)

Both Python and Perl are way up in the upper left ( machine cost high,
programmer cost low) of my little chart.   Perl has much magic that
drives up its programmer cost.  Not by much in the know, but by enough
that I would consider it to have a slightly higher programmer cost than
Python.  If Perl code executes a bit faster, then fine, all I can say is
"that's nice."  If machine costs were an issue I'd recode in vhdl and
compile to silicone.

Of the topic I want to address,  you can entirely circumvent those
issues by coding in C and using the Python C-API instead of strcmp and
friends.



> 
> A Good Reason for thinking along these lines (Perl/Python) is more  
> something like speed and reliability of development.  Another one is  
> maintaintability.  I must confess that I know pretty much nothing about  
> Perl, so I can't comment about that.  My opinion about Python is that it  
> is very, very good for these things.
> 
> The problem domains in which I do most of my work (chemical process  
> modelling and simulation) really do require speed.  That's why I mostly  
> use Delphi (i.e. reasonably fast code) at work.   I believe I know when  
> speed is and is not an issue, and (by far) most of the time, my experience  
> is that it is *not*.  So I use Delphi for numerical code and python for  
> everything else.

Why don't you use C for the numerical work?  Then you can do your number
crunching within a c-based python module.  Have your cake and ... 

> 
> You really will have to convince people here that execution speed is a  
> real issue for your programming task (in order to continue this  
> discussion).  Otherwise the debate will go south real quick.

Not only most speed be an issue, but the economics must be such that any
alternative is better than throwing more hardware at the problem.

Adam DePrince 


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


Re: trolltech comitment

2005-02-08 Thread Leif K-Brooks
Gabriel B. wrote:
What it they revoke this license [on Qt]?
They can't. It's the GPL.
what it windows
longhorn has a non-backwardcompatible GDI API and a newer version of
Qt must be used, and that newer version does not have a gpl version?
What if Wx does that? What if Tk does? What if GTK does?
If i'm going to commit to something, i like to know the lengths the
other side gona commit also.
They have: they're licensing Qt to you under an _irrevocable_ license, 
the GPL. If that's not a commitment, nothing is.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Confused with methods

2005-02-08 Thread Diez B. Roggisch
> No python is not consistent and your continuous repetion doesn't
> make it so. To illustrate, here the following code:
> 
> class A:
>   l = []
>   def f(): pass
> 
> a = A()
> print a.l is A.l
> print a.f is A.f
> 
> which produces:
> 
> True
> False

Thats only inconsistent from your POV because you refuse to accept that the
scope of a function definition does matter. And as usual its a topic of
totally unrelevant practical impact and an expression of your strangely
deeprooted desire to nitpick at such unrelevant details. 

Why don't you pick something that really bothers people and see if your
skills (that I'm sure exist) can be of use there?

--

Regards,

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


A ListComp that maintains its own state (Was: Re: turing machine in an LC)

2005-02-08 Thread Michael Spencer

Jeremy Bowers <[EMAIL PROTECTED]> writes:

On Tue, 08 Feb 2005 17:36:19 +0100, Bernhard Herzog wrote:
Nick Vargish <[EMAIL PROTECTED]> writes:
"Xah Lee" <[EMAIL PROTECTED]> writes:
is it possible to write python code without any indentation?
Not if Turing-completeness is something you desire.

Bernhard Herzog wrote:

a Turing Machine in one line plus assignments - nice!  Turns out that pypy is 
more
verbose than strictly necessary ;-)
...
BTW, I realized that it is indeed possible for a LC to maintain its own state 
without being passed an external mutable.  The trick is to use itertools.repeat 
to return the same mutable object on each iteration.

So, here's factorial in one line:
# state refers to list of state history - it is initialized to [1]
# on any iteration, the previous state is in state[-1]
# the expression also uses the trick of list.append() => None
# to both update the state, and return the last state
>>> [state.append(state[-1] * symbol) or state[-1]
... for symbol, state in it.izip(range(1,10),it.repeat([1]))
... ]
[1, 2, 6, 24, 120, 720, 5040, 40320, 362880]
>>>
Now, who was claiming that 'reduce' was opaque?
Michael ;-)
--
http://mail.python.org/mailman/listinfo/python-list


Re: Loop in list.

2005-02-08 Thread Fredrik Lundh
Stephen Thorne wrote:

>> '>>> a = [i*2*b for i in range(3) for b in range(4)]
>> '>>> a
>> [0, 0, 0, 0, 0, 2, 4, 6, 0, 4, 8, 12]
>>
>> Might take you a while to correlate the answer with the loop, but you
>> should be able to see after a while that this nesting is the same as
>>
>> '>>> a = []
>> '>>> for b in range(4):
>> '>>> for i in range(3):
>> '>>> a.append(i*2*b)
>
> There is a subtle error in this explanation.

if you run the example, you'll notice that it's not so subtle.  read on.

> The equivilence actually looks like:
>
> '> a = []
> '> l1 = range(4)
> '> l2 = range(3)
> '> for b in l1:
> '> for i in l2:
> '> a.append(i*2*b)

really?

def myrange(x):
  print "RANGE", x
  return range(x)

print [i*2*b for i in myrange(3) for b in myrange(4)]

a = []
for b in myrange(4):
  for i in myrange(3):
a.append(i*2*b)
print a

a = []
l1 = myrange(4)
l2 = myrange(3)
for b in l1:
  for i in l2:
a.append(i*2*b)
print a

prints

RANGE 3
RANGE 4
RANGE 4
RANGE 4
[0, 0, 0, 0, 0, 2, 4, 6, 0, 4, 8, 12]
RANGE 4
RANGE 3
RANGE 3
RANGE 3
RANGE 3
[0, 0, 0, 0, 2, 4, 0, 4, 8, 0, 6, 12]
RANGE 4
RANGE 3
[0, 0, 0, 0, 2, 4, 0, 4, 8, 0, 6, 12]

(to translate a list comprehension to nested statements, remove
the result expression, insert colons and newlines between the for/if
statement parts, and put the append(result expression) part inside
the innermost statement)

 



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


Re: variable declaration

2005-02-08 Thread Caleb Hattingh
Jeff
I fully agree.  As I stated in a message to alexander, it is quick and  
easy even to write a simple project-specific tool for checking that only  
allowed variable names exist in all the project files.

Compared to having to work with tons of effectively useless variable  
declarations forever (perhaps even only in other peoples code who decided  
to use the "option"), it is not much to ask (I work in pascal a lot - I  
know all about tons and tons of declarations).

thx
Caleb
You can also get all places where said variable exists by using grep, or  
your editor's search feature.  I don't see how a var declaration gains  
you anything over 'grep PowerOfGenerator *.py' ...

Jeff Shannon
Technician/Programmer
Credit International

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


Re: PHP Embedded In Python

2005-02-08 Thread jdonnell
Well it depends on how php is installed. Is it a linux system? Do you
know how to run a php script from the command line?

Once you have the php script running from the command line then you
need to use the os module in python. There are a couple different ways
to do it. Read the following for more info.
http://docs.python.org/lib/os-process.html
http://docs.python.org/lib/os-newstreams.html#os-newstreams

simple example:

import os
handle = os.popen('path/to/yourScript.php', 'r')
print handle.read()

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


Re: Basic file operation questions

2005-02-08 Thread Grant Edwards
On 2005-02-08, Marc Huffnagle <[EMAIL PROTECTED]> wrote:

>>>for line in file(...):
>>>   # do stuff

> When you read a file with that method, is there an implied close() call 
> on the file?  I assume there is, but how is that handled?

The file will be closed when the the file object is deleted by
the garbage collection algorithm.  That will happen sometime
after the for loop exits and before the program exits.  In
normal C-Python I believe it happens immediately after the for
loop exits.  However, that behavior is not guaranteed by the
language spec.

-- 
Grant Edwards   grante Yow!  Now that I have my
  at   "APPLE", I comprehend COST
   visi.comACCOUNTING!!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Loop in list.

2005-02-08 Thread Caleb Hattingh
Stephen
You're gonna have to help me here.what is the effective difference?
Thanks
Caleb
'>>> a = []
'>>> for b in range(4):
'>>> for i in range(3):
'>>> a.append(i*2*b)
There is a subtle error in this explanation. The equivilence actually
looks like:
'> a = []
'> l1 = range(4)
'> l2 = range(3)
'> for b in l1:
'> for i in l2:
'> a.append(i*2*b)
Stephen
--
http://mail.python.org/mailman/listinfo/python-list


Re: python code with indention

2005-02-08 Thread Steve Holden
Timo Virkkala wrote:
Xah Lee wrote:
is it possible to write python code without any indentation?

1) Why in the name of Xah Lee would you even want to?
2) If you need to ask questions this simple, are you sure you are the 
right person to write tutorials?
3) Do you even read the replies you get?

Surely by now it's obvious that Xah Lee is an output-only device. Please 
do not feed the troll.

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


Re: variable declaration

2005-02-08 Thread Caleb Hattingh
Alexander
  PowerOfGenerator=TakeFromSensor()
  if PowerOfGenerator>xxx:

  RecalcPower(PowerOfGenerator)
  PutToTheDatabase(PowerOfGenerator)
  
Here, python will not help you. The worst thing is that in such  
calculations
you often receive plausible results.
(I think PyChecker has come up before, but...) If you like, you could make  
a text-file index of all the variable names allowed in your program, and  
parse all the python code to ensure that only those variable names are  
used.  I believe this would
a) solve your problem
b) require less than a morning's work
c) not force everyone else to have to deal with variable declarations that  
will be only an annoyance 95% percent of the time.

Is there a specific reason you want this added to the *language* itself?
Thanks
Caleb
--
http://mail.python.org/mailman/listinfo/python-list


Re: overwriting method in baseclass

2005-02-08 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Harald Massa
wrote:

> Thanks for that recommendation, I really do use subversion for some time. 
> But how can I use it to solve this problem? I do changes to the common 
> baseclass which is OUTSIDE my development. I quite correctly assume that 
> the developers of the classlib also use Subversion, alas, having no public 
> access.
> 
> So HOW can SVN be of any use for THIS prob?

Take a look at the Subversion documentation (the "book") and search for
`Vendor branches`.

First paragraph of that section:

  As is especially the case when developing software, the data that you
  maintain under version control is often closely related to, or perhaps
  dependent upon, someone else's data. Generally, the needs of your
  project will dictate that you stay as up-to-date as possible with the
  data provided by that external entity without sacrificing the stability
  of your own project. [...]

The section deals specifically with the situation how to manage 3rd party
source code with subversion which you want to update from time to time and
even apply some modifications.

Ciao,
Marc 'BlackJack' Rintsch


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


Re: Big development in the GUI realm

2005-02-08 Thread Jeff Shannon
Maciej Mróz wrote:
However, imagine simple situation:
1. I write proprietary program with open plugin api. I even make the api 
itself public domain. Program works by itself, does not contain any 
GPL-ed code.
2. Later someone writes plugin using the api (which is public domain so 
is GPL compatible), plugin gets loaded into my software, significantly 
affecting its functionality (UI, operations, file formats, whatever).
3. Someone downloads the plugin and loads it into my program
I believe that in this case, the key is *distribution*.
You are not violating the GPL, because you are not distributing a 
program that is derived (according to the GPL's definition of derived) 
from GPL code.

The plugin author *is* distributing GPL-derived code, but is doing so 
under a GPL license.  That's fine too.

The end user is now linking (dynamically) GPL code with your 
proprietary code.  However, he is *not* distributing the linked 
assemblage.  This is allowed under the GPL; its terms only apply when 
distribution takes place.

If the end user is a repackager, and then turns around and distributes 
both sets of code together, then that would (potentially) violate GPL 
terms.  But as long as they're not distributed together, then it's 
okay.  This should even extend to distributing a basic (proprietary) 
plugin and including a document describing where & how to get the 
more-featureful GPL replacement plugin.  (Distributing both programs 
as separate packages on a single installation medium would be a tricky 
edge case.  I suspect it *could* be done in a GPL-acceptable way, but 
one would need to take care about it.)

Of course, this is only my own personal interpretation and opinion -- 
IANAL, TINLA, YMMV, etc, etc.

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


Re: Loop in list.

2005-02-08 Thread Bruno Desthuilliers
Jim a écrit :
Where did this type of structure come from:
mat = ['a' for i in range(3)]?
This will produce a list of three elements but
I don't see reference for it in any of the books.
Now everyone told you *what* is it, I'll (very very dumbly) answer the 
question : this syntax comes from Haskell.

HTH !-)
Bruno
--
http://mail.python.org/mailman/listinfo/python-list


Re: Basic file operation questions

2005-02-08 Thread Caleb Hattingh
Marc
I don't know how it is handled, but I expect also that there is an implied  
close().

thanks
Caleb
When you read a file with that method, is there an implied close() call  
on the file?  I assume there is, but how is that handled?

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


Re: Python versus Perl ?

2005-02-08 Thread m

You really will have to convince people here that execution speed is a
real issue for your programming task (in order to continue this  
discussion).  Otherwise the debate will go south real quick.

Keep well
Caleb
On Tue, 08 Feb 2005 12:17:05 -0600, m <[EMAIL PROTECTED]> wrote:
Courageous wrote:

If Python is better than Perl, I'm curious how really significant
those advantages are ?

speedwise, i think perl is faster than python and python performed 
the  slowest as shown in http://www.flat222.org/mac/bench/

i have nothing else to add. thanks caleb!
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python versus Perl ?

2005-02-08 Thread m
Irmen de Jong wrote:
m wrote:

Why do you care?
Have you read http://www.python.org/moin/PythonSpeed ?
--Irmen
i had not read it. thanks for pointing it out!
--
http://mail.python.org/mailman/listinfo/python-list


Re: Choosing the right parser for parsing C headers

2005-02-08 Thread Caleb Hattingh
Jean, Paddy
I use "pym" to extract bits of pascal out of delphi code for documentation  
purposes.  You have to add some stuff to the delphi code (in your case, C  
header), but these are added within comment blocks, and the interesting  
thing is that you add python code(!) as a kind of dynamic markup which pym  
executes while parsing the file.

In other words, you can write python code within a comment block in your  
C-header to generate unit-tests into other files, and get that code  
executed with pym.

Keep well
Caleb
On Tue, 08 Feb 2005 19:58:33 GMT, Paddy McCarthy <[EMAIL PROTECTED]>  
wrote:

Jean de Largentaye wrote:
Hi,
 I need to parse a subset of C (a header file), and generate some unit
tests for the functions listed in it. I thus need to parse the code,
then rewrite function calls with wrong parameters. What I call "shaking
the broken tree" :)
I chose to make my UT-generator in Python 2.4. However, I am now
encountering problems in choosing the right parser for the job. I
struggle in choosing between the inappropriate, the out-of-date, the
alpha, or the too-big-for-the task...
Why not see if the output from a tags file generator such as ctags or  
etags will do what you want.

I often find that some simpler tools do 95% of the work and it is easier  
to treat the other five percent as broken-input.

try http://ctags.sourceforge.net/
- Paddy.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Loop in list.

2005-02-08 Thread Stephen Thorne
On Tue, 08 Feb 2005 23:07:09 -0500, Caleb Hattingh <[EMAIL PROTECTED]> wrote:
> '>>> a = [i*2*b for i in range(3) for b in range(4)]
> '>>> a
> [0, 0, 0, 0, 0, 2, 4, 6, 0, 4, 8, 12]
> 
> Might take you a while to correlate the answer with the loop, but you
> should be able to see after a while that this nesting is the same as
> 
> '>>> a = []
> '>>> for b in range(4):
> '>>> for i in range(3):
> '>>> a.append(i*2*b)

There is a subtle error in this explanation. The equivilence actually
looks like:

'> a = []
'> l1 = range(4)
'> l2 = range(3)
'> for b in l1:
'> for i in l2:
'> a.append(i*2*b)

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


Re: python-2.4.msi installation issue

2005-02-08 Thread "Martin v. Löwis"
[EMAIL PROTECTED] wrote:
My question is this: how do I determine what the error was that caused
the installation process to end prematurely?
Please run
msiexec /i python-2.4.msi /l*v python.log
and post the resulting python.log as a bug report on
sf.net/projects/python.
In most such cases, upgrading VisualBasic helped, see
http://www.python.org/2.4/bugs.html
Regards,
Martin
--
http://mail.python.org/mailman/listinfo/python-list


Re: Loop in list.

2005-02-08 Thread Caleb Hattingh
Jim
Someone on this list (SteveB) helped me quite a bit with a list  
comprehension on a recent thread.  Roy said it can be hard to read, and I  
agree in part because I always thought they were hard to read, when in  
actual fact I had just never bothered to learn properly.  Here is a  
mini-tutorial:

e.g. 1: The theory
'>>> a = [  for i in  ]
item2 is iterable (like "range()" in your example)
item1 is the thing that is going to fill up the resulting list, and item1  
is evaluated at each step of the "for" loop.

This is the same as
'>>> a = []
'>>> for i in :
'>>> a.append()
e.g. 2: A real example
'>>> a = [i*2 for i in range(3)]
'>>> a
[0, 2, 4]
so "i*2" gets evaluated for each step in the "for" loop.  The values of  
"i" at each step are [0,1,2], according to how "range" works, so "i*2" is  
what you end up with in the resulting list.

e.g. 3: They can be nested
'>>> a = [i*2*b for i in range(3) for b in range(4)]
'>>> a
[0, 0, 0, 0, 0, 2, 4, 6, 0, 4, 8, 12]
Might take you a while to correlate the answer with the loop, but you  
should be able to see after a while that this nesting is the same as

'>>> a = []
'>>> for b in range(4):
'>>> for i in range(3):
'>>> a.append(i*2*b)
keep well
Caleb
--
http://mail.python.org/mailman/listinfo/python-list


Re: Printing Filenames with non-Ascii-Characters

2005-02-08 Thread "Martin v. Löwis"
Marian Aldenhövel wrote:
 > If you're printing to the console, modern Pythons will try to guess the
 > console's encoding (e.g. cp850).
But it seems to have quessed wrong. I don't blame it, I would not know of
any way to reliably figure out this setting.
It's actually very easy. Python invokes GetConsoleOutputCP() to find out
the encoding of the console (if the output is to a console, as
determined by isatty()).
My console can print the filenames in question fine, I can verify that by
simple listing the directory, so it can display more than plain ascii.
The error message seems to indicate that ascii is used as target.
Yes, because that is the fallback.
So if I were to fix this in sity.py to configure whatever encoding is
actually used on my system, I could print() my filenames without explicitly
calling encode()?
Yes. However, you cannot put a reasonable value in there, because
different parts of your system use different encodings. In particular,
the console likely uses CP 850, whereas the rest of your system
likely uses CP 1252.
So wouldn't fixing site.py be the right thing to do? 
No. If they put CP850 into sitecustomize, Unicode in user interfaces
(menus etc) might be displayed as moji-bake, as the user interface
will likely assume CP1252, not CP850.
Regards,
Martin
--
http://mail.python.org/mailman/listinfo/python-list


Re: graph visualisation

2005-02-08 Thread cwmoad

Alexander Zatvornitskiy wrote:
> Hello, All!
>
> I need routines for visualization of graphs, like this for Matlab:
> ===
> You can visualize an arbitrary graph (such as one learned using the
structure
> learning routines) with Matlab code contributed by Ali Taylan Cemgil
from the
> University of Nijmegen. For static BNs, call it as follows:
>
> draw_graph(bnet.dag);
> ===
>
> Are there any packages with such ability? Also I need in drawing
plots of
> functions.
> 
> Alexander, [EMAIL PROTECTED]

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


Re: Printing Filenames with non-Ascii-Characters

2005-02-08 Thread "Martin v. Löwis"
Marian Aldenhövel wrote:
  dir = os.listdir(somepath)
  for d in dir:
 print d

The program fails for filenames that contain non-ascii characters.

  'ascii' codec can't encode characters in position 33-34:
I cannot reproduce this. On my system, all such file names print just
fine, in Python 2.3.4.
Are you using the Windows XP cmd.exe window to perform this experiment?
What (language) version of XP are you using?
What are your regional settings?
What is sys.stdout.encoding?
What is the result of locale.setlocale(locale.LC_ALL, "")?
What I specifically do not understand is why Python wants to interpret the
string as ASCII at all. Where is this setting hidden?
If this is in cmd.exe (or equivalent), Python
1. verifies that the output is indeed a terminal
2. if it is, determines what code page the terminal uses
3. tries to find a codec for this code page
4. if this fails, falls back to ASCII
In your case, step 4 must have happend. It's not clear to my why this
happened, unless you are using a Japanese version of XP (or some other
version for which Python does not have a codec).
I am running Python 2.3.4 on Windows XP and I want to run the program on
Debian sarge later.
In Linux, make sure that LANG is set to a value that allows Python to
infer the encoding of the terminal.
Regards,
Martin
--
http://mail.python.org/mailman/listinfo/python-list


Re: Basic file operation questions

2005-02-08 Thread Jeff Shannon
Marc Huffnagle wrote:
When you read a file with that method, is there an implied close() call 
on the file?  I assume there is, but how is that handled?

[...]
for line in file(...):
  # do stuff
As I understand it, the disk file will be closed when the file object 
is garbage collected.  In CPython, that will be as soon as there are 
no active references to the file; i.e., in the above case, it should 
happen as soon as the for loop finishes.  Jython uses Java's garbage 
collector, which is a bit less predictable, so the file may not be 
closed immediately.  It *will*, however, be closed during program 
shutdown if it hasn't happened before then.

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


Re: User Identification

2005-02-08 Thread Michael Ströder
Gerhard Haering wrote:
os.getuid() will give you the user id, but I don't know if Python has
methods to look up more information from that from /etc/passwd or
whereever from.
>>> import pwd,os
>>> pwd.getpwuid(os.getuid())
('michael', 'x', 1234, 100, 'Michael Str\xf6der', '/home/michael', 
'/bin/bash')
>>>

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


Re: python code with indention

2005-02-08 Thread Caleb Hattingh

is it possible to write python code without any indentation?
Xah

You can, of course, write a silly little inline script without
any control structures that will all line up at the left
margain. So what?
John Roth
I agree, John, I don't get it.  The vast majority of programmers (albiet  
from my limited perspective) indent their code anyway, whether required by  
the language or not.   This was one of the first features of Python I  
learned about that made me sit up and take notice -- here was a truly  
pragmatic design choice that actually benefitted the programmer (by not  
having to type all those delimiters).

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


Re: msvcp71.dll and Python 2.4 C++ extensions

2005-02-08 Thread "Martin v. Löwis"
Matthias Baas wrote:
I'm creating the installer via the distutils by calling "setup.py
bdist_wininst". How can I configure distutils to have it create an
installer that does the above things?
Ah, I see. Unfortunately, bdist_wininst is not capable of doing
a Windows logo compliant installation (with proper versioning checks,
shared dll reference count, etc) of a DLL. You will have to find
a different technology to distribute your application - or make sure
you copy the DLL in a place where it previously did not exist.
How should an installer check if a DLL is already present? 
It should check if the file exists. If it exists, it should check
the version number of the file (there are APIs for that available),
and if the language of the installed DLL differs from the language
of the package's DLL. If the new DLL is somehow "better" (newer
version, or same version, different language, and user requested
overwriting), it should replace the DLL.
> Are DLLs registered with Windows so I can query a database?
To some degree. If the software is uninstalled, the installer should
remove the file. If the file was already present at installation time,
removal may break other software. Therefor, there is a registry entry
for each path name that is a reference count, under
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SharedDLLs
If you expect that the file is already there, you need to use that
mechanism.
Or should the
installer search for the DLL in the directories specified in the PATH
variable and see if the DLL is there?
No. There is no problem at all to install the same DLL multiple times,
in different places. In fact, Microsoft discourages shared DLLs, and
recommends that each package should install its own copy.
Windows will look for a DLL in
- the directory of the EXE
- the current working directory
- system32
- windows
- PATH
In your case, putting the C++ DLL into the directory containing
python.exe might be sufficient. The safest thing, of course, is to
put the DLL into system32 - in which case you *have* to install it
shared.
"An application should use and redistribute msvcr71.dll, and it should
avoid placing a copy or using an existing copy of msvcr71.dll in the
system directory. Instead, the application should keep a copy of
msvcr71.dll in its application directory with the program executable."
Yes. This means to install it into the directory containing python.exe.
Unfortunately, this does not work if your extension is then used in
an embedded Python, e.g. one running as a COM object. In this case,
python.exe will not be the main executable, but, say, outlook.exe will
be. So Microsoft's recommendation to install the DLL into the EXE
directory is flawed for COM and other embedded cases. This is
precisely the reason why the Python installer installs both python24.dll
and msvcr71.dll into system32.
Well, yes, I know. But I don't see Python as a standalone application.
One of the great things about Python is that there are so many
extension modules for every kinds of purposes. So, making available
the C++ runtime would just pave the way for more of those extension
modules by making it easier to distribute binary packages that are
implemented in C++.
I think we agree that building and running such an extension is not
a problem - it just works.
Distributing such an extension is indeed a problem, as bdist_wininst
does not support this case properly.
I'll plan to write a bdist_msi one day, which should handle DLL
installation better as much of the magic required is built into
Windows Installer.
I was referring to the possibility that the DLL might get installed
several times at several different locations which would be a waste of
disk space. If there's only one file, then I agree with the above
(however, what happens if I uninstall one package and this package
removes the DLL even when there are other packages installed that
still require the DLL?).
The other packages will also have added to the shared reference counter.
Uninstalling will only DECREF the counter, and the file will be removed
only when the counter goes to zero.
For one smaller package I was compiling I solved the problem by
linking against the static versions of the C/C++ runtime. This will
also satisfy the "It-Should-Just-Work" constraint... :)  (however,
there still could be situations where this is not possible (the
sources might not be available, for example)).
You should make sure to use the DLL version of the C runtime. Otherwise,
you will be mixing multiple C runtimes (one that python24.dll links
with, and one linked statically into your extension); this might cause
troubles (such as memory leaks and crashes).
Regards,
Martin
--
http://mail.python.org/mailman/listinfo/python-list


Re: variable declaration

2005-02-08 Thread Jeff Shannon
Alexander Zatvornitskiy wrote:
Another example. Let say you have variable PowerOfGenerator in your program.
But, it is only active power, so you have to (1)rename PowerOfGenerator to
ActivePowerOfGenerator, (2)calculate ReactivePowerOfGenerator, and (3)calculate
new PowerOfGenerator by formula
  PowerOfGenerator=sqrt(ReactivePowerOfGenerator**2+ActivePowerOfGenerator**2)
With var declarations, on step (1) you just rename PowerOfGenerator to
ActivePowerOfGenerator in the place of its declaration, and compile your
program. Compiler will show you all places where you have to rename variables.
After it, on step (3) you can safely and peacefully add new PowerOfGenerator
variable.
You can also get all places where said variable exists by using grep, 
or your editor's search feature.  I don't see how a var declaration 
gains you anything over 'grep PowerOfGenerator *.py' ...

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


Re: variable declaration

2005-02-08 Thread Thomas Bartkus
"Alexander Zatvornitskiy"
<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]

> The worst thing is that in such calculations you often receive plausible
results.


Exactly so!

An ordinary spelling error gets promoted to a logic error that is damn
difficult to detect, let alone trace!  Before one even tries, it behooves
one to spell check his variables. An additional step that counters Python's
procedural simplicity.

"i" comes before "e" except after "c" OR whenever I make a typo!
Thomas Bartkus


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


Re: Python versus Perl ?

2005-02-08 Thread Caleb Hattingh
Hi m
Speed is a contentious issue here.  Point is, if you really need raw  
speed, why stop only at Perl and Python?  There are plenty of statically  
compiled languages that will produce native binaries.

The relative difference in speed between Perl and Python, whatever it is,  
is completely washed out by the enormous jump using, say, C for example  
[please, everyone else, I am aware of all the mitigating circumstances  
regarding, e.g. parts of the standard library written in C, etc.  That is  
not my point.]

A Good Reason for thinking along these lines (Perl/Python) is more  
something like speed and reliability of development.  Another one is  
maintaintability.  I must confess that I know pretty much nothing about  
Perl, so I can't comment about that.  My opinion about Python is that it  
is very, very good for these things.

The problem domains in which I do most of my work (chemical process  
modelling and simulation) really do require speed.  That's why I mostly  
use Delphi (i.e. reasonably fast code) at work.   I believe I know when  
speed is and is not an issue, and (by far) most of the time, my experience  
is that it is *not*.  So I use Delphi for numerical code and python for  
everything else.

You really will have to convince people here that execution speed is a  
real issue for your programming task (in order to continue this  
discussion).  Otherwise the debate will go south real quick.

Keep well
Caleb
On Tue, 08 Feb 2005 12:17:05 -0600, m <[EMAIL PROTECTED]> wrote:
Courageous wrote:

If Python is better than Perl, I'm curious how really significant
those advantages are ?
speedwise, i think perl is faster than python and python performed the  
slowest as shown in http://www.flat222.org/mac/bench/
--
http://mail.python.org/mailman/listinfo/python-list


Reportlab and Barcodes

2005-02-08 Thread Josh
Hi All,

I need someone to explain to me how to output a Code39 barcode to a
Reportlab PDF. As far as I can tell, there is no means to do this with
the Canvas object, and the demo that is included with the libraries is
using the platypus Frame to place the barcode on the form. I do not
wish to use this method. I'm guessing that it needs to be placed on the
form as some type of graphic. It's obviously not going to work with the
drawText method. Any ideas? 

Thanks

Josh

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


Re: Pypy - Which C modules still need converting to py?

2005-02-08 Thread Jan Dries
Caleb Hattingh wrote:
Anyone have that page  
ref handy listing the C modules that the pypy team need translated into  
python?
http://codespeak.net/pypy/index.cgi?doc/cmodules.html
Regards,
Jan
--
http://mail.python.org/mailman/listinfo/python-list


Re: Is Python as capable as Perl for sysadmin work?

2005-02-08 Thread Peter Maas
Jeff Epler schrieb:
Unlike Perl, Python implements only a *finite turning machine* model of
computation.  An easy way to see this limitation is in the following
code:
>>> 1.0 / 10.0
0.10001
In an infinite Turning machine, there would be an unbounded number of
zeros before the second 1, giving the exact result, not a numeric
approximation.
Boy, you are cheating us Wake up, this isn't April 1st! :)))
--
---
Peter Maas,  M+R Infosysteme,  D-52070 Aachen,  Tel +49-241-93878-0
E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64')
---
--
http://mail.python.org/mailman/listinfo/python-list


Pypy - Which C modules still need converting to py?

2005-02-08 Thread Caleb Hattingh
Hi all
I saw it on a webpage a few days ago, can't seem to find it again.  Tried  
a google search for

"pypy needed translate C modules"
but that didn't turn up what I was looking for.   Anyone have that page  
ref handy listing the C modules that the pypy team need translated into  
python?

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


Re: Is Python as capable as Perl for sysadmin work?

2005-02-08 Thread Peter Maas
Jeff Epler schrieb:
There's another little-known fact about Python:  No string is permitted
to end with a backslash! 
Sure you meant string literals. But that is wrong, too:
>>> a = '\\'
>>> print a
\
A Python string mustn't end with an *odd* number of backslashes. Other-
wise a literal using backslash escapes like 'don\'t do that' couldn't
be parsed.
Now, this may not bother Unix sysadmins, but the honest truth is that
you'll be administrating Windows systems, too, anywhere you work!
This is no problem, thanks to os.path.join() ;)
Well, if you ever
have to threaten Python, just keep in mind that '... or die' just plain
won't work.  You have to suggest that it 'try ... except', which is
really offensive.  If I want to beg my computer to run programs, I know
where to find Intercal with its "PLEASE" and "DO PLEASE" constructions.
Sysadmin work with Intercal? Go ahead! ;) But what's wrong with a
protecting try .. except block vs. "... or die" for every command
to be protected?
--
---
Peter Maas,  M+R Infosysteme,  D-52070 Aachen,  Tel +49-241-93878-0
E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64')
---
--
http://mail.python.org/mailman/listinfo/python-list


Re: turing machine in an LC

2005-02-08 Thread Jeremy Bowers
On Tue, 08 Feb 2005 20:47:06 +0100, Bernhard Herzog wrote:
> [x for L in [[[initial_state, 0]]]
>for state, pos in L
>if state is not None
>   and (L.append([M[state][T.get(pos, 0)][2],
>  pos + M[state][T.get(pos, 0)][1]])
>or T.__setitem__(pos, M[state][T.get(pos, 0)][0]))]
> return T

I stand corrected!

Thanks for posting it; I wasn't going to ask anyone to produce one, but if
you had one lying around, that's great.

Nice job!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python versus Perl ?

2005-02-08 Thread Reinhold Birkenfeld
Fredrik Lundh wrote:
> m" <[EMAIL PROTECTED]> wrote:
> 
If Python is better than Perl, I'm curious how really significant
those advantages are ?
>>
>> speedwise, i think perl is faster than python and python performed the 
>> slowest as shown in 
>> http://www.flat222.org/mac/bench/
> 
> if you use Python mostly to write empty loops, your programming license
> should be revoked.  the benchmark author seems to have realized that, as
> can be seen from the "it's dead" paragraph at the top of the page, which
> makes me wonder why you posted this link...

Especially when you read

"""
I found the performance of Python for these benchmarks really surprising
as it is at odds to my everyday experience.
"""

you will seriously think about the benchmark's significance.

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


Re: string issue

2005-02-08 Thread Reinhold Birkenfeld
Alex Martelli wrote:
> Reinhold Birkenfeld <[EMAIL PROTECTED]> wrote:
> 
>> Alex Martelli wrote:
>> 
>> > So, *WHAT ON EARTH* could possibly
>> > make this weird 'x[:]' form preferable to 'x*1'?!  It's MUCH more
>> > obvious that the second one returns an independent, separate object
>> > initially equal to x
>> 
>> .>> x = 2
>> .>> y = x*1
>> .>> x is y
>> True
>> .>>
>> 
>> just-kidding-ly yours,
> 
> You're just snipping a crucial side-observation which I had put in
> exactly to avert such irrelevant diversions:
>
>> whenever it
>> matters -- i.e., whenever x is mutable.
> 
> Immutable types are allowed to collapse any two equal but "distinct"
> objects into one identity -- that's always the case, I acknowledged that
> in my sentence which I just quoted and which you had failed to quote
> again, and I don't see what's funny in this procedure and the time it's
> wasting, for me and for every reader of this group, now and in the
> future from archives.

Well, I overread your side-observation (can happen if you don't have too
much time and are not accustomed to flying over English text) and,
though I sensed that it was bad, posted my little joke.

> I'm sure that by selectively quoting just some of your words and
> artfully omitting others I could ``make" you say, not just slightly
> imprecise things, but utter and total idiocies.  So?  What's the point
> of this "kidding"?  Next time, why don't you just omit, for example, a
> "not", when you quote me, so as to make it appear that I was saying
> exactly the reverse of what I was obviously saying?

Well, snipping single paragraphs is different from snipping words out of
them.

Sorry. Didn't mean to drive you insane -- your posts are of use, so clpy
(include me) need you in the future.

> I guess it must be time for me to go away from this group again, if my
> time on it is to me spent repeating over and over all sorts of asides
> which people "just kidding" carefully avoid quoting from my posts,
> apparently in order to make believe they caught me in anything less than
> perfect accuracy.  Cheez -- I HAVE been guilty of less than perfect
> accuracy in the past (even of outright errors), but not THIS time (if
> one has the common decency to look at ALL the words I posted, rather
> than a careful selection thereof), so I completely fail to see how you
> thought this "kidding" could be fun.

This is the hot Italian temper, I suppose ;) Of course you were right,
and I'm glad to see your posts of today.

> OK, I'm off.  Have a nice life.

Thanks, I'll do.

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


Re: python code with indention

2005-02-08 Thread Timo Virkkala
Xah Lee wrote:
is it possible to write python code without any indentation?
1) Why in the name of Xah Lee would you even want to?
2) If you need to ask questions this simple, are you sure you are the right 
person to write tutorials?
3) Do you even read the replies you get?

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


Re: newbie wants to compile python list of filenames in selected directories

2005-02-08 Thread anthonyberet
M.E.Farmer wrote:
anthonyberet wrote:
Hi, I am new at Python, and very rusty at the one language I was good

at, which was BASIC.
I want to write a script to compare filenames in chosen directories,
on
windows machines. Ideally it would compose a list of strings of all
the
filenames in the directories, and those directories would be chosable
by
the user of the script.
I am quite happy to do my own legwork on this , I realise it is
simple
stuff, but can anyone point me in the right direction to start?
Thanks

Cool! I like your attitude ;)
Others have given you a good start with os. In case you don't know os
has a great many path manipulation methods. Always try to use them so
you can insulate yourself from cross platform path nightmares.
A few of the highlights are:
### split a path
py> parts = os.path.split(r'c:\windows\media\ding.wav')
py> print parts
('c:\\windows\\media', 'ding.wav')
### join a path and part and do it right on any platform
py> path = os.path.join('c:\\windows\\media', 'ding.wav')
'c:\\windows\\media\\ding.wav'
### get basename of the file
py> base = os.path.basename('c:\\windows\\media\\ding.wav')
py> print base
'ding.wav'
Plus many more, be sure to study the os module if you are doing any
path manipulations.
Ok and now for something sorta different( alright, I was really bored )
. def glob_dir(dir):
. """Return a list of *.py* (.py, .pyc, .pyo, .pyw)
.files from a given directory.
. """
. import glob, os
. # Get a list of files that match *.py*
. GLOB_PATTERN = os.path.join(dir, "*.[p][y]*")
. pathlist = glob.glob(GLOB_PATTERN)
. return pathlist
.
. def list_dir(dir):
. ''' Another way to filter a dir '''
. import os
. pathlist = os.listdir(dir)
. # Now filter out all but py and pyw
. filterlist = [x for x in pathlist
.if x.endswith('.py')
.or x.endswith('.pyw')]
.return filterlist
hth,
Thanks to everyone who responded - I feel on my way now, just being able 
to tap 'os python' and 'lisdir python' into Google has netted me plenty 
of reading material - but I would have taken a long time to find that 
out without your tips!
I will surely come back, but not until I get I get stuck :)
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python versus Perl ?

2005-02-08 Thread Irmen de Jong
m wrote:
Fredrik Lundh wrote:
if you use Python mostly to write empty loops, your programming license
should be revoked.  the benchmark author seems to have realized that, as
can be seen from the "it's dead" paragraph at the top of the page, which
makes me wonder why you posted this link...
 

i was trying to decide whether i needed perl or python for some work 
that i had to get done and was seeing which was faster. and came across 
this link which i tht was pertinent. is python as fast as perl for the 
nonempty loops that the author wrote?
Why do you care?
Have you read http://www.python.org/moin/PythonSpeed ?
--Irmen
--
http://mail.python.org/mailman/listinfo/python-list


Re: Is Python as capable as Perl for sysadmin work?

2005-02-08 Thread Paddy McCarthy
Jeff Epler wrote:
No.
Unlike Perl, Python implements only a *finite turning machine* model of
computation.  An easy way to see this limitation is in the following
code:
>>> 1.0 / 10.0
0.10001
<>
Jeff
Nice,
Made my evening :-)
- Pad.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Big development in the GUI realm

2005-02-08 Thread Tim Churches
Fredrik Lundh wrote:
Tim Churches wrote:
 

except that if *you* set things up so the code is combined when run, *you* are
copying, distributing, and/or modifying the program in order to mix, include 
and/or
combine your work with the GPL:ed work.
if you leave all that to the user, you're clear.
 

Yes, that is what I, and others, have been saying, and doing, all along. Our Mozilla Public 
Licensed Python application imports (but contains no code from) a GPLed third-party Python module 
at runtime, but we don't distribute that module, we just tell users to obtain it independently and 
install it on their systems.
   

does your program work (in any way) without this module?
 

Yes.
Tim C
--
http://mail.python.org/mailman/listinfo/python-list


Re: Choosing the right parser for parsing C headers

2005-02-08 Thread Paddy McCarthy
Jean de Largentaye wrote:
Hi,
I need to parse a subset of C (a header file), and generate some unit
tests for the functions listed in it. I thus need to parse the code,
then rewrite function calls with wrong parameters. What I call "shaking
the broken tree" :)
I chose to make my UT-generator in Python 2.4. However, I am now
encountering problems in choosing the right parser for the job. I
struggle in choosing between the inappropriate, the out-of-date, the
alpha, or the too-big-for-the task...
Why not see if the output from a tags file generator such as ctags or 
etags will do what you want.

I often find that some simpler tools do 95% of the work and it is easier 
to treat the other five percent as broken-input.

try http://ctags.sourceforge.net/
- Paddy.
--
http://mail.python.org/mailman/listinfo/python-list


Re: graph visualisation

2005-02-08 Thread bearophileHUGS
This isn't a visualisation routine, but it contains some of them, and
with few mod you can adapt them for your needs:

http://gato.sourceforge.net/

Gato - the Graph Animation Toolbox - is a software which visualizes
algorithms on graphs.

Bearophile

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


Re: turing machine in an LC

2005-02-08 Thread Bernhard Herzog
Jeremy Bowers <[EMAIL PROTECTED]> writes:

> On Tue, 08 Feb 2005 17:36:19 +0100, Bernhard Herzog wrote:
>> Nick Vargish <[EMAIL PROTECTED]> writes:
>>> "Xah Lee" <[EMAIL PROTECTED]> writes:
 is it possible to write python code without any indentation?
>>> Not if Turing-completeness is something you desire.
>> 
>> It's possible to implement a turing machine with a single list
>> comprehension.  No indentation needed.
>
> I had to think about it, it's an interesting, and I'm going to tentatively
> disagree, because of the statement/expression dichotomy. "Tentatively"
> because if somebody can answer these objections than I will happily change
> my mind :-)


Here's an implementation of a turing machine simulator I hacked up a
while ago.  For readability's sake, it's a function definition with a
doc-string, but the heart of it is a single list comprehension which
could be written without indentation:


def listcomp_turing(M, T, initial_state = 0):
"""Run the turing machine M on the tape T.

The tape T should be a dictionary mapping head positions to the
value on the tape at that position.  Valid values on the tape are 0
and 1.  Empty positions have the value 0.  The initial head position
is 0.

The turing machine M should be a sequence of state pairs.  The state
of the machine is used as an index into that sequence and thus
should be in range(len(M)).  Each state pair is a pair of
(write_symbol, head_direction, next_state) triples, one for each of
the possible values on the tape at the current head position.  The
initial state is given by the optional parameter initial_state.  If
the next state is None, the machine stops.  The direction may be
either -1 or 1 meaning left and right respectively.  The function
does not enforce this limitation but with other values the machine
is not a turing machine anymore.

The return value is T.
"""
[x for L in [[[initial_state, 0]]]
   for state, pos in L
   if state is not None
  and (L.append([M[state][T.get(pos, 0)][2],
 pos + M[state][T.get(pos, 0)][1]])
   or T.__setitem__(pos, M[state][T.get(pos, 0)][0]))]
return T



For an example, lets take the one from wikipedia's article on turing
machines:


The following Turing machine has an alphabet {'0', '1'}, with 0
being the blank symbol. It expects a series of 1's on the tape, with
the head initially on the leftmost 1, and doubles the 1's with a 0
in between, i.e., "111" becomes "1110111". The set of states is {s1,
s2, s3, s4, s5} and the start state is s1. The action table is as
follows.

   Old Read   Wr.  New Old Read   Wr.  New
   St. Sym.   Sym. Mv. St. St. Sym.   Sym. Mv. St.
   - - - - - - - - - - - - - - - - - - - - - - - -
s1  1  ->  0R   s2  s4  1  ->  1L   s4
s2  1  ->  1R   s2  s4  0  ->  0L   s5
s2  0  ->  0R   s3  s5  1  ->  1L   s5
s3  0  ->  1L   s4  s5  0  ->  1R   s1
s3  1  ->  1R   s3


The listcomp_turing call with a tape containing "11" would be

listcomp_turing([((0, +1, None), (0, +1, 1)),
 ((0, +1, 2), (1, +1, 1)),
 ((1, -1, 3), (1, +1, 2)),
 ((0, -1, 4), (1, -1, 3)),
 ((1, +1, 0), (1, -1, 4))],
{0:1, 1:1})

which produces a result tape of

   {0: 1, 1: 1, 2: 0, 3: 1, 4: 1}


  Bernhard

-- 
Intevation GmbH http://intevation.de/
Skencil   http://skencil.org/
Thuban  http://thuban.intevation.org/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: turing machine in an LC

2005-02-08 Thread Michael Spencer
Jeremy Bowers wrote:
OK then, I still don't quite see how you can build a Turing Machine in one
LC, but an LC and one preceding list assignment should be possible,
although the resulting list from the LC is garbage; 
Not necessarily garbage - could be anything, say a copy of the results:
 >>> results = [0]
 >>> [(results.append(lastresult+1) or lastresult) for i, lastresult in 
it.izip(xrange(5),results)]
[0, 1, 2, 3, 4]
 >>> # ok, missing the 5, but close!

I don't think the assignment is avoidable though.
I should clarify a point I made earlier
I see no difference between LCs and GEs in this respect:
What I meant was that both LCs and GEs can reference their prior state in the 
same way.  Of course, there is an important difference in that the LC returns 
its list as soon as it is executed whereas the executing the genexp returns an 
iterator that can delay the evaluation of all but the outer loop until its 
next() is called.  This makes a genexp equivalent to (at least some) functions, 
and perhaps that was part of your point that I missed.

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


  1   2   3   >