Re: Function that knows its argument's variable name

2010-03-17 Thread Tino Wildenhain
Hi, Am 14.03.2010 12:58, schrieb Helge Stenström: I want to write function that prints a value of a variable, for debugging. Like: with myVariable = "parrot" otherVariable = "dead" probe(myVariable) probe(otherVariable) instead of the longer print "myVariable = ", myVariable print "otherVa

using DictionaryServices module to get work with python2.6 #OSXspecific

2010-03-17 Thread Shashwat Anand
I wanted to use dictionary in my OSX terminal. So I wrote a function dict() in my ~/.bash_profile dict () { python2.5 -c 'import sys, DictionaryServices; word = " ".join(sys.argv[1:]); print DictionaryServices.DCSCopyTextDefinition(None, word, (0, len(word)))' $@ } here is the output: Shashw

Timer

2010-03-17 Thread Sam Bull
I'm writing a pyGTK program, and I need to display the contents of a window for a few seconds before automatically moving on. I have tried using the time.sleep method, but this has problems, such as the program becoming unresponsive. I have now attempted to use a timer, but this does not seem to r

Re: Dynamic Class Creation

2010-03-17 Thread Gerard Flanagan
Josh English wrote: Chris, Thanks. This worked for the attributes, but I think the tactic is still misleading. There are child elements I can't quite determine how to deal with: Analog Science Fiction and Fact Analog Science Fiction First Contact Hard Science Fiction

Re: using DictionaryServices module to get work with python2.6 #OSXspecific

2010-03-17 Thread Mark Lawrence
Shashwat Anand wrote: I wanted to use dictionary in my OSX terminal. So I wrote a function dict() in my ~/.bash_profile dict () { python2.5 -c 'import sys, DictionaryServices; word = " ".join(sys.argv[1:]); print DictionaryServices.DCSCopyTextDefinition(None, word, (0, len(word)))' $@ } her

RE: How to add a library path to pythonpath ?

2010-03-17 Thread Barak, Ron
> -Original Message- > From: Dave Angel [mailto:da...@ieee.org] > Sent: Tuesday, March 16, 2010 6:24 PM > To: Barak, Ron > Cc: Pablo Recio Quijano; python-list@python.org > Subject: Re: How to add a library path to pythonpath ? > > Barak, Ron wrote: > > > >> -Original Message- > >

Re: Python bindings tutorial

2010-03-17 Thread mikelisa...@gmail.com
On Mar 16, 3:12 pm, "Gabriel Genellina" wrote: > En Tue, 16 Mar 2010 13:20:40 -0300, Johny escribió: > > > Is there any tutorial how to write a bindings for a exe ( dos) > > program? > > I would like to run it from a Python directly > > ( using import command and a particular function from the bi

RE: How to handle file uploads with http.server

2010-03-17 Thread Neil Blue
Thanks Gabriel Yep, that looks like the same one. Cheers Neil -Original Message- From: Gabriel Genellina [mailto:gagsl-...@yahoo.com.ar] Sent: 17 March 2010 02:08 To: python-list@python.org Subject: Re: How to handle file uploads with http.server En Thu, 11 Mar 2010 07:30:24 -0300,

Re: to pass self or not to pass self

2010-03-17 Thread Bruno Desthuilliers
Patrick Maupin a écrit : On Mar 16, 1:59 pm, Jason Tackaberry wrote: Why not create the bound methods at instantiation time, rather than using the descriptor protocol which has the overhead of creating a new bound method each time the method attribute is accessed? Well, for one thing, Python

Re: using DictionaryServices module to get work with python2.6 #OSXspecific

2010-03-17 Thread Shashwat Anand
> Are you thinking of this? > http://pypi.python.org/pypi/pyobjc-framework-DictionaryServices/2.2 > I get the same IndexError while working with this wrapper. My guess is python2.6 does not support DictionaryServices on Snow Leopard . -- http://mail.python.org/mailman/listinfo/python-list

Re: Timer

2010-03-17 Thread Peter Otten
Sam Bull wrote: > I'm writing a pyGTK program, and I need to display the contents of a > window for a few seconds before automatically moving on. I have tried > using the time.sleep method, but this has problems, such as the program > becoming unresponsive. > > I have now attempted to use a timer

Re: Python bindings tutorial

2010-03-17 Thread Stefan Behnel
mikelisa...@gmail.com, 17.03.2010 10:08: Its interesting you've mentioned the hard work involved in this interface (binding to an EXE instead of a DLL). A year or more ago I was looking at interfacing IPMITOOL to python. Do to the problems incurred with swig/python I switched to a running the pro

RE: How to add a library path to pythonpath ?

2010-03-17 Thread Barak, Ron
> -Original Message- > From: Mark Hammond [mailto:skippy.hamm...@gmail.com] > Sent: Wednesday, March 17, 2010 2:08 AM > To: Barak, Ron > Cc: Pablo Recio Quijano; python-list@python.org > Subject: Re: How to add a library path to pythonpath ? > > On 17/03/2010 1:26 AM, Barak, Ron wrote:

Castrated traceback in sys.exc_info()

2010-03-17 Thread Pakal
Hello I've just realized recently that sys.exc_info() didn't return a full traceback for exception concerned : it actually only contains the frame below the point of exception catching. That's very annoying to me, because I planned to log such tracebacks with logging.critical(*, exc_info=True

Re: to pass self or not to pass self

2010-03-17 Thread Lie Ryan
On 03/17/2010 04:32 PM, Steven D'Aprano wrote: > On Wed, 17 Mar 2010 15:57:17 +1100, Lie Ryan wrote: > >> Most people probably would never need to use >> descriptor protocol directly, since the immediate benefit of descriptor >> protocol are property(), classmethod(), and instancemethod() decorato

Re: datetime string conversion error

2010-03-17 Thread Dave Angel
Gabriel Genellina wrote: En Tue, 16 Mar 2010 20:31:11 -0300, Josh English escribió: On Mar 16, 11:56 am, Jordan Apgar wrote: here's what I'm doing: date = "2010-03-16 14:46:38.409137" olddate = datetime.strptime(date,"%Y-%m-%j %H:%M:%S.%f") Due to circumstances, I'm using Python 2.5.

Re: Python bindings tutorial

2010-03-17 Thread Dave Angel
Stefan Behnel wrote: mikelisa...@gmail.com, 17.03.2010 10:08: Its interesting you've mentioned the hard work involved in this interface (binding to an EXE instead of a DLL). A year or more ago I was looking at interfacing IPMITOOL to python. Do to the problems incurred with swig/python I switched

Swapping Content of Two Dictionaries.

2010-03-17 Thread Hatem Oraby
Hello, I want to swap the content of two dictionaries, the obvious way to do it is: a = {1:"I'am A"} b = {2:"I'm B"} temp = a a = b b = temp However, consider the case in which the dictionary we are referencing lives in another module: #external.py # #a = {1:"I'am A} import external temp = extern

Re: Castrated traceback in sys.exc_info()

2010-03-17 Thread Michael Ricordeau
Hi, to log tracebacks, you can probably try traceback module. I use it like this : import traceback # your code for line in traceback.format_exc().splitlines(): log.trace(line) Le Wed, 17 Mar 2010 03:42:44 -0700 (PDT), Pakal a écrit : > Hello > > I've just realized recently that sy

Re: Python bindings tutorial

2010-03-17 Thread Alf P. Steinbach
* Dave Angel: Stefan Behnel wrote: mikelisa...@gmail.com, 17.03.2010 10:08: Its interesting you've mentioned the hard work involved in this interface (binding to an EXE instead of a DLL). A year or more ago I was looking at interfacing IPMITOOL to python. Do to the problems incurred with swig/py

Re: Python bindings tutorial

2010-03-17 Thread Stefan Behnel
Dave Angel, 17.03.2010 12:14: Stefan Behnel wrote: I think the point here is that executable binaries are not supposed to be used as libraries. Libraries are. That's the difference between a DLL and an executable in the first place. To run an executable, execute it. The subprocess module is the

Re: Swapping Content of Two Dictionaries.

2010-03-17 Thread Peter Otten
Hatem Oraby wrote: > Hello, I want to swap the content of two dictionaries, the obvious way to > do it is: > a = {1:"I'am A"} > b = {2:"I'm B"} > temp = a > a = b > b = temp That can be simplified to a, b = b, a and is almost certainly the right approach. > tempKeys = a.keys() > diffKeys = a.k

question about tkinter

2010-03-17 Thread robert schaefer
Hello, This is my first posting to this list so please be gentle - I am new to python and am using it on red-hat linux (I am new to that too). I am responsible for installing open source packages (including python) onto a distributed system of linux boxes. My question is, on python version

Re: Castrated traceback in sys.exc_info()

2010-03-17 Thread Pascal Chambon
Hello, traceback functions indeed allow the manipulation of exception tracebacks, but the root problem is that anyway, since that traceback is incomplete, your "traceback.format_exc().splitlines()" will only provide frames for callee (downward) functions, not caller (upward) ones, starting from th

Re: question about tkinter

2010-03-17 Thread Peter Otten
robert schaefer wrote: > This is my first posting to this list so please be gentle - > > I am new to python and am using it on red-hat linux (I am new to that > too). I am responsible for installing open source packages (including > python) onto a distributed system of linux boxes. > > My q

Re: Web Hosting Python 3

2010-03-17 Thread python
Hidura, > Hello list, i am in a project what need hosting, who give hosting to python3? Check out www.webfaction.com. I'm extremely pleased with this vendor. Highly recommended! Malcolm -- http://mail.python.org/mailman/listinfo/python-list

Re: to pass self or not to pass self

2010-03-17 Thread Lie Ryan
On 03/17/2010 08:12 PM, Bruno Desthuilliers wrote: > Patrick Maupin a écrit : >> On Mar 16, 1:59 pm, Jason Tackaberry wrote: >>> Why not create the bound methods at instantiation time, rather than >>> using the descriptor protocol which has the overhead of creating a new >>> bound method each time

Re: Function that knows its argument's variable name

2010-03-17 Thread Helge Stenström
Thank you to all who answered. Inspection is apparently possible, but too complex for me. Greg's solution does what I want, inserting "" is no problem. /Helge > Not exactly, but you can come close with a little hackery. > > import sys > > def print_var(name): >    print name, "=", sys._getframe(

Re: Castrated traceback in sys.exc_info()

2010-03-17 Thread Vinay Sajip
On Mar 17, 10:42 am, Pakal wrote: > Hello > > I've just realized recently that sys.exc_info() didn't return a full > traceback for exception concerned : it actually only contains the > frame below the point of exception catching. > > That's very annoying to me, because I planned to log such traceb

Re: question about tkinter

2010-03-17 Thread robert schaefer
Peter, Most of my life has been dealing with recalcitrant HAL's in one guise or another. These days, I think HAL has permanently taken up residence in Toyota's engine and brakes. "Stop the car Dave? Have you changed my oil or even washed me lately?" Some serious "sneak paths" are going on. A

multiprocessing on freebsd

2010-03-17 Thread Tim Arnold
Hi, I'm checking to see if multiprocessing works on freebsd for any version of python. My server is about to get upgraded from 6.3 to 8.0 and I'd sure like to be able to use multiprocessing. I think the minimal test would be: - import multiprocessing q = multiprocessing.Queue()

Re: Web Hosting Python 3

2010-03-17 Thread Hidura
I've saw last night in the help area they support Python3.1, thanks anyway On Wed, Mar 17, 2010 at 9:22 AM, wrote: > Hidura, > > > Hello list, i am in a project what need hosting, who give hosting to > python3? > > Check out www.webfaction.com. I'm extremely pleased with this vendor. > > Highly

Special characters (^M & ^[[D) when I read pxssh::before and write it to a file

2010-03-17 Thread ashwini yal
Hi, I am writing a python script which logs into the machine using pxssh, sends a command, reads the response and writes the response to the file. But, when I open the file in the editor like vi, its showing special characters like ^M and ^[[D instead of spaces or newlines. This is how my code l

Re: question about tkinter

2010-03-17 Thread Peter Otten
robert schaefer wrote: > tkinter is in two parts: > 1. a python wrapper > 2. c code > > Both are present in the 2.6.2 python download. > It appears to be a "I can't find the library" path problem not a file > existence problem. > > 1. gcc can't find the libraries that tkinter c code links to ( I

Re: Swapping Content of Two Dictionaries.

2010-03-17 Thread Stefan Behnel
Hatem Oraby, 17.03.2010 12:26: However, consider the case in which the dictionary we are referencing lives in another module: #external.py # #a = {1:"I'am A} import external temp = external.a external.a = b b = temp Looks like the interface of your module is broken. It shouldn't export the tw

Re: Searching for most pythonic/least stupid way to do something simple

2010-03-17 Thread nn
Michael Torrie wrote: > david jensen wrote: > > of course, changing nn's to: > > def getOutcomes(myList=[2,5,8,3,5]): > >low_id = int(myList[0]>myList[1]) > >amountToShare = 2*myList[low_id] > >remainder = myList[not low_id]-myList[low_id] > >tail=list(myList[2:]) > >outcomes

Re: question about tkinter

2010-03-17 Thread robert schaefer
No, And there's a reason (perhaps not a great one - but I'm got some constraints). I am not the system administrator and the tcl installer wants to be installed as root. I tried it. The rationale for not doing this is that the installation packages that I am administrator for, are all instal

bug in bdist_wininst cross compile?

2010-03-17 Thread Robin Becker
has anyone had any success with cross compilation and bdist_wininst; I have modified build_ext very slightly to fix a small bug in cross compilation related to library order. That seems to fix setup.py build --plat-name=win-amd64 however, when I try to do a clean build of an exe ie rm -rf bu

Re: to pass self or not to pass self

2010-03-17 Thread Patrick Maupin
On Mar 17, 4:12 am, Bruno Desthuilliers wrote: > Patrick Maupin a écrit : > > > On Mar 16, 1:59 pm, Jason Tackaberry wrote: > >> Why not create the bound methods at instantiation time, rather than > >> using the descriptor protocol which has the overhead of creating a new > >> bound method each t

Re: Special characters (^M & ^[[D) when I read pxssh::before and write it to a file

2010-03-17 Thread Benjamin Kaplan
On Wed, Mar 17, 2010 at 9:54 AM, ashwini yal wrote: > Hi, > > I am writing a python script which logs into the machine using pxssh, sends > a command, reads the response and writes the response to the file. > > But, when I open the file in the editor like vi, its showing special > characters like

Re: highlight words by regex in pdf files using python

2010-03-17 Thread Peng Yu
On Tue, Mar 16, 2010 at 11:12 PM, Patrick Maupin wrote: > On Mar 4, 6:57 pm, Peng Yu wrote: >> I don't find a general pdf library in python that can do any >> operations on pdfs. >> >> I want to automatically highlight certain words (using regex) in a >> pdf. Could somebody let me know if there i

Re: to pass self or not to pass self

2010-03-17 Thread Bruno Desthuilliers
Lie Ryan a écrit : On 03/17/2010 08:12 PM, Bruno Desthuilliers wrote: Patrick Maupin a écrit : On Mar 16, 1:59 pm, Jason Tackaberry wrote: Why not create the bound methods at instantiation time, rather than using the descriptor protocol which has the overhead of creating a new bound method ea

Structure accessible by attribute name or index

2010-03-17 Thread Wes Santee
I am very new to Python, and trying to figure out how to create an object that has values that are accessible either by attribute name, or by index. For example, the way os.stat() returns a stat_result or pwd.getpwnam() returns a struct_passwd. In trying to figure it out, I've only come across C

Re: highlight words by regex in pdf files using python

2010-03-17 Thread Patrick Maupin
On Wed, Mar 17, 2010 at 9:53 AM, Peng Yu wrote: > Thank you for your long reply! But I'm not sure if you get my question or not. > > Acrobat can highlight certain words in pdfs. I could add notes to the > highlighted words as well. However, I find that I frequently end up > with highlighting some

Re: Structure accessible by attribute name or index

2010-03-17 Thread Christian Heimes
Wes Santee wrote: > I am very new to Python, and trying to figure out how to create an > object that has values that are accessible either by attribute name, > or by index. For example, the way os.stat() returns a stat_result or > pwd.getpwnam() returns a struct_passwd. > > In trying to figure it

Nested Scopes unintended behaviour ?

2010-03-17 Thread Michael Sparks
Hi, Is the following behaviour expected ? Python 2.6.4 (r264:75706, Dec 7 2009, 18:45:15) [GCC 4.4.1] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> def Toggler(F, B): ... print F("Hello") ... print F("Hello") ... print F("Hello") ... print

Re: multiprocessing on freebsd

2010-03-17 Thread Philip Semanchuk
On Mar 17, 2010, at 9:30 AM, Tim Arnold wrote: Hi, I'm checking to see if multiprocessing works on freebsd for any version of python. My server is about to get upgraded from 6.3 to 8.0 and I'd sure like to be able to use multiprocessing. I think the minimal test would be: -

Re: Structure accessible by attribute name or index

2010-03-17 Thread Bruno Desthuilliers
Wes Santee a écrit : I am very new to Python, and trying to figure out how to create an object that has values that are accessible either by attribute name, or by index. For example, the way os.stat() returns a stat_result or pwd.getpwnam() returns a struct_passwd. In trying to figure it out, I

Re: Structure accessible by attribute name or index

2010-03-17 Thread Bruno Desthuilliers
Christian Heimes a écrit : However Python 2.6 has a new factory that creates a similar datatype called named tuple: http://docs.python.org/library/collections.html#namedtuple-factory-function-for-tuples-with-named-fields Duh... Should spend some more time reading 2.6's What's New :( -- http://

Re: Nested Scopes unintended behaviour ?

2010-03-17 Thread Emile van Sebille
On 3/17/2010 8:16 AM Michael Sparks said... Hi, Is the following behaviour expected ? In short, yes. Assignment within a function forces the variable to locals. You can get around it like: Python 2.6.4 (r264:75706, Dec 7 2009, 18:45:15) [GCC 4.4.1] on linux2 Type "help", "copyright",

Re: execute bash builtins in python

2010-03-17 Thread Nobody
On Fri, 12 Mar 2010 08:15:49 -0500, Steve Holden wrote: > For shell=True I believe you should provide the command as a single > string, not a list of arguments. Using shell=True with an argument list is valid. On Unix, it's seldom what you want: it will invoke /bin/sh to execute the first argume

pkg-config and Windows

2010-03-17 Thread Johny
I have a program that needs to be installed with setup.py. But there is a problem when I am trying to install the program with setup.py in Windows. When I try to install with python setup.py install it goes like this C:\>python setup.py install running install running build running build_py r

Re: Structure accessible by attribute name or index

2010-03-17 Thread Wes Santee
On Mar 17, 11:14 am, Christian Heimes wrote: > Wes Santee wrote: > > I am very new to Python, and trying to figure out how to create an > > object that has values that are accessible either by attribute name, > > or by index.  For example, the way os.stat() returns a stat_result or > > pwd.getpwna

Win32All On 64-Bit Operating Systems

2010-03-17 Thread Tim Daneliuk
I have a pure-Python program developed on a POSIX platform (FreeBSD) that I'd like to make fully compatible with Windows systems as well. The only conflict arises insofar as this program makes considerable use of the stat UID and GID values, as well as their corresponding user- and group names. S

Re: Structure accessible by attribute name or index

2010-03-17 Thread Wes Santee
On Mar 17, 11:34 am, Bruno Desthuilliers wrote: > Wes Santee a écrit : > > > I am very new to Python, and trying to figure out how to create an > > object that has values that are accessible either by attribute name, > > or by index.  For example, the way os.stat() returns a stat_result or > > pwd

Re: Win32All On 64-Bit Operating Systems

2010-03-17 Thread Tim Golden
On 17/03/2010 16:32, Tim Daneliuk wrote: I have a pure-Python program developed on a POSIX platform (FreeBSD) that I'd like to make fully compatible with Windows systems as well. The only conflict arises insofar as this program makes considerable use of the stat UID and GID values, as well as th

Python Documentation website layout changed?

2010-03-17 Thread Andrej Mitrovic
Hi, What happened to the sidebar on the left of the documentation website? It seems to be gone: http://docs.python.org/py3k/index.html I found it quite useful since I can quickly swap between Python2/3 documentation, and between other parts of the documentation as well. -- http://mail.python.or

Re: multiprocessing on freebsd

2010-03-17 Thread Tim Arnold
On Mar 17, 11:26 am, Philip Semanchuk wrote: > On Mar 17, 2010, at 9:30 AM, Tim Arnold wrote: > > > > > > > Hi, > > I'm checking to see if multiprocessing works on freebsd for any > > version of python. My server is about to get upgraded from 6.3 to 8.0 > > and I'd sure like to be able to use mult

Re: execute bash builtins in python

2010-03-17 Thread Chris Colbert
On Wed, Mar 17, 2010 at 11:44 AM, Nobody wrote: > On Fri, 12 Mar 2010 08:15:49 -0500, Steve Holden wrote: > > > For shell=True I believe you should provide the command as a single > > string, not a list of arguments. > > Using shell=True with an argument list is valid. > > On Unix, it's seldom wh

Re: Python Documentation website layout changed?

2010-03-17 Thread Andrej Mitrovic
On Mar 17, 6:41 pm, Andrej Mitrovic wrote: > Hi, > > What happened to the sidebar on the left of the documentation website? > It seems to be gone: > > http://docs.python.org/py3k/index.html > > I found it quite useful since I can quickly swap between Python2/3 > documentation, and between other pa

Re: Python Documentation website layout changed?

2010-03-17 Thread Steve Holden
Andrej Mitrovic wrote: > On Mar 17, 6:41 pm, Andrej Mitrovic > wrote: >> Hi, >> >> What happened to the sidebar on the left of the documentation website? >> It seems to be gone: >> >> http://docs.python.org/py3k/index.html >> >> I found it quite useful since I can quickly swap between Python2/3 >>

How to access a web site with an authentication template.

2010-03-17 Thread Anthra Norell
Hi all, I have spent the better part of this day reading docs and googling archives to no avail. About this: I understand that I can access password protected sites with urllib2. However, the protocol seems to be: I try without password and catch the error coming back. The header will then

Re: Win32All On 64-Bit Operating Systems

2010-03-17 Thread Tim Daneliuk
On 3/17/2010 12:05 PM, Tim Golden wrote: > On 17/03/2010 16:32, Tim Daneliuk wrote: >> I have a pure-Python program developed on a POSIX platform (FreeBSD) that >> I'd like to make fully compatible with Windows systems as well. The only >> conflict arises insofar as this program makes considerable

Re: to RG - Lisp lunacy and Perl psychosis

2010-03-17 Thread Xah Lee
2010-03-17 On Mar 10, 9:17 am, Ben Morrow wrote: > Also, flamebait language-comparison xposts involving Lisp are one > of Xah Lee's trademarks. You might want to look into not imitating > him/her/it. being a professional programer today, typically you know more than just one language. Practical

Re: multiprocessing on freebsd

2010-03-17 Thread Martin P. Hellwig
On 03/17/10 13:30, Tim Arnold wrote: Hi, I'm checking to see if multiprocessing works on freebsd for any version of python. My server is about to get upgraded from 6.3 to 8.0 and I'd sure like to be able to use multiprocessing. I think the minimal test would be: - import mult

Re: to pass self or not to pass self

2010-03-17 Thread Terry Reedy
On 3/17/2010 1:35 AM, Patrick Maupin wrote: def a(s, count, lenfunc): ... for i in xrange(count): ...z = lenfunc(s) ... >>> a('abcdef', 1, len) >>> a('abcdef', 1, str.__len__) Running cPython 2.6 on my machine, len() runs about 3 times faster than str.__len__().

Re: Win32All On 64-Bit Operating Systems

2010-03-17 Thread Tim Golden
On 17/03/2010 19:07, Tim Daneliuk wrote: That's not really so. Windows definitely has the notions of users and groups, they just don't quite align with the POSIX model exactly. Yes, my comment was a little blase. I know that Windows has users & groups: http://timgolden.me.uk/python/win32_how_d

Re: Python bindings tutorial

2010-03-17 Thread Terry Reedy
On 3/17/2010 8:18 AM, Stefan Behnel wrote: Dave Angel, 17.03.2010 12:14: Stefan Behnel wrote: I think the point here is that executable binaries are not supposed to be used as libraries. Libraries are. That's the difference between a DLL and an executable in the first place. To run an executabl

Re: question about tkinter

2010-03-17 Thread Terry Reedy
On 3/17/2010 10:33 AM, robert schaefer wrote: No, And there's a reason (perhaps not a great one - but I'm got some constraints). Related to that I tailored Ipython to work with gtk (ipython's default was tkinter) - tailoring was by a command - is there any way to command idle to use gtk?

Re: Nested Scopes unintended behaviour ?

2010-03-17 Thread Terry Reedy
On 3/17/2010 11:44 AM, Emile van Sebille wrote: On 3/17/2010 8:16 AM Michael Sparks said... Hi, Is the following behaviour expected ? In short, yes. Assignment within a function forces the variable to locals. In 3.x, one can declare names to be nonlocal (ie, local to some outer function,

Re: Converting Python CGI to WSGI scripts

2010-03-17 Thread python
Sebastian/John, Thank you very much for your feedback. John: I initially missed the nuance of WSGI scripts being function calls. I suspect your tip has saved me a lot of pain :) Regards, Malcolm -- http://mail.python.org/mailman/listinfo/python-list

Re: Win32All On 64-Bit Operating Systems

2010-03-17 Thread Tim Daneliuk
On 3/17/2010 2:59 PM, Tim Golden wrote: > On 17/03/2010 19:07, Tim Daneliuk wrote: >> That's not really so. Windows definitely has the notions of users and >> groups, >> they just don't quite align with the POSIX model exactly. > > Yes, my comment was a little blase. I know that Windows has users

Re: to pass self or not to pass self

2010-03-17 Thread Patrick Maupin
On Mar 17, 2:55 pm, Terry Reedy wrote: > On 3/17/2010 1:35 AM, Patrick Maupin wrote: > > def a(s, count, lenfunc): > > ...     for i in xrange(count): > > ...        z = lenfunc(s) > > ... > >>>  a('abcdef', 1, len) > >>>  a('abcdef', 1, str.__len__) > > Running cPyt

What Does sys.platform Return On 64 Bit Windows Systems?

2010-03-17 Thread Tim Daneliuk
On older 32 bit Windows systems, sys.platform returns: 'win32' What does it return on 64-bit Windows systems? I'd check myself, but I don't have access to 64-bit Windows. TIA, -- Tim Daneliuk tun...@tundraware.co

Re: bug in bdist_wininst cross compile?

2010-03-17 Thread Gabriel Genellina
En Wed, 17 Mar 2010 11:38:16 -0300, Robin Becker escribió: has anyone had any success with cross compilation and bdist_wininst; I have modified build_ext very slightly to fix a small bug in cross compilation related to library order. Please post your bug report + patch at http://bugs.pyt

os.walk restart

2010-03-17 Thread Keir Vaughan-taylor
I am traversing a large set of directories using for root, dirs, files in os.walk(basedir): run program Being a huge directory set the traversal is taking days to do a traversal. Sometimes it is the case there is a crash because of a programming error. As each directory is processed the name

Re: to pass self or not to pass self

2010-03-17 Thread Joaquin Abian
On Mar 17, 3:43 pm, Patrick Maupin wrote: > On Mar 17, 4:12 am, Bruno Desthuilliers > 42.desthuilli...@websiteburo.invalid> wrote: > > Patrick Maupin a écrit : > > > > On Mar 16, 1:59 pm, Jason Tackaberry wrote: > > >> Why not create the bound methods at instantiation time, rather than > > >> us

Re: How to access a web site with an authentication template.

2010-03-17 Thread Gabriel Genellina
En Wed, 17 Mar 2010 15:43:00 -0300, Anthra Norell escribió: I understand that I can access password protected sites with urllib2. [...] a site I am dealing with, because the opening page does not require a password. It presents an id/password entry template and I have no clue how to respo

Re: C-API PyObject_Call

2010-03-17 Thread moerchendiser2k3
> 1) put the line number information into the message string when you raise > the exception you mean the line and file information of the C code, right? -- http://mail.python.org/mailman/listinfo/python-list

Re: Swapping Content of Two Dictionaries.

2010-03-17 Thread Steven D'Aprano
On Wed, 17 Mar 2010 13:34:51 +0100, Peter Otten wrote: > Hatem Oraby wrote: > >> Hello, I want to swap the content of two dictionaries, the obvious way >> to do it is: >> a = {1:"I'am A"} >> b = {2:"I'm B"} >> temp = a >> a = b >> b = temp > > That can be simplified to > > a, b = b, a > > and

Re: highlight words by regex in pdf files using python

2010-03-17 Thread David Boddie
On Wednesday 17 March 2010 00:47, Aahz wrote: > In article > , > Peng Yu wrote: >> >>I don't find a general pdf library in python that can do any >>operations on pdfs. >> >>I want to automatically highlight certain words (using regex) in a >>pdf. Could somebody let me know if there is a tool to

Re: os.walk restart

2010-03-17 Thread Steven D'Aprano
On Wed, 17 Mar 2010 15:04:14 -0700, Keir Vaughan-taylor wrote: > I am traversing a large set of directories using > > for root, dirs, files in os.walk(basedir): > run program > > Being a huge directory set the traversal is taking days to do a > traversal. > Sometimes it is the case there is

url2lib (windows 7) does not notice when network reconnects (getaddrinfo problem)

2010-03-17 Thread News123
Hi, I'd like to write a function, that knows when the 'internet' is reachable. My setup is a windows7 host with a wireless USB modem. The modem might connect / disconnect any time. I thought I write a small function just checking whether I can fetch a url. # script starts import time,ur

Re: What Does sys.platform Return On 64 Bit Windows Systems?

2010-03-17 Thread Steven D'Aprano
On Wed, 17 Mar 2010 16:30:19 -0500, Tim Daneliuk wrote: > On older 32 bit Windows systems, sys.platform returns: 'win32' > > What does it return on 64-bit Windows systems? I'd check myself, but I > don't have access to 64-bit Windows. According to the docs, it returns win32: http://docs.pytho

Re: os.walk restart

2010-03-17 Thread Gabriel Genellina
En Wed, 17 Mar 2010 19:04:14 -0300, Keir Vaughan-taylor escribió: I am traversing a large set of directories using for root, dirs, files in os.walk(basedir): run program Being a huge directory set the traversal is taking days to do a traversal. Sometimes it is the case there is a crash

Re: to pass self or not to pass self

2010-03-17 Thread Patrick Maupin
On Mar 17, 5:34 pm, Joaquin Abian wrote: > On Mar 17, 3:43 pm, Patrick Maupin wrote: > > > > > On Mar 17, 4:12 am, Bruno Desthuilliers > > 42.desthuilli...@websiteburo.invalid> wrote: > > > Patrick Maupin a écrit : > > > > > On Mar 16, 1:59 pm, Jason Tackaberry wrote: > > > >> Why not create th

Re: What Does sys.platform Return On 64 Bit Windows Systems?

2010-03-17 Thread Christian Heimes
Tim Daneliuk schrieb: > On older 32 bit Windows systems, sys.platform returns: 'win32' > > What does it return on 64-bit Windows systems? I'd check myself, but > I don't have access to 64-bit Windows. Do you want to know if the current build of Python is a 32 or 64bit build? >>> import struct

Re: class inheritance

2010-03-17 Thread Steven D'Aprano
On Mon, 15 Mar 2010 16:34:35 -0700, JLundell wrote: > It's also unfortunate that Python doesn't have an approximately-equal > operator; it'd come in handy for floating-point applications while > preserving hash. If only there were a ~= or ≈ operator I could overload. > And ~ is unary, so no joy.

Re: to pass self or not to pass self

2010-03-17 Thread Joaquin Abian
On Mar 18, 12:11 am, Patrick Maupin wrote: > On Mar 17, 5:34 pm, Joaquin Abian wrote: > > > > > On Mar 17, 3:43 pm, Patrick Maupin wrote: > > > > On Mar 17, 4:12 am, Bruno Desthuilliers > > > 42.desthuilli...@websiteburo.invalid> wrote: > > > > Patrick Maupin a écrit : > > > > > > On Mar 16, 1:

Possible to open a file for shared write mode under Windows?

2010-03-17 Thread python
Is there a way to open a file for shared write mode under Windows? I have 2 processes that will write to different regions of this shared file. Thank you, Malcolm -- http://mail.python.org/mailman/listinfo/python-list

Re: os.walk restart

2010-03-17 Thread alex23
Steven D'Aprano wrote: > # Untested > last_visited = open("last_visited.txt", 'r').read() > for root, dirs, files in os.walk(last_visited or basedir): >      open("last_visited.txt", 'w').write(root) >      run program Wouldn't this only walk the directory the exception occured in and not the rem

Re: os.walk restart

2010-03-17 Thread MRAB
Keir Vaughan-taylor wrote: I am traversing a large set of directories using for root, dirs, files in os.walk(basedir): run program Being a huge directory set the traversal is taking days to do a traversal. Sometimes it is the case there is a crash because of a programming error. As each dir

Re: os.walk restart

2010-03-17 Thread Steve Howell
On Mar 17, 3:04 pm, Keir Vaughan-taylor wrote: > I am traversing a large set of directories using > > for root, dirs, files in os.walk(basedir): >     run program > > Being a huge directory set the traversal is taking days to do a > traversal. > Sometimes it is the case there is a crash because of

Re: os.walk restart

2010-03-17 Thread Steven D'Aprano
On Wed, 17 Mar 2010 20:08:48 -0700, alex23 wrote: > Steven D'Aprano wrote: >> # Untested >> last_visited = open("last_visited.txt", 'r').read() >> for root, dirs, files in os.walk(last_visited or basedir): >>      open("last_visited.txt", 'w').write(root) run program > > Wouldn't this only walk

Re: Possible to open a file for shared write mode under Windows?

2010-03-17 Thread Gabriel Genellina
En Wed, 17 Mar 2010 23:42:46 -0300, escribió: Is there a way to open a file for shared write mode under Windows? I have 2 processes that will write to different regions of this shared file. Using the pywin32 package at sourceforge, you have access to the CreateFile function: http://msdn.

Re: Possible to open a file for shared write mode under Windows?

2010-03-17 Thread Chris Colbert
you could also just have one process do the writing for both processes via pipes. On Thu, Mar 18, 2010 at 12:20 AM, Gabriel Genellina wrote: > En Wed, 17 Mar 2010 23:42:46 -0300, escribió: > > > Is there a way to open a file for shared write mode under >> Windows? >> >> I have 2 processes that

Re: Possible to open a file for shared write mode under Windows?

2010-03-17 Thread Steve Holden
Chris Colbert wrote: [top-posting switched to bottom-posting] > > On Thu, Mar 18, 2010 at 12:20 AM, Gabriel Genellina > mailto:gagsl-...@yahoo.com.ar>> wrote: > > En Wed, 17 Mar 2010 23:42:46 -0300, > escribió: > > > Is there a way to open a file for

Re: Possible to open a file for shared write mode under Windows?

2010-03-17 Thread python
Hi Gabriel, > Using the pywin32 package at sourceforge, you have access to the CreateFile > function: > http://msdn.microsoft.com/en-us/library/aa363858(v=VS.85).aspx > You want dwShareMode=FILE_SHARE_WRITE Thanks - that was exactly what I was looking for. Regards, Malcolm -- http://mail.pyt

Re: Possible to open a file for shared write mode under Windows?

2010-03-17 Thread Chris Colbert
It's not too difficult: # subp.py import sys import time for i in range(10): sys.stdout.write('I am subprocess\n') sys.stdout.flush() # this may not be necessary time.sleep(1) # writer.py import subprocess import time subp = subprocess.Popen(['/usr/bin/python', '-u', './subp.py']

Re: Understanding the CPython dict implementation

2010-03-17 Thread Steven D'Aprano
On Tue, 16 Mar 2010 16:04:22 -0400, Terry Reedy wrote: > On 3/16/2010 7:46 AM, Steven D'Aprano wrote: >> On Sun, 14 Mar 2010 19:39:46 -0400, Terry Reedy wrote: >> >>> I found this PyCon2010 presentation to be excellent: The Mighty >>> Dictionary, Branden Craig Rhodes, 30 min. > > Sorry, > http://

  1   2   >