Re: Remote XML Parsing

2007-03-30 Thread Laurent Pointal
[EMAIL PROTECTED] a écrit :
> How can I parse a remote XML file with Python?
> And what will I be able to do with this XML file in Python?
> 
> Sorry if this is a noob-ish question.

You can process XML data with Python as long as you can get it - you
will be able to do what you want with it.

How do you access your remote file ?

...more details would be wellcome...


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


Re: Game programming for kids: looking for open source 2D game development kit

2007-03-30 Thread Laurent Pointal
Max Kubierschky a écrit :
> Hello,
> 
> I'm planning to give a game programming course for kids of mixed age.
> For this, I am looking for an open source 2D game development kit.
> I am also willing to participate in the development of the development kit.
> 
> Features I'd like to see
> - Possibility to construct simple games via drag and drop without
> programming
> - Integration into an IDE
> - Based on Java or Python
> Pluses:
> - Good Tutorial
> - German documentation

With Python:
* pygame + build your drag'n drop features
* if you like 3D, vpython.


http://www.pygame.org/
http://www.vpython.org/



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


Is any way to split zip archive to sections?

2007-03-30 Thread Durumdara

Hi!

I want to create some backup archives with python (I want to write a backup
application in Python).
Some package managers (7z, arj, winzip) can create splitted archives (1
mega, 650, 700 mega, etc).

Because I want to ftp these results to a ftp server, I want to split large
volumes to 15 mb sections.

Can I do it with any python wrapper automatically (like in Cobian), or I
need to create the large volume, and next split it with another tool?

Or anybody knows about a command line tool (like 7z, or arj) that can expand
the splitted archive (and I can add files with them from Python one by one)?

So what is the solution?

Thanks for your help:
dd
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: with timeout(...):

2007-03-30 Thread Hendrik van Rooyen
 "Nick Craig-Wood" <[EMAIL PROTECTED]> wrote:

> I'd like there to be something which works well enough for day to day
> use.  Ie doesn't ever wreck the internals of python.  It could have
> some caveats like "may not timeout during C functions which haven't
> released the GIL" and that would still make it very useable.

I second this (or third or whatever if my post is slow).
It is tremendously useful to start something and to be told it has timed
out by a call, rather than to have to unblock the i/o yourself and
to "busy-loop" to see if its successful.  And from what I can see
the select functionality is not much different from busy looping...

- Hendrik

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


Re: Weird behavior in search in a list

2007-03-30 Thread Hendrik van Rooyen
"Su Y" <[EMAIL PROTECTED]> wrote:

> I want find the first number in extend[] which is larger than num, so
> I wrote:
> def find(num):
> count=0
> for elem in extend:
> if elem count+=1
> return count
> 
> I found that if extend[] is monotonous, like [1.1, 2.3, 3.2, 4.5,
> 5.6],
> it works fine: find(4) returns 3, extend[3] is 4.5.
> But, if extend[] is not monotonous, like [1.1, 2.3, 3.2, 4.5, 5.6,
> 4.6, 3.4, 2.1, 0.3],
> find(4) returns 6, extend[6] is 3.4!
> 
> what's going on here? I really can't understand

Hint: extend[0]  is1.1
Hint: extend[7] is 2.1
Hint: 2.1 is less than 4

You have to stop counting and come out of the loop when you find the 
first one - what your function is doing is counting the elements less than
num, not finding the first one that is.

hth - Hendrik


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

Re: socket read timeout

2007-03-30 Thread Hendrik van Rooyen
"Jean-Paul Calderone" <[EMAIL PROTECTED]> wrote:

> On Thu, 29 Mar 2007 07:29:35 +0200, Hendrik van Rooyen
<[EMAIL PROTECTED]> wrote:

> >Are sockets full duplex?
>
> Uh, yes.

The reason I asked is that I have noticed that other file like objects
(on Suse 10 Linux and Python 2.4 out of the box) aren't  really:

If you start a blocking read in one thread on a serial port, and you
then issue a write in another thread, the characters are not transmitted
until the read completes.  It is as if the "driver" gets busy in the read
and queues the write - I think a lot of the "My output does not come
out till I close the programme" type of questions on this group is
caused by this.   And calling flush makes no difference under these
circumstances.- you have to unblock and use try - except on the read
as well.

So I was wondering if sockets are the same, as I haven't messed
with them much- just set up simple client server stuff in a
"Monkey see, Monkey do" way.

> >I know Ethernet isn't.
>
> Not that this is relevant, but unless you're using a hub, ethernet _is_
> full duplex.

: - ) Yes the UTP allows point to point full duplex, as there are separate
receive and transmit pairs.

But the protocol is not called Carrier Sense Multiple Access with
Collision Detection for nothing. - there can be no collisions in a true
full duplex channel. And its kind of difficult to swap rx and tx pairs
if there are more than two endpoints - you need a central point, and then
the "slaves" can't hear each other unless the central point passes the
messages on, or does some switching functions.

Reason I mentioned Ethernet is that in most cases (between machines)
its the underlying technology and if sockets were therefore not actually
full duplex it would not be surprising.

Is it actually possible to do what I have described for the serial port
case on a socket and have the message transmitted before one is
received?  Using a blocking receive?

- Hendrik

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


Memory testing in Python

2007-03-30 Thread csselo
Hi all

I want to test my python code for memory efficiency in gnu/linux.How
can I do this?

thanks.

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


Re: What are OOP's Jargons and Complexities

2007-03-30 Thread Timofei Shatrov
On Fri, 30 Mar 2007 06:48:05 GMT, "Mike Schilling" <[EMAIL PROTECTED]>
tried to confuse everyone with this message:

>Xah Lee wrote:
>
>> So, a simple code like this in normal languages:

>> becomes in Java:
>>
>>
>
>Only when written by someone almost entirely ignorant of Java. 
>

Which is the state most people want to be in...

-- 
|Don't believe this - you're not worthless  ,gr-.ru
|It's us against millions and we can't take them all... |  ue il   |
|But we can take them on!   | @ma  |
|   (A Wilhelm Scream - The Rip)|__|
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What are OOP's Jargons and Complexities

2007-03-30 Thread bugbear
Xah Lee wrote:

> So, a simple code like this in normal languages:
> 
> a = "a string";
> b = "another one";
> c = join(a,b);
> print c;
> 
> or in lisp style
> 
> (set a "a string")
> (set b "another one")
> (set c (join a b))
> (print c)
> 
> becomes in Java:
> 
> public class test {
>   public static void main(String[] args) {
> String a = new String("a string");
> String b = new String("another one");
> StringBuffer c = new StringBuffer(40);
> c.append(a); c.append(b);
> System.out.println(c.toString());
> }
> }

Er. How about

public class test {
   public static void main(String[] args) {
 String a = "a string";
 String b = "another one";
 StringBuffer c = a + b;
 System.out.println(c);
 }
}

Alternatively I could recode your Lisp example
as badly as you coded your Java.

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


Re: Game programming for kids: looking for open source 2D game development kit

2007-03-30 Thread Diez B. Roggisch
Max Kubierschky schrieb:
> Hello,
> 
> I'm planning to give a game programming course for kids of mixed age.
> For this, I am looking for an open source 2D game development kit.
> I am also willing to participate in the development of the development kit.
> 
> Features I'd like to see
> - Possibility to construct simple games via drag and drop without 
> programming
> - Integration into an IDE
> - Based on Java or Python
> Pluses:
> - Good Tutorial
> - German documentation

Squeak. Smalltalk, but especially targeted at your requirements.

http://www.squeak.org/

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


Object Oriented Database with interface for Pyhton

2007-03-30 Thread [EMAIL PROTECTED]
Hello all

I am looking for an object oriented database with interffaces for
python. Either open source or commercial.

I am looking for a Database not a object persistence system. I would
like to be able to execute queries outside from the aplication. If
posible wih OQL ( object query language )

The only candidate I have now is Cache from Intersystem

Thanks in advance

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


Indentation for code readability

2007-03-30 Thread DE
Hello,

Here is what I do in C++ and can not right now in python :

pushMatrix()
{
 drawStuff();

 pushMatrix();
 {
drawSomeOtherStuff()
 }
 popMatrix();
}
popMatrix();

The curly brackets have no functional meaning but increase the
readability significantly. I want to be able to do the same thing in
python. Since curly brackets are not available and indenting without
an if or while conditional doesn't work, I have started to question if
this is possible in python at all.

Any ideas ?

MDE

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


Re: Game programming for kids: looking for open source 2D game development kit

2007-03-30 Thread Max Kubierschky
Diez B. Roggisch schrieb:
> Max Kubierschky schrieb:
>> Hello,
>>
>> I'm planning to give a game programming course for kids of mixed age.
>> For this, I am looking for an open source 2D game development kit.
>> I am also willing to participate in the development of the development 
>> kit.
>>
>> Features I'd like to see
>> - Possibility to construct simple games via drag and drop without 
>> programming
>> - Integration into an IDE
>> - Based on Java or Python
>> Pluses:
>> - Good Tutorial
>> - German documentation
> 
> Squeak. Smalltalk, but especially targeted at your requirements.
> 
> http://www.squeak.org/
> 
> Diez


What part of Squeak is targeted at 2D game development?

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


Re: Indentation for code readability

2007-03-30 Thread Thomas Krüger
DE schrieb:
> Hello,
> 
> Here is what I do in C++ and can not right now in python :
> 
> pushMatrix()
> {
>  drawStuff();
> 
>  pushMatrix();
>  {
> drawSomeOtherStuff()
>  }
>  popMatrix();
> }
> popMatrix();
> 
> The curly brackets have no functional meaning but increase the
> readability significantly. I want to be able to do the same thing in
> python. Since curly brackets are not available and indenting without
> an if or while conditional doesn't work, I have started to question if
> this is possible in python at all.
> 
> Any ideas ?

I've been thinking about that for some minutes now and I have doubts
that it will increase the readability. Maybe for you as you invented
that style but not for others.
There are a few standards for formatting C code and even this few have
cause many discussions between developers.
Python has one convention (defined in PEP 8) and the deeper you dive
into the language the more you will like it.
BTW: having one way to do it is one of the main ideas of Python's
philosophy.

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


Re: Object Oriented Database with interface for Pyhton

2007-03-30 Thread csselo
http://www.sqlalchemy.org/

you ll like it.

On 30 Mart, 12:04, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> Hello all
>
> I am looking for an object oriented database with interffaces for
> python. Either open source or commercial.
>
> I am looking for a Database not a object persistence system. I would
> like to be able to execute queries outside from the aplication. If
> posible wih OQL ( object query language )
>
> The only candidate I have now is Cache from Intersystem
>
> Thanks in advance


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


Re: Indentation for code readability

2007-03-30 Thread John Machin
On Mar 30, 7:04 pm, "DE" <[EMAIL PROTECTED]> wrote:
> Hello,
>
> Here is what I do in C++ and can not right now in python :
>
> pushMatrix()
> {
>  drawStuff();
>
>  pushMatrix();
>  {
> drawSomeOtherStuff()
>  }
>  popMatrix();}
>
> popMatrix();
>
> The curly brackets have no functional meaning but increase the
> readability significantly. I want to be able to do the same thing in
> python. Since curly brackets are not available and indenting without
> an if or while conditional doesn't work, I have started to question if
> this is possible in python at all.
>
> Any ideas ?
>

You *can* use round brackets and/or square brackets. E.g.

def pushMatrix():
drawStuff()
pushMatrix()
(
drawSomeOtherStuff()
)
[
drawEvenMoreStuff()
]
popMatrix()

Whether you *should* do that is a different question ... It's a bit
like an English definition of a Scottish gentleman: one who can play
the bagpipes, but doesn't :-)

HTH,
John

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


Re: Indentation for code readability

2007-03-30 Thread Peter Otten
DE wrote:

> Hello,
> 
> Here is what I do in C++ and can not right now in python :
> 
> pushMatrix()
> {
>  drawStuff();
> 
>  pushMatrix();
>  {
> drawSomeOtherStuff()
>  }
>  popMatrix();
> }
> popMatrix();
> 
> The curly brackets have no functional meaning but increase the
> readability significantly. I want to be able to do the same thing in
> python. Since curly brackets are not available and indenting without
> an if or while conditional doesn't work, I have started to question if
> this is possible in python at all.
> 
> Any ideas ?

You could use

if True:
# do stuff

but I have no sympathy for such self-inflicted noise.

With Python 2.5 you can do even better -- you can emulate what should have
been RAII in your C++ example in the first place:

from __future__ import with_statement

from contextlib import contextmanager

def push_matrix():
print "push"

def pop_matrix():
print "pop"

@contextmanager
def matrix():
m = push_matrix()
try:
yield m
finally:
pop_matrix()

with matrix():
print "do stuff"
with matrix():
print "do more stuff"

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


How to get the demension of a video file?

2007-03-30 Thread seppl43
Hello there,

does anybody know, how to get the dimension values (width/height) of a
quicktime (.mov) and/or a avi-file?
Is there perhaps a module which can do this job?

Thank you for tips.

seppl

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


Re: Object Oriented Database with interface for Pyhton

2007-03-30 Thread M�ta-MCI
Hi!

>>> http://www.sqlalchemy.org/

No.
sqlalchemy is an object-oriented-interface(or wrapper)

Alfaeco want an Object-Oriented-Database (like Jasmin, Caché, etc.)


@-salutations

Michel Claveau

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


Re: Object Oriented Database with interface for Pyhton

2007-03-30 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit :
(top-post corrected)
> 
> On 30 Mart, 12:04, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
>> Hello all
>>
>> I am looking for an object oriented database with interffaces for
>> python. Either open source or commercial.
>>
>> I am looking for a Database not a object persistence system. I would
>> like to be able to execute queries outside from the aplication. If
>> posible wih OQL ( object query language )

 > http://www.sqlalchemy.org/
 >
 > you ll like it.

While sqlalchemy is one of the best things since sliced bread, it's 
definitevely *not* an OODB.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Cheeseshop needs mirrors

2007-03-30 Thread Paul Boddie
On 30 Mar, 09:05, "Jon" <[EMAIL PROTECTED]> wrote:
>
> If something as widely used as eggs is going to have a single point of
> failure like the Cheeseshop, we can't have it going down.
>
> I'm sure there are other solutions, but my suggestion is simply to
> have mirrors. It works for Debian, after all.

It was said that the setuptools stuff could work with simple package
index sites using static Web pages, and these could be mirrors of the
main package index, but I suppose it's time once again to remind
anyone wanting to reinvent package/dependency-management tools to take
another look at what's already been done in the domain. As you say, it
works for Debian.

Paul

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


Re: How can I get the content of a web site using http library

2007-03-30 Thread Lawrence Oluyede
<[EMAIL PROTECTED]> wrote:

> http://www.python.org/doc/current/lib/module-urllib2.html
> 
> Look into urlopen's data parameter.

I add also this tutorial to the plate:
http://www.voidspace.org.uk/python/articles/urllib2.shtml

-- 
Lawrence, oluyede.org - neropercaso.it
"It is difficult to get a man to understand 
something when his salary depends on not
understanding it" - Upton Sinclair
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Game programming for kids: looking for open source 2D game development kit

2007-03-30 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Max Kubierschky wrote:

> What part of Squeak is targeted at 2D game development?

http://www.squeak.org/Features/FunandGames/

And also take a look at http://www.squeakland.org/ (Kids play → Etoys)
which is a framework for children, that let's you paint objects and attach
behaviour to them.

Ciao,
Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: socket read timeout

2007-03-30 Thread Jean-Paul Calderone
On Fri, 30 Mar 2007 08:22:18 +0200, Hendrik van Rooyen <[EMAIL PROTECTED]> 
wrote:
>"Jean-Paul Calderone" <[EMAIL PROTECTED]> wrote:
>
>> On Thu, 29 Mar 2007 07:29:35 +0200, Hendrik van Rooyen
><[EMAIL PROTECTED]> wrote:
>
>> >Are sockets full duplex?
>>
>> Uh, yes.
>
>The reason I asked is that I have noticed that other file like objects
>(on Suse 10 Linux and Python 2.4 out of the box) aren't  really:
>
>If you start a blocking read in one thread on a serial port, and you
>then issue a write in another thread, the characters are not transmitted
>until the read completes.  It is as if the "driver" gets busy in the read
>and queues the write - I think a lot of the "My output does not come
>out till I close the programme" type of questions on this group is
>caused by this.   And calling flush makes no difference under these
>circumstances.- you have to unblock and use try - except on the read
>as well.

So posix has this great abstraction around places data can come from and go
to, file descriptors.  But actually it's not so great, because it leaks all
over the place.  Oh well.

Once you get to this level of detail (ie, "is it full duplex?"), then you
really do have to be thinking about what's behind the file descriptor.  A
serial port _can_ be full duplex, but isn't always.  Other kinds of file
descriptors might also be full duplex or they might not be.  It just depends
what the file descriptor really is.

>
>So I was wondering if sockets are the same, as I haven't messed
>with them much- just set up simple client server stuff in a
>"Monkey see, Monkey do" way.
>

Fortunately for us though, TCP sockets are full duplex. :)  Of course, maybe
"full duplex" is an over-simplification.  What does it really mean, anyway?
Does it mean that you can always read at the same time as you are writing?
What does "at the same time" mean anyway?  Oh well, I can just keep assuming
it's just a sort of vague hand-wavey feature. :)

>> >I know Ethernet isn't.
>>
>> Not that this is relevant, but unless you're using a hub, ethernet _is_
>> full duplex.
>
>: - ) Yes the UTP allows point to point full duplex, as there are separate
>receive and transmit pairs.
>
>But the protocol is not called Carrier Sense Multiple Access with
>Collision Detection for nothing. - there can be no collisions in a true
>full duplex channel. And its kind of difficult to swap rx and tx pairs
>if there are more than two endpoints - you need a central point, and then
>the "slaves" can't hear each other unless the central point passes the
>messages on, or does some switching functions.
>
>Reason I mentioned Ethernet is that in most cases (between machines)
>its the underlying technology and if sockets were therefore not actually
>full duplex it would not be surprising.
>
>Is it actually possible to do what I have described for the serial port
>case on a socket and have the message transmitted before one is
>received?  Using a blocking receive?

I'm going to keep saying yes here, but it's hard to explain why without
agreeing on a really detailed definition of "full duplex" and then most
likely also talking about a bunch of things below the TCP interface to
sockets.

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


Library for windows ini-files ?

2007-03-30 Thread stef
hello,

is there a Python library for easy reading and writing windows ini-files ?

thanks,
Stef Mientki
-- 
http://mail.python.org/mailman/listinfo/python-list


python win32com and dispatchbaseclass

2007-03-30 Thread vml
I am a newbie in python and com. I am trying to use python and com to
access to a software.

I had a look in the file .py describing the interface (generated by
makepy) and I found some dispatch base class...

My fisrt question is : is it possible to invoke a com object dispatch
base class?


other question in vb 6 I do something like that :


Public Function GetMyXAxis(idata As foo.idata) As Double()
Dim Block As foo.IBlock

Set Block = idata

GetMyXAxis = Block.XValues
Set Block = Nothing

End Function


is it possible to do the set Block = idata  in python ?


foo.Iblock is a dispatchbaseclass
foo.idata is a dispatchbaseclass

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


Re: Library for windows ini-files ?

2007-03-30 Thread Laurent Pointal
stef a écrit :
> hello,
> 
> is there a Python library for easy reading and writing windows ini-files ?

http://docs.python.org/lib/module-ConfigParser.html

A+

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


Re: Library for windows ini-files ?

2007-03-30 Thread Diez B. Roggisch
stef schrieb:
> hello,
> 
> is there a Python library for easy reading and writing windows ini-files ?

Isn't ConfigParser ini-style? I'm not totally sure though.

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


Re: Indentation for code readability

2007-03-30 Thread Bjoern Schliessmann
DE wrote:

> The curly brackets have no functional meaning but increase the
> readability significantly. 

Personally, I don't think so. It quite explodes the code.

Yes, I also indent "BSD style" in my C++ programs.

Regards,


Björn

-- 
BOFH excuse #175:

OS swapped to disk

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


Re: Memory testing in Python

2007-03-30 Thread Cameron Laird
In article <[EMAIL PROTECTED]>,
 <[EMAIL PROTECTED]> wrote:
>Hi all
>
>I want to test my python code for memory efficiency in gnu/linux.How
>can I do this?
.
.
.
What does "memory efficiency" mean to you?  Are you asking
how to eliminate memory leaks?

While I have a great deal of interest in memory management,
my general reaction to your question as you've posed it is,
"Don't; concentrate for now on good Python style."
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PyPy for dummies

2007-03-30 Thread Cameron Laird
In article <[EMAIL PROTECTED]>,
Paddy <[EMAIL PROTECTED]> wrote:
.
.
.
>It is also European funding for an open source project with sprints.
>I'm sure some eurocrat will be dissecting the project to see if it is
>aa good way to fund technical projects.
>
>- Paddy.
>

PyPy-ers, what *are* the prospects in this direction?
Are there write-ups planned that'll be of interest to
computing people?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: with timeout(...):

2007-03-30 Thread Diez B. Roggisch
Nick Craig-Wood schrieb:
> Diez B. Roggisch <[EMAIL PROTECTED]> wrote:
>>> I beleive the convention is when calling an OS function which might
>>> block the global interpreter lock is dropped, thus allowing other
>>> python bytecode to run.
>>
>>  So what? That doesn't help you, as you are single-threaded here. The 
>>  released lock won't prevent the called C-code from taking as long as it 
>>  wants. |And there is nothing you can do about that.
> 
> I'm assuming that the timeout function is running in a thread...

I wouldn't assume that - it could be a python on a platform without threads.

I really don't think that your idea is worth the effort. If there is 
something that can be safely interrupted at any given point in time - 
which is the exception, not the rule - then one can "code around" that 
missing feature, by spawning a subprocess python, using pyro to 
communicate, and terminate it. I've done so before.

Some people here said "we're adults, we make sure our code will be 
safely interruptable". But first of all, even adults make errors, and 
even more important: most of the time such a feature is wanted, it's 
about limiting some scripts that come from an untrusted source - like 
user-written plugins. Such a feature would encourage people to use it in 
such cases, but not stand up for the nastiness it may provoke.

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


Re: Object Oriented Database with interface for Pyhton

2007-03-30 Thread MC
Salut!

Heureusement qu'il y a qq français pour faire un peu de ménage...

-- 
@-salutations

Michel Claveau


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


Re: make RE more cleaver to avoid inappropriate : sre_constants.error: redefinition of group name

2007-03-30 Thread aspineux
On 30 mar, 00:13, "Paddy" <[EMAIL PROTECTED]> wrote:
> On Mar 29, 3:22 pm, "aspineux" <[EMAIL PROTECTED]> wrote:
>
>
>
> > I want to parse
>
> > '[EMAIL PROTECTED]' or '<[EMAIL PROTECTED]>' and get the email address 
> > [EMAIL PROTECTED]
>
> > the regex is
>
> > r'<[EMAIL PROTECTED]>|[EMAIL PROTECTED]'
>
> > now, I want to give it a name
>
> > r'<(?P[EMAIL PROTECTED])>|(?P[EMAIL PROTECTED])'
>
> > sre_constants.error: redefinition of group name 'email' as group 2;
> > was group 1
>
> > BUT because I use a | , I will get only one group named 'email' !
>
> > Any comment ?
>
> > PS: I know the solution for this case is to use  r'(?P<)?(?P
> > [EMAIL PROTECTED])(?(lt)>)'
>
> use two group names, one for each alternate form and if you are not
> concerned with whichever matched do something like the following:
>
The problem is the way I create this regex :-)

regex={}
regex['email']=r'(?P[EMAIL PROTECTED])'

path=r'<%(email)s>|%(email)s' % regex

Once more, the original question is :
Is it normal to get an error when the same id used on both side of a
|

>
>
> >>> s1 = '[EMAIL PROTECTED]'
> >>> s2 = '<[EMAIL PROTECTED]>'
> >>> matchobj = re.search(r'<(?P[EMAIL PROTECTED])>|(?P[EMAIL 
> >>> PROTECTED])', s1)
> >>> matchobj.groupdict()['email1'] or matchobj.groupdict()['email2']
> '[EMAIL PROTECTED]'
> >>> matchobj = re.search(r'<(?P[EMAIL PROTECTED])>|(?P[EMAIL 
> >>> PROTECTED])', s2)
> >>> matchobj.groupdict()['email1'] or matchobj.groupdict()['email2']
> '[EMAIL PROTECTED]'
>
> - Paddy.


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


Sending emails to 3 addresses....

2007-03-30 Thread Boudreau, Emile
Hello all, I'm trying to send a results email to 3 people. For some
reason only the first person in the list will receive the email but in
the received email it shows the 3 addresses. Here is my code, can
someone show me where I'm going wrong?? Thanks

sendMail('this is the subject line', 'the results: 71 fails, 229 pass,
300 total.', '[EMAIL PROTECTED], [EMAIL PROTECTED],
[EMAIL PROTECTED]')

def sendMail(subject, body, TO, FROM="[EMAIL PROTECTED]"):
print TO
HOST = "exchange.mycompany.com"
BODY = string.join((
"From: %s" % FROM,
"To: %s" % TO,
"Subject: %s" % subject,
"",
body
), "\r\n")
server = smtplib.SMTP(HOST)
server.sendmail(FROM, [TO], BODY)
server.quit()

Emile Boudreau
 
 This message may contain privileged and/or confidential information.  If 
you have received this e-mail in error or are not the intended recipient, you 
may not use, copy, disseminate or distribute it; do not open any attachments, 
delete it immediately from your system and notify the sender promptly by e-mail 
that you have done so.  Thank you.
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Library for windows ini-files ?

2007-03-30 Thread stef
Laurent Pointal wrote:
> stef a écrit :
>   
>> hello,
>>
>> is there a Python library for easy reading and writing windows ini-files ?
>> 
>
> http://docs.python.org/lib/module-ConfigParser.html
>
> A+
>
> Laurent.
>   
thanks Laurent,
that seems to be what I was looking for.

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


Re: which methods to use?

2007-03-30 Thread Steven D'Aprano
On Thu, 29 Mar 2007 14:55:04 -0300, Gabriel Genellina wrote:

> En Thu, 29 Mar 2007 01:56:15 -0300, Steven D'Aprano  
> <[EMAIL PROTECTED]> escribió:
> 
>> By the way, "id(obj) == id(another_object)" is just a long way of writing
>> "obj is another_object".
> 
> Just as a side note: that's not true, testing by id() only works if both  
> objects are alive at the same time.

Correction noted.


> py> id(object()) == id(object())
> True
> py> object() is object()
> False

That's weird. How on earth does that happen?


> So using the `is` operator is the only safe way to test for identity.

But if an object can be garbage collected before the is operator does the
comparison, how can that be safe?


-- 
Steven.

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


Re: Sending emails to 3 addresses....

2007-03-30 Thread Tim Williams
On 30/03/07, Boudreau, Emile <[EMAIL PROTECTED]> wrote:
>
> sendMail('this is the subject line', 'the results: 71 fails, 229 pass, 300
> total.', '[EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED]')
>
> def sendMail(subject, body, TO, FROM="[EMAIL PROTECTED]"):
> print TO
> HOST = "exchange.mycompany.com"
> BODY = string.join((
> "From: %s" % FROM,
> "To: %s" % TO,
> "Subject: %s" % subject,
> "",
> body
> ), "\r\n")
> server = smtplib.SMTP(HOST)
> server.sendmail(FROM, [TO], BODY)
> server.quit()
>

Emile,

You are passing the TO addresses as 3 addresses in a single string.
[TO] results in a list containing a single string - not a list
containing 3 individual addresses.

You need to either pass the addresses to the function as a list
containing the 3 addresses as individual strings,  or change

[TO]

to

TO.split(',')


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


Re: What are OOP's Jargons and Complexities

2007-03-30 Thread Lew
Timofei Shatrov wrote:
> On Fri, 30 Mar 2007 06:48:05 GMT, "Mike Schilling" <[EMAIL PROTECTED]>
> tried to confuse everyone with this message:
> 
>> Xah Lee wrote:
>>
>>> So, a simple code like this in normal languages:
> 
>>> becomes in Java:
>>>
>>>
>> Only when written by someone almost entirely ignorant of Java. 
>>
> 
> Which is the state most people want to be in...

As a particular case of the general proposition that most people want to be 
ignorant of computer programming.

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


Re: What are OOP's Jargons and Complexities

2007-03-30 Thread Lew
Xah Lee wrote:
>> public class test {
>>   public static void main(String[] args) {
>> String a = new String("a string");
>> String b = new String("another one");
>> StringBuffer c = new StringBuffer(40);
>> c.append(a); c.append(b);
>> System.out.println(c.toString());
>> }
>> }
> 
> Er. How about
> 
> public class test {
>   public static void main(String[] args) {
> String a = "a string";
> String b = "another one";
> StringBuffer c = a + b;
> System.out.println(c);
> }
> }

bugbear wrote:
> Alternatively I could recode your Lisp example
> as badly as you coded your Java.

 From what I've seen and heard of Xah Lee, you'd probably lose the bad-coding 
competition to him. He's a professional.

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


Re: Sending emails to 3 addresses....

2007-03-30 Thread Tim Williams
On 30/03/07, Tim Williams <[EMAIL PROTECTED]> wrote:

Emile,   (slight change to my original reply)

You are passing the TO addresses as 3 addresses in a single string.

[TO] results in a list containing a single string - not a list
containing 3 individual addresses.

You need to either pass the addresses to the function as a list
containing the 3 addresses as individual strings, and remove the
conversion to a list at sending time.  Or change

[TO]

to

TO.split(',')

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


RE: Sending emails to 3 addresses....

2007-03-30 Thread Boudreau, Emile
Thanks so much I would of never found that out.

Problem SOLVED 


Emile Boudreau


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Tim
Williams
Sent: Friday, March 30, 2007 9:12 AM
To: Boudreau, Emile
Cc: [email protected]
Subject: Re: Sending emails to 3 addresses

On 30/03/07, Tim Williams <[EMAIL PROTECTED]> wrote:

Emile,   (slight change to my original reply)

You are passing the TO addresses as 3 addresses in a single string.

[TO] results in a list containing a single string - not a list
containing 3 individual addresses.

You need to either pass the addresses to the function as a list
containing the 3 addresses as individual strings, and remove the
conversion to a list at sending time.  Or change

[TO]

to

TO.split(',')

HTH :)
 
 This message may contain privileged and/or confidential information.  If 
you have received this e-mail in error or are not the intended recipient, you 
may not use, copy, disseminate or distribute it; do not open any attachments, 
delete it immediately from your system and notify the sender promptly by e-mail 
that you have done so.  Thank you.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: which methods to use?

2007-03-30 Thread Duncan Booth
Steven D'Aprano <[EMAIL PROTECTED]> wrote:

>> py> id(object()) == id(object())
>> True
>> py> object() is object()
>> False
> 
> That's weird. How on earth does that happen?

The lifetimes of the two objects createted in the first comparison do 
not overlap: once the call to id() returns it immediately drops the 
reference to its parameter. Python's memory allocation has a tendency to 
reuse memory immediately so the second call to object() creates another 
object at the same location.

In the second comparison neither object can be released until the 'is' 
operator returns a result, so there is no memory reuse.

>> So using the `is` operator is the only safe way to test for identity.
> 
> But if an object can be garbage collected before the is operator does 
the
> comparison, how can that be safe?

The objects compared using the is operator have at least one reference, 
so they cannot be subject to garbage collection.

You might get some risky situations if you bring weakrefs into the mix. 
For example de-referencing two weak references to different objects both 
of which get garbage collected compares True because both references now 
return None.

>>> c1, c2 = C(), C()
>>> r1, r2 = weakref.ref(c1), weakref.ref(c2)
>>> r1() is r2()
False
>>> del c1
>>> del c2
>>> r1() is r2()
True

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


Re: Indentation for code readability

2007-03-30 Thread Steven D'Aprano
On Fri, 30 Mar 2007 02:04:45 -0700, DE wrote:

> Hello,
> 
> Here is what I do in C++ and can not right now in python :
> 
> pushMatrix()
> {
>  drawStuff();
> 
>  pushMatrix();
>  {
> drawSomeOtherStuff()
>  }
>  popMatrix();
> }
> popMatrix();
> 
> The curly brackets have no functional meaning 
> but increase the readability significantly. 

I don't understand why you are indenting 
the function calls. What does the
indentation and spacing signify?

Or, to put it another way:


I don't understand why you 
{
are indenting 
{
the function calls. 
}
What does the
}
indentation signify?



> I want to be able to do the same thing in
> python. Since curly brackets are not available and indenting without
> an if or while conditional doesn't work, I have started to question if
> this is possible in python at all.

Thank goodness it isn't, in general.

But if you want people to point at you and laugh in the street, you can do
this:

pushMatrix()
if True:
drawStuff();

pushMatrix();
if True:
drawSomeOtherStuff()

popMatrix();

popMatrix();



> Any ideas ?

Some people 
have a strange 
idea of 
"increase 
readability".


-- 
Steven.

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


Re: A nice way to use regex for complicate parsing

2007-03-30 Thread aspineux
On 29 mar, 17:33, "Paul McGuire" <[EMAIL PROTECTED]> wrote:
> On Mar 29, 9:42 am, Shane Geiger <[EMAIL PROTECTED]> wrote:
>
> > It would be worth learning pyparsing to do this.
>
> Thanks to Shane and Steven for the ref to pyparsing.  I also was
> struck by this post, thinking "this is pyparsing written in re's and
> dicts".

My first idea was : why learn a parsing library if I can do it using
're'
and dicts :-)

>
> The approach you are taking is *very* much like the thought process I
> went through when first implementing pyparsing.  I wanted to easily
> compose expressions from other expressions.  In your case, you are
> string interpolating using a cumulative dict of prior expressions.
> Pyparsing uses various subclasses of the ParserElement class, with
> operator definitions for alternation ("|" or "^" depending on non-
> greedy vs. greedy), composition ("+"), and negation ("~").  Pyparsing
> also uses its own extended results construct, ParseResults, which
> supports named results fields, accessible using list indicies, dict
> names, or instance names.
>
> Here is the pyparsing treatment of your example (I may not have gotten
> every part correct, but my point is more the similarity of our
> approaches).  Note the access to the smtp parameters via the Dict
> transformer.
>
> -- Paul

Thanks !

Any parsing library I used before were heavy to start with.
The benefit was inversely proportional to the size of the project.
Your look to be lighter, and the results are more easily usable.

Thanks for showing me your lib.

Anyway today I will keep my idea for small parsing.


Alain


>
> from pyparsing import *
>
> #  ::=  "."  "."  "." 
> intgr = Word(nums)
> dotnum = Combine(intgr + "." + intgr + "." + intgr + "." + intgr)
>
> #  ::=  |  "." 
> string_ = Word(alphanums)
> dotstring = Combine(delimitedList(string_,"."))
>
> #  ::=   |  "." 
> domain = dotnum | dotstring
>
> #  ::= any one of the 128 ASCII characters except , , quote
> ("), or backslash (\)
> #  ::= any one of the 128 ASCII characters (no exceptions)
> #  ::=  "\"  | "\"   |  |  
> #  ::=  """  """
> quotedString = dblQuotedString  # <- just use pre-defined expr from
> pyparsing
>
> #  ::=  | 
> localpart = (dotstring | quotedString).setResultsName("localpart")
>
> #  ::=  "@" 
> mailbox = Combine(localpart + "@" + domain).setResultsName("mailbox")
>
> #  ::= "<" [  ":" ]  ">"
> # also accept address without <>
> path = "<" + mailbox + ">" | mailbox
>
> # esmtp-keyword::= (ALPHA / DIGIT) *(ALPHA / DIGIT / "-")
> esmtpkeyword = Word(alphanums,alphanums+"-")
>
> # esmtp-value  ::= 1* # esmtp-parameter  ::= esmtp-keyword ["=" esmtp-value]
> esmtpparameters = Dict(
> ZeroOrMore( Group(esmtpkeyword + Suppress("=") + esmtpvalue) ) )
>
> # esmtp-cmd::= inner-esmtp-cmd [SP esmtp-parameters] CR LF
> esmtp_addr = path + \
> Optional(esmtpparameters,default=[])\
> .setResultsName("parameters")
>
> for t in tests:
> for keyword in [ 'MAIL FROM:', 'RCPT TO:' ]:
> keylen=len(keyword)
> if t[:keylen].upper()==keyword:
> t=t[keylen:]
> break
>
> try:
> match = esmtp_addr.parseString(t)
> print 'MATCH'
> print match.dump()
> # some sample code to access elements of the parameters
> "dict"
> if "SIZE" in match.parameters:
> print "SIZE is", match.parameters.SIZE
> print
> except ParseException,pe:
> print 'DONT match', t
>
> prints:
> MATCH
> ['<', ['[EMAIL PROTECTED]'], '>']
> - mailbox: ['[EMAIL PROTECTED]']
>   - localpart: johnsmith
> - parameters: []
>
> MATCH
> [['[EMAIL PROTECTED]']]
> - mailbox: ['[EMAIL PROTECTED]']
>   - localpart: johnsmith
> - parameters: []
>
> MATCH
> ['<', ['[EMAIL PROTECTED]'], '>', ['SIZE', '1234'], ['OTHER',
> '[EMAIL PROTECTED]']]
> - OTHER: [EMAIL PROTECTED]
> - SIZE: 1234
> - mailbox: ['[EMAIL PROTECTED]']
>   - localpart: johnsmith
> - parameters: [['SIZE', '1234'], ['OTHER', '[EMAIL PROTECTED]']]
>   - OTHER: [EMAIL PROTECTED]
>   - SIZE: 1234
> SIZE is 1234
>
> MATCH
> [['[EMAIL PROTECTED]'], ['SIZE', '1234'], ['OTHER', '[EMAIL PROTECTED]']]
> - OTHER: [EMAIL PROTECTED]
> - SIZE: 1234
> - mailbox: ['[EMAIL PROTECTED]']
>   - localpart: johnsmith
> - parameters: [['SIZE', '1234'], ['OTHER', '[EMAIL PROTECTED]']]
>   - OTHER: [EMAIL PROTECTED]
>   - SIZE: 1234
> SIZE is 1234
>
> MATCH
> ['<', ['"[EMAIL PROTECTED]> legal=email"@addresscom'], '>']
> - mailbox: ['"[EMAIL PROTECTED]> legal=email"@addresscom']
>   - localpart: "[EMAIL PROTECTED]> legal=email"
> - parameters: []
>
> MATCH
> [['"[EMAIL PROTECTED]> legal=email"@addresscom']]
> - mailbox: ['"[EMAIL PROTECTED]> legal=email"@addresscom']
>   - localpart: "[EMAIL PROTECTED]> legal=email"
> - parameters: []
>
> MATCH
> ['<', ['"[EMAIL PROTECTED]> legal=email"@addresscom'], '>', ['SIZE', '1234'],
> ['OTHER', '[EMAIL PROTECTE

Re: How to get the demension of a video file?

2007-03-30 Thread Bart Ogryczak
On Mar 30, 11:56 am, "seppl43" <[EMAIL PROTECTED]> wrote:
> Hello there,
>
> does anybody know, how to get the dimension values (width/height) of a
> quicktime (.mov) and/or a avi-file?
> Is there perhaps a module which can do this job?

Identify from ImageMagick. There is a Python binding (PythonMagick,
don't get it confused with PyMagic, which is no longer supported).
http://www.imagemagick.org/script/api.php#python

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


Re: Indentation for code readability

2007-03-30 Thread Mark Jackson
"DE" <[EMAIL PROTECTED]> writes:
> Hello,
> 
> Here is what I do in C++ and can not right now in python :
> 
> pushMatrix()
> {
>  drawStuff();
> 
>  pushMatrix();
>  {
> drawSomeOtherStuff()
>  }
>  popMatrix();
> }
> popMatrix();
> 
> The curly brackets have no functional meaning but increase the
> readability significantly.

You are e. e. cummings, and I claim my £5.

-- 
Mark Jackson - http://www.alumni.caltech.edu/~mjackson
Every 10 years we say to ourselves, "If only we had
done the right thing 10 years ago."
- Thomas Friedman


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

Re: Object Oriented Database with interface for Pyhton

2007-03-30 Thread Laurent Pointal
MC a écrit :
> Salut!
> 
> Heureusement qu'il y a qq français pour faire un peu de ménage...

Question de décalage horaire ?


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


Re: Any "consumer review generators" available?

2007-03-30 Thread Evil Otto
On Mar 30, 3:46 am, nullified <[EMAIL PROTECTED]> wrote:
> On 29 Mar 2007 20:34:26 -0700, "Evil Otto" <[EMAIL PROTECTED]> wrote:
>
> >On Mar 29, 2:19 pm, [EMAIL PROTECTED] wrote:
> >> I am looking for a fake consumer review generator that could generate 
> >> realistic looking reviews for any products, kind of like on amazon.com but 
> >> generated by Artificial Intelligence. Is there a package available in your 
> >> favorite programing language... thx alan
>
> >I really, really hope that you're looking to generate test data or
> >filler text.
>
> >If you're not, then DIAF.
>
> Die In A Fire? Drop In A Fryer? Doug Is A Fucker? Drown In A Fart?

Any of those would accurately describe the underlying sentiment, but I
had "Die In A Fire" in mind specifically.

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


Re: Any "consumer review generators" available?

2007-03-30 Thread nullified
On 30 Mar 2007 07:01:16 -0700, "Evil Otto" <[EMAIL PROTECTED]> wrote:

>On Mar 30, 3:46 am, nullified <[EMAIL PROTECTED]> wrote:
>> On 29 Mar 2007 20:34:26 -0700, "Evil Otto" <[EMAIL PROTECTED]> wrote:
>>
>> >On Mar 29, 2:19 pm, [EMAIL PROTECTED] wrote:
>> >> I am looking for a fake consumer review generator that could generate 
>> >> realistic looking reviews for any products, kind of like on amazon.com 
>> >> but generated by Artificial Intelligence. Is there a package available in 
>> >> your favorite programing language... thx alan
>>
>> >I really, really hope that you're looking to generate test data or
>> >filler text.
>>
>> >If you're not, then DIAF.
>>
>> Die In A Fire? Drop In A Fryer? Doug Is A Fucker? Drown In A Fart?
>
>Any of those would accurately describe the underlying sentiment, but I
>had "Die In A Fire" in mind specifically.

FM!, IWRFT!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Indentation for code readability

2007-03-30 Thread DE
Thanks Peter. This sounds like to right solution for my case, because
in addition to indentation, I can automate push and pop. I'll
investigate this further. I appreciate.

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


Re: Indentation for code readability

2007-03-30 Thread Duncan Booth
"DE" <[EMAIL PROTECTED]> wrote:

> Here is what I do in C++ and can not right now in python :
> 
> pushMatrix()
> {
>  drawStuff();
> 
>  pushMatrix();
>  {
> drawSomeOtherStuff()
>  }
>  popMatrix();
> }
> popMatrix();
> 

If I understand this contortion is because you have some sort of stack 
and you want the code to follow the depth as you push and pop things 
from the stack.

If you write this in Python then when drawSomeOtherStuff() throws an 
exception your 'stack' will get messed up, so you'll need to add some 
more code to handle this. Using Python 2.5 this is the sort of thing you 
should end up with (and you'll notice that your indentation appears 
naturally when you do this):


from __future__ import with_statement
from contextlib import contextmanager

# Dummy functions so this executes
def pushMatrix(arg): print "pushMatrix", arg
def popMatrix(arg): print "popMatrix", arg
def drawStuff(): print "drawStuff"
def drawSomeOtherStuff(): print "drawSomeOtherStuff"

# The matrix stack implemented as a context handler.
@contextmanager
def NewMatrixContext(arg):
pushMatrix(arg)
try:
yield
finally:
popMatrix(arg)

# and finally the function to actually draw stuff in appropriate
# contexts.
def fn():
with NewMatrixContext(1):
drawStuff()
with NewMatrixContext(2):
drawSomeOtherStuff()

fn()
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Indentation for code readability

2007-03-30 Thread DE
>
> I don't understand why you are indenting
> the function calls. What does the
> indentation and spacing signify?

The indentation of function calls increases readability not in the
sense that it is easier to decrypt the code, but rather it is
analogous to the coordinate system transformations these matrix push
and pop calls perform..

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


Re: Indentation for code readability

2007-03-30 Thread DE
Thanks Duncan. I guess you and Peter have been typing in the same
minute :) It really looks like a good solution, I wasn't aware this
with statement in Python. I can imagine the context handler coming
handy in other cases too.

Devrim

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


Re: Indentation for code readability

2007-03-30 Thread Alex Martelli
Thomas Krüger <[EMAIL PROTECTED]> wrote:

> BTW: having one way to do it is one of the main ideas of Python's
> philosophy.

Yes, just like C's -- see point 4 in the "Spirit of C" summary taken
from the ISO Standard for C and quoted e.g. at
 .  Of course, it's an
ideal, a design principle, not an actual description of how things turn
out (in either language).


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


Re: Indentation for code readability

2007-03-30 Thread Paul McGuire
On Mar 30, 4:04 am, "DE" <[EMAIL PROTECTED]> wrote:
>
> The curly brackets have no functional meaning...

"Curly brackets have no functional meaning"?  Surely you must be
thinking of C, but not C++.  Some of the most powerful idioms (idia?)
of C++ make use of functionality that runs when a closing bracket
causes local variables to fall out of scope.  In fact, this technique
is crucial to writing exception-safe code.

The most obvious has to do with memory allocation/deallocation, and
the STL template .   was invented to prevent this
problem:

{
// create a pointer - let's pretend I need a pointer
// and can't just allocate blah as a local SomeObject
SomeObject* blah = new SomeObject();

// do something with blah
blah->doSomething();

// do something else - OOPS! exception happened
blah->doSomethingBad();

delete blah;  // never got here - memory leaked
}

Instead, define blah using :

{
// create a pointer - let's pretend I need a pointer
// and can't just allocate blah as a local SomeObject
auto_ptr blah ( new SomeObject() );

// do something with blah
blah->doSomething();

// do something else - OOPS! exception happened
blah->doSomethingBad();

// but we don't care because when auto_ptr goes out
// of scope, it deletes its pointers allocated
// memory
}

I was on one C++ project in which our coding guidelines said something
to the effect of "no delete statements except in cleanup templates,"
meaning that all allocated variables had to be wrapped in some form of
auto_ptr template to ensure resource release on delete, even in the
face of exceptions.

So that closing '}' actually DOES do something functional, in running
the destructors of all locally declared variables.

But why should Python folks care, since garbage collection takes care
of our basic memory needs without all this auto_ptr stuff?
Well memory allocation is only one of these symmetric function cases.
Garbage collection doesn't do anything for us in:
- database transaction commit/rollback
- mutex lock/unlock
- web client session close/release
- release of any other kind of allocatable resource

AND, it does this deterministically, not "at some possible time in the
future" like GC.
(Yes, I know that CPython's ref counting scheme *does* release memory
immediately, but this is an implementation-specific behavior.)

Prior to Python 2.5's "with" construct, the closest Pythoners could
get was to use try/catch/finally, and put the resource release code
into the finally block.  There are also some decorators on the Python
wiki that encapsulate this "be sure to close the door" logic into some
friendlier syntax (even if it does use that ugly '@').

-- Paul

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


Re: Memory testing in Python

2007-03-30 Thread mkPyVS
>While I have a great deal of interest in memory management,
>my general reaction to your question as you've posed it is,
>"Don't; concentrate for now on good Python style."

I agree but for monitoring...

I've had good luck with executing a popen to grab and parse output
from ps -Af and pass it your own process ID as the search. It adds
overhead to the cpu exec time but it is much less than 1sec so you
won't see it.

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


next python berlin user group meeting / naechstes berliner python treffen

2007-03-30 Thread Stephan Diehl
time: 3.4., 7pm
place: c-base
info: http://groups.google.de/group/python-berlin
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Indentation for code readability

2007-03-30 Thread DE
>
> > The curly brackets have no functional meaning...
>
> "Curly brackets have no functional meaning"?  Surely you must be
> thinking of C, but not C++.  Some of the most powerful idioms (idia?)
> of C++ make use of functionality that runs when a closing bracket
> causes local variables to fall out of scope.  In fact, this technique
> is crucial to writing exception-safe code.

The curly brackets have no functional meaning in the scope of the
example I have written in my original mail. I usually ask C++ memory
management issues in in the relevant newsgroup :)

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


Inserting '-' character in front of all numbers in a string

2007-03-30 Thread kevinliu23
Hey guys,

I want to be able to insert a '-' character in front of all numeric
values in a string. I want to insert the '-' character to use in
conjunction with the getopt.getopt() function.

Rigt now, I'm implementing a menu system where users will be able to
select a set of options like "2a 3ab" which corresponds to menu
choices. However, with getopt.getopt(), it'll only return what I want
if I input -2a -3ab as my string. I don't want the user have to insert
a '-' character in front of all their choices, so I was thinking of
accepting the string input first, then adding in the '-' character
myself.

So my qusetion is, how do I change:

"2a 3ab" into "-2a -3ab".

Regular expressions? :/

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


New to Python - Easy way to open a text file

2007-03-30 Thread Max Steel
Hey gang, I'm new to python coding.  I'm trying to find the simplest way to 
open a text file (on the same server) and display it's content.

The text file is plain text (no markup language of any kind).

The filename gets found and placed into a variable named [plainfiles.href]

I'm using python to find the text files, and a .ezt template to display the 
list of the files.  But I can't figure out how to read the contents of the 
file, and display it within the same template.

Any help is appreciated.

Thanks in advance,
.\\axSteel 


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


Re: Inserting '-' character in front of all numbers in a string

2007-03-30 Thread kyosohma
On Mar 30, 10:38 am, "kevinliu23" <[EMAIL PROTECTED]> wrote:
> Hey guys,
>
> I want to be able to insert a '-' character in front of all numeric
> values in a string. I want to insert the '-' character to use in
> conjunction with the getopt.getopt() function.
>
> Rigt now, I'm implementing a menu system where users will be able to
> select a set of options like "2a 3ab" which corresponds to menu
> choices. However, with getopt.getopt(), it'll only return what I want
> if I input -2a -3ab as my string. I don't want the user have to insert
> a '-' character in front of all their choices, so I was thinking of
> accepting the string input first, then adding in the '-' character
> myself.
>
> So my qusetion is, how do I change:
>
> "2a 3ab" into "-2a -3ab".
>
> Regular expressions? :/

Regular expressions would definitely work. Here's a hack though:

tempInput = '2a 3ab'
tempLst = tempInput.split(' ')

output = ''
for i in tempLst:
   output += ('-' + i + ' ')


I'm sure there are many better and more elegant hacks than this.

Mike

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


Re: Inserting '-' character in front of all numbers in a string

2007-03-30 Thread Larry Bates
kevinliu23 wrote:
> Hey guys,
> 
> I want to be able to insert a '-' character in front of all numeric
> values in a string. I want to insert the '-' character to use in
> conjunction with the getopt.getopt() function.
> 
> Rigt now, I'm implementing a menu system where users will be able to
> select a set of options like "2a 3ab" which corresponds to menu
> choices. However, with getopt.getopt(), it'll only return what I want
> if I input -2a -3ab as my string. I don't want the user have to insert
> a '-' character in front of all their choices, so I was thinking of
> accepting the string input first, then adding in the '-' character
> myself.
> 
> So my qusetion is, how do I change:
> 
> "2a 3ab" into "-2a -3ab".
> 
> Regular expressions? :/
> 
s="2a 3b"
s="-%s -%s"% tuple(s.split())

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


Re: Game programming for kids: looking for open source 2D game development kit

2007-03-30 Thread John Nagle
Max Kubierschky wrote:
> Diez B. Roggisch schrieb:
> 
>> Max Kubierschky schrieb:
>>
>>> Hello,
>>>
>>> I'm planning to give a game programming course for kids of mixed age.
>>> For this, I am looking for an open source 2D game development kit.
>>> I am also willing to participate in the development of the 
>>> development kit.
>>>
>>> Features I'd like to see
>>> - Possibility to construct simple games via drag and drop without 
>>> programming
>>> - Integration into an IDE
>>> - Based on Java or Python
>>> Pluses:
>>> - Good Tutorial
>>> - German documentation

 The Blender GameKit will do all that.

 You can do simple games without programming.
 There's a graphical integrated environment.
 Programs can be written in Python.
 There's a published book ("Blender GameKit")
 German documentation may be hard to come by, though.

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


Re: Islam, the Religion of Ease

2007-03-30 Thread adrian . villanustre
On Mar 29, 11:36 am, "moslim" <[EMAIL PROTECTED]> wrote:
> Excuse me!!
> Would you stop for a moment?!
> O...man...Haven't you thought-one day- about yourself ?
> Who has made it?
> Have you seen a design which hasn't a designer ?!
> Have you seen a wonderful,delicate work without a worker ?!
> It's you and the whole universe!..
> Who has made them all ?!!
> You know who ?.. It's "ALLAH",prise be to him.
> Just think for a moment.
> How are you going to be after death ?!
> Can you believe that this exact system of the universe and all of
> these great creation will end in in nothing...just after death!
> Have you thought, for a second, How to save your soul from Allah's
> punishment?!
> Haven't you thought about what is the right religion?!
> Read ... and think deeply before you answer..
> It is religion of Islam.
> It is the religion that Mohammad-peace upon him- the last prophet, had
> been sent by.
> It is the religion that the right Bible- which is not distorted-has
> preached.
> Just have a look at The Bible of (Bernaba).
> Don't be emstional.
> Be rational and judge..
> Just look..listen...compare..and then judge and say your word.
> We advise you visiting 
> :http://www.islam-guide.comhttp://www.thetruereligion.orghttp://www.beconvinced.comhttp://www.plaintruth.orghttp://english.islamway.comhttp://www.todayislam.comhttp://www.prophetmuhammed.orghttp://www.islamtoday.net/english/http://www.islamunveiled.orghttp://www.islamic-knowledge.com
>
> We willingly recive any inquries at the e-mail :
>
> [EMAIL PROTECTED]

Respectofully:

1.- Use the right place for your propaganda.
2.- Stop with religions, and militarism 
3.- Free the World of religious and Militars and you will get the
Peace for everybody  
4.- Use your time for usefull matters

Regards

Adrian

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


Re: New to Python - Easy way to open a text file

2007-03-30 Thread kyosohma
On Mar 30, 10:49 am, "Max Steel" <[EMAIL PROTECTED]> wrote:
> Hey gang, I'm new to python coding.  I'm trying to find the simplest way to
> open a text file (on the same server) and display it's content.
>
> The text file is plain text (no markup language of any kind).
>
> The filename gets found and placed into a variable named [plainfiles.href]
>
> I'm using python to find the text files, and a .ezt template to display the
> list of the files.  But I can't figure out how to read the contents of the
> file, and display it within the same template.
>
> Any help is appreciated.
>
> Thanks in advance,
> .\\axSteel

I'm not familiar with ezt formats, however reading a text file is a
breeze.

f = open(r'pathToFile')
while True:
line = f.readline()
if not line: break
# do something with the line of text such as print it.

f.close()


I suppose you could write it to .ezt? Maybe you need to format each
line before inserting it. I hope this points you in the right
direction anyway.

Mike

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


Re: New to Python - Easy way to open a text file

2007-03-30 Thread skip

Max> Hey gang, I'm new to python coding.  I'm trying to find the
Max> simplest way to open a text file (on the same server) and display
Max> it's content.

Try the open() builtin function:

f = open(plainfiles.href, "r")
print f.read()

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


Re: Memory testing in Python

2007-03-30 Thread Cameron Laird
In article <[EMAIL PROTECTED]>,
mkPyVS <[EMAIL PROTECTED]> wrote:
>>While I have a great deal of interest in memory management,
>>my general reaction to your question as you've posed it is,
>>"Don't; concentrate for now on good Python style."
>
>I agree but for monitoring...
>
>I've had good luck with executing a popen to grab and parse output
>from ps -Af and pass it your own process ID as the search. It adds
>overhead to the cpu exec time but it is much less than 1sec so you
>won't see it.
>

Fair enough.  

Did you intend to suggest "ps -F"?  While ps remains not-so-well
standardized, I know of no version where "ps -Af" details *memory*
usage.

Parsing can be simplified with such invocations as
ps -o pid -o rss -o size -o cmd
(which can itself be rewritten in various ways, depending on the
flavor of ps involved).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: make RE more cleaver to avoid inappropriate : sre_constants.error: redefinition of group name

2007-03-30 Thread Paddy
On Mar 30, 1:44 pm, "aspineux" <[EMAIL PROTECTED]> wrote:
> On 30 mar, 00:13, "Paddy" <[EMAIL PROTECTED]> wrote:
>
> > On Mar 29, 3:22 pm, "aspineux" <[EMAIL PROTECTED]> wrote:
>
> > > I want to parse
>
> > > '[EMAIL PROTECTED]' or '<[EMAIL PROTECTED]>' and get the email address 
> > > [EMAIL PROTECTED]
>
> > > the regex is
>
> > > r'<[EMAIL PROTECTED]>|[EMAIL PROTECTED]'
>
> > > now, I want to give it a name
>
> > > r'<(?P[EMAIL PROTECTED])>|(?P[EMAIL PROTECTED])'
>
> > > sre_constants.error: redefinition of group name 'email' as group 2;
> > > was group 1
>
> > > BUT because I use a | , I will get only one group named 'email' !
>
> > > Any comment ?
>
> > > PS: I know the solution for this case is to use  r'(?P<)?(?P
> > > [EMAIL PROTECTED])(?(lt)>)'
>
> > use two group names, one for each alternate form and if you are not
> > concerned with whichever matched do something like the following:
>
> The problem is the way I create this regex :-)
>
> regex={}
> regex['email']=r'(?P[EMAIL PROTECTED])'
>
> path=r'<%(email)s>|%(email)s' % regex
>
> Once more, the original question is :
> Is it normal to get an error when the same id used on both side of a
> |
>
>
>
> > >>> s1 = '[EMAIL PROTECTED]'
> > >>> s2 = '<[EMAIL PROTECTED]>'
> > >>> matchobj = re.search(r'<(?P[EMAIL 
> > >>> PROTECTED])>|(?P[EMAIL PROTECTED])', s1)
> > >>> matchobj.groupdict()['email1'] or matchobj.groupdict()['email2']
> > '[EMAIL PROTECTED]'
> > >>> matchobj = re.search(r'<(?P[EMAIL 
> > >>> PROTECTED])>|(?P[EMAIL PROTECTED])', s2)
> > >>> matchobj.groupdict()['email1'] or matchobj.groupdict()['email2']
> > '[EMAIL PROTECTED]'
>
> > - Paddy.

Groups are numbered left-to-right irrespective of the expression
contents.
I am quite happy with the names being merely apseudonym for the
positional
group number and don't see a problem with not allowing multiple
occurrences of  the same group name.
I did see some article about RE's and their speed. It seems that if
Pythons
RE package distinguished between 'grep style' RE' and the full set of
Python
RE's then their are much faster and efficient algorithms available for
the
grep style subset.

- Paddy.

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


Re: Library for windows ini-files ?

2007-03-30 Thread [EMAIL PROTECTED]
On Mar 30, 1:26 am, stef <[EMAIL PROTECTED]> wrote:
> hello,
>
> is there a Python library for easy reading and writing windows ini-files ?
>
> thanks,
> Stef Mientki

Maybe check this out?
http://www.voidspace.org.uk/python/configobj.html

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


911 was a HEINOUS CRIME by RACIST YANK BASTARDZ - Opinion from JAPANESE Americans

2007-03-30 Thread thermate2
http://www.opednews.com/maxwrite/page.php?a=32710

March 28, 2007 at 21:50:23

Breaking my silence on 9/11 Truth

by John Kusumi Page 1 of 1 page(s)

http://www.opednews.com


Tell A Friend

Initially I preferred to keep silent about the 9/11 Truth Movement, to
not be diverted from my issue. I've been associated with the China
Support Network, being its founder, and in recent years, I give my
speeches in that vein exclusively. That means, I have a cause and I
don't need a spare cause, nor a soapbox, nor a reason to be known in
the public discourse, where I've contributed since 1980. My 9/11
article is written, not oral; in any public appearance, I remain on
the China issue. The article is volunteered and not sponsored; I
simply think it fair to have the question, "What happened on 9/11?",
and to have the indicated investigation that is genuine and impartial,
rather than a whitewash. Read on, to where I suggest a role for Glenn
Beck and Bill O'Reilly.

Recently, Rosie O'Donnell raised the issue of 9/11 Truth, questioning
how one or more of the buildings fell in New York City on September
11, 2001. Also, actor Charlie Sheen has come out with his own
questions and concerns about what happened that day, and we've learned
that he will narrate an updated version of Loose Change, a documentary
that questions the official story of 9/11. This led to mentions on
television by Bill O'Reilly and Glenn Beck, top conservative
commentators who seem to have replaced George Will and Bob Novak.
(Note to youngsters: The latter were leading conservative commentators
in the post-Watergate period. What's Watergate? Check Wikipedia.)

I cannot be counted a fanatic on the issue of 9/11 truth. I do my
share of writing, publishing, and speaking; and, but for one related
blog post, this is my first article on the subject. The standard that
I would like to uphold is truth, period -- something that all should
care about, and that journalists in particular should be finicky to
discern and record accurately. The field of journalism at least bills
itself to be concerned about non-fiction and a first draft of history.
I believe that non-fiction and truth are synonyms, and that to sweat
these details ought to be right up the alley of U.S. journalists.

Imagine if you will a bumper sticker that says: "Pearl Harbor:
Roosevelt Knew." In the 1940s, there were many very staunch, patriotic
citizens, who likely had full faith in their President Roosevelt (FDR)
and for whom our hypothetical bumper sticker may hurt, or sting
deeply. The sticker could be rejected on the simple basis that it is
alien to the world view, held by those observers, of FDR as an upright
and above-board U.S. President. More recent research, however, has
convinced many historians that the sticker is indeed accurate. I
believe that even our mainstream commentators have allowed the same,
so that we now have an accepted view of history, to wit that Roosevelt
had foreknowledge of the Japanese attack at Pearl Harbor. If so, then
the truth behind Pearl Harbor becomes LIHOP -- Let It Happen On
Purpose.

The above paragraph does NOT prove anything about 9/11. If people make
bumper stickers saying, "9/11: Bush Knew," then they still must make
their case. For those who assert provocatively, there is an onus or a
burden of proof. Words are not "more true" on a bumper sticker, and
"less true" elsewhere. The standard of proof is not in the placement
of the words. However, I believe and would stand behind a bumper
sticker that said: "Tiananmen Square: Bush Knew." (That refers to the
elder President Bush, who gave a nod and a wink to Chinese leaders
before their troops went to Tiananmen Square. Chinese leaders MIHOP --
Made It Happen On Purpose.)

For those who are toying with the possibilities, alternate
explanations for 9/11 include (a.) "we were surprised -- they got one
by us (totally innocent);" (b.) "we were warned, but we failed to
connect the dots (totally incompetent);" (c.) LIHOP (partial inside
job, partially sinister); and (d.) MIHOP (an inside job, totally
sinister). The official explanation has already migrated, since the
early days, from (a.) to (b.). Perhaps one reason why I've avoided
9/11 Truth as a topic is due to its parallel with rejecting the
"Roosevelt knew of Pearl Harbor" thought, as above. Explanations (c.)
and (d.) for 9/11 entail the culpability of someone in our own
government. It is alien to the world view that the U.S. Government
protects Americans. In this case, Americans were harmed by
perpetrators who were clearly evil, and it is harsh -- indeed
anguishing -- to contemplate the case if it were that the hand of evil
was partly domestic. Culpability within our own government would make
9/11 the crime of the century.

I will not take up the job of re-iterating the case that's been made
by the 9/11 Truth Movement. But, increasing numbers of questions have
been uncovered, and the awareness of prior warnings, given to the U.S.
government in advance, has incr

Re: New to Python - Easy way to open a text file

2007-03-30 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, kyosohma wrote:

> I'm not familiar with ezt formats, however reading a text file is a
> breeze.

This sentence doesn't match the code that follow.  It's really simpler
than that ``while`` loop.

> f = open(r'pathToFile')
> while True:
>   line = f.readline()
>   if not line: break
>   # do something with the line of text such as print it.
> 
> f.close()

f = open(r'pathToFile)
for line in f:
# do something with the line of text such as print it.
f.close()

Ciao,
Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: File deletion after 72 hours of creation

2007-03-30 Thread Tim Williams
On 29 Mar 2007 13:40:58 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> On Mar 29, 12:02 pm, [EMAIL PROTECTED] wrote:
> > Alex> I'm looking for a simple method to delete a folder after 72
> > Alex> "Business hours" (saturday/sunday doesnt count) since its
> > Alex> creation. Note that This is on a linux system and I realize that
> > Alex> it will be the last modified time. These files wont be modified
> > Alex> since their creation.
> >
> > Alex> Im very confused on how to work with the number easily.
> >
> > Take a look at the dateutil module.  Its relativedelta object has some
> > weekday sense:
> >
> >http://labix.org/python-dateutil
> >
> > Skip
>
> Hey, thanks for the reply, I was able to accomplish it (somewhat ugly)
> using the datetime module alone. Here is my code.
> the part with the timestamp.file is just a plaintext file containg
> "#year#month#day" that is created when my client side program copies
> files into my directory.
>
> Just posting the code so if anyone else is wondering how to do this
> ever maybe they can find some of this useful:
> ---
>
> #!/usr/bin/env python
>
> import datetime
> import os
> today = datetime.date.today().toordinal()
> serverFiles = os.listdir("/home/webserver/")
> theDirList=[]
> for xfile in serverFiles:
> if os.path.isdir("/home/webserver/" + xfile) == True:
> theDirList.append(xfile)
>
>
> for xdir in theDirList:
> foo=open("/home/webserver/"+ xdir + "/timestamp.file",'r')
> parseMe = foo.readlines()
> fileDate=parseMe[0].split("#")
> fileYear = fileDate[1]
> fileMonth = fileDate[2]
> fileDay = fileDate[3]
>
> age_of_file = today -
> datetime.date(int(fileYear),int(fileMonth),int(fileDay)).toordinal()
> true_age = age_of_file
> for i in range(age_of_file):
> d=
> datetime.date(int(fileYear),int(fileMonth),int(fileDay)+i)
> ourDay = d.weekday()
> if ourDay == 5 or ourDay == 6:
> true_age = true_age - 1
>
>  print xdir + " : " + str(true_age) + " days old"
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>

You may have "over thought" the problem :)

(Not tested)
--
import os, time

pth = '/home/webserver/'
a_day = 60*60*24
today = time.asctime().split()[0]
cutOffDate = time.time() - (3 * a_day)
if today in ['Mon','Tue','Wed']:
cutOffDate = cutOffDate - (2 * a_day)

for f in os.listdir( pth ):
fname = os.path.join(pth ,f)
if os.path.isfile( fname ) and os.path.getmtime(fname) < cutOffDate:
print fname # os.remove(fname)

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


Re: Inserting '-' character in front of all numbers in a string

2007-03-30 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, kevinliu23
wrote:

> "2a 3ab" into "-2a -3ab".

In [8]: '-' + ' -'.join('2a 3ab 4xy'.split())
Out[8]: '-2a -3ab -4xy'

Ciao,
Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Modules & positive surprises

2007-03-30 Thread Steven Bethard
Jan Danielsson wrote:
>But then there are a few modules that I just love to use, because
> they are so "clean" from interface to function. Among them I can't help
> mentioning optparse.


If you like optparse, you should try argparse:

 http://argparse.python-hosting.com/

It has an optparse-style API, along with support for

* positional arguments
* sub-commands
* required options
* options with a variable number of args
* better usage messages
* a much simpler extension mechanism

and more...



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


Re: Inserting '-' character in front of all numbers in a string

2007-03-30 Thread kevinliu23
Hey guys, thanks for the quick replies. I'm looking for something more
generic than adding it to "2a 3ab". For example, under the menu option
2, there can be upwards of 8 other suboptions. I'll see what's
suggested here and post back if I run into more problems. Thanks guys!

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


Re: Islam, the Religion of Ease

2007-03-30 Thread hg
[EMAIL PROTECTED] wrote:

> On Mar 29, 11:36 am, "moslim" <[EMAIL PROTECTED]> wrote:
>> Excuse me!!
>> Would you stop for a moment?!
>> O...man...Haven't you thought-one day- about yourself ?
>> Who has made it?
>> Have you seen a design which hasn't a designer ?!
>> Have you seen a wonderful,delicate work without a worker ?!
>> It's you and the whole universe!..
>> Who has made them all ?!!
>> You know who ?.. It's "ALLAH",prise be to him.
>> Just think for a moment.
>> How are you going to be after death ?!
>> Can you believe that this exact system of the universe and all of
>> these great creation will end in in nothing...just after death!
>> Have you thought, for a second, How to save your soul from Allah's
>> punishment?!
>> Haven't you thought about what is the right religion?!
>> Read ... and think deeply before you answer..
>> It is religion of Islam.
>> It is the religion that Mohammad-peace upon him- the last prophet, had
>> been sent by.
>> It is the religion that the right Bible- which is not distorted-has
>> preached.
>> Just have a look at The Bible of (Bernaba).
>> Don't be emstional.
>> Be rational and judge..
>> Just look..listen...compare..and then judge and say your word.
>> We advise you visiting
>> :http://www.islam-guide.comhttp://www.thetruereligion.orghttp://www.beconvinced.comhttp://www.plaintruth.orghttp://english.islamway.comhttp://www.todayislam.comhttp://www.prophetmuhammed.orghttp://www.islamtoday.net/english/http://www.islamunveiled.orghttp://www.islamic-knowledge.com
>>
>> We willingly recive any inquries at the e-mail :
>>
>> [EMAIL PROTECTED]
> 
> Respectofully:
> 
> 1.- Use the right place for your propaganda.
> 2.- Stop with religions, and militarism 
> 3.- Free the World of religious and Militars and you will get the
> Peace for everybody  
> 4.- Use your time for usefull matters
> 
> Regards
> 
> Adrian



I don't know ... maybe 'M' python can bring _real_ facts to the
discussion ... guiddo would not mind I gather

http://video.google.com/videoplay?docid=-2002541459944162494
http://www.youtube.com/watch?v=xrShK-NVMIU
http://www.mtholyoke.edu/~ebarnes/python/python.htm

I swore (holly s ) I'd never follow up on any of those guys ... but then
again, one can never trust an atheist.

hg











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


Re: Islam, the Religion of Ease

2007-03-30 Thread hg
Just came to me ... if wars were always fought with fish as weapons, they'd
be much less hunger in the world ... lol ... (as a non-anglo-saxon, I
thought for many years that lol meant "Lord, Oh Lord !)

hg (Holly Grail)


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


Re: What are OOP's Jargons and Complexities

2007-03-30 Thread Mike Schilling
Timofei Shatrov wrote:
> On Fri, 30 Mar 2007 06:48:05 GMT, "Mike Schilling"
> <[EMAIL PROTECTED]> tried to confuse everyone with this
> message:
>
>> Xah Lee wrote:
>>
>>> So, a simple code like this in normal languages:
>
>>> becomes in Java:
>>>
>>>
>>
>> Only when written by someone almost entirely ignorant of Java.
>>
>
> Which is the state most people want to be in...

Most of them have the brains not to display their ignorance so widely. 


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


clean up html document created by Word

2007-03-30 Thread jd
I am looking for python code (working or sample code) that can take an
html document created by Microsoft Word and clean it up (if you've
never had to look at a Word-generated html document, consider yourself
lucky ;-)  Alternatively, if you know of a non-python solution, I'd
like to hear about it.

Thanks...

-- jeff

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


Re: What are OOP's Jargons and Complexities

2007-03-30 Thread Mike Schilling
bugbear wrote:
> Er. How about
>
> public class test {
>   public static void main(String[] args) {
> String a = "a string";
> String b = "another one";
> StringBuffer c = a + b;

String c (etc.), that is.

> System.out.println(c);
> }
> }


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


Re: clean up html document created by Word

2007-03-30 Thread kyosohma
On Mar 30, 12:20 pm, "jd" <[EMAIL PROTECTED]> wrote:
> I am looking for python code (working or sample code) that can take an
> html document created by Microsoft Word and clean it up (if you've
> never had to look at a Word-generated html document, consider yourself
> lucky ;-)  Alternatively, if you know of a non-python solution, I'd
> like to hear about it.
>
> Thanks...
>
> -- jeff

You could try Beautiful Soup at 
http://www.crummy.com/software/BeautifulSoup/documentation.html

Python is good for parsing HTML/XML, so you could also try googling
Python parsing as well.

Mike

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


Re: clean up html document created by Word

2007-03-30 Thread Peter Otten
jd wrote:

> I am looking for python code (working or sample code) that can take an
> html document created by Microsoft Word and clean it up (if you've
> never had to look at a Word-generated html document, consider yourself
> lucky ;-)  Alternatively, if you know of a non-python solution, I'd
> like to hear about it.

The non-python solution:

http://www.w3.org/People/Raggett/tidy/

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


Re: clean up html document created by Word

2007-03-30 Thread jkn
IIUC, the original poster is asking about 'cleaning up' in the sense
of removing the swathes of unnecessary and/or redundant 'cruft' that
Word puts in there, rather than making valid HTML out of invalid HTML.
Again, IIUC, HTMLtidy does not do this.

If Beautiful Soup does, then I'm intererested!

jon N

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


Re: clean up html document created by Word

2007-03-30 Thread Shane Geiger
Tidy can now perform wonders on HTML saved from Microsoft Word 2000! 
Word bulks out HTML files with stuff for round-tripping presentation 
between HTML and Word. If you are more concerned about using HTML on the 
Web, check out Tidy's "Word-2000" 
 config option! Of 
course Tidy does a good job on Word'97 files as well!

  -- source:  http://www.w3.org/People/Raggett/tidy/



jkn wrote:

IIUC, the original poster is asking about 'cleaning up' in the sense
of removing the swathes of unnecessary and/or redundant 'cruft' that
Word puts in there, rather than making valid HTML out of invalid HTML.
Again, IIUC, HTMLtidy does not do this.

If Beautiful Soup does, then I'm intererested!

jon N

  


--
Shane Geiger
IT Director
National Council on Economic Education
[EMAIL PROTECTED]  |  402-438-8958  |  http://www.ncee.net

Leading the Campaign for Economic and Financial Literacy

begin:vcard
fn:Shane Geiger
n:Geiger;Shane
org:National Council on Economic Education (NCEE)
adr:Suite 215;;201 N. 8th Street;Lincoln;NE;68508;United States
email;internet:[EMAIL PROTECTED]
title:IT Director
tel;work:402-438-8958
x-mozilla-html:FALSE
url:http://www.ncee.net
version:2.1
end:vcard

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

Re: clean up html document created by Word

2007-03-30 Thread Peter Otten
jkn wrote:

> IIUC, the original poster is asking about 'cleaning up' in the sense
> of removing the swathes of unnecessary and/or redundant 'cruft' that
> Word puts in there, rather than making valid HTML out of invalid HTML.
> Again, IIUC, HTMLtidy does not do this.

>From that very page I linked to:

"""
Tidy can now perform wonders on HTML saved from Microsoft Word 2000! Word
bulks out HTML files with stuff for round-tripping presentation between
HTML and Word. If you are more concerned about using HTML on the Web, check
out Tidy's "Word-2000" config option! Of course Tidy does a good job on
Word'97 files as well!
"""

Peter

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


Re: clean up html document created by Word

2007-03-30 Thread bearophileHUGS
jd:
> I am looking for python code (working or sample code) that can take an
> html document created by Microsoft Word and clean it up (if you've
> never had to look at a Word-generated html document, consider yourself
> lucky ;-)  Alternatively, if you know of a non-python solution, I'd
> like to hear about it.

It's not an easy job, and it may require some manual editing, because
that html is the worst I have seen. You can use Tidy, there is a GUI
too, and you can use its suggestions to manually remove the offending
things, at the end Tidy is able to digest it, and return a cleaned up
html. But then you have just started, you need to process it even
more.

A solution is to avoid creating the Html in the first place, or to use
something more like Word 97 to create it. Dreamweaver too is able to
help with Word2000+ trashy html, but usually not enough.

If the structure of the Html document is simple enough, and assuming
you are using Windows, you can open it with Word, save it as RTF,
reopen it with Wordpad, save it again to remove some trash, and then
use something else (like Word 97, or maybe even Aracnophobia, etc) to
convert it to Html. Generally I've never found a really good way to
convert Rtf to a very good Html.

Bye,
bearophile

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


Re: Game programming for kids: looking for open source 2D game development kit

2007-03-30 Thread John Salerno
Laurent Pointal wrote:

> With Python:
> * pygame + build your drag'n drop features
> * if you like 3D, vpython.
> 
> 
> http://www.pygame.org/
> http://www.vpython.org/

Wow, vpython looks pretty  need. I'm messing around with it right now 
and reading the docs. But I can't find something...do you know how to 
clear the contents of the current scene? I checked the attributes of the 
display, but there is nothing like "empty" that would do it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: LRU cache (and other things missing from the standard library ...)

2007-03-30 Thread skip

Evan> I agree that LRU caches are a data structure too frequently
Evan> re-implemented in Python. I'd also like to see a "standard" cache
Evan> package, either as part of the standard library or elsewhere.  To
Evan> that end, I've just uploaded an LRU cache package to the Python
Evan> Package Index:

Evan> http://www.python.org/pypi?:action=display&name=lrucache&version=0.2

Couldn't get to your website, but I've been using this one I wrote for
several years:

http://www.webfast.com/~skip/python/Cache.py

I'm just coming to this thread, so I don't know how it compares with your
requirements.

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


Re: Game programming for kids: looking for open source 2D game development kit

2007-03-30 Thread John Salerno
John Salerno wrote:
> Laurent Pointal wrote:
> 
>> With Python:
>> * pygame + build your drag'n drop features
>> * if you like 3D, vpython.
>>
>>
>> http://www.pygame.org/
>> http://www.vpython.org/
> 
> Wow, vpython looks pretty  need.

neat*  :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Object Oriented Database with interface for Pyhton

2007-03-30 Thread kyosohma
On Mar 30, 8:51 am, Laurent Pointal <[EMAIL PROTECTED]> wrote:
> MC a écrit :
>
> > Salut!
>
> > Heureusement qu'il y a qq français pour faire un peu de ménage...
>
> Question de décalage horaire ?

Here is a list of all the popular database interface modules:

http://www.python.org/topics/database/modules.html

And then there's always Zope's database.

Mike

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


Re: manually implementing staticmethod()?

2007-03-30 Thread 7stud
Hi,

Thanks for the responses.


On Mar 28, 4:01 pm, "Michael Spencer" <[EMAIL PROTECTED]> wrote:
> "7stud" <[EMAIL PROTECTED]> wrote in message
>
> news:[EMAIL PROTECTED]> Hi,
>
> > Can someone show me how to manually implement staticmethod()?  Here is
> > my latest attempt:
> > 
>
> Raymond Hettinger can:
>
> http://users.rcn.com/python/download/Descriptor.htm#static-methods-an...

I was using that article to help me.  My problem was I was trying to
implement smeth() as a function rather than a class.  I hacked around
some more, and I came up with the following before peeking at this
thread for the answer:

class smeth(object):
def __init__(self, func):
self.func = func

def __getattribute__(self, name):
print "smeth -- getattribute"
return super(smeth, self).__getattribute__(name)

def __get__(self, inst, cls=None):
print "smeth get"
return self.func

class Test(object):
def __getattribute__(self, name):
print "Test - gettattribute"
return super(Test, self).__getattribute__(name)
def f():
print "executing f()"
return 10
f  = smeth(f)

print Test.f   #displays function obj not unbound method obj!
Test.f()

However, my code does not seem to obey this description in the How-To
Guide to Descriptors:

-
Alternatively, it is more common for a descriptor to be invoked
automatically upon attribute access. For example, obj.d looks up d in
the dictionary of obj. If d defines the method __get__, then
d.__get__(obj) is invoked according to the precedence rules listed
below.***The details of invocation depend on whether obj is an object
or a class***.
...
For objects, the machinery is in object.__getattribute__ which
transforms b.x into type(b).__dict__['x'].__get__(b, type(b)).
...
For classes, the machinery is in type.__getattribute__ which
transforms B.x into B.__dict__['x'].__get__(None, B).
-

When I examine the output from my code, Test.f does not call
Test.__getattribute__(), instead it calls smeth.__get__() directly.
Yet that last sentence from the How-To Guide to Descriptors seems to
say that Test.__getattribute__() should be called first.


I'm using python 2.3.5.

On Mar 29, 9:34 am, [EMAIL PROTECTED] (Alex Martelli) wrote:
> Simplest way:
>
> class smethod(object):
>   def __init__(self, f): self.f=f
>   def __call__(self, *a, **k): return self.f(*a, **k)
>
> Alex

Interesting.  That looks like a functor to me.  Thanks.  I notice that
__get__() overrides __call__().



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


Re: LRU cache (and other things missing from the standard library ...)

2007-03-30 Thread skip

Evan> http://www.python.org/pypi?:action=display&name=lrucache&version=0.2

skip> Couldn't get to your website, but I've been using this one I wrote
skip> for several years:

skip> http://www.webfast.com/~skip/python/Cache.py

skip> I'm just coming to this thread, so I don't know how it compares
skip> with your requirements.

Wow...  Talk about a brain fart.  My email header summary rolled from the
last message to the earliest and I wound up responding to a message from (I
think) 2004!!!

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


Re: Inserting '-' character in front of all numbers in a string

2007-03-30 Thread Michael Bentley

On Mar 30, 2007, at 10:38 AM, kevinliu23 wrote:

> I want to be able to insert a '-' character in front of all numeric
> values in a string. I want to insert the '-' character to use in
> conjunction with the getopt.getopt() function.
>
> Rigt now, I'm implementing a menu system where users will be able to
> select a set of options like "2a 3ab" which corresponds to menu
> choices. However, with getopt.getopt(), it'll only return what I want
> if I input -2a -3ab as my string. I don't want the user have to insert
> a '-' character in front of all their choices, so I was thinking of
> accepting the string input first, then adding in the '-' character
> myself.
>
> So my qusetion is, how do I change:
>
> "2a 3ab" into "-2a -3ab".
>

Will the first character always be a digit?

for i in yourstring.split():
if i[0].isdigit():
yourstring = yourstring.replace(i, '-%s' % (i,))

Or are these hex numbers?

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


Re: New to Python - Easy way to open a text file

2007-03-30 Thread Max Steel
Hmm.. maybe it'd help if I explained that I'm playing with edna
http://edna.sourceforge.net/

I'll play with this simple code:
 f = open(r'pathToFile)
 for line in f:
# do something with the line of text such as print it.
 f.close()

and this one from Skip:
f = open(plainfiles.href, "r")
print f.read()

and see if I can make a go of it.. I think it's the template portion that is 
mixing me up.. the template is what's used to create the look of the html on 
the edna server.

Thanks to all who replied so quickly, much appreciated!
.\\ax


"Marc 'BlackJack' Rintsch" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> In <[EMAIL PROTECTED]>, kyosohma wrote:
>
>> I'm not familiar with ezt formats, however reading a text file is a
>> breeze.
>
> This sentence doesn't match the code that follow.  It's really simpler
> than that ``while`` loop.
>
>> f = open(r'pathToFile')
>> while True:
>> line = f.readline()
>> if not line: break
>> # do something with the line of text such as print it.
>>
>> f.close()
>
> f = open(r'pathToFile)
> for line in f:
># do something with the line of text such as print it.
> f.close()
>
> Ciao,
> Marc 'BlackJack' Rintsch 


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


Re: New to Python - Easy way to open a text file

2007-03-30 Thread kyosohma
On Mar 30, 11:39 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
> In <[EMAIL PROTECTED]>, kyosohma wrote:
> > I'm not familiar with ezt formats, however reading a text file is a
> > breeze.
>
> This sentence doesn't match the code that follow.  It's really simpler
> than that ``while`` loop.
>
> > f = open(r'pathToFile')
> > while True:
> >line = f.readline()
> >if not line: break
> ># do something with the line of text such as print it.
>
> > f.close()
>
> f = open(r'pathToFile)
> for line in f:
> # do something with the line of text such as print it.
> f.close()
>
> Ciao,
> Marc 'BlackJack' Rintsch

Yes, the "while" is lame, I admit it. But sometimes you just gotta go
old school!

Mike

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


Tkinter menu question--how to pass arguments

2007-03-30 Thread Kevin Walzer
I'm having difficulty structuring a Tkinter menu entry. Here is the 
command in question:

self.finkmenu.add_command(label='Update List of Packages', 
command=self.authorizeCommand(self.scanPackages))

When I start my program, it crashes because it's trying to run the 
command self.authorizeCommand. The reason I'm structuring it in this 
fashion is that this command takes another command as an argument--in 
this case, self.ScanPackages.

The basic structure of the program is that the self.authorizeCommand 
function pops up a dialog box for a password; it then feeds the password 
to the function that it takes as an argument, i.e. self.scanPackages.

I tried setting up the menu entry without the additional parameter, i.e. 
command=self.authorizeCommand, but then when I try to run the command 
from the menu, it complains there are not enough arguments. 
Unsurprising, since self.authorizeCommand takes another function name as 
an argument.

How can I structure the menu item to reflect the correct number of 
arguments without it trying to execute the command?

-- 
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: New to Python - Easy way to open a text file

2007-03-30 Thread Max Steel
nothing is "lame" to me , all help is appreciated :)

.\\ax


<[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> On Mar 30, 11:39 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
>> In <[EMAIL PROTECTED]>, kyosohma 
>> wrote:
>> > I'm not familiar with ezt formats, however reading a text file is a
>> > breeze.
>>
>> This sentence doesn't match the code that follow.  It's really simpler
>> than that ``while`` loop.
>>
>> > f = open(r'pathToFile')
>> > while True:
>> >line = f.readline()
>> >if not line: break
>> ># do something with the line of text such as print it.
>>
>> > f.close()
>>
>> f = open(r'pathToFile)
>> for line in f:
>> # do something with the line of text such as print it.
>> f.close()
>>
>> Ciao,
>> Marc 'BlackJack' Rintsch
>
> Yes, the "while" is lame, I admit it. But sometimes you just gotta go
> old school!
>
> Mike
> 


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


Re: Tkinter menu question--how to pass arguments

2007-03-30 Thread Dave Opstad
In article <[EMAIL PROTECTED]>,
 Kevin Walzer <[EMAIL PROTECTED]> wrote:

> I'm having difficulty structuring a Tkinter menu entry. Here is the 
> command in question:
> 
> self.finkmenu.add_command(label='Update List of Packages', 
> command=self.authorizeCommand(self.scanPackages))
> 
> When I start my program, it crashes because it's trying to run the 
> command self.authorizeCommand. The reason I'm structuring it in this 
> fashion is that this command takes another command as an argument--in 
> this case, self.ScanPackages.
> 
> The basic structure of the program is that the self.authorizeCommand 
> function pops up a dialog box for a password; it then feeds the password 
> to the function that it takes as an argument, i.e. self.scanPackages.
> 
> I tried setting up the menu entry without the additional parameter, i.e. 
> command=self.authorizeCommand, but then when I try to run the command 
> from the menu, it complains there are not enough arguments. 
> Unsurprising, since self.authorizeCommand takes another function name as 
> an argument.
> 
> How can I structure the menu item to reflect the correct number of 
> arguments without it trying to execute the command?

If self.scanPackages exists as an attribute of self, why do you need to 
pass it in? If your command is just self.authorizeCommand, and that 
method makes use of self.scanPackages when it runs, then it all should 
work without your having to specify it here.

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


Re: Any "consumer review generators" available?

2007-03-30 Thread Schraalhans Keukenmeester
nullified wrote:
> On 30 Mar 2007 07:01:16 -0700, "Evil Otto" <[EMAIL PROTECTED]> wrote:
> 
>> On Mar 30, 3:46 am, nullified <[EMAIL PROTECTED]> wrote:
>>> On 29 Mar 2007 20:34:26 -0700, "Evil Otto" <[EMAIL PROTECTED]> wrote:
>>>
 On Mar 29, 2:19 pm, [EMAIL PROTECTED] wrote:
> I am looking for a fake consumer review generator that could generate 
> realistic looking reviews for any products, kind of like on amazon.com 
> but generated by Artificial Intelligence. Is there a package available in 
> your favorite programing language... thx alan
 I really, really hope that you're looking to generate test data or
 filler text.
 If you're not, then DIAF.
>>> Die In A Fire? Drop In A Fryer? Doug Is A Fucker? Drown In A Fart?
>> Any of those would accurately describe the underlying sentiment, but I
>> had "Die In A Fire" in mind specifically.
> 
> FM!, IWRFT!
Perhaps if he finds his miracle script he can also train it to create
and 'solve' funny acronyms?
-- 
http://mail.python.org/mailman/listinfo/python-list


  1   2   >