modules in diff. file

2006-09-18 Thread JyotiC
hi,

i have a prog. and i want diving the code in different files.
there will be one mail file which will call modules or
variables(global) from differnet files
how can i do this.
code is very big and i it's getting difficult to manage in same file.

thanx in advance

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


Re: modules in diff. file

2006-09-18 Thread Calvin Spealman
On 18 Sep 2006 00:19:20 -0700, JyotiC <[EMAIL PROTECTED]> wrote:
> hi,
>
> i have a prog. and i want diving the code in different files.
> there will be one mail file which will call modules or
> variables(global) from differnet files
> how can i do this.
> code is very big and i it's getting difficult to manage in same file.
>
> thanx in advance

All of this is covered in any good Python tutorial, including the
official documentation. Simply move code you want to seperate into
their own python files. They will become importable modules, so foo.py
can be accessed with `import foo` from another module. Now, be careful
because you can't circularly import the modules. That means that if
you have module foo and module bar, they can't both import each other.
You'll have to take that into consideration when you seperate the code
into these modules. you can usually break up a moderately sized
project such that one main module imports all the others, and none of
them need to know about one another.

Python Tutorial - Modules
http://docs.python.org/tut/node8.html
-- 
http://mail.python.org/mailman/listinfo/python-list


incompatible exit values between python 2.4 and 2.5

2006-09-18 Thread Anthon
I have a small C program that restarts a python based server
application if the exit value of the
   system("python -m pythonscript arg1 arg2 ...")
is greater than 127 (using WEXITSTATUS on the result of system(..))
If the server really needs to stop I exit with
  sys.exit(0)
but if I just want it to restart (to reread all modules) I can do
  sys.exit(128)

With python 2.4, if pythonscript.py could not be found, the exit value
would be 2 and if there was some syntax error, or other exception
raised, the exit value would be 1.

While trying this out with Python 2.5 I found that the exit value on
error is always 255, so I have to change my script (not a big deal).
However two questions came up while finding out what was
the difference:

1) is this change of behaviour documented somewhere and did I miss
that, or has this not been documented (yet)
2) Is there a build-in way to set the exit value for Python in case an
exception is raised that is uncaught and causes python to terminate? (I
have now implemented something using
   try:
  ...
   except ImportError, comment:
  sys.exit(2)
   except:
  sys.exit(1)
but I still have to figure out how to print the stacktrace before
exiting with specific values.)

Regards
Anthon

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


Re: Pythondocs.info : collaborative Python documentation project

2006-09-18 Thread Michael Ströder
[EMAIL PROTECTED] wrote:
> 
> That's why I have started a collaborative project to make a user
> contributed Python documentation. The wiki is online here:
> http://www.pythondocs.info

Frankly I'm tired of these yet-another-wiki announcements!
Who is supposed to fill them with content?

If you have improvements to the official docs put them into Python's SF
tracker:
http://sourceforge.net/tracker/?func=add&group_id=5470&atid=305470

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


Re: Python programs always open source?

2006-09-18 Thread GHUM
Guy Fawkes schrieb:

> I don't want my program to
> be open-source and so far all the Python programs I've seen included the
> source code.

That's one of the great freedoms of Python and its licence: You are
free to chose the licence for your product. No GPLish "you must be as
free as we", more BSDish: "Do what you want, do not come crying"

> Is it possible to make an executable with only bytecode?
I use py2exe with its "new" (~1 year) single file feature with great
success. I even succeeded in including a virtual static directory for a
webserver within that file.

To be exact, it is not really 1 file, but 2, as you often have to
distribute msvcr71.dll with it  - except for those computers having
i.e. MS Office 11 installed, there it is allready present.

Combining py2exe's single file distributable and upx compression I
achieve fairly compact "just drop and use" applications without a real
need for installation. I do not care about people decompiling
(customers get the source code on request, if they are interested).
It would be possible - but those who have the time and knowledge to
dissect and decompile those upxed py2exed files and still make a profit
would probably not see a reason to buy my software anyway :)

Harald

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


Re: incompatible exit values between python 2.4 and 2.5

2006-09-18 Thread Diez B. Roggisch
> 1) is this change of behaviour documented somewhere and did I miss
> that, or has this not been documented (yet)
> 2) Is there a build-in way to set the exit value for Python in case an
> exception is raised that is uncaught and causes python to terminate? (I
> have now implemented something using
>try:
>   ...
>except ImportError, comment:
>   sys.exit(2)
>except:
>   sys.exit(1)
> but I still have to figure out how to print the stacktrace before
> exiting with specific values.)

For the latter, take a look at

sys.exc_info()


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


Re: Cheese Shop Registration error

2006-09-18 Thread alefnula
The Key ID that the kgpg shows. I tried to paste the key returned by
the quiery on the keyserver. but it also doesn't work. I tried
everything that has any connection with the key, but everything fails.

By the way the key is: 6A61E3AD

Richard Jones wrote:
> [EMAIL PROTECTED] wrote:
> > I tried to register on the Python Cheese Shop, but I constatnly get a
> > "GPG key ID is invalid" error.
> >
> > I made a new GPG key using kgpg, exported the public key to the key
> > server, and copy/pasted the Key ID into the registration form... But it
> > doesn't work.
> 
> And the key ID you were trying to paste in was?
> 
> 
> Richard

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


Re: Pythondocs.info : collaborative Python documentation project

2006-09-18 Thread Bruno Desthuilliers
[EMAIL PROTECTED] wrote:
> Wildemar Wildenburger wrote:
>> [EMAIL PROTECTED] wrote:
>>> I have read many messages of people complaining about the documentation,
>>> it's lack of examples and the use of complicated sentences that you
>>> need to read 10 times before understanding what it means.
>>  >
>> Where have you read that?
>>
>> wildemar
> 
> I don't mean to start a flame war about this but here are some
> reference of people, who like me, don't like the current python doc:
> http://xahlee.org/UnixResource_dir/writ/python_doc.html

Xah Lee is a well-known crank.

-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in '[EMAIL PROTECTED]'.split('@')])"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to change font direction?

2006-09-18 Thread Frederic Rentsch
theju wrote:
> Well here are some self explanatory functions that I've written for
> displaying the text vertically and from right to left. As for rotation
> gimme some more time and i'll come back to you. Also I don't guarantee
> that this is the best method(cos I myself am a newbie), but I can
> guarantee you that it works.
> Here it goes...
>
> im=Image.open("imgfile.jpg")
> draw=ImageDraw.Draw(im)
>
> def verdraw(width,height,spacing,a="Defaulttext"):
>   for i in range(0,len(a)):
>   draw.text((width,height),a[i],())
>   height+=spacing
>
> def right2leftdraw(width,height,spacing,a="Defaulttext"):
>   for i in range(0,len(a)):
>   draw.text((width,height),a[len(a)-i-1],())
>   width += spacing
>
>  is a 3 field length tuple is mentioned in the PIL-Handbook.
> Hope you find it useful
> -Theju
>
> Daniel Mark wrote:
>   
>> Hello all:
>>
>> I am using PIL to draw some graphics and I need to draw some texts
>> in vertical direction rather than the default left-to-right horizontal
>> direction.
>>
>> Is there anyway I could do that?
>>
>>
>> Thank you
>> -Daniel
>> 
>
>   

I have done a circular 24-hour dial with the numbers arranged to read 
upright as seen from the center. I remember writing each number into a 
frame, rotating the frame and pasting it into the dial image at the 
right place. I also remember using a transparency mask, so the white 
background of the little frame didn't cover up what it happened to 
overlap (minute marks). The numbers were black on white, so the frame 
was monochrome and could be used as its own transparency mask.
  (This could well be an needlessly complicated approach. When 
confronting a problem, I tend to weigh the estimated time of  hacking 
against the estimated time of shopping and reading recipes and often 
decide for hacking as the faster alternative.)

Regards

Frederic

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


PythonCAD question

2006-09-18 Thread Franz Steinhaeusler
Hello NG,

I tried to run PythonCad on window and
got follwoing traceback:

Traceback (most recent call last):
  File "C:\temp\PythonCAD-DS1-R34\PythonCad.py", line 45, in ?
import PythonCAD.Interface.Cocoa.ImageDocument
  File "C:\temp\PythonCAD-DS1-R34\PythonCAD\Interface\Cocoa\ImageDocument.py", l
ine 38, in ?
import PythonCAD.Interface.Cocoa.Globals
  File "C:\temp\PythonCAD-DS1-R34\PythonCAD\Interface\Cocoa\Globals.py", line 23
, in ?
from Foundation import NSObject
ImportError: No module named Foundation

* Waht is the module "Foundation"?

Where can I get it?

Many thanks in advance!

-- 
Franz Steinhaeusler

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


Re: PythonCAD question

2006-09-18 Thread Peter Otten
Franz Steinhaeusler wrote:

> Hello NG,
> 
> I tried to run PythonCad on window and
> got follwoing traceback:
> 
> Traceback (most recent call last):
>   File "C:\temp\PythonCAD-DS1-R34\PythonCad.py", line 45, in ?
> import PythonCAD.Interface.Cocoa.ImageDocument
>   File
>   "C:\temp\PythonCAD-DS1-R34\PythonCAD\Interface\Cocoa\ImageDocument.py",
>   l
> ine 38, in ?
> import PythonCAD.Interface.Cocoa.Globals
>   File "C:\temp\PythonCAD-DS1-R34\PythonCAD\Interface\Cocoa\Globals.py",
>   line 23
> , in ?
> from Foundation import NSObject
> ImportError: No module named Foundation
> 
> * Waht is the module "Foundation"?
> 
> Where can I get it?

The .../Cocoa/... part in the paths suggests that PythonCAD assumes it is
running on a Mac. The missing module is rather a symptom than the cause of
the bug.

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


Re: PythonCAD question

2006-09-18 Thread Franz Steinhaeusler
Peter Otten wrote:

> Franz Steinhaeusler wrote:
>
>> Hello NG,
>> 
>> I tried to run PythonCad on window and
>> got follwoing traceback:
>> 
>> Traceback (most recent call last):
>>   File "C:\temp\PythonCAD-DS1-R34\PythonCad.py", line 45, in ?
>> import PythonCAD.Interface.Cocoa.ImageDocument
>>   File
>>   "C:\temp\PythonCAD-DS1-R34\PythonCAD\Interface\Cocoa\ImageDocument.py",
>>   l
>> ine 38, in ?
>> import PythonCAD.Interface.Cocoa.Globals
>>   File "C:\temp\PythonCAD-DS1-R34\PythonCAD\Interface\Cocoa\Globals.py",
>>   line 23
>> , in ?
>> from Foundation import NSObject
>> ImportError: No module named Foundation
>> 
>> * Waht is the module "Foundation"?
>> 
>> Where can I get it?
>
> The .../Cocoa/... part in the paths suggests that PythonCAD assumes it is
> running on a Mac. The missing module is rather a symptom than the cause of
> the bug.
>
> Peter

Hello Peter, 

On the homepage,
http://www.pythoncad.org/
there is the text:


"PythonCAD does run on Windows if you have the Windows
ports of the required libraries and modules." 

-- 
Franz Steinhaeusler

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


Re: incompatible exit values between python 2.4 and 2.5

2006-09-18 Thread John Machin

Diez B. Roggisch wrote:
> > 1) is this change of behaviour documented somewhere and did I miss
> > that, or has this not been documented (yet)
> > 2) Is there a build-in way to set the exit value for Python in case an
> > exception is raised that is uncaught and causes python to terminate? (I
> > have now implemented something using
> >try:
> >   ...
> >except ImportError, comment:
> >   sys.exit(2)
> >except:
> >   sys.exit(1)
> > but I still have to figure out how to print the stacktrace before
> > exiting with specific values.)
>
> For the latter, take a look at
>
> sys.exc_info()
> 

 or perhaps the traceback module ...

Cheers,
John

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


Re: PythonCAD question

2006-09-18 Thread Peter Otten
Franz Steinhaeusler wrote:

>> The .../Cocoa/... part in the paths suggests that PythonCAD assumes it is
>> running on a Mac. The missing module is rather a symptom than the cause
>> of the bug.

> On the homepage,
> http://www.pythoncad.org/
> there is the text:
> 
> 
> "PythonCAD does run on Windows if you have the Windows
> ports of the required libraries and modules."

I don't doubt that. Looking into PythonCad.py, though, I find

# main routine to start Cocoa-based PythonCad

On Windows gtkpycad.py with

# main routine to start GTK-based pycad

looks more promising...

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


Re: Python programs always open source?

2006-09-18 Thread Ben Finney
"GHUM" <[EMAIL PROTECTED]> writes:

> That's one of the great freedoms of Python and its licence: You are
> free to chose the licence for your product. No GPLish "you must be
> as free as we", more BSDish: "Do what you want, do not come crying"

This has nothing to do with the license of Python. Whether Python was
distributed under the GPL, BSD or Jack's Own Oddball License, the
copyright holder of Python has no say over what license you choose for
your own work.

So long as you're not distributing some or all of Python itself, or a
derivative work, the license for Python has no legal effect on what
license you choose for your own work.

-- 
 \  "He that would make his own liberty secure must guard even his |
  `\  enemy from oppression."  -- Thomas Paine |
_o__)  |
Ben Finney

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


Re: Where can i download mod_webkit from?

2006-09-18 Thread Bruno Desthuilliers
[EMAIL PROTECTED] wrote:
> Hi
> 
> I am trying to get webware for python running on Apache.  I want to get
> it working with mod_webkit, but for the life of me i can't find a
> webpage where i can download a source for it or maybe an rpm.  If
> anyone knows the download page, i'd greatly appreciate if you share it
> with me.

http://www.webwareforpython.org/WebKit/Docs/InstallGuide.html#mod-webkit
"""
The source code and a README file describing how to configure and build
mod_webkit are located in the Webware/WebKit/Adapters/mod_webkit
"""

> Thanks
> 


-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in '[EMAIL PROTECTED]'.split('@')])"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PythonCAD question

2006-09-18 Thread Franz Steinhaeusler
Peter Otten wrote:

> Franz Steinhaeusler wrote:
>
>>> The .../Cocoa/... part in the paths suggests that PythonCAD assumes it is
>>> running on a Mac. The missing module is rather a symptom than the cause
>>> of the bug.
>
>> On the homepage,
>> http://www.pythoncad.org/
>> there is the text:
>> 
>> 
>> "PythonCAD does run on Windows if you have the Windows
>> ports of the required libraries and modules."
>
> I don't doubt that. Looking into PythonCad.py, though, I find
>
> # main routine to start Cocoa-based PythonCad
>
> On Windows gtkpycad.py with
>
> # main routine to start GTK-based pycad
>
> looks more promising...
>
> Peter

Thank you! It laid diretly in front of me.
-- 
Franz Steinhaeusler

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


Re: CONSTRUCT - Adding Functionality to the Overall System

2006-09-18 Thread Steve Holden
Ilias Lazaridis wrote:
> Damjan wrote:
> 
I understand that I can use __metaclass__ to create a class which
modifies the behaviour of another class.

How can I add this metaclass to *all* classes in the system?

(In ruby I would alter the "Class" class)
>>>
>>>You'd have to set
>>>
>>>__metaclass__ = whatever
>>>
>>>at the top of each module whose classes are to get the new behavior.
>>
>>I think '__metaclass__ = whatever' affects only the creation of classes that
>>would otherwise be old-style classes?
> 
> 
> It seems so:
> 
> http://mail.python.org/pipermail/python-list/2003-June/166572.html
> 
> 
>>>You can't alter classes which you don't control or create in your code.
>>
>>I remeber I've seen an implementation of import_with_metaclass somewhere on
>>IBM's developerworks. I didn't quite undersntad it though.
> 
> 
> http://www-128.ibm.com/developerworks/linux/library/l-pymeta.html
> 
> I am not so much interested in old-style, as is start production with
> python 2.4 (possibly even with python 2.5).
> 
The fact remains that you won't be able to affect the built-in classes 
such as int and str - they are hard-coded in C (for CPython, at least), 
and so their metaclass is also implied and cannot be changed.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Skype: holdenweb   http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

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


Re: 911 FORGERY bigger than the Protocols of the Learned Elders of Zion

2006-09-18 Thread schoenfeld . one

malibu wrote:
> tadchem wrote:
> > "Protocols of the Elders of Zion" was a fraud
> > http://en.wikipedia.org/wiki/The_Protocols_of_the_Elders_of_Zion
> > http://ddickerson.igc.org/protocols.html
> > http://www.straightdope.com/mailbag/mzionprotocol.html
> > http://www.museumofhoaxes.com/hoaxorum/hoaxorum1869.html
> >
> > The fraud was proven by identifying the sources used by the plagiarist
> > in 1921, but there are *still* those who believe it because it
> > justifies their racial hatred.
> >
> > Of course, like the 'Protocols', the 9/11 conspiracy hoax will be
> > embraced by those whose will to believe something that justifies their
> > irrational prejuduces exceeds their will to understand the implications
> > of rational data.
> >
> > As can be expected, there is a lot of overlap between the hateful
> > racists of the antisemitic groups and the delusional paranoids involved
> > in the 9/11 conspiracy theories.
> >
> > Tom Davidson
> > Richmond, VA
>
> There were many people who reported
> numerous explosions in the WTC buildings.
> When the firefighters arrived all the ground
> floor windows had been blown out.
> There were explosions in the sub-basement floors
> as reported by severely-injured caretakers who
> came up from there and by
> firefighters on the scene.
>
> Seismic records substantiate these claims.
>
> Isn't 'delusional paranoia' a little less
> substantive than that?
>
> Maybe you should actually *look*
> at the data- I know as a physicist you've kinda
> gotten away from that mindset.

One should not confuse clergymen with physicists. Anyone who observes a
building freefall into itself and deny a controlled demolition can
never be called a physicist.

> John

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


Re: CONSTRUCT - Adding Functionality to the Overall System

2006-09-18 Thread Paul McGuire
"Calvin Spealman" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> On 17 Sep 2006 09:22:16 -0700, Ilias Lazaridis <[EMAIL PROTECTED]> 
> wrote:
>> I understand that I can use __metaclass__ to create a class which
>> modifies the behaviour of another class.
>>
>> How can I add this metaclass to *all* classes in the system?
>>
>> (In ruby I would alter the "Class" class)
>
> This is a terrible idea. When my, Joe Modulewriter, released my
> library of AwesomeCoolClasses, i except my metaclass to be something
> particular and if it starts getting wonky and I do anything hackery on
> my end with the types, then the end-user's computer might 'splode!
>
> What I am trying to say, is its a terrible idea to go changing other
> peoples' classes at runtime without knowing the real affects of what
> is going on. If you are just going to shoot yourself in the foot, why
> should we even give you a gun?

Reminds me of when I was learning Smalltalk, and modified printOn (ST's 
equivalent of str()) of the root-of-all-classes object class.  I don't 
remember the exact error I made, but it was a mess undoing it!

-- Paul


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


PIL 2.5 win32 binaries?

2006-09-18 Thread GHUM
On the PIL website I read:

The current free version is PIL 1.1.5, which has been tested with
Python 1.5.2 and newer, including 2.3 and 2.5.

but in downloads I cannot see any binaries for windows and Python 2.5

Are they somewhere available?

Best wishes,

Harald

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


Re: PIL 2.5 win32 binaries?

2006-09-18 Thread Thomas Heller
GHUM schrieb:
> On the PIL website I read:
> 
> The current free version is PIL 1.1.5, which has been tested with
> Python 1.5.2 and newer, including 2.3 and 2.5.
> 
> but in downloads I cannot see any binaries for windows and Python 2.5
> 
> Are they somewhere available?
> 
> Best wishes,
> 
> Harald
> 
http://effbot.org/downloads/#PIL

Thomas

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


Automatically installing libraries?

2006-09-18 Thread Chaz Ginger
Here is a problem I am trying to solve; I am sure there must be an easy 
way to do it and I just don't know how.

I have a rather large application that I am writing. To make it easy for 
the user to run I have them run a startup.py script. This script will 
try to load each of the third party libraries the application will need. 
If it is present, great. If it isn't, I would like to automatically 
install it. This is the heart of my problem: is there a Python 
equivalent to PERL's CPAN?

Peace,
Chaz
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Automatically installing libraries?

2006-09-18 Thread John Machin

Chaz Ginger wrote:
> Here is a problem I am trying to solve; I am sure there must be an easy
> way to do it and I just don't know how.
>
> I have a rather large application that I am writing. To make it easy for
> the user to run I have them run a startup.py script. This script will
> try to load each of the third party libraries the application will need.
> If it is present, great. If it isn't, I would like to automatically
> install it. This is the heart of my problem: is there a Python
> equivalent to PERL's CPAN?
>

Check out setuptools:
http://peak.telecommunity.com/DevCenter/setuptools

HTH,
John

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


Re: Automatically installing libraries?

2006-09-18 Thread Bruno Desthuilliers
Chaz Ginger wrote:
> Here is a problem I am trying to solve; I am sure there must be an easy
> way to do it and I just don't know how.
> 
> I have a rather large application that I am writing. To make it easy for
> the user to run I have them run a startup.py script. This script will
> try to load each of the third party libraries the application will need.
> If it is present, great. If it isn't, I would like to automatically
> install it. This is the heart of my problem: is there a Python
> equivalent to PERL's CPAN?

Not quite. But you should definitively have a look at setuptools before
proceeding to reinventing the SquareWheel(tm):

http://peak.telecommunity.com/DevCenter/setuptools


-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in '[EMAIL PROTECTED]'.split('@')])"
-- 
http://mail.python.org/mailman/listinfo/python-list


Interact with system command prompt

2006-09-18 Thread billie
Hi all. I would like to know if there's some python framework able to
interact with system command prompt (cmd.exe or /bin/sh, depending on
the system) from python.
I need something that supports key/path auto completion by pressing TAB
button and the possibility to use interactive programs like ftp, gpg or
even vi.
I would like to write a remote shell application the best featured as
possible and I'm wondering if Python is able to emulate the
functionalities of applications like telnet or ssh.

Thanks in advance for your helping.

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


Re: Interact with system command prompt

2006-09-18 Thread Diez B. Roggisch
billie wrote:

> Hi all. I would like to know if there's some python framework able to
> interact with system command prompt (cmd.exe or /bin/sh, depending on
> the system) from python.
> I need something that supports key/path auto completion by pressing TAB
> button and the possibility to use interactive programs like ftp, gpg or
> even vi.
> I would like to write a remote shell application the best featured as
> possible and I'm wondering if Python is able to emulate the
> functionalities of applications like telnet or ssh.

Check out IPython.

http://ipython.scipy.org/


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


Re: Interact with system command prompt

2006-09-18 Thread billie

Diez B. Roggisch ha scritto:

> billie wrote:
>
> > Hi all. I would like to know if there's some python framework able to
> > interact with system command prompt (cmd.exe or /bin/sh, depending on
> > the system) from python.
> > I need something that supports key/path auto completion by pressing TAB
> > button and the possibility to use interactive programs like ftp, gpg or
> > even vi.
> > I would like to write a remote shell application the best featured as
> > possible and I'm wondering if Python is able to emulate the
> > functionalities of applications like telnet or ssh.
>
> Check out IPython.
>
> http://ipython.scipy.org/
>
>
> Diez

Thank you. It seems to me a powerful tool. I'll try to play with it.

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


Interfacing my chess client with GNU chess using python

2006-09-18 Thread Varun Hiremath
Hello,
   I have written a chess client using python which is a graphic
   interface to play chess. It is at present a two player version,
   players move their peices by clicking two squares on the board as
   in any other chess clients. 
   Now i want to interface my program with the already available
   gnuchess program. Basically i want to feed the user input to the
   gnuchess and get the output and then display in my GUI. I have read
   about Popen but i couldn't figure out how to do it. Is there any
   other better ways of doing it. Any help would be appreciated.

 

-- 
-8<--8<--8<--8<
Varun Hiremath
Undergraduate Student,
Aerospace Engg. Department,
Indian Institute of Technology Madras,
Chennai, India
---
Webpage : http://www.ae.iitm.ac.in/~ae03b032
---

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


Re: Python programs always open source?

2006-09-18 Thread Leif K-Brooks
Ben Finney wrote:
> So long as you're not distributing some or all of Python itself, or a
> derivative work, the license for Python has no legal effect on what
> license you choose for your own work.

How many Python programs use nothing from the standard library?
-- 
http://mail.python.org/mailman/listinfo/python-list


Multiping

2006-09-18 Thread Fransiska M Argasetya
dear all     i have the following code that keeps on pinging several sites infinitely     i was wondering if anyone could help me out in how to make the results for each set of loops of the pings to be displayed in an excel file? i need to use the maximum and minimum delay for my project.     thank you for any response     ===     import threadingimport osimport Queueimport timefrom time import sleep  def showResponse(args):    """Pretty prints passed tuple to stdout"""      ip, stdoutLi, threadName = args    print '%s \t\t\t\t\t\n' % (ip)      for line in stdoutLi:    line =
 line.strip()    if not line: continue    print '\t' + line    print '-'*72  class Pinger(threading.Thread):      def __init__(self, host, queue):    threading.Thread.__init__(self)    self.__host = host    self.__queue = queue    self.setDaemon(1)      def run(self):    pingCmd = "ping -n 10 -w 1000 " + self.__host    childStdout = os.popen(pingCmd)    result = (self.__host, childStdout.readlines(), self.getName())   
 childStdout.close()    self.__queue.put(result)  if __name__ == '__main__':    hostLi = ['www.google.com','www.yahoo.co.uk'] # assign while 1:    # infinite loop, 1 is always true    q = Queue.Queue()    startA = time.time()    for host in hostLi: # for every host in hostLi   
 Pinger(host,q).start()    for i in hostLi:    showResponse(q.get())   # removes an item out of the list / queue        === 
		On Yahoo!7 
Fuel Price Watch - Find and map the cheapest petrol prices in Australia   -- 
http://mail.python.org/mailman/listinfo/python-list

[ANN] Code Golf Challenge : 1,000 Digits Of Pi

2006-09-18 Thread Carl Drinkwater
Hi all,

Code Golf's 12th challenge has just been added to the site.  It asks you 
to calculate the first 1,000 digits of Pi - Something I'm sure most of 
you have thought about, but never done.  You can see the challenge at :

   http://codegolf.com/1000-digits-of-pi

For those who haven't heard of codegolf.com, it can be described as 
"allowing you to show off your code-fu by trying to solve coding 
problems using the least number of keystrokes."

The site currently supports Perl, PHP, Python and Ruby with Scheme to 
(hopefully) follow soon.  Your entries are automatically executed and 
scored - No need to wait for someone to validate your code.

Other challenges include implementing the Vigenere Cipher, Prime 
factors, SHA-256 Hashing as well as the obvious 99 Bottles Of Beer.  All 
of the challenges are competitive but there is still scope to well in 
them, even if you're new to the site.

I hope some of you will find this interesting, and sorry for disturbing 
you if not!

Have fun,
Carl.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interact with system command prompt

2006-09-18 Thread billie
Uhm... It seems that IPython got some problems:
http://ipython.scipy.org/doc/manual/node12.html

In details:

>Note that this does not make IPython a full-fledged system shell. In 
>particular, it has >no job control, so if you type Ctrl-Z (under Unix), you'll 
>suspend pysh itself, not the >process you just started.

>What the shell profile allows you to do is to use the convenient and powerful 
>syntax of >Python to do quick scripting at the command line.

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


Re: Python programs always open source?

2006-09-18 Thread Steve Holden
Leif K-Brooks wrote:
> Ben Finney wrote:
> 
>>So long as you're not distributing some or all of Python itself, or a
>>derivative work, the license for Python has no legal effect on what
>>license you choose for your own work.
> 
> 
> How many Python programs use nothing from the standard library?

That doesn't matter either. The required copyright statements are 
included in the Python interpreter. There is no reason to fear 
distributing Python as a part of either open source or proprietary 
works, and Guido framed the original license to allow precisely such 
uses. Later versions have retained the same spirit.

The official license doesn't take a lot of understanding or legalese. 
Try it:

   http://www.python.org/download/releases/2.4.2/license/

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Skype: holdenweb   http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

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


Re: Multiping

2006-09-18 Thread Steve Holden
Fransiska M Argasetya wrote:
> dear all
>  
> i have the following code that keeps on pinging several sites infinitely
>  
> i was wondering if anyone could help me out in how to make the results 
> for each set of loops of the pings to be displayed in an excel file? i 
> need to use the maximum and minimum delay for my project.
>  
> thank you for any response
>  
I'm afraid my only response is to ask you to stop posting the same 
question multiple times ... and just wait for someone to answer the 
question! If there's no reply in 48 hours a brief reminder (rather than 
a complete re-post) might be in order. Until then, patience should be 
the order of the day.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Skype: holdenweb   http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

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


Re: Python programs always open source?

2006-09-18 Thread Leif K-Brooks
Steve Holden wrote:
> Leif K-Brooks wrote:
>> Ben Finney wrote:
>>
>>> So long as you're not distributing some or all of Python itself, or a
>>> derivative work, the license for Python has no legal effect on what
>>> license you choose for your own work.
>>
>>
>> How many Python programs use nothing from the standard library?
> 
> That doesn't matter either. The required copyright statements are 
> included in the Python interpreter. There is no reason to fear 
> distributing Python as a part of either open source or proprietary 
> works, and Guido framed the original license to allow precisely such 
> uses. Later versions have retained the same spirit.

Yes, I know that. I was replying to Ben Finney's claim that in a 
hypothetical world where Python was licensed under the GPL, there would 
still be no restriction on distributing Python programs under a 
closed-source license.
-- 
http://mail.python.org/mailman/listinfo/python-list


How to stop a running embedded interpreter?

2006-09-18 Thread Dirk Runge
Hi!

I have embedded Python in an C++ App.
The Python-Interpreter is running in its own
Thread (I'm using PThreads).

I use PyRun_SimpleString to run Python-Code that the user entered
in an editorwindow.
I want the user to be able to stop the execution of
Python-Code (e.g. using a Cancel-Button).
Unfortunately I can't find a way to do this.

Of course, I can kill the Interpreter-Thread forcibly with 
pthread_cancel() but the App will crash if I call any Python API-
Function afterwards.

I thought about starting 2 Threads in Python: One thread checks for a 
stop condition (by calling a C-function that checks the Cancel-Button) 
and the user-code runs in a second thread. The Problem with this 
approach is that there seems to be no possibility for one Python-thread 
to kill another.
I don't want the user to have to check fo a stop condition himself either.

Any help is greatly appreciated.

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


win32com InvokeTypes is None

2006-09-18 Thread SS Hares
Hi,

I'm encountering an issue where the InvokeTypes method is returning
None and I'm unable to Dispatch a particular COM object from
DMCoreAutomation.dll. Everything works fine except for method
GetItemFields.

Using Python 2.4.2, pywin32 build 209.

Here is some example code (I can provide full source code if needed):

>>> from win32com.client import gencache
>>> file = 'C:\Shoaev\dev_qxdm\mylog.isf'
>>> mod = gencache.GetModuleForProgID('DMCoreAutomation.ItemStoreFiles')
>>> ds = mod.Dispatch('DMCoreAutomation.ItemStoreFiles')
>>> ds

>>> ss = mod.IItemStoreFiles(ds)
>>> ss

>>> hisf = ss.LoadItemStore(file)
>>> dc = ss.GetItem(hisf, 497)
>>> dc

>>> sc = mod.IColorItem(dc)
>>> sc

>>> sc.GetItemKeyText()
u'[0x1007/017]'
>>> df = sc.GetItemFields()
>>> df
>>>

df here is None. Other IColorItem methods work correctly.

Here is the relevant bit from the makepy generated code:

def GetItemFields(self):
"""Get (DB parsed) item fields (returns DB parsed field 
interface)"""
ret = self._oleobj_.InvokeTypes(414, LCID, 1, (9, 0), (),)
if ret is not None:
ret = Dispatch(ret, 'GetItemFields', None, 
UnicodeToString=0)
return ret

>From pdb, self._oleobj_.InvokeTypes(414, LCID, 1, (9, 0), (),) is
returning None


Any idea what is going on?

Thanks,
Shoaev

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


Re: Interact with system command prompt

2006-09-18 Thread Diez B. Roggisch
billie wrote:

> Uhm... It seems that IPython got some problems:
> http://ipython.scipy.org/doc/manual/node12.html
> 
> In details:
> 
>>Note that this does not make IPython a full-fledged system shell. In
>>particular, it has >no job control, so if you type Ctrl-Z (under Unix),
>>you'll suspend pysh itself, not the >process you just started.
> 
>>What the shell profile allows you to do is to use the convenient and
>>powerful syntax of >Python to do quick scripting at the command line.


Might be. But it could provide some insight into how to solve your problem.

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


Creating database structures in a portable way

2006-09-18 Thread Samuel
Hi,

I am looking for a library that takes an XML file that specifies a
table structure, and generates the CREATE/DROP/ALTER SQL statements to
create the tables in the database.

In particular, I am trying to port a PHP application that currently
uses the AdoDB XML schema:

> http://phplens.com/lens/adodb/docs-datadict.htm#xmlschema

Is there a way to do something similar with the DB-API modules in
Python?

Thanks,
-Samuel

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


Re: Creating database structures in a portable way

2006-09-18 Thread Bruno Desthuilliers
Samuel wrote:
> Hi,
> 
> I am looking for a library that takes an XML file that specifies a
> table structure, and generates the CREATE/DROP/ALTER SQL statements to
> create the tables in the database.
> 
> In particular, I am trying to port a PHP application that currently
> uses the AdoDB XML schema:
> 
>> http://phplens.com/lens/adodb/docs-datadict.htm#xmlschema
> 
> Is there a way to do something similar with the DB-API modules in
> Python?

FWIW, there's a Python port of adodb:
http://phplens.com/lens/adodb/adodb-py-docs.htm

and parsing XML in Python is quite easy. So you could as well port the
AdoDB XML to Python too.

OTOH, there are other - possibly better (YMMV) - DB abstraction layers
in Python, like SQLAlchemy. And since the above solution requires
(re)writing the xml-parsing part, it might be worth rewriting it so it
knows how to generate SQLAlchemy schemas instead.

My 2 cents...

-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in '[EMAIL PROTECTED]'.split('@')])"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pythondocs.info : collaborative Python documentation project

2006-09-18 Thread Bruno Desthuilliers
Rakotomandimby (R12y) wrote:
> On Sat, 16 Sep 2006 22:43:41 +0200, Daniel Nogradi wrote:
>> Then how about running your site on python and not php?
> 
> PHP has "better" documentation... ;-)
> More seriously, I can provide a CPS hosting to nicolasfr if he wants.

Alert ! Unusable undocumented monstruosity ahead...

-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in '[EMAIL PROTECTED]'.split('@')])"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help me use my Dual Core CPU!

2006-09-18 Thread mystilleef
Paul Rubin wrote:
> "mystilleef" <[EMAIL PROTECTED]> writes:
> > I use D-Bus (Python). I recommend it. I don't know how cross platform
> > it is. However, it supports message passing of most built-in (strings,
> > ints, lists, dictionaries etc) Python objects accross processes. You
> > can mimick clean Erlang-like concurrency with it. It is the future of
> > IPC on Desktop Unix. Given Python's crippled threading implementation,
> > it can play a role in making your Python applications scalable, with
> > regards to concurrency. I am recommending D-Bus because I have used it,
> > and I know it works. I didn't read this of a newsgroup or mailing list.
>
> It looks useful, but as far as I can tell, it's just another IPC
> thingie that works through sockets, sort of like pyro without the
> remote objects.  I don't see how it's related to Erlang-like
> concurrency (which means ultralightweight coroutines, not heavyweight
> Unix or Windows processes).  I think Python concurrency schemes get
> interesting when they at least share memory (like POSH).  Otherwise I
> think of them more as "distributed" than "concurrent".

What is revolutionary about Erlang's concurrency model isn't exactly
its light weight threads (Python already has a frame work that
implements something similar) but the fact that in Erlang each thread
behaves like a process and each thread communicates with each other via
message passing. In Erlang, threads do not share state information. So
all the limitations associated with concurrent programming in other
mainstream languages are absent in Erlang. Because threads behave like
processes and do not share state, Erlang allows you to create thousands
of threads easily without the drawbacks of thread locks. Each thread or
process manages its own state. Erlang then provides a protocol to allow
each thread to communicate with each other.

You can mimic this concept with a light weight event based IPC like
D-Bus. D-Bus supports message passing and signals. It also provides you
with an easy protocol that allows processes to talk to each other. You
are right when you say that D-Bus uses heavy processes while Erlang
uses light ones. But the robustness and scalability of Erlang's
concurrency model stems from the fact that Erlang's threads are not
really threads, but light weight processes that do not share state
information. In brief, Erlang's concurrency model is basically IPC
programming with light-weight processes. This is what I say you can
mimic with D-Bus albeit, unfortunately, with heavy-weight processes.

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


Re: Help me use my Dual Core CPU!

2006-09-18 Thread mystilleef

Paul Rubin wrote:
> "mystilleef" <[EMAIL PROTECTED]> writes:
> > I use D-Bus (Python). I recommend it. I don't know how cross platform
> > it is. However, it supports message passing of most built-in (strings,
> > ints, lists, dictionaries etc) Python objects accross processes. You
> > can mimick clean Erlang-like concurrency with it. It is the future of
> > IPC on Desktop Unix. Given Python's crippled threading implementation,
> > it can play a role in making your Python applications scalable, with
> > regards to concurrency. I am recommending D-Bus because I have used it,
> > and I know it works. I didn't read this of a newsgroup or mailing list.
>
> It looks useful, but as far as I can tell, it's just another IPC
> thingie that works through sockets, sort of like pyro without the
> remote objects.  I don't see how it's related to Erlang-like
> concurrency (which means ultralightweight coroutines, not heavyweight
> Unix or Windows processes).  I think Python concurrency schemes get
> interesting when they at least share memory (like POSH).  Otherwise I
> think of them more as "distributed" than "concurrent".

I always forget to bring up Stackless Python in this kinda discussions.
I haven't used, but I plan porting one of my projects to it.

http://www.stackless.com/about/sdocument_view

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


Re: Help

2006-09-18 Thread Larry Bates
Rrajal wrote:
> Hi there, I am new in this subject so could you please tell me from
> where I can get help (or good e-book) of python?
> 
Some books that helped me:

Python Bible by Dave Brueck and Stephen Tanner
Python Cookbook by Alex Martelli, Anna Martelli Revenscroft &
 David Ascher
Python programming on Win 32 by Mark Hammond & Andy Robinson

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


Re: Interfacing my chess client with GNU chess using python

2006-09-18 Thread Will McGugan

Varun Hiremath wrote:
> Hello,
>I have written a chess client using python which is a graphic
>interface to play chess. It is at present a two player version,
>players move their peices by clicking two squares on the board as
>in any other chess clients.
>Now i want to interface my program with the already available
>gnuchess program. Basically i want to feed the user input to the
>gnuchess and get the output and then display in my GUI. I have read
>about Popen but i couldn't figure out how to do it. Is there any
>other better ways of doing it. Any help would be appreciated.
>

The subprocess module may help you...

http://docs.python.org/dev/lib/module-subprocess.html


Will McGugan
--
http://www.willmcgugan.com

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


Re: Pythondocs.info : collaborative Python documentation project

2006-09-18 Thread Laurent Pointal
[EMAIL PROTECTED] wrote:

> Hi,
> 
> I am a bit disapointed with the current Python online documentation. I
> have read many messages of people complaining about the documentation,
> it's lack of examples and the use of complicated sentences that you
> need to read 10 times before understanding what it means.

I agree in some ways, Python docs could have better organization (more links
between related things).

> That's why I have started a collaborative project to make a user
> contributed Python documentation. The wiki is online here:
> http://www.pythondocs.info
> 
> This is a fresh new website, so there's not much on it, but I hope to
> make it grow quickly. Help and contributions are welcome; Please
> register and start posting your own documentation on it.
> 
> Regards,
> 
> Nicolas.
> -
> http://www.pythondocs.info

Here is another URL of such a project, i bookmarked some times:
http://www.simisen.com/jmg/cpd/
And there is nothing beyond this URL, like many of such projects.

AFAIR there is a starting of Wiki documentation - like PHP docs, one page
per function, contributors comments & Co, from one main Python developers
(dont remember who start this neither what is the URL).

In all case, dont setup another new system, use
http://wiki.python.org/moin/, at least your work will not be lost.

A+

Laurent.



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


Re: Code Golf Challenge : 1,000 Digits Of Pi

2006-09-18 Thread [EMAIL PROTECTED]

Carl Drinkwater wrote:
> Hi all,
>
> Code Golf's 12th challenge has just been added to the site.  It asks you
> to calculate the first 1,000 digits of Pi - Something I'm sure most of
> you have thought about, but never done.  You can see the challenge at :
>
>http://codegolf.com/1000-digits-of-pi
>
> For those who haven't heard of codegolf.com, it can be described as
> "allowing you to show off your code-fu by trying to solve coding
> problems using the least number of keystrokes."
>
> The site currently supports Perl, PHP, Python and Ruby with Scheme to
> (hopefully) follow soon.  Your entries are automatically executed and
> scored - No need to wait for someone to validate your code.
>
> Other challenges include implementing the Vigenere Cipher, Prime
> factors, SHA-256 Hashing as well as the obvious 99 Bottles Of Beer.  All
> of the challenges are competitive but there is still scope to well in
> them, even if you're new to the site.
>
> I hope some of you will find this interesting, and sorry for disturbing
> you if not!
>
> Have fun,
> Carl.

Here's a thought: for your next contest, why not issue a
  challenge to see who can write a scoreboard
  that actually works?



Overall:

This Challenge's Best Entries [View All]
(View the Overall | Perl | PHP | Python | Ruby leaderboard.)

Rank User   Size Language Score [?]
1st  primo   62  Ruby 10,000 (v12)
2nd  jix 65  Ruby  9,538 (v7)
3rd  MadOnion92  Ruby  6,739 (v4)
4th  jojo   112  Ruby  5,535 (v6)
5th  zeriod 134  Ruby  4,626 (v6)
6th  kmeyer 151  Ruby  4,105 (v3)
7th  dseverin   159  Ruby  3,899 (v7)
8th  bearophile 165  Python3,757 (v5)
9th  ToastyX167  Php   3,712 (v20)
10th Leafy  181  Php   3,425 (v8)


Perl:

This Challenge's Best Entries [View All]
(View the Overall | Perl | PHP | Python | Ruby leaderboard.)

Rank User   Size  Language Score [?]
1st  _W_  183 Perl 10,000 (v2)
2nd  jojo 524 Perl  3,492 (v2)
3rd  zeriod 1,009 Perl  1,813 (v7)


PHP:

This Challenge's Best Entries [View All]
(View the Overall | Perl | PHP | Python | Ruby leaderboard.)

Rank UserSize  Language Score [?]
1st  ToastyX   167 Php  10,000 (v20)
2nd  Leafy 181 Php   9,226 (v8)
3rd  jojo  539 Php   3,098 (v3)
4th  Theory660 Php   2,530 (v1)
5th  zeriod  1,002 Php   1,666 (v1)
6th  skauert 1,002 Php   1,666 (v1)
7th  Makan   1,002 Php   1,666 (v1)
8th  _W_ 1,002 Php   1,666 (v4)
9th  Stormx  1,004 Php   1,663 (v3)


Python:

This Challenge's Best Entries [View All]
(View the Overall | Perl | PHP | Python | Ruby leaderboard.)

Rank User   Size Language Score [?]
1st  primo   69  Python   10,000 (v11)
2nd  bearophile 165  Python4,181 (v5)
3rd  jojo   557  Python1,238 (v1)


Ruby:

This Challenge's Best Entries [View All]
(View the Overall | Perl | PHP | Python | Ruby leaderboard.)

Rank User Size Language Score [?]
1st  primo 62  Ruby 10,000 (v12)
2nd  jix   65  Ruby  9,538 (v7)
3rd  MadOnion  92  Ruby  6,739 (v4)
4th  jojo 112  Ruby  5,535 (v6)
5th  zeriod   134  Ruby  4,626 (v6)
6th  kmeyer   151  Ruby  4,105 (v3)
7th  dseverin 159  Ruby  3,899 (v7)
8th  will 544  Ruby  1,139 (v4)

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


Re: Help

2006-09-18 Thread Matimus
I have yet to find a language/community with better online
documentation. I taught myself with the Python tutorial found at
http://docs.python.org/tut/tut.html. I would look there first. If you
are new to programming altogether I think Python may still be a good
choice, but that may not be the _best_ reference.

Rrajal wrote:
> Hi there, I am new in this subject so could you please tell me from
> where I can get help (or good e-book) of python?

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


Could not build MySQLdb on PowerMac (PPC)

2006-09-18 Thread Ted Zeng
Hi,

I am new to Python. I am trying to build MySQLdb for my PowerPC
PowerMac.
I just downloaded the source last week and tried to build it.
But I got the error messages as follow. I checked and there is no such
files as 
mysql_config
mysql.h
my_config.h
...

Did I download the wrong source?

python setup.py build

sh: line 1: mysql_config: command not found
...(same as above for a few lines)
running build
running build_py
copying MySQLdb/release.py -> build/lib.macosx-10.4-fat-2.4/MySQLdb
running build_ext
building '_mysql' extension
gcc -arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk
-fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-madd
-fno-common -dynamic -DNDEBUG -g -O3
-I/Library/Frameworks/Python.framework/Versions/2.4/include/python2.4 -c
_mysql.c -o build/temp.macosx-10.4-fat-2.4/_mysql.o
-Dversion_info="(1,2,1,'final',2)" -D__version__="1.2.1_p2"
_mysql.c:39:19:_mysql.c:39:19: error: mysql.h: No such file or directory
_mysql.c:40:23: error: my_config.h: No such file or directory
_mysql.c:41:26: error: mysqld_error.h: No such file or directory
_mysql.c:42:20: error:  error: mysql.h: No such file or directory
_mysql.c:40:23: error: my_config.h: No such file or directory
errmsg.h: No such file or directory
_mysql.c:41:26:_mysql.c:72: error: parse error before 'MYSQL'
_mysql.c:72: warning: no semicolon at end of struct or union
_mysql.c:75: error: parse error before '}' token
_mysql.c:75: warning: data definition has no type or storage class
_mysql.c:86: error: parse error before 'MYSQL_RES'


Ted Zeng
Adobe Systems Incorporated
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pythondocs.info : collaborative Python documentation project

2006-09-18 Thread Laurent Pointal
[EMAIL PROTECTED] wrote:

> Hi,
> 
> I am a bit disapointed with the current Python online documentation. I
> have read many messages of people complaining about the documentation,
> it's lack of examples and the use of complicated sentences that you
> need to read 10 times before understanding what it means.
> 
> That's why I have started a collaborative project to make a user
> contributed Python documentation. The wiki is online here:
> http://www.pythondocs.info
> 
> This is a fresh new website, so there's not much on it, but I hope to
> make it grow quickly. Help and contributions are welcome; Please
> register and start posting your own documentation on it.
> 
> Regards,
> 
> Nicolas.
> -
> http://www.pythondocs.info

You're realy nor the first one, see
http://mail.python.org/pipermail/python-list/2004-May/219580.html
(and following thread)

Other (never achieved) projects... http://www.pythondocs.org/

Even Skip Montanaro python-glossary site seem to not have been continued...
http://mail.python.org/pipermail/python-list/2004-May/219682.html


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


Re: Creating database structures in a portable way

2006-09-18 Thread Samuel
> FWIW, there's a Python port of adodb:
> http://phplens.com/lens/adodb/adodb-py-docs.htm
>
> and parsing XML in Python is quite easy. So you could as well port the
> AdoDB XML to Python too.

That is exactly what I am trying to avoid. While implementing the
parser might be easy, you have to translate things into different
database flavors, caring about a bunch of things that I'd rather not
have to think about.

> OTOH, there are other - possibly better (YMMV) - DB abstraction layers
> in Python, like SQLAlchemy.

SQLAlchemy looks pretty good, but unfortunately apparently requires
shell access for installation (or at least, I have not found any other
solution covered in the docs), which I can not use. I need a solution
that can be shipped in a software package, and installed by simply
copying it to the server.

> And since the above solution requires
> (re)writing the xml-parsing part, it might be worth rewriting it so it
> knows how to generate SQLAlchemy schemas instead.

Rewriting the schema is possible (I only want to keep it separated from
the code), so using SQLAlchemy's built in solution for generating
tables seems just fine. It's only the installation part.

Anyway, I am wondering; Python seems to include database adapters for
almost any important database, all with a unified API. Why would you
need another database abstraction on top of that?

Thanks,
-Samuel

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


PyPy Sprint Announcement, Duesseldorf 30 Oct - 5 Nov

2006-09-18 Thread Carl Friedrich Bolz
Hi all!

The next PyPy sprint will be held in the Computer Science department of
Heinrich-Heine Universitaet Duesseldorf from the 30th of October to the
5th of November 2006.

Topics and goals


The topics of the sprints are not fixed yet.  We will progress on the
subjects that we are currently working on, while giving a special
priority to any topic that "non-core" people find interesting.  There
are many topics that could fit both category :-)  Here are some
examples:

* Just-In-Time work.  Two sub-topics:

  - write and/or optimize a machine-code backend (we have 386 only so
far)
  - work on turning simple interpreters into JIT compilers (we cannot do
this for the whole of the PyPy interpreter yet, we're getting there
small step by small step).

* Optimization of core Python data types, making full
  use of PyPy's flexible architecture and python-implemented (and then
  translated) type system.  (We have already various dict and str
  implementations.)

* "Next-step stuff" that will requires some thinking and design:

  - distribution (where a single program runs on multiple machines)
  - persistence (save an "image" of a running program, or a part of it)
  - security (in many possible senses of the word)

* Working on py.test testing tool:

  - py.test recently grew some distribution features which are still
rough around the edges and could use improvement

  - there are some more ideas for features of py.test around, like
adding profiling capabilities (and more)

* Work on the PyPy build tool: There are some plans to provide a tool
  that allows one to flexibly configure PyPy and to also request builds
  from a set of build servers. If there is interest there could be work
  in this area.

* and as always, there is the topic of implementing or completing core
  extension modules (e.g. socket...).  This is hacking with a mix of
  ctypes and RPython.


Location


The sprint will (probably) take place in a seminar room of the geography
department (which is getting assimilated by the cs department and is
below it).  It is in the building 25.12 of the university campus. For
travel instructions see

http://stups.cs.uni-duesseldorf.de/anreise/esbahn.php

Registration


If you'd like to come, please subscribe to the `pypy-sprint mailing
list`_ and drop a note about your interests and post any questions.
More organisational information will be send to that list.  We'll keep a
list of `people`_ which we'll update (which you can do so yourself if
you have codespeak commit rights).

.. _`pypy-sprint mailing list`:
http://codespeak.net/mailman/listinfo/pypy-sprint
.. _`people`:
http://codespeak.net/pypy/extradoc/sprintinfo/ddorf2006b/people.html



Cheers,

Carl Friedrich Bolz & the PyPy team



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


Re: Code Golf Challenge : 1,000 Digits Of Pi

2006-09-18 Thread Paddy

Carl Drinkwater wrote:

> For those who haven't heard of codegolf.com, it can be described as
> "allowing you to show off your code-fu by trying to solve coding
> problems using the least number of keystrokes."
Is having good 'code-fu' worthwhile? It may be trivial to score but do
the results show who iss the better programmer?

Methinks I'll pass.

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


Re: Help

2006-09-18 Thread BartlebyScrivener
Rrajal wrote:
> Hi there, I am new in this subject so could you please tell me from
> where I can get help (or good e-book) of python?

You don't provide much info about where you are in your learning cycle.
New to programming? New to Python? Both?

If you do use the Tutorial, use the newest version:

http://docs.python.org/dev/tut/tut.html

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


Re: Help

2006-09-18 Thread Wildemar Wildenburger
Matimus wrote:
>> Hi there, I am new in this subject so could you please tell me from
>> where I can get help (or good e-book) of python?
> 
http://www.diveintopython.org/
That did the trick for me. It is, however, "a Python book for 
experienced programmers" (quoted from website). Not too tough, but if 
you have no clue of programming at all, maybe have a look at

http://ibiblio.org/obp/thinkCS/python.php
It called "How to Think Like a Computer Scientist" (the title sounds 
dryer than the book really is, trust me). Very good as well.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Could not build MySQLdb on PowerMac (PPC)

2006-09-18 Thread Diez B. Roggisch
Ted Zeng schrieb:
> Hi,
> 
> I am new to Python. I am trying to build MySQLdb for my PowerPC
> PowerMac.
> I just downloaded the source last week and tried to build it.
> But I got the error messages as follow. I checked and there is no such
> files as 
> mysql_config
> mysql.h
> my_config.h
> ...
> 
> Did I download the wrong source?

You need the mysql development files. You could e.g. use fink to install 
mysql and the development files package. On my machine it's called 
mysql14-dev.


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


newbie division question

2006-09-18 Thread David Isaac
Suppose x and y are ints in moduleA.

If I put
from __future__ import division
in moduleA then x/y will produce the truediv result.

If I put
from __future__ import division
in moduleB
and
from moduleB import *
in module A
then x/y will NOT produce the truediv result
(in moduleA).

Why?
And is there some way to avoid importing
from __future__ in module after module?

Thanks,
Alan Isaac


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


Re: Code Golf Challenge : 1,000 Digits Of Pi

2006-09-18 Thread bearophileHUGS
Paddy:
> Is having good 'code-fu' worthwhile? It may be trivial to score but do
> the results show who iss the better programmer?

With Python you can't win, because Perl and Ruby allow for shorter
programs.
Beside the language, you win if you can invent more tricks, that you
have to avoid in real code, because it must be very readable.
The positive side of this game is that you exercise yourself, so you
get to know the programming language better, and you learn all the
corner cases of your language. Knowing them is useful, to avoid them
when you program for real, to avoid some kind of bugs generated by
corner cases.

Bye,
bearophile

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


python and snmp

2006-09-18 Thread Nicolas Miyasato
Hi all, I was just wondering if someone here had any experience with
some of these implementations of the snmp protocol?

pysnmp, libsnmp, snmpy.

Does anybody know of another implementation?

thanks in advance!!!

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


PIL PSDraw textsize method

2006-09-18 Thread Bauke Veenstra
Running the example from the excellent PIL handbook gives an error,
after these two lines:
ps.setfont("HelveticaNarrow-Bold", 36)
w, h, b = ps.textsize(title)
AttributeError: PSDraw instance has no attribute 'textsize'

Can someone tell me what's wrong, this error occurred on my Linux and on
my Windows system.

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


Re: newbie division question

2006-09-18 Thread casevh
David Isaac wrote:
> Suppose x and y are ints in moduleA.
>
> If I put
> from __future__ import division
> in moduleA then x/y will produce the truediv result.
>
> If I put
> from __future__ import division
> in moduleB
> and
> from moduleB import *
> in module A
> then x/y will NOT produce the truediv result
> (in moduleA).
>
> Why?
The statement "from __future__ import division" in ModuleB influences
the byte codes generated when ModuleB is compiled. It doesn't influence
the byte code generated in ModuleA.
> And is there some way to avoid importing
> from __future__ in module after module?
Start python with the "-Qnew" option.
> 
> Thanks,
> Alan Isaac

casevh

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


why a main() function?

2006-09-18 Thread beliavsky
I think I read a suggestion somewhere to wrap the code where a Python
script starts in a main() function, so one has

def main():
print "hi"

main()

instead of

print "hi"

What are the advantages of doing this?

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


Cross-process dictionary/hashtable

2006-09-18 Thread Sandra-24
A dictionary that can be shared across processes without being
marshaled?

Is there such a thing already for python?

If not is there one for C maybe?

I was just thinking how useful such a thing could be. It's a great way
to share things between processes. For example I use a cache that
subclasses a dictionary. It would be trivial to modify it to work
across processes by changing the base class and the locking mechanism.

Thanks,
-Sandra

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


Re: Code Golf Challenge : 1,000 Digits Of Pi

2006-09-18 Thread Paul McGuire
<[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Paddy:
>> Is having good 'code-fu' worthwhile? It may be trivial to score but do
>> the results show who iss the better programmer?
>
> With Python you can't win, because Perl and Ruby allow for shorter
> programs.
> Beside the language, you win if you can invent more tricks, that you
> have to avoid in real code, because it must be very readable.
> The positive side of this game is that you exercise yourself, so you
> get to know the programming language better, and you learn all the
> corner cases of your language. Knowing them is useful, to avoid them
> when you program for real, to avoid some kind of bugs generated by
> corner cases.
>
> Bye,
> bearophile
>

Success lies in the journey, not the destination.

or in Yoda-speak:

In the journey success lies, in the destination not.

-- Paul


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


Threads blocking on OpenBSD w/ Python 2.4.2

2006-09-18 Thread [EMAIL PROTECTED]
I'm attempting to write a faily simple threaded app that fires off a
thread to select() on a FIFO while the main loop handles data read from
that pipe and a few other tasks.  For some reason, calls to
time.sleep() seem to block until the first time data is dumped into the
pipe.  Clearly, I could work around this quite easily by "priming the
pipe" as it were with a bit of garbage data.  However, I'd rather
understand the problem.

Here's a code snippet:

===
ipList = []

def readPipe(pipeName):
p = file(pipeName, 'r')
while True:
x = select.select([p.fileno()], [], [])
dataLine = p.readline()
ipList.append(dataLine)

def main():
if not os.path.exists('bob'):
os.mkfifo('bob')
print "FIFO created."
print "Starting thread."
thread.start_new_thread(readPipe, ('bob',))
print "Thread started."
while True:
print time.time()
time.sleep(1)
===

On Linux and OS X, this behaves as expected.  Running the code
immediately produces output like this:

tarja:~ ben$ ./mycapd
Starting thread.
Thread started.
1158608481.67 []
1158608482.67 []
1158608483.67 []
...

But on OpenBSD I get this:

[ [EMAIL PROTECTED] ] $ ./mycapd
Starting thread.
Thread started.
1158608528.5 []

And there it hangs until I dump some data into the fifo.  Then it runs
as expected, dumping out a timestamp every second.

So the question is this:  Am I doing something wrong or is there a
problem on OpenBSD?

-Ben

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


Re: why a main() function?

2006-09-18 Thread [EMAIL PROTECTED]

[EMAIL PROTECTED] wrote:
> I think I read a suggestion somewhere to wrap the code where a Python
> script starts in a main() function, so one has
>
> def main():
> print "hi"
>
> main()
>
> instead of
>
> print "hi"
>
> What are the advantages of doing this?


I'm sure there are other reasons, but for me the most important is that
you can import your code into the interpreter and poke at it from there
without executing the script.  Also, of course, you can re-use your
code as a module in another program.

-Ben

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


Re: newbie division question

2006-09-18 Thread David Isaac
> Alan Isaac wrote:
> > Suppose x and y are ints in moduleA.
> >
> > If I put
> > from __future__ import division
> > in moduleA then x/y will produce the truediv result.
> >
> > If I put
> > from __future__ import division
> > in moduleB
> > and
> > from moduleB import *
> > in module A
> > then x/y will NOT produce the truediv result
> > (in moduleA).

<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> The statement "from __future__ import division" in ModuleB influences
> the byte codes generated when ModuleB is compiled. It doesn't influence
> the byte code generated in ModuleA.
> Start python with the "-Qnew" option.


That is pretty good,
but it affects every module I use,
not just my (selected) modules.

Thanks,
Alan

PS Any news on when true division will be the default?


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


Re: Cross-process dictionary/hashtable

2006-09-18 Thread Rob Wolfe
"Sandra-24" <[EMAIL PROTECTED]> writes:

> A dictionary that can be shared across processes without being
> marshaled?
>
> Is there such a thing already for python?

Check this out:

http://poshmodule.sourceforge.net/

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


Re: Cross-process dictionary/hashtable

2006-09-18 Thread Calvin Spealman
On 18 Sep 2006 12:44:32 -0700, Sandra-24 <[EMAIL PROTECTED]> wrote:
> A dictionary that can be shared across processes without being
> marshaled?
>
> Is there such a thing already for python?
>
> If not is there one for C maybe?
>
> I was just thinking how useful such a thing could be. It's a great way
> to share things between processes. For example I use a cache that
> subclasses a dictionary. It would be trivial to modify it to work
> across processes by changing the base class and the locking mechanism.
>
> Thanks,
> -Sandra

Maybe what you want is something like memcache
(http://cheeseshop.python.org/pypi/memcached), which offers a basic
in-memory, key-value share that processes (even on different boxes)
can connect to. Of course, as with any kind of concurrent work, its
going to be far easier to have some restrictions, which memcache has.
For example, full python objects being shared isn't a great idea, or
even possible in many situations. The closest you could get with
something like memcache is to wrap it up in a dictionary-like object
and have it pickle things coming in and out, but that won't work for
everying and has security concerns.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: why a main() function?

2006-09-18 Thread Calvin Spealman
On 18 Sep 2006 12:40:00 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> I think I read a suggestion somewhere to wrap the code where a Python
> script starts in a main() function, so one has
>
> def main():
> print "hi"
>
> main()
>
> instead of
>
> print "hi"
>
> What are the advantages of doing this?

It is useful both importating scripts without running them, for
debugging or reusing parts of them later, and also for adding small
test scripts to modules to allow them to be run for testing purposes.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: why a main() function?

2006-09-18 Thread Benjamin Niemann
[EMAIL PROTECTED] wrote:

> I think I read a suggestion somewhere to wrap the code where a Python
> script starts in a main() function, so one has
> 
> def main():
> print "hi"
> 
> main()
> 
> instead of
> 
> print "hi"
> 
> What are the advantages of doing this?

Refine this to:

def main():
print "hi"

if __name__ == "__main__":
main()

The advantage of the 'if __name__ ..' statement is that you can import the
script without running the 'main' code, e.g. from your unittest module.

Wrapping the main code in a function allows you to call this function from
your unittests and test it like any other function.

Additionally I do usually add an 'argv' argument to main() which I use
instead of sys.argv, so I can easily test it with different arguments.

-- 
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://pink.odahoda.de/
-- 
http://mail.python.org/mailman/listinfo/python-list


How to find number of characters in a unicode string?

2006-09-18 Thread Preben Randhol
Hi

If I use len() on a string containing unicode letters I get the number
of bytes the string uses. This means that len() can report size 6 when
the unicode string only contains 3 characters (that one would write by
hand or see on the screen). Is there a way to calculate in characters
and not in bytes to represent the characters.

The reason for asking is that PyGTK needs number of characters to set
the width of Entry widgets to a certain length, and it expects viewable
characters and not number of bytes to represent them.


Thanks in advance


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


Re: How to find number of characters in a unicode string?

2006-09-18 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>,
Preben Randhol wrote:

> If I use len() on a string containing unicode letters I get the number
> of bytes the string uses. This means that len() can report size 6 when
> the unicode string only contains 3 characters (that one would write by
> hand or see on the screen). Is there a way to calculate in characters
> and not in bytes to represent the characters.

Yes and you already seem to know the answer:  Decode the byte string and
use `len()` on the unicode string.

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


Re: How to find number of characters in a unicode string?

2006-09-18 Thread faulkner
are you sure you're using unicode objects?
len(u'\u') == 1
the encodings module should help you turn '\xff\xff' into u'\u'.

Preben Randhol wrote:
> Hi
>
> If I use len() on a string containing unicode letters I get the number
> of bytes the string uses. This means that len() can report size 6 when
> the unicode string only contains 3 characters (that one would write by
> hand or see on the screen). Is there a way to calculate in characters
> and not in bytes to represent the characters.
>
> The reason for asking is that PyGTK needs number of characters to set
> the width of Entry widgets to a certain length, and it expects viewable
> characters and not number of bytes to represent them.
> 
> 
> Thanks in advance
> 
> 
> Preben

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


Re: newbie division question

2006-09-18 Thread casevh

> PS Any news on when true division will be the default?

Python 3.0 (aka P3K). It is the release that can break backwards
compatibility.

http://www.python.org/dev/peps/pep-3000/

casevh

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


Re: newbie division question

2006-09-18 Thread Paul McGuire
<[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
>
>> PS Any news on when true division will be the default?
>
> Python 3.0 (aka P3K). It is the release that can break backwards
> compatibility.
>
> http://www.python.org/dev/peps/pep-3000/
>
> casevh
>

Yes, Break Backwards Compatibility is a Level 60 spell, reserved for Night 
Elf mages.

-- Paul


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


Re: why a main() function?

2006-09-18 Thread Steve Holden
[EMAIL PROTECTED] wrote:
> I think I read a suggestion somewhere to wrap the code where a Python
> script starts in a main() function, so one has
> 
> def main():
> print "hi"
> 
> main()
> 
> instead of
> 
> print "hi"
> 
> What are the advantages of doing this?
> 
Guido van Rossum himself can tell you:

   http://www.artima.com/forums/flat.jsp?forum=106&thread=4829

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Skype: holdenweb   http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

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


Re: Code Golf Challenge : 1,000 Digits Of Pi

2006-09-18 Thread Paddy

Paul McGuire wrote:

> Success lies in the journey, not the destination.
>
> or in Yoda-speak:
>
> In the journey success lies, in the destination not.
>
> -- Paul
Ah, I always wondered what lemmings thought , before splat!!! :-)

- Pad.

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


Re: newbie division question

2006-09-18 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Paul McGuire wrote:

> <[EMAIL PROTECTED]> wrote in message 
> news:[EMAIL PROTECTED]
>>
>>> PS Any news on when true division will be the default?
>>
>> Python 3.0 (aka P3K). It is the release that can break backwards
>> compatibility.
>>
>> http://www.python.org/dev/peps/pep-3000/
>>
>> casevh
>>
> 
> Yes, Break Backwards Compatibility is a Level 60 spell, reserved for Night 
> Elf mages.

But new keywords certainly can make it into 2.x releases.  Only Level 10
spells?  :-)

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


Re: why a main() function?

2006-09-18 Thread bearophileHUGS
Others have already told you the most important things.

There is another secondary advantage: the code inside a function runs
faster (something related is true for C programs too). Usually this
isn't important, but for certain programs they can go 20%+ faster.

Bye,
bearophile

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


Re: Creating database structures in a portable way

2006-09-18 Thread Bruno Desthuilliers
Samuel a écrit :
>>FWIW, there's a Python port of adodb:
>>http://phplens.com/lens/adodb/adodb-py-docs.htm
>>
>>and parsing XML in Python is quite easy. So you could as well port the
>>AdoDB XML to Python too.
> 
> 
> That is exactly what I am trying to avoid. While implementing the
> parser might be easy, you have to translate things into different
> database flavors, caring about a bunch of things that I'd rather not
> have to think about.

This I can understand pretty well - hence my suggestion of using 
SQLAlchemy instead.

> 
>>OTOH, there are other - possibly better (YMMV) - DB abstraction layers
>>in Python, like SQLAlchemy.
> 
> 
> SQLAlchemy looks pretty good, but unfortunately apparently requires
> shell access for installation (or at least, I have not found any other
> solution covered in the docs), which I can not use. I need a solution
> that can be shipped in a software package, and installed by simply
> copying it to the server.

It doesn't use binaries AFAIK, so just copying should work as well.

> 
>>And since the above solution requires
>>(re)writing the xml-parsing part, it might be worth rewriting it so it
>>knows how to generate SQLAlchemy schemas instead.
> 
> Rewriting the schema is possible (I only want to keep it separated from
> the code),

Why ? Isn't your code supposed to use it ?

> so using SQLAlchemy's built in solution for generating
> tables seems just fine. It's only the installation part.

cf above.

> Anyway, I am wondering; Python seems to include database adapters for
> almost any important database, all with a unified API. Why would you
> need another database abstraction on top of that?

A first point is that the DB-API doesn't hide the differences between 
various SQL dialects. A second point is that DB-API requires you to 
embed SQL statements as strings, while SQLAlchemy allow you to build 
your SQL queries in pure Python. (and FWIW, if using an existing DB, you 
don't even have to describe the schema a second time to use it). Well, 
just start playing with it, and I really doubt you'll want to come back 
to the embedded hand-written SQL !-)

My 2 cents
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Code Golf Challenge : 1,000 Digits Of Pi

2006-09-18 Thread Paul Rubin
[EMAIL PROTECTED] writes:
> With Python you can't win, because Perl and Ruby allow for shorter
> programs.

Python has native bignums, which should simplify a program like this
enormously.  I don't know if Ruby has them.  Perl doesn't, and if you
use some CPAN library that simulates them, that should count as part
of your program size.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Code Golf Challenge : 1,000 Digits Of Pi

2006-09-18 Thread Paddy

Paul Rubin wrote:
> [EMAIL PROTECTED] writes:
> > With Python you can't win, because Perl and Ruby allow for shorter
> > programs.
>
> Python has native bignums, which should simplify a program like this
> enormously.  I don't know if Ruby has them.  Perl doesn't, and if you
> use some CPAN library that simulates them, that should count as part
> of your program size.

Unfortunately:

$ perl -Mbignum -e 'print
1234567890123456789012345678901234567890,"\n"'
1234567890123456789012345678901234567890

HP [EMAIL PROTECTED] /cygdrive/c/Documents and Settings/All
Users/Documents/Python tutorial
$ perl -v

This is perl, v5.8.7 built for cygwin-thread-multi-64int
(with 1 registered patch, see perl -V for more detail)


Yep my standard Cygwin perl installation for windows includes the
bignum package.

- Paddy.

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


Which date will it be 'over x days'?

2006-09-18 Thread cyberco
I must be overlooking something since I can't find a simple way to
calculate which date it will be over, say, 9 days. I checked the
datetime, time and calendar modules, but none of them seem to have a
function to calculate the time offset.

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


Re: [ANN] Code Golf Challenge : 1,000 Digits Of Pi

2006-09-18 Thread Calvin Spealman
On 9/18/06, Carl Drinkwater <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> Code Golf's 12th challenge has just been added to the site.  It asks you
> to calculate the first 1,000 digits of Pi - Something I'm sure most of
> you have thought about, but never done.  You can see the challenge at :
>
>http://codegolf.com/1000-digits-of-pi
>
> For those who haven't heard of codegolf.com, it can be described as
> "allowing you to show off your code-fu by trying to solve coding
> problems using the least number of keystrokes."
>
> The site currently supports Perl, PHP, Python and Ruby with Scheme to
> (hopefully) follow soon.  Your entries are automatically executed and
> scored - No need to wait for someone to validate your code.
>
> Other challenges include implementing the Vigenere Cipher, Prime
> factors, SHA-256 Hashing as well as the obvious 99 Bottles Of Beer.  All
> of the challenges are competitive but there is still scope to well in
> them, even if you're new to the site.
>
> I hope some of you will find this interesting, and sorry for disturbing
> you if not!
>
> Have fun,
> Carl.

Just once, I would like to see a programming contest that was judged
on the quality of your code, not the number of bytes you managed to
incomprehensively hack it down to.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Cheese Shop Registration error

2006-09-18 Thread Richard Jones
[EMAIL PROTECTED] wrote:
> The Key ID that the kgpg shows. I tried to paste the key returned by
> the quiery on the keyserver. but it also doesn't work. I tried
> everything that has any connection with the key, but everything fails.
> 
> By the way the key is: 6A61E3AD

Here is the code that could generate that error message:

if len(gpgid) != 8:
raise FormError, 'GPG key ID is invalid'
try:
int(gpgid)
except ValueError:
raise FormError, 'GPG key ID is invalid'

So I suspect there might have been some cut-n-paste error. Check that you've
not pasted in any whitespace that could confuse the first test.


Richard

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


Re: Problem with operator overloading and inheritance in Python

2006-09-18 Thread Calvin Spealman
On 9/18/06, Edward Waugh <[EMAIL PROTECTED]> wrote:
> I quickly glanced at Guido's paper of new-style classes and I am puzzled
> because the definition of a new-style class looks exactly the same as that
> for the classic classes: class []:  the class>.
>
> How do I define new-style classes?
>
> - Edward
>
>
> Original Message Follows
> From: "Calvin Spealman" <[EMAIL PROTECTED]>
> Reply-To: [EMAIL PROTECTED]
> To: "Edward Waugh" <[EMAIL PROTECTED]>
> Subject: Re: Problem with operator overloading and inheritance in Python
> Date: Mon, 18 Sep 2006 17:06:53 -0400
>
> On 9/18/06, Edward Waugh <[EMAIL PROTECTED]> wrote:
> >Tried this and it didn't work:
> >
> >C:\Files\Python> problem.py
> >Traceback (most recent call last):
> >   File "C:\Files\Python\problem.py", line 21, in ?
> > x += 1
> >   File "C:\Files\Python\problem.py", line 7, in __add__
> > return type(self)(self.data + value)
> >TypeError: instance() argument 1 must be classobj, not int
> >
> >But then in a moment of inspiration I tried self.__class__(self.data +
> >value) and it worked:
>
> Sorry, I neglected to consider that you might be using old-style
> classes! For any old-style class, type(someInstance) is always the
> instance type, where as new-style classes actually give yuou the class
> itself! So either you need to do what you have done now or learn about
> and move to new-style classes. Usually you can just inherit your base
> classes from object and you wont have any trouble.

They are syntactically the same, but the difference is in some subtle
behaviors related to some lookup rules in various situations, like the
dropping of the instance type. By inheriting from object, the base
new-style class, you cause your class to become a new-style class.
This should all have been covered in anything you read.

# Old-Style
class foo:
pass

# New-Style
class foo(object):
pass
-- 
http://mail.python.org/mailman/listinfo/python-list


Zenoss Version 0.22.3 Available

2006-09-18 Thread Drew Bray
09-18-2006

Announcing Zenoss Version 0.22.3

All,

Version 0.22.3 of Zenoss is available for download. Version 0.22.3 is  
a dot release of version 0.22.0, which added several new features,  
including:

* Support for Nagios Plugins (zenagios)
* Addition of a GUI for the selection of Alerting Rules
* Adds Email alerts with configurable body text
* Automated maintenance windows
* Allows the assignment of users to the systems they manage

Zenoss Version 0.22.3 provides several minor bug fixes and  
enhancements, including:

* Use of latin-1 encoding when calling xml-rpc
* Improved handling of Unicode items
* Repaired bad zenagios heartbeat timeout
* Corrected zenagios unpack of config (component and eventKey were  
backward)
* Take off newline when reading configfile values
* Fixed additional date-time zone problems

Download Links:
* Source: http://www.zenoss.org/download/latest/src
* Zenwin: http://www.zenoss.org/download/latest/zenwin
* Documentation: http://www.zenoss.org/download/latest/docs
* Release Notes: http://www.zenoss.org/download/latest/relnotes

Project Blurb:
Zenoss is Python-based, network/systems monitoring application that  
offers a single integrated package for end to end monitoring  
(discovery, configuration, availability, performance, events, alerts)  
of resources across the stack (servers, applications, networks,  
environment, etc...).

Zenoss was recognized as one of the "Top 10 Open Source Projects to  
Watch" by Network World in August of 2006.  (http://www.zenoss.org/ 
about/news_items/articles/nw-10towatch)

Zenoss is currently hiring talented Zope & Python developers.  Join  
the team!
http://www.zenoss.org/jobs.

Enjoy,

Drew
Project Zenoss
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Which date will it be 'over x days'?

2006-09-18 Thread John Machin
cyberco wrote:
> I must be overlooking something since I can't find a simple way to
> calculate which date it will be over, say, 9 days. I checked the
> datetime, time and calendar modules, but none of them seem to have a
> function to calculate the time offset.

I suppose that it depends on your thresholds for "simple" and "seem"
but datetime.timedelta() does it for me:

| >>> import datetime
| >>> datetime.date.today()
| datetime.date(2006, 9, 19)
| >>> datetime.date.today() + datetime.timedelta(days=9)
| datetime.date(2006, 9, 28)
| >>>

http://docs.python.org/lib/datetime-timedelta.html

HTH,
John

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


gnome module

2006-09-18 Thread Jay
Am I correct in assuming that I can use the gnome module to minimize
all windows (aka show desktop)?  If so, how?

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


Re: Cheese Shop Registration error

2006-09-18 Thread John Machin

Richard Jones wrote:
> [EMAIL PROTECTED] wrote:
> > The Key ID that the kgpg shows. I tried to paste the key returned by
> > the quiery on the keyserver. but it also doesn't work. I tried
> > everything that has any connection with the key, but everything fails.
> >
> > By the way the key is: 6A61E3AD
>
> Here is the code that could generate that error message:
>
> if len(gpgid) != 8:
> raise FormError, 'GPG key ID is invalid'
> try:
> int(gpgid)

| >>> int("6A61E3AD")
Traceback (most recent call last):
  File "", line 1, in ?
ValueError: invalid literal for int(): 6A61E3AD
| >>> int("6A61E3AD", 16)
1784800173

What am I missing?

> except ValueError:
> raise FormError, 'GPG key ID is invalid'
>
> So I suspect there might have been some cut-n-paste error. Check that you've
> not pasted in any whitespace that could confuse the first test.
> 

Cheers,
John

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


How to efficiently proceed addition and subtraction in python list?

2006-09-18 Thread Daniel Mark
Hello all:

I have a list AAA = [1, 2, 3] and would like to subtract one from list
AAA
so AAA' = [0, 1, 2]

What should I do?


Thank you
-Daniel

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


Re: How to efficiently proceed addition and subtraction in python list?

2006-09-18 Thread Tim Chase
> I have a list AAA = [1, 2, 3] and would like to subtract one from list
> AAA
> so AAA' = [0, 1, 2]
> 
> What should I do?


Sounds like a list comprehension to me:

 >>> a = [1,2,3]
 >>> a_prime = [x-1 for x in a]
 >>> a_prime
[0, 1, 2]

-tkc



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


Message dialog on 'focus-out-event'

2006-09-18 Thread Tuomas
import pygtk, gtk, gobject, ...

class MyEntry(gtk.Entry):
 def __init__(self, is_OK):
 gtk.Entry.__init__(self)
 self.is_OK=is_OK
 self.add_events(gtk.gdk.FOCUS_CHANGE)
 self.focus_out_id=self.connect('focus-out-event',
self.on_focus_out)

 def on_focus_out(self, sender, event):
 if self.is_OK(self.get_text()): return False
 else:
 # don't want another focus-out-event because of show_message
 self.disconnect(self.focus_out_id)
 # self.grab_focus()
 show_message("Wrong value for entry")
 self.focus_out_id=self.connect('focus-out-event',
self.on_focus_out)
 return False

 # Leaving focus in not_OK case results:

 # GtkWarning: GtkEntry - did not receive focus-out-event.
 # If you connect a handler to this signal, it must return
 # FALSE so the entry gets the event as well

 # The required False is given, but may be the messagebox
 # times it out.

 # My second trial was to include self.grab_focus() before
 # show_message, but it gives focus to the toplevel
 # gtk.gdk.Window and I lose access to the entry.

 # Any suggestions?
 # Tuomas Vesterinen
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help me use my Dual Core CPU!

2006-09-18 Thread Michael Sparks
Paul Rubin wrote:
> "Ramon Diaz-Uriarte" <[EMAIL PROTECTED]> writes:
> > You might also want to check
> > http://www.lindaspaces.com/products/NWS_overview.html
> > by the guys who "invented" Linda.
>
> Cool, I guess.
>
> > (The Oz language/Mozart system is a good example of a different and
> > very neat approach to concurrency; somewhat similar Python solutions
> > can be found at Kamaelia and Candygram. Links and other stuff at:
>
> I looked at these.  Oz/Mozart is a whole nother language, worth
> examining for its ideas, but the implementation is quite slow.
> Kamaelia doesn't attempt concurrency at all.  Its main idea is to use
> generators to simulate microthreads.

Regarding Kamaelia, that's not been the case for over a year now.

We've had threaded components as well as generator based ones since
around last July, however their API stablised properly about 4 months
back. If you use C extensions that release the GIL and are using an OS
that puts threads on different CPUs then you have genuine concurrency.
(those are albeit some big caveats, but not uncommon ones in python).

Also integrating things as a sub process is as simple instantiating a
component that talks to the subprocess over stdin/out to the
inbox/outbox model of Kamaelia and then just using it. Something
concrete this is useful for:
mencoder_options = "-ovc lavc -oac mp3lame -ffourcc DX50 -lavcopts
acodec=mp3:vbitrate=200:abitrate=128 -vf scale=320:-2 -"
...#  assume 'encodingfile' is defined above
Pipeline( DVB_TuneToChannel(channel="BBC ONE",fromDemuxer="MUX1"),
  UnixProcess("mencoder -o "+encodingfile+"
"+mencoder_options)
).run()

On a dual CPU machine that code does indeed both use CPUs (as you'd
want and expect).

Also whilst we haven't had the chance to implement OS level process
based components, that doesn't mean to say we're not interested in
them, it's just that 2 people have to focus on something so we've been
focussed on building things using the system rather than fleshing out
the concurrently. To say we don't attempt implies that we don't want to
go down these routes of adding in genuine concurrency. (Which is really
why I'm replying - that's not the case - I do want to go down these
routes, and it's more man-hours than desire that are the issue).

Personally, I'm very much in the camp that says "shared data is
invariably a bad idea unless you really know what you're doing"
(largely because it's the most common source of bugs for people where
they're trying to do more than one thing at a time). People also
generally appear to find writing threadsafe code very hard. (not
everyone, just the people who aren't at the top end of the bell curve
for writing code that does more than one thing at a time)

This is why Kamaelia is message based (ie it's a concious choice in
favour), except for certain types of data (where we have a linda-esque
type system for more systemic information). The reason for this is to
help the average programmer from shooting himself in his own foot (with
a 6 CPU-barrelled shotgun :-).

In terms of how this is *implemented* however, we have zero copying of
data (except to/from threads at the moment) and so data is shared
directly, but in a location the user of the system thinks its natural
to have handoff to someone else. This approach we find tends to
encourage arbitration of access to shared resources, which IMO is a
good (defensive) approach to avoiding the problems people have with
shared resources.

But if it turns out our approach sucks for the average programmer, then
that's a bug, so we'd have to work to fix it. And if new approaches are
better, we'd welcome implementations since not all problems are screws
and not all tools are hammers :-) (as a result I'd also welcome people
saying what sucks and why, but preferably based on the system as it is
today, not as it was :)

Have fun :)


Michael.

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


Re: Cross-process dictionary/hashtable

2006-09-18 Thread Sandra-24
I looked at posh, and read the report on it, it's very interesting, but
it will not work for me. Posh requires that it forks the processes, but
in mod_python the processes were forked by apache and use different
interpreters.

Calvin Spealman wrote:
> Maybe what you want is something like memcache
> (http://cheeseshop.python.org/pypi/memcached), which offers a basic
> in-memory, key-value share that processes (even on different boxes)
> can connect to. Of course, as with any kind of concurrent work, its
> going to be far easier to have some restrictions, which memcache has.
> For example, full python objects being shared isn't a great idea, or
> even possible in many situations. The closest you could get with
> something like memcache is to wrap it up in a dictionary-like object
> and have it pickle things coming in and out, but that won't work for
> everying and has security concerns.

Memcached looks like it will do the job. Thanks!

-Sandra

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


Re: Code Golf Challenge : 1,000 Digits Of Pi

2006-09-18 Thread George Sakkis
Calvin Spealman wrote:

> Just once, I would like to see a programming contest that was judged
> on the quality of your code, not the number of bytes you managed to
> incomprehensively hack it down to.

Unfortunately, quality is not as easy to judge as number of bytes. Such
contest would be as crazy an idea as a beauty contest! Oh, wait...

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


Read a group of files as a list

2006-09-18 Thread citlaly
Hi!!
I'm a beginner in python and I'm trying to use the files from a
"folder" as a list. What I want to do is  read each one as a list, but
just the name of the file, the data inside doesn't matter. How can I do
it?  I was trying using a list, but I don't know how "convert" the
elements (files) to a list that I can read and manipulate...

Thanks in advance for your help!!

Citlaly

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


Read a group of files as a list

2006-09-18 Thread citlaly
Hi!!
I'm a beginner in python and I'm trying to use the files from a
"folder" as a list. What I want to do is  read each one as a list, but
just the name of the file, the data inside doesn't matter. How can I do
it?  I was trying using a list, but I don't know how "convert" the
elements (files) to a list that I can read and manipulate...

Thanks in advance for your help!!

Citlaly

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


  1   2   >