Re: first release of PyPy

2005-05-23 Thread Alex Stapleton
The question still remains, can it run it's self? ;)

On 20 May 2005, at 23:50, Kay Schluehr wrote:

>
> holger krekel wrote:
>
>> Welcome to PyPy 0.6
>> 
>>
>> *The PyPy Development Team is happy to announce the first
>> public release of PyPy after two years of spare-time and
>> half a year of EU funded development.  The 0.6 release
>> is eminently a preview release.*
>>
>
> Congratulation to You and Your team!
>
> PyPy is really awesome and if it succeeds in speed demands after the
> translation phase I believe that the project will shift the power
> within the Python community on the long run. There are moments I'm
> almost shocked about it and think about the fate of other programming
> programming languages like LISP. PyPy can be resolved to "Python in
> Python" but also "Python multiplied/powered by itself" which is much
> more triumphant. A short review of the 'thunks' objspace example gives
> me the impression that the language development process as we know it
> comes to an end and makes a kind of transition. This is both very
> exciting and dangerous, like every philosophical event.
>
> Regards,
> Kay
>
> -- 
> http://mail.python.org/mailman/listinfo/python-list
>
>

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


[avast! - INFECTED] hi

2005-05-23 Thread djamal . benslimane
It's the long-awaited film version of the Broadway hit. The  message  sent as  
a binary attachment.



---
avast! Antivirus: message Sortant INFECTE:
\readme.zip#2473510810 (Win32:Lovgate-W [Wrm]) Moved to chest

Base de donnees virale  (VPS): 0520-4, 20/05/2005
Teste le: 05/03/2005 08:34:45
avast! - copyright (c) 1988-2004 ALWIL Software.
http://www.avast.com






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

Re: first release of PyPy

2005-05-23 Thread Michael Sparks
holger krekel wrote:

> The PyPy 0.6 release
> 
> 
> *The PyPy Development Team is happy to announce the first
> public release of PyPy after two years of spare-time and
> half a year of EU funded development.  The 0.6 release
> is eminently a preview release.*

Yay! Congratulations guys!


Michael.
-- 
[EMAIL PROTECTED]
British Broadcasting Corporation, Research and Development
Kingswood Warren, Surrey KT20 6NP

This message (and any attachments) may contain personal views
which are not the views of the BBC unless specifically stated.


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


Manipulating mailboxes

2005-05-23 Thread Laszlo Zsolt Nagy

 Hi All,

I need to create a daemon that sits on a server and forwards some 
e-mails. (Well not only that, it needs to change header information 
before forwarding and also insert messages into a database). The mailbox 
module is fine but I do not see a way to delete/add messages - it is 
ready only. The other possiblity is IMAP4 but it is bad because my 
program should not store passwords for all users. I can only see one 
solution right now:

1. Make a copy of the mailbox
2. Truncate the mailbox
3. Process the messages in the copy and forward the e-mails by sending 
out real e-mails.

But this looks so clumsy. Is there a way to delete/add messages to 
mailboxes of different users, directly?

Thanks,

  Laci 2.0

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


Re: install python 2.4.1

2005-05-23 Thread [EMAIL PROTECTED]
Hello,

I installed python 2.4.1 at last.
I installed in two different computers all windows xp pro. I found the
installation size in add/remove software different in size is that
normal.

pujo

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


Re: Manipulating mailboxes

2005-05-23 Thread Paul Rubin
Laszlo Zsolt Nagy <[EMAIL PROTECTED]> writes:
> But this looks so clumsy. Is there a way to delete/add messages to
> mailboxes of different users, directly?

Why not use procmail or equivalent to drop incoming messages into
your daemon one at a time.  Then use the smtp module to forward them
to their actual destinations.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: first release of PyPy

2005-05-23 Thread Christian Tismer
Ville Vainio wrote:

>>"Christian" == Christian Tismer <[EMAIL PROTECTED]> writes:
> 
> 
> >> PyPy is written in python, if it can be compiled then the programs
> >> can
> >> be as well.
> 
> Christian> Well, this is not really true. PyPy is written in
> Christian> RPython, a sub-language of Python that is implicitly
> Christian> defined by "simple and static enough to be compilable".
> 
> Could it be possible to tag some modules in application code as
> RPython-compatible, making it possible to implement the speed critical
> parts in RPython?

Interesting idea.
Especially since we have automatic translation from RPythonic
application code to interpreter level.
Maybe not for now, but I'm cc-ing pypy-dev.

@rpythonic:-)

-- 
Christian Tismer :^)   
tismerysoft GmbH : Have a break! Take a ride on Python's
Johannes-Niemeyer-Weg 9A :*Starship* http://starship.python.net/
14109 Berlin : PGP key -> http://wwwkeys.pgp.net/
work +49 30 802 86 56  mobile +49 173 24 18 776  fax +49 30 80 90 57 05
PGP 0x57F3BF04   9064 F4E1 D754 C2FF 1619  305B C09C 5A3B 57F3 BF04
  whom do you want to sponsor today?   http://www.stackless.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: firebird and unicode

2005-05-23 Thread flupke
flupke wrote:


I solved it by getting the latest py files from CVS and overwriting the 
existing ones. It gave an Attribute error but that was gone after 
commenting this line:
#isc_info_isc_version =  _k.isc_info_isc_version

I'm not sure if this is a safe way of working. It's like jumping over a 
fence with barb wire. You know your balls might be in danger but 
sometimes you got to take a risk :)

I hope i don't end up singing with a funny voice ;)

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


Re: firebird and unicode

2005-05-23 Thread F. Petitjean
Le Mon, 23 May 2005 09:30:31 GMT, flupke a écrit :
> It's like jumping over a fence with barb wire.
> You know your balls might be in danger but 
> sometimes you got to take a risk :)
+1  QOTW

> 
> I hope i don't end up singing with a funny voice ;)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is Python suitable for a huge, enterprise size app?

2005-05-23 Thread Antoon Pardon
Op 2005-05-20, Dieter Maurer schreef <[EMAIL PROTECTED]>:
> "Fredrik Lundh" <[EMAIL PROTECTED]> writes on Thu, 19 May 2005 09:54:15 +0200:
>> ...
>> and unless your operating system is totally braindead, and thus completely 
>> unfit
>> to run huge enterprise size applications, that doesn't really matter much.  
>> leaks
>> are problematic, large peak memory use isn't.
>
> Could you elaborate a bit?
>
> Large peak memory use means that the application got a large
> address space. What garantees that the residual memory use
> (after the peak) is compact and not evenly spread across
> the address space.

Well nothing. But how do you want to return memory back
to the O.S. when the residual memory use isn't compact
and evenly spread across the address space?

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


what is addMethod ?

2005-05-23 Thread qwejohn
Hello,

   I saw some python open source project with many
self.addMethod() functions (with 3 paramters)

What does self.addMethod() is good for ?

 I had looked at documnetation (downloaded and grepped
all the pdf doc files)  and could not find a thing about
it ; nore did googling helped.

Regards,
John

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


Re: Python on a public library computer

2005-05-23 Thread Piet van Oostrum
There are several ssh and telnet applets on the web. Of course it depends
on the Java support in your IE.
-- 
Piet van Oostrum <[EMAIL PROTECTED]>
URL: http://www.cs.uu.nl/~piet [PGP]
Private email: [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is Python suitable for a huge, enterprise size app?

2005-05-23 Thread Paul Rubin
Antoon Pardon <[EMAIL PROTECTED]> writes:
> Well nothing. But how do you want to return memory back
> to the O.S. when the residual memory use isn't compact
> and evenly spread across the address space?

All large-scale language implementations with automatic storage
management that I know of use compacting storage schemes, e.g. copying
garbage collectors (maybe generational, multi-threaded/realtime, or
whatever).  I think Python will have to do the same, sooner or later.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to config a comserver in a customize dll?

2005-05-23 Thread Giles Brown
But just to muddy the waters, using py2exe you can package your COM
server as a .dll in its own right.

Cheers,
Giles Brown

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


Re: what is addMethod ?

2005-05-23 Thread F. Petitjean
Le 23 May 2005 02:40:57 -0700, [EMAIL PROTECTED] a écrit :
> Hello,
> 
>I saw some python open source project with many
> self.addMethod() functions (with 3 paramters)

Which "open source project" ? Which class in which module ?
> 
> What does self.addMethod() is good for ?
> 
Find where this method is defined : (with fgrep or findstr according to
your operating system) and then 
import NameOfModule
help(NameOfModule)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: what is addMethod ?

2005-05-23 Thread Leif K-Brooks
[EMAIL PROTECTED] wrote:
>I saw some python open source project with many
> self.addMethod() functions (with 3 paramters)
> 
> What does self.addMethod() is good for ?

It's not a standard method, so it's good for whatever the particular
class you were looking at was using it for. We might be able to tell you
more if you mentioned the specific script you saw it used in.
-- 
http://mail.python.org/mailman/listinfo/python-list


Com object questions

2005-05-23 Thread Gijs Korremans
Hi,

I'm still figuring out how I can use the win32com for the use of a com object 
which I think is made in VB

First I've created a file with MakePy
Then I used the following code to init the com object:
import win32com.client
Client = win32com.client.Dispatch("ClientModule.Client")

Then, when I want to use a function, for example this one:
ipaddr = kddClient.GetLocalIPAddress()
I get this error:
File 
"C:\Python23\lib\site-packages\win32com\gen_py\0F4570B8-4D39-47CD-84B4-8A424233EEBFx0x1x0.py",
 line 69, in GetLocalIPAddress
return self._ApplyTypes_(11, 1, (36, 0), (), 'GetLocalIPAddress', 
None,)
File "C:\Python23\lib\site-packages\win32com\client\__init__.py", line 
446, in _ApplyTypes_
return self._get_good_object_(self._oleobj_.InvokeTypes(dispid, 0, 
wFlags, retType, argTypes, *args),user, resultCLSID)
com_error: (-2147024809, 'The parameter is incorrect.', None, None)
I don't know which parameter is incorrect because the function doesn't need any 
parameters

and when I try to use a struct for the IP address using the following code:
ipaddr = win32com.client.Record("IPADDRESS_STRUCT", Client)
I get this message:
File "C:\Python23\lib\site-packages\win32com\client\__init__.py", line 
403, in Record
raise ValueError, "The structure '%s' is not defined in module 
'%s'" % (name, package)
ValueError: The structure 'IPADDRESS_STRUCT' is not defined in module 
''
I think this means that there is no struct IPADDRESS_STRUCT defined in the com 
object but when I'm going to the ComBrowser in PythonWin it is in there.

I'm using python 2.3 with pywin32 build 203

Does anybody know what i'm doing wrong?

Kind regards, 


Gijs

--
This message has been scanned for viruses and
dangerous content by Network Sentry, and is
believed to be clean.
http://www.networksentry.co.za

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


Re: Manipulating mailboxes

2005-05-23 Thread Maksim Kasimov

change header information, insert messages into a database, delete/add 
messages, should not store passwords for all users, ... and any things else you 
wish to do - if your OS is UNIX - just forward mail messages of some users to 
your python script (you don't need to write a daemon for this)
All you need is to place file ".forward" in users home directory, and write 
like this:
|/path/myscript.py

and chmod the script:
chmod 777 /path/myscript.py

Laszlo Zsolt Nagy wrote:
> 
> Hi All,
> 
> I need to create a daemon that sits on a server and forwards some 
> e-mails. (Well not only that, it needs to change header information 
> before forwarding and also insert messages into a database). The mailbox 
> module is fine but I do not see a way to delete/add messages - it is 
> ready only. The other possiblity is IMAP4 but it is bad because my 
> program should not store passwords for all users. I can only see one 
> solution right now:
> 
> 1. Make a copy of the mailbox
> 2. Truncate the mailbox
> 3. Process the messages in the copy and forward the e-mails by sending 
> out real e-mails.
> 
> But this looks so clumsy. Is there a way to delete/add messages to 
> mailboxes of different users, directly?
> 
> Thanks,
> 
>  Laci 2.0
> 


-- 
Best regards,
Maksim Kasimov
mailto: [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Test

2005-05-23 Thread Test
Its only test.
Please klick on a link to test:
http://www.surf-tipps.info/fclick/fclick.php?03

Thanks

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


What are OOP's Jargons and Complexities?

2005-05-23 Thread Xah Lee

What are OOP's Jargons and Complexities
Xah Lee, 20050128

The Rise of Classes, Methods, Objects

In computer languages, often a function definition looks like this:
subroutine f (x1, x2, ...) {
  variables ...
  do this or that
}

In advanced languages such as LISP family, it is not uncommon to define
functions inside a function. For example:
subroutine f (x1, x2, ...) {
  variables...
  subroutine f1 (x1...) {...}
  subroutine f2 (x1...) {...}
}

Often these f1 f2 inner functions are used inside f, and are not
relevant outside of f. Such power of the language gradually developed
into a style of programing. For example:
subroutine a_surface () {
  coordinatesList = ...;
  subroutine translate (distance) {...}
  subroutine rotate (angle) {..}
}

Such a style is that the a_surface is no longer viewed as a function.
But instead, a boxed set of functions, centered around a piece of data.
And, all functions for manipulating this piece of data are all embodied
in this function. For example:
subroutine a_surface (arg) {
  coordinatesList = ...
  subroutine translate (distance) {set coordinatesList to translated
version}
  subroutine rotate (angle) {set coordinatesList to rotated version}
  subroutine return () {return coordinatesList}

  if (no arg) {return coordinatesList}
else { apply arg to coordinatesList }
}

In this way, one uses a_surface as a data, which comes with its owe set
of functions:
mySurface = a_surface();
mySurface(rotate(angle));// now the surface data has been
rotated
mySurface(translate(distance));  // now its translated
newSurface = mySurface(return())

So now, a_surface is no longer viewed as a subroutine, but a boxed set
of things centered around a piece of data. All functions that work on
the data are included in the boxed set. This paradigm possible in
functional languages has refined so much so that it spread to other
groups and became known as Object Oriented Programing, and complete
languages with new syntax catered to such scheme emerged.

In such languages, instead of writing them like this:
mySurface = a_surface();
mySurface(rotate(angle));

the syntax is changed to like this, for example:
mySurface = new a_surface();
mySurfaceRotated = mySurface.rotate(angle);

In such languages, the super subroutine a_surface is no longer called a
function or subroutine. It is now called a “Class”. And now the
variable holding the function "mySurface = a_surface()" is now called a
“Object”. Subroutines inside the function a_surface() are no longer
called inner-subroutines. They are called “Methods”. The act of
assigning a super-subroutine to a variable is called instantiation.

This style of programing and language have become so fanatical that in
such dedicated languages like Java, everything in the language are
“Classes”. One can no longer just define a variable or subroutine.
Instead, one creates these meta-subroutine “Classes”. Everything
one do are inside Classes. And one assign Classes inside these Classes
to create “Objects”. And one uses “Methods” to manipulate
Objects. In this fashion, even basic primitives like numbers, strings,
and lists are no longer atomic entities. They are now Classes.

For example, in Java, a string is a class String. And inside the class
String, there are Methods to manipulate strings, such as finding the
number of chars, or extracting parts of the string. This can get very
complicated. For example, in Java, there are actually two Classes of
strings: One is String, and the other is StringBuffer. Which one to use
depends on whether you intend to change the data.

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 pure OOP languages:
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());
}
}

Here, the "new String" creates a String object. The "new
StringBuffer(40)" creates the changeable string object StringBuffer,
with room for 40 chars. "append" is a method of StringBuffer. It is
used to join two Strings.

Notice the syntax "c.append(a)", which we can view it as calling a
inner subroutine "append", on a super subroutine that has been assigned
to c, where, the inner subroutine modifies the inner data by appending
a to it.

And in the above Java example, StringBuffer class has another method
"toString()" used to convert this into a String Class, necessary
because System.out.println's parameter requires a String type, not
StringBuffer.

For a example of the complexity of classes and methods, see the Java
documentation for the StringBuffer class at
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/StringBuffer.html
(local copy)

In the same way, numbers in Java have become a formalization of many
c

What are OOP's Jargons and Complexities?

2005-05-23 Thread Xah Lee

What are OOP's Jargons and Complexities
Xah Lee, 20050128

The Rise of Classes, Methods, Objects

In computer languages, often a function definition looks like this:
subroutine f (x1, x2, ...) {
  variables ...
  do this or that
}

In advanced languages such as LISP family, it is not uncommon to define
functions inside a function. For example:
subroutine f (x1, x2, ...) {
  variables...
  subroutine f1 (x1...) {...}
  subroutine f2 (x1...) {...}
}

Often these f1 f2 inner functions are used inside f, and are not
relevant outside of f. Such power of the language gradually developed
into a style of programing. For example:
subroutine a_surface () {
  coordinatesList = ...;
  subroutine translate (distance) {...}
  subroutine rotate (angle) {..}
}

Such a style is that the a_surface is no longer viewed as a function.
But instead, a boxed set of functions, centered around a piece of data.
And, all functions for manipulating this piece of data are all embodied
in this function. For example:
subroutine a_surface (arg) {
  coordinatesList = ...
  subroutine translate (distance) {set coordinatesList to translated
version}
  subroutine rotate (angle) {set coordinatesList to rotated version}
  subroutine return () {return coordinatesList}

  if (no arg) {return coordinatesList}
else { apply arg to coordinatesList }
}

In this way, one uses a_surface as a data, which comes with its owe set
of functions:
mySurface = a_surface();
mySurface(rotate(angle));// now the surface data has been
rotated
mySurface(translate(distance));  // now its translated
newSurface = mySurface(return())

So now, a_surface is no longer viewed as a subroutine, but a boxed set
of things centered around a piece of data. All functions that work on
the data are included in the boxed set. This paradigm possible in
functional languages has refined so much so that it spread to other
groups and became known as Object Oriented Programing, and complete
languages with new syntax catered to such scheme emerged.

In such languages, instead of writing them like this:
mySurface = a_surface();
mySurface(rotate(angle));

the syntax is changed to like this, for example:
mySurface = new a_surface();
mySurfaceRotated = mySurface.rotate(angle);

In such languages, the super subroutine a_surface is no longer called a
function or subroutine. It is now called a “Class”. And now the
variable holding the function "mySurface = a_surface()" is now called a
“Object”. Subroutines inside the function a_surface() are no longer
called inner-subroutines. They are called “Methods”. The act of
assigning a super-subroutine to a variable is called instantiation.

This style of programing and language have become so fanatical that in
such dedicated languages like Java, everything in the language are
“Classes”. One can no longer just define a variable or subroutine.
Instead, one creates these meta-subroutine “Classes”. Everything
one do are inside Classes. And one assign Classes inside these Classes
to create “Objects”. And one uses “Methods” to manipulate
Objects. In this fashion, even basic primitives like numbers, strings,
and lists are no longer atomic entities. They are now Classes.

For example, in Java, a string is a class String. And inside the class
String, there are Methods to manipulate strings, such as finding the
number of chars, or extracting parts of the string. This can get very
complicated. For example, in Java, there are actually two Classes of
strings: One is String, and the other is StringBuffer. Which one to use
depends on whether you intend to change the data.

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 pure OOP languages:
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());
}
}

Here, the "new String" creates a String object. The "new
StringBuffer(40)" creates the changeable string object StringBuffer,
with room for 40 chars. "append" is a method of StringBuffer. It is
used to join two Strings.

Notice the syntax "c.append(a)", which we can view it as calling a
inner subroutine "append", on a super subroutine that has been assigned
to c, where, the inner subroutine modifies the inner data by appending
a to it.

And in the above Java example, StringBuffer class has another method
"toString()" used to convert this into a String Class, necessary
because System.out.println's parameter requires a String type, not
StringBuffer.

For a example of the complexity of classes and methods, see the Java
documentation for the StringBuffer class at
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/StringBuffer.html
(local copy)

In the same way, numbers in Java have become a formalization of many
c

Re: Manipulating mailboxes

2005-05-23 Thread Laszlo Zsolt Nagy
Maksim Kasimov wrote:

>change header information, insert messages into a database, delete/add 
>messages, should not store passwords for all users, ... and any things else 
>you wish to do - if your OS is UNIX - just forward mail messages of some users 
>to your python script (you don't need to write a daemon for this)
>All you need is to place file ".forward" in users home directory, and write 
>like this:
>|/path/myscript.py
>  
>

>and chmod the script:
>chmod 777 /path/myscript.py
>  
>
Oh, fantastic. :-) Then I can open stdin and read the e-mail message 
from there.
Thank you so much

Laci 2.0


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


minidom and DTD

2005-05-23 Thread Laszlo Zsolt Nagy

  Hi All,

How can I put the



thing into an XML created by xml.dom.minidom?

Of course I can parse the generated XML file and insert the DOCTYPE string
but there must be a standard way to do this...

Best,

   Laci 2.0


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


Re: what is addMethod ?

2005-05-23 Thread qwejohn
Thnks,
I wrongly took it for a standard method;
I found where it is defined (it's part of the project); Tnnks.

John

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


Strange behaviour of floating point constants in imported modules

2005-05-23 Thread Tomasz Lisowski
Hi,

We are distributing our Python application as the short main script (.py 
file) and a set of modules compiled to the .pyc files. So far, we have 
always treated .pyc files as portable between platforms, but recently we 
have discovered an annoying problem. In a module, there is the following 
code fragment:

Deg2Rad = math.pi/180.0
angleEPS = 0.5
angle0B = angleEPS*Deg2Rad

which calculates 'angle0B' as the angle of a half of a degree, converted 
to radians. The module has been compiled on an English Windows XP 
machine, and then tested on a Polish Windows XP workstation.

What was our astonishment, when various exceptions started to be raised 
on a test machine (no problem on the original English-version Windows 
XP). We have traced them to the fact, that both angleEPS and angle0B 
were found to be ZERO (!!!), whereas in reality, angle0B is about 0.008. 
And this all happened silently, without any error during the import of 
the module!

What's the reason of this error? I start thinking, that it may be 
related to the fact, that the decimal point on the Enlish Windows XP is 
the '.' character, and on the Polish one - ','.

Is there a good method to avoid this kind of problems? How to make such 
distributed modules really portable?

Thanks in advance
-- 
Tomasz Lisowski
-- 
http://mail.python.org/mailman/listinfo/python-list


overhead of starting threads

2005-05-23 Thread Will McGugan
Hi,

What is the overhead of starting threads in Python? Currently my app 
starts around 20 threads per second, but I'm considering creating a pool 
of a fixed number of threads and keeping them fed with data. But only if 
it would give me a noticeable performance boost.

Has anyone got any any experience in this area that they could share? - 
before I start investigating myself..

I'm running on Windows, if thats relevant.


Regards,

Will McGugan

-- 
http://www.willmcgugan.com
"".join( [ {'*':'@','^':'.'}.get(c,None) or chr(97+(ord(c)-84)%26) for c 
in "jvyy*jvyyzpthtna^pbz" ] )
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What are OOP's Jargons and Complexities?

2005-05-23 Thread Wibble
You're point being...?

I'm an old lisp hacker too, and lisp developed
objects too, because they're cool and useful (Flavors & CLOS).

Java has inner classes also, and nobody misses FLET & LABELS.

Limiting responsiblity and enhanced type safety, as well as
improved readablity are a win hands down over the bad old
days.

Lisp is not a more advanced language than Java.  Its 30+
years older and shows it in alot places.  Lisp has some
things I wish were in Java but the corralary holds true.

Object orient programming in Lisp is nice too.

Xah Lee wrote:
> What are OOP's Jargons and Complexities
> Xah Lee, 20050128
> 
> The Rise of Classes, Methods, Objects
> 
> In computer languages, often a function definition looks like this:
> subroutine f (x1, x2, ...) {
>   variables ...
>   do this or that
> }
> 
> In advanced languages such as LISP family, it is not uncommon to define
> functions inside a function. For example:
> subroutine f (x1, x2, ...) {
>   variables...
>   subroutine f1 (x1...) {...}
>   subroutine f2 (x1...) {...}
> }
> 
> Often these f1 f2 inner functions are used inside f, and are not
> relevant outside of f. Such power of the language gradually developed
> into a style of programing. For example:
> subroutine a_surface () {
>   coordinatesList = ...;
>   subroutine translate (distance) {...}
>   subroutine rotate (angle) {..}
> }
> 
> Such a style is that the a_surface is no longer viewed as a function.
> But instead, a boxed set of functions, centered around a piece of data.
> And, all functions for manipulating this piece of data are all embodied
> in this function. For example:
> subroutine a_surface (arg) {
>   coordinatesList = ...
>   subroutine translate (distance) {set coordinatesList to translated
> version}
>   subroutine rotate (angle) {set coordinatesList to rotated version}
>   subroutine return () {return coordinatesList}
> 
>   if (no arg) {return coordinatesList}
> else { apply arg to coordinatesList }
> }
> 
> In this way, one uses a_surface as a data, which comes with its owe set
> of functions:
> mySurface = a_surface();
> mySurface(rotate(angle));// now the surface data has been
> rotated
> mySurface(translate(distance));  // now its translated
> newSurface = mySurface(return())
> 
> So now, a_surface is no longer viewed as a subroutine, but a boxed set
> of things centered around a piece of data. All functions that work on
> the data are included in the boxed set. This paradigm possible in
> functional languages has refined so much so that it spread to other
> groups and became known as Object Oriented Programing, and complete
> languages with new syntax catered to such scheme emerged.
> 
> In such languages, instead of writing them like this:
> mySurface = a_surface();
> mySurface(rotate(angle));
> 
> the syntax is changed to like this, for example:
> mySurface = new a_surface();
> mySurfaceRotated = mySurface.rotate(angle);
> 
> In such languages, the super subroutine a_surface is no longer called a
> function or subroutine. It is now called a “Class”. And now the
> variable holding the function "mySurface = a_surface()" is now called a
> “Object”. Subroutines inside the function a_surface() are no longer
> called inner-subroutines. They are called “Methods”. The act of
> assigning a super-subroutine to a variable is called instantiation.
> 
> This style of programing and language have become so fanatical that in
> such dedicated languages like Java, everything in the language are
> “Classes”. One can no longer just define a variable or subroutine.
> Instead, one creates these meta-subroutine “Classes”. Everything
> one do are inside Classes. And one assign Classes inside these Classes
> to create “Objects”. And one uses “Methods” to manipulate
> Objects. In this fashion, even basic primitives like numbers, strings,
> and lists are no longer atomic entities. They are now Classes.
> 
> For example, in Java, a string is a class String. And inside the class
> String, there are Methods to manipulate strings, such as finding the
> number of chars, or extracting parts of the string. This can get very
> complicated. For example, in Java, there are actually two Classes of
> strings: One is String, and the other is StringBuffer. Which one to use
> depends on whether you intend to change the data.
> 
> 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 pure OOP languages:
> 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());
> }
> }
> 
> Here, the "new String" creates a String object. The "new
> StringBuffer(40)" creates the changeable string object StringBuffer,
> with room 

Access lotus notes using Python

2005-05-23 Thread Sateesh
Hi,
Is it possible to access Lotus notes using Python? Can anyone provide me
some pointers?

Thanks
Sateesh


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


Re: Com object questions

2005-05-23 Thread Roger Upole
Does IPADDRESSSTRUCT appear anywhere in the makepy-generated module ?
Specifically, there should be a RecordMap dict containing any defined 
Records
and their GUID's.

 Roger

"Gijs Korremans" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
Hi,

I'm still figuring out how I can use the win32com for the use of a com 
object which I think is made in VB

First I've created a file with MakePy
Then I used the following code to init the com object:
import win32com.client
Client = win32com.client.Dispatch("ClientModule.Client")

Then, when I want to use a function, for example this one:
ipaddr = kddClient.GetLocalIPAddress()
I get this error:
File 
"C:\Python23\lib\site-packages\win32com\gen_py\0F4570B8-4D39-47CD-84B4-8A424233EEBFx0x1x0.py",
 
line 69, in GetLocalIPAddress
return self._ApplyTypes_(11, 1, (36, 0), (), 'GetLocalIPAddress', None,)
File "C:\Python23\lib\site-packages\win32com\client\__init__.py", line 446, 
in _ApplyTypes_
return self._get_good_object_(self._oleobj_.InvokeTypes(dispid, 0, 
wFlags, retType, argTypes, *args),user, resultCLSID)
com_error: (-2147024809, 'The parameter is incorrect.', None, None)
I don't know which parameter is incorrect because the function doesn't need 
any parameters

and when I try to use a struct for the IP address using the following code:
ipaddr = win32com.client.Record("IPADDRESS_STRUCT", Client)
I get this message:
File "C:\Python23\lib\site-packages\win32com\client\__init__.py", line 403, 
in Record
raise ValueError, "The structure '%s' is not defined in module '%s'" % 
(name, package)
ValueError: The structure 'IPADDRESS_STRUCT' is not defined in module 
''
I think this means that there is no struct IPADDRESS_STRUCT defined in the 
com object but when I'm going to the ComBrowser in PythonWin it is in there.

I'm using python 2.3 with pywin32 build 203

Does anybody know what i'm doing wrong?

Kind regards,


Gijs

--
This message has been scanned for viruses and
dangerous content by Network Sentry, and is
believed to be clean.
http://www.networksentry.co.za




== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 
Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Shift-JIS to UTF-8 conversion

2005-05-23 Thread Jeff Epler
On Fri, May 20, 2005 at 12:16:15AM -0700, [EMAIL PROTECTED] wrote:
> Hello, I think the answer is basically correct but shift-jis is not a
> standard part of Python 2.3.

Ah, I was fooled --- I tested on Python 2.3, but my packager must have
included the codecs you went on to mention.

Jeff


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

Re: Access lotus notes using Python

2005-05-23 Thread Simon Brunning
On 5/23/05, Sateesh <[EMAIL PROTECTED]> wrote:
> Hi,
> Is it possible to access Lotus notes using Python? Can anyone provide me
> some pointers?

http://www.google.com/search?q=python+lotus+notes&btnI=Lucky

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


Re: Access lotus notes using Python

2005-05-23 Thread Kartic
The Great 'Sateesh' uttered these words on 5/23/2005 7:14 AM:
> Hi,
> Is it possible to access Lotus notes using Python? Can anyone provide me
> some pointers?
> 
> Thanks
> Sateesh
> 
> 

Yes, you can... You need the win32all distribution installed and you can 
access Notes using the COM interface (win32com.client).

Google for "Lotus Notes Python" gave the following as the first match.

http://www.dominopower.com/issuesprint/issue28/command.html

Dig around.

Win32-perl has some nice COM examples for accessing Notes also. You can 
convert the Perl-win32 examples to  Python rather easily without knowing 
much perl.

Cheers,
-Kartic
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Access lotus notes using Python

2005-05-23 Thread Peter Dembinski
"Sateesh" <[EMAIL PROTECTED]> writes:

> Hi,
> Is it possible to access Lotus notes using Python? Can anyone
> provide me some pointers?

jython + LN Java bindings may be usable

-- 
http://www.peter.dembinski.prv.pl
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Strange behaviour of floating point constants in imported modules

2005-05-23 Thread Jeff Epler
This may be relevant to the problems you're seeing:

https://sourceforge.net/tracker/?func=detail&atid=305470&aid=774665&group_id=5470

The short story, as the tracker item paints it, is that setting
LC_NUMERIC to anything other than 'C' can give results like the ones you
describe---Python itself should never do this, but third parties code
may.

A web search for python LC_NUMERIC should turn up more about this topic,
probably even some past threads on this mailing list/newsgroup.

Jeff


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

Re: Strange behaviour of floating point constants in imported modules

2005-05-23 Thread John Machin
On Mon, 23 May 2005 12:39:00 +0200, Tomasz Lisowski
<[EMAIL PROTECTED]> wrote:

>Hi,
>
>We are distributing our Python application as the short main script (.py 
>file) and a set of modules compiled to the .pyc files. So far, we have 
>always treated .pyc files as portable between platforms, 

There is no guarantee at all that a .pyc file is good for any purpose
outside the machine that produced it.  In practice, however, you
*should* be able to rely on no surprises if you have the same platform
and the same version of Python; do you?

How did you transfer the .pyc files from one box to the other? A
Windows installer? A ZIP file? FTP using text mode? Plain-text
attachments to an e-mail message?


>but recently we 
>have discovered an annoying problem. In a module, there is the following 
>code fragment:
>
>Deg2Rad = math.pi/180.0
>angleEPS = 0.5
>angle0B = angleEPS*Deg2Rad
>
>which calculates 'angle0B' as the angle of a half of a degree, converted 
>to radians. The module has been compiled on an English Windows XP 
>machine, and then tested on a Polish Windows XP workstation.
>
>What was our astonishment, when various exceptions started to be raised 
>on a test machine (no problem on the original English-version Windows 
>XP). We have traced them to the fact, that both angleEPS and angle0B 
>were found to be ZERO (!!!), whereas in reality, angle0B is about 0.008. 

What evidence do you have? Have you disassembled the .pyc file on both
boxes and diff'ed the results? Have you computed checksums on both
boxes?

>And this all happened silently, without any error during the import of 
>the module!
>
>What's the reason of this error? I start thinking, that it may be 
>related to the fact, that the decimal point on the Enlish Windows XP is 
>the '.' character, and on the Polish one - ','.

This is *extremely* unlikely. Firstly, you are (I understand) talking
about a .pyc file, that was produced on an English Windows box.  Even
though the "180.0" and the "0.5" are visible as character strings in
the .pyc file, Python sure doesn't use the locale when it loads a .pyc
file.

Secondly, even if you are talking about a .py file, Python takes
absolutely no notice of the locale when it compiles the .py file.
Polish programmers write "0.5", not "0,5". Read the language reference
manual, section 2.4.5 -- it uses ".", not "whatever the decimal point
character might be in your locale". If it did depend on locale, you
would need a locale declaration at the top of the file, if one wanted
.py files to be portable internationally; ever seen or heard of such a
declaration?

Thirdly, if the dot was interpreted as something other than a decimal
point, then what? Perhaps assign a tuple (0, 5), or perhaps a syntax
error; zero is achieved under what conditions?

It's more likely that the .pyc file has been damaged somehow. AFAIK
they don't have checksums.

>
>Is there a good method to avoid this kind of problems? How to make such 
>distributed modules really portable?

Distribute source. 

HTH,

John

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


Re: Multiple selections in Tix Hlist

2005-05-23 Thread Peter Saffrey
To answer my own question:

HList(selectmode="extended")

does all the work for you.

Peter

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


Re: I want to ask you the most important question of your life. The question is: Are you saved? It is not a question of how good you are, nor if you are a church member, but are you saved? Are you sure you will go to Heaven when you die? The reason some people don't know for sure if they are going to Heaven when they die is because they just don't know. The good news is that you can know for sure you are going to Heaven. May 22, 2005 12:10:55 pm

2005-05-23 Thread Linønut
[EMAIL PROTECTED] poked his little head through the XP firewall and said:

> THE MOST IMPORTANT QUESTION OF YOUR LIFE
>
> This is the most important question of your life.
>
> The question is: Are you saved?

Yeah!  I'm saved!  I use Linux!

Hallelujah!

-- 
When all you have is a hammer, everything looks like a nail.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: problem uploading ZIP file tp PyPI

2005-05-23 Thread John Machin
On Mon, 23 May 2005 15:04:27 +1000, richard
<[EMAIL PROTECTED]> wrote:

>John Machin wrote:
>> FYI, there are a few unreconstructed diehards out here who neither run
>> on a *x platform nor run bleeding-edge Python straight out of last
>> night's CVS.
>
>I think you need to pull your head in, mate.
>
>The bug you discovered in PyPI is plain and simple a bug in its attempts to
>discover whether an uploaded ZIP file was generated by distutils.
>
>It's a bug. It will get fixed.
>
>Get over your damn platform paranoia.
>
>

That remark was in response to Tony's seemingly *x-centric suggestion
to use "setup.py --format=gztar" which would have presented some
difficulties to a Windows-only person. Perhaps I should have festooned
it with smileys. In any case it was nothing to do with the bug and
nothing to do with you. I think you need to suck *your* scone in,
cobber :-)

Cheers,
John

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


ANNOUNCE: twill v0.7, scriptable Web testing

2005-05-23 Thread C. Titus Brown
ANNOUNCING twill v0.7.

twill is a simple Web scripting language built on top of Python and
mechanize.  It's designed for automated testing of Web sites, but
it may be useful for anybody who needs to deal with Web sites
(with e.g. logins and cookies) in a non-interactive manner.

twill is a reimplementation of Cory Dodt's PBP.

A twill script looks like this:

   # go to the /. login page
   go http://slashdot.org/login.pl

   # fill in the form
   fv 1 unickname test
   fv 1 upasswd test
   submit

   # ok, there's no such account ;). show error HTML.
   show

---

This is the first public release of twill, version 0.7.

(Tagline: "It seems usable to me, but then I'm its author.")

With this release, I'm looking for general feedback on usability, as
well as suggestions on additional use cases.

Download directly here:

 http://darcs.idyll.org/~t/projects/twill-0.7.tar.gz

Documentation is online at

 http://www.idyll.org/~t/www-tools/twill.html

---

Miscellaneous details:

twill is implemented in Python and uses pyparsing and mechanize.  In
addition to the existing simple command language, twill can easily be
extended with Python.  twill also provides a fairly simple and
well-documented wrapper around mechanize.

twill scripts can be recorded with maxq, although scripts may require
some hand tweaking at the moment.  See the twill documentation for
more information.

twill does not understand JavaScript, I'm sorry to say.

--titus, [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Binding the names in a module in a class instance

2005-05-23 Thread Neal Norwitz
Jacob H wrote:
> Hello all,
>
> I would like to be able to take a module full of class instances,
> functions, etc and bind all its names to a separate container class
in
> a different module. I have come up with the following way to do it..

[snip]

> I feel uneasy about this method. I foresee bad namespace clashes.
> What's a better way? :)

Perhaps this is more like what you are looking for:

import stuff  # stuff we want to copy
import everything # initially empty module where to store stuff

# loop over each attribute name in stuff
for attr in dir(stuff):
# skip over __special__ attributes, probably don't want them
if attr.startswith('__') and attr.endswith('__'):
continue

value = getattr(stuff, attr)
setattr(everything, attr, value)

You can add more checking for clashes or whatever by looking at the
attribute name (attr) which is a string.

hth,
n

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


Re: minidom and DTD

2005-05-23 Thread "Martin v. Löwis"
Laszlo Zsolt Nagy wrote:
> How can I put the
> 
> 
> 
> thing into an XML created by xml.dom.minidom?

You should put a DocumentType node into your
DocumentNode, and pass a qualifiedName of
"collection" and a systemId of "recipes.dtd"
to the createDocumentType call.

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


re[2]: Com object questions

2005-05-23 Thread Gijs Korremans


> Does IPADDRESSSTRUCT appear anywhere in the makepy-generated module ?
Specifically, there should be a RecordMap dict containing any defined 
Records
and their GUID's.

No it's not in the genereted module, but it is in the COM Browser so I'm sure 
the struct is in the com object
Maybe I can find out somewhere what the GUID's is and put it in the RecodMap 
manually?

   Roger

"Gijs Korremans" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
Hi,

I'm still figuring out how I can use the win32com for the use of a com 
object which I think is made in VB

First I've created a file with MakePy
Then I used the following code to init the com object:
import win32com.client
Client = win32com.client.Dispatch("ClientModule.Client")

Then, when I want to use a function, for example this one:
ipaddr = kddClient.GetLocalIPAddress()
I get this error:
File 
"C:\Python23\lib\site-packages\win32com\gen_py\0F4570B8-4D39-47CD-84B4-8A424233EEBFx0x1x0.py",
 
line 69, in GetLocalIPAddress
  return self._ApplyTypes_(11, 1, (36, 0), (), 'GetLocalIPAddress', None,)
File "C:\Python23\lib\site-packages\win32com\client\__init__.py", line 446, 
in _ApplyTypes_
  return self._get_good_object_(self._oleobj_.InvokeTypes(dispid, 0, 
wFlags, retType, argTypes, *args),user, resultCLSID)
com_error: (-2147024809, 'The parameter is incorrect.', None, None)
I don't know which parameter is incorrect because the function doesn't need 
any parameters

and when I try to use a struct for the IP address using the following code:
ipaddr = win32com.client.Record("IPADDRESS_STRUCT", Client)
I get this message:
File "C:\Python23\lib\site-packages\win32com\client\__init__.py", line 403, 
in Record
  raise ValueError, "The structure '%s' is not defined in module '%s'" % 
(name, package)
ValueError: The structure 'IPADDRESS_STRUCT' is not defined in module 
''
I think this means that there is no struct IPADDRESS_STRUCT defined in the 
com object but when I'm going to the ComBrowser in PythonWin it is in there.

I'm using python 2.3 with pywin32 build 203

Does anybody know what i'm doing wrong?

Kind regards,


Gijs <



Kind regards, 


Gijs 

--
This message has been scanned for viruses and
dangerous content by Network Sentry, and is
believed to be clean.
http://www.networksentry.co.za

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


Re: minidom and DTD

2005-05-23 Thread Laszlo Zsolt Nagy
Martin v. Löwis wrote:

>Laszlo Zsolt Nagy wrote:
>  
>
>>How can I put the
>>
>>
>>
>>thing into an XML created by xml.dom.minidom?
>>
>>
>
>You should put a DocumentType node into your
>DocumentNode, and pass a qualifiedName of
>"collection" and a systemId of "recipes.dtd"
>to the createDocumentType call.
>  
>
That worked, thank you.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: first release of PyPy

2005-05-23 Thread Rocco Moretti
Alex Stapleton wrote:
> The question still remains, can it run it's self? ;)
> 

I think they try, every once in a while, to self host. The only problem 
at this stage of the game is the ~2000x speed slowdown. Using that 
figure, a five second startup time for PyPy on CPython would take about 
3 hours for PyPy on PyPy on CPython (5s*2000). Running a 1 second (on 
CPython) Python program would take a month and a half for PyPy on PyPy 
on CPython. (1s*2000*2000)

Once they get the speed issue licked, the self hosting problems should 
be no trouble. ;)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What are OOP's Jargons and Complexities?

2005-05-23 Thread Mike Meyer
"Xah Lee" <[EMAIL PROTECTED]> writes:

So now we find out that Xah Lee is as ignorant of other programming
languages as he is of Python and Perl.

> In advanced languages such as LISP family, it is not uncommon to define
> functions inside a function. For example:
> subroutine f (x1, x2, ...) {
>   variables...
>   subroutine f1 (x1...) {...}
>   subroutine f2 (x1...) {...}
> }

Nested subroutines date back to Algol, which was first specified in
the 50s.

> So now, a_surface is no longer viewed as a subroutine, but a boxed set
> of things centered around a piece of data. All functions that work on
> the data are included in the boxed set. This paradigm possible in
> functional languages has refined so much so that it spread to other
> groups and became known as Object Oriented Programing, and complete
> languages with new syntax catered to such scheme emerged.

Actually, classes and other OO concepts come out of simulation programming,
not as an outgrowth of nested functions. Most of the features one
associates with OO languages were present in Simula.

Function nesting and classes were viewed as independent features. Some 
OO languages support nesting, others don't. I think it was Grace Murray
Hopper commenting on Ada who said that "With classes, nesting is for the
birds."

> This style of programing and language have become so fanatical that in
> such dedicated languages like Java, everything in the language are
> “Classes”.

Strictly speaking, this isn't true of *any* language. Even the most
fanatical of languages distinguish between classes, objects and
methods.

But IIRC, Java comes with a set of low-level types that don't have
classes associated with them.

> This Object Oriented Programing style and dedicated languages (such as
> C++, Java)

This is pretty sloppy english. You imply that C++, like Java, is pure OO
language - meaning that there are no freestanding functions or variables.
That's false.

> have become a fad like wild fire among the programing mass
> of ignoramuses in the industry. Partly because of the data-centric new
> perspective, partly because the novelty and mysticism of new syntax and
> jargonization.

Actually, C++ became popular because it promised access to the power of
OO programming while leveraging the programmers familiarity with C. In
reality, it combined the worst features of both. Java became popular
because it fixed some of the problems with C++ while leveraging
programmers familiarity with C++ and promising "run anywhere" capability.

Personally, I think that these two languages are good examples of
someones ability to design a popular language being much better than
their ability to design a good language. But that's a matter of opinion,
and as such is debatable.

> It is especially hyped by the opportunist Sun Microsystems with the
> inception of Java, internet, and web applications booms around 1995. At
> those times, OOP (and Java) were thought to revolutionize the industry
> and solve all software engineering problems, in particular by certain
> "reuse of components" concept that was thought to come with OOP.

At that time, OOP was pushing 30 years old. Some people were using it
and getting that component reuse that it promised. Others were using
it and discovering that designing reusable classes is *hard*. It was
clear to pretty much everyone that OOP wasn't a silver bullet.

> We now know that the jargon Class is originally and effectively just a
> boxed set of data and subroutines, all defined inside a subroutine. And
> the jargon "Object" is just a variable that has been set to this super
> subroutine. And the inner subroutines are what's called Methods.

This is simply ludicruously wrong.

> to be continued tomorrow.

Please don't waste our time.

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

detached subprocess

2005-05-23 Thread Robin Becker
After struggling with os.spawnxxx to get a detached process I tried using 
Pyhton2.4's new subprocess module.

I struggled with that as well even when trying to use the creation flags for 
DETACHED_PROCESS 0x8 and CREATE_NEW_PROCESS_GROUP = 0x200

I am using the following cgi script parent.cgi

#!c:/python24/python.exe -u
print 'content-type: text/plain'
print
print 'DONE'
import subprocess
pid = subprocess.Popen(['c:/python24/pythonw.exe',
 'c:\\tmp\\child.py', 'arg1', 'arg2'], creationflags=0x208).pid
print pid
#end of parent script


child is a simple time delay

#child.py
import time, sys, os
time.sleep(10)
print 'stdout IN THE CHILD'
print >>sys.stderr, 'stderr IN THE CHILD'
#end of child


When I run the parent.cgi script through apache I see no output in the browser 
for 10 seconds; when the child dies (as observed using procexp) I see the 
expected

DONE
3256

In other words it seems impossible to get standard subprocess.py to detach the 
child process properly.

However, if I hack subprocess.py to alter the bInheritHandles flag passed into 
CreateProcess (line 718) from the constant 1 to

not (creationflags & 0x8) and 1 or 0

Is this a buglet or a feature request? It seems subprocess punts on closefds 
for 
mswindows, but setting bInheritHandles to 0 seems to work fine ie when it is 0 
my test seems to indicate that the parent has finished and gone to heaven long 
before the child ends its sleep. Of course it may be that it's just the handles 
that are being held.
-- 
Robin Becker

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


Re: blabla

2005-05-23 Thread Peter Maas
Noud Aldenhoven schrieb:
> Python rulz and sorry for this spam...

news.test is made for testing :)

-- 
---
Peter Maas,  M+R Infosysteme,  D-52070 Aachen,  Tel +49-241-93878-0
E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64')
---
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Optimise Europython competition

2005-05-23 Thread Jacob Hallen
In article <[EMAIL PROTECTED]>,
Carl Friedrich Bolz  <[EMAIL PROTECTED]> wrote:
>Jacob Hallen wrote:
>> 2. A track should be continuous. Each track that is continuous gives you
>>10 points.
>
>What exactly do you mean by "continuous track"?

Continuous means that from the time of the first talk in the track until
all talks in the track have been given, there will be a talk from the track
in each time slot (in exceptional cases there can be an empty time slot
inserted to make things fit, but usually that is not needed.)

The main reason for this rule is that some people only come for a few
talks in a specific track, and they don't want to have to stay 3 days
because we scheduled some on Monday morning and the rest on Wednesday
morning.

Last year we even had 2 people driving down from Norway, paying the
270 Euro on-site fee, just to listen to a single talk. They then had
a chat with the speaker and went home, quite happy with their conference.

Jacob Hallén

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

Re: python24.zip

2005-05-23 Thread Scott David Daniels
Martin v. Löwis wrote:
> Dieter Maurer wrote:
> 
>>Really?
>>
>>Is the interpreter unable to call "C" functions ("stat" for example)
>>to determine whether an object exists before it puts it on "path".
> 
> What do you mean, "unable to"? It just doesn't.
In fact, the interpreter doesn't necessarily know when it is
affecting the path.

> Could it? Perhaps, if somebody wrote a patch.
> Would the patch be accepted? Perhaps, if it didn't break something
> else.
> 
> In the past, there was a silent guarantee that you could add
> items to sys.path, and only later create the directories behind
> these items. I don't know whether people rely on this guarantee.

If you only checked "lost" files/directories on the path a few
seconds later than the last time you checked, you might be able
to drive this "failed open" time down drastically without seriously
affecting those who care.  Such an implementation should have a
call which allowed you to "clear" the timestamps for the "known bad"
entries.

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


Re: detached subprocess

2005-05-23 Thread Robin Becker
Robin Becker wrote:
.
> before the child ends its sleep. Of course it may be that it's just the 
> handles 
> that are being held.

After further tests with procexp it seems that the parent is allowed to die, 
but 
its output is held up (perhaps apache is waiting on an eof) until the child 
dies.

It would seem prudent to allow the mswindows version to control the 
bInheritHandles flag in some way.
-- 
Robin Becker

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


No encodings after freezing

2005-05-23 Thread mmf
Hi.

I have the following script (for example):

#!/usr/bin/python
text = 'Hallo'
text_new = text.encode('utf_8')
print text_new

The I tried to "freeze" this script with cx_freeze 3.0.1 (command
./FreezePython example.py).
Everything worked finde, a binary was created correctly.

But everytime I run this binary the utf-8 encoding cannot be found.
(Also any other encoding like iso8859_15 cannot be found...)

What am I doing wrong?
Thank.

Best regards,
Markus

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


Re: SQL Query via python

2005-05-23 Thread Scott David Daniels
Steve Holden wrote:
> Jeff Elkins wrote:
>>... cursor.execute("SELECT name, month, day ,category, city "
>>   " FROM bday WHERE %s = %s", (arg1,arg2))
>> No results. However, if I hardcode the WHERE argument with a field name:
>>cursor.execute("SELECT name, month, day ,category, city "
>>   " FROM bday WHERE month = %s", (arg2,))
>> Works.
>>
> Because here you aren't trying to parameterize the name of a database 
> object.
> 
>> How can I code the left side of the WHERE clause so I can pass an 
>> arbitrary field name to search on?
>>
>>
> You might have to construct the SQL statement to include the names of 
> tables and columns. It's still better to use parameterization for data 
> substitutions, though, because then you don't have to perform any quoting.

I'm sure Steve knows this, but for those wondering:
 A database system will often produce an optimized execution plan
 from the first argument (and cache that plan).  The string had
 better be good enough for the DBMS to determine how to best perform
 the query.  This means only data can be parameterized, not table or
 field names).  The query plan includes things like which indexes to
 use and what tables to access in what order.

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


Re: None module reference

2005-05-23 Thread Peter Hansen
Stefan Seefeld wrote:
> In a python module of mine I import system modules
> ('sys', say) and then use them from within some functions.
> 
> However, during program termination I'm calling
> one such function and the module reference ('sys')
> is 'None' !

Are you running any daemon threads?  This can generally happen when a 
daemon thread continues to access module globals during the interpreter 
shutdown sequence.  At one stage all globals in all modules are rebound 
to None, and there's a chance some of your daemon thread code will 
execute just as this is occurring, resulting in that kind of error message.

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


Error sending message [1116860878726.2800.mailserver_papl] from [www.pansegroup.com]

2005-05-23 Thread www.pansegroup.com PostMaster
[<00>] V-POP3bounce: [EMAIL PROTECTED];Error=[550 Error: Invalid Attachment]


[<01>] Error sending message [1116860878726.2800.mailserver_papl] from 
[www.pansegroup.com].

ID:
Mail From: 
Rcpt To:   <[EMAIL PROTECTED]>
Server: [209.120.245.170]


[<02>] The reason of the delivery failure was:

550 Error: Invalid Attachment


[<05>] Here is listed the initial part of the message:

Received: from python.org (192.168.1.130:4513)
by smtp.pansegroup.com with [V-POP3Mail (Win32/Ix86) ESMTP Server]
id  for <[EMAIL PROTECTED]> from ;
Mon, 23 May 2005 20:37:58 +0530
From: [email protected]
To: [EMAIL PROTECTED]
Subject: MAIL TRANSACTION FAILED
Date: Mon, 23 May 2005 20:37:36 +0530
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="=_NextPart_000_0012_6513DF42.EC70CFD3"
X-Priority: 3
X-MSMail-Priority: Normal

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


Re: What are OOP's Jargons and Complexities?

2005-05-23 Thread Jonathan Bartlett
Mike Meyer wrote:
> "Xah Lee" <[EMAIL PROTECTED]> writes:
> 
> So now we find out that Xah Lee is as ignorant of other programming
> languages as he is of Python and Perl.

I think you're misreading some of what is being said.

> Nested subroutines date back to Algol, which was first specified in
> the 50s.

I think the author was speaking in terms of how high a level of a 
language it is, not necessarily how recent it is.

> Actually, classes and other OO concepts come out of simulation programming,
> not as an outgrowth of nested functions. Most of the features one
> associates with OO languages were present in Simula.

Again, I think the author was pointing out that it is an outgrowth 
logically, not necessarily historically.  There is a basic equivalence 
between a class and a group of functions closed over the same variables. 
  I mention something similar in an IBM DeveloperWorks article here:

http://www.ibm.com/developerworks/linux/library/l-highfunc.html

> Function nesting and classes were viewed as independent features. Some 
> OO languages support nesting, others don't. I think it was Grace Murray
> Hopper commenting on Ada who said that "With classes, nesting is for the
> birds."

Doesn't this quote show the opposite?

> Strictly speaking, this isn't true of *any* language. Even the most
> fanatical of languages distinguish between classes, objects and
> methods.

I think the point was that in Java everything is done within the context 
of a class.  You can define methods, but only as a part of a class.  You 
cannot define a function or even a variable that stands on its own.

> But IIRC, Java comes with a set of low-level types that don't have
> classes associated with them.

But still, it does not allow you, the programmer, to do the same.

Jon

Learn to program using Linux assembly language
http://www.cafeshops.com/bartlettpublish.8640017
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SQL Query via python

2005-05-23 Thread Austyn Bontrager
How about:

cursor.execute("""
SELECT name, month, day ,category, city FROM bday
WHERE %(col_name)s = %%s
""" % dict(col_name=arg1),
(arg2)
)

The "%(col_name)s" will be replaced by normal Python string 
substitution, while the "%%s" will be quoted by the db module.

Watch out for SQL injection in arg1, though! Maybe check beforehand that 
it is a string containing only word characters...

Jeff Elkins wrote:
> I'm attempting to pass an SQL query via the console:
> 
> $ ./getbd month 05
> 
> The arguments get seem to passed correctly (via print statements) and then:
> 
> cursor.execute ("""
>  SELECT name, month, day ,category, city FROM bday
>  WHERE %s = %s
>""",(arg1,arg2))
> 
> No results. However, if I hardcode the WHERE argument with a field name:
> 
>  cursor.execute ("""
>  SELECT name, month, day ,category, city FROM bday
>  WHERE month = %s
>""",(arg2))
> 
> It works.
> 
> How can I code the left side of the WHERE clause so I can pass an arbitrary 
> field name to search on?
> 
> 
> Thanks,
> 
> Jeff Elkins
> 
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Memory errors with large zip files

2005-05-23 Thread Marcus Lowland
Thank for the detailed reply John! I guess it turned out to be a bit
tougher than I originally thought :-)

Reading over your links, I think I better not attempt rewriting the
zipfile.py program... a little over my head :-). The best solution,
from everything I read seems to be calling an unzipper program from a
subprocess. I assume you mean using execfile()? I can't think of
another way.

Anyway, thank you very much for your help, it's been very educational.

Best regards,
Lorn

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


Re: SQL Query via python

2005-05-23 Thread Gerhard Haering
On Mon, May 23, 2005 at 04:12:31PM +, Austyn Bontrager wrote:
> How about:
> 
> cursor.execute("""
>   SELECT name, month, day ,category, city FROM bday
>   WHERE %(col_name)s = %%s
>   """ % dict(col_name=arg1),
>   (arg2)
>   )
> 
> The "%(col_name)s" will be replaced by normal Python string 
> substitution, while the "%%s" will be quoted by the db module.
> 
> Watch out for SQL injection in arg1, though! Maybe check beforehand that 
> it is a string containing only word characters...

Maybe what you really need is the ability to search for two fields, or
both fields?

Here's an approach that I usually use:

- Write a search function accepting the parameters you search for.
- If you fill one of the parameters with None (in SQL: NULL), you don't
  care for its value
- This way, you can narrow your search as much as you like

Here's a quick test script, using pysqlite2 to demonstrate the approach.
It's also not meant as production code, but at least it only works with
SQL parameter binding.

- SQLite uses :name for named parameters instead of %(name)s.
- locals() is a neat hack to access the local variables as a dictionary

#v+
from pysqlite2 import dbapi2 as sqlite

con = sqlite.connect(":memory:")
cur = con.cursor()
cur.execute("create table test(a, b)")
cur.execute("insert into test(a, b) values (1, 2)")
cur.execute("insert into test(a, b) values (1, 3)")
cur.execute("insert into test(a, b) values (2, 3)")

def search(a, b):
global cur
cur.execute("""
select a, b from test
where (:a is null or a=:a)
  and (:b is null or b=:b)
  """, locals())
return cur.fetchall()

print search(2, None)
print "-" * 50
print search(None, 3)
print "-" * 50
print search(2, 3)
#v-

-- Gerhard
-- 
Gerhard Häring - [EMAIL PROTECTED] - Python, web & database development


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

line-by-line output from a subprocess

2005-05-23 Thread Chermside, Michael
I am using the subprocess module to invoke a command-line utility and
process the output.

However, I would like to process the output line-by-line as it is
generated rather than
running the subprocess to completion and THEN processing the results.
So, for instance,
I'd like to write code like this:

all_files = []
import subprocess
subp = subprocess.Popen('dir', stdout=subprocess.PIPE)
for line in subp.stdout:
sys.stdout.print(line)
all_files.append(line)

...and have it print the lines to stdout one-by-one until the entire
list is
collected. (Pretend that 'dir' is VERY slow.)

The communicate() method in subprocess blocks until the subprocess has
exited... I'm sure there is some good reason for this behavior. But how
does
one achieve what I am trying to do?

(PS: this is on Windows... although I'd rather use an OS-agnostic
solution if
one exists.)

-- Michael Chermside






*
This email may contain confidential or privileged information. If you believe
 you have received the message in error, please notify the sender and delete 
the message without copying or disclosing it.
*

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


concurrent access to object file

2005-05-23 Thread Frank Abel
Hi all!
I will build a HTTPServer and dislike that one request is handled at a time
(synchronous). So I write:

class MyHTTPServer(SocketServer.ThreadingMixIn, BaseHTTPServer.HTTPServer):



For log the request and error I create a file and atteched it to the server
instance. Then the file log object can be see at RequestHandler instance
("self.server.log_file"). I overwrite in MyHTTPRequestHandler the methods
"log_message" to write instead of "sys.stderr" in my log file
"self.server.log_file".

My question is: Is posible that the log file crash (merge lines or some
other things) if two or more thread try to write in it "simultaneously" or
the write method of file object has a lock that prevent this?

Some other suggestion to get the aproach painted above?

Thank in advance
Frank





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


Re: first release of PyPy

2005-05-23 Thread Carl Friedrich Bolz
Rocco Moretti wrote:
> Alex Stapleton wrote:
> 
>>The question still remains, can it run it's self? ;)
>>

This allready worked in the past, though it doesn't at the moment.

> 
> 
> I think they try, every once in a while, to self host. The only problem 
> at this stage of the game is the ~2000x speed slowdown. Using that 
> figure, a five second startup time for PyPy on CPython would take about 
> 3 hours for PyPy on PyPy on CPython (5s*2000). Running a 1 second (on 
> CPython) Python program would take a month and a half for PyPy on PyPy 
> on CPython. (1s*2000*2000)
> 
> Once they get the speed issue licked, the self hosting problems should 
> be no trouble. ;)

Speed isn't even the biggest problem when running PyPy on itself. PyPy 
still 'fakes' some objects, e.g. borrows them from the underlying 
Python. This is mostly the case for things that have direct access to 
the OS, e.g. files. If you run PyPy on PyPy on CPython you try to fake 
the faked objects again, which gives trouble. Since we have to handle 
faked objects differently in the future anyway we decided that at the 
moment it isn't worth the effort to keep the self-hosting working.

Regards,

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


execution error

2005-05-23 Thread Ximo
Hello, I'm programing an advanced calculator, and I have many problems with 
the execution errors, specually with the division by 0.

And my question is how can show the execution error whitout exit of the 
program, showing it in the error output as

>>2+2
>>4
>>3*4
>>12
>>6/0
>>"Error: Division per 0"

Thank you. 


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


Terminating a thread from the parent

2005-05-23 Thread DE
Hello,

I have an app with embedded Python. Python scripts create their own
threads and I need to terminate these threads at the point where the
user wants to leave the application. I use threading.Thread as base
classes.

I have tried to use call the join method of the python thread objects
from C++. But although the call succeeds, the threads don't exit.

What is the proper way of doing this ? (e.g. how does the python shell
do this ? )

Thanks in advance,

Devrim.

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


Re: execution error

2005-05-23 Thread Paul Rubin
"Ximo" <[EMAIL PROTECTED]> writes:
> And my question is how can show the execution error whitout exit of the 
> program, showing it in the error output as...
> >>6/0
> >>"Error: Division per 0"

Trap the ArithmeticError exception and go by the name of the exception
class.  See the language ref manual about how exceptions work.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: execution error

2005-05-23 Thread Skip Montanaro

Ximo> And my question is how can show the execution error whitout exit
Ximo> of the program, showing it in the error output as

You need to catch ZeroDivisionError.  Here's a trivial example:

>>> try:
...   6/0
... except ZeroDivisionError:
...   print "whoops! divide by zero..."
... 
whoops! divide by zero...

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


Re: Running a python program during idle time only

2005-05-23 Thread los
Thanks for all the replies.

I did try using nice under windows.  I created a java program that
would just loop and print numbers on the screen.  Even when I ran that
simple program with nice, (lets call it program A) as soon as I started
the program the cpu went all the way to 100% usage.  Then when I ran
another program that did the same thing (lets call it program B),
program A halted to let B finish, then it started again.  Nevertheless
it still hogged all the cpu while I was using the computer.

For my indexing program I just wrote a simple python program and called
on the python os.walk() method to iterate through the drive and then it
connects to a database to store some information.  Then I wrote a
simple interface to connect to the database to search for files using
visual basic.  Once everything is indexed it works fine, but it would
be nice to have the program looping through and indexing the files all
the time to account to file updates, deletes, and relocation, but
without hurting the performance when I'm using the computer.

So really what I am looking for is some way to have the program only
start indexing and crawling through the hd after 5 minutes of no user
interaction with the computer.

I'm going to take a look at this CPU load possibility.  But I'm afraid
that this will work similarly to "nice" in which case it will let the
program kick in when the CPU isn't being used heavily, but I might
still be using the computer.  

thanks once again!

-los

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


Re: python24.zip

2005-05-23 Thread "Martin v. Löwis"
Scott David Daniels wrote:
>>> Is the interpreter unable to call "C" functions ("stat" for example)
>>> to determine whether an object exists before it puts it on "path".
>>
>>
>> What do you mean, "unable to"? It just doesn't.
> 
> In fact, the interpreter doesn't necessarily know when it is
> affecting the path.

Now I remember what makes this stuff really difficult: PEP 302
introduces path hooks (sys.path_hooks), allowing imports from
other sources than files. So the items on sys.path don't have
to be directory or file names at all, and importing from them
may still succeed if though stat fails.

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


Re: No encodings after freezing

2005-05-23 Thread "Martin v. Löwis"
mmf wrote:
> text_new = text.encode('utf_8')
[...]
> But everytime I run this binary the utf-8 encoding cannot be found.
> (Also any other encoding like iso8859_15 cannot be found...)
> 
> What am I doing wrong?

Codecs are modules (in the encodings package). So if the codecs
you need aren't frozen, they aren't available at run-time. OTOH,
freeze cannot "see" the import (since it doesn't know that the
argument to .encode is really similar to a module name), so
it won't include the modules. You need to give it an explicit
list of encodings you want to freeze.

Most likely, there is some explicit command line argument, but
alternatively, you could also put

if 0:
  import encodings.utf_8
  import encodings.iso8859_1
  # etc

into some source file.

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


Re: What are OOP's Jargons and Complexities?

2005-05-23 Thread Paul McGuire
Is this supposed to be some sort of wake-up call or call-to-arms to all
the CS lemmings who have been hoodwinked by Sun into the realm of
jargon over substance?

Please do some informed research and homework before spouting off with
such blather.  Sun Microsystems is hardly The Great Satan of OOP,
trying to foist object-speak on the rest of humanity.  The object
concepts of classes, methods, instances, inheritance, polymorphism,
etc. were already well on their way into the CS consciousness before
Java came on the scene.  To attempt to relate the emergence of object
concepts as starting with Java simply illustrates a lack of historical
awareness.  To omit so obvious a Java precursor as Smalltalk seriously
undermines any authority you may have once had on this topic.

It is easy to attack "terminology" as "jargon," but in fact, precise
definitions of terms help improve communication of complex concepts.
Unfortunately, some of the concepts *are* complex - we just recently on
this forum had someone ask about "polymorphism" when what they really
meant was "overloaded method signatures."  (It is even more unfortunate
that language features such as overloaded method signatures and
operator overloading get equated with OOP, simply because OO language
XYZ supports them.)  I would say that terminology becomes jargon when
it introduces new terms that do not really help describe any new
concepts, but simply raise an arbitrary barrier to new students of the
field.  And *any* complex field's terminology will be perceived as
jargon to those who have not done adequate study - are you about to
begin a parallel crusade to attack the jargon-spewing conspiracy among
quantum physicists, what with their terms of top, down, spin, charm,
muon, meson, lepton, etc.?

Your complaint about Java requiring all code to reside in a class is
not new.  It is a common newbie issue that one has to get past "static
void main(string[] args)" just to do a simple "Hello, World!".  But
this seems to be a minor point for someone as authoritative as yourself
to waste over 1000 words on.  All computing languages have good and bad
features.  Determining whether Java's "classes-only" language design is
"good" or "bad" is something of a point of view - let it go that some
folks find it overly purist and a nuisance, while others like the
uniformity of implementation.

You certainly seem to have a lot of energy and enthusiasm for these
topics.  It would be nice if you could find a way to illuminate and
educate, without falling prey to the urge to pontificate.  If you
really have some points to make, put away the breathless and profane
debate style - it just gets in the way of anything you're trying to
say.  Really, we are *mostly* adults here, and can make up our own
minds on most things.

-- Paul

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


Re: execution error

2005-05-23 Thread Paul McNett
Ximo wrote:
> Hello, I'm programing an advanced calculator, and I have many problems with 
> the execution errors, specually with the division by 0.
> 
> And my question is how can show the execution error whitout exit of the 
> program, showing it in the error output as


Wrap the math in a try/except block such as:

# Handle the zero-division plus maybe some others:
exceptions_to_handle = (ZeroDivisionError,)

try:
# do the math here
result = eval(my_math)
except exceptions_to_handle, e:
# gracefully handle here
result = str(e)
# show the result in the calculator here
print result

... or something like that. The point is you need to handle the zero 
division error while not handling other, unexpected error conditions.



-- 
pkm ~ http://paulmcnett.com

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


MUD Client and Python Plugin Framework

2005-05-23 Thread Discipulus
Hey,
I'm contemplating starting a MUD client in Python, and I would like to
make it so that people can write their own plugins, but I need ideas on
the framework. Any suggestions?

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


Problems installing SOAPpy.

2005-05-23 Thread Amitpython5



Hello,
 
  I'm having some problems installing SOAPpy module on my host, which 
has python 2.1
First when it attempts it import logging, it complains that classmethod is 
not defined. When I commented out (import logging), I got a different errror, 
about missing module thread.
Specifically:
Traceback (most recent call last):  File "setup.py", line 8, in 
?    from SOAPpy.version import __version__  File 
"SOAPpy/__init__.py", line 5, in ?    from 
Client  import *  File "SOAPpy/Client.py", 
line 57, in ?    from Parser  
import parseSOAPRPC  File "SOAPpy/Parser.py", line 10, in 
?    from wstools.XMLname import fromXMLname  File 
"SOAPpy/wstools/__init__.py", line 6, in ?    import 
WSDLTools  File "SOAPpy/wstools/WSDLTools.py", line 16, in 
?    from XMLSchema import XMLSchema, SchemaReader, 
WSDLToolsAdapter  File "SOAPpy/wstools/XMLSchema.py", line 18, in 
?    from threading import RLock  File 
"/usr/local/abinitio-V2-13-1/lib/python2.1/threading.py", line 5, in 
?    import threadImportError: No module named 
thread
Is there way I can install thread module?
Any help will be greatly appreciated.
Thanks,
Amit.
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: MUD Client and Python Plugin Framework

2005-05-23 Thread Jack Diederich
On Mon, May 23, 2005 at 10:51:47AM -0700, Discipulus wrote:
> Hey,
> I'm contemplating starting a MUD client in Python, and I would like to
> make it so that people can write their own plugins, but I need ideas on
> the framework. Any suggestions?

Use Lyntin? (http://lyntin.sourceforge.net/)
An extensible MUD client written in python.

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


Re: What are OOP's Jargons and Complexities?

2005-05-23 Thread Thomas G. Marshall
Paul McGuire coughed up:
> Is this supposed to be some sort of wake-up call or call-to-arms to
> all the CS lemmings who have been hoodwinked by Sun into the realm of
> jargon over substance?

...[rip]...

> You certainly seem to have a lot of energy and enthusiasm for these
> topics.  It would be nice if you could find a way to illuminate and
> educate, without falling prey to the urge to pontificate.  If you
> really have some points to make, put away the breathless and profane
> debate style - it just gets in the way of anything you're trying to
> say.  Really, we are *mostly* adults here, and can make up our own
> minds on most things.


Of the many things that bother me about his post is his tendency to voice 
his conclusions as if they would be universally arrived at given his data. 
{shrug}  Paying attention to this guy's post has proven to be a complete 
WOT.


-- 
I've seen this a few times--Don't make this mistake:

Dwight: "This thing is wildly available."
Smedly: "Did you mean wildly, or /widely/ ?"
Dwight: "Both!", said while nodding emphatically.

Dwight was exposed to have made a grammatical
error and tries to cover it up by thinking
fast.  This is so painfully obvious that he
only succeeds in looking worse.


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


Re: Running a python program during idle time only

2005-05-23 Thread James Carroll
I think you can keep your sleep commands in your program to keep it
from hogging the cpu even when you are running it as nice.

You know, even more important than cpu load (since your indexer is
accessing the hard drive, is hard drive access..)  You can monitor the
bytes  / second going to the hard drives using a WMI query similar to
the one that gives you LoadPercentage for a cpu.

If something Is trying to read and write to the hard drive, and your
indexer is going at the same time, hard drive head contention can slow
down both processess to a crawl.  (Say your program is in C:/apps  and
another program is simutaneously trying to read from C:/data... the
heads have to seek back and forth between the two spots on the hard
drive, and it's much faster to do all the C:/apps accesses and then
later do all the C:/data accesses.)

So I think my approach would be to have the indexer take about 10% of
cpu load while it is active, and as soon as another process is doing
enough reading / writing to the hard drive, stop and wait for about
five minutes... then continuing.

The screen saver idea is another good one.  I found this the other day...
  http://homepage.hispeed.ch/py430/python/win32screensaver-0.3.2.zip

The problem is that any potential user that really likes their pretty
screen saver (Helios under Ubuntu... droool slurp.)  then
they can't have both your indexer and their pretty screensaver active
during idle time.

-Jim


On 23 May 2005 10:32:18 -0700, los <[EMAIL PROTECTED]> wrote:
> Thanks for all the replies.
>
> I did try using nice under windows.  I created a java program that
> would just loop and print numbers on the screen.  Even when I ran that
> simple program with nice, (lets call it program A) as soon as I started
> the program the cpu went all the way to 100% usage.  Then when I ran


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


Fwd: Running a python program during idle time only

2005-05-23 Thread James Carroll
I think you can keep your sleep commands in your program to keep it
from hogging the cpu even when you are running it as nice.

You know, even more important than cpu load (since your indexer is
accessing the hard drive, is hard drive access..)  You can monitor the
bytes  / second going to the hard drives using a WMI query similar to
the one that gives you LoadPercentage for a cpu.

If something Is trying to read and write to the hard drive, and your
indexer is going at the same time, hard drive head contention can slow
down both processess to a crawl.  (Say your program is in C:/apps  and
another program is simutaneously trying to read from C:/data... the
heads have to seek back and forth between the two spots on the hard
drive, and it's much faster to do all the C:/apps accesses and then
later do all the C:/data accesses.)

So I think my approach would be to have the indexer take about 10% of
cpu load while it is active, and as soon as another process is doing
enough reading / writing to the hard drive, stop and wait for about
five minutes... then continuing.

The screen saver idea is another good one.  I found this the other day...
  http://homepage.hispeed.ch/py430/python/win32screensaver-0.3.2.zip

The problem is that any potential user that really likes their pretty
screen saver (Helios under Ubuntu... droool slurp.)  then
they can't have both your indexer and their pretty screensaver active
during idle time.

-Jim







On 23 May 2005 10:32:18 -0700, los <[EMAIL PROTECTED]> wrote:
> Thanks for all the replies.
>
> I did try using nice under windows.  I created a java program that
> would just loop and print numbers on the screen.  Even when I ran that
> simple program with nice, (lets call it program A) as soon as I started
> the program the cpu went all the way to 100% usage.  Then when I ran
> another program that did the same thing (lets call it program B),
> program A halted to let B finish, then it started again.  Nevertheless
> it still hogged all the cpu while I was using the computer.
>
> For my indexing program I just wrote a simple python program and called
> on the python os.walk() method to iterate through the drive and then it
> connects to a database to store some information.  Then I wrote a
> simple interface to connect to the database to search for files using
> visual basic.  Once everything is indexed it works fine, but it would
> be nice to have the program looping through and indexing the files all
> the time to account to file updates, deletes, and relocation, but
> without hurting the performance when I'm using the computer.
>
> So really what I am looking for is some way to have the program only
> start indexing and crawling through the hd after 5 minutes of no user
> interaction with the computer.
>
> I'm going to take a look at this CPU load possibility.  But I'm afraid
> that this will work similarly to "nice" in which case it will let the
> program kick in when the CPU isn't being used heavily, but I might
> still be using the computer.
>
> thanks once again!
>
> -los
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python24.zip

2005-05-23 Thread Robin Becker
Martin v. Löwis wrote:

> 
> 
> Now I remember what makes this stuff really difficult: PEP 302
> introduces path hooks (sys.path_hooks), allowing imports from
> other sources than files. So the items on sys.path don't have
> to be directory or file names at all, and importing from them
> may still succeed if though stat fails.
 so is there implication of multiplicative behaviour?

ie if we have N importers and F leading failure syspath entries before the 
correct one is found do we get order N*F failed stats/opens etc etc?

-- 
Robin Becker

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


how do you return an exit code with out exiting

2005-05-23 Thread Matthew Thorley
I wrote a simple python program that scrapes a web page every 30 secons
and dumps the result in a data base. I want to use my linux distros
build in init tools to run the script in the back ground as a daemon.
The problem is when I call the daemon script to background the program I
wrote it just hangs, waiting for my program to exit 1 or 0. My program
never does exits because its looping every 30 seconds.

Is there a way I can pass an exit value with out actualy exiting? or is
there are better way to do this?

Thanks
--
Matthew Thorley
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Access lotus notes using Python

2005-05-23 Thread Michael Ströder
Kartic wrote:
> The Great 'Sateesh' uttered these words on 5/23/2005 7:14 AM:
> 
>> Is it possible to access Lotus notes using Python? Can anyone provide me
>> some pointers?
> 
> Yes, you can... You need the win32all distribution installed and you can
> access Notes using the COM interface (win32com.client).

There could be even more cross-platform programming options depending
what "access Lotus Notes" really means for the original poster.

Depending on configuration a Domino server might have several Internet
protocol services for accessing Notes data (POP3, IMAP, LDAP, etc.).

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


Re: how do you return an exit code with out exiting

2005-05-23 Thread Grant Edwards
On 2005-05-23, Matthew Thorley <[EMAIL PROTECTED]> wrote:

> I wrote a simple python program that scrapes a web page every
> 30 secons and dumps the result in a data base. I want to use
> my linux distros build in init tools to run the script in the
> back ground as a daemon. The problem is when I call the daemon
> script to background the program I wrote it just hangs,
> waiting for my program to exit 1 or 0. My program never does
> exits because its looping every 30 seconds.
>
> Is there a way I can pass an exit value with out actualy exiting?

No.

> or is there are better way to do this?

Yes.  

To be a well-behavied daemon, you need to do the things
described in this howto:

  http://www.linuxprofilm.com/articles/linux-daemon-howto.html

Here are a couple references on how to do this in Python:

  http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/278731
  http://homepage.hispeed.ch/py430/python/
  
-- 
Grant Edwards   grante Yow!  Intra-mural sports
  at   results are filtering
   visi.comthrough th' plumbing...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What are OOP's Jargons and Complexities?

2005-05-23 Thread Peter Dembinski
"Xah Lee" <[EMAIL PROTECTED]> writes:

[snap]

put it on your blog

-- 
http://www.peter.dembinski.prv.pl
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Terminating a thread from the parent

2005-05-23 Thread Peter Hansen
DE wrote:
> I have an app with embedded Python. Python scripts create their own
> threads and I need to terminate these threads at the point where the
> user wants to leave the application. I use threading.Thread as base
> classes.
> 
> I have tried to use call the join method of the python thread objects
> from C++. But although the call succeeds, the threads don't exit.

join() waits until the thread terminates, but it doesn't cause it to 
terminate.

> What is the proper way of doing this ? (e.g. how does the python shell
> do this ? )

You have to poll for a termination request in the thread's main loop, 
and have the thread terminate itself (by returning from the target 
function or from the run() method, depending on which technique you used 
to create the Thread in the first place).  Threads cannot be forcibly 
terminated**.

There are numerous examples of this in the archives and probably a 
Cookbook recipe or two about it, if you look.  Otherwise someone can 
post an example here.

-Peter

** The exception is Threads on which .setDaemon(True) has been called, 
which will terminate immediately when the main thread exits (i.e. when 
the entire process terminates), though that might not be helpful to you 
in your particular situation.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: first release of PyPy

2005-05-23 Thread Shane Hathaway
Mike Meyer wrote:
> Basically, there's a *lot* of history in programming languages. I'd
> hate to see someone think that we went straight from assembler to C,
> or that people didn't understand the value of dynamic languages very
> early.

Yes, although I wasn't following historical events; I was following the
trends of what programmers in general have used.  Theory has always been
far ahead of practice... and generalizations are never correct. ;-)

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


Re: ANNOUNCE: twill v0.7, scriptable Web testing

2005-05-23 Thread Alex Stapleton
This is exactly the sort of thing ive been trying to avoid  
implementing my self for ages :) I will take it for a spin and see  
how it behaves, looks great though.

On 23 May 2005, at 05:07, C. Titus Brown wrote:

> ANNOUNCING twill v0.7.
>
> twill is a simple Web scripting language built on top of Python and
> mechanize.  It's designed for automated testing of Web sites, but
> it may be useful for anybody who needs to deal with Web sites
> (with e.g. logins and cookies) in a non-interactive manner.
>
> twill is a reimplementation of Cory Dodt's PBP.
>
> A twill script looks like this:
>
># go to the /. login page
>go http://slashdot.org/login.pl
>
># fill in the form
>fv 1 unickname test
>fv 1 upasswd test
>submit
>
># ok, there's no such account ;). show error HTML.
>show
>
> ---
>
> This is the first public release of twill, version 0.7.
>
> (Tagline: "It seems usable to me, but then I'm its author.")
>
> With this release, I'm looking for general feedback on usability, as
> well as suggestions on additional use cases.
>
> Download directly here:
>
>  http://darcs.idyll.org/~t/projects/twill-0.7.tar.gz
>
> Documentation is online at
>
>  http://www.idyll.org/~t/www-tools/twill.html
>
> ---
>
> Miscellaneous details:
>
> twill is implemented in Python and uses pyparsing and mechanize.  In
> addition to the existing simple command language, twill can easily be
> extended with Python.  twill also provides a fairly simple and
> well-documented wrapper around mechanize.
>
> twill scripts can be recorded with maxq, although scripts may require
> some hand tweaking at the moment.  See the twill documentation for
> more information.
>
> twill does not understand JavaScript, I'm sorry to say.
>
> --titus, [EMAIL PROTECTED]
> -- 
> http://mail.python.org/mailman/listinfo/python-list
>
>

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


Re: how do you return an exit code with out exiting

2005-05-23 Thread Matthew Thorley
thanks thats perfect!

Grant Edwards wrote:
> On 2005-05-23, Matthew Thorley <[EMAIL PROTECTED]> wrote:
> 
> 
>>I wrote a simple python program that scrapes a web page every
>>30 secons and dumps the result in a data base. I want to use
>>my linux distros build in init tools to run the script in the
>>back ground as a daemon. The problem is when I call the daemon
>>script to background the program I wrote it just hangs,
>>waiting for my program to exit 1 or 0. My program never does
>>exits because its looping every 30 seconds.
>>
>>Is there a way I can pass an exit value with out actualy exiting?
> 
> 
> No.
> 
> 
>>or is there are better way to do this?
> 
> 
> Yes.  
> 
> To be a well-behavied daemon, you need to do the things
> described in this howto:
> 
>   http://www.linuxprofilm.com/articles/linux-daemon-howto.html
> 
> Here are a couple references on how to do this in Python:
> 
>   http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/278731
>   http://homepage.hispeed.ch/py430/python/
>   
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: what is addMethod ?

2005-05-23 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit :
> Thnks,
> I wrongly took it for a standard method;
> I found where it is defined (it's part of the project); 

Then it would be nice to fully answer your question, so everyone may 
know what's this method and what it does (and what project it comes from).

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


Re: blabla

2005-05-23 Thread Jwaixs
Peter Maas wrote:

> Noud Aldenhoven schrieb:
>> Python rulz and sorry for this spam...
>
> news.test is made for testing :)
>

I really should appoligize for this spam, I though I couldn't post it
but actually it did. I was trying to get Pan running, but I couldn't
find a place where I could put my authorisation for the smtp server. So
I though I could post something and it would never be sent. But it
did...

Sorry,

Jwaixs

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


Re: Newbie python design question

2005-05-23 Thread Bruno Desthuilliers
Michael a écrit :
> Hi,
> I'm trying to write a script to parse a .cpp file and begin to create a
> 'translational unit'.
> To do this i need to:
> 
> Go through the file and remove all 'C' comments as
> /* Comment 1*/
> (can be on multiple lines)
> 
> Go through and remove all 'C++' comments, anything between // and '\n' char.
> 
> The start at the top, and work the way through, with the following valid
> terms:
> 
> #include 
> #include "filename"
> - copy the contents of filename to this point in the file and continue.
> 
> #define X Y
> -Store the term X,Y in DefineDictionary, then later if X is encountered,
> substitute Y.
> 
> namespace n
> {
> 
> };
> -a  namespace, can contain classes, functions and sub-namespaces
> 
> class c
> {
> 
> 
> };
> -a class.
> 
> 
> If i were to process this in C++, i would create some form of statemachine,
> similar to a regex engine... I would just like some ideas on the easiest way
> to implment this in python!!

I have no real answer, but well:
- there's a regexp module in the stdlib
- there's a quite nice FSM implementation on the Python Cookbook
- there are many Python-based parser generators

And I would of course recommand the reading of "Text Processing in 
Python"...

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


no win32com.client

2005-05-23 Thread plsullivan
In 2.4.1 the following is generated from a script that ran in 2.2:

import sys, string, os, win32com.client
ImportError: No module named win32com.client

thanks for any input,
Phil

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


Re: Memory errors with large zip files

2005-05-23 Thread John Machin
On 23 May 2005 09:28:15 -0700, "Marcus Lowland" <[EMAIL PROTECTED]>
wrote:

>Thank for the detailed reply John! I guess it turned out to be a bit
>tougher than I originally thought :-)
>
>Reading over your links, I think I better not attempt rewriting the
>zipfile.py program... a little over my head :-). The best solution,
>from everything I read seems to be calling an unzipper program from a
>subprocess. I assume you mean using execfile()? I can't think of
>another way.

Errr ... no, execfile runs a Python source file. 

Check out the subprocess module:

"""
6.8 subprocess -- Subprocess management 

New in version 2.4. 

The subprocess module allows you to spawn new processes, connect to
their input/output/error pipes, and obtain their return codes. This
module intends to replace several other, older modules and functions,
such as: 

os.system
os.spawn*
os.popen*
popen2.*
commands.*
"""


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


Re: no win32com.client

2005-05-23 Thread Matt

plsullivan wrote:
> In 2.4.1 the following is generated from a script that ran in 2.2:
>
> import sys, string, os, win32com.client
> ImportError: No module named win32com.client
>
> thanks for any input,
> Phil

Have you downloaded the win32com extensions?

http://starship.python.net/crew/mhammond/win32/Downloads.html

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


Problem with DispatchWithEvents

2005-05-23 Thread ccahoon
Traceback (most recent call last):
  File "windowedfax.py", line 223, in OnClick
self.iexplore = DispatchWithEvents("InternetExplorer.Application",
eventHandling)
  File "C:\Python24\Lib\site-packages\win32com\client\__init__.py",
line 268, in DispatchWithEvents
user_event_class.__init__(instance)
  File "windowedfax.py", line 178, in __init__
this.iexploreInstance = self
NameError: global name 'this' is not defined

Output completed (18 sec consumed) - Normal Termination

I am running Python 2.4 with the most recent 2.4 win32all package
installed.  This is straight from the installer.  I did a clean
installation of everything.

This was working before I tried an ActivePython distribution.  It
stopped working because ActivePython did not seem to support my SSL
usage in urllib, so I returned to a stock python distribution.

The line where I call DispatchWithEvents is like this:
iexplore = DispatchWithEvents("InternetExplorer.Application",
eventHandling)

where eventHandling is a functioning class to that purpose.

Thanks for any help, in advance.

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


Re: What are OOP's Jargons and Complexities?

2005-05-23 Thread Erik Max Francis
Jonathan Bartlett wrote:

> I think you're misreading some of what is being said.

I think you're giving the author too much credit.

-- 
Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/
San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
   Love is the true price of love.
   -- George Herbert
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: line-by-line output from a subprocess

2005-05-23 Thread Simon Percivall
Okay, so the reason what you're trying to do doesn't work is that the
readahead buffer used by the file iterator is 8192 bytes, which clearly
might be too much. It also might be because the output from the
application you're running is buffered, so you might have to do
something about that as well.

Anyway, if the output from the child application is unbuffered, writing
a generator like this would work:

def iterread(fobj):
stdout = fobj.stdout.read(1) # or what you like
data = ""
while stdout:
data += stdout
while "\n" in data:
line, data = data.split("\n", 1)
yield line
stdout = fobj.stdout.read(1)
if data:
yield data,

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


Re: no win32com.client

2005-05-23 Thread Do Re Mi chel La Si Do
Hi !

Or : http://sourceforge.net/project/showfiles.php?group_id=78018

@-salutations
-- 
Michel Claveau 


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


Re: first release of PyPy

2005-05-23 Thread Kay Schluehr

Carl Friedrich Bolz wrote:
> Rocco Moretti wrote:
> > Alex Stapleton wrote:
> >
> >>The question still remains, can it run it's self? ;)
> >>
>
> This allready worked in the past, though it doesn't at the moment.
>
> >
> >
> > I think they try, every once in a while, to self host. The only
problem
> > at this stage of the game is the ~2000x speed slowdown. Using that
> > figure, a five second startup time for PyPy on CPython would take
about
> > 3 hours for PyPy on PyPy on CPython (5s*2000). Running a 1 second
(on
> > CPython) Python program would take a month and a half for PyPy on
PyPy
> > on CPython. (1s*2000*2000)
> >
> > Once they get the speed issue licked, the self hosting problems
should
> > be no trouble. ;)
>
> Speed isn't even the biggest problem when running PyPy on itself.
PyPy
> still 'fakes' some objects, e.g. borrows them from the underlying
> Python.

Does it mean You create an RPython object that runs on top of CPython,
but is just an RPython facade wrapped around a CPython object? So You
have four kinds of Pythons:

RPy  -  translateable into LL code
APy  -  non-translateable but interpretable by translated RPy
RPy* -  non-translateable but consistent interface with RPy. Calls
APy*
APy* -  not translateable and not interpreteable by translated RPy

"Selfhosting" would imply vanishing RPy* and APy*. But the problem
seems to be that selfhosting must somehow be broken because the system
needs to interact with OS-dependend librarys. As long as You run the
system upon CPython the problem does not occur but once You drop it, a
kind of "extension objectspace" must be created which is translated
into code with nice interfacing properties. Or do You think that
RPython translations will be sufficient and another ext-objectspace is
just useless epi-cycling?

Kay

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


Re: Access lotus notes using Python

2005-05-23 Thread Kartic
The Great 'Michael Ströder' uttered these words on 5/23/2005 2:43 PM:
> Kartic wrote:
> 
>>The Great 'Sateesh' uttered these words on 5/23/2005 7:14 AM:
>>
>>
>>>Is it possible to access Lotus notes using Python? Can anyone provide me
>>>some pointers?
>>
>>Yes, you can... You need the win32all distribution installed and you can
>>access Notes using the COM interface (win32com.client).
> 
> 
> There could be even more cross-platform programming options depending
> what "access Lotus Notes" really means for the original poster.
> 
> Depending on configuration a Domino server might have several Internet
> protocol services for accessing Notes data (POP3, IMAP, LDAP, etc.).
> 
> Ciao, Michael.


So I guess it upto the Sateesh to tell whether he needs more information 
or not.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: overhead of starting threads

2005-05-23 Thread Simon Percivall
How much you gain by starting threads is also determined by what you're
doing in those threads. Remember (or learn): In CPython only one thread
at a time can execute python code, so depending on your task threading
might gain you little. If you're doing I/O or calling functions written
in C (and if they release the Global Intepreter Lock [GIL]) you might
gain a lot by using threads.

As for overhead: profile, profile, profile. You'll have to do sample
runs and find your sweet-spot. It all depends on what you're doing in
the threads.

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


Re: python24.zip

2005-05-23 Thread "Martin v. Löwis"
Robin Becker wrote:
> ie if we have N importers and F leading failure syspath entries before
> the correct one is found do we get order N*F failed stats/opens etc etc?

No. Each path hook is supposed to provide a decision as to whether this
is a useful item on sys.path only once; the importer objects themselves
are then cached (with some operation to clear the cache). Each path hook
may apply its own algorithm, e.g. looking at the syntactical structure
or the type of the sys.path item, so not all of them need stat/open
to determine whether they support the item.

The multiplicative behaviour rather results from the different type of
modules: each path item may carry .py, .pyc, .so, module.so, etc.

Regards,
Martin

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


Re: line-by-line output from a subprocess

2005-05-23 Thread Jp Calderone
On 23 May 2005 13:22:04 -0700, Simon Percivall <[EMAIL PROTECTED]> wrote:
>Okay, so the reason what you're trying to do doesn't work is that the
>readahead buffer used by the file iterator is 8192 bytes, which clearly
>might be too much. It also might be because the output from the
>application you're running is buffered, so you might have to do
>something about that as well.
>
>Anyway, if the output from the child application is unbuffered, writing
>a generator like this would work:
>
>def iterread(fobj):
>stdout = fobj.stdout.read(1) # or what you like
>data = ""
>while stdout:
>data += stdout
>while "\n" in data:
>line, data = data.split("\n", 1)
>yield line
>stdout = fobj.stdout.read(1)
>if data:
>yield data,
>

Or, doing the same thing, but with less code:

def iterread(fobj):
return iter(fobj.readline, '')

Haven't tried this on subprocess's pipes, but I assume they behave much the 
same way other file objects do (at least in this regard).

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


  1   2   >