Python compiled on Windows

2007-02-04 Thread Franz Steinhaeusler
Hello, I'm only curious.

Why is Python and most extension (also wxPython) not built using an
open source compiler like gcc or g++ on Windows?

I'm always wondering, why Microsoft is still supported 
in that way, using VC++ 7.1, if I'm not wrong.

Ok, maybe the compiled assembler code could be better, but
this cannot be the reason, or?

It would be wonderful (from the principle) if this could be possible.
>From the standpoint of open source.

What are your opinions?
-- 
http://mail.python.org/mailman/listinfo/python-list


subprocess stdin encoding

2007-02-04 Thread yc
I have a encoding problem during using of subprocess. The input is a
string with UTF-8 encoding.

the code is:

tokenize =
subprocess.Popen(tok_command,stdin=subprocess.PIPE,stdout=subprocess.PIPE,close_fds=True,shell=True)

(tokenized_text,errs) = tokenize.communicate(t)

the error is:
  File "/usr/local/python/lib/python2.5/subprocess.py", line 651, in
communicate
return self._communicate(input)
  File "/usr/local/python/lib/python2.5/subprocess.py", line 1115, in
_communicate
bytes_written = os.write(self.stdin.fileno(), input[:512])
UnicodeEncodeError: 'ascii' codec can't encode character u'\xa9' in
position 204: ordinal not in range(128)


How I change the default encoding from "ascii" to "utf-8"?

Ying Chen

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


Re: sgmllib bug in Python 2.5, works in 2.4.

2007-02-04 Thread Stefan Rank
on 05.02.2007 03:49 John Nagle said the following:
> (Was prevously posted as a followup to something else by accident.)
> 
> I'm running a website page through BeautifulSoup.  It parses OK
> with Python 2.4, but Python 2.5 fails with an exception:
> 
> Traceback (most recent call last):
> File "./sitetruth/InfoSitePage.py", line 268, in httpfetch
>   self.pagetree = BeautifulSoup.BeautifulSoup(sitetext) # parse into tree 
> form
> File "./sitetruth/BeautifulSoup.py", line 1326, in __init__
>   BeautifulStoneSoup.__init__(self, *args, **kwargs)
> File "./sitetruth/BeautifulSoup.py", line 973, in __init__
>   self._feed()
> File "./sitetruth/BeautifulSoup.py", line 998, in _feed
>   SGMLParser.feed(self, markup or "")
> File "/usr/lib/python2.5/sgmllib.py", line 99, in feed
>   self.goahead(0)
> File "/usr/lib/python2.5/sgmllib.py", line 133, in goahead
>   k = self.parse_starttag(i)
> File "/usr/lib/python2.5/sgmllib.py", line 291, in parse_starttag
>   self.finish_starttag(tag, attrs)
> File "/usr/lib/python2.5/sgmllib.py", line 340, in finish_starttag
>   self.handle_starttag(tag, method, attrs)
> File "/usr/lib/python2.5/sgmllib.py", line 376, in handle_starttag
>   method(attrs)
> File "./sitetruth/BeautifulSoup.py", line 1416, in start_meta
>   self._feed(self.declaredHTMLEncoding)
> File "./sitetruth/BeautifulSoup.py", line 998, in _feed
>   SGMLParser.feed(self, markup or "")
> File "/usr/lib/python2.5/sgmllib.py", line 99, in feed
>   self.goahead(0)
> File "/usr/lib/python2.5/sgmllib.py", line 133, in goahead
>   k = self.parse_starttag(i)
> File "/usr/lib/python2.5/sgmllib.py", line 285, in parse_starttag
>   self._convert_ref, attrvalue)
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xa7 in position 0: 
> ordinal
> not in range(128)
> 
>   The code that's failing is in "_convert_ref", which is new in Python 
> 2.5.
> That function wasn't present in 2.4.  I think the code is trying to
> handle single quotes inside of double quotes, or something like that.
> 
>   To replicate, run
> 
>   http://www.bankofamerica.com
> or
>   http://www.gm.com
> 
> through BeautifulSoup.
> 
> Something about this code doesn't like big companies. Web sites of smaller
> companies are going through OK.
> 
> Also reported as a bug:
> 
> [ 1651995 ] sgmllib _convert_ref UnicodeDecodeError exception, new in 2.5
> 
> 
>   John Nagle

Hi,

I had a similar problem recently and did not have time to file a 
bug-report. Thanks for doing that.

The problem is the code that handles entity and character references in 
SGMLParser.parse_starttag. Seems that it is not careful about 
unicode/str issues.

My quick'n'dirty workaround was to remove the offending char-entity from 
the website before feeding it to Beautifulsoup::

   text = text.replace('®', '') # remove rights reserved sign entity

cheers,
stefan

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


Re: COM makepy util finds multiple versions of my COM object

2007-02-04 Thread Tim Roberts
[EMAIL PROTECTED] wrote:
>
>I have a problem where an earlier version of my Com object is being
>used by makepy for early binding. In makepy I see -
>
>MyCom (1.0)
>MyCom (1.0)
>MyCom (2.0)

Is your MyCom object also in Python?  The only way this can happen is if
you are generating different GUIDs every time you register the thing.  If
so, you need to unregister the old version before you register a new one.
-- 
Tim Roberts, [EMAIL PROTECTED]
Providenza & Boekelheide, Inc.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: problems loading modules

2007-02-04 Thread Ganesan Rajagopal
> Frank  <[EMAIL PROTECTED]> writes:

 import random
 from numpy import *
 
 print random.randrange(10)
> Traceback (most recent call last):
>  File "", line 1, in ?
> AttributeError: 'module' object has no attribute 'randrange'
 

> Here it does not work.

Here's a clue.

==
>>> import numpy
>>> numpy.random 

===

Ganesan

-- 
Ganesan Rajagopal

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


Re: problems loading modules

2007-02-04 Thread Ben Finney
"Frank" <[EMAIL PROTECTED]> writes:

> >>> import random
> >>> print random.randrange(10)
> 8
> >>>
>
> Everything is fine.
>
> >>> import random
> >>> from numpy import *
> >>>
> >>> print random.randrange(10)
> Traceback (most recent call last):
>  File "", line 1, in ?
> AttributeError: 'module' object has no attribute 'randrange'
> >>>
>
> Here it does not work.

"Don't do that, then."

More specifically, 'from foo import *' is deprecated for exactly the
reason you found here: you risk clobbering an existing name in the
current namespace, and there's no way to determine that by looking at
the code.

Instead, import modules preserving a module namespace, which is the
behaviour you get from 'import foo'. That way, all names remain
explicit and you can see where you might be re-binding an existing
name.

>>> import random
>>> random

>>> import numpy
>>> random

>>> numpy.random


Alternatively, if you want *specific* attributes from a module or
package to be in the current namespace, import them explicitly by
name; the same applied above, that you can see which names in
particular are being re-bound.

>>> import random
>>> random

>>> from numpy import random
>>> random


Again: don't use 'from foo import *', without knowing exactly why
you're doing it. 'import foo' or 'from foo import bar' are always
available, and usually better.

-- 
 \   "I always wanted to be somebody. I see now that I should have |
  `\  been more specific."  -- Lily Tomlin |
_o__)  |
Ben Finney

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


Re: problems loading modules

2007-02-04 Thread Robert Kern
Frank wrote:
> Hi,
> 
> I have the following weird behavior when I load modules:
> 
> 
 import random
 print random.randrange(10)
> 8
> 
> Everything is fine.
> 
 import random
 from numpy import *

 print random.randrange(10)
> Traceback (most recent call last):
>  File "", line 1, in ?
> AttributeError: 'module' object has no attribute 'randrange'
> 
> Here it does not work.

numpy has a subpackage called random. You imported it when you did "from numpy
import *".

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco

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


problems loading modules

2007-02-04 Thread Frank
Hi,

I have the following weird behavior when I load modules:


>>> import random
>>> print random.randrange(10)
8
>>>

Everything is fine.

>>> import random
>>> from numpy import *
>>>
>>> print random.randrange(10)
Traceback (most recent call last):
 File "", line 1, in ?
AttributeError: 'module' object has no attribute 'randrange'
>>>

Here it does not work.


>>> from numpy import *
>>> import random
>>>
>>> print random.randrange(10)
8
>>>

Now everything is back to normal.

That means the order the modules are loaded matters! I would expect
there is a problem with my installation because I guess this should
normally be independent of the loaded modules.

Here are my questions:
1. Does anyone has this behavior too?

2. How can I fix this problem?

I use linux with fedora core 6 and python 2.4.4

I appreciate any hint. Thanks!

Frank

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


Re: Parallel Python

2007-02-04 Thread parallelpython
On Jan 12, 11:52 am, Neal Becker <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> > Has anybody tried to runparallelpythonapplications?
> > It appears that if your application is computation-bound using 'thread'
> > or 'threading' modules will not get you any speedup. That is because
> >pythoninterpreter uses GIL(Global Interpreter Lock) for internal
> > bookkeeping. The later allows only onepythonbyte-code instruction to
> > be executed at a time even if you have a multiprocessor computer.
> > To overcome this limitation, I've created ppsmp module:
> > http://www.parallelpython.com
> > It provides an easy way to runparallelpythonapplications on smp
> > computers.
> > I would appreciate any comments/suggestions regarding it.
> > Thank you!
>
> Looks interesting, but is there any way to use this for a cluster of
> machines over a network (not smp)?

There are 2 major updates regarding Parallel Python: http://
www.parallelpython.com

1) Now (since version 1.2) parallel python software could be used for
cluster-wide parallelization (or even Internet-wide). It's also
renamed accordingly: pp (module is backward compatible with ppsmp)

2) Parallel Python became open source (under BSD license): http://
www.parallelpython.com/content/view/18/32/

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


Re: Recursive zipping of Directories in Windows

2007-02-04 Thread Josh Bloom

Hi Jandre,

Your code is treating the directory as a file and trying to open it and read
its bytes to zip them. You'll need to differentiate between files and
directories.

You'll need to check out the Zip module to see how it expects files that
should be nested within folders. I believe you'll need to set the archive
name for the nested files to something like \\temp\\file.ext etc.

-Josh


On 4 Feb 2007 11:42:23 -0800, Jandre <[EMAIL PROTECTED]> wrote:


On Feb 1, 9:39 pm, Larry Bates <[EMAIL PROTECTED]> wrote:
> Jandre wrote:
> > Hi
>
> > I am a python novice and I am trying to write a python script (most of
> > the code is borrowed) to Zip a directory containing some other
> > directories and files. The script zips all the files fine but when it
> > tries to zip one of the directories it fails with the following
> > error:
> > "IOError: [Errno 13] Permission denied: 'c:\\aaa\\temp'"
>
> > The script I am using is:
>
> > import zipfile, os
>
> > def toZip( directory, zipFile ):
> > """Sample for storing directory to a ZipFile"""
> > z = zipfile.ZipFile(
> > zipFile, 'w', compression=zipfile.ZIP_DEFLATED
> > )
> > def walker( zip, directory, files, root=directory ):
> > for file in files:
> > file = os.path.join( directory, file )
> > # yes, the +1 is hacky...
> > archiveName = file[len(os.path.commonprefix( (root,
> > file) ))+1:]
> > zip.write( file, archiveName, zipfile.ZIP_DEFLATED )
> > print file
> > os.path.walk( directory, walker, z  )
> > z.close()
> > return zipFile
>
> > if __name__ == "__main__":
> > toZip( 'c:\\aaa', 'c:\\aaa\\test.zip' )
>
> > I have tried to set the permissions on the folder, but when I check
> > the directory permissions it is set back to "Read Only"
>
> > Any suggestions?
>
> > Thanks
> > Johan Balt
>
> Couple of quick suggestions that may help:
>
> 1) don't use 'file' as a variable name. It will mask
> the builtin file function.  If it hasn't bitten you before
> it will if you keep doing that.
>
> 2) If you put the target .zip file in the directory you are
> backing what do you expect the program to do when it comes
> to the file you are creating as you walk the directory?  You
> haven't done anything to 'skip' it.
>
> 3) Your commonprefix and +1 appears to result in same
> information that the easier to use os.path.basename()
> would give you.  Double check me on that.
>
> I don't see anything that references C:\\aaa\temp in your
> code.  Does it exist on your hard drive?  If so does it
> maybe contain temp files that are open?  zipfile module
> can't handle open files.  You must use try/except to
> catch these errors.
>
> Hope info helps.
>
> -Larry

Thank you Larry.
I've changed the code as epr your advice. The code is now:

import zipfile, os

def toZip( directory, zipFile ):
"""Sample for storing directory to a ZipFile"""
z = zipfile.ZipFile(
zipFile, 'w', compression=zipfile.ZIP_DEFLATED
)
def walker( zip, directory, files, root=directory ):
for f in files:
f = os.path.join( directory, f )
archiveName = os.path.basename(f)
zip.write( f, archiveName, zipfile.ZIP_DEFLATED )
print f
os.path.walk( directory, walker, z  )
z.close()
return zipFile


if __name__ == "__main__":
toZip( 'c:\\aaa\\', 'c:\\bbb\\test.zip' )

I still get the same error:
Traceback (most recent call last):
  File "C:\Python24\Lib\site-packages\pythonwin\pywin\framework
\scriptutils.py", line 310, in RunScript
exec codeObject in __main__.__dict__
  File "C:\Python24\Scripts\dirZip.py", line 20, in ?
toZip( 'c:\\aaa\\', 'c:\\bbb\\test.zip' )
  File "C:\Python24\Scripts\dirZip.py", line 14, in toZip
os.path.walk( directory, walker, z  )
  File "C:\Python24\lib\ntpath.py", line 329, in walk
func(arg, top, names)
  File "C:\Python24\Scripts\dirZip.py", line 12, in walker
zip.write( f, archiveName, zipfile.ZIP_DEFLATED )
  File "C:\Python24\lib\zipfile.py", line 405, in write
fp = open(filename, "rb")
IOError: [Errno 13] Permission denied: 'c:\\aaa\\temp'

c:\\aaa\\temp is a directory in the directory I an trying to zip. I
want to use this script to back up my work once a day and would like
to
keep the directory structure as is. I can zip the files in c:\aaa\tem
fine so I guess that there aren't any open files in the directory.
Any more ideas?

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

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

Re: Decimating Excel files

2007-02-04 Thread gonzlobo
Excellent suggestion. I'm going with xlrd! Thanks

> I've had good luck with xlrd. It does not require using COM, Excel, or even 
> Windows!
>   http://www.lexicon.net/sjmachin/xlrd.htm
> Robert Kern
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Parameter lists

2007-02-04 Thread Steven D'Aprano
On Sun, 04 Feb 2007 17:45:04 +0100, Mizipzor wrote:

> Consider the following snippet of code:
> 
> ==
> 
> class Stats:
> def __init__(self, speed, maxHp, armor, strength, attackSpeed, imagePath):
> self.speed = speed
> self.maxHp = maxHp
> self.armor = armor
> self.strength = strength
> self.attackSpeed = attackSpeed
> self.originalImage = loadTexture(imagePath)
> 
> ==
> 
> I little container for holding the stats for some rpg character or
> something. Now, I dont like the looks of that code, there are many
> function parameters to be sent in and if I were to add an attribute, i
> would need to add it in three places. Add it to the function
> parameters, add it to the class and assign it.
> 
> Is there a smoother way to do this? There usually is in python, hehe.

There is no "right way" to handle the issue of initialising attributes.
The above way is very common, easy, self-documenting and doesn't have that
many disadvantages unless you have lots of parameters to deal with.


> I recall when reading python tutorials that you could do something
> like this:
> 
> foo(*list_of_parameters):
> 
> To send many parameters as a list or a tuple. Then I could assign them
> like this:
> 
> class Stats:
> def __init__(self, *li):
> self.speed = li[0]
> self.maxHp = li[1]
> (...)


That's even worse.

Which is correct?

Stats(..., armour, stealth, ...)
Stats(..., stealth, armour, ...)

You have to read the code to find out. Not just the function definition,
but you actually have to read through all the assignments. Bad bad bad.


> Or maybe there is an even niftier way that lets me iterate through
> them? Hmm... but that may lead to that I need to store them in a way
> that makes it cumbersome to access them later.


def __init__(self, **kwargs):
for key in kwargs:
if hasattr(self, key):
# key clashes with an existing method or attribute
raise ValueError("Attribute clash for '%s'" % key)
self.__dict__.update(kwargs)


=== Advantages ===

(1) you can create new attributes without changing any code;
(2) creating an instance is self-documenting:

Stats(armour="chainmail", stealth=2, strength=4, ...)

(3) attributes can be added in any order;
(4) easy to modify the class so it inherits sensible defaults:

class Stats:
armour = "leather"
wisdom = 10
dexterity = 10
weapon = "sword"
def __init__(self, **kwargs):
for key in kwargs:
if self.__dict__.has_key(key):
raise ValueError("Attribute clash for '%s'" % key
self.__dict__.update(kwargs)



=== Disadvantages ===

(1) You have to put in the attribute name, always:

Stats(armour="chainmail", stealth=2, strength=4, ...) instead of
Stats("chainmail", 2, 4, ...)

(2) Typos can cause strange bugs which are hard to find:

Stats(armour="chainmail", stealth=2, stregnth=4, ...)

Now your character is unexpectedly strong because it inherits the default,
and you don't know why.

(3) Easy to break your class functionality:

Stats(name_that_clashes_with_a_method="something else", ...)



If you've got lots of attributes, you're better off moving them to
something like a INI file and reading from that:

class Stats:
defaults = "C:/path/defaults.ini"
def __init__(self, filename=None, **kwargs):
if not filename:
filename = self.__class__.defaults
self.get_defaults(filename) # an exercise for the reader
for key in kwargs:
if not self.__dict__.has_key(key):
raise ValueError("Unknown attribute '%s' given" % key)
self.__dict__.update(kwargs)

Notice that here I've changed from testing for attributes which clash to
testing for attributes which *don't* match a key in the INI file. Which is
the "best" behaviour, I leave up to you to decide.



-- 
Steven D'Aprano 



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


Weekly Python Patch/Bug Summary

2007-02-04 Thread Kurt B. Kaiser
Patch / Bug Summary
___

Patches :  423 open ( +2) /  3553 closed ( +4) /  3976 total ( +6)
Bugs:  963 open (+20) /  6479 closed ( +8) /  7442 total (+28)
RFE :  260 open ( +0) /   250 closed ( +0) /   510 total ( +0)

New / Reopened Patches
__

ConfigParser getboolean() consistency  (2007-01-28)
   http://python.org/sf/1646432  opened by  Tal Einat

gzip.GzipFile has no name attribute  (2007-01-29)
   http://python.org/sf/1647484  opened by  Lars Gustäbel

proxy_bypass in urllib handling of  macro  (2007-01-30)
   http://python.org/sf/1648102  opened by  Anthony Tuininga

pty.fork() python implementation leaks the slave fd  (2007-01-31)
CLOSED http://python.org/sf/1648435  opened by  John Levon

Adding support for _Bool to ctypes as c_bool  (2007-01-31)
   http://python.org/sf/1649190  opened by  David Remahl

configHandler support for raw data  (2007-02-01)
   http://python.org/sf/1650174  opened by  Tal Einat

Patches Closed
__

file -> open in stdlib  (2007-01-25)
   http://python.org/sf/1644218  closed by  gbrandl

compiler.pycodegen causes crashes when compiling 'with'  (2007-01-18)
   http://python.org/sf/1638243  closed by  gbrandl

Add aliases for latin7/9/10 charsets  (2007-01-13)
   http://python.org/sf/1634778  closed by  gbrandl

pty.fork() python implementation leaks the slave fd  (2007-01-31)
   http://python.org/sf/1648435  closed by  gbrandl

New / Reopened Bugs
___

os.access now returns bool but docstring is not updated  (2007-01-27)
CLOSED http://python.org/sf/1645944  opened by  Seo Sanghyeon

Dict lookups fail if sizeof(Py_ssize_t) < sizeof(long)  (2007-01-27)
   http://python.org/sf/1646068  opened by  ked-tao

ctypes.string_at(buf, 0) is seen as zero-terminated-string  (2007-01-28)
   http://python.org/sf/1646630  opened by  Johannes Hölzl

datetime.fromtimestamp fails with negative fractional times  (2007-01-29)
   http://python.org/sf/1646728  opened by  James Henstridge

os.path, %HOME% set: realpath contradicts expanduser on '~'  (2007-01-29)
   http://python.org/sf/1646838  opened by  wrstl prmpft

cookielib.CookieJar does not handle cookies when port in url  (2007-01-29)
CLOSED http://python.org/sf/1647037  opened by  STS

zero-length match confuses re.finditer()  (2007-01-29)
   http://python.org/sf/1647489  opened by  Jacques Frechet

SystemError with re.match(array)  (2007-01-30)
   http://python.org/sf/1647541  opened by  Armin Rigo

No obvious and correct way to get the time zone offset  (2007-01-30)
   http://python.org/sf/1647654  opened by  James Henstridge

set update problem with class derived from dict  (2007-01-30)
CLOSED http://python.org/sf/1648179  opened by  duncan

Grammatical error  (2007-01-30)
CLOSED http://python.org/sf/1648191  opened by  Chris Beelby

Parameter list mismatches (portation problem)  (2007-01-30)
   http://python.org/sf/1648268  opened by  ked-tao

HP-UX: ld -Wl,+b...  (2007-01-31)
   http://python.org/sf/1648890  opened by  Johannes Abt

HP-UX: -lcurses missing for readline.so  (2007-01-31)
   http://python.org/sf/1648923  opened by  Johannes Abt

HP-UX: _ctypes/libffi/src/ia64/ffi/__attribute__/native cc  (2007-01-31)
   http://python.org/sf/1648957  opened by  Johannes Abt

HP-UX11.23: module zlib missing  (2007-01-31)
   http://python.org/sf/1648960  opened by  Johannes Abt

HP-UX: compiler warnings: alignment  (2007-01-31)
   http://python.org/sf/1649011  opened by  Johannes Abt

non-standard: array[0]  (2007-01-31)
   http://python.org/sf/1649098  opened by  Johannes Abt

Arithmetics behaving strange  (2007-01-31)
CLOSED http://python.org/sf/1649100  opened by  Sascha Peilicke

potential class with C++ in ceval.h  (2007-01-31)
   http://python.org/sf/1649238  opened by  thechao

gettext.py incompatible with eggs  (2007-01-31)
   http://python.org/sf/1649329  opened by  Shannon -jj Behrens

decimals compare badly to floats  (2007-02-01)
   http://python.org/sf/1650053  opened by  Brian Sutherland

doctest doesn't find nested functions  (2007-02-01)
   http://python.org/sf/1650090  opened by  Daniel Brown

sys.excepthook does not work with -m command line switch  (2007-02-02)
CLOSED http://python.org/sf/1650899  opened by  Miki Tebeka

PyFloat_FromString deprecated form  (2007-02-02)
   http://python.org/sf/1650903  opened by  Jim Jewett

ctypes.Structure formal parameter dies given tuple  (2007-02-03)
   http://python.org/sf/1651235  opened by  Gary Bishop

readline needs termcap on my FC6  (2007-02-03)
   http://python.org/sf/1651427  opened by  guichaz

sgmllib _convert_ref UnicodeDecodeError exception, new in 2.  (2007-02-04)
   http://python.org/sf/1651995  opened by  John Nagle

Bugs Closed
___

os.access now returns bool but docstring is not updated  (2007-01-27)
   http://python.org/sf/1645944  closed by  gbrandl

cookielib.

Re: Missing member

2007-02-04 Thread Paul McGuire
On Feb 4, 4:45 pm, "Mizipzor" <[EMAIL PROTECTED]> wrote:
> I have some troubles with a member variable that seems to be missing
> in a class. In short, heres what I do; class A is the parent class, B
> inherits from A and C inherits from B (hope I used the right words
> there). Now, I create an instance of C, which calls A's __init__ which
> in turn creates all the member variables. Then I call C.move() (a
> function defined in A), but then, one of the variables seems to have
> become 'NoneType'.
>
> The code can be found here (Ive taken away unnecessery 
> stuff):http://pastebin.com/875394
>
> The exact error is (which occur on line 15 in the pasted code):
> TypeError: unsupported operand type(s) for *: 'NoneType' and 'float'
>
> Any comments are welcome. :)

Here's a suggestion: use new-style classes.  Have _BaseEntity inherit
from object, allows you to use super for invoking methods on super
classes.  Instead of:
class Entity(_BaseEntity):
def __init__(self, type, x = 0, y = 0):
_BaseEntity.__init__(self, type, x, y)

You enter:
class Entity(_BaseEntity):
def __init__(self, type, x = 0, y = 0):
super(Entity,self).__init__(type, x, y)

This makes it easier to update your inheritance hierarchy later.  New-
style classes have other benefits too.

As for your NoneType problem, try adding "print self._direction" to
the end of _BaseElement.__init__.

-- Paul

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


sgmllib bug in Python 2.5, works in 2.4.

2007-02-04 Thread John Nagle
(Was prevously posted as a followup to something else by accident.)

I'm running a website page through BeautifulSoup.  It parses OK
with Python 2.4, but Python 2.5 fails with an exception:

Traceback (most recent call last):
File "./sitetruth/InfoSitePage.py", line 268, in httpfetch
  self.pagetree = BeautifulSoup.BeautifulSoup(sitetext) # parse into tree 
form
File "./sitetruth/BeautifulSoup.py", line 1326, in __init__
  BeautifulStoneSoup.__init__(self, *args, **kwargs)
File "./sitetruth/BeautifulSoup.py", line 973, in __init__
  self._feed()
File "./sitetruth/BeautifulSoup.py", line 998, in _feed
  SGMLParser.feed(self, markup or "")
File "/usr/lib/python2.5/sgmllib.py", line 99, in feed
  self.goahead(0)
File "/usr/lib/python2.5/sgmllib.py", line 133, in goahead
  k = self.parse_starttag(i)
File "/usr/lib/python2.5/sgmllib.py", line 291, in parse_starttag
  self.finish_starttag(tag, attrs)
File "/usr/lib/python2.5/sgmllib.py", line 340, in finish_starttag
  self.handle_starttag(tag, method, attrs)
File "/usr/lib/python2.5/sgmllib.py", line 376, in handle_starttag
  method(attrs)
File "./sitetruth/BeautifulSoup.py", line 1416, in start_meta
  self._feed(self.declaredHTMLEncoding)
File "./sitetruth/BeautifulSoup.py", line 998, in _feed
  SGMLParser.feed(self, markup or "")
File "/usr/lib/python2.5/sgmllib.py", line 99, in feed
  self.goahead(0)
File "/usr/lib/python2.5/sgmllib.py", line 133, in goahead
  k = self.parse_starttag(i)
File "/usr/lib/python2.5/sgmllib.py", line 285, in parse_starttag
  self._convert_ref, attrvalue)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xa7 in position 0: ordinal
not in range(128)

  The code that's failing is in "_convert_ref", which is new in Python 2.5.
That function wasn't present in 2.4.  I think the code is trying to
handle single quotes inside of double quotes, or something like that.

  To replicate, run

http://www.bankofamerica.com
or
http://www.gm.com

through BeautifulSoup.

Something about this code doesn't like big companies. Web sites of smaller
companies are going through OK.

Also reported as a bug:

[ 1651995 ] sgmllib _convert_ref UnicodeDecodeError exception, new in 2.5


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


Re: Return images with matplotlib?

2007-02-04 Thread Istvan Albert
On Feb 4, 8:18 pm, Jan Danielsson <[EMAIL PROTECTED]> wrote:

> def barchart(req, params):
>some_format = matplotlib.generate_fancy_graph(params)
>png_buf = make_png_buffer(some_format)
>return png_buf
>
>Is this possible? If so -- how?

savefig does that. You can save to a file name or a buffer.

http://matplotlib.sourceforge.net/matplotlib.pylab.html#-savefig

i.


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


Return images with matplotlib?

2007-02-04 Thread Jan Danielsson
Hello all,

   I have written a program which takes some data from a postgresql
database, and via mod_python outputs it as tables on a web site. Now I
would like to present these tables as graphs, which matplotlib can do.
  But in order to properly display these graphs on the web page, I need
to return the image data, like so:

def barchart(req, params):
   some_format = matplotlib.generate_fancy_graph(params)
   png_buf = make_png_buffer(some_format)
   return png_buf

   Is this possible? If so -- how?

-- 
Kind regards,
Jan Danielsson
 And now a word from our sponsor --
For a quality usenet news server, try DNEWS, easy to install,
fast, efficient and reliable. For home servers or carrier class
installations with millions of users it will allow you to grow!
  See http://netwinsite.com/sponsor/sponsor_dnews.htm  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python does not play well with others

2007-02-04 Thread Graham Dumpleton
On Feb 5, 9:45 am, John Nagle <[EMAIL PROTECTED]> wrote:
> Graham Dumpleton wrote:
> > On Feb 4, 1:05 pm, Paul Rubin  wrote:
>
> >>"Paul Boddie" <[EMAIL PROTECTED]> writes:
>
> >>>Probably the biggest inhibitor, as far as I can see, has been the
> >>>server technology chosen. Many hosting providers have historically
> >>>offered no better than CGI for Python, whilst PHP runs within Apache
> >>>itself, and it has previously been stated that mod_python has been
> >>>undesirable with regard to isolating processes from each other.
> >>>Consequently, a number of Python people seem to have held out for
> >>>other "high performance" solutions, which various companies now offer.
>
> >>Your point that shared hosting with Python isn't so easy because of
> >>insufficient isolation between apps is valid.  Maybe Python 3.0 can do
> >>something about that and it seems like a valid thing to consider while
> >>fleshing out the 3.0 design.
>
> > To clarify some points about mod_python, since these posts do not
> > properly explain the reality of the situation and I feel people are
> > getting the wrong impression.
>
> > First off, when using mod_python it is possible to have it create
> > multiple sub interpreters within each Apache child process.
>
>  Realistically, mod_python is a dead end for large servers,
> because Python isn't really multi-threaded.  The Global Python
> Lock means that a multi-core CPU won't help performance.

That is not true if 'prefork' MPM is used for Apache which is how most
people seem to run it. This is because each Apache child process only
run one request at a time and so there isn't normally going to be any
contention on the GIL at all. The only case where there would be
contention in this arrangement is if the request handlers within
Apache had spawned off distinct threads themselves to do stuff. Even
then, in this arrangement the main request handler is usually not
doing anything and is just waiting for the created thread to finish
what it was doing. Thus if only one thread was spawned to do some work
or a blocking operation to allow the main thread to timeout, then
again there isn't really any contention as only one thread is actually
doing anything. If you are trying to embed very intensive operations
with threads within Apache then I would suggest it is not really the
best design you could use anyway as such things would be much better
farmed off to a long running backend process using XML-RPC or some
other interprocess communication mechanism.

If one is using the "worker" MPM then yes there will be some
contention if multiple requests are being handled by mod_python at the
same time within the same Apache child process. The downside of this
is lessened however by the fact that there are still multiple Apache
child processes and Apache will spread requests across all the Apache
child processes, thus the amount that may be running concurrently
within any one process is less.

The basic problem of GIL contention here is no different to a single
Python backend process which is handling everything behind Apache. In
some respects the Apache approach actually works better as there are
multiple processes spreading the load. Your comment on the GIL is
therefore partly unjustified in that respect for Apache and
mod_python. Your statement in some respect still stands for Python
itself when run as a single process, but you linked it to mod_python
and Apache which lessens the impact through its architecture of using
multiple child processes.

Finally we have 'winnt' MPM, again, because this is all in the one
process you will have GIL contention in a much more substantial
manner. However, I'd suggest that most wouldn't choose Apache on
Windows as a major deployment platform.

>  FastCGI, though, can get all the CPUs going.  It takes more
> memory, though, since each instance has a full copy of Python
> and all the libraries in use.

How is that any different to Apache child processes. Each Apache child
process has a full copy of Python and the libraries in use. Each
Apache child process can be making use of different CPUs. Further,
static file requests, plus other requests against PHP, mod_perl etc
can when mod_python is also running be on separate CPUs within the
same child process when 'worker' MPM is being used. Thus you haven't
lost all forms or parallelism that may be possible, it is only within
the mod_python world that there will be some GIL contention and only
with 'worker' and 'winnt' MPMs, not 'prefork'. It isn't going to lock
out non Python stuff from making use of additional CPUs.

>  (FastCGI is a straightforward transaction processing engine.
> Each transaction program is launched in a separate process, and,
> once done with one transaction, can be used to do another one
> without reloading.  When things are slow, the extra transaction processes
> are told to exit; when load picks up, more of them are forked.
> Security is comparable to CGI.)

Ap

Re: It is good to blow up a marketplace full of people buying and selling food

2007-02-04 Thread Bob Kolker
Frank Arthur wrote:

> 
> Suicide truck bomber kills at least 130 in Baghdad
> By Tina Susman, Times Staff Writer
> 11:23 AM PST, February 3, 2007

The sound of the exploding bomb is the Muslim Call to Prayer.

Allah hu'Akbar.

Bob Kolker

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


Re: "Subscribing" to topics?

2007-02-04 Thread Kirk Sluder
In article <[EMAIL PROTECTED]>,
 "Mizipzor" <[EMAIL PROTECTED]> wrote:

> On Feb 4, 9:55 pm, Toby A Inkster <[EMAIL PROTECTED]>
> wrote:
> > You discovered wrong -- Google does not provide a free newsserver. They no
> > doubt *have* several newsservers, but don't provide direct access to them
> > either free, or for a fee. They only provide a web interface to access the
> > contents of their newsservers, with a fraction of the features that a real
> > newsreader would.
> 
> Hehe, it has all the features I knew existed in a newsreader, except
> this "subscribe to topic" thing Im looking for.

If you have My Groups enabled, you can highlight a topic as a 
favorite. When reading a thread, click on the star near the upper 
left corner of the screen under the subject header.  This will add 
that subject to your favorites.  Then to see your favorite topics, 
click "favorites" at the top of the page, toward the right-hand side.

In an email client, you can set a filter that dumps messages from a 
list that don't match specific keywords into the trash or an archive 
folder.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: when will python 2.5 take in mainstream?

2007-02-04 Thread [EMAIL PROTECTED]
When they have to ...

One of the big things about Python is that its penetration slows it
down. There's more legacy code and interdependant systems around now
that Python is more successful and more mature.

Here's a thought -- perhaps it would be worth having some good ways to
interact with Python from Python. Suppose you have some 2.4 code
someplace, interacting with your mysqldb or whatever, and you don't
want to rewrite it. So long as you have some kind of object broker,
you could (plausibly) leave your 2.4 apps running with the old
interpreter, but wrap them for Python 2.5 and use that in your new
development.

Ditto 3.0.

Rather than having to re-write every interacting component, maybe it
could be straightforward to all Python2.4 from Python2.5 to execute
particular library calls. I'm not an expert, I don't know how you'd
build such a system, but I do know that re-writing stuff is a real
pain.

Perhaps APIs for 2.5 and 3.0 could have a special version flag, and if
not present or not compatible, a 2.4 interpreter could be called
instead...

Cheers,
-T

On Feb 5, 8:01 am, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote:
> On Sun, 4 Feb 2007 19:10:13 +0800, "Eric CHAO" <[EMAIL PROTECTED]>
> declaimed the following in comp.lang.python:
>
> > When will all these applications support 2.5?
>
> cynical answer: when you download the sources and build them against
> the 2.5 headers
>
> In the case of MySQLdb, one problem is that, as I recall, the
> primary author does not have a Windows compatible build environment and
> essentially relies upon others doing the Linux port to Windows and
> releasing pre-built installers.
> --
> WulfraedDennis Lee Bieber   KD6MOG
> [EMAIL PROTECTED] [EMAIL PROTECTED]
> HTTP://wlfraed.home.netcom.com/
> (Bestiaria Support Staff:   [EMAIL PROTECTED])
> HTTP://www.bestiaria.com/


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


Re: Missing member

2007-02-04 Thread John Machin
On Feb 5, 9:45 am, "Mizipzor" <[EMAIL PROTECTED]> wrote:
> I have some troubles with a member variable that seems to be missing
> in a class. In short, heres what I do; class A is the parent class, B
> inherits from A and C inherits from B (hope I used the right words
> there). Now, I create an instance of C, which calls A's __init__ which
> in turn creates all the member variables. Then I call C.move() (a
> function defined in A), but then, one of the variables seems to have
> become 'NoneType'.
>
> The code can be found here (Ive taken away unnecessery 
> stuff):http://pastebin.com/875394
>
> The exact error is (which occur on line 15 in the pasted code):
> TypeError: unsupported operand type(s) for *: 'NoneType' and 'float'

Line 15 is:
self.pos += (self._direction * self.stats.speed)
So obviously(???) self._direction is None

What does line 8 do: self._direction = vector() ???

I'd suggest adding line 8.1:

assert self._direction is not None

> Any comments are welcome. :)

I doubt that you really mean that, so I have refrained from
commenting :-)

Cheers,
John

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


Re: Unicode problem in BeautifulSoup; worked in Python 2.4, fails in Python 2.5.

2007-02-04 Thread Mizipzor
On Feb 4, 11:39 pm, John Nagle <[EMAIL PROTECTED]> wrote:
> I'm running a website page through BeautifulSoup.  It parses OK
> with Python 2.4, but Python 2.5 fails with an exception:
>
> Traceback (most recent call last):
>File "./sitetruth/InfoSitePage.py", line 268, in httpfetch
>  self.pagetree = BeautifulSoup.BeautifulSoup(sitetext) # parse into tree 
> form
>File "./sitetruth/BeautifulSoup.py", line 1326, in __init__
>  BeautifulStoneSoup.__init__(self, *args, **kwargs)
>File "./sitetruth/BeautifulSoup.py", line 973, in __init__
>  self._feed()
>File "./sitetruth/BeautifulSoup.py", line 998, in _feed
>  SGMLParser.feed(self, markup or "")
>File "/usr/lib/python2.5/sgmllib.py", line 99, in feed
>  self.goahead(0)
>File "/usr/lib/python2.5/sgmllib.py", line 133, in goahead
>  k = self.parse_starttag(i)
>File "/usr/lib/python2.5/sgmllib.py", line 291, in parse_starttag
>  self.finish_starttag(tag, attrs)
>File "/usr/lib/python2.5/sgmllib.py", line 340, in finish_starttag
>  self.handle_starttag(tag, method, attrs)
>File "/usr/lib/python2.5/sgmllib.py", line 376, in handle_starttag
>  method(attrs)
>File "./sitetruth/BeautifulSoup.py", line 1416, in start_meta
>  self._feed(self.declaredHTMLEncoding)
>File "./sitetruth/BeautifulSoup.py", line 998, in _feed
>  SGMLParser.feed(self, markup or "")
>File "/usr/lib/python2.5/sgmllib.py", line 99, in feed
>  self.goahead(0)
>File "/usr/lib/python2.5/sgmllib.py", line 133, in goahead
>  k = self.parse_starttag(i)
>File "/usr/lib/python2.5/sgmllib.py", line 285, in parse_starttag
>  self._convert_ref, attrvalue)
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xa7 in position 0: 
> ordinal
> not in range(128)
>
>  The code that's failing is in "_convert_ref", which is new in Python 2.5.
> That function wasn't present in 2.4.  I think the code is trying to
> handle single quotes inside of double quotes, or something like that.
>
>  To replicate, run
>
>http://www.bankofamerica.com
> or
>http://www.gm.com
>
> through BeautifulSoup.
>
> Something about this code doesn't like big companies. Web sites of smaller
> companies are going through OK.
>
> Also reported as a bug:
>
> [ 1651995 ] sgmllib _convert_ref UnicodeDecodeError exception, new in 2.5
>
> John Nagle

I think this post got rather missplaced, hehe.

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


Re: Python does not play well with others

2007-02-04 Thread John Nagle
Graham Dumpleton wrote:
> On Feb 4, 1:05 pm, Paul Rubin  wrote:
> 
>>"Paul Boddie" <[EMAIL PROTECTED]> writes:
>>
>>>Probably the biggest inhibitor, as far as I can see, has been the
>>>server technology chosen. Many hosting providers have historically
>>>offered no better than CGI for Python, whilst PHP runs within Apache
>>>itself, and it has previously been stated that mod_python has been
>>>undesirable with regard to isolating processes from each other.
>>>Consequently, a number of Python people seem to have held out for
>>>other "high performance" solutions, which various companies now offer.
>>
>>Your point that shared hosting with Python isn't so easy because of
>>insufficient isolation between apps is valid.  Maybe Python 3.0 can do
>>something about that and it seems like a valid thing to consider while
>>fleshing out the 3.0 design.
> 
> 
> To clarify some points about mod_python, since these posts do not
> properly explain the reality of the situation and I feel people are
> getting the wrong impression.
> 
> First off, when using mod_python it is possible to have it create
> multiple sub interpreters within each Apache child process.

 Realistically, mod_python is a dead end for large servers,
because Python isn't really multi-threaded.  The Global Python
Lock means that a multi-core CPU won't help performance.

 FastCGI, though, can get all the CPUs going.  It takes more
memory, though, since each instance has a full copy of Python
and all the libraries in use.

 (FastCGI is a straightforward transaction processing engine.
Each transaction program is launched in a separate process, and,
once done with one transaction, can be used to do another one
without reloading.  When things are slow, the extra transaction processes
are told to exit; when load picks up, more of them are forked.
Security is comparable to CGI.)

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


Missing member

2007-02-04 Thread Mizipzor
I have some troubles with a member variable that seems to be missing
in a class. In short, heres what I do; class A is the parent class, B
inherits from A and C inherits from B (hope I used the right words
there). Now, I create an instance of C, which calls A's __init__ which
in turn creates all the member variables. Then I call C.move() (a
function defined in A), but then, one of the variables seems to have
become 'NoneType'.

The code can be found here (Ive taken away unnecessery stuff):
http://pastebin.com/875394

The exact error is (which occur on line 15 in the pasted code):
TypeError: unsupported operand type(s) for *: 'NoneType' and 'float'

Any comments are welcome. :)

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


Unicode problem in BeautifulSoup; worked in Python 2.4, fails in Python 2.5.

2007-02-04 Thread John Nagle
I'm running a website page through BeautifulSoup.  It parses OK
with Python 2.4, but Python 2.5 fails with an exception:

Traceback (most recent call last):
   File "./sitetruth/InfoSitePage.py", line 268, in httpfetch
 self.pagetree = BeautifulSoup.BeautifulSoup(sitetext) # parse into tree 
form
   File "./sitetruth/BeautifulSoup.py", line 1326, in __init__
 BeautifulStoneSoup.__init__(self, *args, **kwargs)
   File "./sitetruth/BeautifulSoup.py", line 973, in __init__
 self._feed()
   File "./sitetruth/BeautifulSoup.py", line 998, in _feed
 SGMLParser.feed(self, markup or "")
   File "/usr/lib/python2.5/sgmllib.py", line 99, in feed
 self.goahead(0)
   File "/usr/lib/python2.5/sgmllib.py", line 133, in goahead
 k = self.parse_starttag(i)
   File "/usr/lib/python2.5/sgmllib.py", line 291, in parse_starttag
 self.finish_starttag(tag, attrs)
   File "/usr/lib/python2.5/sgmllib.py", line 340, in finish_starttag
 self.handle_starttag(tag, method, attrs)
   File "/usr/lib/python2.5/sgmllib.py", line 376, in handle_starttag
 method(attrs)
   File "./sitetruth/BeautifulSoup.py", line 1416, in start_meta
 self._feed(self.declaredHTMLEncoding)
   File "./sitetruth/BeautifulSoup.py", line 998, in _feed
 SGMLParser.feed(self, markup or "")
   File "/usr/lib/python2.5/sgmllib.py", line 99, in feed
 self.goahead(0)
   File "/usr/lib/python2.5/sgmllib.py", line 133, in goahead
 k = self.parse_starttag(i)
   File "/usr/lib/python2.5/sgmllib.py", line 285, in parse_starttag
 self._convert_ref, attrvalue)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xa7 in position 0: ordinal 
not in range(128)

 The code that's failing is in "_convert_ref", which is new in Python 2.5.
That function wasn't present in 2.4.  I think the code is trying to
handle single quotes inside of double quotes, or something like that.

 To replicate, run

http://www.bankofamerica.com
or
http://www.gm.com

through BeautifulSoup.

Something about this code doesn't like big companies. Web sites of smaller 
companies are going through OK.

Also reported as a bug:

[ 1651995 ] sgmllib _convert_ref UnicodeDecodeError exception, new in 2.5


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


Re: Python does not play well with others

2007-02-04 Thread Paul Boddie
Graham Dumpleton wrote:
>
> Having said all that, perhaps those who are complaining about lack of
> support for specific features in mod_python can now clarify what
> actually you are talking about. At the moment the brief comments being
> made seem to possibly cover some things that mod_python can already do
> but may not be obvious.

I had a more complete response to this before Google Groups and my
browser went into "stupid mode" together, but I'd like to say that I
don't have any complaints about mod_python, but I know that there were
people who claimed [1] that PHP had its "safe mode" [2] which gave
isolation to applications belonging to different users in the same
Apache instance, asserting that mod_python not having that particular
feature prevented wider adoption of Python in the hosting business.

It's good to see a clarification of mod_python and its position in
relation to such issues, though. I don't really share the concerns
mentioned, and wouldn't want to be using or providing services of the
kind previously discussed, anyway. Instead, I'd want to deploy
applications using other techniques such as virtualisation, rather
than throwing customers into the same Web server and, apparently in
the case of PHP, relying on hearsay about whether they can interfere
with each other. I note that the creator of mod_python seems to have a
similar perspective on virtualisation, given the nature of his hosting
company's services.

Paul

[1] http://groups.google.com/group/comp.lang.python/msg/
469dd47f5c1ad521
[2] http://no.php.net/features.safe-mode

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


Re: How can I access data from MS Access?

2007-02-04 Thread Ben Finney
Bruno Desthuilliers <[EMAIL PROTECTED]> writes:

> I sadly admit that I was wrong. "Doesn't seem to work" is effectivly
> even more useless than "doesn't work". I give up.

+1 QOTW

-- 
 \ "You can't have everything; where would you put it?"  -- Steven |
  `\Wright |
_o__)  |
Ben Finney

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


Re: Python does not play well with others

2007-02-04 Thread Graham Dumpleton
On Feb 4, 1:05 pm, Paul Rubin  wrote:
> "Paul Boddie" <[EMAIL PROTECTED]> writes:
>> Probably the biggest inhibitor, as far as I can see, has been the
>> server technology chosen. Many hosting providers have historically
>> offered no better than CGI for Python, whilst PHP runs within Apache
>> itself, and it has previously been stated that mod_python has been
>> undesirable with regard to isolating processes from each other.
>> Consequently, a number of Python people seem to have held out for
>> other "high performance" solutions, which various companies now offer.
>
> Your point that shared hosting with Python isn't so easy because of
> insufficient isolation between apps is valid.  Maybe Python 3.0 can do
> something about that and it seems like a valid thing to consider while
> fleshing out the 3.0 design.

To clarify some points about mod_python, since these posts do not
properly explain the reality of the situation and I feel people are
getting the wrong impression.

First off, when using mod_python it is possible to have it create
multiple sub interpreters within each Apache child process. These
distinct sub interpreters can be linked to different parts of the URL
namespace. This means that it is possible to host more than one
mod_python application where each executes within in their own
distinct sub interpreter. The outcome of this is that each application
can have their own sys.path, own os.environ, own sets of modules and
potentially with different versions of some module.

Maintaining separation using sub interpreters eliminates the bulk of
problems with applications interfering which each other at least
within a process. Some problems can still arise though where third
party extension modules for Python aren't written so as to be usable
from multiple sub interpreters at the same time however. This is not a
failing of mod_python though, but a failing of the module writers.

The main area where interference can occur is where applications needs
to write to the file system. This is because all code will be
executing as the user that Apache runs as. Thus, distinct applications
could overwrite each others data within the file system. On one level
this just means that applications need to be configured to always use
their own part of the file system. For example, if using the support
in mod_python for sessions, the distinct applications should perhaps
use separate session databases rather than use the same common
database. Ultimately though, a rogue application could write where
ever it wants to, but from what I know (and could be wrong), this
isn't different to other languages systems within Apache such as PHP
and mod_perl.

Another possibility for interference is where an application simply
does something bad like get stuck in a tight loop or consume lots of
memory. Such an event can possibly interfere with other applications,
even across language boundaries, however, how bad the impact will be
depend on what MPM is used by Apache.

If "prefork" MPM is used, then the request being handled by that
application is the only thing which would be running within that child
process at that particular time. Thus, if it stops the functioning of
just that one process it doesn't matter as Apache will just farm
requests off to other child processes. If that initial child process
crashes because of the problem, then again it doesn't matter as Apache
will just create another child process to replace it and will
otherwise keep running.

If the "worker" MPM is used the impact can be greater as there could
be other requests being handled concurrently within the same child
process and the performance of those requests may be hindered. If the
worst happens and the child process crashes, only other requests being
handled within that specific child process would be affected, those in
other child processes would again continue unaffected as would Apache
as a whole.

The worst case is the "winnt" MPM (ie., Windows boxes). This is
because there is only one Apache process and thus a rogue application
can affect the whole Apache web server.

It should be highlighted though that this class of problem is not
unique to Python or mod_python as you could get rogue code in a PHP
page or mod_perl application just as easily.

What it all really comes down to is that the only features that are
really missing are the ability for distinct applications to run as
distinct users, or for applications to run inside of some sort of
chroot environment. Some aspects of this are addressed by FCGI and
SCGI, but again lack of this feature within mod_python itself is not
unique to it and that as far as I know is also going to be an issue
for other language systems for Apache such as PHP or mod_perl.

Having said all that, perhaps those who are complaining about lack of
support for specific features in mod_python can now clarify what
actually you are talking about. At the moment the brief comments being
made seem to possi

Re: It is good to blow up a marketplace full of people buying and selling food

2007-02-04 Thread thermate
On Feb 4, 11:46 am, "Frank Arthur" <[EMAIL PROTECTED]> wrote:
> It is good to blow up a marketplace full of people buying and selling food
> in Iraq.
> This is how Muslim insurgents will drive "the enemy" out of their country.
> By killing and maiming fellow Iraqis! The traditional Muslim way.
> The way of Allah! The way of the Quaran! The way of Mohammed!
> They don't need any democracy. They don't need free elections. They are true
> believers!

Excellent comment by the internet spook on duty. Your analysis is
correct that they are CIA PATSIES. They dont have the smarts of Cuba,
India, Iran, Venezuela, Israel or the Yanks. Its quite obvious who is
behind the controlled demolition of Silverstein Properties and the
Golden Dome of that mosque or shrine of the Shia.

Dr Fidel Castro Ruz has made Cuba into a leading Biotechnology Center
of the World. Many American sheeple dont even know the full name of Dr
Ruz, or his occupation or even the status of Cuba as the leading
Biotechnology Center in the world.



RESPONSE FROM DR. FIDEL CASTRO RUZ, PRESIDENT OF THE REPUBLIC OF CUBA,
TO THE STATEMENTS MADE BY THE UNITED STATES GOVERNMENT ON BIOLOGICAL
WEAPONS.

Hardly three days ago, someone only too well known to us, Assistant
Secretary of State Otto Reich was caught out in an embarrassing lie
when he said that four Cuban planes had landed in the Venezuelan
capital on April 12, and that nobody knew "what they were doing there,
what they were carrying, we don't know". Apparently, it was the
beginning of an anti-Cuba campaign or a vendetta due to the amazing
failure of the fascist coup he set in motion, or both.

On Tuesday May 7, when the Ministry of Foreign Affairs challenged him
publicly, the State Department said that it had no confirmation
whatsoever, and that it did not want to discuss the subject any more.

The idea of destroying Cuba, an obsession that has lasted more than 43
years, has lead and still leads U.S. policy down a tortuous path
filled with lies, mistakes, failures and crimes. What the US
government is telling the world today and what it is doing with Cuba
is perhaps the most grievous and demoralizing contradiction in its
foreign policy. This great power had never found itself in such a
compromising position and it has no alternative but to lie, lie and
lie. And there is no lack of unscrupulous characters in major public
positions willing to do so, no lack of press spokesmen caught up in
the continuous and bitter need to right wrongs and explain the
inexplicable in their bosses' statements.

Even men like Colin Powell, son of Jamaican immigrants, that despite
his military training or maybe because of it, is not considered a hawk
since he knows about war and has seen many men die --a man that many
Americans even came to look on as a potential presidential candidate--
has found himself enmeshed in shameful and little ennobling intrigues
promoted by such characters. He knows better than anyone else how
inexperienced they are and what little intellectual and political
worth those people have.

Whom this new character involved in a sinister maneuver against Cuba
can deceive? Mr. John Bolton, an Under Secretary of State, none other
than the one for Arms Control. What are they aiming for with the
attack launched by this official in an aggressive speech against Cuba
given at the Heritage Foundation, famous for its ultra-rightwing
stance?

His statement, supposedly an analysis of the dangers of terrorism
threatening the United States, begin by saying: "In addition to Libya
and Syria, there is a threat coming from another BWC signatory, and
one that lies just 90 miles from the U.S. mainland-namely, Cuba."

Then, after the usual name-calling and stupid remarks full of the
hatred common in such arrogant and misinformed people, Mr. Bolton
added something all his own:

"We know that Cuba is collaborating with other state sponsors of
terror."

"Castro has repeatedly denounced the U.S. war on terrorism. He
continues to view terror as a legitimate tactic to further
revolutionary objectives. Last year, Castro visited Iran, Syria and
Libya --all designees on the same list of terrorist-sponsoring states.
At Teheran University, these were his words: 'Iran and Cuba, in
cooperation with each other, can bring America to its knees. The U.S.
regime is very weak, and we are witnessing this weakness from close-
up.'"

"But Cuba's threat to our security has often been underplayed. An
official U.S. government report in 1998 concluded that Cuba did not
represent a significant military threat to the United States or the
region. It went only so far as to say that, 'Cuba has a limited
capacity to engage in some military and intelligence activities which
could pose a danger to U.S. citizens in some circumstances.'"

Mr. Bolton immediately looked for something to cover up the suspicious
fact that it had never before occurred to any US government official
to make such an infamous accusation against Cuba. Mr. Bolton blames
this weaknes

Re: "Subscribing" to topics?

2007-02-04 Thread Mizipzor
On Feb 4, 9:55 pm, Toby A Inkster <[EMAIL PROTECTED]>
wrote:
> You discovered wrong -- Google does not provide a free newsserver. They no
> doubt *have* several newsservers, but don't provide direct access to them
> either free, or for a fee. They only provide a web interface to access the
> contents of their newsservers, with a fraction of the features that a real
> newsreader would.

Hehe, it has all the features I knew existed in a newsreader, except
this "subscribe to topic" thing Im looking for.

> You seem to already have a newsreader -- you're using Opera, which
> includes a fairly good one, hidden away in the Hotlist/Panels/whatever-
> they're-calling-it-today. Other newsreaders I'd recommend are PAN and
> Forte Agent.

Did I mention I use Opera? I do anyway, it was just days ago I made
the switch from Firefox. I found their mail-/newsreader client but
since I didnt know what to type in the server settings of the
newsreader, my search continued.

> So you just need a server. "pubnews.gradwell.net" still seems to exist --
> it's free. Alternatively, "news.individual.net" offers a good service for
> a fairly low yearly cost.

So should "pubnews.gradwell.net" go in both Incoming and Outgoing
server fields?

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


Re: How can I access data from MS Access?

2007-02-04 Thread Bruno Desthuilliers
Peter Otten a écrit :
> [EMAIL PROTECTED] wrote:
> 
> 
>>On Feb 3, 10:27 pm, Bruno Desthuilliers
> 
> 
>>>"doesn't work" is the worst possible description of a problem. Did it
>>>print out some insults in a foreign language ? wipe out your HD ? Else ?
> 
>  
> 
>>I havn't said "doesn't work", I rather doesn't seem to work.
> 
> 
> Bruno, admit that you were wrong. Finger.Octopus is able to give a
> description that is even worse than what you deemed possible :-)

Peter, I sadly admit that I was wrong. "Doesn't seem to work" is 
effectivly even more useless than "doesn't work". I give up.

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


Re: "Subscribing" to topics?

2007-02-04 Thread Toby A Inkster
Mizipzor wrote:

> I searhed around a little and it seems that not only do i need a
> newsreader, i need a newsserver to. To fetch all the messages from
> here. I learned that sometimes the ISP provides one, however, mine do
> not. But then I discovered that Google has a free newsserver, so I
> joined this group from there.

You discovered wrong -- Google does not provide a free newsserver. They no
doubt *have* several newsservers, but don't provide direct access to them
either free, or for a fee. They only provide a web interface to access the
contents of their newsservers, with a fraction of the features that a real
newsreader would.

You seem to already have a newsreader -- you're using Opera, which
includes a fairly good one, hidden away in the Hotlist/Panels/whatever-
they're-calling-it-today. Other newsreaders I'd recommend are PAN and
Forte Agent.

So you just need a server. "pubnews.gradwell.net" still seems to exist --
it's free. Alternatively, "news.individual.net" offers a good service for
a fairly low yearly cost.

-- 
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
Geek of ~ HTML/CSS/Javascript/SQL/Perl/PHP/Python*/Apache/Linux

* = I'm getting there!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: raise or not to raise [Newbie]

2007-02-04 Thread Bruno Desthuilliers
Jacol a écrit :
> I understand that author generated exception and than extracted the name of
> function from the exeption. But is any sens in using exeptions service if
> we have smthing simpler: just print for example? In my opinion no, it
> doesn't make sens.

You're of course right. Exceptions are mainly a way of handling 
'exceptional' conditions without cluttering the source code with error 
code checking. The canonical use case is:

try:
   some_call_that_may_raise(args)
except SomeException, e:
   try_to_solve_the_problem()

The nice thing with exceptions (compared to 'manual' error handling) is 
that you can choose where you want to handle the problem without having 
to pass back error code/error message all along the call stack...


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


Re: Definitions of editor and IDE?

2007-02-04 Thread Bruno Desthuilliers
Necmettin Begiter a écrit :
> 04 Şub 2007 Paz 00:48 tarihinde, Dick Moores şunları yazmıştı: 
> 
>> Are there generally accepted definitions of "editor" and "IDE". Is there a
>>clear-cut distinction between them? I've been looking at the lists of each
>>at python.org, < http://wiki.python.org/moin/PythonEditors>  and <
>>http://wiki.python.org/moin/IntegratedDevelopmentEnvironments>. Many
>>programs are on both lists: Komodo, Eclipse, jedit, SPE, Wing IDE, UliPad,
>>etc.
>>
>> Dick Moores
> 
> Can't give definitions, but here is the difference: if you use an editor, you 
> will have to run your script or program from outside the editor; if you use 
> an IDE, you will press a key or key combination in the IDE (say F9 or F5) and 
> your program/script will run...

In which case Emacs is an IDE - while it's usually descibed as an editor...


IDE stands for "Integrated Development Environment". Since one of the 
central tasks in development is editing code, IDEs are usually built 
around the editor.

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

Re: Learning to program in Python

2007-02-04 Thread Paul Rubin
"jbchua" <[EMAIL PROTECTED]> writes:
> I am an Electrical Engineering major and have dabbled in several
> languages such as Python, C, and Java in my spare time because of my
> interest in programming. However, I have not done any practical
> programming because I have no idea where to get started. I taught
> myself these languages basically by e-tutorials and books. This makes
> me feel as if I don't really know how to implement these languages.
> Does anybody have any advice on where to start applying my limited
> knowledge practically in order to advance my learning?

Try http://www.diveintopython.org .

If you want something more academic about programming in general, try
 http://mitpress.mit.edu/sicp/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pyYaml community

2007-02-04 Thread kwatch
you should subscribe yaml-core mailing list.
mailto:[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/yaml-core
this is what you want.

--
kwatch

 Imbaud Pierre <[EMAIL PROTECTED]> wrote:
> I began using pyYaml.
> I found no place where pyYaml users exchange ideas, know-how, etc
> (as here for python).
> There is a wiki, a bug tracker, documentation, but such a place
> (mailing list, newsgroup, forum, or even IRC) is a must (IMHO) to smooth
> the learning curve.
> Does someone know better?
>
> My concern: yaml allows "complex data" as keys to dicts.
> I need tuples as keys, pyYaml turns my yaml sequences into lists,
> and then yells list cant be used as keys. No way to turn my yaml
> sequences into tuples?
> Oh, I found! RTFM, as usual!
> (the first question sticks)


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


Re: PYTHONPATH or any other way to set seachpath (winXP) ?

2007-02-04 Thread Stef Mientki

> Just a note, If you run the module from different location, it may not 
> always work.
> 
> The '..' is relative to the location you are running the module from, 
> the current directory, and not relative to the location of the module is 
> at.
thanks for the tip Ron,
I didn't realized ".." was literal ;-)
so I've changed my application, so it inserts the absolute path.

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


Re: result of os.times() is different with 'time' command

2007-02-04 Thread kwatch
Thank you, aspineux and Douglas.

Douglas's analysis is especially great.
I changed HZ to CLK_TCK in Python-2.5/Modules/posixmodule.c and
got the proper result!

  
  $ time /usr/local/python2.5/bin/python ostimetest.rb
  n=35, v=14930352
  utime=12.42, stime=0.04

  real0m13.621s
  user0m12.438s
  sys 0m0.063s
  

Great job, Douglas.

--
regards,
kwatch


[EMAIL PROTECTED] (Douglas Wells) wrote:
> [various posting problems corrected and response interspersed in
> previous post for purposes of coherent response]
>
> In article <[EMAIL PROTECTED]>,
>
>
>
> "aspineux" <[EMAIL PROTECTED]> writes:
> > On 2 Feb, 19:30, [EMAIL PROTECTED] wrote:
> > > Hi,
>
> > > I have a question about os.times().
> > > os.times() returns a tuple containing user time and system time,
> > > but it is not matched to the result of 'time' command.
> > > For example, os.times() reports that user time is 39.85 sec,
> > > but 'time' command reports that user time is 28.55sec.
> > > (machine: Python2.5, MacOS X 10.4 Tiger, MacBook 1.83GHz intel core
> > > duo)
>
> > >   [ source elided ]
>
> > I dont see anything wrong !
> > Did you try to measure time with your watch ?
> > Did you try a simple python test.py without the time command ?
> > Maybe python is 'disturbed' by the intel core
>
> > can you try this ?
>
> > # strace python test.py  2>&1 | grep time
> > times({tms_utime=1, tms_stime=1, tms_cutime=0, tms_cstime=0}) =
> > 43021
> > times({tms_utime=2238, tms_stime=2, tms_cutime=0, tms_cstime=0})  = 
> > 430220049
> > write(1, "n=35, v=14930352\nutime=22.37, st"..., 41n=35, v=14930 52
> > utime=22.37, stime=0.01
>
> Note that this likely won't work.  First, strace is not native to
> OS X; ktrace is the analogous native command.  Second, OS X almost
> certainly implements the times system call in terms of getrusage.
>
>
>
> > >   Result:
> > >   
> > >   $ python -V
> > >   Python 2.5
> > >   $ time python ostimetest.py
> > >   n=35, v=14930352
> > >   utime=39.85, stime=0.2167
> > >   real0m28.554suser0m23.938ssys 0m0.177s
> > >   
>
> > > This shows that os.times() reports that user time is 39.85sec,
> > > but time command shows that user time is 23.938sec.
> > > Why os.times() reports wrong result? Do I have any mistake?
>
> > > --
> > > kwatch
>
> Yes, I can reproduce this on my FreeBSD system.  No, I do not believe
> that you have made a mistake.  Yes, I believe that you have uncovered
> a bug in the Python os/posix modules.
>
> Here's my analysis (although I should note that I've not looked
> at the source of Python previously).  I'm looking at Python 2.4.3,
> but this looks like a long existing bug:
>
> The following code exists in the source code module
> Modules/posixmodule.c @ posix_times:
> struct tms t;
> clock_t c;
> [ ... ]
> c = times(&t);
> [ ... ]
> return Py_BuildValue("d",
>  (double)t.tms_utime / HZ,
>  (double)t.tms_stime / HZ,
>  (double)t.tms_cutime / HZ,
>  (double)t.tms_cstime / HZ,
>  (double)c / HZ);
> This is incorrect.  It should not be dividing by HZ, but by the
> result of the dynamic value 'sysconf (_SC_CLK_TCK)'.  Even if
> it were to use a compile time value, the proper value would be
> CLK_TCK, not HZ.
>
> So here's what's happening.  Neither my FreeBSD nor the OP's Mac
> defines HZ as a compile time variable, but the same source module
> also contains the following code:
> #ifndef HZ
> #define HZ 60 /* Universal constant :-) */
> #endif /* HZ */
> So, the Python posix module is using 60 instead of the proper
> value, which happens to be 128 on my FreeBSD, and 100 on the OP's
> OS X(*).  (BTW, this sort of historic code is exactly why POSIX
> no longer defines HZ.)
>
> In support of this, I note that the following ratios exist:
>   user time from os.times / user time from time command
> 39.85 / 23.938 => 1.665
>   CLK_TCK / HZ
>   100 / 60 => 1.667
> which are in reasonably close agreement!
>
>  - dmw
>
> [*] I've actually only looked at OS X for the PPC platform, not
> for the User's Intel platform, but I'm fairly certain that the
> CLK_TCK value is the same on both.
>
> --
> .   Douglas Wells .  Connection Technologies  .
> .   Internet:  -sp9804- -at - contek.com- .


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


Re: "Subscribing" to topics?

2007-02-04 Thread Jeffrey Froman
Mizipzor wrote:

> I discovered that Google has a free newsserver, so I
> joined this group from there. Sadly, I cant see a feature here that
> lets me subscribe to an individual topic, so if anyone else is using
> Google groups and know how to do something like this, please tell
> me.

I don't know about Google Groups, but you may be able to accomplish what you
want to do with "filters" provided by your newsreader software.


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


Re: Learning to program in Python

2007-02-04 Thread Steve Holden
jbchua wrote:
> John Henry wrote:
>> jbchua wrote:
>>> Hello everybody.
>>>
>>> I am an Electrical Engineering major and have dabbled in several
>>> languages such as Python, C, and Java in my spare time because of my
>>> interest in programming. However, I have not done any practical
>>> programming because I have no idea where to get started. I taught
>>> myself these languages basically by e-tutorials and books. This makes
>>> me feel as if I don't really know how to implement these languages.
>>> Does anybody have any advice on where to start applying my limited
>>> knowledge practically in order to advance my learning?
>> Which area of EE are you in?  Or just starting on that as well?
>>
>> If you're just starting, chanllege yourself to build a R mesh and
>> calculate the Thevenin equivalent looking out from a particular node.
>> Then you can expand that to an RLC network.
>>
>> Besure to use Objects, think in terms of objects, and code in objects.
>>  Don't hard code the data type.  You'll be able to see how magical the
>> Duck Typing is in Python.
>>
>> Have fun.
> 
> I'm a freshman-- I have yet to take any actual EE classes. I am
> actually thinking of maybe changing my focus towards Computer Science
> or at least minoring in it.
> 
> To be perfectly honest, I have no idea what you just asked me to do ;\
> 
That's an answer that indicates you are likely to learn fast.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
Blog of Note:  http://holdenweb.blogspot.com
See you at PyCon? http://us.pycon.org/TX2007

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


Re: Create a cookie with cookielib

2007-02-04 Thread Alessandro Fachin
John J. Lee wrote:

> Fine, but see my other post -- I think you misunderstand how cookies
> work.

Maybe you misunderstand me... While i wrote "cookie are simply http
header :)" i want to said that i've look at wrong thing, cookielib are not
needed... Anyway thank you for help, regards.

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


Re: PYTHONPATH or any other way to set seachpath (winXP) ?

2007-02-04 Thread Ron Adam
Stef Mientki wrote:
>> Do you mean something like that?
>>
> import some_module
>> Traceback (most recent call last):
>>   File "", line 1, in ?
>> ImportError: No module named some_module
> import sys
> sys.path.append("..")
> import some_module
> Rob,
> thank you very much,
> that's exactly what I want.
> (Why is the obvious so often invisible to me ;-)
> 
> cheers,
> Stef Mientki

Just a note, If you run the module from different location, it may not always 
work.

The '..' is relative to the location you are running the module from, the 
current directory, and not relative to the location of the module is at.

It won't be a problem for you if you can be sure the module is always ran from 
the location it is at.

Cheers,
Ron

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


Re: It is good to blow up a marketplace full of people buying and selling food

2007-02-04 Thread Jonathan Curran
Frank,
Could you please try and stick to discussing python related subjects on 
this 
mailing list?

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


Re: Python does not play well with others

2007-02-04 Thread Paul Boddie
John Nagle wrote:
>
>  The real problems are with integration of modules that
> aren't written in Python.  Python-only modules don't have the
> version compatibility problems which C modules do.  Loading
> a Python-only module from an external source is usually not
> a big deal.  Building a C module, especially one with
> dependencies on other components, can be a big deal.
> So, focus on problems with modules which have C
> components.

I think that the integration of certain "popular" extensions into the
Python distribution has been one of the tools employed to mitigate the
version compatibility situation: if the popular stuff gets released
with Python, perhaps fewer people will complain about "C modules"
whose developers/maintainers haven't updated them for the latest
release. I'm not really convinced that this makes for a sustainable
approach, however, since this just becomes a process of accretion
where the core development community must get larger and become very
well-coordinated in order to manage the dependencies within the
software, as well as tracking external dependencies.

Over the years there have been suggestions which might have made the
compatibility situation a bit better: a "Python in a tie" release was
an objective of the seemingly dormant Python Business Foundation;
Linux Standard Base inclusion of Python has been proposed and
discussed. I can't help feeling that without improvements in such
other areas, things like "C module" availability for different Python
versions (and for different versions of related libraries) is mainly
an issue of doing the almost thankless hard work of backporting,
testing and managing different build configurations. Still, there may
be demand for a backports community in all this.

Paul

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


nokia s60 python code debugging with komodo

2007-02-04 Thread worlman385
anyway I can setup and debug nokia s60 python in komodo ( a python IDE
)?

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


Re: "Subscribing" to topics?

2007-02-04 Thread Mizipzor
On Feb 4, 10:51 am, hg <[EMAIL PROTECTED]> wrote:
> Mizipzor wrote:
> > Is there a way to "subscribe" to individual topics? im currently
> > getting bombarded with daily digests and i wish to only receive a mail
> > when there is activity in a topic that interests me. Can this be done?
>
> > Thanks in advance.
>
> Use a news reader and leave the mailing list
>
> hg

I searhed around a little and it seems that not only do i need a
newsreader, i need a newsserver to. To fetch all the messages from
here. I learned that sometimes the ISP provides one, however, mine do
not. But then I discovered that Google has a free newsserver, so I
joined this group from there. Sadly, I cant see a feature here that
lets me subscribe to an individual topic, so if anyone else is using
Google groups and know how to do something like this, please tell
me. :)

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


It is good to blow up a marketplace full of people buying and selling food

2007-02-04 Thread Frank Arthur
It is good to blow up a marketplace full of people buying and selling food
in Iraq.
This is how Muslim insurgents will drive "the enemy" out of their country.
By killing and maiming fellow Iraqis! The traditional Muslim way.
The way of Allah! The way of the Quaran! The way of Mohammed!
They don't need any democracy. They don't need free elections. They are true
believers!

Suicide truck bomber kills at least 130 in Baghdad
By Tina Susman, Times Staff Writer
11:23 AM PST, February 3, 2007


BAGHDAD -- A suicide bomber posing as a trucker hauling food drove into a
busy market in central Baghdad today and blew himself up, killing at least
130 people, injuring more than 300, and capping a particularly volatile day
in Iraq's sectarian war.

Seven car bombs also tore through the northern city of Kirkuk, leaving two
dead in attacks that underscored tensions enveloping the oil-rich region as
Arabs and Kurds vie for power. Another person died south of Baghdad in a
separate car bombing.


The incidents illustrated the breadth of polarization plaguing Iraq as U.S.
and Iraqi officials prepare for what they vow will be a decisive crackdown
on insurgents.

The Interior Ministry said the blast in the market in Sadriya killed at
least 130 people and injured 305. It came in the early evening as shoppers
thronged the stalls and tiny shops to stock up for the evening meal. Hamed
Majed, a butcher, was tending to customers when he saw a large yellow truck
trying to navigate down the narrow, alley-like street leading through the
market.


<[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> First the tiny hezbollah destroyed merkevas one after another using
> precision anti-tank weapons reducing the israelis to madness of
> indiscriminate cluster bombing.
>
> But the Iranians are the smartest of these Islamics. Grand chess
> masters ... who once saved the ass of jews under Cyrus the Great from
> Nebuchadnezzer
>
> =
>
> Open house at Iranian nuclear site
>
> Isfahan, Iran
> February 5, 2007
> AdvertisementAdvertisement
>
> Iran has opened one of its nuclear sites to local and international
> reporters and ambassadors to show the transparency of its program
> before a UN Security Council deadline this month.
>
> Tehran has kept up efforts to give the site at Isfahan more publicity.
> A tourism official said late last year that Iran planned to open it
> and other nuclear plants to foreign tourists.
>
> Iran's ambassador to the International Atomic Energy Agency, Ali
> Asghar Soltanieh, said the purpose of the tour was to assure the world
> that Iran's program was peaceful.
>
> "In fact we have representatives from all over the world," Mr
> Soltanieh said. "We decided to have them come here and see for
> themselves," he said.
>
> He made a point of emphasising the IAEA surveillance cameras at
> Isfahan.
>
> Photographers and video camera operators were not allowed to take
> pictures in the outside area of the compound.
>
> Uranium ore is converted into yellowcake and gas at Isfahan. The gas
> is transferred to the more sophisticated plant at Natanz, where it
> could be enriched with centrifuges.
>
> Reporters at the weekend passed the Natanz site but were not allowed
> inside, where Iran recently said it was installing 3000 centrifuges.
>
> NEW YORK TIMES
> 


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


Re: Recursive zipping of Directories in Windows

2007-02-04 Thread Jandre
On Feb 1, 9:39 pm, Larry Bates <[EMAIL PROTECTED]> wrote:
> Jandre wrote:
> > Hi
>
> > I am a python novice and I am trying to write a python script (most of
> > the code is borrowed) to Zip a directory containing some other
> > directories and files. The script zips all the files fine but when it
> > tries to zip one of the directories it fails with the following
> > error:
> > "IOError: [Errno 13] Permission denied: 'c:\\aaa\\temp'"
>
> > The script I am using is:
>
> > import zipfile, os
>
> > def toZip( directory, zipFile ):
> > """Sample for storing directory to a ZipFile"""
> > z = zipfile.ZipFile(
> > zipFile, 'w', compression=zipfile.ZIP_DEFLATED
> > )
> > def walker( zip, directory, files, root=directory ):
> > for file in files:
> > file = os.path.join( directory, file )
> > # yes, the +1 is hacky...
> > archiveName = file[len(os.path.commonprefix( (root,
> > file) ))+1:]
> > zip.write( file, archiveName, zipfile.ZIP_DEFLATED )
> > print file
> > os.path.walk( directory, walker, z  )
> > z.close()
> > return zipFile
>
> > if __name__ == "__main__":
> > toZip( 'c:\\aaa', 'c:\\aaa\\test.zip' )
>
> > I have tried to set the permissions on the folder, but when I check
> > the directory permissions it is set back to "Read Only"
>
> > Any suggestions?
>
> > Thanks
> > Johan Balt
>
> Couple of quick suggestions that may help:
>
> 1) don't use 'file' as a variable name. It will mask
> the builtin file function.  If it hasn't bitten you before
> it will if you keep doing that.
>
> 2) If you put the target .zip file in the directory you are
> backing what do you expect the program to do when it comes
> to the file you are creating as you walk the directory?  You
> haven't done anything to 'skip' it.
>
> 3) Your commonprefix and +1 appears to result in same
> information that the easier to use os.path.basename()
> would give you.  Double check me on that.
>
> I don't see anything that references C:\\aaa\temp in your
> code.  Does it exist on your hard drive?  If so does it
> maybe contain temp files that are open?  zipfile module
> can't handle open files.  You must use try/except to
> catch these errors.
>
> Hope info helps.
>
> -Larry

Thank you Larry.
I've changed the code as epr your advice. The code is now:

import zipfile, os

def toZip( directory, zipFile ):
"""Sample for storing directory to a ZipFile"""
z = zipfile.ZipFile(
zipFile, 'w', compression=zipfile.ZIP_DEFLATED
)
def walker( zip, directory, files, root=directory ):
for f in files:
f = os.path.join( directory, f )
archiveName = os.path.basename(f)
zip.write( f, archiveName, zipfile.ZIP_DEFLATED )
print f
os.path.walk( directory, walker, z  )
z.close()
return zipFile


if __name__ == "__main__":
toZip( 'c:\\aaa\\', 'c:\\bbb\\test.zip' )

I still get the same error:
Traceback (most recent call last):
  File "C:\Python24\Lib\site-packages\pythonwin\pywin\framework
\scriptutils.py", line 310, in RunScript
exec codeObject in __main__.__dict__
  File "C:\Python24\Scripts\dirZip.py", line 20, in ?
toZip( 'c:\\aaa\\', 'c:\\bbb\\test.zip' )
  File "C:\Python24\Scripts\dirZip.py", line 14, in toZip
os.path.walk( directory, walker, z  )
  File "C:\Python24\lib\ntpath.py", line 329, in walk
func(arg, top, names)
  File "C:\Python24\Scripts\dirZip.py", line 12, in walker
zip.write( f, archiveName, zipfile.ZIP_DEFLATED )
  File "C:\Python24\lib\zipfile.py", line 405, in write
fp = open(filename, "rb")
IOError: [Errno 13] Permission denied: 'c:\\aaa\\temp'

c:\\aaa\\temp is a directory in the directory I an trying to zip. I
want to use this script to back up my work once a day and would like
to
keep the directory structure as is. I can zip the files in c:\aaa\tem
fine so I guess that there aren't any open files in the directory.
Any more ideas?

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


Re: Create a cookie with cookielib

2007-02-04 Thread John J. Lee
Alessandro Fachin <[EMAIL PROTECTED]> writes:

> Matthew Franz wrote:
> 
> > I'm not sure what you mean be forge, but if you mean set an arbitrary
> > cookie manually (vs. one that was provided by the server).  just use
> > add_header() in http://docs.python.org/lib/request-objects.html
> 
> Yes is exactly what i want to do... i don't known because i looked at

No, you don't ;-)

> cookielib to set cookie data, cookie are simply http header :) Inserting
> values with add_header() or addheaders() it works. Thank you

Fine, but see my other post -- I think you misunderstand how cookies
work.


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


Re: Python does not play well with others

2007-02-04 Thread John Nagle
Paul Boddie wrote:
> I was really advocating improvements to the built-in SSL support,
> anyway, which was also what the complainant was suggesting before
> people started asking him mistakenly why he thought that Python was
> weakened by some third party packages (PyOpenSSL, M2Crypto). 

 The real problems are with integration of modules that
aren't written in Python.  Python-only modules don't have the
version compatibility problems which C modules do.  Loading
a Python-only module from an external source is usually not
a big deal.  Building a C module, especially one with
dependencies on other components, can be a big deal.
So, focus on problems with modules which have C
components.

John Nagle

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


Re: Create a cookie with cookielib

2007-02-04 Thread John J. Lee
"Matthew Franz" <[EMAIL PROTECTED]> writes:

> I'm not sure what you mean be forge, but if you mean set an arbitrary
> cookie manually (vs. one that was provided by the server).  just use
> add_header() in http://docs.python.org/lib/request-objects.html
> 
> It may be possible to use CookieJar for this purpose but I've only
> used it for manipulating cookies set by the server...
> 
> And  I would agree that Python cookie APIs are less intuitive than
> what are available in others such as Jakarta HttpClient

There's not really intended to *be* an API, for most purposes -- you
just let it do its stuff.

What do you like from HttpClient?


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


Re: Python does not play well with others

2007-02-04 Thread Colin J. Williams
Paul Rubin wrote:
> "George Sakkis" <[EMAIL PROTECTED]> writes:
>>> What does "batteries included" mean to you?  To me, it means you don't
>>> have to install add-ons.
>> So let's make a 500MB executable and add Numpy, Zope, Django, PIL,
>> pretty much everything actually. Even better, make CheeseShop just a
>> frontend to a build system that adds and updates automatically
>> submitted packages to the core. Problem solved ! .
> 
> Numpy should certainly be included and I think there are efforts in
> that direction.  
As I understand it, the effort is directed towards elaborating the 
current array module so that it handles multi-dimensional array.

This would be a good step but numpy os much more and is of minority 
interest and so should probably not, in my opinion, be included in the 
Python core.

Colin W.
There is also a movement to choose a web framework to
> include and Django might be a good choice.  I think the Zope
> maintainers want to keep Zope separate and I think PIL has an
> incompatible license.  I'm not sure what you mean about making
> CheeseShop a front end to a build system, but I certainly don't think
> random user contributions should get added to the core automatically.
> Including a module in the core should carry with it the understanding
> that the module has undergone some reasonable evaluation by the core
> maintainers and is maintained.
> 
> I do think the core should have more stuff than it does, so that its
> functionality can be on a par with competing language distros like
> J2SE and PHP.  Both of those distros include database connectvity
> modules and web frameworks.  It could be that those other packages can
> include more stuff because they have more active developer communities
> and can therefore expend more resources maintaining their libraries.
> But if that's the case, since the Java and PHP languages themselves
> suck compared with Python, we have to ask ourselves why Python has not
> been able to attract similar levels of effort and what it could be
> doing differently.

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


Re: Parameter lists

2007-02-04 Thread Jeffrey Froman
Mizipzor wrote:

> class Stats:
>   def __init__(self, *li):
>   self.speed = li[0]
>   self.maxHp = li[1]
>   (...)
> 
> Or maybe there is an even niftier way that lets me iterate through
> them?

Using keyword arguments instead of positional parameters makes this easy:

>>> class Stats:
... def __init__(self, **kw):
... self.__dict__.update(kw)
... 
>>> stats = Stats(speed=10, maxHp=100, armor='plate mail')
>>> stats.speed
10
>>> stats.maxHp
100
>>> stats.armor
'plate mail'


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


Re: "Subscribing" to topics?

2007-02-04 Thread Stef Mientki
Mizipzor wrote:
> Is there a way to "subscribe" to individual topics? im currently
> getting bombarded with daily digests and i wish to only receive a mail
> when there is activity in a topic that interests me. Can this be done?
> 
> Thanks in advance.

I'm relative new (couple of months),
and although there seems already to be a few different categories,
I see a lot of posts of experienced users,
that completely ignore these differences
(or perhaps I don't understand a bit of it ;-).

[ANN] is this group, I thought we had:
   [EMAIL PROTECTED]
   pycon-announce@python.org
Scipy questions, I thought we had:
   [EMAIL PROTECTED]
Delphi, I thought we had:
   [EMAIL PROTECTED]
Probably there are a number of other groups
(would be nice to have a list of these)

here is the description list that I'm subscribed for many years,
that uses good defined topics
   http://www.piclist.com/techref/piclist/index.htm
It has one major disadvantage for newbies,
if a message without the proper tag arrives,
it is blocked and can be manual added to the list by the moderator.

cheers,
(and sorry for all the stupid newbie posts,
which probably is not of your interest ;-)
Stef Mientki
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: when will python 2.5 take in mainstream?

2007-02-04 Thread Steven Bethard
Eric CHAO wrote:
> A lot of application based on python claim that python 2.3 or 2.4 is
> needed not 2.5, ie. mysqldb. I've been using python for months. I
> don't care about 2.4 or 2.5. But I like the default icons of python in
> 2.5. So I just use that, but some scripts can't work on that.
> 
> When will all these applications support 2.5?

Many applications that require 2.3 or 2.4 work fine in 2.5.  Did you try 
mysqldb and have it fail?

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


[ANN] ConfigObj 4.4.0 and Validate 0.2.3

2007-02-04 Thread Fuzzyman
Updated versions of both `ConfigObj `_ and `Validate `_ are now available.

* `ConfigObj 4.4.0 `_
* `Validate 0.2.3 `_

**ConfigObj** is a Python module for the simple reading and writing of
config files. It has many features, whilst remaining easy to use.

With the assistance of **Validate** it can validate a config file
against a specification, and convert members to the expected type.

Thanks to Nicola Larosa who implemented most of the fixes in this
release.


What is New in ConfigObj 4.4.0?
===

* Made the import of compiler conditional so that ConfigObj can be
used with IronPython.

* Fix for Python 2.5 compatibilities.

* String interpolation will now check the current section before
checking DEFAULT sections. Based on a patch by Robin Munn.

* Added Template-style interpolation, with tests, based on a patch by
Robin Munn.

* Allowed arbitrary indentation in the ``indent_type`` parameter.

* Fixed Sourceforge bug #1523975 by adding the missing ``self``


What is New in Validate 0.2.3?
==

Fixed validate doc to talk of boolean instead of bool; changed the
``is_bool`` function to ``is_boolean`` (Sourceforge bug #1531525).

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


Iran opens Nuclear Enrichment School, judeo-yank-fascists in defeat

2007-02-04 Thread thermate
First the tiny hezbollah destroyed merkevas one after another using
precision anti-tank weapons reducing the israelis to madness of
indiscriminate cluster bombing.

But the Iranians are the smartest of these Islamics. Grand chess
masters ... who once saved the ass of jews under Cyrus the Great from
Nebuchadnezzer

=

Open house at Iranian nuclear site

Isfahan, Iran
February 5, 2007
AdvertisementAdvertisement

Iran has opened one of its nuclear sites to local and international
reporters and ambassadors to show the transparency of its program
before a UN Security Council deadline this month.

Tehran has kept up efforts to give the site at Isfahan more publicity.
A tourism official said late last year that Iran planned to open it
and other nuclear plants to foreign tourists.

Iran's ambassador to the International Atomic Energy Agency, Ali
Asghar Soltanieh, said the purpose of the tour was to assure the world
that Iran's program was peaceful.

"In fact we have representatives from all over the world," Mr
Soltanieh said. "We decided to have them come here and see for
themselves," he said.

He made a point of emphasising the IAEA surveillance cameras at
Isfahan.

Photographers and video camera operators were not allowed to take
pictures in the outside area of the compound.

Uranium ore is converted into yellowcake and gas at Isfahan. The gas
is transferred to the more sophisticated plant at Natanz, where it
could be enriched with centrifuges.

Reporters at the weekend passed the Natanz site but were not allowed
inside, where Iran recently said it was installing 3000 centrifuges.

NEW YORK TIMES

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


Re: Dividing integers...Convert to float first?

2007-02-04 Thread rzed
"Simon Brunning" <[EMAIL PROTECTED]> wrote in 
news:[EMAIL PROTECTED]:

> On 1/5/07, Grant Edwards <[EMAIL PROTECTED]> wrote:
>>>>> from __future__ import LotteryNumbers
>>  File "", line 1
>>SyntaxError: future feature LotteryNumbers is not defined
>>
>> Damn.
>>
>> I guess it's back to work then.
> 
> Remember the PEP 8 module name standards.
> 
 from __future__ import lottery_numbers
> [1, 16, 19, 20, 21, 39]
> 

My Python version is so old that I only get three numbers. I guess 
I'll have to upgrade.

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


Re: HELP NEEDED ... Regd. Regular expressions PyQt

2007-02-04 Thread [EMAIL PROTECTED]
On Feb 3, 11:40 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
> In <[EMAIL PROTECTED]>, vishal wrote:
> > I am trying to work out a regular expression in a PyQt environment for
> > time in hh:mm:ss format. Any suggestions?
>
> Maybe don't use a re for something that simple.  Splitting at ``:``
> characters, converting to `int` and checking the value ranges isn't that
> hard without a regular expression.
>
> Ciao,
> Marc 'BlackJack' Rintsch

Except that if a full regex is used, the pattern can be matched or
denied and pull out the important information simultaneously. Here's a
simple regex that would work:

(\d{1,2}):(\d{1,2}):(\d{1,2})

but here's one that works only for the 12 hour clock:

((1[012])|(0?\d)):([0-5]?\d):([0-5]?\d)

and one for the 24 hour clock:

((2[0-4])|([01]?\d)):([0-5]?\d):([0-5]?\d)

I hope this helps

--Tim

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


Re: Parameter lists

2007-02-04 Thread rzed
Mizipzor <[EMAIL PROTECTED]> wrote in
news:[EMAIL PROTECTED]: 

> Consider the following snippet of code:
> 
> ==
> 
> class Stats:
> def __init__(self, speed, maxHp, armor, strength,
> attackSpeed, imagePath): 
> self.speed = speed
> self.maxHp = maxHp
> self.armor = armor
> self.strength = strength
> self.attackSpeed = attackSpeed
> self.originalImage = loadTexture(imagePath)
> 
> ==
> 
> I little container for holding the stats for some rpg character
> or something. Now, I dont like the looks of that code, there are
> many function parameters to be sent in and if I were to add an
> attribute, i would need to add it in three places. Add it to the
> function parameters, add it to the class and assign it.
> 
> Is there a smoother way to do this? There usually is in python,
> hehe. I recall when reading python tutorials that you could do
> something like this:
> 
> foo(*list_of_parameters):
> 
> To send many parameters as a list or a tuple. Then I could
> assign them like this:
> 
> class Stats:
> def __init__(self, *li):
> self.speed = li[0]
> self.maxHp = li[1]
> (...)
> 
> Or maybe there is an even niftier way that lets me iterate
> through them? Hmm... but that may lead to that I need to store
> them in a way that makes it cumbersome to access them later.
> 
> Any comments and/or suggestions are welcome!  :)
> 

I often use something like this, based on a Martellibot posting:

>>> class Stats(dict):
... def __init__(self, *args, **kwds):
... self.update(*args)
... self.update(kwds)
... def __setitem__(self, key, value):
... return super(Stats, self).__setitem__(key, value)
... def __getitem__(self, name):
... try:
... return super(Stats, self).__getitem__(name)
... except KeyError:
... return None
... __getattr__ = __getitem__
... __setattr__ = __setitem__
...
>>> m = dict(a=1,b=22,c=(1,2,3))
>>> p = Stats(m,x=4,y=[5,9,11])
>>> p.y
[5, 9, 11]
>>> p['y']
[5, 9, 11]

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


Re: Python does not play well with others

2007-02-04 Thread Paul Boddie
Jorge Godoy wrote:
> "Paul Boddie" <[EMAIL PROTECTED]> writes:
>
> > And while Python eggs may be useful for people managing additional
> > software as some unprivileged user, hosting providers (and virtual
> > private server administrators) will want packages that fit in with the
> > rest of the software being managed in the hosting environment.
>
> And why eggs wouldn't satisfy them?  Eggs can be installed globally as well,
> making the package available to every client of this hosting server (if they
> mount their libs from a unique NFS server then it would automatically be
> available for all of their servers).

Because Python is just another thing to support for various hosting
providers. One of the problems people supposedly have when persuading
such companies to add or update packages is, I imagine, a lack of
familiarity those companies have with Python technologies. Asking them
to use a technology-specific packaging system might be a bit much if
they aren't even familiar with (or interesting in knowing more about)
the packages required to satisfy their customers' basic needs.

Moreover, there's a lot of software in the average GNU/Linux or BSD
distribution, but if you had to "break out" into technology-specific
package/dependency managers to install some of the more heterogeneous
packages, it would be a nightmare: perhaps installing the
documentation would have you visit CPAN for some Perl scripts before
throwing you into the TeX package manager to get some missing TeX
libraries; then you might be off into setuptools for the Python
scripting extensions, possibly via equivalent tools for other
scripting extensions; finally, you'd be off via any other system
thought essential to manage software from a particular parochial
technological viewpoint. I've had to install software like this, and
it takes huge amounts of time for no good reason if you can use system
packages instead.

Paul

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


Re: Parameter lists

2007-02-04 Thread bearophileHUGS
Mizipzor
> I dont like the looks of that code, there are many
> function parameters to be sent in and if I were to add an attribute, i
> would need to add it in three places. Add it to the function
> parameters, add it to the class and assign it.
> Is there a smoother way to do this?

You may use something like this:

def selfassign(self, locals):
# Code from web.py  http://webpy.org  modified.
for key, value in locals.iteritems():
if key != 'self':
setattr(self, key, value)

Generally used in __init__ methods, as:

def __init__(self, foo, bar, baz=1):
selfassign(self, locals())

You may use it as (untested):

class Stats:
def __init__(self, speed, maxHp, armor, strength, attackSpeed,
imagePath):
selfassign(self, locals())
self.originalImage = loadTexture(imagePath)
del self.imagePath

I don't like that del

Bye,
bearophile

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


Re: "Subscribing" to topics?

2007-02-04 Thread hg
Mizipzor wrote:

> Is there a way to "subscribe" to individual topics? im currently
> getting bombarded with daily digests and i wish to only receive a mail
> when there is activity in a topic that interests me. Can this be done?
> 
> Thanks in advance.
Use a news reader and leave the mailing list

hg

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


Parameter lists

2007-02-04 Thread Mizipzor
Consider the following snippet of code:

==

class Stats:
def __init__(self, speed, maxHp, armor, strength, attackSpeed, imagePath):
self.speed = speed
self.maxHp = maxHp
self.armor = armor
self.strength = strength
self.attackSpeed = attackSpeed
self.originalImage = loadTexture(imagePath)

==

I little container for holding the stats for some rpg character or
something. Now, I dont like the looks of that code, there are many
function parameters to be sent in and if I were to add an attribute, i
would need to add it in three places. Add it to the function
parameters, add it to the class and assign it.

Is there a smoother way to do this? There usually is in python, hehe.
I recall when reading python tutorials that you could do something
like this:

foo(*list_of_parameters):

To send many parameters as a list or a tuple. Then I could assign them
like this:

class Stats:
def __init__(self, *li):
self.speed = li[0]
self.maxHp = li[1]
(...)

Or maybe there is an even niftier way that lets me iterate through
them? Hmm... but that may lead to that I need to store them in a way
that makes it cumbersome to access them later.

Any comments and/or suggestions are welcome!  :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: parent-child object design question

2007-02-04 Thread Steven D'Aprano
On Fri, 02 Feb 2007 13:53:21 -0800, manstey wrote:

> Hi,
> 
> There was a mistake above, and then I'll explain what we're doing:
 insCacheClass = CacheClass(oref)
 insCacheProperty = CacheProperty(insOref,'Chapter')
> 
> should have been
 insCacheClass = CacheClass(oref)
 insCacheProperty = CacheProperty(insCacheClass ,'Chapter')
> 
> Now, to answer some questions.
> 1. Cache refers to Intersystems Cache database, an powerful oo dbase
> that holds our data.
> 2. It comes with a pythonbinding, but unfortunatley the API, written
> in C as a python extension, only provides old-style classes, which is
> why we wrap the oref (an in-memory instance of a Cache class/table)
> with CacheClass. This allows us to add attributes and methods to the
> CacheClass, the most important being CacheProperty, which is a class
> corresponding to the Cache property/field classes of the dbase.

You can add attributes and methods to old-style classes.


> 3. The pythonbind also has a strange behaviour, to our view. It gets
> and sets values of its properties (which are classes), 

Are you sure you're using the word "classes" correctly? That seems ...
strange. I'm wondering whether the properties are class _instances_.


> via the
> 'parent' oref, i.e. oref.set('Name','Peter'). But we want a pythonic
> way to interact with Cache, such as, insCacheClass.Name='Peter'. and
> insOref.Name.Set().

Okay, let me see that I understand what happens. Here's some pseudo-code
of what I think you are currently doing:


oref = get_a_reference_to_Cache_database()  # or whatever
# now do work on it using the python bindings.
oref.set("Name", "Peter")
oref.set("Something", "Else")


Here's a wrapper for the bindings, so they work more pythonically:

class Oref_Wrapper(object):
def __init__(self, oref):
self._oref = oref  # save the oref for later use
# Delegate attribute access to the oref
def __setattr__(self, name, value):
return self._oref.set(name, value)
def __getattr__(self, name):
return self._oref.get(name)  # or whatever the oref does
def __delattr__(self, name):
return self._oref.del(name)  # or whatever the oref does


This is how you use it:


oref = get_a_reference_to_Cache_database()  # or whatever
# re-bind the name to a wrapped version
oref = Oref_Wrapper(oref)
# now do work on it
oref.Name = "Peter"
oref.Something = "Else"


> The code above (in post 7) does this, but as I
> asked, by storing the parent instance (insCacheClass) inside each of
> its attributes (insCacheProperty1,2, etc).

Do you use insCacheClass and insCacheProperty for anything other than
making the bindings more Pythonic? Because for the life of me I can't work
out what they're supposed to do!


> 4. Another reason we want a new-style class wrapped around the oref,
> is that each oref has many methods on the server-side Cache database,
> but they are all called the same way, namely,
> oref.run_obj_method('%METHODNAME',[lisArgs]). We want to call these in
> python in the much better insCacheClass.METHODNAME(Args). E.g. we
> prefer insCacheClass.Save() to oref.run_obj_method('%Save',[None]).

Using my code above, oref.METHODNAME(args) would resolve to:

oref._oref.get("METHODNAME")(args)

which may not do what you want. 

If you know all the possible METHODNAMES, then that's easy enough to fix:
create methods at runtime. (If you don't know the methods, the problem
becomes too hard for me to work out at 3am, but will probably still be
solvable.)

Change the __init__ method above to something like this (untested):

import new

class Oref_Wrapper(object):
def __init__(self, oref):
self._oref = oref  # save the oref for later use
METHODNAMES = ["Save", "Clear", "Something"]
for name in METHODNAMES:
function = lambda self, *args: \
self._oref.run_obj_method("%"+name, args)
method = new.instancemethod(function, name)
self.__dict__[name] = method

then define the __getattr__ etc. methods as before, and (hopefully!) you
are done:

oref.Save()
oref.Clear(1, 2, 3, 7)



I hope this was of some help.



-- 
Steven.

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


"Subscribing" to topics?

2007-02-04 Thread Mizipzor
Is there a way to "subscribe" to individual topics? im currently
getting bombarded with daily digests and i wish to only receive a mail
when there is activity in a topic that interests me. Can this be done?

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


Re: Python does not play well with others

2007-02-04 Thread Ramon Diaz-Uriarte
I find Paul Rubin's arguments compelling and convincing. As just a
Python user (i.e., someone who has contributed nothing) let me add a
few comments along the same lines.

On 03 Feb 2007 18:31:03 -0800, Paul Rubin
<"http://phr.cx"@nospam.invalid> wrote:
> [EMAIL PROTECTED] writes:
> > Paul> Why would I expect your employer to solve my problems anyway, even
> > Paul> if they relate to some module that you actually use?
> >
> > Your reasoning seems to be that Python should contain the functional union
> > of everything at least in Java and PHP if not Perl, Ruby and Tcl as well.
>
> I wouldn't go quite that far.  I think there are specific application
> areas, such as web server apps, where the Python advocates here on
> clpy pitch Python relentlessly against those other languages.  Given
> that context, Python's stdlib should try to match the libraries of
> those other languages in those areas.  There are other areas where
> Python doesn't get pitched as hard and the other languages have
> acknowledged advantages.  So it's ok if Python's stdlib gets less
> attention in those areas.
>

In fact, it is quite frustrating to operate under the impression that
"Python is good for X, Y, Z, " and then realize "ooops, it is
becoming a pain in the ass to do X, whereas language L does X just
fine". It seems to me that Python advocates sometimes (often?) get
carried away. DB "sure, no problem"; web-frameworks "who needs Rails,
we have (lots of) frameworks that do it"; functional programming
"Python can do all the functional programming anyone in his/her mind
should ever try to do"; etc.

Compare this to the, in my opinion, equanimous, fair, "advertisement"
one finds in the Erlang page or the recognition by schemers that
scheme is not the only game in town.


>
> > If you want to turn the Python distribution into a kitchen sink,
> > make the argument on python-dev and be prepared to shoulder your
> > share of the burden should your arguments sway the group as a whole.
>
> We've had this conversation before and I continue to think your
> reasoning above is invalid.  I'm not a Python developer, I'm just a
> user, and my volunteer coding priorities are elsewhere, as I've
> explained before.  Python's developers and advocates have a declared
> goal of reaching as many users as they can, and as a user I don't mind
> offering suggestions about how to do that, but my responsibilities
> don't go any further.



R.


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


-- 
Ramon Diaz-Uriarte
Statistical Computing Team
Structural Biology and Biocomputing Programme
Spanish National Cancer Centre (CNIO)
http://ligarto.org/rdiaz
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Definitions of editor and IDE?

2007-02-04 Thread Kirk Sluder
In article <[EMAIL PROTECTED]>,
 "Paddy" <[EMAIL PROTECTED]> wrote:

> On Feb 4, 9:01 am, Necmettin Begiter <[EMAIL PROTECTED]>
> wrote:
> > Can't give definitions, but here is the difference: if you use an editor, 
> > you
> > will have to run your script or program from outside the editor; if you use
> > an IDE, you will press a key or key combination in the IDE (say F9 or F5) 
> > and
> > your program/script will run...
> 
> Hmm, is vim an editor or an IDE?
> By the above definition it would be an IDE because under the tools
> menu you can run make or compilers/interpreters.
> It has probably got to the stage that its a continuum from something
> like Eclipse or SPE that are definitely IDE's through to ed and
> notepad which are editors.

I would define an IDE as a system that supports multiple tasks of 
the development process using a related set of interfaces.  Some of 
these tasks may include:

Searching and browsing reference documentation.
Writing source code.
Building/compiling projects. 
Evaluation using a shell or REPL.
Debugging and testing.
Production of graphical elements.
Production of documentation.
Packaging.
Project management and version tracking.

I'll agree that it's a spectrum with the most comprehensive IDEs 
supporting more different tasks of the development process.  

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


Re: Dlaczego ten destruktor nie dziala

2007-02-04 Thread Sulsa
sorry, wrong group.
-- 
http://mail.python.org/mailman/listinfo/python-list


Dlaczego ten destruktor nie dziala

2007-02-04 Thread Sulsa
Mam klase A po ktorej dziedziczy B i jesli w destruktorze klasy B
wywolam:
self.__class__.__bases__[0].__del__(self)

to wszytkos jest ok, i destruktor klasy a jest wywolywany, jesli
natomiast napisze: A.__del__(self)  to otrzymuje nastepujacy wyjatek: 
Exception exceptions.AttributeError: "'NoneType' object has no
attribute '__del__'" in > ignored

czemu tak sie dzieje?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python does not play well with others

2007-02-04 Thread Kirk Sluder
In article <[EMAIL PROTECTED]>,
 "Paul Boddie" <[EMAIL PROTECTED]> wrote:

> Would it benefit the Python community more if Python shipped with
> MySQL support out of the box? Is it likely that a user suddenly finds
> him/herself needing to connect to a MySQL database? 

The other problem is that it chains the python release schedule to 
that of MySQL AB (and postgresql, and whatever.)  One of the key 
advantages to independent modules is that I don't need to update my 
entire python system every time my database vendor releases a new 
library, nor do I have to accept lag time as the module is tested 
and rolled into the base distribution.  Database client libraries 
are much more of a moving target than core language features.

I find it interesting that PHP struggled with these issues and 
decided to abandon embedded MySQL support partly because they 
couldn't maintain their own parallel versions of the client 
libraries.
  
http://us2.php.net/manual/en/faq.databases.php#faq.databases.mysql.ph
p5

Among the other problems faced by both PHP and Python in bundling 
MySQL support is that they can't legally do it without adopting the 
GPL.  

Which leaves me wondering why the python core should adopt a feature 
that was abandoned by PHP, and was never highly recommended or used?

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


Re: Python does not play well with others

2007-02-04 Thread Jorge Godoy
"Paul Boddie" <[EMAIL PROTECTED]> writes:

> And while Python eggs may be useful for people managing additional
> software as some unprivileged user, hosting providers (and virtual
> private server administrators) will want packages that fit in with the
> rest of the software being managed in the hosting environment.

And why eggs wouldn't satisfy them?  Eggs can be installed globally as well,
making the package available to every client of this hosting server (if they
mount their libs from a unique NFS server then it would automatically be
available for all of their servers).  

-- 
Jorge Godoy  <[EMAIL PROTECTED]>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python does not play well with others

2007-02-04 Thread Paul Boddie
Paul Rubin wrote:
> "Paul Boddie" <[EMAIL PROTECTED]> writes:
> > Python should only incorporate functionality in order to offer a
> > coherent experience (where the omission of functionality would
> > otherwise lead to a flawed experience). For example, having support
> > for SSL in the socket module offers a coherent experience because it
> > means that urllib and related modules can offer to support SSL-related
> > URLs out of the box.
>
> But they can't, because the built-in socket module SSL interface
> doesn't check certificates, causing total security failure if someone
> spoofs the remote site.  The built-in SSL functionality is broken and
> users have to resort to external packages.

I was really advocating improvements to the built-in SSL support,
anyway, which was also what the complainant was suggesting before
people started asking him mistakenly why he thought that Python was
weakened by some third party packages (PyOpenSSL, M2Crypto). The
choice here involves either improving the built-in support or
unbundling SSL-based communications altogether. The former option
obviously demands a certain amount of engineering, and then one might
ask why there isn't a convenient framework for plugging in other
flavours of sockets, for example, although there arguably aren't any
as generally important as secure sockets. The latter option needs
everyone to think about how you'd plug such stuff back into Python in
a nice enough way, and then to get people to work on the right
projects to provide something which does the job.

> Then you have to ask why the stdlib includes anything like urllib in
> the first place, under this "coherent experience" concept (I interpret
> that as some kind of minimalist philosophy).  Can't users have a
> coherent experience if the stdlib doesn't include urllib?  My own
> answer is the one that I thought that the developers had settled on
> years ago, namely "batteries included", i.e. ship a rich set of
> libraries that provide a wide variety of useful functions, i.e. the
> doctrine of minimalism has been explicitly rejected.

Really, we have to ask whether including the batteries would save
people a lot of work, not just in whether the end-user has to find out
about an external package and then download something, but whether the
logistics around developing the code, integrating it with Python, and
maintaining it would be easier if people just included the stuff with
Python. Here, you need some kind of consensus that feature X needs
supporting and there's an approved way of supporting it which a group
of people would be happy to maintain. Would it benefit the Python
community (including core developers) more if Python shipped with SSL
support out of the box, and would the cost of doing so ultimately be
less than just pointing people at third party libraries and dealing
with their problems?

>  We then get the question of whether to include any specific function and 
> that's where
> comparisons with other languages come in.

Would it benefit the Python community more if Python shipped with
MySQL support out of the box? Is it likely that a user suddenly finds
him/herself needing to connect to a MySQL database? Is it more likely
that the user might suddenly find him/herself needing to download from
a secure site, particularly if some tool (eg. setuptools) suddenly
stumbles across an https URL. Some database systems have a choice of
drivers/libraries/modules (PostgreSQL has quite a few, for example):
choosing a module for standard library inclusion and integrating the
development can be too high a barrier for such questions of inclusion
to be resolved trivially.

[...]

> > So, for the less forward-thinking providers a metapackage would be the
> > solution, then?
>
> I'm not sure what you mean by metapackage but in general the goal is
> to minimize the number of places that the hosting provider (or OS
> distro maintainer, or whatever)

On various distributions you get packages which don't actually contain
anything, but which indicate a suite of packages which are to be
installed. So, if you install the ubuntu-desktop package on Ubuntu
systems, you get the GNOME desktop environment and all the
dependencies (and a bunch of other stuff). Perhaps there should be a
python-mysql-hosting package for such providers.

Paul

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


Re: Python does not play well with others

2007-02-04 Thread Paul Boddie
Kirk Sluder wrote:
> In article <[EMAIL PROTECTED]>,
>  "Paul Boddie" <[EMAIL PROTECTED]> wrote:
>
> > Quite. I imagine that most GNU/Linux distributions (and various BSDs)
> > provide at least some version of MySQLdb as a package.
>
> Bingo, I've rarely installed python from python.org, or other
> libraries from sourceforge, etc., etc.. Usually I've installed
> BSD-style ports, debian-style packages, or RedHat-style RPMs.

And while Python eggs may be useful for people managing additional
software as some unprivileged user, hosting providers (and virtual
private server administrators) will want packages that fit in with the
rest of the software being managed in the hosting environment.

Paul

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


Re: Vim scripting with python

2007-02-04 Thread Tool69
Thanks Stuart,
I'll take a look at it.

Another thing :
Is there any way to made some modification de the python.syntax file
to highlight the functions call, i.e :
os.popen(...) ---> "popen(...)" will be highlighted.

Cheers.

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


Re: PYTHONPATH or any other way to set seachpath (winXP) ?

2007-02-04 Thread Stef Mientki
Inca wrote:
>> Through "My computer" | properties | advanced | Environment Variables"
>> you have to reboot.
> 
> The best overall solution is the one where you modify sys.path to add
> your own custom paths,
I agree, specially in my situation that is the best solution.

  however Jussi is right in that you do not need
> to reboot. You have to restart any applications that relies on using
> the updated environment variables (in your case the Delphi program):
> 
> http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/environment_variables.mspx?mfr=true
> 
I think the problem comes from the Delphi interface,
both Idle and PyScripter reflect a change PYTHONPATH after a restart.
But my Delphi program needs a reboot :-(
I'll ask around in the Python4Delphi newsgroup.

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


Re: when will python 2.5 take in mainstream?

2007-02-04 Thread paul
Eric CHAO schrieb:
> A lot of application based on python claim that python 2.3 or 2.4 is
> needed not 2.5, ie. mysqldb. I've been using python for months. I
> don't care about 2.4 or 2.5. But I like the default icons of python in
> 2.5. So I just use that, but some scripts can't work on that.
What do you mean by "that"? I just use the 2.5 icons with 2.4 and all my
scripts are happy ;)

thanks
 Paul

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


Re: CTypes

2007-02-04 Thread [EMAIL PROTECTED]
On Feb 4, 7:26 am, "Mark" <[EMAIL PROTECTED]> wrote:

Hey, I really appreciate you responding to my post. I've been on this
problem for some days now and it was getting to me. Sad that pywinauto
doesn't run on Win98SE, are there any other Python libraries for
'automating' Windows COM? If not I looked into AutoIt, which is a
Windows automation tool. It has a DLL which I believe contains all the
methods it does in the scripting language it has. I read over the
(yeah, 'the'. I keep finding the exact same tutorial) ctypes tutorial,
and I don't get it. I don't get how to load a DLL. So if I had a
script file 'test.py' and a DLL 'AutoIt3X.DLL' in the same folder, how
could I load it? The tutorial did something like dll=windll.kernel32,
which I understands loads the kernel but I don't see how I could apply
that to load AutoIt3X. Thanks in advanced.

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


Re: stlib name clash when using python as ASP language

2007-02-04 Thread Joost
> You *assume* that [0] is the IIS path, but perhaps some other imported
> module changed sys.path too, and now it's not the first one anymore.
> If you know exactly the path, try sys.path.remove(iis_path).
>
> --
> Gabriel Genellina

It's was a hack and definitely not meant to go in to production ;)
Since gzip.py lives in python24\lib I thought setting sys.path[0] to
python24\lib would load this load this module, no matter what.
However, in some magically way the sys.path gets modified during the
request by IIS. Maybe IIS resets the global sys.path per new request,
causing sporadic problems when request are handled concurrently? I
just don't know. The iis/inetsrv path is included in sys.path for a
reason and I don't want to fiddle around with sys.path to create
problems in other parts of the code. I was wandering if there is some
way to prevent a  name clashes by using a custom importer or something
like that.

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


Re: Hi, I'm new to python

2007-02-04 Thread millball54
Thanks very much guys for your help.. Its been greatly appreciated.

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


Re: PYTHONPATH or any other way to set seachpath (winXP) ?

2007-02-04 Thread Inca
> Through "My computer" | properties | advanced | Environment Variables"
> you have to reboot.

The best overall solution is the one where you modify sys.path to add
your own custom paths, however Jussi is right in that you do not need
to reboot. You have to restart any applications that relies on using
the updated environment variables (in your case the Delphi program):

http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/environment_variables.mspx?mfr=true

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


Re: CTypes

2007-02-04 Thread Mark
Hi,

On Feb 3, 6:22 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> I forgot to mention I am running Windows 98SE.

Hmm - pywinauto is not supported on Windows 98 - it relies competely
on Unicode.

You could try renaming all the functions ending in W to ending in A
e.g. change GetModuleFileNameExW  to GetModuleFileNameExA - but I am
fairly sure that this would NOT solve all the problems you would have
trying to run on W98.

As far as I know (not 100% sure) but ctypes should have no problem on
W98 - it is a pywinauto requirement for Unicode.

Another thing to look into might be Unicows.dll (which gives some
Unicode functions to W98)

Mark

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


Question

2007-02-04 Thread Magdy Sanad

  Dear All

I'm a Researcher  from Cairo, Egypt.

I installed the language programmer 
  Python Enthought Edition--Python 2.4.3 for Windows 
Enhanced Python Distribution.I have certain data in the default file 
format ( GADGET ) . 
 
 
I Will be appreciated if you guide me to read these data 
under Python ?


 I'm looking forward to hear from you.

  Best Regards

Magdy Sanad
  
National Research   Institute of
Astronomy and Geophysics
Astronomy Department
Helwan - Cairo - Egyp
 
-
Never miss an email again!
Yahoo! Toolbar alerts you the instant new Mail arrives. Check it out.-- 
http://mail.python.org/mailman/listinfo/python-list

Re: ctypes.com.IUnknown

2007-02-04 Thread Robin Becker
Giles Brown wrote:
>
> 
> What about downloading the spin-off library?
> http://sourceforge.net/projects/comtypes/
> 
> (I think this was created to move the com stuff out of ctypes?)
...

Thanks I didn't know that; I'll give it a whirl.
-- 
Robin Becker
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Definitions of editor and IDE?

2007-02-04 Thread Paddy
On Feb 4, 9:01 am, Necmettin Begiter <[EMAIL PROTECTED]>
wrote:
> 04 Şub 2007 Paz 00:48 tarihinde, Dick Moores şunları yazmıştı:>  Are there 
> generally accepted definitions of "editor" and "IDE". Is there a
> > clear-cut distinction between them? I've been looking at the lists of each
> > at python.org,   and <
> >http://wiki.python.org/moin/IntegratedDevelopmentEnvironments>. Many
> > programs are on both lists: Komodo, Eclipse, jedit, SPE, Wing IDE, UliPad,
> > etc.
>
> >  Dick Moores
>
> Can't give definitions, but here is the difference: if you use an editor, you
> will have to run your script or program from outside the editor; if you use
> an IDE, you will press a key or key combination in the IDE (say F9 or F5) and
> your program/script will run...

Hmm, is vim an editor or an IDE?
By the above definition it would be an IDE because under the tools
menu you can run make or compilers/interpreters.
It has probably got to the stage that its a continuum from something
like Eclipse or SPE that are definitely IDE's through to ed and
notepad which are editors.

- Pad.

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

when will python 2.5 take in mainstream?

2007-02-04 Thread Eric CHAO
A lot of application based on python claim that python 2.3 or 2.4 is
needed not 2.5, ie. mysqldb. I've been using python for months. I
don't care about 2.4 or 2.5. But I like the default icons of python in
2.5. So I just use that, but some scripts can't work on that.

When will all these applications support 2.5?

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


Re: PYTHONPATH or any other way to set seachpath (winXP) ?

2007-02-04 Thread Stef Mientki
Jussi Salmela wrote:
> Stef Mientki kirjoitti:
>> Is it possible to change the searchpath for modules on the flight,
>> under winXP ?
> What do you mean by *on the flight*: inside IDLE? using the command line?

No, I run Python, embedded from within a Delphi program.

>> Most preferred is some command to extend the searchpath.
>> (the environment variable PYTHONPATH needs a reboot)
>>
> No, it doesn't. PYTHONPATH can be updated somewhere in the environment 
> options (sorry: I've got a Finnish language XP version, so I don't 
> remember the exact terms) and the new path comes in effect immediately 
> i.e. the launches after that see the new definition.
> 
Through "My computer" | properties | advanced | Environment Variables"
you have to reboot.
But as I remember well there should be a way, (through the registry or DOS-box 
?)
but I don't want to mess in the registry,
I want to keep my application portable.
But the suggestion of Rob, looks perfect.

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


Re: Decimating Excel files

2007-02-04 Thread Arnd
> Every other line would be bicimating or something,
> wouldn't it?

Good observation, but as we have numbers of type Cardinalia,
Ordinalia, Distributiva & Multiplicativa in Latin I would prefer
secundating or secondating. (Bisimating or bicimating would multiply
the lines by a factor 2)

;) Arnd

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


Re: ctypes.com.IUnknown

2007-02-04 Thread Giles Brown
On 3 Feb, 20:36, Robin Becker <[EMAIL PROTECTED]> wrote:
> I find that ctypes.com has disappeared from the ctypes extension bundled
> with Python 2.5. I think I only need the IUnknown, I was playing with
> building a dialog using venster, but it needs IUnknown, STDMETHOD,
> HRESULT, GUID from ctypes.com. Any ideas what should replace those or is
> venster now too old to bother with.
> --
> Robin Becker

What about downloading the spin-off library?
http://sourceforge.net/projects/comtypes/

(I think this was created to move the com stuff out of ctypes?)

Giles

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


Re: PYTHONPATH or any other way to set seachpath (winXP) ?

2007-02-04 Thread Jussi Salmela
Stef Mientki kirjoitti:
> Is it possible to change the searchpath for modules on the flight,
> under winXP ?
What do you mean by *on the flight*: inside IDLE? using the command line?
> Most preferred is some command to extend the searchpath.
> (the environment variable PYTHONPATH needs a reboot)
> 
No, it doesn't. PYTHONPATH can be updated somewhere in the environment 
options (sorry: I've got a Finnish language XP version, so I don't 
remember the exact terms) and the new path comes in effect immediately 
i.e. the launches after that see the new definition.

That way of changing the PYTHONPATH is a little difficult, though. In 
command line usage i.e. CMD.EXE I have been using these kinds of bat 
files to alternate between versions 2.4 and 2.5 of Python. (These were 
suggested earlier by someone in this group I think):
===
Py24.bat (Py25.bat has Python25 instead of Python24 in it)
===
@echo off
if .%1.==.. goto NODEV
set DEMOHOME=%1
goto CONT
:NODEV
set DEMOHOME=C:
:CONT
set PYTHONHOME=%DEMOHOME%\Python24
set PYTHONPATH=%PYTHONHOME%;
set PYTHON=%PYTHONHOME%\python.exe
set PYTHONW=%PYTHONHOME%\pythonw.exe
set PATH=%PYTHONHOME%;%PATH%

===
Py.bat (to launch Python)
===
"%PYTHON%" "%1.py" "%2" "%3" "%4" "%5" "%6" "%7" "%8" "%9"

> thanks,
> Stef Mientki

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


Re: PYTHONPATH or any other way to set seachpath (winXP) ?

2007-02-04 Thread Stef Mientki
> Do you mean something like that?
> 
 import some_module
> Traceback (most recent call last):
>   File "", line 1, in ?
> ImportError: No module named some_module
 import sys
 sys.path.append("..")
 import some_module
Rob,
thank you very much,
that's exactly what I want.
(Why is the obvious so often invisible to me ;-)

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


Re: PYTHONPATH or any other way to set seachpath (winXP) ?

2007-02-04 Thread Rob Wolfe
Stef Mientki <[EMAIL PROTECTED]> writes:

> Is it possible to change the searchpath for modules on the flight,
> under winXP ?
> Most preferred is some command to extend the searchpath.
> (the environment variable PYTHONPATH needs a reboot)

Do you mean something like that?

>>> import some_module
Traceback (most recent call last):
  File "", line 1, in ?
ImportError: No module named some_module
>>> import sys
>>> sys.path.append("..")
>>> import some_module

http://docs.python.org/tut/node8.html#SECTION00811

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


Re: wxPython: TextCtrl delayed update when using TE_RICH(2)

2007-02-04 Thread jean-michel bain-cornu
Hi,
> def Execute(self, evt):
> print "Start query"
> time.sleep(5)
> 
> The "Start query" message should show in the *messages* box when I
> press the button. Instead, it shows only after the time.sleep(5)
> delay.
> 
> If I don't use the wx.TE_RICH / wx.TE_RICH2 style on *messages*, the
> text shows before the time.sleep(5)

For this kind of stuff, I'd try to put "self.out.WriteText(string)" in 
some 'Idle' event, which avoid to fall in focus loops or other objects 
events management problems not easy to solve.

Did you try something like that :

def write(self, string):
 self.outBuffer= string
def onIdle(self,event):
 if self.outBuffer != None:
 self.out.WriteText(self.outBuffer)
 self.outBuffer= None
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Where Does One Begin?

2007-02-04 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>,
[EMAIL PROTECTED] wrote:

> On Feb 3, 2:16 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
>> In <[EMAIL PROTECTED]>,
>>
>> [EMAIL PROTECTED] wrote:
>> > pygame is probily a good program to start with as long as you keep in
>> > mind that it is possible that up to 50% of the p.c. laptops may not be
>> > able to run it.
>>
>> Huh?  Care to explain this?
> 
> This is based on the documentation from panda3d explaining why certain
> functions do not work on pc lap tops.

Could you point to such documentation?  The search function in the online
docs doesn't know about "laptop".

> The trend in tek is smaller faster exc exc..  based on what they said at
> the time of thier documation and I would have to check this certain
> functions are not available because of memory of the graphics card???  I
> am going by memory and as promised those panda 3d functions do not work
> but the program overall is fine.

There must be enough memory to display a full screen, obviously,
everything else is done in main memory then.  And you are talking about
panda3d functions and not pygame ones.  The OP wanted to write simple 2D
games, so it's irrelevant if panda3d doesn't work on some laptops. 
Claiming pygame doesn't work on about 50% of the laptops out there based
on these facts is a bit exaggerated.

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


Re: Decimating Excel files

2007-02-04 Thread jean-michel bain-cornu
Hi,
> We have a data acquisition program that saves its output to Excel's
> ..xls format. Unfortunately, the programmer was too stupid to write
> files the average user can read.
> 
> I'd like some advice on how to go about:
> 1. Reading a large Excel file and chop it into many Excel files (with
> only 65535 lines per file)
> or
> 2. Decimate an Excel file & write... say every other line (user
> selectable)... to a new file.
> 
> I'm pretty experienced at reading and writing simple text files, but
> this is my first foray into using COM. I would imagine either choice 1
> or 2 is pretty simple once I can get the file open.
When I have Excel stuff to do, I use :
http://sourceforge.net/projects/pyexcelerator
May be it can cover your needs ?
 From my point of view, COM is something to avoid : no docs, lot of 
investigations, weak results.
Regards
jm
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: confused about resizing array in Python

2007-02-04 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Dongsheng Ruan wrote:

> This seems to be  clever to use reference for list.
> 
> Is it unique to Python?

No of course not.  Java is very similar in only passing references around
for objects.  And `ArrayList` and `Vector` behave similar to Python lists.

> How about the traditional programming languages like C, Pascal or C++?

For a start they don't have a built in list type.  C and Pascal don't even
have one in the standard library.  C++ has STL vectors and if you, the
programmer, decide to store pointers in it instead of structures or
objects then you have something like Python's list type.

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


Re: Definitions of editor and IDE?

2007-02-04 Thread Necmettin Begiter
04 Şub 2007 Paz 00:48 tarihinde, Dick Moores şunları yazmıştı: 
>  Are there generally accepted definitions of "editor" and "IDE". Is there a
> clear-cut distinction between them? I've been looking at the lists of each
> at python.org, < http://wiki.python.org/moin/PythonEditors>  and <
> http://wiki.python.org/moin/IntegratedDevelopmentEnvironments>. Many
> programs are on both lists: Komodo, Eclipse, jedit, SPE, Wing IDE, UliPad,
> etc.
>
>  Dick Moores
Can't give definitions, but here is the difference: if you use an editor, you 
will have to run your script or program from outside the editor; if you use 
an IDE, you will press a key or key combination in the IDE (say F9 or F5) and 
your program/script will run...
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Create a cookie with cookielib

2007-02-04 Thread Alessandro Fachin
Matthew Franz wrote:

> I'm not sure what you mean be forge, but if you mean set an arbitrary
> cookie manually (vs. one that was provided by the server).  just use
> add_header() in http://docs.python.org/lib/request-objects.html

Yes is exactly what i want to do... i don't known because i looked at
cookielib to set cookie data, cookie are simply http header :) Inserting
values with add_header() or addheaders() it works. Thank you

> It may be possible to use CookieJar for this purpose but I've only
> used it for manipulating cookies set by the server...
> 
> And  I would agree that Python cookie APIs are less intuitive than
> what are available in others such as Jakarta HttpClient
> 
> - mdf


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