Re: Can you introduce some book about python?

2005-05-21 Thread rdsteph
You m,igth try my page of Python Book reviews at
http://www.awaretek.com/book.html

Ron Stephens


fdsl ysnh wrote:
> --- [EMAIL PROTECTED]:
>
> > Send Python-list mailing list submissions to
> > python-list@python.org
> >
> > To subscribe or unsubscribe via the World Wide Web,
> > visit
> > http://mail.python.org/mailman/listinfo/python-list
> > or, via email, send a message with subject or body
> > 'help' to
> > [EMAIL PROTECTED]
> >
> > You can reach the person managing the list at
> > [EMAIL PROTECTED]
> >
> > When replying, please edit your Subject line so it
> > is more specific
> > than "Re: Contents of Python-list digest..."
> > > Today's Topics:
> >
> >1. Re: appending key-value pairs to a dict (Peter
> > Hansen)
> >2. Re: Is Python suitable for a huge, enterprise
> > size app?
> >   (Paul Rubin)
> >3. Re: appending key-value pairs to a dict (Brian
> > Beck)
> >4. Re: Comparing 2 similar strings? (Skip
> > Montanaro)
> >5. Re: Is Python suitable for a huge, enterprise
> > size app?
> >   (Paul Rubin)
> >6. Re: buffer_info error ([EMAIL PROTECTED])
> >7. Re: appending key-value pairs to a dict (James
> > Stroud)
> >8. From the call hook, how do I know more
> > precisely what is
> >   called? (Vijay Kumar)
> >9. Re: PyGame and Rotozoom (Sorry if OT) (Lee
> > Harr)
> >   10. Re: buffer_info error (Jp Calderone)
> >   11. Re: appending key-value pairs to a dict (Roy
> > Smith)
> >   12. Re: Is Python suitable for a huge, enterprise
> > size app?
> >   (Dave Brueck)
> >   13. Re: Process monitoring (John Abel)
> > > 发件人: Peter Hansen <[EMAIL PROTECTED]>
> > 收件人: python-list@python.org
> > 日期: Fri, 20 May 2005 16:12:17 -0400
> > 主题: Re: appending key-value pairs to a dict
> >
> > rbt wrote:
> > > I know how to setup an empty list and loop thru
> > something... appending
> > > to the list on each loop... how does this work
> > with dicts?
> > >
> > > I'm looping thru a list of files and I want to put
> > the file's name and
> > > its sha hash into a dict on each loop.
> >
> > Whereas with a list you would call "append" in the
> > loop, with a
> > dictionary you simply use an indexed-assignment type
> > of access:
> >
> > mydict = {}
> > for filename in some_list_of_filenames:
> >  hash =
> > sha.sha(open(filename).read()).hexdigest() # or
> > whatever
> >  mydict[filename] = hash
> >
> > -Peter
> >
> > > 发件人: Paul Rubin 
> > 收件人: python-list@python.org
> > 日期: 20 May 2005 13:12:50 -0700
> > 主题: Re: Is Python suitable for a huge, enterprise
> > size app?
> >
> > Dave Brueck <[EMAIL PROTECTED]> writes:
> > > One thing from your experience that did resonate
> > with me is that,
> > > except for ftplib and occasionally urllib (for
> > basic, one-shot GETs),
> > > we don't use any of the standard library's
> > "protocol" modules - partly
> > > because we had to implement our own HTTP libraries
> > for performance and
> > > scalability reasons anyway, and partly because we
> > had trouble figuring
> > > out e.g. all the ins and outs of
> > urllib/urllib2/httplib.
> >
> > What do you use for HTTPS?  And did you use the
> > Cookie module in your
> > HTTP servers?  You may have had problems without
> > even being aware of
> > them (until recently if you used Cookie with its
> > default settings, any
> > attacker could completely take over your server by
> > sending you
> > carefully concoted cookies).  I'm not trying to be
> > contentious here,
> > just mentioning a couple further cases of where
> > problems aren't
> > visible from far away but are there when you look
> > close.
> >
> > > 发件人: Brian Beck <[EMAIL PROTECTED]>
> > 收件人: python-list@python.org
> > 日期: Fri, 20 May 2005 16:14:17 -0400
> > 主题: Re: appending key-value pairs to a dict
> >
> > rbt wrote:
> > > I know how to setup an empty list and loop thru
> > something... appending
> > > to the list on each loop... how does this work
> > with dicts?
> > >
> > > I'm looping thru a list of files and I want to put
> > the file's name and
> > > its sha hash into a dict on each loop.
> >
> > Like so:
> >
> > d = {}
> > for filename in files:
> >  d[sha_func(filename)] = filename
> >
> >
> > Or like so:
> >
> > d = dict([(sha_func(filename), filename) for
> > filename in files])
> >
> > --
> > Brian Beck
> > Adventurer of the First Order
> >
> > > 发件人: Skip Montanaro <[EMAIL PROTECTED]>
> > 抄送: python-list@python.org
> > 收件人: Steve Holden <[EMAIL PROTECTED]>
> > 日期: Fri, 20 May 2005 15:16:49 -0500
> > 主题: Re: Comparing 2 similar strings?
> >
> >
> > Steve> (is this the same as 'Conchobar'?)
> >
> > No, that's a trendy pub in Key West...
> >
> > 
> >
> > Skip
> >
> > > 发件人: Paul Rubin 
> > 收件人: python-list@python.org
> > 日期: 20 May 2005 13:15:48 -0700
> > 主题: Re: Is Python suitable for a huge, enterprise
> > size app?
> >
> > "Fredrik Lundh" <[EMAIL PROTECTED]> writes:
> > > this has been reported before, and it won't get
> > fi

Re: SQL Query via python

2005-05-21 Thread Heiko Wundram
Am Samstag, 21. Mai 2005 06:54 schrieb Sakesun Roykiattisak:
> Try
>
> cursor.execute (
> """
>   SELECT name, month, day ,category, city FROM bday
>   WHERE %s = %s
> """
>   %(arg1,arg2))

*argh* You don't do any quoting of SQL-parameters, and that's more than bad! 
(leaves you up to the mercy of SQL-injection attacks, for example)

What you basically want to have is something like the following:

# Make sure arg1 is actually just characters.
if not arg1.isalpha():
raise RuntimeError, "trying to do SQL-injection attack?!"

# Now do query.
cursor.execute("""
SELECT name, month, day, category, city FROM body
WHERE %s = %%s
""" % (arg1,),
(arg2,))

See how I didn't just use arg1 to paste it in the query string, but checked it 
before trying the query to consist only of characters. You'd have to adjust 
this accordingly for field-names you use (maybe you use underscores, etc.). 
But, be sure that arg1 contains no ";"!

HTH!

-- 
--- Heiko.
  see you at: http://www.stud.mh-hannover.de/~hwundram/wordpress/


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

Re: Can you introduce some book about python?

2005-05-21 Thread Heiko Wundram
Am Samstag, 21. Mai 2005 08:59 schrieb [EMAIL PROTECTED]:
> 

Quoting a senseless quote, bravo!

...

wasting-bandwith-sure-is-fun-over-ISDN-'ly yours,

-- 
--- Heiko.
  see you at: http://www.stud.mh-hannover.de/~hwundram/wordpress/


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

Re: first release of PyPy

2005-05-21 Thread Torsten Bronger
Hallöchen!

Paul Rubin  writes:

> Torsten Bronger <[EMAIL PROTECTED]> writes:
>
>> Please could somebody explain to us non-CS people why PyPy could
>> have speed features CPython can't have?
>
> Does the one-word answer "compiler" explain enough?

No, just more questions.  ;-)

What's supposed to be compiled?  Only PyPy itself or also the
programs it's "interpreting"?

: "In the next step
of the project, we will generate C code or machine code from the
source of Pypy, thereby reducing the speed penalty."

I've been told by so many books and on-line material that Python
cannot be compiled (unless you cheat).  So how is this possible?

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetus
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: first release of PyPy

2005-05-21 Thread Ville Vainio
> "Torsten" == Torsten Bronger <[EMAIL PROTECTED]> writes:

Torsten> What's supposed to be compiled?  Only PyPy itself or also
Torsten> the programs it's "interpreting"?

PyPy is written in python, if it can be compiled then the programs can
be as well.

Torsten> I've been told by so many books and on-line material that
Torsten> Python cannot be compiled (unless you cheat).  So how is
Torsten> this possible?

These guys are exploring a new territory. OTOH, Lisp is a dynamic
language like python and it can be compiled to native code. Pyrex
demonstrates the "trivial" way to compile python to native code, the
real problem is making the resulting code fast. Typically this
requires type inference (i.e. figuring out the type of an object from
the context because there are no type declarations) to avoid dict
lookups in method dispatch.

This is not about PyPy but it might help:

http://www.python.org/pycon/dc2004/papers/1/paper.pdf

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


Re: first release of PyPy

2005-05-21 Thread Ville Vainio
> "Ville" == Ville Vainio <[EMAIL PROTECTED]> writes:

Ville> This is not about PyPy but it might help:

Ville> http://www.python.org/pycon/dc2004/papers/1/paper.pdf

(It's about starkiller, sorry about the opaque url)

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


Re: [pysqlite] How do I use pysqlite in a multi-threading env.?

2005-05-21 Thread F. GEIGER

"Gerhard Haering" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
news:[EMAIL PROTECTED]

I've completely rewritten the db handling stuff, which formerly did too much
behind the scenes (explicit is better than implicit...). Now everything
looks much better. No unexpected errors and - most important - locking works
as expected. I have no idea yet, what went wrong with the former (probably
more pythonic) solution. It always did it with MySQL as backend.

Anyway, I'm quite happy now, that I can work on a db, that is incorporated
into the app itself.

Thanks for your help, Gerhard! And, sorry for the troubles...

Kind regards
Franz GEIGER


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


Re: first release of PyPy

2005-05-21 Thread Shane Hathaway
Torsten Bronger wrote:
> Hallöchen!
> 
> "Kay Schluehr" <[EMAIL PROTECTED]> writes:
> 
> 
>>[...]
>>
>>[...] Once You get enough speed out of the PyPy-runtime and the
>>community shifts to it the PEP-process degenerates in the view of
>>a PyPythonista to discussions about aspects of the std-objectspace
>>and language design patterns. There will be some CPython
>>compliance - that's all.
> 
> 
> Please could somebody explain to us non-CS people why PyPy could
> have speed features CPython can't have?

The idea is to shift more of the responsibility to optimize code from
the human to the computer.  Since C code is at a low level, the computer
can only infer low level intent and thus perform low level
optimizations.  Humans optimize C by making thousands of speed-oriented
decisions directly in the code.  Python code is at a much higher level,
which should enable the computer to discover more of the programmer's
intent and perform deep optimizations.

In the end, the computer's automated optimization could turn out better
than a human's manual optimization.  Thus, by expressing the Python
interpreter in a high level manner, PyPy is a first step toward deep
optimizations that aren't possible to automate in C.

Even if things don't turn out that way, note that each generation of
programming languages builds on its predecessors, and PyPy could help
bootstrap the next generation.  Assemblers first had to be written in
machine code; when it was possible to write assemblers in assembly,
people started writing complex grammars and came up with C.  C compilers
first had to be written in assembly; when it was possible to write C
compilers in C, people started inventing high level languages.  Now
people are experimenting with high level compilers written in high level
languages.  Where will this pattern lead?  Who knows. :-)

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

Re: first release of PyPy

2005-05-21 Thread Kay Schluehr

Torsten Bronger wrote:
> Hallöchen!
>
> Paul Rubin  writes:
>
> > Torsten Bronger <[EMAIL PROTECTED]> writes:
> >
> >> Please could somebody explain to us non-CS people why PyPy could
> >> have speed features CPython can't have?
> >
> > Does the one-word answer "compiler" explain enough?
>
> No, just more questions.  ;-)
>
> What's supposed to be compiled?  Only PyPy itself or also the
> programs it's "interpreting"?

There is no "PyPy itself". The distinction bewteen interpreter-level
code and application-level code is nothing but a set of coding
conventions which are usefull but not necessary to let the type
inferencer ( "annotator" in PyPy slang ) terminate definitely on a set
of machine-translateable types in case of interpreter-level code. At
least the interpreter should not interpret it's own code after an
inititalisation phase. Currently type annotated application level code
will still be compiled into bytecodes but it is not only possible to
JIT and to specialize it by means of Psyco, but it should be possible
to compile parts of it into native code like we do today with
C-extensions.

It's hard for me to recognize a fixedpoint in this process or a clear
boundary between interpreter and application level code. This is IMO a
pure heuristic not a categorial distinction but is also clear there
will ever be a remaining gap due to the dynanism of the language. I
think a lot of research understanding this distinction will follow in
the next years.

As a conclusion: with PyPy Python will still be interpreted, but a
large corpus of Python code may be compiled into native code of the
underlying machine. 

Regards,
Kay

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


Re: first release of PyPy

2005-05-21 Thread Kay Schluehr

Shane Hathaway wrote:

> Now people are experimenting with high level compilers written in
high level
> languages.  Where will this pattern lead?  Who knows. :-)

Drift from old Europe ( greek Pythons ) to old India to "Nagas" and
other snake-beings and goddesses :-)

http://www.khandro.net/mysterious_naga.htm#many-headed

Regards,
Kay

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


Re: [Tutor] Comparing a string

2005-05-21 Thread Jonas Melian
Alan G wrote:
>>I'm tryin compare a string with a value with style of
> 
> Use regular expressions and turn it around:
> 
> import re
> s = 'i686'
> ex = re.compile('i?86')
> if ex.match(s): print 'they match!'
> 
> Is that what you mean?
> 
> Alan G.
> 
> 

Thanks, that's the way. But in a expression regular ('i?86') it would be:

('i[0-9]86') or ('i\d86') for match a number
-- 
http://mail.python.org/mailman/listinfo/python-list


IDLE 1.0.5 crashs on Windows

2005-05-21 Thread Torsten Bronger
Hallöchen!

I've installed Python 2.3.5, IDLE 1.0.5 on a Win2k box and have
fatal Windows errors with a trivial script.  You can see a
screenshot of the problem at
.
My script (on the left side) is trivial, namely

def _to_int(x):
return x

VI_SUCCESS   = _to_int(0x)
VI_SUCCESS_EVENT_EN  = _to_int(0x3FFF0002)
VI_SUCCESS_EVENT_DIS = _to_int(0x3FFF0003)
VI_SUCCESS_QUEUE_EMPTY   = _to_int(0x3FFF0004)
VI_SUCCESS_TERM_CHAR = _to_int(0x3FFF0005)
VI_SUCCESS_MAX_CNT   = _to_int(0x3FFF0006)
...


The shell window says the following:

Python 2.3.5 (#62, Mar 22 2005, 21:53:13) [MSC v.1200 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.


Personal firewall software may warn about the connection IDLE
makes to its subprocess using this computer's internal loopback
interface.  This connection is not visible on any external
interface and no data is sent to or received from the Internet.


IDLE 1.0.5   No Subprocess 
>>> Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Programme\Python23\lib\lib-tk\Tkinter.py", line 1345, in __call__
return self.func(*args)
  File "C:\Programme\Python23\lib\idlelib\ScriptBinding.py", line 135, in 
run_module_event
code = self.checksyntax(filename)
  File "C:\Programme\Python23\lib\idlelib\ScriptBinding.py", line 96, in 
checksyntax
return compile(source, filename, "exec")
  File "C:\Programme\Python23\lib\warnings.py", line 116, in warn_explicit
showwarning(message, category, filename, lineno)
  File "C:\Programme\Python23\lib\idlelib\PyShell.py", line 55, in 
idle_showwarning
file.write(warnings.formatwarning(message, category, filename, lineno))
IOError: [Errno 9] Bad file descriptor


Then it hangs, i.e., I can't input anything.  Does anybody know why
this happens?

Thank you!

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetus
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: IDLE 1.0.5 crashs on Windows

2005-05-21 Thread Torsten Bronger
Hallöchen!

Torsten Bronger <[EMAIL PROTECTED]> writes:

> I've installed Python 2.3.5, IDLE 1.0.5 on a Win2k box and have
> fatal Windows errors with a trivial script.  You can see a
> screenshot of the problem at
> .

At http://www-users.rwth-aachen.de/torsten.bronger/idle_error2.png
you see another error that I get when the soucecode looks slightly
different.  Sometimes it really crashes with a memory access error.
My IDLE has gone mad, hasn't it?

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetus
-- 
http://mail.python.org/mailman/listinfo/python-list

moving from c++ to python

2005-05-21 Thread Michael
Hi,
I'm a pretty sound programmer in C++, but would like to learn python! Does
anyone know of any tutorial s aimed at me?? My biggest confusion so far is
the lack of pointers in Python ..
Regards


Michael


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


Re: moving from c++ to python

2005-05-21 Thread pythonchallenge
Michael wrote:
> Hi,
> I'm a pretty sound programmer in C++, but would like to learn python! Does
> anyone know of any tutorial s aimed at me?? My biggest confusion so far is
> the lack of pointers in Python ..
> Regards
> 
> 
> Michael
> 
> 

I suggest that you start with the official Python tutorial at 
http://docs.python.org/tut/tut.html

-- 
Are you a riddle lover?
Try http://www.pythonchallenge.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: moving from c++ to python

2005-05-21 Thread William Heymann
On Saturday 21 May 2005 03:19 am, Michael wrote:

Yeah this tutorial is aimed at people that already know how to program.

http://www.diveintopython.org/

It would still be a good idea though to go through the basic python tutorial 
at  http://docs.python.org/tut/tut.html  

For someone already experienced in programming the basic tutorial will 
probably only take an hour or so and it is good to read it at least once. The 
other thing I highly recommend is reading  
http://docs.python.org/lib/lib.html  just to see what libraries python has 
and a basic idea of what they can do. I have seen a LOT of programmers come 
from languages like c++ and spend days and sometimes hundreds of lines of 
code implementing something that could be done with a single line of code 
from the standard library. :)  Just trying to save you from that problem.

> Hi,
> I'm a pretty sound programmer in C++, but would like to learn python! Does
> anyone know of any tutorial s aimed at me?? My biggest confusion so far is
> the lack of pointers in Python ..
> Regards
>
>
> Michael
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Memory errors with large zip files

2005-05-21 Thread John Machin
On 20 May 2005 18:04:22 -0700, "Lorn" <[EMAIL PROTECTED]> wrote:

>Ok, I'm not sure if this helps any, but in debugging it a bit I see the
>script stalls on:
>
>newFile.write (zf.read (zfilename))
>
>The memory error generated references line 357 of  the zipfile.py
>program at the point of decompression:
>
>elif zinfo.compress_type == ZIP_DEFLATED:
>   if not zlib:
>  raise RuntimeError, \
>  "De-compression requires the (missing) zlib module"
>  # zlib compress/decompress code by Jeremy Hylton of CNRI
>dc = zlib.decompressobj(-15)
>bytes = dc.decompress(bytes)  ###  <-- right here
>


The basic problem is that the zipfile module is asking the "dc" object
to decompress the whole file at once -- so you would need (at least)
enough memory to hold both the compressed file (C) and the
uncompressed file (U). There is also a possibility that this could
rise to 2U instead of U+C -- read a few lines further on:

bytes = bytes + ex

>Is there anyway to modify how my code is approaching this

You're doing the best you can, as far as I can tell.

> or perhaps
>how the zipfile code is handling it

Read this:
http://docs.python.org/lib/module-zlib.html

If you think you can work out how to modify zipfile.py to feed
dc.decompressobj a chunk of data at a time, properly manipulating
dc.unconsumed_tail, and keeping memory usage to a minimum, then go for
it :-)

Reading the source of the Python zlib module, plus this page from the
zlib website could be helpful, perhaps even necessary:
http://www.gzip.org/zlib/zlib_how.html

See also the following post to this newsgroup:
From: John Goerzen <[EMAIL PROTECTED]>
Newsgroups: comp.lang.python
Subject: Fixes to zipfile.py [PATCH]
Date: Fri, 07 Mar 2003 16:39:25 -0600

... his patch obviously wasn't accepted :-(


> or do I need to just invest in more
>RAM? I currently have 512 MB and thought that would be plenty
>perhaps I was wrong :-(.

Before you do anything rash (hacking zipfile.py or buying more
memory), take a step back for a moment:

Is this a one-off exercise or a regular exercise? Does it *really*
need to be done programatically? There will be at least one
command-line unzipper program for your platform . One-off req't: do it
manually.
Regular: Try using the unzipper manually; if all the available
unzippers on your platform die with a memory allocation problem then
you really have a problem. If it works, then instead of using the
zipfile module, use the unzipper program from your Python code via a
subprocess.

HTH,
John


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


Re: ANN: new release of RUR-PLE available

2005-05-21 Thread could ildg
It's very interestring,
I like it.
On 5/20/05, André Roberge <[EMAIL PROTECTED]> wrote:
> Michael Hoffman wrote:
> > André Roberge wrote:
> >
> >>Version 0.8.6a is now available.
> >
> >
> > You might see a bit more interest if you briefly explain what RUR-PLE
> > is, and where to find it.
> Oops.. sorry about that.
> 
> RUR - a Python Learning Environment.
> Its purpose is to provide an environment where people with no prior
> experience can learn computer programming (using Python of course!).
> 
> RUR-PLE currently requires that both Python and wxPython be installed.
> More information can be found at http://rur-ple.sourceforge.net
> 
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: first release of PyPy

2005-05-21 Thread Carl Friedrich Bolz
Hi!

Ville Vainio wrote:
>>"Torsten" == Torsten Bronger <[EMAIL PROTECTED]> writes:
> 
> 
> Torsten> What's supposed to be compiled?  Only PyPy itself or also
> Torsten> the programs it's "interpreting"?
> 
> PyPy is written in python, if it can be compiled then the programs can
> be as well.

That's correct in the sense that if a program adherses to the same 
staticness conditions as the PyPy code, it can be compiled. The core 
parts of the PyPy interpreter are written in "Restricted Python" 
(RPython), which imposes some limits to the features you are allowed to 
use. This is done in such a way that the annotator can perform type 
inference, e.g. you are not allowed to assign values with different 
types to a variable (plus some more restrictions). See

http://codespeak.net/pypy/index.cgi?doc/coding-guide.html#restricted-python

for more details about RPython.

> 
> Torsten> I've been told by so many books and on-line material that
> Torsten> Python cannot be compiled (unless you cheat).  So how is
> Torsten> this possible?
> 
> These guys are exploring a new territory. OTOH, Lisp is a dynamic
> language like python and it can be compiled to native code. Pyrex
> demonstrates the "trivial" way to compile python to native code, the
> real problem is making the resulting code fast. Typically this
> requires type inference (i.e. figuring out the type of an object from
> the context because there are no type declarations) to avoid dict
> lookups in method dispatch.

There is some preliminary documentation about the type infering (which 
is called annotation here) and the translation process:

http://codespeak.net/pypy/index.cgi?doc/translation.html

Regards,

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


ZODB memory problems (was: processing a Very Large file)

2005-05-21 Thread DJTB
[posted to comp.lang.python, mailed to [EMAIL PROTECTED]

Hi,

I'm having problems storing large amounts of objects in a ZODB.
After committing changes to the database, elements are not cleared from
memory. Since the number of objects I'd like to store in the ZODB is too
large to fit in RAM, my program gets killed with signal 11 or signal 9...

Below a minimal working (or actually: it doesn't work because of memory
errors)
example code with hopefully enough comments:



# This was suggested by Tim Peters in comp.lang.python thread
# 'processing a Very Large file'
# It is to make sure that no two or more copies of the same object
# reside in memory
class ObjectInterning:
def __init__(self):
self.object_table = {}

def object_intern(self,o):
return self.object_table.setdefault(o, o)


from sets import Set

# An ExtentedTuple is a tuple with some extra information
# (hence: 'Extended'). Furthermore, the elements of the tuple are
# unique.
# As you can see, ExtendedTuple does not inheret from Persistent.
# It will not be stored in the root of a database directly, it will
# be stored in a Persistent ExtendedTupleTable (see below).
class ExtendedTuple(tuple):

def __init__(self, els):
tuple.__init__(self,els)

# This is a set containing other ExtendedTuple objects
# which conflicts with self
# e.g. if self = ExtendedTuple([1,2,3,4]) and
# other = ExtendedTuple([3,4,5]) then self conflicts with
# other, because they share one or more elements (in this
# case:. 3 and 4)
# So, self.conflicts = Set([ExtendedTuple([3,4,5])])
#other.conflicts = Set([ExtendedTuple([1,2,3,4])])
self.conflicts = Set()

def __hash__(self):
return hash(tuple(self))

def __repr__(self):
return 'ExtendedTuple(%s)' % str(list(self))


import ZODB
from persistent import Persistent
import random

# The Persistent ExtendedTupleTable generates and stores a large
# amount of ExtendedTuple objects. Since ExtendedTuple contains a
# Set with other ExtendedTuple objects, each ExtendedTuple object
# may get very large.
class ExtendedTupleTable(Persistent):
def __init__(self):
self.interning = ObjectInterning()

# This Set stores all generated ExtendedTuple objects.
self.ets = Set() # et(s): ExtendedTuple object(s)
# This dictionary stores a mapping of elements to Sets of
# ExtendedTuples.
# eg: self.el2ets[3] = Set([(1,2,3), (3,4,5), (1,3,9)])
# self.el2ets[4] = Set([(3,4,5), (2,4,9)])
self.el2ets = {}  # el: element of an ExtendedTuple object

# These dictionaries are here for performance optimizations.
# It is being used to prevent billions of hash()
# calculations (relatively slow compared to dictionary
# lookups)
self._v_el2hs = {} # h(s): hash(es) of ExtendedTuple object(s)
self._v_h2et = {}
self._v_et2h = {}

# The keys of el2ets (and thus the elements of the
# ExtendedTuple objects) are all in a prespecified range.
# In this example: range(200):
self.__el_count = 200
# Number of ExtendedTuple objects in this ExtendedTupleTable
self.__et_count = 5000

# Start generation of ExtendedTuple objects and calculation of
# conflicts for each ExtendedTuple object
def calculate_all(self):
self.calc_ets()
self.calc_el2ets()
self.calc_conflicts()



def add(self, et_uninterned):
et = self.interning.object_intern(et_uninterned)
h = self.interning.object_intern(hash(et))
self.ets.add(et)
self._v_h2et[h] = et
self._v_et2h[et] = h
self._p_changed = True

def calc_ets(self):
# Calculate a large amount of ExtendedTuple objects.
# In this example, the tuples are random, the elements of
# the tuples are within a prespecified range.
# The elements of each tuple are unique.
print 'generating %s random ExtendedTuple objects' % self.__et_count
for i in xrange(self.__et_count):
# Create random tuple with unique elements
l = []
for el in xrange(self.__el_count/3):
l.append(random.randint(0,self.__el_count-1))
et = ExtendedTuple(tuple(Set(l)))
self.add(et)
self.__et_count = len(self.ets)

def calc_el2ets(self):
'''For each el, calculate which et uses that el'''
for el in xrange(self.__el_count):
print 'calculating all ExtendedTuple objects using', el
self.el2ets[el] = Set([ et for et in self.ets if el in et])
self._v_el2hs[el] = Set([ self._v_et2h[et] for et in
self.el2ets[el] ])
self._p_changed = True

def calc_conflicts(self):
'''For each et, calculate the set of conflicting ets'''
self.__et_count = len(self.ets)
commit_interval = 100
for i, e

Re: SQL Query via python

2005-05-21 Thread Sakesun Roykiattisak


*argh* You don't do any quoting of SQL-parameters, and that's more than bad! 
(leaves you up to the mercy of SQL-injection attacks, for example)


 



I'm aware of the issue. But I think the one who start this question is 
too naive to explain anything more complex.

Just give him a hint for further investigate.

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

Re: first release of PyPy

2005-05-21 Thread beliavsky
Shane Hathaway wrote:



> > Please could somebody explain to us non-CS people why PyPy could
> > have speed features CPython can't have?
>
> The idea is to shift more of the responsibility to optimize code from
> the human to the computer.  Since C code is at a low level, the
computer
> can only infer low level intent and thus perform low level
> optimizations.  Humans optimize C by making thousands of
speed-oriented
> decisions directly in the code.  Python code is at a much higher
level,
> which should enable the computer to discover more of the programmer's
> intent and perform deep optimizations.
>
> In the end, the computer's automated optimization could turn out
better
> than a human's manual optimization.  Thus, by expressing the Python
> interpreter in a high level manner, PyPy is a first step toward deep
> optimizations that aren't possible to automate in C.

I am less optimistic but hope I am wrong :).

C++ is a higher level language than C, but it's not clear to me that
compilers are able to optimize C++ code using higher-level features
such as the Standard Library so that they run as fast as the equivalent
C code. OTOH, some C++ experts have advocated template metaprogramming
as a way of speeding up programs. I wonder how widely this technique is
used.

Fortran 95 is a considerably higher level language than Fortran 77, but
I get the impression from comp.lang.fortran that it is harder to
optimize. Fortran compilers compete in a performance-driven market, and
AFAIK they are written in C.

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


Re: moving from c++ to python

2005-05-21 Thread Ville Vainio
> "Michael" == Michael  <[EMAIL PROTECTED]> writes:

Michael> me?? My biggest confusion so far is the lack of pointers
Michael> in Python ..

Achtually, python uses pointers for everything. On the contrary there
are no "value types" in python.

MyClass* c = new MyClass(12,13);

is equal to 

c = MyClass(12,13)

There is no equivalent to 

MyClass c(12,13);

because it's not needed.

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


Problem: embedding Python

2005-05-21 Thread mmf
Hallo!

I tried to use Python from C like it is described in the Python
Docmentation. So I wrote the following C source file:

#include 
int
main(int argc, char *argv[])
{
Py_Initialize();
PyRun_SimpleString("print 'Hallo World!'\n");
Py_Finalize();
return 0;
}

I saved it as run.c and tried to compile it using the following
command:
gcc  run.c

But that always results in a list of errors:

/tmp/cc1tmrPU.o(.text+0x1d): In function `main':
: undefined reference to `Py_Initialize'
/tmp/cc1tmrPU.o(.text+0x2a): In function `main':
: undefined reference to `PyRun_SimpleString'
/tmp/cc1tmrPU.o(.text+0x32): In function `main':
: undefined reference to `Py_Finalize'

What am I doing wrong? Can you help me?

Tanks.

Best regards,
Markus

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


Re: Problem: embedding Python

2005-05-21 Thread thesamet
mmf wrote:
> Hallo!
> 
> I tried to use Python from C like it is described in the Python
> Docmentation. So I wrote the following C source file:
> 
> #include 
> int
> main(int argc, char *argv[])
> {
>   Py_Initialize();
>   PyRun_SimpleString("print 'Hallo World!'\n");
>   Py_Finalize();
>   return 0;
> }
> 
> I saved it as run.c and tried to compile it using the following
> command:
> gcc  run.c
> 
> But that always results in a list of errors:
> 
> /tmp/cc1tmrPU.o(.text+0x1d): In function `main':
> : undefined reference to `Py_Initialize'
> /tmp/cc1tmrPU.o(.text+0x2a): In function `main':
> : undefined reference to `PyRun_SimpleString'
> /tmp/cc1tmrPU.o(.text+0x32): In function `main':
> : undefined reference to `Py_Finalize'
> 
> What am I doing wrong? Can you help me?
> 
> Tanks.
> 
> Best regards,
> Markus
> 

You should link with Python's shared object (replace with your version 
of Python):
   gcc -o run run.c -I/usr/include/python2.4 -lpython2.4

-- 
Are you a riddle lover?
Try http://www.pythonchallenge.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: import cx_Oracle fails!

2005-05-21 Thread Bernard Delmée
Hi Daniel,

is your processor Itanium or PA? I am having a hard time
getting cx_oracle (4.1) and python (2.3.5) to cooperate on
an HP-UX 11.23 server (I see you're running 11.11).

I can compile both packages with gcc 3.4.3 either in 32-bit
(apparently the default) or 64-bit (-mlp64 gcc flag) but python
refuses to load the cx_oracle.sl shared lib...

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


Re: first release of PyPy

2005-05-21 Thread John Roth
"Torsten Bronger" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Hallöchen!
>
> Paul Rubin  writes:
>
>> Torsten Bronger <[EMAIL PROTECTED]> writes:
>>
>>> Please could somebody explain to us non-CS people why PyPy could
>>> have speed features CPython can't have?
>>
>> Does the one-word answer "compiler" explain enough?
>
> No, just more questions.  ;-)
>
> What's supposed to be compiled?  Only PyPy itself or also the
> programs it's "interpreting"?

To be more specific, the (possible) speed increase will come
from JIT (Just In Time) compilation technology. JIT technology
is quite capable of handling dynamic languages. That has to
come after they get a compilable interpreter working, but I
believe it was in the original project vision statement.

A JIT compiler within the interpreter will put PyPy pretty
much on a par with Java as far as speed goes.

> : "In the next step
>of the project, we will generate C code or machine code from the
>source of Pypy, thereby reducing the speed penalty."
>
> I've been told by so many books and on-line material that Python
> cannot be compiled (unless you cheat).  So how is this possible?

JIT compilers cheat. Specifically, they compile for the observed
object environment of a statement, and then insert a test to make
sure that the actual environment matches the expected environment.
If it doesn't, it goes back to interpretation for that code segment.

John Roth
>
> Tschö,
> Torsten.
>
> -- 
> Torsten Bronger, aquisgrana, europa vetus 

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

PyPy 0.6.1

2005-05-21 Thread holger krekel
Hi again,

On Fri, May 20, 2005 at 23:38 +0200, holger krekel wrote:
> The PyPy 0.6 release
> 

has already been superseded by the PyPy 0.6.1 bug-fix release.
We are temporarily not having access to that time machine 
and thus have to fix things the old way, unfortunately.  
But we are working on improving this situation.

The bug is trivial enough: py.py crashes on string formatting
the second time you run it. You can find the fixed packages
and svn-locations here:

Getting started: 
http://codespeak.net/pypy/index.cgi?doc/getting_started.html

have fun & sorry for the inconvenience,

holger krekel


> *The PyPy Development Team is happy to announce the first 
> public release of PyPy after two years of spare-time and
> half a year of EU funded development.  The 0.6 release 
> is eminently a preview release.*  
> 
> What it is and where to start 
> -
> 
> Getting started:
> http://codespeak.net/pypy/index.cgi?doc/getting_started.html
> 
> PyPy Documentation: http://codespeak.net/pypy/index.cgi?doc
> 
> PyPy Homepage:  http://codespeak.net/pypy/
> 
> PyPy is a MIT-licensed reimplementation of Python written in
> Python itself.  The long term goals are an implementation that
> is flexible and easy to experiment with and retarget to
> different platforms (also non-C ones) and such that high
> performance can be achieved through high-level implementations
> of dynamic optimisation techniques.
> 
> The interpreter and object model implementations shipped with 0.6 can
> be run on top of CPython and implement the core language features of
> Python as of CPython 2.3.  PyPy passes around 90% of the Python language
> regression tests that do not depend deeply on C-extensions.  Some of
> that functionality is still made available by PyPy piggy-backing on
> the host CPython interpreter.  Double interpretation and abstractions
> in the code-base make it so that PyPy running on CPython is quite slow
> (around 2000x slower than CPython ), this is expected.  
> 
> This release is intended for people that want to look and get a feel
> into what we are doing, playing with interpreter and perusing the
> codebase.  Possibly to join in the fun and efforts.
> 
> Interesting bits and highlights
> -
> 
> The release is also a snap-shot of our ongoing efforts towards 
> low-level translation and experimenting with unique features. 
> 
> * By default, PyPy is a Python version that works completely with
>   new-style-classes semantics.  However, support for old-style classes
>   is still available.  Implementations, mostly as user-level code, of
>   their metaclass and instance object are included and can be re-made
>   the default with the ``--oldstyle`` option.
> 
> * In PyPy, bytecode interpretation and object manipulations 
>   are well separated between a bytecode interpreter and an 
>   *object space* which implements operations on objects. 
>   PyPy comes with experimental object spaces augmenting the
>   standard one through delegation:
> 
>   * an experimental object space that does extensive tracing of
> bytecode and object operations;
> 
>   * the 'thunk' object space that implements lazy values and a 'become'
> operation that can exchange object identities.
>   
>   These spaces already give a glimpse in the flexibility potential of
>   PyPy.  See demo/fibonacci.py and demo/sharedref.py for examples
>   about the 'thunk' object space.
> 
> * The 0.6 release also contains a snapshot of our translation-efforts 
>   to lower level languages.  For that we have developed an
>   annotator which is capable of infering type information
>   across our code base.  The annotator right now is already
>   capable of successfully type annotating basically *all* of
>   PyPy code-base, and is included with 0.6.  
> 
> * From type annotated code, low-level code needs to be generated.
>   Backends for various targets (C, LLVM,...) are included; they are
>   all somehow incomplete and have been and are quite in flux. What is
>   shipped with 0.6 is able to deal with more or less small/medium examples.
> 
> 
> Ongoing work and near term goals
> -
> 
> Generating low-level code is the main area we are hammering on in the
> next months; our plan is to produce a PyPy version in August/September 
> that does not need to be interpreted by CPython anymore and will 
> thus run considerably faster than the 0.6 preview release. 
> 
> PyPy has been a community effort from the start and it would
> not have got that far without the coding and feedback support
> from numerous people.   Please feel free to give feedback and 
> raise questions. 
> 
> contact points: http://codespeak.net/pypy/index.cgi?contact
> 
> contributor list: 
> http://codespeak.net/pypy/index.cgi?doc/contributor.html 
> 
> have fun, 
> 
> Armin Rigo, Samuele Pedroni, 
> 
> Holger Krekel, Christian Tismer, 
> 
> Carl

Re: SQL Query via python

2005-05-21 Thread Jeff Elkins
On Saturday 21 May 2005 04:56 am, Heiko Wundram wrote:
> Am Samstag, 21. Mai 2005 06:54 schrieb Sakesun Roykiattisak:
> > Try
> >
> > cursor.execute (
> > """
> >   SELECT name, month, day ,category, city FROM bday
> >   WHERE %s = %s
> > """
> >   %(arg1,arg2))
>
> *argh* You don't do any quoting of SQL-parameters, and that's more than
> bad! (leaves you up to the mercy of SQL-injection attacks, for example)
>
> What you basically want to have is something like the following:
>
> # Make sure arg1 is actually just characters.
> if not arg1.isalpha():
> raise RuntimeError, "trying to do SQL-injection attack?!"
>
> # Now do query.
> cursor.execute("""
> SELECT name, month, day, category, city FROM body
> WHERE %s = %%s
> """ % (arg1,),
> (arg2,))
>
> See how I didn't just use arg1 to paste it in the query string, but checked
> it before trying the query to consist only of characters. You'd have to
> adjust this accordingly for field-names you use (maybe you use underscores,
> etc.). But, be sure that arg1 contains no ";"!
>
> HTH!

Hey, I could barely spell SQL yesterday...:)

I really appreciate the pointers!

Jeff




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


Re: How to learn OO of python?

2005-05-21 Thread Benji York
 >"Harlin Seritt" <[EMAIL PROTECTED]> wrote:
 >class Animal:
 >   def eats(self):
 >  print 'The animal eats.'
 >   def walks(self):
 >  print 'The animal walks.'

 >   """#the self keyword means that this function will be a class
 >function"""

Mike Meyer wrote:
 > First, the correct terminology is class *method*. Yes, it looks like
 > a function definition, but it's a class method.

Perhaps you meant "instance method" instead of "class method".

 From http://docs.python.org/lib/built-in-funcs.html:

 A class method receives the class as implicit first argument, just
 like an instance method receives the instance.
--
Benji York
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: first release of PyPy

2005-05-21 Thread Skip Montanaro

beliavsky> C++ is a higher level language than C, 

>From the compiler's viewpoint C++ is not much higher level than C.  It has
the same basic types, (structs, unions and C++ classes are really the same
thing data-wise, though C++ classes can be somewhat more complex
layout-wise) and supports pointers to those types as well as void pointers
(pointers to untyped memory).  In addition, the operators are essentially
the same.

Python has a somewhat higher-level set of objects, doesn't have pointers,
nor does it allow untyped pointers to random chunks of memory.  I would
think that a run-time specializing compiler like Psyco could potentially do
more with that than a C/C++ compiler can do with the data structures and
operations it has to work with.

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


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

2005-05-21 Thread Dave Brueck
Paul Rubin wrote:
> Dave Brueck <[EMAIL PROTECTED]> writes:
> 
>>>What do you use for HTTPS?
>>
>>m2crypto (plus some patches to make asynchronous SSL do what we needed).
> 
> 
> That seems to be a nice piece of code, but it's still at version 0.13;

Version numbers are fairly relative, though. In another project we're using 
some 
proprietary, closed source libraries (unrelated to crypto) that are version 3 
and they seem buggier and less stable than m2crypto.

And don't get me started on Microsoft products (we've been using DirectShow *9* 
in some stuff, and due to bugs in DirectShow we were completely and utterly 
screwed despite what the documentation said; things just didn't work as they 
should, and Microsoft has confirmed that it's a bug that will be fixed in some 
future release - so we had to backtrack, ripping out code that should work just 
fine, and take another stab at getting DirectShow to cooperate). Version NINE 
(supposedly).

> if something goes wrong, are you sure you want to explain that you
> were using beta-test software to protect your customers' production
> financial transactions?

lol - what? We're not doing any financial transactions with it (IOW - we 
evaluated m2crypto for what we needed to do, and it's a good fit - that we 
didn't evaluate it in terms of what we don't need it to do doesn't bother me).

Having said that - I think we probably *would* use it for production financial 
transactions - but that's more a matter of closed vs. open source than Python 
vs 
not.

Besides, do you really think that, if something went wrong, you'd in the end 
have some meeting where you explain to your customer that you were using beta 
software? Of course not - it just doesn't work that way. Either they won't care 
and will drop you because of the problem (regardless of the source) or they 
want 
some broad details.

> There's also been some traffic on the
> python-crypto list about Zope encountering memory leaks with it.

Ok... so? I mean, if there's a memory leak, and it's hurting us, we have 
options: we can go look in the source code, we can make Zope reboot itself 
often, we can hire somebody to fix it, we can see if the author wants to give 
us 
a support contract, etc.

Memory leaks aren't exactly unique to Python - according to bugs.sun.com, there 
are currently 382 *open* bugs related to memory leaks in the JDK alone. If 
you're using Java in your "huge, enterprise size app" and get bit by one of 
those bugs, and if you're not a big enough company to get some 
ridiculously-priced support contract from Sun, what are your options? Again, 
this seems more like an open-vs-closed source issue, but to me it's another 
reason why I'd feel uncomfortable using Java in mission critical work.

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


Re: How to receive events (eg. user mouse clicks) from IE

2005-05-21 Thread Roger Upole
There does appear to be some sort of conflict between the two event
hooks.  I wasn't seeing it before since IE was getting google from my
browser cache and it was coming up almost instantaneously.  As soon
as I switched the URL to a page that loads slowly, I got the same
result.

   Adding win32gui.PumpWaitingMessages() to the wait loop
seems to allow both event hooks to run without blocking each other.

 Roger


<[EMAIL PROTECTED]> wrote:
> Thanks for the response again. The solution is pretty close but not yet
> complete
> This is what I observed.
> a) I tried to use the delay mechanism as suggested below
> ie.
> ie.Navigate('www.google.com')
> while ie.ReadyState !- 4
>   time.sleep(0.5)
>
> d=win32com.client.DispatchWithEvents(ie.Document, Doc_Events)
>
> IE *fails* to load the webpage
>
> b) Then I changed the delay to a specified time interval eg
> ie.Navigate('www.google.com')
> time.sleep(60) #wait for a minute
> d=win32com.client.DispatchWithEvents(ie.Document, Doc_Events)
>
> IE loads the web page *after* 60 seconds
>
> c) Then I used raw_input() eg
> ie.Navigate('www.google.com')
> raw_input()
> d=win32com.client.DispatchWithEvents(ie.Document, Doc_Events)
> IE now loads the webpage and prompts the user. If I click on the web
> page *before* clicking ok on the raw_input prompt - then it correctly
> invokes the Doc_Events method Ononactivate method.
>
>>From these observations, it seems that there is some kind of a race
> condition / timing issue happening. Can you please comment (or maybe
> point me to other sources of info that I can investigate).
> I am running Python 2.3 on Windows 2k machine.
>



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


Fw: evidence john bokma al jazeera connection ?

2005-05-21 Thread William Baker



   please add forward to alt.security.terrorism if information

p.p.s.  "john bokma" shows long list in message boards, just in last 
month.  lots of information to netherlands where muslem militants 
are.  could some be coded cryption to aljazeera, so messages are in
secret for the terror network?
   nl.comp.hardware
nl.media.tv
   nl.wetenschap
   nl.huishouden
   nl.politiek
  nl.religie
  alt.nl.schandpaal
   nl.comp.os.linux.installatie
  be.politics
   nl.gezondheid.psychiatrie
  nl.internet.www.ontwerp
   nl.gezondheid.medisch
   nl.internet.misbruik
   nl.internet.algemeen
  comp.lang.python
  nl.comp.programmeren
   comp.lang.perl.modules
  comp.lang.perl.misc
  sci.electronics.basics
   nl.internet.www.server-side
  alt.internet.search-engines
  alt.www.webmaster
   comp.lang.perl.misc
  nl.markt.freelance
nl.comp.hacken
   microsoft.public.msn.messenger
   be.comp.programming
  be.comp.internet.design
   nl.comp.os.linux.programmeren

what if dutch messages are most coded and  hardest to break?  there is no 
arab language at babelfish.altavista.com.  dutch is there, and english.

 i will try to send this message around.  i hope some law agents will
look at john bokma.  he may work for al jazeera, on the computer webs and tv.

concerned,
william

> p.s.   i ran a cross reference on john bokma  whereabouts, like he 
>just admits <[EMAIL PROTECTED]> .
>
>look for the  words "al-jazeera" and "new zealand", or netherlands, 
>mexico, turkey, or "sri lanka".  can it be only coincidence that john bokma 
>shows  up in the same places around the world, and at same times that 
>al jazeera showing up there?  thats way to many coincidences for one to have.
>
> you can see  his programs at www.aljazeera.com,  and use translations 
>at babelfish.altavista.com, if you need, like for his dutch records.   
>somebody 
>needs to tell fbi agents this john bokma woirks for terror computers and tv.
>

>>i keep looking at the john bokma al jazeera connection, and his dossier 
>>gets bigger.  this just one day cancels for al-jazeera and arab militant.  do 
>>bokma clients know how deep  he works for al jazeera?  look at this.
>>
>>see this from 2003, cancel  for al jazeera and other arab names
>>at this message <[EMAIL PROTECTED]> 
>>---
>>nl.internet.misbruik.rapport > Cancelreport from autocancelbot Sat Oct 11 
>>00:00:05 2003 - View Parsed
>>From: Erik Hensema <[EMAIL PROTECTED]>
>>Newsgroups: nl.internet.misbruik.rapport
>>Subject: Cancelreport from autocancelbot Sat Oct 11 00:00:05 2003
>>Followup-To: nl.internet.misbruik
>>Date: Fri, 10 Oct 2003 22:00:05 + (UTC)
>>Approved: [EMAIL PROTECTED]
>>Message-ID: <[EMAIL PROTECTED]>
>>NNTP-Posting-Host: dexter.hensema.net
>>NNTP-Posting-Date: Fri, 10 Oct 2003 22:00:05 + (UTC)
>>
>>Id: SWEN-ac-1065775366-168-1872
>>From:   John Bokma <[EMAIL PROTECTED]>
>>Subject:Re: Gibe virus onderschepprogramma maken met Delphi
>>Newsgroups: nl.comp.programmeren
>>Message-Id: <[EMAIL PROTECTED]>
>>
>>Id: 1063628593-ac-1065747874-64-61268
>>From:   Rasheed AL-Jazeera <[EMAIL PROTECTED]>
>>Subject:nlo.news.groups, rethink the cool
>>Newsgroups: nlo.news.groups
>>Message-Id: <[EMAIL PROTECTED]>
>>
>>Id: 1063628593-ac-1065748328-65-93686
>>From:   Hakeem Agha AL-Najjar <[EMAIL PROTECTED]>
>>Subject:nl.sport.vissen, power of his own PR
>>Newsgroups: nl.sport.vissen
>>Message-Id: <[EMAIL PROTECTED]>
>>
>>Id: 1063628593-ac-1065748636-66-67216
>>From:   Abdel Said al-Zahhar <[EMAIL PROTECTED]>
>>Subject:Re: nl.sport.bridge, counterbranding game
>>Newsgroups: nl.sport.bridge
>>Message-Id: <[EMAIL PROTECTED]>
>>
>>Id: 1063628593-ac-1065748640-67-29631
>>From:   Ahmed al-Zawahiri <[EMAIL PROTECTED]>
>>Subject:nl.sport.voetbal, a fading empire
>>Newsgroups: nl.sport.voetbal
>>Message-Id: <[EMAIL PROTECTED]>
>>
>>Id: 1063628593-ac-1065744129-55-50231
>>From:   Ayub Al Zahhar <[EMAIL PROTECTED]>
>>Subject:Re: nl.sport.skate, we take on Phil
>>Newsgroups: nl.sport.skate
>>Message-Id: <[EMAIL PROTECTED]>
>>
>>Id: 1063628593-ac-1065744130-56-4336
>>From:   Karim Muhammad <[EMAIL PROTECTED]>
>>Subject:nl.sport.varen, isn't exactly rocket science
>>Newsgroups: nl.sport.varen
>>Message-Id: <[EMAIL PROTECTED]>
>>
>>Id: 1063628593-ac-1065744134-57-60721
>>From:   Fahd Saad Haq <[EMAIL PROTECTED]>
>>Subject:nl.kunst.sf+fantasy, a final challenge
>>Newsgroups: nl.kunst.sf+fantasy
>>Message-Id: <[EMAIL PROTECTED]>
>>
>>Id: 1063628593-ac-1065744135-58-79683
>>From:   Fahd el-Hassan <[EMAIL PROTECTED]>
>>Subject:Re: nl.sport.klim+bergsport, grass roots capitalism
>>Newsgroups: nl.sport.klim+bergsport
>>Message-Id: <[EMAIL PROTECTED]>
>>
>>Id: 1063628593-ac-1065744136-59-36414
>>From:   Ramez al Shehhi <[EMAIL PROTECTED]>
>>Subject:nl.sport.volleybal, megacorps do not control
>>Newsgroups: nl.sport.

Re: Can you introduce some book about python?

2005-05-21 Thread [EMAIL PROTECTED]
if u r come from china, maybe python.cn is a good start :)

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


Re: count files in a directory

2005-05-21 Thread rbt
Heiko Wundram wrote:
> Am Samstag, 21. Mai 2005 06:25 schrieb James Stroud:
> 
>>This will work for your purposes (and seems pretty fast compared to the
>>alternative):
>>
>>file_count = len(os.walk(valid_path).next()[2])
> 
> 
> But will only work when you're just scanning a single directory with no 
> subdirectories...!
> 
> The alternative (which will work regardless of subdirectories) is something 
> like the following:
> 
> [EMAIL PROTECTED] ~ $ python
> Python 2.4 (#1, Apr  3 2005, 00:49:51)
> [GCC 3.4.3-20050110 (Gentoo Linux 3.4.3.20050110-r1, ssp-3.4.3.20050110-0, 
> pie- on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> 
import os
path = "/home/heiko"
file_count = sum((len(f) for _, _, f in os.walk(path)))
file_count
> 
> 55579
> 
> 
> HTH!
> 

Thanks! that works great... is there any significance to the underscores that 
you 
used? I've always used root, dirs, files when using os.walk() do the 
underscores make 
it faster... or more efficient?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: first release of PyPy

2005-05-21 Thread Mike Meyer
Shane Hathaway <[EMAIL PROTECTED]> writes:
> Torsten Bronger wrote:
> Even if things don't turn out that way, note that each generation of
> programming languages builds on its predecessors, and PyPy could help
> bootstrap the next generation.  Assemblers first had to be written in
> machine code; when it was possible to write assemblers in assembly,
> people started writing complex grammars and came up with C.  C compilers
> first had to be written in assembly; when it was possible to write C
> compilers in C, people started inventing high level languages.  Now
> people are experimenting with high level compilers written in high level
> languages.  Where will this pattern lead?  Who knows. :-)

Your history of programming languages skips so many steps that it's
misleading.

For instance, C didn't arrive ab initio. It was preceeded by B, which
was a derivative of BCPL. From the history at http://www.cs.bell-labs.com/who/dmr/chist.html >, it seems that B
slowly evolved into C. B started life as an interpreted language, with
a compiler that generated pseudo-code. The first B compiler was
written in TMG, which was a high-level language designed for creating
compilers - well, sorta. Based in that history, it seems likely that
the first program that compiled a language called C was written in B.

I'm used to seeing the term "high level languages" used for languages
a lot like C, to distinguish them from assembler. See http://www.computerhope.com/jargon/h/highll.htm > for one
definition. "Very high level languages" used to be popular, but I
haven't seen it used much. At least one person classifies Python as
such http://www.everything2.com/index.pl?node_id=735359 >.  In
any case, powerful dynamic languages - of which python is an example -
date back to LISP. The first LISP compiler in LISP almost certainly
predates C.

Basically, there's a *lot* of history in programming languages. I'd
hate to see someone think that we went straight from assembler to C,
or that people didn't understand the value of dynamic languages very
early.

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


Re: count files in a directory

2005-05-21 Thread rbt
James Stroud wrote:
> Sorry, I've never used os.walk and didn't realize that it is a generator.
> 
> This will work for your purposes (and seems pretty fast compared to the 
> alternative):
> 
> file_count = len(os.walk(valid_path).next()[2])

Thanks James... this works *really* well for times when I only need to count 
files in 
the current directory (no recursion). I think others will find it useful as 
well.
-- 
http://mail.python.org/mailman/listinfo/python-list


ImportError: cannot import name - newbie

2005-05-21 Thread qwejohn
Hello,

I am quite a newbie to Python.
I am working on Linux Fedora Core 3.
I have wrote a small program named box.py which has only a constructor:


"""box.py"""

class box:
  def __init__(self):
print "in box"

This program passes running "python box.py".

I had put this program under /work/dev/mytests/new

Now I want to use it from a second python program, which
resides in a totally different path.

I had tried , in a program named test.py,
"""test.py"""
sys.path = [ '/work/dev/mytests' ] + sys.path
from new import box

class test:
  def __init__(self):
print "in test"

Running python test.py
I get the following error:

Traceback (most recent call last):
  File "test.py", line 6, in ?
from new import box
ImportError: cannot import name box

Any idea ? 

Regards,
John

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


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

2005-05-21 Thread Dieter Maurer
"Fredrik Lundh" <[EMAIL PROTECTED]> writes on Thu, 19 May 2005 09:54:15 +0200:
> ...
> and unless your operating system is totally braindead, and thus completely 
> unfit
> to run huge enterprise size applications, that doesn't really matter much.  
> leaks
> are problematic, large peak memory use isn't.

Could you elaborate a bit?

Large peak memory use means that the application got a large
address space. What garantees that the residual memory use
(after the peak) is compact and not evenly spread across
the address space. While the OS probably is able to
reuse complete pages which are either unused for a longer
time or at least rarely accessed, it may become nasty when
almost every page contains a small amount of heavily used
memory.


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


Re: count files in a directory

2005-05-21 Thread Steven Bethard
rbt wrote:
> Heiko Wundram wrote:
> import os
> path = "/home/heiko"
> file_count = sum((len(f) for _, _, f in os.walk(path)))
> file_count
> 
> Thanks! that works great... is there any significance to the underscores 
> that you used? I've always used root, dirs, files when using os.walk() 
> do the underscores make it faster... or more efficient?

No, they don't make any semantic difference; they work just like any 
other identifier.  It's just that, by convention, single underscores 
indicate that we don't care what values these names are bound to.  So in 
the example above, Heiko indicates that we don't care about what you 
would normally call 'root' and 'dirs'.

HTH,

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


Re: ImportError: cannot import name - newbie

2005-05-21 Thread Steven Bethard
[EMAIL PROTECTED] wrote:
> """box.py"""
> 
> class box:
>   def __init__(self):
> print "in box"
> 
> This program passes running "python box.py".
> 
> I had put this program under /work/dev/mytests/new
> 
> Now I want to use it from a second python program, which
> resides in a totally different path.
> 
> I had tried , in a program named test.py,
> """test.py"""
> sys.path = [ '/work/dev/mytests' ] + sys.path
> from new import box

When you say "from new import box", you're saying something like "from 
the package new, import the module box".  Which means that you need to 
indicate that the "new" directory is a package.  To do this, place an 
empty file called "__init__.py" in the "new" directory (along with 
"box.py").  Python should then be able to identify "new" as a package, 
and find the "box" module inside of it.

HTH,

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


Re: How to receive events (eg. user mouse clicks) from IE

2005-05-21 Thread J Correia
"Roger Upole" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> There does appear to be some sort of conflict between the two event
> hooks.  I wasn't seeing it before since IE was getting google from my
> browser cache and it was coming up almost instantaneously.  As soon
> as I switched the URL to a page that loads slowly, I got the same
> result.
>
>Adding win32gui.PumpWaitingMessages() to the wait loop
> seems to allow both event hooks to run without blocking each other.
>
>  Roger

I added that line to the wait loop and while it does indeed speed it
 up dramatically (in 10 tests: min = 13 sec; max = 33, ave ~ 20 secs)
it's still nowhere near the 1-2 secs it takes without hooking the
IE events.  I also can't explain the wide differences between min
and max times since they seem to occur randomly
(e.g. min occurred on 7th run, max on 4th).

I assume that that response time won't be adequate for the original
poster's needs, due to the slowdown in browsing for his users.

Jose





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


Re: Fw: evidence john bokma al jazeera connection ?

2005-05-21 Thread jg
William Baker wrote:

> 
> 
> 
>please add forward to alt.security.terrorism if information
> 
> p.p.s.  "john bokma" shows long list in message boards, just in last
> month.  lots of information to netherlands where muslem militants
> are.  could some be coded cryption to aljazeera, so messages are in
> secret for the terror network?

Do not forget his alter egos: Waldo Centini, Jerry Harper, Els... ;-)

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


http://www.tbn.org/films/videos/To_Hell_And_Back.ram << GREAT VIDEO! Just click on link to view.

2005-05-21 Thread AOLfan250106
http://www.tbn.org/films/videos/To_Hell_And_Back.ram << GREAT VIDEO!
Just click on link to view.

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


Re: ANN: Veusz 0.6 - a scientific plotting package

2005-05-21 Thread qwweeeit
Hi Jeremy,
I am interested in collaborating to your project, but first of all I
must install Veusz and see what is the feeling I get.  I'm almost a
newbie in Python but I'm an old programmer and have quite a lot of
experience in designing scientific software. For example I know very
well contour plots also if the alghorithm I used can now be  a little
out-dated (some year ago  it was a flash in C...).
Another reason to be tempted in this adventure is the fact that your
choice is exactly mine: Python and Qt  (and besides that I can learn to
use OO ... at last!)
Bye.

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


Re: python24.zip

2005-05-21 Thread Dieter Maurer
"Martin v. Löwis" <[EMAIL PROTECTED]> writes on Fri, 20 May 2005 18:13:56 +0200:
> Robin Becker wrote:
> > Firstly should python start up with non-existent entries on the path?
> 
> Yes, this is by design.
> 
> > Secondly is this entry be the default for some other kind of python
> > installation?
> 
> Yes. People can package everything they want in python24.zip (including
> site.py). This can only work if python24.zip is already on the path
> (and I believe it will always be sought in the directory where
> python24.dll lives).

The question was:

   "should python start up with **non-existent** objects on the path".

I think there is no reason why path needs to contain an object
which does not exist (at the time the interpreter starts).

In your use case, "python24.zip" does exist and therefore may
be on the path. When "python24.zip" does not exist, it does
not contain anything and especially not "site.py".


I recently analysed excessive import times and
saw thousands of costly and unneccesary filesystem operations due to:

  *  long "sys.path", especially containing non-existing objects

 Although non-existent, about 5 filesystem operations are
 tried on them for any module not yet located.

  *  a severe weakness in Python's import hook treatment

 When there is an importer "i" for a path "p" and
 this importer cannot find module "m", then "p" is
 treated as a directory and 5 file system operations
 are tried to locate "p/m". Of course, all of them fail
 when "p" happens to be a zip archive.


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


Parsing XML - Newbie help

2005-05-21 Thread rh0dium
Hi all,

I am relatively new to python and certainly new to XML parsing.  Can
some show me how to get the product text out of this?  Really I want to
know this has 2 processors and the are AMD Opteron(tm) Processor 250

I have gotten this far...

class HWParser:

def __init__(self):
if os.path.isfile(LSHW):
lshw=Exec.Exec(LSHW)
lshw.execute('-xml')
else:
print "lshw does not exist", LSWH
return "Unknown"

self.data  = lshw.read()
self.error = lshw.error()
self.exit  = lshw.poll()

if self.error:
print "Error Exist", self.error
return
else:
self.xml = minidom.parseString(self.data)
self.xml.normalize()

def p (self):
print self.xml.toxml()

If anyone can help me out that would be great!

---





   CPU
   AMD Opteron(tm) Processor 250
   Advanced Micro Devices [AMD]
   5
   [EMAIL PROTECTED]
   15.5.10
   CPU0
   24
   30
   64
   16
   
  mathematical co-processor
  FPU exceptions
reporting
  
  virtual mode extensions
  debugging extensions
  page size extensions
  time stamp counter
  model-specific registers
  4GB+ memory addressing (Physical
Address Extension)
  machine check exceptions
  compare and exchange
8-byte
  on-chip advanced programmable
interrupt controller (APIC)
  fast system calls
  memory type range
registers
  page global enable
  machine check architecture
  conditional move
instruction
  page attribute table
  36-bit page size
extensions
  
  multimedia extensions
(MMX)
  fast floating point
save/restore
  streaming SIMD extensions
(SSE)
  streaming SIMD extensions
(SSE2)
  fast system calls
  no-execute bit (NX)
  multimedia extensions
(MMXExt)
  64bits extensions
(x86-64)
  multimedia extensions
(3DNow!Ext)
  multimedia extensions
(3DNow!)
   


   CPU
   AMD Opteron(tm) Processor 250
   Advanced Micro Devices [AMD]
   3
   [EMAIL PROTECTED]
   15.5.10
   CPU1
   24
   30
   64
   16
   
  mathematical co-processor
  FPU exceptions
reporting
  
  virtual mode extensions
  debugging extensions
  page size extensions
  time stamp counter
  model-specific registers
  4GB+ memory addressing (Physical
Address Extension)
  machine check exceptions
  compare and exchange
8-byte
  on-chip advanced programmable
interrupt controller (APIC)
  fast system calls
  memory type range
registers
  page global enable
  machine check architecture
  conditional move
instruction
  page attribute table
  36-bit page size
extensions
  
  multimedia extensions
(MMX)
  fast floating point
save/restore
  streaming SIMD extensions
(SSE)
  streaming SIMD extensions
(SSE2)
  fast system calls
  no-execute bit (NX)
  multimedia extensions
(MMXExt)
  64bits extensions
(x86-64)
  multimedia extensions
(3DNow!Ext)
  multimedia extensions
(3DNow!)
   


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


Re: SQL Query via python

2005-05-21 Thread Jeff Elkins
On Saturday 21 May 2005 01:32 pm, Dennis Lee Bieber wrote:
> On Fri, 20 May 2005 23:57:01 -0400, Jeff Elkins

>  You have to remember that .execute(), using the (template,
> (arg...)) format, is designed to apply suitable quoting to the
> arguments. It does not parse the SQL to determine if arguments are being
> used as identifiers and not data values.
>
>  The above sample probably generated:
>
> SELECT name, month, day, category, city from bday
> WHERE "month" = 5

This is getting much clearer. Thanks much.

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


Re: How to receive events (eg. user mouse clicks) from IE

2005-05-21 Thread Roger Upole
Reducing the sleep time in the loop also seems to speed things up.
I'm guessing due to giving both event loops more resources, but
I can't prove it conclusively.

This might make a good candidate for the Cookbook (or there's
a collection of IE automation examples at win32com.de)
so anybody else trying to do something similar knows some of the pitfalls.

   Roger

"J Correia" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> "Roger Upole" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
>> There does appear to be some sort of conflict between the two event
>> hooks.  I wasn't seeing it before since IE was getting google from my
>> browser cache and it was coming up almost instantaneously.  As soon
>> as I switched the URL to a page that loads slowly, I got the same
>> result.
>>
>>Adding win32gui.PumpWaitingMessages() to the wait loop
>> seems to allow both event hooks to run without blocking each other.
>>
>>  Roger
>
> I added that line to the wait loop and while it does indeed speed it
> up dramatically (in 10 tests: min = 13 sec; max = 33, ave ~ 20 secs)
> it's still nowhere near the 1-2 secs it takes without hooking the
> IE events.  I also can't explain the wide differences between min
> and max times since they seem to occur randomly
> (e.g. min occurred on 7th run, max on 4th).
>
> I assume that that response time won't be adequate for the original
> poster's needs, due to the slowdown in browsing for his users.
>
> Jose
>
>
>
>
> 




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


Re: We are one of the world leading legal sources for male impotence treatments

2005-05-21 Thread qwweeeit
I should need  "a great errrect1on "... but get away from beeing
permanently on the top of the list!

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


Re: python24.zip

2005-05-21 Thread Robin Becker
Dieter Maurer wrote:
.
> 
> The question was:
> 
>"should python start up with **non-existent** objects on the path".
> 
> I think there is no reason why path needs to contain an object
> which does not exist (at the time the interpreter starts).
> 
> In your use case, "python24.zip" does exist and therefore may
> be on the path. When "python24.zip" does not exist, it does
> not contain anything and especially not "site.py".
> 

I think this was my intention, but also I think I have some concern over
having two possible locations for the standard library. It seems non pythonic
and liable to cause confusion if some package should manage to install
python24.zip while I believe that python24\lib is being used.

> 
> I recently analysed excessive import times and
> saw thousands of costly and unneccesary filesystem operations due to:
> 
>   *  long "sys.path", especially containing non-existing objects
> 
>  Although non-existent, about 5 filesystem operations are
>  tried on them for any module not yet located.
> 
>   *  a severe weakness in Python's import hook treatment
> 
>  When there is an importer "i" for a path "p" and
>  this importer cannot find module "m", then "p" is
>  treated as a directory and 5 file system operations
>  are tried to locate "p/m". Of course, all of them fail
>  when "p" happens to be a zip archive.
> 
> 
> Dieter

I suppose that's a reason for eliminating duplicates and non-existent entries.

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


Re: Running a python program during idle time only

2005-05-21 Thread James Carroll
There's probably a way to tell how long the user has been idle, but here's
how you can check the CPU load to see if it's elevated... (of course
your program might elevate  it too.)

On linux, you can read from /proc/loadavg 

Here's a fun thing to try on windows...

make sure you have the win32all package installed...

import win32com.client
computer="."
query="select LoadPercentage from Win32_Processor where DeviceID = 'CPU0'"
objWMIService = win32com.client.Dispatch("WbemScripting.SWbemLocator")
objSWbemServices = objWMIService.ConnectServer(computer,"root\cimv2")
rows = objSWbemServices.ExecQuery(query)
print rows[0].LoadPercentage

import time

for count in xrange(4):
print objSWbemServices.ExecQuery(query)[0].LoadPercentage
time.sleep(1)

The microsoft docs on the info you can get on the processor is here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_processor.asp

If you run this from a shell like PyCrust, you won't see anything for
four seconds, and then it will all show up.

What are you using for the text indexing?  PyLucene???  

-Jim

On 5/21/05, Donn Cave <[EMAIL PROTECTED]> wrote:
> Quoth Mike Meyer <[EMAIL PROTECTED]>:
> | "los" <[EMAIL PROTECTED]> writes:
> | > I'm trying to create a program similar to that of Google's desktop that
> | > will crawl through the hard drive and index files.  I have written the
> | > program and as of now I just put the thread to sleep for 1 second after
> | > indexing a couple of files.
> | >
> | > I'm wondering if anyone knows of a way that I could make so that the
> | > program will run at full speed only runs after the computer has been
> | > idle for a while.  I've looked at the "nice" command but that's not
> | > exactly what I want.
> |
> | On Unix, nice is exactly the answer. It's a lot more fine-grained than
> | what you're talking about, though. But it's the way things like
> | setiathome manage to run continuously without interfering with normal
> | usage.
> 
> Well, he could certainly try it if he hasn't already, but I wouldn't
> be too surprised if it really isn't exactly what he wants.  Maybe it
> depends on the scheduler, and maybe things have gotten a lot better
> in that department, but from my experience a process can be niced pretty
> hard and still tie up a lot of resources.  A disk crawler sounds like
> a good example.
> 
> I don't have any brilliant ideas, though.  Your suggestion to use
> os.getloadavg sounds good to me.  It might be kind of neat if there
> were some kind of APM ioctl that would register the calling process
> for notification of pending disk spin down, low power mode etc.
> 
> Donn
> --
> http://mail.python.org/mailman/listinfo/python-list
> 
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python24.zip

2005-05-21 Thread "Martin v. Löwis"
Dieter Maurer wrote:
> The question was:
> 
>"should python start up with **non-existent** objects on the path".
> 
> I think there is no reason why path needs to contain an object
> which does not exist (at the time the interpreter starts).

There is. When the interpreter starts, it doesn't know what object
do or do not exist. So it must put python24.zip on the path
just in case.

> In your use case, "python24.zip" does exist and therefore may
> be on the path. When "python24.zip" does not exist, it does
> not contain anything and especially not "site.py".

Yes, but the interpreter cannot know in advance whether
python24.zip will be there when it starts.

> I recently analysed excessive import times and
> saw thousands of costly and unneccesary filesystem operations due to:

Hmm. In my Python 2.4 installation, I only get 154 open calls, and
63 stat calls on an empty Python file. So somebody must have messed
with sys.path really badly if you saw thoughsands of file operations
(although I wonder what operating system you use so that failing
open operations are costly; most operating systems should do them
very efficiently).

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


Re: Fw: evidence john bokma al jazeera connection ?

2005-05-21 Thread Neil Hodgson
There is a response to this on John's web site:

http://johnbokma.com/mexit/2005/05/19/daniel-joseph-min.html

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


embedded python in c - function

2005-05-21 Thread PixelDust1
Hi guys,

I am pretty new to Python and to embedding it in C.
Here is what I am trying to accomplish:

I have a C program that accepts user input, which can be
a Python script which includes functions defined by the user line by
line as typed in. Let me show the code that I have:

#include "Python.h"


main(int argc, char **argv)
{


// Pass argv[0] to the Python interpreter 
Py_SetProgramName(argv[0]);

// Initialize the Python interpreter.  Required. 
Py_Initialize();


// Define sys.argv.  It is up to the application if you
// want this; you can also let it undefined (since the Python 
// code is generally not a main program it has no business
// touching sys.argv...) 
PySys_SetArgv(argc, argv);

PyRun_SimpleString("def fib(n):\n");
PyRun_SimpleString("\t\ta, b = 0, 1\n");
PyRun_SimpleString("\t\t\while b < n:n");
PyRun_SimpleString("\t\tprint b,\n");
PyRun_SimpleString("\t\t\a, b = b, a+bn");
PyRun_SimpleString("fib(2000)\n");


// Exit, cleaning up the interpreter 
Py_Exit(0);

}

The code gives me the following:

  File "", line 1
def fib(n):
  ^
SyntaxError: unexpected EOF while parsing
  File "", line 1
a, b = 0, 1
^
SyntaxError: invalid syntax
  File "", line 1
while b < n:n
^
SyntaxError: invalid syntax
  File "", line 1
print b,
^
SyntaxError: invalid syntax
  File "", line 1
, b = b, a+bn
^
SyntaxError: invalid syntax
Traceback (most recent call last):
  File "", line 1, in ?


Could anybody help me out by either pointing to a tutorial that deals
with this type of embedding to point out my mistakes in the code!

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


Re: first release of PyPy

2005-05-21 Thread Christian Tismer
Torsten Bronger wrote:

...

> I've been told by so many books and on-line material that Python
> cannot be compiled (unless you cheat).  So how is this possible?

Have a look at Psyco, that will be folded into and improved
by PyPy.

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


Re: first release of PyPy

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

>>"Torsten" == Torsten Bronger <[EMAIL PROTECTED]> writes:
> 
> 
> Torsten> What's supposed to be compiled?  Only PyPy itself or also
> Torsten> the programs it's "interpreting"?
> 
> PyPy is written in python, if it can be compiled then the programs can
> be as well.

Well, this is not really true. PyPy is written in RPython,
a sub-language of Python that is implicitly defined by
"simple and static enough to be compilable".

We have not yet started to work on the dynamic nature of
Python, that needs different technology (Psyco).

> Torsten> I've been told by so many books and on-line material that
> Torsten> Python cannot be compiled (unless you cheat).  So how is
> Torsten> this possible?
> 
> These guys are exploring a new territory. OTOH, Lisp is a dynamic
> language like python and it can be compiled to native code. Pyrex
> demonstrates the "trivial" way to compile python to native code, the
> real problem is making the resulting code fast. Typically this
> requires type inference (i.e. figuring out the type of an object from
> the context because there are no type declarations) to avoid dict
> lookups in method dispatch.

Type inference works fine for our implementation of Python,
but it is in fact very limited for full-blown Python programs.
Yoou cannot do much more than to try to generate effective code
for the current situation that you see. But that's most often
quite fine.

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


Re: first release of PyPy

2005-05-21 Thread Paul Rubin
Christian Tismer <[EMAIL PROTECTED]> writes:
> Type inference works fine for our implementation of Python,
> but it is in fact very limited for full-blown Python programs.
> Yoou cannot do much more than to try to generate effective code
> for the current situation that you see. But that's most often
> quite fine.

Type inference (or static type declarations) is one part of compiling
dynamic languages but I think its importance is overblown in these
Python compiler threads.  There's lots of compiled Lisp code out there
that's completely dynamic, with every operation dispatching on the
type tags in the Lisp objects.  Yes, the code runs slower than when
the compiler knows the type in advance, but it's still much faster
than interpreted code.

I'd expect one of the worst bottlenecks in Python is the multiple
levels of dictionary lookup needed when you say a.x().  The
interpreter has to search through the method dictionaries for class(a)
and all of its superclasses.  It has to do this every time you do the
operation, since those dictionaries can change at any time.  Being
able to do that, it seems to me, is NOT in the interest of reliable or
maintainable programming--look at the cruft in socket.py, for example.
Being able to statically generate the method call (like a C++ compiler
does) or even just being able to cache a method list in each class
(avoiding searching through all the superclasses on subsequent calls
to any operation) would probably make a big difference in execution
speed in both the compiler and interpreter.  It would require a change
to the Python language but I think the change would be a beneficial
one both from the software maintainability and the performance point
of view.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: first release of PyPy

2005-05-21 Thread Jp Calderone
On 21 May 2005 17:57:17 -0700, Paul Rubin <"http://phr.cx"@nospam.invalid> 
wrote:
>Christian Tismer <[EMAIL PROTECTED]> writes:
>> Type inference works fine for our implementation of Python,
>> but it is in fact very limited for full-blown Python programs.
>> Yoou cannot do much more than to try to generate effective code
>> for the current situation that you see. But that's most often
>> quite fine.
>
>Type inference (or static type declarations) is one part of compiling
>dynamic languages but I think its importance is overblown in these
>Python compiler threads.  There's lots of compiled Lisp code out there
>that's completely dynamic, with every operation dispatching on the
>type tags in the Lisp objects.  Yes, the code runs slower than when
>the compiler knows the type in advance, but it's still much faster
>than interpreted code.
>
>I'd expect one of the worst bottlenecks in Python is the multiple
>levels of dictionary lookup needed when you say a.x().
> [snip]

  Have you profiler data in support of this?  Suggesting optimizations, 
especially ones which require semantic changes to existing behavior, without 
actually knowing that they'll speed things up, or even that they are targetted 
at bottleneck code, is kind of a waste of time.

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


Re: first release of PyPy

2005-05-21 Thread Paul Rubin
Jp Calderone <[EMAIL PROTECTED]> writes:
>   Have you profiler data in support of this?  Suggesting
>optimizations, especially ones which require semantic changes to
>existing behavior, without actually knowing that they'll speed things
>up, or even that they are targetted at bottleneck code, is kind of a
>waste of time.

I don't have measurements for Python (no idea whether PyPy supports
profiling, and CPython interpreters aren't very interesting since
the effect matters mostly for compiled code), but Flavors faced
a very similar problem and caching was a big win.  I'm sure all
serious CLOS implementations do something similar.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: porting help

2005-05-21 Thread Neal Norwitz
You may need to write your own dynload_vxworks.c.  Notice there are
various OS specific dynload_*.c files.  You can try to use
dynload_stub.c to see if you can get it to compile.  You may also need
to muck with Include/pyport.h and configure to get things going.

Good Luck!
n

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


None module reference

2005-05-21 Thread Stefan Seefeld
hello,

I'v run into a bug that I find hard to understand:

In a python module of mine I import system modules
('sys', say) and then use them from within some functions.

However, during program termination I'm calling
one such function and the module reference ('sys')
is 'None' !

What does that mean ? Have those modules already
been unloaded ? If so, why, given that my
current module still references them ?

Any help is highly appreciated,

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



Re: SQL Query via python

2005-05-21 Thread Jeff Elkins
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. I know I could have installed other *nix programs that would do the 
same thing, but so what :)

Thanks so much to the folks on this list who took the trouble to reply. I hope 
I can pay it forward in the future.

Jeff Elkins

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


Re: None module reference

2005-05-21 Thread Kay Schluehr

Stefan Seefeld wrote:
> hello,
>
> I'v run into a bug that I find hard to understand:
>
> In a python module of mine I import system modules
> ('sys', say) and then use them from within some functions.
>
> However, during program termination I'm calling
> one such function and the module reference ('sys')
> is 'None' !

Do You register Your function using atexit() ?

This works perfectly fine and as expected for me. I would wonder if the
interpreter was shut down and tries to execute a cleanup thereafter.

Checkout following example code. You may also have a look at the
/lib/atexit.py module see how it works.

import atexit
import sys
def foo():
print sys

atexit.register(foo)
 
Ciao,
Kay

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