Re: Running a python program during idle time only

2005-05-24 Thread Asbjørn Sæbø
los [EMAIL PROTECTED] writes:

 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.

Well, shouldn't it?  You don't want to waste CPU cycles.  If   your
program is niced to a low priority, it will run _only when more
important tasks doesn't run_.  I.e.: It stays out of the way when
higher priority processes claim the computer, while still utilizing
the rest of the computational power.

My experience is that properly niced processes can use almost 100
percent CPU, and still not have any noticeable effect on my other use
of the computer.

Asbj.S.
-- 
Asbjørn Sæbø, post.doc. 
Centre for Quantifiable Quality of Service in Communication Systems
Norwegian University of Science and Technology
URL: http://www.q2s.ntnu.no/ 
-- 
http://mail.python.org/mailman/listinfo/python-list


Automatic response to your mail (Error)

2005-05-24 Thread Webmaster
The automatic reply to this e-mail which you should have
received in response to your e-mail to [EMAIL PROTECTED] has not been defined.

Please contact [EMAIL PROTECTED] for assistance.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to use protocols.msn.FileSend and protocols.msnFileReceive

2005-05-24 Thread alex23
I think Joe was trying to encourage you to provide some more
information so that someone _can_ help you...

Mentioning in the subject that your question is about Twisted would
certainly be a step in the right direction, as would at _least_
touching on what you're intending to do, what you've tried, what
problems you've encountered, what documentation you've read and what
issues you're not following.

I have zero experience with Twisted, so I can't provide any help
myself, but clearing up your own question might encourage someone who
does know to answer.

In other words, the easier you make it for someone to answer your
question, the more inclined they'll be to answer it.

Good luck.

-alex23

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


Re: What are OOP's Jargons and Complexities?

2005-05-24 Thread Tassilo v. Parseval
Also sprach John W. Kennedy:

 alex goldman wrote:
 John W. Kennedy wrote:
 
 
Strong typing has been a feature of mainstream programming languages
since the late 1950's.
 
 I'm just curious, what do you mean by /strong/ typing, and which strongly
 typed languages do you know?

 Unfortunately, I have seen the meaning shift with the context. In Ada 
 '83, it means it is not possible to have the equivalent of a C 
 unprototyped function, and that mixed-type expressions tend to need 
 explicit casting. In other contexts (as here), I've seen it used to mean 
 simply that variables have definite types, and it is not possible 
 (except by the use of polymorphic classes) for a variable to change from 
 an integer to a float to a character string in the course of execution. 
 In this sense, compile-to-machine-code languages (ee.g., Fortran, COBOL, 
 C, C++, or Pascal), are generally strongly typed 

These are statically typed. The extent to which they are also strongly
typed differs: C++ is probably a little more strongly typed than C, but
by and large their typing is still fairly weak.

Most often, languages with strong typing can be found on the functional
front (such as ML and Haskell). These languages have a dynamic typing
system. I haven't yet come across a language that is both statically and
strongly typed, in the strictest sense of the words. I wonder whether
such a language would be usable at all.

Tassilo
-- 
use bigint;
$n=71423350343770280161397026330337371139054411854220053437565440;
$m=-8,;;$_=$n(0xff)$m,,$_=$m,,print+chr,,while(($m+=8)=200);
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What are OOP's Jargons and Complexities?

2005-05-24 Thread alex goldman
Tassilo v. Parseval wrote:

 Also sprach John W. Kennedy:
 
 alex goldman wrote:
 John W. Kennedy wrote:
 
 
Strong typing has been a feature of mainstream programming languages
since the late 1950's.
 
 I'm just curious, what do you mean by /strong/ typing, and which
 strongly typed languages do you know?

 Unfortunately, I have seen the meaning shift with the context. In Ada
 '83, it means it is not possible to have the equivalent of a C
 unprototyped function, and that mixed-type expressions tend to need
 explicit casting. In other contexts (as here), I've seen it used to mean
 simply that variables have definite types, and it is not possible
 (except by the use of polymorphic classes) for a variable to change from
 an integer to a float to a character string in the course of execution.
 In this sense, compile-to-machine-code languages (ee.g., Fortran, COBOL,
 C, C++, or Pascal), are generally strongly typed
 
 These are statically typed. The extent to which they are also strongly
 typed differs: C++ is probably a little more strongly typed than C, but
 by and large their typing is still fairly weak.
 
 Most often, languages with strong typing can be found on the functional
 front (such as ML and Haskell). These languages have a dynamic typing
 system. 

No, ML  Haskell are strongly and statically typed. Read this paper if
interested:

http://research.microsoft.com/Users/luca/Papers/TypeSystems.pdf


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


Re: Access lotus notes using Python

2005-05-24 Thread Sateesh
Hi,
What I am trying to do is to retrieve data from Lotus Notes Domino server
and display the results in some specific format. I initially thought of
doing it using Java JDBC (specifically thru JdbcDomino.jar file), but was
not successful in getting the jar file (looks like IBM has removed the
support for JDBC for LotusNotes).
So now I am trying Python to get my work done. I downloaded pywin and
installed it. I am trying ways to connect to the Domino server, but could
not get hold of the API to do so. Also pywin itself seems to be having lots
of bugs.

Any help is appreciated.

regards,
Sateesh

Kartic [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 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: Terminating a thread from the parent

2005-05-24 Thread flupke
DE wrote:
 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.
 

I found this example somewhere. It shows how you terminate a thread.
As Peter said, it's the thread that terminates itself.

#!/usr/bin/env python

testthread.py
An example of an idiom for controling threads

Doug Fort
http://www.dougfort.net


import threading

class TestThread(threading.Thread):
 
 A sample thread class
 

 def __init__(self):
 
 Constructor, setting initial variables
 
 self._stopevent = threading.Event()
 self._sleepperiod = 1.0

 threading.Thread.__init__(self, name=TestThread)

 def run(self):
 
 overload of threading.thread.run()
 main control loop
 
 print %s starts % (self.getName(),)

 count = 0
 while not self._stopevent.isSet():
 count += 1
 print loop %d % (count,)
 self._stopevent.wait(self._sleepperiod)

 print %s ends % (self.getName(),)

 def join(self,timeout=None):
 
 Stop the thread
 
 self._stopevent.set()
 threading.Thread.join(self, timeout)

if __name__ == __main__:
 testthread = TestThread()
 testthread.start()

 import time
 time.sleep(10.0)

 testthread.join()

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


Re: Access lotus notes using Python

2005-05-24 Thread Thor Arne Johansen
Sateesh wrote:
 Hi,
 Is it possible to access Lotus notes using Python? Can anyone provide me
 some pointers?
 
 Thanks
 Sateesh
 
 

NotesSQL is an ODBC driver for Notes.

Using NotesSQL and a python odbc connection you can use the standard 
python db-api2 to access tables.

(Examples of odbc connection: mxODBC or the odbc provided by win32all)

HTH,

Thor Arne Johansen
Technical Director
Ibas AS

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


Re: Access lotus notes using Python

2005-05-24 Thread [EMAIL PROTECTED]
try this

import win32com.client
session = win32com.client.Dispatch('Lotus.NotesSession')
session.Initialize(r'')
db = session.GetDatabase('',r'.nsf')
view = db.GetView(r'')
doc = view.GetFirstDocument()
print doc.GetFirstItem('ii').Values

domino return string as unicode

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


Re: What are OOP's Jargons and Complexities?

2005-05-24 Thread Tassilo v. Parseval
Also sprach alex goldman:

 Tassilo v. Parseval wrote:

 Most often, languages with strong typing can be found on the functional
 front (such as ML and Haskell). These languages have a dynamic typing
 system. 

 No, ML  Haskell are strongly and statically typed. Read this paper if
 interested:

You're right, their type system is in fact static. To me they never had
a very static feel though which is why I get their classification wrong
most of the time. LISP would have been an example for strongly and
dynamically typed.

Tassilo
-- 
use bigint;
$n=71423350343770280161397026330337371139054411854220053437565440;
$m=-8,;;$_=$n(0xff)$m,,$_=$m,,print+chr,,while(($m+=8)=200);
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: searching substrings with interpositions

2005-05-24 Thread bplumhoff
Hello Giorgi,

I suggest to google for python boyer moore to get a fast
implementation of a string search algorithm in Python (the Boyer-Moore
algorithm).

One promising hit seems to be:
http://www.egenix.com/files/python/mxTextTools.html

HTH,
Bernd

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


Re: searching substrings with interpositions

2005-05-24 Thread Kent Johnson
[EMAIL PROTECTED] wrote:
 hi everyone.
 a problem:
 two binary strings, a=0101 b=0100;
 i search a function f(a,b) that gives 1 if a is contained in b with
 any sub strings interposed.
 in this example a in contained cause 0100 but also
 10100
  but also 10100 but also 0100 etc
 any idea?
 Thanx in advance.
 Giorgi Borghi

You can do this easily with regular expressions though I guess may be poor with 
long strings:
   import re
   re.search('0.*1.*0.*1', '0100')
_sre.SRE_Match object at 0x008D9BF0
   _.span()
(0, 10)
Put the chars of the search string in groups if you need to know where they 
were found.

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


Melbourne (Australia) Python User Group

2005-05-24 Thread Anthony
Hi all,

I'm interested in starting a Python user group in Melbourne,
Australia. So far there seems to have been a lot of interest from
various parties, but for whatever reasons it's fizzled out. So I've
decided that if there's going to be a user group, I'll have to start
it myself (hopefully without the meetup.com albatross).

If you're in Melbourne, you're a python programmer and you're
interested in meeting up, drop me an email and let me know. I'll
probably also contact the Linux user groups in the area, but if you
know of any other groups that would be interested, please let me know.
If you want to forward this email on to other people or groups, feel
free to do so.

Thanks,

Anthony

-- 
-
 HyPEraCtiVE? HeY, WhO aRE YoU cALliNg HypERaCtIve?!
 [EMAIL PROTECTED]
-
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What are OOP's Jargons and Complexities?

2005-05-24 Thread Joe Smith
Xah Lee wrote:

 The Rise of Classes, Methods, Objects

1) Most of the information you posted was incomplete and much of
it is just plain wrong.

2) What you posted was not perl related.

Are you deliberately trying to make yourself a laughingstock?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Access lotus notes using Python

2005-05-24 Thread jm
Lotus Domino Designer 6.5.1 Help (instaled by notesdesigner)

see section LotusScript/COM/OLE Classes   LotusScript Classes A-Z

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


Re: searching substrings with interpositions

2005-05-24 Thread Claudio Grondi
 i search a function f(a,b) that gives 1 if a is contained in b with
 any sub strings interposed.

If I understand it right, it should be something
like this:

def blnFindCharSequenceAevenIfSpreadOverEntireStringB(strA, strB):
  intNoOfCharsFound = 0
  intPtrToBeginOfSubsectionOfB = 0
  intLenA = len(strA)
  intLenB = len(strB)
  blnStrAinB = False
  for chrA in strA:
blnFoundChrA = False
# print chrA
for indxToB in range(intPtrToBeginOfSubsectionOfB, intLenB):
  if(chrA == strB[indxToB]):
intNoOfCharsFound += 1
# print,chrA, strB[indxToB], indxToB
intPtrToBeginOfSubsectionOfB = indxToB + 1
blnFoundChrA = True
break
  #:if
#:for
if(intNoOfCharsFound == intLenA):
  blnStrAinB = True
  print sequence '%s' found in '%s'%(strA, strB)
  break
#:if
if(blnFoundChrA == False):
  break
#:if
  #:for
  if  blnStrAinB == False:
  print sequence '%s' not in '%s'%(strA, strB)
  #:if
#:def

strA = 0101
strB = 0100
blnFindCharSequenceAevenIfSpreadOverEntireStringB(strA, strB)

strA = 010101
strB = 0100
blnFindCharSequenceAevenIfSpreadOverEntireStringB(strA, strB)

Note: code above is intended to help clarify things only,
so that a bunch of examples can be tested.
If you need production quality code, maybe someone else
can provide it.

Is it what you are looking for?

By the way:
it looks to me like a standard problem while
comparing DNA sequences, so I suppose
that there are ready to use fast libraries
providing such kind of function.

Claudio

[EMAIL PROTECTED] schrieb im Newsbeitrag
news:[EMAIL PROTECTED]
 hi everyone.
 a problem:
 two binary strings, a=0101 b=0100;
 i search a function f(a,b) that gives 1 if a is contained in b with
 any sub strings interposed.
 in this example a in contained cause 0100 but also
 10100
  but also 10100 but also 0100 etc
 any idea?
 Thanx in advance.
 Giorgi Borghi




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


reg python related job searching

2005-05-24 Thread praba kar
Dear All,

Can any one guide me how to get python
related jobs?.  Actually Now I am
in Python web programming field.
I have technical knowledge about Python,
ZOPE and Twisted-web(Twisted Python) with 1 year exp..




Yahoo! India Matrimony: Find your life partner online
Go to: http://yahoo.shaadi.com/india-matrimony
-- 
http://mail.python.org/mailman/listinfo/python-list


Hacking the scope to pieces

2005-05-24 Thread Hugh Macdonald
We're starting to version a number of our python modules here, and I've
written a small function that assists with loading the versioned
modules...

A module would be called something like: myModule_1_0.py

In anything that uses it, though, we want to be able to refer to it
simply as 'myModule', with an environment variable (MYMODULE_VERSION
- set to 1.0) that defines the version.

I've written a module called 'moduleLoader' with the follwing function
in:

def loadModule(module, version, v = globals()):
  import compiler
  loadStr = import %s_%s as %s % (module, version.replace(., _),
module)
  eval(compiler.compile(loadStr, /tmp/%s_%s_errors.txt % (module,
version.replace(., _)), single))
  v[module] = vars()[module]


The ideal situation with this would be to be able, in whatever script,
to have:

import moduleLoader
moduleLoader.loadModule(myModule, os.getenv(MODULE_VERSION))


However, this doesn't work. The two options that do work are:

import moduleLoader
moduleLoader.loadModule(myModule, os.getenv(MODULE_VERSION),
globals())


import moduleLoader
moduleLoader.loadModule(myModule, os.getenv(MODULE_VERSION))
from moduleLoader import myModule


What I'm after is a way of moduleLoader.loadModule working back up the
scope and placing the imported module in the main global scope. Any
idea how to do this?


--
Hugh Macdonald

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


ANN: Leo 4.3 final

2005-05-24 Thread Edward K. Ream
Leo 4.3 final is now available at http://sourceforge.net/projects/leo/

Leo 4.3 is here after almost five months of work.

The defining features of Leo 4.3:
-
1. Leo now stores options in @settings trees, that is, outlines whose 
headline is '@settings'. When opening a .leo file, Leo looks for @settings 
trees not only in the outline being opened but also in various 
leoSettings.leo files. Users can create arbitrarily complex user options 
with @settings trees.

2. The Preferences command temporarily replaces the outline pane with an 
outline showing all the @settings trees in effect. The Preferences command 
also replaces the body pane with a settings pane. This settings pane 
allows you to change the settings selected in the outline pane using 
standard gui widgets.

3. Leo now stores recent files information in .leoRecentFiles.txt files.

4. Leo's read/write code in leoAtFile.py has been rewritten to support 
user-defined tangling and untangling. This is a major cleanup of Leo's core.

5. Leo now contains an excellent Plugins Manager plugin. This plugin enables 
and disables plugins automatically and tells you everything you need to know 
about each plugin. This plugin also lets you download plugins from Leo's cvs 
site.

6. You can install third-party extensions in Leo's extensions directory. Leo 
will attempt to import such extensions from the extensions directory when 
normal imports fail. The distribution contains Python Mega Widgets in the 
extensions directory.

What people are saying about Leo

Another day, another breakthrough using Leo--now I realize Leo is the best 
URL bookmark manager there is. No more bookmarks menus or favorites lists 
inside the browser for me. With the @url directive I can just double click 
on the URL to open it in my browser. Leo lets me arrange the URLs in a 
hierarchy (or multiple hierarchies), attach notes to them, save clippings of 
things I read on the sites. It's sooo much better than anything the browsers 
have built in and it lets me easily use different browsers on different 
platforms and different machines (try that with the browsers' built-in 
bookmark managers). -- Dan Winkler

I am an amateur photographer. I use plain old 35mm. film for my pictures. 
Over the weekend, I used Leo to organize my lists of pictures. It is quite 
helpful--I can have separate nodes for pictures I have enlarged, as well as 
pictures I have submitted to our local camera club. Thanks! -- Rich Reis

Cloning is pure genius!... Leo's cloning facility, allows me to create 
several views on the CFA course material. My main view follows the 
prescribed study guide. Another view is organized like the textbooks. Yet 
another gives me a glossary of terms. And when I'm done, I'll have some nice 
libraries...I can re-use later in other projects. -- Michael Manti

More quotes at: http://webpages.charter.net/edreamleo/testimonials.html

What makes Leo special?
---
- Leo's outlines add a new dimension to programming.
- Leo shows you your code and data the way _you_ want to see them.
- Leo extends, completes and simplifies literate programming.
- Leo's script buttons bring scripts to data.

What is Leo?

- A programmer's editor, an outlining editor and a flexible browser.
- A literate programming tool, compatible with noweb and CWEB.
- A data organizer and project manager. Leo provides multiple views
  of projects within a single outline.
- Fully scriptable using Python. Leo saves its files in XML format.
- Portable. leo.py is 100% pure Python.
- Open Software, distributed under the Python License.

Leo requires Python 2.2.1 or above and tcl/tk 8.4 or above.
Leo works on Linux, Windows and MacOs X.

Links:
--
Leo:  http://webpages.charter.net/edreamleo/front.html
Home: http://sourceforge.net/projects/leo/
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
CVS:  http://sourceforge.net/cvs/?group_id=3458
Quotes:   http://webpages.charter.net/edreamleo/testimonials.html


Edward K. Ream   email:  [EMAIL PROTECTED]
Leo: Literate Editor with Outlines
Leo: http://webpages.charter.net/edreamleo/front.html



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


IRIX MipsPro compiler chokes on Python.h

2005-05-24 Thread Bram Stolk
Hi there,

I just built and installed Python-2.4.1 on my Irix machine.
My compiler, the MipsPro compiler, chokes on the Python.h include file,
as demonstrated here:


$ CC -v
MIPSpro Compilers: Version 7.41
$ python -V
Python 2.4.1
$ cat l.cxx
#include Python.h

int main()
{
   return 0;
}

$ CC -I $HOME/include/python2.4 l.cxx
cc-1311 CC: ERROR File = /usr/include/sys/time.h, Line = 186
   The indicated linkage specification is incompatible with previous select
   (declared at line 479 of /usr/include/unistd.h).

   static int select(
  ^

1 error detected in the compilation of l.cxx.

Has anyone experienced the same?
How do I solve this?

Thanks,

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


staticmethod and classmethod

2005-05-24 Thread C Gillespie
Hi,

Does anyone know of any examples on how ( where) to use staticmethods and
classmethods?

Thanks

Colin


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


Re: Python DOM

2005-05-24 Thread Drazen Gemic
On Mon, 23 May 2005 22:37:09 -0700, [EMAIL PROTECTED] wrote:

 textNode = yourDocumentElement.createTextNode(the content)
 yourElement.appendChild(textNode)

Thanks, it works, but 'yourDocumentElement' needs to be of type
'document'. The name leads to conclusion that it needs to be
a root element of the document.

DG


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


Re: What are OOP's Jargons and Complexities?

2005-05-24 Thread Andreas Rottmann
Wibble [EMAIL PROTECTED] writes:

 Java or even C is more strongly typed than lisp or tcl which
 dont really have a concept of a typed variable.
 Lisp only does runtime type checking unless you do wierd
 unnatural things.

You get terminology totally wrong here. As already said, Lisp is
stronger typed than C, but C is statically typed, whereas Lisp is
dynamically typed. In Lisp (or Scheme), all variables have types:

(define foo #(1 2 3))
(vector? foo) = #t
(boolean? foo) = #t

See http://cliki.tunes.org/Type%20System.

Rotty
-- 
Andreas Rottmann | [EMAIL PROTECTED]  | [EMAIL PROTECTED] | [EMAIL 
PROTECTED]
http://yi.org/rotty  | GnuPG Key: http://yi.org/rotty/gpg.asc
Fingerprint  | DFB4 4EB4 78A4 5EEE 6219  F228 F92F CFC5 01FD 5B62
v2sw7MYChw5pr5OFma7u7Lw2m5g/l7Di6e6t5BSb7en6g3/5HZa2Xs6MSr1/2p7 hackerkey.com

Python is executable pseudocode, Perl is executable line-noise.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SQL Query via python

2005-05-24 Thread Frithiof Andreas Jensen

Jeff Elkins [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Just as an fyi:

 In one weekend I have gone from knowing zip about SQL/Python to
implementing
 code on my personal server that emails info to family about birthdays and
 such.

Actually - http://www.pythonweb.org/ will handle the SQL (and many other
tasks) in a much simpler way!

If you do try the web.database.object examples, be aware that the docs are
not entirely tracking the code; f.ex. databases have no type parameter;
it's an adapter

i.e.
connection = web.database.connect(type=sqlite,database=object-simple.db)
should be:
connection =
web.database.connect(adapter=sqlite,database=object-simple.db)'

there are probably others - it's good to see what the parameters are in
idle if something does not work as advertised.

Overall, Pythonweb is very impressive work IMO.




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


Running in Release or Debug version of the python interpreter?

2005-05-24 Thread Raphael Zulliger
Hi

I have to check wheter a .py script is run within the debug or the 
release version of an embedded python interpreter (in short, wheter 
python24_d.dll or python24.dll is in use).

long version: I'm using ctypes to load my own dll. There exists 2 
version of this dll - a debug and a release version (where one is linked 
against debug C runtime dll and the other to release C runtime dll). Now
I have to change the name of the dll I want to be loaded by ctypes... 
But how can I find out which of the dll I have to load?!

Thanks in advance!
Raphael Zulliger
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: slow sql server DB reads

2005-05-24 Thread Larry Bates
If GUID is not a key in the database make it one.  That
way you won't have to do serial reads through the entire
table to locate matching entries.

It is hard to be more specific because we don't know how
many records are in ASPSessionState table.  If there are
only a few, the problem is probably elsewhere.  If there
are many, indexing on GUID would provide speed improvement.

Larry Bates

bart wrote:
 I run a python website on a IIS server. I replaced my flat file DB
 with SQL server, but the reads are very slow. 7 seconds for 3 querrys
 like these
 
 conn= adodbapi.connect( Provider=SQLOLEDB.1;Persist Security
 Info=False;User ID=sa;Password=xxx;Initial Catalog=dlpl;Data
 Source=(local) )
 crsr = conn.cursor() 
 sql = select SessionKey, SessionValue from ASPSessionState
 where GUID='%s' % self.id
 crsr.execute(sql)
 while 1: 
 info = crsr.fetchone() 
 if not info: 
 break 
 strKey = str(info[0])
 
 Opening the database is already good for 2 seconds. 
 Anyone know how to speed it up?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Terminating a thread from the parent

2005-05-24 Thread DE
I appreciate your posts guys. It answers my questions and I like the
idea of overriding join method. I will use this one.

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


Re: searching substrings with interpositions

2005-05-24 Thread [EMAIL PROTECTED]
thanx everyone, is what i need.
As Claudio argues, it's a standard problem of dna sequences
comparation.
the next step of my job is to make limits of lenght of interposed
sequences (if someone can help me in this way i'll apreciate a lot)
thanx everyone.
giorgio

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


TEENS FUCKIN FOR CASH

2005-05-24 Thread Maria
18 Years young Teenies fuckin for Cash!
Geile Teens ficken fuer Taschengeld!
http://www.sexycorner.biz

Enjoy
Maria

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


Re: What are OOP's Jargons and Complexities?

2005-05-24 Thread John W. Kennedy
alex goldman wrote:
 John W. Kennedy wrote:
 
 
Strong
typing has been a feature of mainstream programming languages since the
late 1950's.
 
 
 Is Fortran a strongly typed language? I don't think so. Strong typing has
 been invented in the 70's, if I'm not mistaken, when ML was invented, but
 strong typing has never been mainstream.

I begin to believe that I have been reading naughty references, and that 
I should rather have said statically typed.

I am not familiar with modern Fortran. Surely it at least has argument 
prototyping by now?

-- 
John W. Kennedy
You can, if you wish, class all science-fiction together; but it is 
about as perceptive as classing the works of Ballantyne, Conrad and W. 
W. Jacobs together as the 'sea-story' and then criticizing _that_.
   -- C. S. Lewis.  An Experiment in Criticism
-- 
http://mail.python.org/mailman/listinfo/python-list


\l operation in regular expressions

2005-05-24 Thread Kalle Anka
I've started to play around with regexps in Python and I tried
something like this

print re.sub( r'(\bw\w+\b)', r'\u\1', 'will it work')

and get

\uwill it \uwork

when I had expected

Will it Work

I tried to find some documentation about this but I can't find anything
that says if operations like \l \L \u \U etc are supported or not. It
doesn't look like it supported? What is the Python way of doing this,
writing a function and use that as the replacement?


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


py2exe for WMI

2005-05-24 Thread GMane Python
Hello All.
  I'm trying to 'compile-to-EXE' a python program which uses Win32  WMI to
pull system info. from the PC such as serial number, CPU speed, etc.  I'm
having problems with py2exe -- with regard to Win2000  WinXP platforms.  It
seems that the program only works if I have one typelib for WinXP and a
slightly different one for Win2000.  Here is my relevent section from the
py2exe setup.py:
setup(
options = {py2exe: {typelibs:
##  # typelib for WMI - WinXP
##  [('{565783C6-CB41-11D1-8B02-00600806D9B6}', 0,
1, 2)],

  # typelib for WMI - Win2000
  [('{565783C6-CB41-11D1-8B02-00600806D9B6}', 0, 1,
1)],

  # create a compressed zip archive
  compressed: 1,
  optimize: 2,
  packages: [encodings],
  excludes: excludes}},
# The lib directory contains everything except the executables and the
python dll.
# Can include a subdirectory name.
zipfile = lib/shared.zip,

Can anyone tell me how I might make one unified py2exe setup.py that'll
'compile' for both Win2000  WinXP?

If not, can someone give me a hint as to how I can have a python 'launcher'
which can determine the difference between Win2000  WinXP?  Using the
sys.platform, they both show as Win32.

Thanks!
Dave



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


Re: reg python related job searching

2005-05-24 Thread Skip Montanaro

praba Can any one guide me how to get python related jobs?

You mean a source of job postings?  If so, try the Python Jobs Board:

http://www.python.org/Jobs.html

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


Re: Hacking the scope to pieces

2005-05-24 Thread Skip Montanaro

Hugh What I'm after is a way of moduleLoader.loadModule working back up
Hugh the scope and placing the imported module in the main global
Hugh scope. Any idea how to do this?

You want to write an import hook I think.  I'd start with the docs for the
__import__ builtin.  Also, Google for python import hook.

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


Re: Hacking the scope to pieces

2005-05-24 Thread Hugh Macdonald
I will take a look!

Thanks Skip

--
Hugh

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


Running PythonNN.DLL as debug or release?

2005-05-24 Thread Stephen Kellett
Hi Folks,

We've been using Python embedded in an application for a while now, 
where the Python dll is PythonNN.dll, NN being the version number, such 
as Python24.dll.

Recently it was pointed out to me that Python can run in a debug or 
release configuration and that you can specify this on the command line 
using -O and -OO.

My question is how do I specify this to the Python DLL I have embedded 
in my application? Is it as straightforward as:
o Use PythonNN.dll for release mode Python
o Use PythonNN_d.dll for debug mode Python

and if so, how do I specify I want -O or -OO with release mode?

I've tried looking at the C API documentation but couldn't find anything 
useful there.

We are using versions of Python from 2.2 upwards.

Cheers

Stephen
-- 
Stephen Kellett
Object Media Limited
Computer Consultancy, Software Development
Windows C++, Java, Assembler, Performance Analysis, Troubleshooting
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: py2exe for WMI

2005-05-24 Thread Tim Golden
| Hello All.
|   I'm trying to 'compile-to-EXE' a python program which uses 
| Win32  WMI to
| pull system info. from the PC such as serial number, CPU 
| speed, etc.  I'm
| having problems with py2exe -- with regard to Win2000  WinXP 
| platforms.  It
| seems that the program only works if I have one typelib for 
| WinXP and a
| slightly different one for Win2000.  Here is my relevent 
| section from the
| py2exe setup.py:

[... snipped ...]

| Can anyone tell me how I might make one unified py2exe 
| setup.py that'll
| 'compile' for both Win2000  WinXP?
| 
| If not, can someone give me a hint as to how I can have a 
| python 'launcher'
| which can determine the difference between Win2000  WinXP?  Using the
| sys.platform, they both show as Win32.
| 
| Thanks!
| Dave

There was a thread about this on the python-win32 list a 
while back. I think this is the start of the the thread
(altho' it's a bit confusing). The conclusion seems to
be that there's no conclusion. Maybe there's more info
on the py2exe list/wiki?

http://aspn.activestate.com/ASPN/Mail/Message/Python-win32/2007557

As to the other question (which platform am I on) there
was also a thread about this recently:

http://groups-beta.google.com/group/comp.lang.python/browse_frm/thread/b87d5de8f91c8e9c?tvc=1q=platform+hl=en

which, in short, says: use the platform module

TJG


This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk

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


interesting Link

2005-05-24 Thread Giox
Hello everybody, I found on the web an interesting way to gain some money:
it's netbux, that allows you to learn something while you search the web 
through google or altaista.
I earned 40$ in a month, not a lot, but I have simply to use Google to do My 
searches.
If you want try it subscribe at:

http://netbux.org/?r=67933




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


Re: execution error

2005-05-24 Thread Ximo

Skip Montanaro [EMAIL PROTECTED] escribió en el mensaje 
news:[EMAIL PROTECTED]

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...

But I execute the operation in the else:

try:
   except ZeroDivisionError:
   print whoops! divide by zero...
else:
   execute( )

The exeption is produced after.










 Skip 


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

Re: searching substrings with interpositions

2005-05-24 Thread Cyril BAZIN
Just another solution, pretty and effective:

def fct(a, b):
 idx = -1
 for c in a:
 idx = b.find(c, idx+1)
 if idx == -1:
 return False
 return True
On 24 May 2005 06:06:03 -0700, [EMAIL PROTECTED] [EMAIL PROTECTED]
 wrote:thanx everyone, is what i need.As Claudio argues, it's a standard problem of dna sequences
comparation.the next step of my job is to make limits of lenght of interposedsequences (if someone can help me in this way i'll apreciate a lot)thanx everyone.giorgio--
http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: \l operation in regular expressions

2005-05-24 Thread Fredrik Lundh
Kalle Anka [EMAIL PROTECTED] wrote:

 I've started to play around with regexps in Python and I tried
 something like this

 print re.sub( r'(\bw\w+\b)', r'\u\1', 'will it work')

 and get

 \uwill it \uwork

 when I had expected

 Will it Work

 I tried to find some documentation about this but I can't find anything
 that says if operations like \l \L \u \U etc are supported or not.

they're not mentioned in the RE syntax chapter, and they don't work, so not
supported is probably the right answer.

 It doesn't look like it supported? What is the Python way of doing this,
 writing a function and use that as the replacement?

def fixup(m):
return m.group().capitalize()
s = re.sub( r'(\bw\w+\b)', fixup, 'will it work')

or, if you insist on writing one-liners:

s = re.sub( r'(\bw\w+\b)', lambda m: m.group().capitalize(), 'will it work')

/F 



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


Re: Just remember that Python is sexy

2005-05-24 Thread Scott Kirkwood
Silly but true. It started with trying to figure how to remember it's
strip() and not trim(). 
Then it went downhill from there.

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


Pyrex: TypeError: unsubscriptable object

2005-05-24 Thread Luis P. Mendes
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi,

I'm just transforming a Python module into Pyrex, and I get the
following error:
File indicadorPyrex.pyx, line 37, in indicadorPyrex.volatilidade
~h1 = precoMax[barra]

I made no changes to this module except including 'int' for two
variables in the def argument of the function.

I also tried to declare cdef float h1, but I get the same error.

What can be wrong?

Thanks,

Luis
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCkz6MHn4UHCY8rB8RAlTZAJ0ZXfdmkZuXFLPrhGvaYUBoS7YTVQCZAZhp
Fc65UgWF+rCkilTs0BAmNSU=
=PZpG
-END PGP SIGNATURE-
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Running PythonNN.DLL as debug or release?

2005-05-24 Thread Fredrik Lundh
Stephen Kellett wrote:

 We've been using Python embedded in an application for a while now,
 where the Python dll is PythonNN.dll, NN being the version number, such
 as Python24.dll.

 Recently it was pointed out to me that Python can run in a debug or
 release configuration and that you can specify this on the command line
 using -O and -OO.

whoever pointed that out to you was confused: -O and -OO are optimization
flags used by the Python interpreter, and has nothing to do with what Python
runtime you're using.

$ python -h
usage: python [option] ... [-c cmd | file | -] [arg] ...
Options and arguments (and corresponding environment variables):
...
-O : optimize generated bytecode (a tad; also PYTHONOPTIMIZE=x)
-OO: remove doc-strings in addition to the -O optimizations
...

if you want to use these from your C code, setting the global Py_OptimizeFlag
to 1 (-O) or 2 (-OO) should work.

/F 



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


Re: Python on a public library computer

2005-05-24 Thread Anton Vredegoor
alex23 wrote:

 In this case, it sounds like the library is providing computers for
two
 purposes: access to Office tools and to the internet. Given the
 everything not forbidden is permissable attitude of most people,
 unless the use is restricted to only those two activities people
 legitimately wanting access will tend to end up waiting for others
who
 have co-opted the services for their own personal end.

But who are those people using this *public* library for their own
personal end? Is it the cannibal elite that is using this public space
to promote microsoft products and 'reducing' their workload (actually I
believe they are making their own job harder) or is it the user who
wants to run public domain software?

The current situation is such that in order to make the system 'safer'
I cannot clear my own cache, so my internet history is visible for the
next user, which compromises *my* security. Surely there should be a
balance between the interests of the provider and the client, but since
in this case the client is also the 'owner' of the service (it's a
*public* library) there should be room to run non-proprietary software.

The connection with the european constitution is exactly about this
shifting of the ownership of public buildings, institutions,
infrastructure etc. *from* the persons using the service *towards* the
people accidentally working in that place.

So social security starts to act like it's an employer, but since they
are also the state, they don't have to pay minimum wages, if one is
treated unfairly it's impossible to get a fair trial. If one doesn't
agree with this treatment they just keep the money they are obliged to
pay (according to our national constituton) to themselves.

Universities start to act like the buildings are extra living room for
the persons working there and in order to get a degree one has to
*work* for a professor.

The elite in the city starts building luxury appartments for their own
people (who are payed with public money stolen one way or the other
from the normal residents in the city) in the natural resorts because
their is some kind of 'shortage' in the housing market.

On the other hand one wants to make the polluter pay and creates
taxes for garbage. But these taxes are 'equal' for everyone, meaning
that they are negligible for the rich but a large part of the income of
the poor.

The same goes for fines for speeding or parking tickets. If you're rich
or know the people in the elite you can get away with anything.

The *european* constitution is related to this because our government
wants to limit the discussion to the merits of the document. The
problem is that even with a good constitution a corrupt elite can
interpret the terms in a way that is unfavorable for the poor (almost
anyone is poor or becoming poor by now). And secondly the document is
only intelligible for specialists, so even if it was good, there's no
way to tell.

So we might find ourselves in a situation one day when walking to the
water tap to fill our teakettle a voice will come out of it asking
whether we want *coca* cola or *pepsi* cola. When complaning about this
to our government we will hear something like: 'Look you *have* a
choice it's not like we prefer one brand over the other, so what are
you complaining about? Be silent out you will be removed from our
administration, which means no food, health care, money or friends.

I'm currently mentally analogizing this discussion with the one on
python dev about whether the decimal module should give users 'what
they expect' or conform to industry standards, but I guess one has to
be Dutch to see any connection at all here :-)

The rationale for all of this is that the economy is bad and we have
close to zero growth. We should be like China or other low wage
countries in order to be more competitive.

However the rationale is false! Because we have better infrastructure
here we are *further* up the exponential development curve so we could
have fenomenal growth if we wanted! The fact that this isn't happening
at all has nothing to do with with the economic potential but all the
more with conservative power consolidation tactics.

The media play a very nasty role in all of this. For example the
newspapers are complaining nobody reads paper anymore because of the
internet. IMO it is caused more by nobody wanting to read the same old
selfpromotion anymore. Something comparable is happening with public
television which is not a true representation of the public opinion at
all. Not to say public opinion is always good, but if noone thinks you
are giving the right characterization of the current situation, one is
not likely to want to join the discussion.

Ok, this is getting way to far off topic. Thanks to all for the hints
to get python running here. I'm now contemplating to access the already
running java interpreter that must hide somewher in this IE, and to
start a jython console from there (without even running a new

Build error Python 2.4.1 - stat problem?

2005-05-24 Thread Servatius.Brandt
Hello,

I tried to build Python 2.4.1 on a Reliant Unix system.  Just after the
python executable program has been built, I get the following error:

 begin make output ===
CC  -W1 -Blargedynsym -o python \
Modules/python.o \
libpython2.4.a -lresolv -lsocket -lnsl -ldl
-lm  
case $MAKEFLAGS in \
*-s*)  CC='cc' LDSHARED='ld' OPT='-DNDEBUG -O' ./python -E
./setup.py -q build;; \
*)  CC='cc' LDSHARED='ld' OPT='-DNDEBUG -O' ./python -E
./setup.py build;; \
esac
Traceback (most recent call last):
  File ./setup.py, line 1088, in ?
class PyBuildInstallLib(install_lib):
  File ./setup.py, line 1094, in PyBuildInstallLib
so_ext = sysconfig.get_config_var(SO)
  File /build_dir/Python-2.4.1/Lib/distutils/sysconfig.py, line 511,
in get_config_var
return get_config_vars().get(name)
  File /build_dir/Python-2.4.1/Lib/distutils/sysconfig.py, line 488,
in get_config_vars
func()
  File /build_dir/Python-2.4.1/Lib/distutils/sysconfig.py, line 358,
in _init_posix
raise DistutilsPlatformError(my_msg)
distutils.errors.DistutilsPlatformError: invalid Python installation:
unable to open /usr/local/lib/python2.4/config/Makefile (No such file or
directory)
make: *** Error code 1

make: Fatal error.
 end make output ===

It is strange that the Makefile complains about /usr/local/lib/python2.4
since this is still the build phase, far away from the installation into
/usr/local.


I used the python executable from the build directory to run the
following program:

import os

def main():
if not (os.path.exists(/)):
print / does not exist
else:
print / exists
if not (os.path.isdir(/)):
print / is not a directory
else:
print / ok

if __name__ == __main__:
main()

The output is:

/ exists
/ is not a directory

It's the same for every (existing) directory name I try: os.path.isdir()
always returns false.

It looks as if the stat results are not recognised: os.path.exists()
works, but all the functions os.path.isdir(), os.path.isfile() etc.
don't.

Could anyone help me to solve the problem?

- Servatius


Servatius Brandt Phone: +49 89 636-41504
Fujitsu Siemens ComputersFax:   +49 89 636-48716
EP SW AD C++ Email: [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: execution error

2005-05-24 Thread Ximo
Ximo My question is how can show the execution error whitout exit  of 
 the program, showing it in the error output as


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


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


 But I execute the operation in the else:

try:
   except ZeroDivisionError:
   print whoops! divide by zero...
else:
   execute( )

 The exeption is produced after. 


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


Re: Running in Release or Debug version of the python interpreter?

2005-05-24 Thread Fredrik Lundh
Raphael Zulliger wrote:

long version: I'm using ctypes to load my own dll. There exists 2
 version of this dll - a debug and a release version (where one is linked
 against debug C runtime dll and the other to release C runtime dll). Now
 I have to change the name of the dll I want to be loaded by ctypes...
 But how can I find out which of the dll I have to load?!

calling GetModuleFileName (in kernel32.dll) on sys.dllhandle should give
you the name of the current Python DLL.  something like this should work:

from ctypes import *
MAX_PATH = 500
filename = c_buffer(MAX_PATH)
windll.kernel32.GetModuleFileNameA(sys.dllhandle, filename, MAX_PATH)
filename = filename.value

/F 



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


execution error 2

2005-05-24 Thread Ximo
Ximo My question is how can show the execution error whitout exit  of
 the program, showing it in the error output as


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


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


 But I execute the operation in the else:

try:
   except ZeroDivisionError:
   print whoops! divide by zero...
else:
   execute( )

 The exeption is produced after.



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


RE: [ZODB-Dev] ZODB memory problems (was: processing a Very Largefile)

2005-05-24 Thread Tim Peters
[Jeremy Hylton]
 ...
 It looks like your application has a single persistent instance -- the
 root ExtendedTupleTable -- so there's no way for ZODB to manage the
 memory.  That object and everything reachable from it must be in memory
 at all times.

Indeed, I tried running this program under ZODB 3.4b1 on Windows, and
about 4% of the way done it dies during one of the subtransaction
commits, with a StackError:  the object is so sprawling that a
megabyte C stack is blown by recursion while trying to serialize it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: first release of PyPy

2005-05-24 Thread Carl Friedrich Bolz
Kay Schluehr wrote:
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?

yes. It means that there are objects that behave like they should in
PyPy but are implemented by keeping creating a regular CPython instance
of the object and delegating all calls on PyPy-level back to the CPython
level.

 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?

Not exactly sure what you mean here. It's clear that we have to handle
faked objects differently to get a stand-alone PyPy version. One
possibility would be, that the RPython code calls certain functions
which are implemented in Python (can be regular Python), that are not
translated but replaced by a proper C function. For example we have a
function intmask at the moment which takes a long and removes as many
bits from it as neccessary to make it fit into an int again. This
function is left out when translating, since in C an int can obviously
not overflow to a long.

Regards,

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


Re: py2exe for WMI

2005-05-24 Thread Thomas Heller
Tim Golden schrieb:
 | Hello All.
 |   I'm trying to 'compile-to-EXE' a python program which uses 
 | Win32  WMI to
 | pull system info. from the PC such as serial number, CPU 
 | speed, etc.  I'm
 | having problems with py2exe -- with regard to Win2000  WinXP 
 | platforms.  It
 | seems that the program only works if I have one typelib for 
 | WinXP and a
 | slightly different one for Win2000.  Here is my relevent 
 | section from the
 | py2exe setup.py:
 
 [... snipped ...]
 
 | Can anyone tell me how I might make one unified py2exe 
 | setup.py that'll
 | 'compile' for both Win2000  WinXP?
 | 
 | If not, can someone give me a hint as to how I can have a 
 | python 'launcher'
 | which can determine the difference between Win2000  WinXP?  Using the
 | sys.platform, they both show as Win32.
 | 
 | Thanks!
 | Dave
 
 There was a thread about this on the python-win32 list a 
 while back. I think this is the start of the the thread
 (altho' it's a bit confusing). The conclusion seems to
 be that there's no conclusion. Maybe there's more info
 on the py2exe list/wiki?
 
 http://aspn.activestate.com/ASPN/Mail/Message/Python-win32/2007557
 
I don't think something wnet into the wiki, unfortunately.
The OP of the thread Tim mentions here already had a solution, if I 
understood him correctly, and the other things that were suggested 
didn't work.  Basically, IIUC, he did add the typelib wrappers from the 
'other' windows version manually to the library.zip file.

Totally different solutions would be:
- change Tim's wmi.py module so that it works with dynamic binding (no 
typelib wrappers needed)
or
- change win32com so that the typelib wrappers can be generated by 
frozen executables at runtime.

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


Re: Running in Release or Debug version of the python interpreter?

2005-05-24 Thread Thomas Heller
Raphael Zulliger schrieb:
 Hi
 
 I have to check wheter a .py script is run within the debug or the 
 release version of an embedded python interpreter (in short, wheter 
 python24_d.dll or python24.dll is in use).
 
 long version: I'm using ctypes to load my own dll. There exists 2 
 version of this dll - a debug and a release version (where one is linked 
 against debug C runtime dll and the other to release C runtime dll). Now
 I have to change the name of the dll I want to be loaded by ctypes... 
 But how can I find out which of the dll I have to load?!
 
 Thanks in advance!
 Raphael Zulliger

You could use imp.get_suffixes(). In a release build the returned list 
will contain these entries
('.pyd', 'rb', 3), ('.dll', 'rb', 3)
in a debug build that will be
('_d.pyd', 'rb', 3), ('_d.dll', 'rb', 3)

Another way would be to look at the filename of any binary extension 
module.  _ctypes.__file__, for example:  '.\\_ctypes.pyd' vs. 
'\\_ctypes_d.pyd'.

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


Re: staticmethod and classmethod

2005-05-24 Thread lbolognini
Think I read something about it here:

http://heather.cs.ucdavis.edu/~matloff/Python/

not sure though.

Lorenzo

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


RE: py2exe for WMI

2005-05-24 Thread Tim Golden
[Thomas Heller]

[... snip problems with py2exe  WMI ...]

| The OP of the thread Tim mentions here already had a solution, if I 
| understood him correctly, and the other things that were suggested 
| didn't work.  Basically, IIUC, he did add the typelib 
| wrappers from the 
| 'other' windows version manually to the library.zip file.
| 
| Totally different solutions would be:
| - change Tim's wmi.py module so that it works with dynamic 
| binding (no 
| typelib wrappers needed)
| or

Well, if it helps, there's a version of the WMI module
that uses dynamic binding on my site:

http://timgolden.me.uk/python/downloads/wmi-0.6a.py

I've hardcoded the relevant constants (which is pretty 
much all I was using early binding for) and replaced 
any other EnsureDispatch calls with simple Dispatch.

Does anyone want to give it a try to let me know if
it helps? I don't use py2exe myself.

TJG



This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk

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


Re: What are OOP's Jargons and Complexities?

2005-05-24 Thread Thomas G. Marshall
John W. Kennedy coughed up:
 alex goldman wrote:
 John W. Kennedy wrote:


 Strong
 typing has been a feature of mainstream programming languages since
 the late 1950's.


 Is Fortran a strongly typed language? I don't think so. Strong
 typing has been invented in the 70's, if I'm not mistaken, when ML
 was invented, but strong typing has never been mainstream.

 I begin to believe that I have been reading naughty references, and
 that I should rather have said statically typed.

 I am not familiar with modern Fortran. Surely it at least has argument
 prototyping by now?


There are some fortran advocates that pop into here now and again.  Frankly, 
I'm spooked by how far fortran seems to have come.  There is even OO support 
now.  OI.

I preferred the old days of thinking that fortran sucked just 'cause.  :)


-- 
Enough is enough.  It is /not/ a requirement that someone must google
relentlessly for an answer before posting in usenet.  Newsgroups are
for discussions.  Discussions do /not/ necessitate prior research.  If
you are bothered by someone asking a question without taking time to
look something up, simply do not respond.


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


Re: staticmethod and classmethod

2005-05-24 Thread Steven Bethard
C Gillespie wrote:
 Does anyone know of any examples on how ( where) to use staticmethods and
 classmethods?

My personal experience is that I almost *never* want a staticmethod. 
The things that I would have written as a staticmethod in Java I simply 
write as a module-level function in Python.

I do occasionally used classmethods though to build alternate 
constructors.  I recently had a class with a constructor that looked like:

class C(object):
 def __init__(self, *args):
 ...

I already had code working with this constructor, but I needed to add an 
optional 'index' parameter.  I found the clearest way to do this was 
something like:

class C(object):
 def __init__(self, *args):
 ...
 @classmethod
 def indexed(cls, index, *args):
 ...
 obj = cls(*args)
 obj.index = index
 ...
 return obj

Then the classes that needed the 'index' parameter simply use 
C.indexed() as the constructor instead of C().

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


Re: install python 2.4.1

2005-05-24 Thread Trent Mick
[EMAIL PROTECTED] wrote]
 I use win xp pro.
 I wonder about this new version of python because I use Nummeric, pyro,
  combine with komodo and pydev ide in my python 2.4.
 If there is compatibility isue with the new version, it is better for
 me not to install the new version.

There will be no compatibility issue with Komodo, at least. Nor should
there be with the others, as Martin mentioned.

Trent

-- 
Trent Mick
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: searching substrings with interpositions

2005-05-24 Thread Andrew Dalke
[EMAIL PROTECTED] wrote:
 the next step of my job is to make limits of lenght of interposed
 sequences (if someone can help me in this way i'll apreciate a lot)
 thanx everyone.

Kent Johnson had the right approach, with regular expressions.
For a bit of optimization, use non-greedy groups.  That will
give you shorter matches.

Suppose you want no more than 10 bases between terms.  You could
use this pattern.

a.{,10}?t.{,10}?c.{,10}?g.{,10}?


 import re
 pat = re.compile('a.{,10}t.{,10}c.{,10}g.{,10}?')
 m = pat.search(tcgaacccgtagctaatcg)
 m.group(0), m.start(0), m.end(0)
('aacccgtagctaatcg', 3, 23)
 

 pat.search(tcgaacccgtagctaatttg)
_sre.SRE_Match object at 0x9b950
 pat.search(tcgaacccgtagctaag)
 

If you want to know the location of each of the bases, and
you'll have less than 100 of them (I think that's the limit)
then you can use groups in the regular expression language

 def make_pattern(s, limit = None):
... if limit is None:
... t = .*?
... else:
... t = .{,%d}? % (limit,)
... text = []
... for c in s:
... text.append((%s)%s % (c, t))
... return .join(text)
... 
 make_pattern(atcg)
'(a).*?(t).*?(c).*?(g).*?'
 make_pattern(atcg, 10)
'(a).{,10}?(t).{,10}?(c).{,10}?(g).{,10}?'
 pat = re.compile(make_pattern(atcg, 10))
 m = pat.search(tcgaacccgtagctaatttg)
 m
_sre.SRE_Match object at 0x8ea70
 m.groups()
('a', 't', 'c', 'g')
 for i in range(1, len(atcg)+1):
...   print m.group(i), m.start(i), m.end(i)
... 
a 3 4
t 9 10
c 16 17
g 27 28
 



Andrew
[EMAIL PROTECTED]

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


Dr. Dobb's Python-URL! - weekly Python news and links (May 24)

2005-05-24 Thread Simon Brunning
QOTW: If you're sick of answering newbie questions, and don't think you
can do so politely, for the sake of the community, DON'T!  You're not that
necessary. - Joal Heagney

Who controls the runtime also controls the language. - Kay Schluehr


Jake tells us about the \r control character, which allows one to
refresh a terminal line. Many people help him to use it from Python,
and Fredrik warns him that it might well not work from an IDE:

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

John Reese asks whether he needs to explicitly close file objects,
or whether reference counting will take care of it for him. Martin
v. Löwis shows a scenario that demonstrates that ref counting won't
always close files when you think it will:

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

Simon Percivall and Jp Calderone show Michael Chermside how to
process subprocess module output a line at a time:

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

WSGI Explorations with Python - Mike Orr investigates WSGI and Paste:
http://rex.kicks-ass.net/python/wsgi-explorations.html

Len, an old time Cobol programmer, asks for some advice on storing data:

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

Dustin is refactoring some unpythonic code that uses a very nasty
import mechanism, but now he's having trouble with circular imports:

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

A Matter Of Questions - Ben Last tells us how he's using Python for
data cleansing, amongst other things, while building a Playstation
Music Quiz:
http://www.livejournal.com/users/benlast/24719.html

William Park wants to test how similar two strings are. This is
more complicated than it sounds...

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

Create an ODBC data source in the fly with Python:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/414879

Paul Rubin investigates how the super() function works with
multiple inheritance. A number of people clear things up for him.

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

Notable releases:
pysqlite 2.0.2
http://pysqlite.org/
PyPy 0.6 (!)

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



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

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

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

For far, FAR more Python reading than any one mind should
absorb, much of it quite interesting, several pages index
much of the universe of Pybloggers.
http://lowlife.jp/cgi-bin/moin.cgi/PythonProgrammersWeblog
http://www.planetpython.org/
http://mechanicalcat.net/pyblagg.html

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

http://groups.google.com/groups?oi=djqas_ugroup=comp.lang.python.announce

Steve Bethard, Tim Lesher, and Tony Meyer continue the marvelous
tradition early borne by Andrew Kuchling, Michael Hudson and Brett
Cannon of intelligently summarizing action on the python-dev mailing
list once every other week.
http://www.python.org/dev/summary/

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

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

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

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

Python Success Stories--from air-traffic control to on-line
match-making--can inspire you 

Re: install python 2.4.1

2005-05-24 Thread Pujo Aji
thanks

On 5/24/05, Trent Mick [EMAIL PROTECTED] wrote:
 [EMAIL PROTECTED] wrote]
  I use win xp pro.
  I wonder about this new version of python because I use Nummeric, pyro,
   combine with komodo and pydev ide in my python 2.4.
  If there is compatibility isue with the new version, it is better for
  me not to install the new version.
 
 There will be no compatibility issue with Komodo, at least. Nor should
 there be with the others, as Martin mentioned.
 
 Trent
 
 --
 Trent Mick
 [EMAIL PROTECTED]

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


Re: searching substrings with interpositions

2005-05-24 Thread Claudio Grondi

[EMAIL PROTECTED] schrieb im Newsbeitrag
news:[EMAIL PROTECTED]
 thanx everyone, is what i need.
 As Claudio argues, it's a standard problem of dna sequences
 comparation.
 the next step of my job is to make limits of lenght of interposed
 sequences (if someone can help me in this way i'll apreciate a lot)
 thanx everyone.
 giorgio

Note: code below is intended to help to clarify things only,
so that a bunch of examples can be tested.
If you need bugfree production quality code, maybe
someone else can provide it.

I have introduced two additional parameter to the function.
If  intMaxLenOfGap == 0  the gap size doesn't matter.
lstStartEndOfRangeOfBwithOccurenceOfA returns in its
0,1 elements the begin and end of the range strA was
found in strB.

Hope this does what you mean with
  make limits of lenght of interposed sequences,
does it?

Claudio
P.S. Here the code:

def blnFindCharSequenceAevenIfSpreadOverEntireStringB(strA, strB,
intMaxLenOfGap = 0, lstStartEndOfRangeOfBwithOccurenceOfA = []):

  lstStartEndOfRangeOfBwithOccurenceOfA = []
  intNoOfCharsFound = 0
  intPtrToFirstCharFound = 0
  intPtrToBeginOfSubsectionOfB = 0
  intLenA = len(strA)
  intLenB = len(strB)
  blnStrAinB = False
  indxToA = 0

  while(indxToA  intLenA):
# print chrA
if(indxToA == 0):
  blnFoundChrA = False
  for indxToB in range(intPtrToBeginOfSubsectionOfB, intLenB):
if(strA[indxToA] == strB[indxToB]):
  intNoOfCharsFound += 1
  # print,chrA, strB[indxToB], indxToB
  intPtrToFirstCharFound = indxToB
  intPtrToBeginOfSubsectionOfB = indxToB + 1
  blnFoundChrA = True
  break
#:if
  #:for
  if(intNoOfCharsFound == intLenA):
blnStrAinB = True
print sequence '%s' found in '%s'%(strA, strB)
break
  #:if
  if(blnFoundChrA == False):
break
  #:if
  indxToA += 1
else:
  intGapLen = 0
  blnFoundChrA = False
  for indxToB in range(intPtrToBeginOfSubsectionOfB, intLenB):
if(strA[indxToA] == strB[indxToB]):
  intNoOfCharsFound += 1
  # print,chrA, strB[indxToB], indxToB
  intPtrToBeginOfSubsectionOfB = indxToB + 1
  blnFoundChrA = True
  break
#:if
intGapLen += 1
if(intMaxLenOfGap  0 and intGapLen  intMaxLenOfGap):
  indxToA = 0
  blnFoundChrA = False
  intPtrToBeginOfSubsectionOfB = intPtrToFirstCharFound + 1
  intNoOfCharsFound = 0
  break
#:if
  #:for
  if(intNoOfCharsFound == intLenA):
blnStrAinB = True
print sequence '%s' found in '%s' at range(%i, %i)%(strA, strB,
intPtrToFirstCharFound, indxToB+1)
lstStartEndOfRangeOfB.append(intPtrToFirstCharFound)
lstStartEndOfRangeOfB.append(indxToB+1)
break
  #:if
  if(blnFoundChrA == False):
break
  #:if
  indxToA += 1
#:if/else
  #:while
  if  blnStrAinB == False:
if(intMaxLenOfGap  0 and intGapLen  intMaxLenOfGap):
  print sequence '%s' not in '%s' (maybe allowed gap of %i chars was
too small?)%(strA, strB, intMaxLenOfGap)
else:
  print sequence '%s' not in '%s'%(strA, strB)
  #:if
#:def

print

lstStartEndOfRangeOfB = []
strA = 0101
strB = 0100
blnFindCharSequenceAevenIfSpreadOverEntireStringB(strA, strB)

lstStartEndOfRangeOfB = []
strA = 0101
strB = 0100
blnFindCharSequenceAevenIfSpreadOverEntireStringB(strA, strB, 2)

strA = 010101
strB = 0100
blnFindCharSequenceAevenIfSpreadOverEntireStringB(strA, strB, 6,
lstStartEndOfRangeOfB)

strA = 010101
strB = 01001
blnFindCharSequenceAevenIfSpreadOverEntireStringB(strA, strB, 4,
lstStartEndOfRangeOfB)

strA = 010101
strB = 01001
blnFindCharSequenceAevenIfSpreadOverEntireStringB(strA, strB, 5,
lstStartEndOfRangeOfB)
print
print usage of lstStartEndOfRangeOfB parameter passed to function for use
as return value:
print sequence '%s' was found in '%s' at range(%i, %i)%(strA, strB,
lstStartEndOfRangeOfB[0], lstStartEndOfRangeOfB[1])


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


Re: Hacking the scope to pieces

2005-05-24 Thread Hugh Macdonald
Maybe I misunderstood what you meant, but I couldn't quite manage to
get this one working

My initial hopes about __import__() were that I could define it inside
my new module (moduleLoader) and, when the module is imported, it could
do stuff (like try to hold onto the vars() and globals() from the
importing scope). However, I couldn't get it to import...

The route I've ended up going (which is just about as simple) is just
to return the new module from moduleLoader.loadModule, so my loading
code is:

import moduleLoader
myModule = moduleLoader.loadModule(myModule,
os.getenv(MODULE_VERSION))

I've also switched over to using 'inp' for this, rather than creating a
compiler string - much nicer

Anyway, thanks Skip

--
Hugh

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


Tk and raw_input segfault

2005-05-24 Thread dale
Python newbie disclaimer on

I am running an app with Tkinter screen in one thread and command-line
input in another thread using raw_input().  First question - is this
legal, should it run without issue?  If not can you point me to a
description of why.

While updating objects on the screen I get a segfault after an
indeterminate number of updates.  It doesn't seem to matter how quickly
the updates occur, but it does segfault faster when there are more
objects on the screen ( as I said failure time seems to have a random
factor added to it ).

Commenting out the raw_input() makes problem go away.  I can schedule
as many updates as I wish without error.  And it doesn't seem to matter
if I actually hit any keys for raw_input(), it can just sit there.

I have read other posts about readline library failures with Esc O M
sequences and could not recreate those failures.

This happens on 2 separate machines

1st: development workstation
tk-8.4.6-28
tcl-8.4.6-23
Python 2.3.3 (#1, Feb  5 2005, 16:30:27)
[GCC 3.3.3 (SuSE Linux)] on linux2
Linux name deleted 2.6.5-7.151-smp #1 SMP Fri Mar 18 11:31:21 UTC
2005 x86_64 x86_64 x86_64 GNU/Linux

2nd: target machine
tk-8.4.6-37
tcl-8.4.6-26
Python 2.3.3 (#1, Apr  6 2004, 01:47:39)
[GCC 3.3.3 (SuSE Linux)] on linux2
Linux name deleted 2.6.4-52-default #1 Wed Apr 7 02:08:30 UTC 2004
i686 i686 i386 GNU/Linux

I have tried to simplify the code as much as possible to make error
more visible( no actual updates of the screen etc )  I've uncommented
the after code line so it fails much more rapidly.  I know its ugly
repeatedly scheduling the after but, the same code runs without the
raw_input, and it shows the error more readily.

To see the error start the code and click the button repeatedly until
it segfaults.  It will still segfault if you remove the 'command'
funtion and call update dirctly - it just takes a bit longer and your
wrist will probably get tired.

Thanks in advance for any responses.
--

from Tkinter import *
from time import sleep
import thread

class Test(Frame):
def __init__(self, parent=None):
Frame.__init__(self, parent, bg='white')

# Button Definition: CLEAR ALL OUTPUTS
caB = Button( self, text='CLEAR ALL\nOUTPUTS',\
#command = (lambda: self.update()) )
command = (lambda: self.command()) )
caB.pack()
self.updateCount = 0
self.commanded = 0
self.update()

def command( self ):
self.commanded = 1
self.update()

def update( self ):
self.updateCount += 1
print 'updatin... num = ', self.updateCount
self.after( 1, self.update )

def test():
root = Tk()
root.geometry('640x480')
Test().pack()
root.mainloop()

if __name__ == '__main__':
scanTID= thread.start_new_thread( test, () )
sleep(1)

while True:
f= raw_input()
print 'f=', f
sleep(1)

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


RE: line-by-line output from a subproce

2005-05-24 Thread Michael Chermside
I wrote:
 I am using the subprocess module to invoke a command-line utility
 [...] I would like to process the output line-by-line [...]
 rather than running [...] to completion

Simon Percivall writes:
 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.

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

Thanks folks... that did it nicely!

-- Michael Chermside

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


Creating methods depending on packages that have been installed

2005-05-24 Thread C Gillespie
Dear All,

What is the best way of creating methods depending on the packages that have
been installed.

A silly example is

try:
import somepack
class hello:
def __init__(self):
print 'hi'
def some(self):
print 'some'
except:
class hello:
def __init__(self):
print 'hi'

This is obviously not what I want - since it looks ugly and I wish to test
for lots packages.

Any ideas?

Thanks

Colin



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


Re: reference counting and file objects

2005-05-24 Thread Peter

Martin v. Löwis wrote:
 Paul Rubin wrote:
 Consider the function above.  Do I need the fp.close(), or will the
 file be closed automatically when fp goes out of scope and its
 reference count drops to zero?
 
  In CPython, fp gets closed when it leaves scope.

 One issue is that when the function terminates through an exception,
 the file stays open as long as the traceback is available, which
 exists until the next exception is raised (and thus replaces this
 traceback).

 If the function terminates normally (i.e. through return), it is
 as you say.

 Regards,
 Martin

Does the idiom:

lines = file(myfile,r).readlines()

have any better guarantee of being closed automatically? 

Peter

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


Re: PIL and line drawing

2005-05-24 Thread Fredrik Lundh
rzed [EMAIL PROTECTED] wrote:

  if you have 1.1.5, you can use the width option to control
  the line width. see:

 I'm glad to see that addition. I was surprised to see that 'width'
 is actually doubled in the resulting line, though. I suppose the
 code adds and subtracts the specified width from the specified
 coordinate point(?).

hmm.  that sure sounds a lot like a bug I though I had fixed.

/F



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


Python 2.4.1 installation problem

2005-05-24 Thread Philippe C. Martin
Hi,

I am trying to install 2.4.1 on a new machine and have the following
problems.

1) I'm on MDK 10.1
2) The system had 2.3.4 installed in /usr , I deleted the lib
3) I ran ./configure --prefix=/usr, then make, then make install, everything
went OK


If I run Python, I get

File /etc/pythonrc.py, Line 2 in ?
ImportError: no module readline



I also tried to run one of my script and got an import error on bz2.


I have 2.4.1 running OK on another machine with the exact same distro.


Any clue ?

Thanks,

Philippe


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


Re: Dr. Dobb's Python-URL! - weekly Python news and links (May 24)

2005-05-24 Thread Rocco Moretti
Simon Brunning wrote:
 QOTW: If you're sick of answering newbie questions, and don't think you
 can do so politely, for the sake of the community, DON'T!  You're not that
 necessary. - Joal Heagney

Taken out of context, Joal's comments might seem a bit rude and abrasive 
- I don't think they were meant that way. People really should look at 
the context of the quote - it'a actually a very constructive suggestion.

(If the direct link works:)
http://groups-beta.google.com/group/comp.lang.python/msg/6330925dcecb6bdb

(If not, go to http://groups.google.com and search Joal Heagney 
politely group:comp.lang.python Click on the Python Polymorphism thread.)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Build error Python 2.4.1 - stat problem?

2005-05-24 Thread Donn Cave
In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] wrote:
...
 I used the python executable from the build directory to run the
 following program:
 
 import os
 
 def main():
 if not (os.path.exists(/)):
 print / does not exist
 else:
 print / exists
 if not (os.path.isdir(/)):
 print / is not a directory
 else:
 print / ok
 
 if   name   ==   main  :
 main()
 
 The output is:
 
 / exists
 / is not a directory
 
 It's the same for every (existing) directory name I try: os.path.isdir()
 always returns false.
 
 It looks as if the stat results are not recognised: os.path.exists()
 works, but all the functions os.path.isdir(), os.path.isfile() etc.
 don't.
 
 Could anyone help me to solve the problem?

Unless there are other Reliant users here ahead of you, some
of it is going to be up to you.  If you follow isdir() back,
you'll find some hard-coded octal bitmask definitions, including
S_IFDIR = 004.

Check it out.  Try to use that value the way they're using it,
in C and in Python, and print out all the values involved.
At worst, if C comes out wrong too, you may have a question
that the vendor will be more likely to respond to.

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


Re: staticmethod and classmethod

2005-05-24 Thread John Roth
C Gillespie [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Hi,

 Does anyone know of any examples on how ( where) to use staticmethods and
 classmethods?

A python class method is closer to a Java static method than a python static 
method.
Class methods can be useful if you want to be able to change objects in the
class, or if you want to be able to use inheritance, neither of which python 
static
methods allow you to do cleanly.

Another, and rather esoteric use, is to use the class as its own instance.

I  find that static methods are useful when I want to import a class from
a module, and don't want to import the module itself or a lot of bits and
pieces from the module. The class gives a place to park the method, and
also lets you use inheritance, neither of which putting it into the module
does.

John Roth

 Thanks

 Colin

 

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


Re: py2exe for WMI

2005-05-24 Thread Thomas Heller
Tim Golden schrieb:
 [Thomas Heller]
 
 [... snip problems with py2exe  WMI ...]
 
 | The OP of the thread Tim mentions here already had a solution, if I 
 | understood him correctly, and the other things that were suggested 
 | didn't work.  Basically, IIUC, he did add the typelib 
 | wrappers from the 
 | 'other' windows version manually to the library.zip file.
 | 
 | Totally different solutions would be:
 | - change Tim's wmi.py module so that it works with dynamic 
 | binding (no 
 | typelib wrappers needed)
 | or
 
 Well, if it helps, there's a version of the WMI module
 that uses dynamic binding on my site:
 
 http://timgolden.me.uk/python/downloads/wmi-0.6a.py
 
 I've hardcoded the relevant constants (which is pretty 
 much all I was using early binding for) and replaced 
 any other EnsureDispatch calls with simple Dispatch.

It may be dangerous since the constants may or may not be the same on 
different versions, at least in theory.  I've appended a small module 
which allows to bind constants from the type library at runtime.
Not much error checking, but you may get the idea.  I'll leave providing 
a proper patch for pywin32, if it makes sense, to those that have more 
time ;-)

 Does anyone want to give it a try to let me know if
 it helps? I don't use py2exe myself.

The simple test case I have works on XP (I don't use wmi myself, except 
as sample for py2exe).

Thomas

# constants.py

class ProvideConstants(object):
 A class which, when called on a win32com.client.Dispatch object,
 provides lazy access to constants defined in the typelib.

 They can be accessed as attributes of the _constants property.
 def __init__(self, comobj):
 comobj.__dict__[_constants] = self
 # Get the typelibrary's typecomp interface
 self.__typecomp = \
comobj._oleobj_.GetTypeInfo().GetContainingTypeLib()[0].GetTypeComp()

 def __getattr__(self, name):
 if name.startswith(__) and name.endswith(__):
 raise AttributeError, name
 result = self.__typecomp.Bind(name)
 # Bind returns a 2-tuple, first item is TYPEKIND,
 # the second item has the value
 if not result[0]:
 raise AttributeError, name
 return result[1].value

if __name__ == __main__:
 from win32com.client import Dispatch
 d = Dispatch(WbemScripting.SWbemLocator)
 ProvideConstants(d)

 print d._constants.wbemImpersonationLevelAnonymous
 print d._constants.wbemImpersonationLevelDelegate
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Hacking the scope to pieces

2005-05-24 Thread gry

Hugh Macdonald wrote:
 We're starting to version a number of our python modules here, and
I've
 written a small function that assists with loading the versioned
 modules...

 A module would be called something like: myModule_1_0.py

 In anything that uses it, though, we want to be able to refer to it
 simply as 'myModule', with an environment variable
(MYMODULE_VERSION
 - set to 1.0) that defines the version.

Another technique that you might want to consider, is to have an
explicit
require call in the code, instead of an external environment
variable.
The python gtk interface, pygtk, is used like so:

import pygtk
pygtk.require('1.5')
import gtk

-- or

import pygtk
pygtk.require('2.0')
import gtk

I imagine you could eliminate the extra import gtk step, by clever
coding of the import hook.  You can find pygtk at:

http://ftp.gnome.org/pub/GNOME/sources/pygtk/2.4/pygtk-2.4.1.tar.gz


 I've written a module called 'moduleLoader' with the follwing
function
 in:

 def loadModule(module, version, v = globals()):
   import compiler
   loadStr = import %s_%s as %s % (module, version.replace(.,
_),
 module)
   eval(compiler.compile(loadStr, /tmp/%s_%s_errors.txt % (module,
 version.replace(., _)), single))
   v[module] = vars()[module]


 The ideal situation with this would be to be able, in whatever
script,
 to have:

 import moduleLoader
 moduleLoader.loadModule(myModule, os.getenv(MODULE_VERSION))


 However, this doesn't work. The two options that do work are:

 import moduleLoader
 moduleLoader.loadModule(myModule, os.getenv(MODULE_VERSION),
 globals())


 import moduleLoader
 moduleLoader.loadModule(myModule, os.getenv(MODULE_VERSION))
 from moduleLoader import myModule


 What I'm after is a way of moduleLoader.loadModule working back up
the
 scope and placing the imported module in the main global scope. Any
 idea how to do this?
 
 
 --
 Hugh Macdonald

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


Re: Running a python program during idle time only

2005-05-24 Thread los
Yes it should.  The problem is that I notice a loss in performance when
the program is running at 100% CPU.  Even though it is nice, if you try
to open up new applications, or switch between them, you notice your
computer lagging a little bit.  That's why even though I'm not using
the cpu that much as I'm just reading my email, or browsing the web, I
wouldn't necessarily want the indexing program to be running at full
pace.  If you use google's desktop program, you'll notice that once the
computer has been idle for a few minutes your CPU will go to 100%, but
as soon as you move your mouse, or hit a keystroke the cpu will drop to
5-10% usage.  That's the behavior I'm trying to achieve.

Thanks David for your suggestions.  That seems to be what I was looking
for.  I'm going to try to incorporate those changes in my code and see
what I can come up with.  Thanks for everyone who responded as well.  I
really appreciate it.

-los

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


Re: Python 2.4.1 installation problem

2005-05-24 Thread Philippe C. Martin
I had not realized (silly me) that Python might need external libraries in
order to support specific modules.

I have installed the bz2 and readline devel packages re-configured/made and
everythin os now working.




Philippe C. Martin wrote:

 Hi,
 
 I am trying to install 2.4.1 on a new machine and have the following
 problems.
 
 1) I'm on MDK 10.1
 2) The system had 2.3.4 installed in /usr , I deleted the lib
 3) I ran ./configure --prefix=/usr, then make, then make install,
 everything went OK
 
 
 If I run Python, I get
 
 File /etc/pythonrc.py, Line 2 in ?
 ImportError: no module readline
 
 
 
 I also tried to run one of my script and got an import error on bz2.
 
 
 I have 2.4.1 running OK on another machine with the exact same distro.
 
 
 Any clue ?
 
 Thanks,
 
 Philippe

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


Re: first release of PyPy

2005-05-24 Thread ionel
so what could this PyPy do in the future ?  .. concretely ...
hope this is not a stupid question

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


Re: What are OOP's Jargons and Complexities?

2005-05-24 Thread Matthias Buelow
Andreas Rottmann wrote:

 You get terminology totally wrong here. As already said, Lisp is
 stronger typed than C, but C is statically typed, whereas Lisp is
 dynamically typed. In Lisp (or Scheme), all variables have types:
 
 (define foo #(1 2 3))
 (vector? foo) = #t
 (boolean? foo) = #t

Hmm.. weird Scheme you're using here.
Normally you have to quote the vector (see R5RS, 6.2.6) because it is
not self-evaluating, and boolean? should not return true on vectors (6.3.1).

I get (on scheme48):

(define foo '#(1 2 3))
(vector? foo)  = #t
(boolean? foo) = #f


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


Re: Encryption with Python?

2005-05-24 Thread James Stroud
For your own good, please change your credit card number now! You have 
obviously lost your mind. Please read Applied Cryptography if you are 
wondering why I would say this. I am not trying to be mean.

For example:

I have access to 80 Pentium 3 cpus (at ~1.8 GHz) and have engineered a simple 
brute force on this (in pure python) that can check 2**31 integers overnight. 
I timed it. I used absolutely NO optimization. Also, beyond these 2**31 
integers, I stopped trying because I have other things to do--I had no 
incentive. Now your credit card info is on the line. I'm a rank ammy and I'm 
sure a skilled programmer could speed it up 100 to 1000 fold (1000 ~ 2**10). 
Also, this was for your first message about which I knew positively nothing. 
You have made the job now several times easier (lets say 10 ~ 2**3) by 
disclosing the nature of the plain text. If you think that there are lots of 
keys that map some part of your cipher text to a set of 16 numbers (+/-) 
separators, you are right. But they would be some small fraction of the total 
keyspace. 10**6 such keys could be stored easily and so second and later 
rounds of analysis would be trivial.

So lets do some math. Say someone had the same computing power as I do. Say, 
we could start with 2**32 keys in 24 hours or 1 day. Now lets say they are a 
good programmer: 2**32 * 2**10 keys/day. Now lets say they take full 
advantage of knowing the nature of the plain text: 3**32 * 2**10 * 2**3. Lets 
say they put 2 weeks of computing time into it: 14 days ~ 2**4 days.

Of course both + and - integers are possible, so we'll divide our final answer 
by 2 later.

So, say you had a highly motivated, reasonably adept programmer whose lack of 
cryptanalysis knowledge limited himself to brute force--but he had a lot of 
computers and 2 weeks to work with--and was checking both + and - integers:

2**(32+10+3+4-1) = 281474976710656

That's 15 digits. That is a telephone number (with area code) and a 5 digit 
zip. That's 2 birthdays, easy. That is easily the hash of any hashable python 
object (only 2**32 possibilities for these). Do you get the point? Basically, 
these 15 digits are about the limit of any managable key.

Now, lets say you have someone skilled at cryptanalysis. Well, they are 
probably already trying to figure out what they want to buy first. Normally I 
wouldn't warn you of this, but I am positively certain that someone smarter 
than me will be spending on your credit card and I want to spoil their 
holiday.

James


On Tuesday 24 May 2005 01:16 am, Anthra Norell wrote:
 I wasn't going to pursue this any further. Actually, I am quite
 disappointed about the belligerent style of some correspondents. It's not
 necessary. It spoils the fun. It cloggs bandwidth.
Why whack someone over the head who tries to develop an idea of his own.
 Such an approach isn't uncommon to earn extra credit in educational
 settings.
True, I have also been offered good advice and being able to extract it
 from between insuslts I have expressed my appreciation for it. In return of
 the favor I offer a little anecdote about the nature of creativeness.
The connection between candor and creativeness has always fascinated me.
 At some point, almost thirty years ago, I came across an article in a hang
 glider magazine by one Dr. Paul MacCready who had just won the Kremer Prize
 with his human-powered Gossamer Condor, a prize that had been standing for
 decades despite innumerable unsuccessful attempts to win it. In that
 article MacCready explained that it was the advent of hang gliders that
 gave him the idea to go for the Kremer prize. Namely, he immediately
 realized that hang gliders dissipated less energy in stable flight than any
 other aircraft in existence, not because the flew so well--they didn't--but
 because of their low weight. He calculated that a twenty-kilogram hang
 glider with a wing span of close to thirty meters would dissipate no more
 than one third of a horse power or thereabout and that is an amount of
 energy a competition cyclist generates over the course of a race.
 After winning the prize, MacCready challenged himself to fly across the
 English channel and started building an improved second version of his
 airplane. Passing through Los Angeles I went to see the project in a Long
 Beach hangar and took the opportunity to pick MacCready's brain for the
 benefit of our own magazine. Referring to his article I confessed my
 surprise that a scientist of his caliber would be inspried by such crude
 aeronautical engineering hacks as hang gliders unquestionably were. His
 reply was this:
 I also consider myself an amateur. I have a PhD in aeronautics, but
 not in aeronautical engineering. But this just might have been my
 advantage. All these many previous failed attempts had been made by people
 with better engineering credentials. If their conception of possible
 solutions was better defined, it was probably also more constrained by
 

pygame 1.6 for windows (python2.4)

2005-05-24 Thread bc
Hi All,

Does anyone have any info concerning the windows pygame 1.6 for
python2.4?  It doesn't seem to be available yet.   Will pygame1.6 for
python23 work with python24?

Thanks for any help concerning this.

BC

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


Re: Just remember that Python is sexy

2005-05-24 Thread Do Re Mi chel La Si Do
:-)



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


Re: first release of PyPy

2005-05-24 Thread Carl Friedrich Bolz
ionel wrote:
 so what could this PyPy do in the future ?  .. concretely ...
 hope this is not a stupid question
 
Maybe the description from the homepage says it best:

The PyPy project aims at producing a flexible and fast Python 
implementation. The guiding idea is to translate a Python-level 
description of the Python language itself to lower level languages. 
Rumors have it that the secret goal is being faster-than-C which is 
nonsense, isn't it?


Regards,

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


Linuz Python Module using PythonC/ API

2005-05-24 Thread David
I have this error message poping up when I try to import a module I made in C
using the Python/C API. Everything compiles like a charm.

Gives me this error message :

Traceback (most recent call last):
  File mod_test.py, line 4, in ?
import utm
ImportError: dynamic module does not define init function (initutm)

but the initutm function is there.

Running on Fedora Core 3.

Thanx 
David

P.S Other question is there a command to know what export symbols a .so library
has ?

Relevant files below.

utmmodule.c
--
#include Python.h

#include utm.h


PyMODINIT_FUNC initutm(void);

static PyObject * utm_utm_to_ll(PyObject * self, PyObject * args);

static PyObject * utm_ll_to_utm(PyObject * self, PyObject * args);

static PyObject * utm_zone(PyObject * self, PyObject * args);

static PyObject * utm_grid(PyObject * self, PyObject * args);

static PyObject * utm_trans_list(PyObject * self, PyObject * args);

static PyObject * utm_transform(PyObject * self, PyObject * args);



//

/*! \var static PyObject * UTMError

\brief UTM Python Module error handling object

*/

//

static PyObject * UTMError;



//

/*! \var static PyMethodDef UTMMethods 

\brief UTM Python Module function list

*/

//

static PyMethodDef UTMMethods[] = {

  

  {utm_to_ll,  utm_utm_to_ll, METH_VARARGS, Converts UTM coordinates to
Lat/Long using the input UTM zone number and letter and tranformation.},

  {ll_to_utm,  utm_ll_to_utm, METH_VARARGS, Converts Lat/Long coordinates to
UTM using the input transformation.},

  {zone,  utm_zone, METH_VARARGS, Returns the UTM longitude zone number.},

  {grid,  utm_grid, METH_VARARGS, Returns the UTM latitude zone letter (C to
X) - omiting chars I and O.\nReturns Z if Latitude value out of UTM bounds 84N -
80S.},

  {trans_list,  utm_trans_list, METH_VARARGS, Returns the list of available
ellipsoid transformations in a list.},  

  {transform,  utm_transform, METH_VARARGS, Returns the tranform index based
on the transform type string, EX: 'WGS 84' returns index 29},  

  {NULL, NULL, 0, NULL}/* Sentinel */

};



//

/*! \fn PyMODINIT_FUNC initutm(void)

\brief Python Module __init__() function



This function is called when the module is loaded by Python. It creates a
mapping of the

python module commands linked to their C counterpart in the DLL/SO module.
It also creates

an error handling Python object (UTMError).

*/

//



PyMODINIT_FUNC initutm(void) {

  

  PyObject *m;

  

  m = Py_InitModule( utm, UTMMethods );

  

  UTMError = PyErr_NewException( utm.error, NULL, NULL );

  Py_INCREF( UTMError );

  PyModule_AddObject( m, error, UTMError );

}

--

makefile important lines
---
CC=g++

CFLAGS=-Wall -I/usr/local/src/Python-2.3.5/Include
-L/usr/local/src/Python-2.3.5/Objects -L/usr/local/src/Python-2.3.5

LDFLAGS=



all: main



main: utm.o utmmodule.o

$(CC) $(CFLAGS) -shared -fPIC -Xlinker -export-dynamic -lpython2.3 -o 
utm.so

---

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


Re: python24.zip

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

 if the importers are tested statically how does a filesystem path ever
 manage
 to get back into the loop if it was ever found missing? In other words if
 things (eg python24.zip) are found not importable/usable in one pass how do
 they get reinstated?

I think (but see the code yourself) that only the successful importers
are cached.

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


Re: reference counting and file objects

2005-05-24 Thread Martin v. Löwis
Peter wrote:

 Does the idiom:
 
 lines = file(myfile,r).readlines()
 
 have any better guarantee of being closed automatically? 

Yes. The file object only lives on the evaluation stack,
and that is discarded in any case when the function terminates
(whether through a return or through an exception). In
addition, the object is released as soon as readlines
returns.

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


Re: pygame 1.6 for windows (python2.4)

2005-05-24 Thread Will McGugan
bc wrote:
 Hi All,
 
 Does anyone have any info concerning the windows pygame 1.6 for
 python2.4?  It doesn't seem to be available yet.   Will pygame1.6 for
 python23 work with python24?

Have you been to the site? 1.6 is available, and there are versions for 
Python2.3 and Python2.4

http://www.pygame.org/download.shtml


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: reference counting and file objects

2005-05-24 Thread Paul Rubin
Martin v. Löwis [EMAIL PROTECTED] writes:
  lines = file(myfile,r).readlines()
  
  have any better guarantee of being closed automatically? 
 
 Yes. The file object only lives on the evaluation stack,
 and that is discarded in any case when the function terminates
 (whether through a return or through an exception). In
 addition, the object is released as soon as readlines
 returns.

It's released even if the exception is raised inside readlines?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PIL and line drawing

2005-05-24 Thread rzed
Fredrik Lundh [EMAIL PROTECTED] wrote in
news:[EMAIL PROTECTED]: 

 rzed [EMAIL PROTECTED] wrote:
 
  if you have 1.1.5, you can use the width option to control
  the line width. see:

 I'm glad to see that addition. I was surprised to see that
 'width' is actually doubled in the resulting line, though. I
 suppose the code adds and subtracts the specified width from
 the specified coordinate point(?).
 
 hmm.  that sure sounds a lot like a bug I though I had fixed.
 
Ah, I see that I was using   VERSION = 1.1.5b1 which I have now
upgraded to 1.1.5. Retesting ... nope, same thing. Specifying a
width of 10, I get a line of width 20. ImageDraw shows: 

# $Id: ImageDraw.py 2134 2004-10-06 08:55:20Z fredrik $

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


Re: Dr. Dobb's Python-URL! - weekly Python news and links (May 24)

2005-05-24 Thread Cameron Laird
In article [EMAIL PROTECTED],
Rocco Moretti  [EMAIL PROTECTED] wrote:
Simon Brunning wrote:
 QOTW: If you're sick of answering newbie questions, and don't think you
 can do so politely, for the sake of the community, DON'T!  You're not that
 necessary. - Joal Heagney

Taken out of context, Joal's comments might seem a bit rude and abrasive 
- I don't think they were meant that way. People really should look at 
the context of the quote - it'a actually a very constructive suggestion.

(If the direct link works:)
http://groups-beta.google.com/group/comp.lang.python/msg/6330925dcecb6bdb
.
.
.
General principle:  if in doubt about the significance of an item in
Python-URL!, assume that it's intended in a constructive way.  In
our emphasis on brevity, though, we sometimes abbreviate to the point
that ambiguity obscures the civility.  Thanks to Mr. Moretti for his
well-referenced observation.
-- 
http://mail.python.org/mailman/listinfo/python-list


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

2005-05-24 Thread Fredrik Lundh
Dieter Maurer wrote:

 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.

nothing guarantees that, of course.  but I've never seen that
happen. and I'm basing my comments on observed behaviour in
real systems, not on theoretical worst-case scenarios.  every
time I've seen serious fragmentation, it's been related to leaks,
not peak memory usage.

/F



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


Re: Linux Python Module using PythonC/ API

2005-05-24 Thread David Legault
Hi Jeff thanx for the reply

I'm a complete noob when it comes to Linux and trying to learn how to manage
the compilation process of the same objects that work on windows.

The complete linking line is this.

--

all: main

main: utm.o utmmodule.o
$(CC) $(CFLAGS) -shared -fPIC -Xlinker -export-dynamic -lpython2.3 -o
utm.so

---

If you could direct me into how to properly link the stuff into the .so
file, I'd appreciate it.

I will check to see if the symbols are effectively exported to the .so file.

In windows I found it pretty easy to create the module files as dlls.

Thanx

David

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


Re: python24.zip

2005-05-24 Thread Dieter Maurer
Steve Holden [EMAIL PROTECTED] writes on Sun, 22 May 2005 16:19:10 -0400:
 ...
 Indeed I have written PEP 302-based code to import from a relational
 database, but I still don't believe there's any satisfactory way to
 have [such a hooked import mechanism] be a first-class component of an
 architecture that specifically requires an os.py to exist in the file
 store during initialization.
 
 
 I wasn't asking for an import hook mechanism (since I already knew
 these to exist), but for a way to allow such mechanisms to be the sole
 import support for certain implementations.

We do not have os.py (directly) on the file system.
It lives (like everything else) in a zip archive.

This works because the zipimporter is put on
sys.path_hook before the interpreter starts executing Python code.

Thus, all you have to do: use a different Python startup
and ensure that you special importer (able to import e.g. os)
is already set up, before you start executing Python code.


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


Re: python24.zip

2005-05-24 Thread Dieter Maurer
Martin v. Löwis [EMAIL PROTECTED] writes on Sun, 22 May 2005 21:24:41 +0200:
 ...
 What do you mean, unable to? It just doesn't.

The original question was: why does Python put non-existing
entries on 'sys.path'.

Your answer seems to be: it just does not do it -- but it might
be changed if someone does the work.

This fine with me.

 ...
 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.

I do not argue that Python should prevent adding non-existing
items on path. This would not work as Python may not
know what existing means (due to path_hooks).

I only argue that it should not *itself* (automatically) put items on path
where it knows the responsible importers and knows (or can
easily determine) that they are non existing for them.

 ...
  The application was Zope importing about 2.500 modules
  from 2 zip files zope.zip and python24.zip.
  This resulted in about 12.500 opens -- about 4 times more
  than would be expected -- about 10.000 of them failing opens.
 
 I see. Out of curiosity: how much startup time was saved
 when sys.path was explicitly stripped to only contain these
 two zip files?

I cannot tell you precisely because it is very time consuming
to analyse cold start timing behavior (it requires a reboot for
each measurement).

We essentially have the following numbers only:

   warm startcold start
(filled OS caches)(empty OS caches)

from file system5s 13s
from ZIP archives   4s  8s
frozen  3s  5s

The ZIP archive time was measured after a patch to import.c
that prevents Python to view a ZIP archive member as a directory
when it cannot find the currently looked for module (of course,
this lookup fails also when the archive member is viewed as a directory).
Furthermore, all C-extensions were loaded via a meta_path hook (and
not sys.path) and sys.path contained just the two Zip archives.
These optimizations led to about 3.000 opens (down from originally 12.500).

 I would expect that importing 2500 modules takes *way*
 more time than doing 10.000 failed opens.

You may be wrong: searching for non existing files may cause
disk io which is several orders of magnitude slower that
CPU activities.

The comparison between warm start (few disc io) and cold start
(much disc io) tells you that the import process is highly
io dominated (for cold starts).

I know that this does not prove that the failing opens contribute
significantly. However, a colleague reported that the
import.c patch (essential for the reduction of the number of opens)
resulted in significant (but not specified) improvements.


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


PAM authentication?

2005-05-24 Thread Gary Wilson Jr
I would like my application to be able to authenticate through PAM. Is
there any code out there that implements this? All I could find was PyPAM
(http://www.pangalactic.org/PyPAM/), which doesn't look like it has been
touched in almost 6 years and requires python1.5.

-- 
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 24, 2005 10:49:20 am

2005-05-24 Thread The Ghost In The Machine
In comp.os.linux.advocacy, [EMAIL PROTECTED]
[EMAIL PROTECTED]
 wrote
on 24 May 2005 07:48:47 -0700
[EMAIL PROTECTED]:

 THE MOST IMPORTANT QUESTION OF YOUR LIFE

 This is the most important question of your life.

 The question is: Are you saved?

I'm tempted to ask if you're *shaved* (I'm not).  Why you're
asking this in technical groups is far from clear.  God
doesn't care if you're using Python, C, Matlab, Linux, or OSX,
at least, not as far as I know.

It is vaguely possible that the Almighty has in fact
upgraded his internal communications network to include
TCP/IP, MBone, and Etherial Prayer Protocol (EPP), but
I'd prefer to see hard evidence.

Followups to a slightly more logical place. :-)

[rest snipped]

-- 
#191, [EMAIL PROTECTED]
It's still legal to go .sigless.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pygame 1.6 for windows (python2.4)

2005-05-24 Thread bc
Thanks for the reply, Will... I have been to the site, but I get a URL
not found error when I try the pygame 1.6 for python24 link;  I guess
I will just keep trying until the HTML is fixed.

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


Re: PAM authentication?

2005-05-24 Thread Diez Roggisch
Gary Wilson Jr wrote:
 I would like my application to be able to authenticate through PAM. Is
 there any code out there that implements this? All I could find was PyPAM
 (http://www.pangalactic.org/PyPAM/), which doesn't look like it has been
 touched in almost 6 years and requires python1.5.
 

You can still use it. However what I don't like about it is that you 
need to run  as root to actually use PAM. Otherwise the process can only 
authenticate its (effective?) user.

So I switched to LDAP - and would like to see sasld being supported, but 
so far it's not wrapped I haven't found the time to do it myself.


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


Re: searching substrings with interpositions

2005-05-24 Thread Andrew Dalke
Claudio Grondi wrote:
 Note: code below is intended to help to clarify things only,
 so that a bunch of examples can be tested.
 If you need bugfree production quality code, maybe
 someone else can provide it.

Still not tested enough to ensure that it's bug free, but more
concise.  Here's one the implements the algorithm directly and
another that uses a regexp.  The latter should be the preferred
approach.  My intent was that the algorithm implements the given
pattern so they should given identical results.

# Doing the work ourselves
def find_spread_substring(query, target, limit = None):
stack = []
ti = qi = 0
Nq = len(query)
Nt = len(target)
delta = 0

while ti  Nt:
# We have a match
if query[qi] == target[ti]:
stack.append( (qi, ti, delta) )
qi = qi + 1
if qi == Nq:
return [ti for (qi, ti, delta) in stack]
ti = ti + 1
delta = 0
else:
# No match
while 1:
# If we have a partial match, check if we've
# gone over the limit.
if stack:
delta = delta + 1
if limit is not None and delta  limit:
# backtrack, treating it as an invalid match
# (so retry this 'else:' block)
qi, ti, delta = stack.pop()
continue
# No backtracking needed
break
# Advance to check the next character in the target
ti = ti + 1

# Failure
return None

# Using regular expressions
import re
def find_spread_substring2(query, target, limit = None):
if limit is None:
template = (%s).*?
else:
template = (%%s).{,%d}? % (limit,)
terms = [template % c for c in query]
pattern = .join(terms)

pat = re.compile(pattern)
m = pat.search(target)
if not m:
return None
return [m.start(i) for i in range(1, len(query)+1)]


def test():
for (q, t, limit, is_valid) in (
(1010, 10001001, None, True),
(1010, 100011, None, False),
(1010, 100010, 3, True),
(1010, 100010, 1, True),
(1010, 110, 1, False),
(1010, 0110, 2, True),
(1010, 0110, 1, False),
(1010, 010, None, False),

):
result = find_spread_substring(q, t, limit)
result2 = find_spread_substring2(q, t, limit)
if result != result2:
raise AssertionError( (result, result2) )

if result is not None:
if limit is not None:
# check that it's a proper subset
for (x, y) in zip(result[:-1], result[1:]):
# +1 because 'limit' is the maximum gap size
if (y-x)  limit+1:
raise AssertionError((q, t, limit, result, x, y))
s = .join([t[i] for i in result])
if s != q:
raise AssertionError((q, t, limit, result, s))

if result is None and not is_valid:
pass
elif result is not None and is_valid:
pass
else:
raise AssertionError( (q, t, limit, is_valid, result) )

if __name__ == __main__:
test()
print All tests passed.


Andrew
[EMAIL PROTECTED]

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


Re: python24.zip

2005-05-24 Thread Martin v. Löwis
Dieter Maurer wrote:
 The comparison between warm start (few disc io) and cold start
 (much disc io) tells you that the import process is highly
 io dominated (for cold starts).

Correct. However, I would expect that the contents of existing
directories is cached, and it might be that the absence of a directory
on sys.path is also cached (I know Linux does negative dentry caching).

 I know that this does not prove that the failing opens contribute
 significantly. However, a colleague reported that the
 import.c patch (essential for the reduction of the number of opens)
 resulted in significant (but not specified) improvements.

When I experimented with startup time for 2.4, I found that these
calls don't matter at all in any significant way (atleast not for
warm starts). Instead, I found that reducing the size of .pyc files,
by sharing interned strings, gives more speedup (and indeed, 2.4
changed the marshal format to accommodate shared interned strings).

So I would agree that IO makes a significant part of startup, but
I doubt it is directory reading (unless perhaps you have an
absent NFS server or some such).

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


Re: pygame 1.6 for windows (python2.4)

2005-05-24 Thread Will McGugan
bc wrote:
 Thanks for the reply, Will... I have been to the site, but I get a URL
 not found error when I try the pygame 1.6 for python24 link;  I guess
 I will just keep trying until the HTML is fixed.
 

Does seem to be broken at the moment. I've uploaded a copy to my server..

http://www.willmcgugan.com/pygame-1.6.win32-py2.4.exe

Will
-- 
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


  1   2   >