python command not working

2009-04-22 Thread 83nini
Hi guys,

I'm new to python, i downloaded version 2.5, opened windows (vista)
command line and wrote "python", this should take me to the python
command line, but it did not! i'm getting : python is not an internal
command, external command, program, or command file.

anybody has a clue how do i solve this?
thanks in advance,
cheers,
Lina
--
http://mail.python.org/mailman/listinfo/python-list


Re: python command not working

2009-04-22 Thread David Cournapeau
On Wed, Apr 22, 2009 at 4:20 PM, 83nini <[email protected]> wrote:
> Hi guys,
>
> I'm new to python, i downloaded version 2.5, opened windows (vista)
> command line and wrote "python", this should take me to the python
> command line, but it did not! i'm getting : python is not an internal
> command, external command, program, or command file.

The installer does not add the path of python into your %PATH%
variable, You have to do it manually or call the full command path
(C:\Python25\python.exe or something)

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


Re: python command not working

2009-04-22 Thread 83nini
On 22 Apr, 09:36, David Cournapeau  wrote:
> On Wed, Apr 22, 2009 at 4:20 PM, 83nini <[email protected]> wrote:
> > Hi guys,
>
> > I'm new to python, i downloaded version 2.5, opened windows (vista)
> > command line and wrote "python", this should take me to the python
> > command line, but it did not! i'm getting : python is not an internal
> > command, external command, program, or command file.
>
> The installer does not add the path of python into your %PATH%
> variable, You have to do it manually or call the full command path
> (C:\Python25\python.exe or something)
>
> David

thanks for the tip, how do i add the path of python into my %PATH%?
--
http://mail.python.org/mailman/listinfo/python-list


python in Emacs (windows)

2009-04-22 Thread Mark Zweers
Hi!

I'm trying to run python from within Emacs. This is in my .emacs file :

(setq auto-mode-alist ; trigger python mode automatically
   (cons '("\\.py$" . python-mode) auto-mode-alist))
(setq interpreter-mode-alist
   (cons '("python" . python-mode)
interpreter-mode-alist))
(autoload 'python-mode "python-mode" "Python editing mode." t)

, but I got this message :

"Searching for program: no such file or directory, python"

So I've added the following line :

(setq py-python-command '("C:/Program Files/Python"))

This is the path where my 'python.exe' is located. But then this message
occurs:

Using the CPython shell
let: Wrong type argument: integerp, "C:/Program Files/Python"

Could anyone tell me how to solve this? Thanks a lot in advance!

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


Re: python command not working

2009-04-22 Thread Ben Finney
83nini <[email protected]> writes:

> I'm new to python, i downloaded version 2.5

What exactly did you download? Give us the URL to the file if possible.

> opened windows (vista) command line and wrote "python"

The Python interpreter and libraries, like any other application, needs
to be installed into your system before you can start using it properly.
If you only downloaded it, then it's just bits in a file, nothing more.
Did you run the installer?

-- 
 \ “If you're not part of the solution, you're part of the |
  `\  precipitate.” —Steven Wright |
_o__)  |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list


Re: python command not working

2009-04-22 Thread David Cournapeau
On Wed, Apr 22, 2009 at 4:44 PM, 83nini <[email protected]> wrote:

>
> thanks for the tip, how do i add the path of python into my %PATH%?

>From the command line (and from memory, I don't use windows regularly):

set PATH=C:\python25;%PATH%

And you can set it up permanently in the advanced settings panel of
windows (the one where you set up things like amount of swap,
restoration and the likes, I don't know the exact name in English)

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


Re: python command not working

2009-04-22 Thread 83nini
On 22 Apr, 09:59, Ben Finney  wrote:
> 83nini <[email protected]> writes:
> > I'm new to python, i downloaded version 2.5
>
> What exactly did you download? Give us the URL to the file if possible.
>
> > opened windows (vista) command line and wrote "python"
>
> The Python interpreter and libraries, like any other application, needs
> to be installed into your system before you can start using it properly.
> If you only downloaded it, then it's just bits in a file, nothing more.
> Did you run the installer?
>
> --
>  \             “If you're not part of the solution, you're part of the |
>   `\                                      precipitate.” —Steven Wright |
> _o__)                                                                  |
> Ben Finney

yes i did
--
http://mail.python.org/mailman/listinfo/python-list


Re: python command not working

2009-04-22 Thread karlos barlos


--- On Wed, 4/22/09, karlos barlos  wrote:

From: karlos barlos 
Subject: Re: python command not working
To: "Ben Finney" 
Date: Wednesday, April 22, 2009, 3:05 AM

look for envaroment   variables__   in system menu__path_paste the 
python path in ___- done
i recomend you add scripts too ...





  


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


setuptools setup.py and "extras"

2009-04-22 Thread Chadrik

in addition to resolving install dependencies, setuptools supports
"extras" with their own dependencies.   these can be installed using
easy_install, like so:

$ easy_install mypackage[extraFeature]

what is the best way to cause an extra's dependencies to be installed
when using the `python setup.py` form?


i discovered that you can use easy_install via setup.py and point it
at the current directory:

$ python setup.py easy_install .  #<--- the period points easy_install
at our current dir


however, this does not install the extra features.  trying the next
logical step doesn't work:

$ python setup.py easy_install .[extraFeature]


so far the best that i've found is :

$ cd /path/to/mypackage
$ cd ..
$ python mypackage/setup.py easy_install mypackage[extraFeature]

is there a simpler way?

-chad


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


Re: Essential tools for Python development

2009-04-22 Thread Jeremiah Dodds
On Wed, Apr 22, 2009 at 3:50 AM, Esmail  wrote:

> Great list Ben, I use emacs and will check out the tools
> you listed.
>
> What techniques/tools do you recommend for debugging?
>
> Esmail
> --
> http://mail.python.org/mailman/listinfo/python-list
>

pdb is good if you need to do step-through debugging.

What I normally do in emacs is the following (while working on python
script, and with the python-mode that comes with emacs22):

C-x 3  #splits the screen into two vertical columns
C-c C-c   #fires up python and sends the current buffer to it
C-x o  #switches to the other column
C-x b Py #switches to the python interactive buffer

This is, I do believe, equivalent to running a script with python -i
script.py . Drops you into an interactive session where you can interact
with what you just wrote. Another very handy tool is etags, see the help in
emacs (You can get to it through C-h i m emacs)
--
http://mail.python.org/mailman/listinfo/python-list


Re: python command not working

2009-04-22 Thread 83nini
On 22 Apr, 10:04, David Cournapeau  wrote:
> On Wed, Apr 22, 2009 at 4:44 PM, 83nini <[email protected]> wrote:
>
> > thanks for the tip, how do i add the path of python into my %PATH%?
> >From the command line (and from memory, I don't use windows regularly):
>
> set PATH=C:\python25;%PATH%
>
> And you can set it up permanently in the advanced settings panel of
> windows (the one where you set up things like amount of swap,
> restoration and the likes, I don't know the exact name in English)
>
> David

thanks David, the PATH=C:\python25;%PATH% worked, but i still don't
know how to do it perminantly
--
http://mail.python.org/mailman/listinfo/python-list


Re: python command not working

2009-04-22 Thread Tim Golden

83nini wrote:

On 22 Apr, 10:04, David Cournapeau  wrote:

On Wed, Apr 22, 2009 at 4:44 PM, 83nini <[email protected]> wrote:


thanks for the tip, how do i add the path of python into my %PATH%?

>From the command line (and from memory, I don't use windows regularly):

set PATH=C:\python25;%PATH%

And you can set it up permanently in the advanced settings panel of
windows (the one where you set up things like amount of swap,
restoration and the likes, I don't know the exact name in English)

David


thanks David, the PATH=C:\python25;%PATH% worked, but i still don't
know how to do it perminantly


Well you can do by selecting [System] from the Control Panel,
selecting the [Advanced] tab, the [Environment Variables]
button and then finding the PATH (user or system) and editing
it in the agonisingly small edit control which doesn't seem
to have changed since Windows 3.1. (He says, exaggerating only
a little)...

... or, I was going to say, you could run Christian Heimes'
win_add2path.py script which is in c:\python26\lib\tools.
Except that it wasn't added until python26 and uses
_winreg.ExpandEnvironmentStrings which also wasn't added
until then. (I think). But for anyone else still watching
the show...

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


Re: Would you support adding UNC support to os.path on Windows?

2009-04-22 Thread Tim Golden

Larry Hastings wrote:



I've written a patch for Python 3.1 that changes os.path so it handles 
UNC paths on Windows.  You can read about it at the Python bug tracker:


   http://bugs.python.org/issue5799

I'd like to gauge community interest in the patch.  After all, it's has 
been declined before; I submitted a similar patch for 1.5.2 way back in 
1999.  (You can read the details of that on the tracker page too.)


Having just implemented similar functionality elsewhere, I'm
up for it. Apart from other considerations, anyone who has gone
to the effort of clarifying the various holes and corners of
Windows drives, paths & UNCs gets my vote. 


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


Re: python command not working

2009-04-22 Thread 83nini
On 22 Apr, 10:31, Tim Golden  wrote:
> 83nini wrote:
> > On 22 Apr, 10:04, David Cournapeau  wrote:
> >> On Wed, Apr 22, 2009 at 4:44 PM, 83nini <[email protected]> wrote:
>
> >>> thanks for the tip, how do i add the path of python into my %PATH%?
> >> >From the command line (and from memory, I don't use windows regularly):
>
> >> set PATH=C:\python25;%PATH%
>
> >> And you can set it up permanently in the advanced settings panel of
> >> windows (the one where you set up things like amount of swap,
> >> restoration and the likes, I don't know the exact name in English)
>
> >> David
>
> > thanks David, the PATH=C:\python25;%PATH% worked, but i still don't
> > know how to do it perminantly
>
> Well you can do by selecting [System] from the Control Panel,
> selecting the [Advanced] tab, the [Environment Variables]
> button and then finding the PATH (user or system) and editing
> it in the agonisingly small edit control which doesn't seem
> to have changed since Windows 3.1. (He says, exaggerating only
> a little)...
>
> ... or, I was going to say, you could run Christian Heimes'
> win_add2path.py script which is in c:\python26\lib\tools.
> Except that it wasn't added until python26 and uses
> _winreg.ExpandEnvironmentStrings which also wasn't added
> until then. (I think). But for anyone else still watching
> the show...
>
> TJG- Dölj citerad text -
>
> - Visa citerad text -

thanks guyz for the nice info
--
http://mail.python.org/mailman/listinfo/python-list


installer for py2exe files?

2009-04-22 Thread Gabriel Rossetti

Hello everyone,

I am wanting to create an installer for my project. I first use py2exe 
to create win32 executables and then would like to have an easy to use 
(for the end user) installer. I would need the installer to launch a 
script (a python script also turned into an exec) after the install is 
done, or even better yet, incorperate the script's tasks in the 
installation process (configure files, check for open ports, etc.). Does 
anyone have an idea, recommendation or has had a similar situation before?


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


Re: best "void" return of a member function

2009-04-22 Thread Tim Rowe
2009/4/20 Stefan Behnel :

> That's the typical SWIG problem: you can generate wrappers for tons of
> languages, mostly automatically. But none of them will feel 'native' to the
> users of each of the target languages (well, possibly excluding C and Java 
> here).

On the other hand, a thin wrapper around a library will let the user
leverage existing library documentation, so the choice is not a
complete no-brainer.

One approach (used in the Ada community for it's MS Windows bindings,
for instance) is to have a thin wrapper and build the thick wrappers
on top of that. Most Ada MS Windows thick wrappers (ie, ones that feel
natural to Ada) are built on top of Win32Ada, which stays as close to
the underlying C interface as it can.

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


Re: python command not working

2009-04-22 Thread Christian Heimes
David Cournapeau schrieb:
> On Wed, Apr 22, 2009 at 4:20 PM, 83nini <[email protected]> wrote:
>> Hi guys,
>>
>> I'm new to python, i downloaded version 2.5, opened windows (vista)
>> command line and wrote "python", this should take me to the python
>> command line, but it did not! i'm getting : python is not an internal
>> command, external command, program, or command file.
> 
> The installer does not add the path of python into your %PATH%
> variable, You have to do it manually or call the full command path
> (C:\Python25\python.exe or something)

I highly recommend against adding C:\Python25 to your %PATH%. You can
get the same effect by adding a simple bat file to C:\Windows\System32

---
@C:\Python25\python.exe %*
---

Call it python25.bat and you are done. Apropos call, don't forget to
"call python25" in batch files. :)

Christian

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


Re: installer for py2exe files?

2009-04-22 Thread Chris Rebert
On Wed, Apr 22, 2009 at 2:17 AM, Gabriel Rossetti
 wrote:
> Hello everyone,
>
> I am wanting to create an installer for my project. I first use py2exe to
> create win32 executables and then would like to have an easy to use (for the
> end user) installer. I would need the installer to launch a script (a python
> script also turned into an exec) after the install is done, or even better
> yet, incorperate the script's tasks in the installation process (configure
> files, check for open ports, etc.). Does anyone have an idea, recommendation

http://jrsoftware.org/isinfo.php
http://nsis.sourceforge.net/Main_Page

Cheers,
Chris
-- 
I have a blog:
http://blog.rebertia.com
--
http://mail.python.org/mailman/listinfo/python-list


Memory footpring of python objects

2009-04-22 Thread BlueBird

Hi,

I have a program that manages several thousands instances of one
object. To reduce memory
consumption, I want of course that specific object to have the
smallest memory footpring possible.

I have a few ideas that I want to experiment with, like using
__slots__, using a tuple or using a dict. My
question is: how do I know the memory footprint of a given python
object ? I could not find any
builtin functions for this in the documentation.

cheers,

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


Re: Memory footpring of python objects

2009-04-22 Thread Chris Rebert
On Wed, Apr 22, 2009 at 2:24 AM, BlueBird  wrote:
>
> Hi,
>
> I have a program that manages several thousands instances of one
> object. To reduce memory
> consumption, I want of course that specific object to have the
> smallest memory footpring possible.
>
> I have a few ideas that I want to experiment with, like using
> __slots__, using a tuple or using a dict. My
> question is: how do I know the memory footprint of a given python
> object ? I could not find any
> builtin functions for this in the documentation.

sys.getsizeof() - http://docs.python.org/library/sys.html#sys.getsizeof

Cheers,
Chris
-- 
I have a blog:
http://blog.rebertia.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: installer for py2exe files?

2009-04-22 Thread David Lyon
Hi Gabriel,

look at ...

 - inno setup http://jrsoftware.org/isinfo.php
 - nsis http://sourceforge.net/projects/nsis/

I think these are the two clear leaders for open source...


On Wed, 22 Apr 2009 11:17:10 +0200, Gabriel Rossetti
 wrote:
> Hello everyone,
> 
> I am wanting to create an installer for my project. I first use py2exe
> to create win32 executables and then would like to have an easy to use
> (for the end user) installer. I would need the installer to launch a
> script (a python script also turned into an exec) after the install is
> done, or even better yet, incorperate the script's tasks in the
> installation process (configure files, check for open ports, etc.). Does
> anyone have an idea, recommendation or has had a similar situation
before?
> 
> Thanks!
> Gabriel
> --
> http://mail.python.org/mailman/listinfo/python-list

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


Re: [Py2exe-users] installer for py2exe files?

2009-04-22 Thread Yann Leboulanger
Gabriel Rossetti wrote:
> Hello everyone,
> 
> I am wanting to create an installer for my project. I first use py2exe 
> to create win32 executables and then would like to have an easy to use 
> (for the end user) installer. I would need the installer to launch a 
> script (a python script also turned into an exec) after the install is 
> done, or even better yet, incorperate the script's tasks in the 
> installation process (configure files, check for open ports, etc.). Does 
> anyone have an idea, recommendation or has had a similar situation before?
> 
> Thanks!
> Gabriel

Have a look at NSIS, it's an opensource project

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


Re: Memory footpring of python objects

2009-04-22 Thread Marco Mariani

BlueBird wrote:


I have a program that manages several thousands instances of one
object. To reduce memory
consumption, I want of course that specific object to have the
smallest memory footpring possible.


Have you thought of using something like the flyweight pattern and a 
compact data representation like a numpy array?


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


Re: Memory footpring of python objects

2009-04-22 Thread Steven D'Aprano
On Wed, 22 Apr 2009 02:30:32 -0700, Chris Rebert wrote:

> On Wed, Apr 22, 2009 at 2:24 AM, BlueBird  wrote:
>>
>> Hi,
>>
>> I have a program that manages several thousands instances of one
>> object. To reduce memory
>> consumption, I want of course that specific object to have the smallest
>> memory footpring possible.
>>
>> I have a few ideas that I want to experiment with, like using
>> __slots__, using a tuple or using a dict. My question is: how do I know
>> the memory footprint of a given python object ? I could not find any
>> builtin functions for this in the documentation.
> 
> sys.getsizeof() - http://docs.python.org/library/sys.html#sys.getsizeof

Only in Python 2.6.

But if you search Activestate, there's a recipe to do the same thing. Ah, 
here it is:

http://code.activestate.com/recipes/546530/



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


Problem with base64 mimeparts and email.*

2009-04-22 Thread seal
Hello,

I'm writing a rss2mbox program as a first python project. I'm using
feedparser,
mailbox and email.* modules. I have a problem. The produced MIME-
message (see below)
seems right, as far as I know, but the base64-encoded part isn't
decoded in the MUAs.
I've tried cone and vm. The encoded content is simply displayed 'as
text'.

Help?

Thanks
/Sebastian

Content-Type: multipart/mixed; boundary="===2078015454=="
MIME-Version: 1.0
From: xkcd.com
Subject: Borders
Date: Wed, 15 Apr 2009 04:00:00 +

--===2078015454==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit

http://xkcd.com/569/

--===2078015454==
Content-Type: text/html; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64

UEdsdFp5QnpjbU05SW1oMGRIQTZMeTlwYldkekxuaHJZMlF1WTI5dEwyTnZiV2xqY3k5aWIzSmta
WEp6TG5CdVp5SWdkR2wwYkdVOQpJa1YyWlc1MGRXRnNiSGtnWVNCVlRpQnBjeUJ6WlhRZ2RYQXVJ
Q0JCYm1RZ2RHaGxiaUJoSUd4dmJtVWdjbVZpWld3Z2NuVnVjeUJrCmIzZHVJSFJvWlNCc2FXNWxJ
RzltSUdac1lXZHpJR2x1SUdaeWIyNTBJRzltSUdsMExDQnlkVzV6SUdKaFkyc2dkRzhnYUdseklH
SmgKYzJVc0lHRnVaQ0JuWlhSeklHRWdhMkZxYVd4c2FXOXVJSEJ2YVc1MGN5NGlJR0ZzZEQwaVJY
WmxiblIxWVd4c2VTQmhJRlZPSUdsegpJSE5sZENCMWNDNGdJRUZ1WkNCMGFHVnVJR0VnYkc5dVpT
QnlaV0psYkNCeWRXNXpJR1J2ZDI0Z2RHaGxJR3hwYm1VZ2IyWWdabXhoClozTWdhVzRnWm5KdmJu
UWdiMllnYVhRc0lISjFibk1nWW1GamF5QjBieUJvYVhNZ1ltRnpaU3dnWVc1a0lHZGxkSE1nWVNC
cllXcHAKYkd4cGIyNGdjRzlwYm5SekxpSWdMejRLCg==

--===2078015454==--

The code:

from time import strftime, gmtime
from email.header import Header
from email.charset import Charset
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
import mailbox, feedparser

[...]

def entry2msg(e, title, encoding):
c =  Charset(encoding)
m = MIMEMultipart()

m.attach(MIMEText(e.get('id', '') + '\n'))
print e.title
print encoding
print c.output_charset
type = minortype(e.get('summary_detail.type', 'plain'))
body = c.body_encode((e.get('summary', '') + '\n').encode
(encoding))
m.attach(MIMEText(body, type, encoding))

for i in e.get('content', []):
type = minortype(i.type)
body = c.body_encode(i.value.encode(encoding))
m.attach(MIMEText(body, type, encoding))

m['From'] = Header(title, encoding)
m['Subject'] = Header(e.get('title', 'No title'), encoding)
m['Date'] = strftime('%a, %d %b %Y %H:%M:%S +',
 e.get('date_parsed', gmtime()))

# Won't get a valid mbox otherwise.
m.epilogue = "\n"

return mailbox.mboxMessage(m)

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


Re: python command not working

2009-04-22 Thread 83nini
On 22 Apr, 11:24, Christian Heimes  wrote:
> David Cournapeau schrieb:
>
> > On Wed, Apr 22, 2009 at 4:20 PM, 83nini <[email protected]> wrote:
> >> Hi guys,
>
> >> I'm new to python, i downloaded version 2.5, opened windows (vista)
> >> command line and wrote "python", this should take me to the python
> >> command line, but it did not! i'm getting : python is not an internal
> >> command, external command, program, or command file.
>
> > The installer does not add the path of python into your %PATH%
> > variable, You have to do it manually or call the full command path
> > (C:\Python25\python.exe or something)
>
> I highly recommend against adding C:\Python25 to your %PATH%. You can
> get the same effect by adding a simple bat file to C:\Windows\System32
>
> ---
> @C:\Python25\python.exe %*
> ---
>
> Call it python25.bat and you are done. Apropos call, don't forget to
> "call python25" in batch files. :)
>
> Christian

THIS IS REALLY KILLING ME!!!
i've been trying everything you adviced me to do, none works!!!
all i want to do is to type "python" in the cmd and get the python
command line
i want to run a server writing "python manage.py runserver" that is
not working either, of course cos "python" command is not working.
is this one of the stupid things that vista causes? or what???
--
http://mail.python.org/mailman/listinfo/python-list


Re: python command not working

2009-04-22 Thread 83nini
On 22 Apr, 12:06, 83nini <[email protected]> wrote:
> On 22 Apr, 11:24, Christian Heimes  wrote:
>
>
>
>
>
> > David Cournapeau schrieb:
>
> > > On Wed, Apr 22, 2009 at 4:20 PM, 83nini <[email protected]> wrote:
> > >> Hi guys,
>
> > >> I'm new to python, i downloaded version 2.5, opened windows (vista)
> > >> command line and wrote "python", this should take me to the python
> > >> command line, but it did not! i'm getting : python is not an internal
> > >> command, external command, program, or command file.
>
> > > The installer does not add the path of python into your %PATH%
> > > variable, You have to do it manually or call the full command path
> > > (C:\Python25\python.exe or something)
>
> > I highly recommend against adding C:\Python25 to your %PATH%. You can
> > get the same effect by adding a simple bat file to C:\Windows\System32
>
> > ---
> > @C:\Python25\python.exe %*
> > ---
>
> > Call it python25.bat and you are done. Apropos call, don't forget to
> > "call python25" in batch files. :)
>
> > Christian
>
> THIS IS REALLY KILLING ME!!!
> i've been trying everything you adviced me to do, none works!!!
> all i want to do is to type "python" in the cmd and get the python
> command line
> i want to run a server writing "python manage.py runserver" that is
> not working either, of course cos "python" command is not working.
> is this one of the stupid things that vista causes? or what???- Dölj citerad 
> text -
>
> - Visa citerad text -

Ok, it's not killing me anymore :P
I uninstalled python and reinstalled it again, and now it's working
--
http://mail.python.org/mailman/listinfo/python-list


Re: Install NumPy in python 2.6

2009-04-22 Thread Ole Streicher
Hi David,

David Cournapeau  writes:
> On Fri, Mar 13, 2009 at 8:20 PM, gopal mishra  wrote:
>> error: Setup script exited with error: None
> Numpy 1.3.0 (to be released 1st April 2009) will contain everything to
> be buildable and usable with python 2.6 on windows. If you are in a
> hurry, you can install numpy from svn (I regularly test on windows
> lately, and I can confirm it does work).

I tried to install numpy and scipy on my Linux machine (64 bit,
openSUSE 11, Python 2.6).

Numpy installed with warnings like "Lapack (...) libraries not found",
but scipy then fails:

error:
Lapack (http://www.netlib.org/lapack/) libraries not found.
Directories to search for the libraries can be specified in the
numpy/distutils/site.cfg file (section [lapack]) or by setting
the LAPACK environment variable.

Unfortunately, www.netlib.org is not reachable, so I cannot try to
install lapack.

What is the reason for that?

I tried numpack 1.3.0 and scipack 0.7.0, with easy_install.

Best regards

Ole

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


Re: [Python-Dev] PEP 383: Non-decodable Bytes in System Character Interfaces

2009-04-22 Thread Nick Coghlan
Martin v. Löwis wrote:
> I'm proposing the following PEP for inclusion into Python 3.1.
> Please comment.

That seems like a much nicer solution than having parallel bytes/Unicode
APIs everywhere.

When the locale encoding is UTF-8, would UTF-8b also be used for the
command line decoding and environment variable encoding/decoding? (the
PEP currently only states that the encoding switch will be done for the
file system encoding - it is silent regarding the other two system
interfaces).

Cheers,
Nick.

-- 
Nick Coghlan   |   [email protected]   |   Brisbane, Australia
---
--
http://mail.python.org/mailman/listinfo/python-list


py2exe with BeautifulSoup and simplejson error

2009-04-22 Thread Gabriel Rossetti

Hello everyone,

I am tryng to use py2exe with BeautifulSoup and simplejson. I have
already successfully used it with storm and twisted, but for some reason
py2exe does not find neither BeautifulSoup nor simplejson. I did do
something different when installing those packages, I used easy_install
as with the others I used installers. Does anyone know how to fix this?

Thank you,
Gabriel
--
http://mail.python.org/mailman/listinfo/python-list


Serving html and python cgi through BaseHTTPServer.py

2009-04-22 Thread Mads Nielsen
Hello all.

im tinkering with some beginner cgi stuff in python. (form processing)
i have a basic html document with a form and some inputs and i have a cgi.py
file to process the form.

how does one serve html and python cgi through the BaseHTTPServer included
with python 2.6 ?

i have tried to go to http://localhost:8000/index.html but no go. i get a
Error response 501 Unsupported method ('GET').

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


Re: installer for py2exe files?

2009-04-22 Thread Werner F. Bruhin

Hi Gabriel,

Gabriel Rossetti wrote:

Hello everyone,

I am wanting to create an installer for my project. I first use py2exe 
to create win32 executables and then would like to have an easy to use 
(for the end user) installer.

I use InnoSetup - link already given by David.
 I would need the installer to launch a
script (a python script also turned into an exec) after the install is 
done, or even better yet, incorperate the script's tasks in the 
installation process (configure files, check for open ports, etc.). Does 
anyone have an idea, recommendation or has had a similar situation before?
If you install on e.g. Vista then the installer is running as admin, be 
careful when you want to set configuration info.  You might set it for 
the admin instead of for the real user.


IIRC, you should only set HKCR and HKLM keys in the registry, do not set 
HKCU unless you want to set something for the admin.


You also have to watch out that you application folder is read-only, 
i.e. do not store configuration files in your application program folder 
 if they might get changed by the user.  If you do and user changes 
them then they will be written to a folder under the users home folder 
and this might cause strange errors and/or confusion.


There are some more tips and more details about all this on the 
InnoSetup site.


Werner

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


Re: python command not working

2009-04-22 Thread David Cournapeau
On Wed, Apr 22, 2009 at 6:24 PM, Christian Heimes  wrote:

>
> I highly recommend against adding C:\Python25 to your %PATH%. You can
> get the same effect by adding a simple bat file to C:\Windows\System32

I am curious, what's the difference ?

And does this work if you want to add it to your user PATH (not the
system one) ?

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


Re: execfile (exec?) create non consistent locals() state

2009-04-22 Thread David Stanek
>> I expected exec to work the same, but apparently I was wrong. Is there is a
>> way to exec a file "more" correctly? thus avoid the need to resort to
>> awkward solutions such as using the locals() dictionary?
>
> I don't know personally. Perhaps a kind soul will chime in.
>

Why not just exec into a dictionary like this:

{{{
eee0:~% cat execme.py
a = 0

def func():
print a
eee0:~% python
Python 2.5.2 (r252:60911, Oct  5 2008, 19:24:49)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> d = {}
>>> execfile('execme.py', d, d)
>>> d['a']
0
>>> d['func']()
0
>>>
}}}


-- 
David
blog: http://www.traceback.org
twitter: http://twitter.com/dstanek
--
http://mail.python.org/mailman/listinfo/python-list


Re: python command not working

2009-04-22 Thread Christian Heimes
David Cournapeau schrieb:
> On Wed, Apr 22, 2009 at 6:24 PM, Christian Heimes  wrote:
> 
>> I highly recommend against adding C:\Python25 to your %PATH%. You can
>> get the same effect by adding a simple bat file to C:\Windows\System32
> 
> I am curious, what's the difference ?
> 
> And does this work if you want to add it to your user PATH (not the
> system one) ?

My way doesn't add the dlls to the search path. It allows you to have
multiple python commands at once, too. I have shortcuts for python24,
python25 and python26 on my Windows box.

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


Re: python command not working

2009-04-22 Thread David Cournapeau
On Wed, Apr 22, 2009 at 8:43 PM, Christian Heimes  wrote:

>
> My way doesn't add the dlls to the search path. It allows you to have
> multiple python commands at once, too. I have shortcuts for python24,
> python25 and python26 on my Windows box.

Ah, thanks, that's really useful. I need this too, and did it the
"unix" way, which did not work so well for various reasons. This is
much better,

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


Re: Install NumPy in python 2.6

2009-04-22 Thread David Cournapeau
On Wed, Apr 22, 2009 at 6:38 PM, Ole Streicher  wrote:

>
> Unfortunately, www.netlib.org is not reachable, so I cannot try to
> install lapack.
>
> What is the reason for that?

I don't know, I think netlib.org will be back soon. You need LAPACK
for scipy, it is not possible to build it without it. I believe suse
has a package for it, though.

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


Weird lambda behavior

2009-04-22 Thread Rüdiger Ranft
Hi all,

I want to generate some methods in a class using setattr and lambda.
Within each generated function a name parameter to the function is
replaced by a string constant, to keep trail which function was called.
The problem I have is, that the substituted name parameter is not
replaced by the correct name of the function, but by the last name the
for loop has seen.

import unittest

class WidgetDummy:
'''This class records all calls to methods to an outer list'''

def __init__( self, name, calls ):
'''name is the name of the object, which gets included into a
call record. calls is the list where the calls are appended.'''
self.name = name
self.calls = calls
for fn in ( 'Clear', 'Append', 'foobar' ):
func = lambda *y,**z: self.__callFn__( fn, y, z )
setattr( self, fn, func )

def __callFn__( self, fnName, *args ):
'''Add the function call to the call list'''
self.calls.append( ( self.name, fnName, args ) )

class Testcase( unittest.TestCase ):
def testFoo( self ):
calls = []
wd = WidgetDummy( 'foo', calls )
wd.Append( 23 )
self.assertEqual( [ ( 'foo', 'Append', ( 23, {} ) ) ], calls )

unittest.main()

-- 
GPG encrypted mails preferred.
GPG verschlüsselte Mails bevorzugt.
---> http://chaosradio.ccc.de/media/ds/ds085.pdf Seite 20 <
--
http://mail.python.org/mailman/listinfo/python-list


Re: Binary IP address representation

2009-04-22 Thread Philipp Hagemeister
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA512

Hi Dave,

I've solved this now using ipaddr. ipaddr will be in the stdlib as soon
as its developers realize there are actually not one, but two proposals
to fix the remaining issues waiting for their input.

Anyway, since ipaddr:r68, you can do the following:

>>> import ipaddr
>>> ipaddr.IP('::1').packed
b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01'

Since you don't know or want to know the family in most use cases, this
interface is actually nicer than that of inet_pton. For the record,
here's how my compatibility function looks like.

def _compat_ipaddr_inet_pton(family, addr):
if family == socket.AF_INET:
return ipaddr.IPv4(addr).packed
elif family == socket.AF_INET6:
return ipaddr.IPv6(addr).packed
else:
raise ValueError("Unknown protocol family " + family)

Since socket.AF_INET6 will not be defined on old systems (are there any
versions of Python 2.5+ that do not have that defined?), your solution
is better for those (but needs netaddr, which is unlikely to enter
stdlib soon). Thanks for sharing it.

Regards,

Philipp

DrKJam wrote:
> Hi,
> 
> I've only just come across this thread this morning :-
> 
> http://mail.python.org/pipermail/python-list/2009-March/703388.html
> 
> Bit late to respond on this list so here is another option (if you are
> still interested).
> 
> Try the netaddr.fallback module :-
> 
 from netaddr.fallback import inet_pton, AF_INET6
 inet_pton(AF_INET6, '::1')
> \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01
> 
> It is self contained and written in pure Python. Forms part of the
> latest 0.6.2 release of netaddr.
> 
> Apologies the code in my project comes across as unreadable :-(
> 
> Regards,
> 
> Dave M.
> 
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEAREKAAYFAknu/zAACgkQ9eq1gvr7CFwUwwCfQLP+dnOdjn9JEttcaFQb5FH0
hLQAn33Lve8k/HXVsW0j7JZP3dL7897W
=ki8e
-END PGP SIGNATURE-
--
http://mail.python.org/mailman/listinfo/python-list


Re: Install NumPy in python 2.6

2009-04-22 Thread Eduardo Lenz
On Wednesday 22 April 2009 04:47:54 David Cournapeau wrote:
> On Wed, Apr 22, 2009 at 6:38 PM, Ole Streicher  
wrote:
> > Unfortunately, www.netlib.org is not reachable, so I cannot try to
> > install lapack.
> >
> > What is the reason for that?
>
> I don't know, I think netlib.org will be back soon. You need LAPACK
> for scipy, it is not possible to build it without it. I believe suse
> has a package for it, though.
>
> David
> --
> http://mail.python.org/mailman/listinfo/python-list

try ATLAS instead.

-- 

 Eduardo Lenz Cardoso
 Dr.  Eng.
 Associate Professor
 
 State University of Santa Catarina
 Department of Mechanical Engineering
 89223-100 - Joinville-SC - Brasil

 Tel: +55 47 4009-7971 - Fax: +55 47 4009-7940
 E-mail: [email protected]  
 -

-- 
Esta mensagem foi verificada pelo sistema de antivírus e
 acredita-se estar livre de perigo.

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


Tryton 1.2 released

2009-04-22 Thread ced
Tryton is a three-tiers high-level general purpose application
platform
under the license GPL-3 written in Python and using PostgreSQL as
database engine.

It is the core base of a complete business solution providing
modularity,
 scalability and security.

Step by step Tryton is getting more features while sticking with the
central goal of providing a solid and powerful platform for creating
enterprise solutions. This new release comes with some exciting new
features. The most noteworthy are:

- Historical data handling:

  This feature can be enabled with a simple attribute on any
  model. Once activated the kernel transparently archives every
  modification made to the records of the model in a history
  table. Records are accessed in a standard way by passing a date in
  the context to get the record values relevant for that date. This
  makes looking up historical data easy.  The first module using this
  new functionality 'Account Invoice History' is described below.

- MacOS client (beta): The Tryton client is now available as a native
  MacOS application (for MacOS > 10.4).

- Email as attachment functionality for reports:

  In addition to being opened directly, each report can also be
  automatically added as an attachment to an email.  The user's email
client
  is used to open a Compose Email window with the report as an
attachment.
  The subject, the recipient and other information are automatically
  filled in with respect to the current document.

- Online VAT checking:

  A new wizard allows the user to automatically check VAT numbers of
parties
  with an online web service provided by the European VAT Information
Exchange
  System.

- Integrated sale and purchase order handling.

  Cancellation of shipments or of draft invoices can be
  handled directly from the corresponding sale or purchase order. This
  is possible thanks to the back-propagation of information from the
  shipment or the invoice. This allows the sale or purchase manager to
  re-create necessary documents or to ignore cancellations.


This release also comes with lots of bug fixes for the server, client
and modules. As well as a split of the Spanish and Colombian
translations. As promised, this version will migrate automatically
databases created with Tryton 1.0, except for the completely new tax
rule system that need some parametrization.

A more complete list of the new features on:
http://www.tryton.org/news.html#n20090420

:Homepage:http://www.tryton.org/
:Downloads:   http://www.tryton.org/downloads.html
:Screenshots: http://www.tryton.org/screenshots.html
:Invoice Historization Video: 
http://www.tryton.org/video/invoice_historization.html
:Demo: http://www.tryton.org/demo.html
--
http://mail.python.org/mailman/listinfo/python-list


Re: Memory footpring of python objects

2009-04-22 Thread BlueBird
On 22 avr, 11:56, Steven D'Aprano
 wrote:
> On Wed, 22 Apr 2009 02:30:32 -0700, Chris Rebert wrote:
> > On Wed, Apr 22, 2009 at 2:24 AM, BlueBird  wrote:
>
> >> Hi,
>
> >> I have a program that manages several thousands instances of one
> >> object. To reduce memory
> >> consumption, I want of course that specific object to have the smallest
> >> memory footpring possible.
>
> >> I have a few ideas that I want to experiment with, like using
> >> __slots__, using a tuple or using a dict. My question is: how do I know
> >> the memory footprint of a given python object ? I could not find any
> >> builtin functions for this in the documentation.
>
> > sys.getsizeof() -http://docs.python.org/library/sys.html#sys.getsizeof
>
> Only in Python 2.6.
>
> But if you search Activestate, there's a recipe to do the same thing. Ah,
> here it is:
>
> http://code.activestate.com/recipes/546530/

Thanks. "There is always a tool that makes you realise how you are
less smart than you thought" - Andrew Morton, about git.

I had a bit of hard time getting through the different sizes reported
and the vocabulary. From what I understood, basicsize is the size of
the object alone, without the size of his references. And asizeof( x,
code=False, limit=100 ) will give me the memory footprint of a new
instance of an object.

In my case, I just want an object with named attributes.

My two attempts for comparison:
import sys, asizeof

def print_sizeof( v_name, v ):
print 'Size of %s: %d, %d' % (v_name,
asizeof.flatsize(v),
asizeof.asizeof(v, code=False, limit=100) )

def test_impl( v ):
assert v.a == 1
assert v.b == 'bbb'
assert v.c == False

### The reference, a dictionnary
ref_dict = {'a':1, 'b':'bbb', 'c':False }
print_sizeof( 'ref_dict', ref_dict )

### A modified dictionnary
class AttrDict (dict):
"""Dictionary allowing attribute access to its elements if they
are valid attribute names and not already existing methods."""

def __getattr__ (self, name):
return self[name]

attrDict = AttrDict( ref_dict )
test_impl( attrDict )
print_sizeof( 'attrDict', attrDict )

### Using __slots__
class ObjWithSlots(object):
__slots__ = [ 'a', 'b', 'c' ]

objWithSlots = ObjWithSlots()
for k in ref_dict:
setattr( ObjWithSlots, k, ref_dict[k] )
test_impl( objWithSlots )
print_sizeof( 'ObjectWithSlots', objWithSlots )

is giving me:
Size of ref_dict: 140, 304
Size of attrDict: 140,
304
Size of ObjectWithSlots: 36,
144

So, it looks like I could shrink down the structure to 144 bytes in a
simple case.

Marco, my objects have varying length data structures (strings) so I
don't think that would be possible. And it would clearly be overkill
in my case.



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


use smtpd as a gmail proxy server

2009-04-22 Thread Robin Becker
A bit of googling reveals that it's possible to use smtplib to do mailing using 
gmail. Is there a way to use smtpd as a proxy server with gmail.


This apparently works with smtplib,


  mailServer = smtplib.SMTP('smtp.gmail.com', 587)
  mailServer.ehlo()
  mailServer.starttls()
  mailServer.ehlo()
  mailServer.login(gmailUser, gmailPassword)
  mailServer.sendmail(gmailUser, recipient, msg)
  mailServer.close()


but I'm trying to test an application that will use its host's mta eventually to 
send mail so I need to set up a local proxy that can log in to gmail.


Is there an easy way forward with smtpd?

Looking in the PureProxy code it seems that I need to mess with the _deliver 
method to use the above approach, but there isn't any convenient hook.

--
Robin Becker

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


Re: Install NumPy in python 2.6

2009-04-22 Thread Ole Streicher
Hi Eduardo,

Eduardo Lenz  writes:
> On Wednesday 22 April 2009 04:47:54 David Cournapeau wrote:
>> On Wed, Apr 22, 2009 at 6:38 PM, Ole Streicher  
> wrote:
>> > but scipy then fails:
>> > error: Lapack (http://www.netlib.org/lapack/) libraries not found.
>> > What is the reason for that?

> try ATLAS instead.

I did:
$ easy_install --prefix=/work/python/ atlas-0.27.0.tar.gz
$ ls -l /work/python/lib/python2.6/site-packages/atlas-0.27.0-py2.6.egg
-rw-r--r-- 1 os gr 98386 2009-04-22 14:05 
/work/python/lib/python2.6/site-packages/atlas-0.27.0-py2.6.egg

For some reason, this is not a directory, like numpy or matplotlib,
but I guess that is OK?

Anyway: it did not help. The error stays the same. What could be the
problem?


  "easy install" is something different than python's easy_install.


Best regards.

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


Re: execfile (exec?) create non consistent locals() state

2009-04-22 Thread Peter Otten
[original post is not on my news server]

[Doron Tal]

>>> > Recently I tried to execute a python file using execfile (exec
>>> > performed just the same for that reason).

Not over here:

Python 2.4.4 (#2, Aug  1 2008, 00:04:43)
[GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> def f():
... execfile("execme.py")
... print "locals:", locals()
... print a
...
>>> f()
locals: {'a': 2}
Traceback (most recent call last):
  File "", line 1, in ?
  File "", line 4, in f
NameError: global name 'a' is not defined
>>> def g():
... exec open("execme.py").read()
... print "locals:", locals()
... print a
...
>>> g()
locals: {'a': 2}
2

The reason is that while execfile() is just an ordinary function the exec
statement affects the function's bytecode (LOAD_NAME instead of LOAD_GLOBAL
or LOAD_FAST). This leads to the following Voodoo:

>>> def h():
... exec ""
... execfile("execme.py")
... print "locals:", locals()
... print a
...
>>> h()
locals: {'a': 2}
2

While this is certainly not the most regular behaviour it allows to avoid
going through a dictionary for every assignment in functions that don't
have an exec statement, thus giving you faster code in the vast majority of
cases at the cost of a few quirks like the one you encountered.

Peter

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


Re: PEP 383: Non-decodable Bytes in System Character Interfaces

2009-04-22 Thread MRAB

Martin v. Löwis wrote:
[snip]

To convert non-decodable bytes, a new error handler "python-escape" is
introduced, which decodes non-decodable bytes using into a private-use
character U+F01xx, which is believed to not conflict with private-use
characters that currently exist in Python codecs.

The error handler interface is extended to allow the encode error
handler to return byte strings immediately, in addition to returning
Unicode strings which then get encoded again.

If the locale's encoding is UTF-8, the file system encoding is set to
a new encoding "utf-8b". The UTF-8b codec decodes non-decodable bytes
(which must be >= 0x80) into half surrogate codes U+DC80..U+DCFF.


If the byte stream happens to include a sequence which decodes to
U+F01xx, shouldn't that raise an exception?
--
http://mail.python.org/mailman/listinfo/python-list


Re: [Python-Dev] PEP 383: Non-decodable Bytes in System Character Interfaces

2009-04-22 Thread Walter Dörwald
Martin v. Löwis wrote:

> I'm proposing the following PEP for inclusion into Python 3.1.
> Please comment.
> 
> Regards,
> Martin
> 
> PEP: 383
> Title: Non-decodable Bytes in System Character Interfaces
> Version: $Revision: 71793 $
> Last-Modified: $Date: 2009-04-22 08:42:06 +0200 (Mi, 22. Apr 2009) $
> Author: Martin v. Löwis 
> Status: Draft
> Type: Standards Track
> Content-Type: text/x-rst
> Created: 22-Apr-2009
> Python-Version: 3.1
> Post-History:
> 
> Abstract
> 
> 
> File names, environment variables, and command line arguments are
> defined as being character data in POSIX; the C APIs however allow
> passing arbitrary bytes - whether these conform to a certain encoding
> or not. This PEP proposes a means of dealing with such irregularities
> by embedding the bytes in character strings in such a way that allows
> recreation of the original byte string.
> 
> Rationale
> =
> 
> The C char type is a data type that is commonly used to represent both
> character data and bytes. Certain POSIX interfaces are specified and
> widely understood as operating on character data, however, the system
> call interfaces make no assumption on the encoding of these data, and
> pass them on as-is. With Python 3, character strings use a
> Unicode-based internal representation, making it difficult to ignore
> the encoding of byte strings in the same way that the C interfaces can
> ignore the encoding.
> 
> On the other hand, Microsoft Windows NT has correct the original

"correct" -> "corrected"

> design limitation of Unix, and made it explicit in its system
> interfaces that these data (file names, environment variables, command
> line arguments) are indeed character data, by providing a
> Unicode-based API (keeping a C-char-based one for backwards
> compatibility).
> 
> [...]
> 
> Specification
> =
> 
> On Windows, Python uses the wide character APIs to access
> character-oriented APIs, allowing direct conversion of the
> environmental data to Python str objects.
> 
> On POSIX systems, Python currently applies the locale's encoding to
> convert the byte data to Unicode. If the locale's encoding is UTF-8,
> it can represent the full set of Unicode characters, otherwise, only a
> subset is representable. In the latter case, using private-use
> characters to represent these bytes would be an option. For UTF-8,
> doing so would create an ambiguity, as the private-use characters may
> regularly occur in the input also.
> 
> To convert non-decodable bytes, a new error handler "python-escape" is
> introduced, which decodes non-decodable bytes using into a private-use
> character U+F01xx, which is believed to not conflict with private-use
> characters that currently exist in Python codecs.

Would this mean that real private use characters in the file name would
raise an exception? How? The UTF-8 decoder doesn't pass those bytes to
any error handler.

> The error handler interface is extended to allow the encode error
> handler to return byte strings immediately, in addition to returning
> Unicode strings which then get encoded again.

Then the error callback for encoding would become specific to the target
encoding. Would this mean that the handler checks which encoding is used
and behaves like "strict" if it doesn't recognize the encoding?

> If the locale's encoding is UTF-8, the file system encoding is set to
> a new encoding "utf-8b". The UTF-8b codec decodes non-decodable bytes
> (which must be >= 0x80) into half surrogate codes U+DC80..U+DCFF.

Is this done by the codec, or the error handler? If it's done by the
codec I don't see a reason for the "python-escape" error handler.

> Discussion
> ==
> 
> While providing a uniform API to non-decodable bytes, this interface
> has the limitation that chosen representation only "works" if the data
> get converted back to bytes with the python-escape error handler
> also.

I thought the error handler would be used for decoding.

> Encoding the data with the locale's encoding and the (default)
> strict error handler will raise an exception, encoding them with UTF-8
> will produce non-sensical data.
> 
> For most applications, we assume that they eventually pass data
> received from a system interface back into the same system
> interfaces. For example, and application invoking os.listdir() will

"and" -> "an"

> likely pass the result strings back into APIs like os.stat() or
> open(), which then encodes them back into their original byte
> representation. Applications that need to process the original byte
> strings can obtain them by encoding the character strings with the
> file system encoding, passing "python-escape" as the error handler
> name.

Servus,
   Walter
--
http://mail.python.org/mailman/listinfo/python-list


Re: Weird lambda behavior

2009-04-22 Thread Chris Rebert
On Wed, Apr 22, 2009 at 4:50 AM, Rüdiger Ranft <[email protected]> wrote:
> Hi all,
>
> I want to generate some methods in a class using setattr and lambda.
> Within each generated function a name parameter to the function is
> replaced by a string constant, to keep trail which function was called.
> The problem I have is, that the substituted name parameter is not
> replaced by the correct name of the function, but by the last name the
> for loop has seen.
>
> import unittest
>
> class WidgetDummy:
>    '''This class records all calls to methods to an outer list'''
>
>    def __init__( self, name, calls ):
>        '''name is the name of the object, which gets included into a
>        call record. calls is the list where the calls are appended.'''
>        self.name = name
>        self.calls = calls
>        for fn in ( 'Clear', 'Append', 'foobar' ):
>            func = lambda *y,**z: self.__callFn__( fn, y, z )
>            setattr( self, fn, func )

Common wart to run into as of late. fn (in the lambda) doesn't get
evaluated until the call-time of the lambda, by which point the loop
has finished and the loop variable has been changed to its final
value, which is used by the lambda.

Workaround:
#exact syntax may vary with your version of Python, but you should be
able to get the idea
func = lambda *y,**z, fn=fn: self.__callFn__( fn, y, z )

The default argument value gets evaluated at definition-time, thus
forcing the right value of fn within the function.

Cheers,
Chris
-- 
I have a blog:
http://blog.rebertia.com
--
http://mail.python.org/mailman/listinfo/python-list


namespace query

2009-04-22 Thread Dr Mephesto
Hi,

I have a quick question about global namespace, and I'm hoping someone
could give a quick reply to sort me out :)

I have a single file program that uses numpy, and it works just fine.
I want to move some classes into their own files, to make the code
reusable.  When I cut and paste the the classes into new files, and
then "import" them back into the original program, I get an
error,:"NameError: name 'numpy' is not defined", called about the new
class files.

If I add a "global numpy" to the beginning of each class in the new
files, the program runs. Do I really have to add "global XXX" for
every module I import in the main program into every module I create
and import? Why are the class files I created not seeing the top
namespace?

Thanks in Advance!

Dave

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


Re: pyflakes, pylint, pychecker - and other tools

2009-04-22 Thread Colin J. Williams

Esmail wrote:

What is the consensus of the Python community regarding these
code checkers?

In particular, are the stylistic recommendations that
pylint makes considered sensible/valid?


pylint seems a bit heavy handled, a bit 
too much PEP 8, which was intended as a 
guide, rather than a prescription.


Colin W.



Are there any other tools you consider essential to Python
development?

Thanks.
Esmail


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


Re: Essential tools for Python development

2009-04-22 Thread Colin J. Williams

Esmail wrote:

Great list Ben, I use emacs and will check out the tools
you listed.

What techniques/tools do you recommend for debugging?


I like PyScripter for Windows, which 
provides a tool for PyLint.


Colin W.


Esmail


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


Re: namespace query

2009-04-22 Thread Marco Mariani

Dr Mephesto wrote:


Why are the class files I created not seeing the top namespace?


Because it's how python works. What you think is a top namespace, it's 
not "at the top". It's just the namespace of the module you run the 
program with. You must import numpy from the all the modules that make 
use of it.


I doubt your "global" fixed something, I'd like to see an example.

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


Re: namespace query

2009-04-22 Thread Steven D'Aprano
On Wed, 22 Apr 2009 05:21:06 -0700, Dr Mephesto wrote:

> If I add a "global numpy" to the beginning of each class in the new
> files, the program runs. Do I really have to add "global XXX" for every
> module I import in the main program into every module I create and
> import? Why are the class files I created not seeing the top namespace?

What's the top namespace?

Every Python module is a namespace. The module namespace is flat: all 
modules are at the same level. A module can't know what other modules 
have imported it, and code in the imported module can't see the importing 
namespace.

However, you can get something like a hierarchical namespace by using 
packages. Possibly this might accomplish what you are trying to do.

http://docs.python.org/tutorial/modules.html#packages



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


Re: namespace query

2009-04-22 Thread Peter Otten
Dr Mephesto wrote:

> I have a quick question about global namespace, and I'm hoping someone
> could give a quick reply to sort me out :)
> 
> I have a single file program that uses numpy, and it works just fine.
> I want to move some classes into their own files, to make the code
> reusable.  When I cut and paste the the classes into new files, and
> then "import" them back into the original program, I get an
> error,:"NameError: name 'numpy' is not defined", called about the new
> class files.
> 
> If I add a "global numpy" to the beginning of each class in the new
> files, the program runs. Do I really have to add "global XXX" for
> every module I import in the main program into every module I create
> and import? Why are the class files I created not seeing the top
> namespace?

The global namespace in Python is actually a module-wide namespace. You have
to put an

import numpy

at the top of every module that uses numpy. 

I lack the fantasy to imagine what exactly you have done that "global numpy"
has the described effect. It's probably not pretty.

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


Re: pyflakes, pylint, pychecker - and other tools

2009-04-22 Thread Esmail

Colin J. Williams wrote:

Esmail wrote:

What is the consensus of the Python community regarding these
code checkers?

In particular, are the stylistic recommendations that
pylint makes considered sensible/valid?


pylint seems a bit heavy handled, a bit too much PEP 8, 


Just having used this for a short while, I would have to agree,
though for someone coming to Python from other languages (like
myself) it does provide some stylistic guidance, at least initially,
to do it the Pythonic way.

which was 
intended as a guide, rather than a prescription.



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


Re: Re: Weird lambda behavior

2009-04-22 Thread Rüdiger Ranft
Chris Rebert schrieb:
> On Wed, Apr 22, 2009 at 4:50 AM, Rüdiger Ranft <[email protected]> wrote:
>> Hi all,
>>
>> I want to generate some methods in a class using setattr and lambda.
>> Within each generated function a name parameter to the function is
>> replaced by a string constant, to keep trail which function was called.
>> The problem I have is, that the substituted name parameter is not
>> replaced by the correct name of the function, but by the last name the
>> for loop has seen.
>>
>> import unittest
>>
>> class WidgetDummy:
>>'''This class records all calls to methods to an outer list'''
>>
>>def __init__( self, name, calls ):
>>'''name is the name of the object, which gets included into a
>>call record. calls is the list where the calls are appended.'''
>>self.name =ame
>>self.calls =alls
>>for fn in ( 'Clear', 'Append', 'foobar' ):
>>func =ambda *y,**z: self.__callFn__( fn, y, z )
>>setattr( self, fn, func )
> 
> Common wart to run into as of late. fn (in the lambda) doesn't get
> evaluated until the call-time of the lambda, by which point the loop
> has finished and the loop variable has been changed to its final
> value, which is used by the lambda.

Doh! I wasn't aware of the point when the lambda expression is evaluated.

> Workaround:
> #exact syntax may vary with your version of Python, but you should be
> able to get the idea
> func =ambda *y,**z, fn=fn: self.__callFn__( fn, y, z )
> 
> The default argument value gets evaluated at definition-time, thus
> forcing the right value of fn within the function.

Thank you, I replaced the direct assignment with a proxy function call,
and now it works.

def __init__( self, name, calls ):
self.name = name
self.calls = calls

def forceEval(x):
setattr( self, fn, lambda *y,**z: self.__callFn__(x, y, z) )

for fn in ( 'Clear', 'Append', 'foobar' ):
forceEval(fn)

-- 
GPG encrypted mails preferred.
GPG verschlüsselte Mails bevorzugt.
---> http://chaosradio.ccc.de/media/ds/ds085.pdf Seite 20 <

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


Re: Best Python Web Framework ?

2009-04-22 Thread SKYLAB
On 21 Nisan, 23:56, "[email protected]" 
wrote:
> On Apr 21, 2:46 pm, SKYLAB  wrote:
>
> > Greetings..
>
> > First , my english is not good .
>
> > I heard that was written in python ( Youtube Programming Language :
> > PYTHON :S ) Correct ?
>
> > That's not correct ? Then youtube is PHP application ?
>
> > That's correct ; Which python web framework in friendfeed ? Web.py ?
> > Django ? web2py ?
>
> > Thanks..
>
> There may not be a "best" web framework -- only one that is best for
> you and what you need to do with it.
>
> If you want a large and feature-rich framework, try django.
>
> If you want something smaller and simpler, maybe try Karrigell. Also,
> Werkzeughttp://werkzeug.pocoo.org/seems actively developed and well-
> documented.
>
> Dunno what youtube or friendfeed use. Google might tell you.
>
> Enjoy experimenting. :)

Thanks. Django 4EVER :)

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


Re: Please help me grok: webserver > python

2009-04-22 Thread bobicanprogram
On Apr 21, 3:20 pm, Phillip B Oldham  wrote:
> I'm having trouble grok'ing how to get python talking through a
> webserver. I've got a lot of experience working with nginx+php-fcgi
> (via a unix socket) and I'd like to know what would be the bare
> minimum to get python talking in the same way.
>
> Now, I've looked at modules like CherryPy but they're all a little
> high level and talk via http. I'd like to know how to mimic the php
> setup I'm used to; I've no specific goal other than to become
> aquainted with the python environment.
>
> Any examples would be great!


There is some example code at:

http://www.icanprogram.com/06py/lesson7/lesson7.html

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


What is the best framework or module in Python for a small GUI based application development?

2009-04-22 Thread srinivasan srinivas

Hi,
Could you suggest me some modules in Python which can be used to develop GUI 
based applications? and tell me which could be the best(in terms of 
efficiency) one for a small GUI based application development?

Thanks,
Srini


  Bollywood news, movie reviews, film trailers and more! Go to 
http://in.movies.yahoo.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: namespace query

2009-04-22 Thread Dr Mephesto
ok, sorted. I had thought that when a module was imported, it was
added to a larger shared namespace used by all the modules.


And yes, you are all correct; the "global numpy" thing was an illusion
caused by saving the file at the wrong time after making a few
changes.


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


Re: namespace query

2009-04-22 Thread Marco Mariani

Dr Mephesto wrote:



ok, sorted. I had thought that when a module was imported, it was
added to a larger shared namespace used by all the modules.


Now, that would be awfulll

Because one of the most important things about python (and the reason I 
can live without an IDE) is that I can point my finger to an object 
somewhere and tell you where it comes from, without loading a different 
source file.


For the same reason, import * is frowned upon, especially because it's 
transitive (and contagious).


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


Re: Install NumPy in python 2.6

2009-04-22 Thread David Cournapeau
On Wed, Apr 22, 2009 at 9:11 PM, Ole Streicher  wrote:
> Hi Eduardo,
>
> Eduardo Lenz  writes:
>> On Wednesday 22 April 2009 04:47:54 David Cournapeau wrote:
>>> On Wed, Apr 22, 2009 at 6:38 PM, Ole Streicher 
>> wrote:
>>> > but scipy then fails:
>>> > error: Lapack (http://www.netlib.org/lapack/) libraries not found.
>>> > What is the reason for that?
>
>> try ATLAS instead.
>
> I did:
> $ easy_install --prefix=/work/python/ atlas-0.27.0.tar.gz
> $ ls -l /work/python/lib/python2.6/site-packages/atlas-0.27.0-py2.6.egg
> -rw-r--r-- 1 os gr 98386 2009-04-22 14:05 
> /work/python/lib/python2.6/site-packages/atlas-0.27.0-py2.6.egg

ATLAS is an optimized version of BLAS/LAPACK, and has nothing to do
with python. You can't install it with easy_install, you need to build
it by yourself. I would advise against using it unless you need fast
linear algebra for big matrices. Building ATLAS is a pain, and is
maybe the number one issue for newcomers who try to build numpy. You
can always install it later if you want,

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


Re: Python, MS SQL, and batch inserts

2009-04-22 Thread pruebauno
On Apr 21, 5:21 pm, Scott David Daniels  wrote:
> [email protected] wrote:
> > On Apr 21, 4:01 pm, [email protected] wrote:
> >> On Apr 21, 3:36 pm, Scott David Daniels  wrote:
> >>>  I forget the name of the SQL Server bulk loader, 
>
> bcp (bulk copy) was the name of the bulk loader.  I just remembered.
>
> Sorry, no more exciting advice.  it does sound like a good idea to go
> to a SQL Server group.
>
> --Scott David Daniels
> [email protected]

For MS SQL try:

BULK INSERT AdventureWorks.Sales.SalesOrderDetail
FROM '':\\''
WITH (ROWTERMINATOR = '''+CHAR(10)+''')
--
http://mail.python.org/mailman/listinfo/python-list


need help with a multiloop error

2009-04-22 Thread Brian
I'm trying to run a python program with a multiloop and I am getting
this error message.  I was wondering if anyone could tell from this
message what I'm doing wrong or where I've made a mistake.  Let me
know if you need some of the code for this to make more sense.  Thanks
a lot.


How much labor time does each individual have?8
1331
Traceback (most recent call last):

  File "C:\Python25\commodity\commoditytrading4.2.py  ", line 233, in 

options = mp.options(all,names)
  File "C:\Python25\commodity\multipleloop.py", line 265, in options
for name, value in zip(names, experiment)]))
  File "C:\Python25\commodity\misc.py", line 244, in str2obj
b = str2bool(s)
  File "C:\Python25\commodity\misc.py", line 155, in str2bool
(s, type(s))
TypeError: 0.0  cannot be converted to bool
--
http://mail.python.org/mailman/listinfo/python-list


Re: What is the best framework or module in Python for a small GUI based application development?

2009-04-22 Thread Mike Driscoll
On Apr 22, 8:11 am, srinivasan srinivas 
wrote:
> Hi,
> Could you suggest me some modules in Python which can be used to develop GUI 
> based applications? and tell me which could be the best(in terms of 
> efficiency) one for a small GUI based application development?
>
> Thanks,
> Srini
>

See the Python Wiki: http://wiki.python.org/moin/GuiProgramming

Python comes with Tkinter, which is good for simple programs and some
of the people on this list use it for very complicated programs. I
like wxPython. There are many others as well. It really depends on
what you want to do and whether or not you need special widgets.

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


Re: python command not working

2009-04-22 Thread 83nini
On 22 Apr, 13:45, David Cournapeau  wrote:
> On Wed, Apr 22, 2009 at 8:43 PM, Christian Heimes  wrote:
>
> > My way doesn't add the dlls to the search path. It allows you to have
> > multiple python commands at once, too. I have shortcuts for python24,
> > python25 and python26 on my Windows box.
>
> Ah, thanks, that's really useful. I need this too, and did it the
> "unix" way, which did not work so well for various reasons. This is
> much better,
>
> David

Excuse me guys, could you please help me and tell me step by step how
to make the bat file that Christian is talking about and save it in
the System32?

I'm trying to save anything there but it's not working, though i'm the
administrator, vista keeps telling me that i can't save anything to
the system32 folder and that i have to contact my admin. in order to
fix it!

thanks for the help.
cheers,
Lina
--
http://mail.python.org/mailman/listinfo/python-list


Re: need help with a multiloop error

2009-04-22 Thread MRAB

Brian wrote:

I'm trying to run a python program with a multiloop and I am getting
this error message.  I was wondering if anyone could tell from this
message what I'm doing wrong or where I've made a mistake.  Let me
know if you need some of the code for this to make more sense.  Thanks
a lot.


How much labor time does each individual have?8
1331
Traceback (most recent call last):

  File "C:\Python25\commodity\commoditytrading4.2.py  ", line 233, in 

options = mp.options(all,names)
  File "C:\Python25\commodity\multipleloop.py", line 265, in options
for name, value in zip(names, experiment)]))
  File "C:\Python25\commodity\misc.py", line 244, in str2obj
b = str2bool(s)
  File "C:\Python25\commodity\misc.py", line 155, in str2bool
(s, type(s))
TypeError: 0.0  cannot be converted to bool


What is str2bool? Having the code would definitely help!
--
http://mail.python.org/mailman/listinfo/python-list


Re: need help with a multiloop error

2009-04-22 Thread Jeremiah Dodds
On Wed, Apr 22, 2009 at 3:07 PM, Brian  wrote:

> I'm trying to run a python program with a multiloop and I am getting
> this error message.  I was wondering if anyone could tell from this
> message what I'm doing wrong or where I've made a mistake.  Let me
> know if you need some of the code for this to make more sense.  Thanks
> a lot.
>
>
> How much labor time does each individual have?8
> 1331
> Traceback (most recent call last):
>
>  File "C:\Python25\commodity\commoditytrading4.2.py  commoditytrading4.2.py> ", line 233, in 
>
>options = mp.options(all,names)
>  File "C:\Python25\commodity\multipleloop.py", line 265, in options
>for name, value in zip(names, experiment)]))
>  File "C:\Python25\commodity\misc.py", line 244, in str2obj
>b = str2bool(s)
>  File "C:\Python25\commodity\misc.py", line 155, in str2bool
>(s, type(s))
> TypeError: 0.0  cannot be converted to bool
> --
> http://mail.python.org/mailman/listinfo/python-list
>


I think we'd have to see your str2* functions. I'm a bit confused as to why
they exist anyhow, as the normal "if foo" tends to work in most situations.

What are you trying to do? Why do you need str2obj, and str2bool? I'm
betting that there's a much better way to solve what you're trying to, but
we're going to need some more info (and code) to help.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Weird lambda behavior

2009-04-22 Thread Dave Angel

Rüdiger Ranft wrote:

Hi all,

I want to generate some methods in a class using setattr and lambda.
Within each generated function a name parameter to the function is
replaced by a string constant, to keep trail which function was called.
The problem I have is, that the substituted name parameter is not
replaced by the correct name of the function, but by the last name the
for loop has seen.

import unittest

class WidgetDummy:
'''This class records all calls to methods to an outer list'''

def __init__( self, name, calls ):
'''name is the name of the object, which gets included into a
call record. calls is the list where the calls are appended.'''
self.name = name
self.calls = calls
for fn in ( 'Clear', 'Append', 'foobar' ):
func = lambda *y,**z: self.__callFn__( fn, y, z )
setattr( self, fn, func )

def __callFn__( self, fnName, *args ):
'''Add the function call to the call list'''
self.calls.append( ( self.name, fnName, args ) )

class Testcase( unittest.TestCase ):
def testFoo( self ):
calls = []
wd = WidgetDummy( 'foo', calls )
wd.Append( 23 )
self.assertEqual( [ ( 'foo', 'Append', ( 23, {} ) ) ], calls )

unittest.main()

  
This is a common problem on this list.  I was possibly the last one to 
ask what was essentially the same question, though it was on the 
wxPython list, 3/15/09 - "Using lambda function within event binding"


Anyway, the answer is that when (free) variables are used inside any 
nested function (a def inside a def, or a lambda), these variables are 
not copied, they are scoped from the nesting environment.  So even 
though the __init__ may have ended, all these lambda functions still 
retain a reference to the same 'fn' variable, which is kept alive till 
all the lambda functions are gone.  Lookup closures if you want to 
understand more, or use dis() on the function.


The simplest solution is a hack, but a common one.  Use default 
variables, which have a lifetime that matches the lambda, but are 
initialized when the lambda is being created.  To do this, you'd add an 
extra optional argument to the lambda, and use that as the first 
argument to the call.   Unfortunately, although this is what I used, I 
don't know if you can do it when you're already using the *y syntax.  In 
the line below, I assumed you could change to exactly one non-keyword 
argument.


func = lambda y, unlikelydummyname=fn, **z: self.__callFn__( fn, y, **z )


Incidentally, in your example, I believe you needed the *y and **z in 
the actual parameters to __callFn__().   You had omitted the asterisks.  
Further, you had no keyword arguments in the formal parameter list.  So 
I'm not sure where you were really headed.  But perhaps the above will 
get you started.



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


Re: python command not working

2009-04-22 Thread 83nini
On 22 Apr, 16:23, 83nini <[email protected]> wrote:
> On 22 Apr, 13:45, David Cournapeau  wrote:
>
> > On Wed, Apr 22, 2009 at 8:43 PM, Christian Heimes  wrote:
>
> > > My way doesn't add the dlls to the search path. It allows you to have
> > > multiple python commands at once, too. I have shortcuts for python24,
> > > python25 and python26 on my Windows box.
>
> > Ah, thanks, that's really useful. I need this too, and did it the
> > "unix" way, which did not work so well for various reasons. This is
> > much better,
>
> > David
>
> Excuse me guys, could you please help me and tell me step by step how
> to make the bat file that Christian is talking about and save it in
> the System32?
>
> I'm trying to save anything there but it's not working, though i'm the
> administrator, vista keeps telling me that i can't save anything to
> the system32 folder and that i have to contact my admin. in order to
> fix it!
>
> thanks for the help.
> cheers,
> Lina

Christian,
at last i made the bat file (python25.bat) that contains the following
contents:

---
@C:\Python25\python.exe %*
---

could you tell me how to call python25 in the batch files? what batch
files do you mean? where do i find them?
--
http://mail.python.org/mailman/listinfo/python-list


Re: [Py2exe-users] installer for py2exe files?

2009-04-22 Thread Gabriel Rossetti

Gabriel Rossetti wrote:

Hello everyone,

I am wanting to create an installer for my project. I first use py2exe 
to create win32 executables and then would like to have an easy to use 
(for the end user) installer. I would need the installer to launch a 
script (a python script also turned into an exec) after the install is 
done, or even better yet, incorperate the script's tasks in the 
installation process (configure files, check for open ports, etc.). Does 
anyone have an idea, recommendation or has had a similar situation before?


Thanks!
Gabriel
  
Thank you for your answers, I think that I'm going to use NSI since it 
has a great eclipse plugin that helps out a lot and can create forms and 
all.


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


gethostbyname blocking

2009-04-22 Thread marc wyburn
Hi, I am writing an asynchronous ping app to check if 1000s of hosts
are alive very quickly.  Everything works extremely quickly unless the
host name doesn't have a DNS record.

when calling socket.gethostbyname if there is no record for the host
the result seems to block all other threads.  As an example I have 6
threads running and if I pass the class below a Queue with about 30
valid addresses with one invalid address in the middle the thread that
the exception occurs in seems to block the others.

I'm pretty new to threading so am not sure if my threading code is
wrong or whether I need to look at how gethostbyname?  When there list
is made entirely of valid host names I get the responses back very
very quickly.

class HostThread(threading.Thread):
def __init__(self, Host_Queue):
threading.Thread.__init__(self)
self.Host_Queue = Host_Queue
def run(self):
while True:
# Create a new IP packet and set its source and
destination addresses.
host = self.Host_Queue.get()
try:
dest_addr, alias, ipaddrlist  =
socket.gethostbyname_ex(host)
except socket.gaierror, (errorno, details):
print '%s: %s' %(host,details)
else:
print '%s: %s' %(host, ipaddrlist)
self.Host_Queue.task_done()

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


Re: python in Emacs (windows)

2009-04-22 Thread David Robinow
On Wed, Apr 22, 2009 at 3:52 AM, Mark Zweers  wrote:
> Hi!
>
> I'm trying to run python from within Emacs. This is in my .emacs file :
>
> (setq auto-mode-alist ; trigger python mode automatically
>    (cons '("\\.py$" . python-mode) auto-mode-alist))
> (setq interpreter-mode-alist
>    (cons '("python" . python-mode)
>         interpreter-mode-alist))
> (autoload 'python-mode "python-mode" "Python editing mode." t)
>
> , but I got this message :
>
> "Searching for program: no such file or directory, python"
>
> So I've added the following line :
>
> (setq py-python-command '("C:/Program Files/Python"))
>
> This is the path where my 'python.exe' is located. But then this message
> occurs:
>
> Using the CPython shell
> let: Wrong type argument: integerp, "C:/Program Files/Python"
>
> Could anyone tell me how to solve this? Thanks a lot in advance!
>
> Mark
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>
1: Try:
   (setq py-python-command "C:/Program Files/Python")

2: Putting your python in "Program Files" is demented.

3. If you put python in your PATH you don't have to set the variable
at all. (Not necessarily recommended, but it's an option.)

4. python-mode supports customize. That might be less error-prone than
trying to set py-python-command in your .emacs

5. Are you aware that emacs comes with a python mode? (python.el in
lisp/progmodes).
Not that it's necessarily better, but I'm curious why you rejected it
for a mode that you don't know how to use.
--
http://mail.python.org/mailman/listinfo/python-list


pylab quick reference? (matplotlib)

2009-04-22 Thread Esmail

Hello all,

Does anyone know of a quick reference for the various plotting
functions for pylab? I'm just getting started with this
after years of work with gnuplot.

I found this

  http://matplotlib.sourceforge.net/api/pyplot_api.html

which is very comprehensive and would be good for digging into
specific commands. What I'm looking for is something small enough
to print out (< 10-20 pages) that gives a sufficient overview so
that I know what's available.

I've looked on the web without much success. I'd be grateful if
you have any pointers.

Thanks!
Esmail

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


Re: python command not working

2009-04-22 Thread Scott David Daniels

83nini wrote:
... at last i made the bat file (python25.bat) that contains the 
following contents:

---
@C:\Python25\python.exe %*
---
could you tell me how to call python25 in the batch files? what batch
files do you mean? where do i find them?


"python25.bat" or "python25.cmd" are acceptable names for that file.

Assuming you have a command window, if you enter the command,
C:\WhereEver> echo %path%
you will see a semicolon-separated list of directories.  Put the
file in any of the directories on that list.  You should then be
able to use the command:
C:\WhereEver> python25 

Personally, I would use the name "python25.cmd", but that may just be
superstition on my part about the difference between .bat and .cmd
files.

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


Re: What is the best framework or module in Python for a small GUI based application development?

2009-04-22 Thread srinivasan srinivas

Thanks for the info.
My requirement is to write an application which is GUI based has to run on 
browsers. Could you tell me which one would be suitable for this?



- Original Message 
From: Mike Driscoll 
To: [email protected]
Sent: Wednesday, 22 April, 2009 7:51:33 PM
Subject: Re: What is the best framework or module in Python for a small GUI 
based application development?

On Apr 22, 8:11 am, srinivasan srinivas 
wrote:
> Hi,
> Could you suggest me some modules in Python which can be used to develop GUI 
> based applications? and tell me which could be the best(in terms of 
> efficiency) one for a small GUI based application development?
>
> Thanks,
> Srini
>

See the Python Wiki: http://wiki.python.org/moin/GuiProgramming

Python comes with Tkinter, which is good for simple programs and some
of the people on this list use it for very complicated programs. I
like wxPython. There are many others as well. It really depends on
what you want to do and whether or not you need special widgets.

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



  Now surf faster and smarter ! Check out the new Firefox 3 - Yahoo! 
Edition http://downloads.yahoo.com/in/firefox/
--
http://mail.python.org/mailman/listinfo/python-list


Ending data exchange through multiprocessing pipe

2009-04-22 Thread Michal Chruszcz
Hi,

I am adding support for parallel processing to an existing program
which fetches some data and then performs some computation with
results saved to a database. Everything went just fine until I wanted
to gather all of the results from the subprocesses.

First idea, which came to my mind, was using a queue. I've got many
producers (all of the workers) and one consumer. Seams quite simple,
but it isn't, at least for me. I presumed that each worker will put()
its results to the queue, and finally will close() it, while the
parent process will get() them as long as there is an active
subprocess. So I did this:

>>> from multiprocessing import Process, Queue, active_children
>>>
>>> def f(q):
... q.put(1)
... q.close()
...
>>> queue = Queue()
>>> Process(target=f, args=(queue,)).start()
>>> while len(active_children()) > 0:
... print queue.get()
...
1

This (of course?) hangs after first iteration of the loop. Delaying
second iteration by putting a sleep() call fixes the problem, since
the result of active_children is being some kind of refreshed, but
it's not the solution. One could say to iterate the exact number of
subprocesses I have, but let's presume such information isn't
available.

Due to my failure with queues I decided to have a try with pipes, and
again I found a behavior, which is at least surprising and not
obvious. When I use a pipe within a process everything works
perfectly:

>>> from multiprocessing import Pipe
>>> parent, child = Pipe()
>>> child.send(1)
>>> child.close()
>>> parent.recv()
1
>>> child.closed
True
>>> parent.recv()
Traceback (most recent call last):
  File "", line 1, in 
EOFError

The problems appear in subprocess communication using pipes, though.

>>> from multiprocessing import Process, Pipe
>>> def f(child):
... child.send(1)
... child.close()
...
>>> parent, child = Pipe()
>>> Process(target=f, args=(child,)).start()
>>> parent.recv()
1
>>> child.closed
False
>>> parent.recv()

... and hangs. No idea of fixing this, not even of a workaround, which
would solve my problem.

Most possibly I'm missing something in philosophy of multiprocessing,
but I couldn't find anything covering such a situation. I'd appreciate
any kind of hint on this topic, as it became a riddle I just have to
solve. :-)

Best regards,
Michal Chruszcz
--
http://mail.python.org/mailman/listinfo/python-list


Re: What is the best framework or module in Python for a small GUI based application development?

2009-04-22 Thread Diez B. Roggisch
srinivasan srinivas wrote:

> 
> Thanks for the info.
> My requirement is to write an application which is GUI based has to run on
> browsers. Could you tell me which one would be suitable for this?

There is no GUI-framework on browsers. There is HTML/CSS + JS, which is
produced by servers that can be implemented from raw CGI to the ZOPE
apps-server. Google for python web frameworks.

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


Re: Weird lambda behavior

2009-04-22 Thread Diez B. Roggisch
Rüdiger Ranft wrote:

> Hi all,
> 
> I want to generate some methods in a class using setattr and lambda.
> Within each generated function a name parameter to the function is
> replaced by a string constant, to keep trail which function was called.
> The problem I have is, that the substituted name parameter is not
> replaced by the correct name of the function, but by the last name the
> for loop has seen.

Python's closures don't capture the values, but only the names they contain
when they are created. So whatever value is bound to that name as last is
used.

to overcome this, you need to create another closure or bind the value to a
name local to the created function via named arguments:

>>> for f in [lambda i=i: i**2 for i in xrange(10)]:
... f()
...
0
1
4
9
16
25
36
49
64
81


Diez




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


Re: What is the best framework or module in Python for a small GUI based application development?

2009-04-22 Thread Tim Chase

My requirement is to write an application which is GUI based
has to run on browsers. Could you tell me which one would be
suitable for this?


These are generally 2 different things:  either you're writing a 
local GUI rich-client (in which case, use the GuiProgramming wiki 
link Mike sent), or you're doing web development targeting 
browsers in which case you should investigate the myriad web 
programming frameworks for Python (Django, Turbogears, CheryPy, 
web.py, webstack, etc).


There's a third "type" of application that I abhor, usually 
developed in Flash/Silverblight/JavaFX that runs within a 
web-browser, but allows for richer interactions/rendering than 
your average web-page.  However, I don't know of any python 
tie-ins for any of these environments.


There's also a blurred line if you embed a web-browser in a local 
GUI application.


-tkc




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


Re: Would you support adding UNC support to os.path on Windows?

2009-04-22 Thread Aahz
In article ,
Larry Hastings   wrote:
>
>I've written a patch for Python 3.1 that changes os.path so it handles 
>UNC paths on Windows.  You can read about it at the Python bug tracker:
>
>http://bugs.python.org/issue5799
>
>I'd like to gauge community interest in the patch.  After all, it's has 
>been declined before; I submitted a similar patch for 1.5.2 way back in 
>1999.  (You can read the details of that on the tracker page too.)

You should bring this up on python-dev.
-- 
Aahz ([email protected])   <*> http://www.pythoncraft.com/

"If you think it's expensive to hire a professional to do the job, wait
until you hire an amateur."  --Red Adair
--
http://mail.python.org/mailman/listinfo/python-list


Re: Weird lambda behavior

2009-04-22 Thread Scott David Daniels

Dave Angel wrote:
... Incidentally, in your example, I believe you needed the *y and **z in 
the actual parameters to __callFn__()


Also, use a name like __callFn rhather than __callFn__ -- You are 
treading on Pythons internal names if you put __ at the beginning

_and_ the end, and will confuse your reader (they may be fooled into
looking up what the "__callFn__" special method does in addition to
normal method behaviors.

--Scott David Daniels
[email protected]

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


Re: generating random tuples in python

2009-04-22 Thread Michael Spencer

Robert Kern wrote:

On 2009-04-20 23:04, per wrote:


to be more formal by very different, i would be happy if they were
maximally distant in ordinary euclidean space... so if you just plot
the 3-tuples on x, y, z i want them to all be very different from each
other.  i realize this is obviously biased and that the tuples are not
uniformly distributed -- that's exactly what i want...

any ideas on how to go about this?


Perhaps it would help if you told us what application you are going to 
use them for? 


Perhaps it's a glowworm arrangement problem:
http://books.google.com/books?id=pzj90slTTEIC&printsec=frontcover#PPA267,M1

M

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


Re: What is the best framework or module in Python for a small GUI based application development?

2009-04-22 Thread Mike Driscoll
On Apr 22, 10:51 am, Tim Chase  wrote:
> > My requirement is to write an application which is GUI based
> > has to run on browsers. Could you tell me which one would be
> > suitable for this?
>
> These are generally 2 different things:  either you're writing a
> local GUI rich-client (in which case, use the GuiProgramming wiki
> link Mike sent), or you're doing web development targeting
> browsers in which case you should investigate the myriad web
> programming frameworks for Python (Django, Turbogears, CheryPy,
> web.py, webstack, etc).
>
> There's a third "type" of application that I abhor, usually
> developed in Flash/Silverblight/JavaFX that runs within a
> web-browser, but allows for richer interactions/rendering than
> your average web-page.  However, I don't know of any python
> tie-ins for any of these environments.
>
> There's also a blurred line if you embed a web-browser in a local
> GUI application.
>
> -tkc

Technically speaking, Silverlight can be run with IronPython...which
works on Windows and Linux (through Mono), but not Mac (as far as I
know).

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


Re: pyflakes, pylint, pychecker - and other tools

2009-04-22 Thread Aahz
In article , Colin J. Williams  wrote:
>
>pylint seems a bit heavy handled, a bit too much PEP 8, which was
>intended as a guide, rather than a prescription.

That's half-true on both counts:

First of all, any new library must be PEP 8-compliant for submission to
the standard library, so PEP 8 is indeed somewhat prescriptive.

Second, you can configure pylint to respect your personal style; I think
that pylint's default PEP 8 configuration makes a lot of sense.
-- 
Aahz ([email protected])   <*> http://www.pythoncraft.com/

"If you think it's expensive to hire a professional to do the job, wait
until you hire an amateur."  --Red Adair
--
http://mail.python.org/mailman/listinfo/python-list


Re: gethostbyname blocking

2009-04-22 Thread Jean-Paul Calderone

On Wed, 22 Apr 2009 08:08:51 -0700 (PDT), marc wyburn 
 wrote:

Hi, I am writing an asynchronous ping app to check if 1000s of hosts
are alive very quickly.  Everything works extremely quickly unless the
host name doesn't have a DNS record.

when calling socket.gethostbyname if there is no record for the host
the result seems to block all other threads.  As an example I have 6
threads running and if I pass the class below a Queue with about 30
valid addresses with one invalid address in the middle the thread that
the exception occurs in seems to block the others.


If your system doesn't have the gethostbyname_r function, then you can
only make one gethostbyname_ex call at a time - a call to this function
will block any other calls to this function, since it is not safe to
call gethostbyname reentrantly.

I'm not sure what the easiest way to determine whether Python has found
gethostbyname_r or not on your system is.  The configure script used to
build Python will probably tell, but I doubt you have that lying around.
You could just assume this is the case, since you're observing behavior
consistent with it. ;)

An alternate approach would be to use a DNS library which doesn't have
this restriction.  For example, Twisted includes a DNS library which
is not implemented in terms of threads.  There are also a couple other
Python DNS client libraries around.

This isn't /quite/ the same as using gethostbyname, though, since
gethostbyname is controlled by system configuration in various ways,
and may do more than just DNS lookups (in fact, it may even be
configured not to use DNS at all!).  But it's pretty close, and may
be close enough for your purposes.

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


Re: Ending data exchange through multiprocessing pipe

2009-04-22 Thread MRAB

Michal Chruszcz wrote:

Hi,

I am adding support for parallel processing to an existing program
which fetches some data and then performs some computation with
results saved to a database. Everything went just fine until I wanted
to gather all of the results from the subprocesses.

First idea, which came to my mind, was using a queue. I've got many
producers (all of the workers) and one consumer. Seams quite simple,
but it isn't, at least for me. I presumed that each worker will put()
its results to the queue, and finally will close() it, while the
parent process will get() them as long as there is an active
subprocess. So I did this:


from multiprocessing import Process, Queue, active_children

def f(q):

... q.put(1)
... q.close()
...

queue = Queue()
Process(target=f, args=(queue,)).start()
while len(active_children()) > 0:

... print queue.get()
...
1

This (of course?) hangs after first iteration of the loop. Delaying
second iteration by putting a sleep() call fixes the problem, since
the result of active_children is being some kind of refreshed, but
it's not the solution. One could say to iterate the exact number of
subprocesses I have, but let's presume such information isn't
available.

Due to my failure with queues I decided to have a try with pipes, and
again I found a behavior, which is at least surprising and not
obvious. When I use a pipe within a process everything works
perfectly:


from multiprocessing import Pipe
parent, child = Pipe()
child.send(1)
child.close()
parent.recv()

1

child.closed

True

parent.recv()

Traceback (most recent call last):
  File "", line 1, in 
EOFError

The problems appear in subprocess communication using pipes, though.


from multiprocessing import Process, Pipe
def f(child):

... child.send(1)
... child.close()
...

parent, child = Pipe()
Process(target=f, args=(child,)).start()
parent.recv()

1

child.closed

False

parent.recv()


... and hangs. No idea of fixing this, not even of a workaround, which
would solve my problem.

Most possibly I'm missing something in philosophy of multiprocessing,
but I couldn't find anything covering such a situation. I'd appreciate
any kind of hint on this topic, as it became a riddle I just have to
solve. :-)


You could do this:

from multiprocessing.queues import Empty

queue = Queue()
Process(target=f, args=(queue,)).start()
while active_children():
try:
print queue.get(timeout=1)
except Empty:
pass
--
http://mail.python.org/mailman/listinfo/python-list


Re: gethostbyname blocking

2009-04-22 Thread marc wyburn
On Apr 22, 5:19 pm, Jean-Paul Calderone  wrote:
> On Wed, 22 Apr 2009 08:08:51 -0700 (PDT), marc wyburn 
>  wrote:
> >Hi, I am writing an asynchronous ping app to check if 1000s of hosts
> >are alive very quickly.  Everything works extremely quickly unless the
> >host name doesn't have a DNS record.
>
> >when calling socket.gethostbyname if there is no record for the host
> >the result seems to block all other threads.  As an example I have 6
> >threads running and if I pass the class below a Queue with about 30
> >valid addresses with one invalid address in the middle the thread that
> >the exception occurs in seems to block the others.
>
> If your system doesn't have the gethostbyname_r function, then you can
> only make one gethostbyname_ex call at a time - a call to this function
> will block any other calls to this function, since it is not safe to
> call gethostbyname reentrantly.
>
> I'm not sure what the easiest way to determine whether Python has found
> gethostbyname_r or not on your system is.  The configure script used to
> build Python will probably tell, but I doubt you have that lying around.
> You could just assume this is the case, since you're observing behavior
> consistent with it. ;)
>
> An alternate approach would be to use a DNS library which doesn't have
> this restriction.  For example, Twisted includes a DNS library which
> is not implemented in terms of threads.  There are also a couple other
> Python DNS client libraries around.
>
> This isn't /quite/ the same as using gethostbyname, though, since
> gethostbyname is controlled by system configuration in various ways,
> and may do more than just DNS lookups (in fact, it may even be
> configured not to use DNS at all!).  But it's pretty close, and may
> be close enough for your purposes.
>
> Jean-Paul

Thanks for the quick response.  I'm using Win32, I don't think there
is a non-blocking gethostbyname avail.  I managed to find some info on
the net but most of it was old and Nix related and I was hoping it was
a bug that had been fixed and I was making a mistake with my threads.
I wrote a simlar script that uses multiprocess and that seemed to have
less problems but I will look at http://www.dnspython.org/.

Thanks, Marc.

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


Re: relation class

2009-04-22 Thread Aaron Brady
On Apr 22, 12:09 am, Chris Rebert  wrote:
> On Tue, Apr 21, 2009 at 5:51 PM, Aaron Brady  wrote:
> > Hi all,
>
> > I think Python should have a relation class in the standard library.
> > Fat chance.
>
> Perhaps I'm not understanding "relation" correctly, but are you not
> aware ofhttp://docs.python.org/library/sqlite3.html?
>
> Cheers,
> Chris
> --
> I have a blog:http://blog.rebertia.com

Yes, I am aware of it.  I should have mentioned.  It is much the same
as what I am picturing, especially with the special ':memory:' name
for creating in RAM.

It only supports numbers and strings, which makes it appropriate for
persistence but not in-memory objects.  It is also very advanced
compared to what I am picturing.

Its strategy for the syntax of the select statement is to use a
string, followed by the arguments for interpolation.  How could you
use it to map, say, tree nodes back and forth to their parents?

There are many data structures which are in undirected relations to
others.
--
http://mail.python.org/mailman/listinfo/python-list


Re: unpythonic use of property()?

2009-04-22 Thread Luis Zarrabeitia
On Monday 20 April 2009 11:29:19 am J Kenneth King wrote:
> Changing the ID value would break things on the server, so I
> wanted to write the interface class to respect those conventions.

Then, take this opportunity fix the server and prevent it from breaking once 
you change the ID, because:

> I'm well aware that if a developer really wanted to, they could get
> around it no matter what I did, but I figure that if I at least make
> it really difficult it will be obvious that they're really going into
> dangerous territory.

you will have to do it anyway.

I think it's great, for you, that the language you are using makes it so 
extremely easy to bypass almost any access restriction that you may put in 
the data sent to your clients. That means that you won't be overconfident, 
that you are forced to make sound decisions from the beginning, and that you 
won't be trusting that your clients will be well behaved (even with very 
strong enforcement of data hiding, a malicious client could forge the 
connection).

Then, when the server is safe from user data, by all means go and make sure 
that the clients (and even the server!) will complain as loudly as possible 
if they want to break encapsulation.

-- 
Luis Zarrabeitia (aka Kyrie)
Fac. de Matemática y Computación, UH.
http://profesores.matcom.uh.cu/~kyrie
--
http://mail.python.org/mailman/listinfo/python-list


RE: pylab quick reference? (matplotlib)

2009-04-22 Thread Benjamin J. Racine
Not exactly what you've described, but I like this... I just spot the type of 
plot I'm looking for, copy the code, and I'm off...

http://matplotlib.sourceforge.net/gallery.html

I like this technique better than any formal documentation almost.

Btw, there is a specific matplotlib list as well.  

https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Hope this helps,

Ben R. 

-Original Message-
From: [email protected] 
[mailto:[email protected]] On Behalf Of Esmail
Sent: Wednesday, April 22, 2009 8:28 AM
To: [email protected]
Subject: pylab quick reference? (matplotlib)

Hello all,

Does anyone know of a quick reference for the various plotting functions for 
pylab? I'm just getting started with this after years of work with gnuplot.

I found this

   http://matplotlib.sourceforge.net/api/pyplot_api.html

which is very comprehensive and would be good for digging into specific 
commands. What I'm looking for is something small enough to print out (< 10-20 
pages) that gives a sufficient overview so that I know what's available.

I've looked on the web without much success. I'd be grateful if you have any 
pointers.

Thanks!
Esmail

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


Re: What is the best framework or module in Python for a small GUI based application development?

2009-04-22 Thread John Fabiani
srinivasan srinivas wrote:

> 
> Hi,
> Could you suggest me some modules in Python which can be used to develop
> GUI based applications? and tell me which could be the best(in terms of
> efficiency) one for a small GUI based application development?
> 
> Thanks,
> Srini
> 
> 
>   Bollywood news, movie reviews, film trailers and more! Go to
>   http://in.movies.yahoo.com/

You might consider Dabo (www.dabodev.com) if access to data is required.
John
--
http://mail.python.org/mailman/listinfo/python-list


Re: unpythonic use of property()?

2009-04-22 Thread J Kenneth King
Luis Zarrabeitia  writes:

> On Monday 20 April 2009 11:29:19 am J Kenneth King wrote:
>> Changing the ID value would break things on the server, so I
>> wanted to write the interface class to respect those conventions.
>
> Then, take this opportunity fix the server and prevent it from breaking once 
> you change the ID, because:

Unfortunately it's not my server to fix. I can suggest a patch, but
that's it.

>
>> I'm well aware that if a developer really wanted to, they could get
>> around it no matter what I did, but I figure that if I at least make
>> it really difficult it will be obvious that they're really going into
>> dangerous territory.
>
> you will have to do it anyway.
>
> I think it's great, for you, that the language you are using makes it so 
> extremely easy to bypass almost any access restriction that you may put in 
> the data sent to your clients. That means that you won't be overconfident, 
> that you are forced to make sound decisions from the beginning, and that you 
> won't be trusting that your clients will be well behaved (even with very 
> strong enforcement of data hiding, a malicious client could forge the 
> connection).
>
> Then, when the server is safe from user data, by all means go and make sure 
> that the clients (and even the server!) will complain as loudly as possible 
> if they want to break encapsulation.

Well, really all I'm doing is writing a light framework around xmlrpclib.

The design allows me to keep this kind of exception highly localized,
so its not really a huge practical issue.

The problem I had was that I found two approaches to the same problem
that appeared to be pedantic in difference.

However, you are right of course -- logically the server should
protect against this vulnerability itself instead of the
implementation using my framework.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Would you support adding UNC support to os.path on Windows?

2009-04-22 Thread norseman

Larry Hastings wrote:



I've written a patch for Python 3.1 that changes os.path so it handles 
UNC paths on Windows.  You can read about it at the Python bug tracker:


   http://bugs.python.org/issue5799

I'd like to gauge community interest in the patch.  After all, it's has 
been declined before; I submitted a similar patch for 1.5.2 way back in 
1999.  (You can read the details of that on the tracker page too.)


So: would you like to see this patch committed?  Your votes, ladies and 
gentlemen, if you please.


For what it's worth, Mark Hammond supports this patch.  (But then, iirc 
he supported it 1999 too.)



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


=
So we all start from the same page I have cut'n'pasted from the bugs 
posting:

   -
---This patch changes "ntpath" so all functions handle UNC paths.

In a Windows path string, a UNC path functions *exactly* like a drive
letter.  This patch means that the Python path split/join functions
treats them as if they were.

For instance:
>>> splitdrive("A:\\FOO\\BAR.TXT")
("A:", "\\FOO\\BAR.TXT")

With this patch applied:
>>> splitdrive("HOSTNAME\\SHARE\\FOO\\BAR.TXT")
("HOSTNAME\\SHARE", "\\FOO\\BAR.TXT")

This methodology only breaks down in one place: there is no "default
directory" for a UNC share point.  E.g. you can say
>>> os.chdir("c:")
or
>>> os.chdir("c:foo\\bar")
but you can't say
>>> os.chdir("hostname\\share")

The attached patch changes:
* Modify join, split, splitdrive, and ismount to add explicit support
  for UNC paths.  (The other functions pick up support from these four.)
* Simplify isabs and normpath, now that they don't need to be delicate
  about UNC paths.
* Modify existing unit tests and add new ones.
* Document the changes to the API.
* Deprecate splitunc, with a warning and a documentation remark.
   -

"...This patch changes "ntpath" ..."changing or adding to such a 
module which is OS specific is fine with me.


I get a bit concerned of such changes beyond that.  In order to maintain 
ongoing and (hopefully) onward compatibility (eliminating mandatory 
re-writes of perfectly good code) some things need to be avoided.



To reduce the need to maintain multiple versions of source code I use a 
simple technique:


get OS
if OS == this_one
  NearVerb = function of OS-1-specificVerb
elsif  OS == this_other_one
  NearVerb = function of OS-2-specificVerb
.
etc

NearVerb is a slightly modified but still recognizable synonym that is 
then used through out the code.

(windows) import module as zmodule
(linux)   import module as zmodule
you get the idea
If it needs to modify the parameter list (in either direction) - then it 
does so by being made into a translating function.

(windows) import module as wmodule
def zmodule(string):
  fixit code
  wmodule.string
  more fixit code if needed
  return(normal-form-compatible)

Of course the same test can (and is sometimes required to) be applied to 
sections of code because some OS incompatibilities require it.

Mr. Mark Hammond's module. Excellent work, perfect example.

This has worked perfectly across many Operating Systems including but 
not limited to MVS-OS, Windows, MSDOS, UNIX, Linux, PRIME, DEC, Vax-VMS.


I guess that what I'm trying to get across is DO NOT FAVOR a particular 
OS over another. (Unless it's Linux of course. :)   Seriously - a 
programming or scripting or macro language should concentrate on giving 
the SAME code the SAME functionality (errors and all) across all 
architectures and OS protocols on which it is supposed to run.  IF a 
particular OS has something with no twin in others, there is nothing 
wrong with my 'work-around'.


To point it bluntly:  How does one use "F:" in Linux in the identical 
fashion as a MicroSoft OS?  Remember - drive letters for a given 
removable can change throughout the day in MicroSoft.


That the ntpath be a module and aliasable and contain the changes noted 
in your posting would be ideal.  Doing Network Shares under MicroSoft 
seems to be a moving target in the first place.   So:

"...can ...
>>> os.chdir("c:foo\\bar")
but you can't say
>>> os.chdir("hostname\\share")
..."
should have it's own handlers anyway.

Yes - it would be nice to have the drive letters available for use, but 
not at the expense of the rest of the world.



But Microsoft IS the world?  Bull-shit.

Currently the best time on a particular data reorganization on Windows 
takes 2 hours per 1 year of data.  Best team effort to date.

(Desktop 3+ GHz w/SATA)

My use of Linux takes 8 minutes 41 seconds per 10 years of same data 
doing same re-org.

(Laptop 2.4Ghz w/slow buss/drive speeds)

Programming is not an end unto itself. It's just another tool in the 
box.  If it's broke, messed up or inconsistent - it goes into the trash.

Useless is useless.

Re: What is the best framework or module in Python for a small GUI based application development?

2009-04-22 Thread Benjamin Kaplan
On Wed, Apr 22, 2009 at 12:13 PM, Mike Driscoll  wrote:

> On Apr 22, 10:51 am, Tim Chase  wrote:
> > > My requirement is to write an application which is GUI based
> > > has to run on browsers. Could you tell me which one would be
> > > suitable for this?
> >
> > These are generally 2 different things:  either you're writing a
> > local GUI rich-client (in which case, use the GuiProgramming wiki
> > link Mike sent), or you're doing web development targeting
> > browsers in which case you should investigate the myriad web
> > programming frameworks for Python (Django, Turbogears, CheryPy,
> > web.py, webstack, etc).
> >
> > There's a third "type" of application that I abhor, usually
> > developed in Flash/Silverblight/JavaFX that runs within a
> > web-browser, but allows for richer interactions/rendering than
> > your average web-page.  However, I don't know of any python
> > tie-ins for any of these environments.
> >
> > There's also a blurred line if you embed a web-browser in a local
> > GUI application.
> >
> > -tkc
>
> Technically speaking, Silverlight can be run with IronPython...which
> works on Windows and Linux (through Mono), but not Mac (as far as I
> know).
>

Mono is also available for Mac. I don't know if Moonlight works (no reason
it shouldn't but you'll probably have to use an X11 web browser) and I don't
know if Mono works with the Mac Silverlight, but IronPython runs fine.
--
http://mail.python.org/mailman/listinfo/python-list


Re: pylab quick reference? (matplotlib)

2009-04-22 Thread norseman

Esmail wrote:

Hello all,

Does anyone know of a quick reference for the various plotting
functions for pylab? I'm just getting started with this
after years of work with gnuplot.

I found this

  http://matplotlib.sourceforge.net/api/pyplot_api.html

which is very comprehensive and would be good for digging into
specific commands. What I'm looking for is something small enough
to print out (< 10-20 pages) that gives a sufficient overview so
that I know what's available.

I've looked on the web without much success. I'd be grateful if
you have any pointers.

Thanks!
Esmail

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


=

Just out of curiosity,  have you tried:

import pylab
help(pylab)

The next step is to print it, which I've never felt the need to do.
Someone else can describe that step.


Steve

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


Splice decorator out of exception stack trace?

2009-04-22 Thread Ben Weaver
Hi,

Is there any way to "splice" a decorator out of an exception stack
trace?  For example:

>>> def decorator(proc):
... def internal(*args, **kwargs):
... return proc(*args, **kwargs)
... return internal

>>> @decorator
... def foo():
... assert False, 'simulate failure'

>>> foo()
Traceback (most recent call last):
 ...
 File "<...>", line 1, in 
 File "<...>", line 3, in internal
 File "<...>", line 3, in foo
AssertionError: simulate failure

I would like to know if it's possible to somehow end up with this
stack trace instead:

 File "<...>", line 1, in 
 File "<...>", line 3, in foo

Thanks in advance,

-Ben

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


Re: Splice decorator out of exception stack trace?

2009-04-22 Thread Chris Rebert
On Wed, Apr 22, 2009 at 11:19 AM, Ben Weaver  wrote:
> Hi,
>
> Is there any way to "splice" a decorator out of an exception stack
> trace?  For example:
>
 def decorator(proc):
> ...     def internal(*args, **kwargs):
> ...         return proc(*args, **kwargs)
> ...     return internal
>
 @decorator
> ... def foo():
> ...     assert False, 'simulate failure'
>
 foo()
> Traceback (most recent call last):
>  ...
>  File "<...>", line 1, in 
>  File "<...>", line 3, in internal
>  File "<...>", line 3, in foo
> AssertionError: simulate failure
>
> I would like to know if it's possible to somehow end up with this
> stack trace instead:
>
>  File "<...>", line 1, in 
>  File "<...>", line 3, in foo

You can probably do it by fiddling with the `traceback` module
(http://docs.python.org/library/traceback.html), although without any
context regarding your situation, it seems like it's more trouble than
it's worth to bother doing so.

Cheers,
Chris
-- 
I have a blog:
http://blog.rebertia.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: Essential tools for Python development

2009-04-22 Thread Phillip B Oldham
On Apr 22, 5:00 am, Ben Finney  wrote:
> [snip] and code each module so that the
> behaviour is easily introspected and tested from outside the module. If
> I'm not able to easily introspect the code at an interactive prompt,
> that's a clear sign that the code interface is poorly designed. So I fix
> that first.

Could you give a small example of this approach?
--
http://mail.python.org/mailman/listinfo/python-list


Re: unpythonic use of property()?

2009-04-22 Thread Luis Zarrabeitia
On Wednesday 22 April 2009 01:44:38 pm J Kenneth King wrote:
> > Then, take this opportunity fix the server and prevent it from breaking
> > once you change the ID, because:
>
> Unfortunately it's not my server to fix. I can suggest a patch, but
> that's it.

Yes, that's unfortunate.
Btw, when I re-read my phrase by itself, it seemed hostile... My apologies. 
I'm still not very good at expressing my thoughts in english.

Then, I guess, you have little choice. Mangle the name, hope that the server 
will get fixed.

-- 
Luis Zarrabeitia (aka Kyrie)
Fac. de Matemática y Computación, UH.
http://profesores.matcom.uh.cu/~kyrie
--
http://mail.python.org/mailman/listinfo/python-list


  1   2   >