Re: Python deadlock using subprocess.popen and communicate

2011-09-22 Thread Nobody
On Thu, 22 Sep 2011 11:19:28 -0700, Atherun wrote: >> I suggest obtaining a copy of Process Explorer, and using it to >> investigate the state of both processes (but especially the child) at the >> point that the "deadlock" seems to occur. > > In the one case I can easily reproduce, its in a p4.e

Re: python install on locked down windows box?

2011-09-22 Thread Matt Joiner
5 is the best solution, followed by 2 and 3. On Sep 22, 2011 11:02 PM, "Steven D'Aprano" < steve+comp.lang.pyt...@pearwood.info> wrote: > Chris Withers wrote: > >> Hi All, >> >> Is there a way to install python on a locked down Windows desktop? >> (ie: no compilers, no admin rights, etc) > > (1) Br

Python 2.5 zlib trouble

2011-09-22 Thread Jesramz
Hello, I am trying to deploy an app on google app engine using bottle, a micro-framework, similar to flask. I am running on ubuntu which comes with python 2.7 installed but GAE needs version 2.5, so I installed 2.5. I then realized I didn't use make altinstall so I may have a default version probl

Re: PyEval_EvalCodeEx return value

2011-09-22 Thread Mark Hammond
On 20/09/2011 8:34 PM, Mateusz Loskot wrote: Hi, I'm trying to dig out details about what exactly is the return value the of PyEval_EvalCodeEx function in Python 3.x The documentation is sparse, unfortunately. Perhaps I'm looking at wrong function. My aim is simple, I need to execute Python cod

Re: random.randint() slow, esp in Python 3

2011-09-22 Thread Chris Angelico
On Fri, Sep 23, 2011 at 4:14 AM, Steven D'Aprano wrote: > What makes you think it's in C? I don't have Python 3.3a, but in 3.2 the > random module is mostly Python. There is an import of _random, which > presumably is in C, but it doesn't have a randint method: True. It seems to be defined in cpy

Re: Negativ nearest interger?

2011-09-22 Thread Terry Reedy
On 9/22/2011 7:44 AM, Jussi Piitulainen wrote: joni writes: Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) ... -7/3 -3 In late Python 2 you *can* and in Python 3 you *must* use // rather than / to get an int result. -3 are more wrong than -2. Negativ number seems not to round to nea

Re: Context manager with class methods

2011-09-22 Thread Terry Reedy
On 9/22/2011 6:21 AM, Gavin Panella wrote: On Python 2.6 and 3.1 the following code works fine: class Foo(object): @classmethod def __enter__(cls): print("__enter__") @classmethod def __exit__(cls, exc_type, exc_value, traceback):

Re: Python Mixins

2011-09-22 Thread Thomas Jollans
On 2011-09-22 23:14, Matt wrote: > I'm curious about what people's opinions are about using mixins in > Python. I really like, for example, the way that class based views > were implemented in Django 1.3 using mixins. It makes everything > extremely customizable and reusable. I think this is a very

Re: Python Mixins

2011-09-22 Thread rantingrick
On Sep 22, 4:14 pm, Matt wrote: > (although having only a single parent doesn't > make much sense either, I believe there are very few actual documented > cases of that happening). There is nothing wrong with an object having only one parent. Most times the reasons are for maintainability. I mig

Python Mixins

2011-09-22 Thread Matt
I'm curious about what people's opinions are about using mixins in Python. I really like, for example, the way that class based views were implemented in Django 1.3 using mixins. It makes everything extremely customizable and reusable. I think this is a very good practice to follow, however, in Pyt

Re: Python deadlock using subprocess.popen and communicate

2011-09-22 Thread Atherun
On Sep 22, 10:44 am, Nobody wrote: > On Thu, 22 Sep 2011 08:55:40 -0700, Atherun wrote: > >> Just handle process.stdout/stderr by yourself - read it out until EOF > >> and then wait() for the process. > > > Thats what confuses me though, the documentation says > > process.stdout.read()/stderr.read

Re: random.randint() slow, esp in Python 3

2011-09-22 Thread Steven D'Aprano
Chris Angelico wrote: > The standard library function random.randint() seems to be quite slow > compared to random.random(), and worse in Python 3 than Python 2 [...] > But this still doesn't explain why randint() is so much slower. In > theory, randint() should be doing basically the same thing t

Re: Decision on python technologies

2011-09-22 Thread Emile van Sebille
On 9/22/2011 9:00 AM Navkirat Singh said... Hi Guys, I have been a python developer for a bit now and for the life of me I am not being able to decide something. I am trying to develop a web based application in python. I am torn between using python 2 or 3. All the good frameworks are still in

Re: Python deadlock using subprocess.popen and communicate

2011-09-22 Thread Nobody
On Thu, 22 Sep 2011 08:55:40 -0700, Atherun wrote: >> Just handle process.stdout/stderr by yourself - read it out until EOF >> and then wait() for the process. > > Thats what confuses me though, the documentation says > process.stdout.read()/stderr.read() can deadlock and apparently so can > comm

random.randint() slow, esp in Python 3

2011-09-22 Thread Chris Angelico
The standard library function random.randint() seems to be quite slow compared to random.random(), and worse in Python 3 than Python 2 (specifically that's 3.3a0 latest from Mercurial, and 2.6.6 that came default on my Ubuntu install). My test involves building a list of one million random integer

Re: Environment variables not visible from Python

2011-09-22 Thread Peter Pearson
On Thu, 22 Sep 2011 09:21:59 +0200, Thomas Rachel wrote: [snip] > $ python -c 'import os; print "\n".join(sorted("%s=%s" % (k,v) for k,v > in os.environ.iteritems()))' | diff -u - <(env|LANG=C sort) [standing ovation] -- To email me, substitute nowhere->spamcop, invalid->net. -- http://mail.py

Re: [ANNC] pynguin-0.12 (fixes problems running on Windows)

2011-09-22 Thread Miki Tebeka
Thank you! My kids *love* it. -- http://mail.python.org/mailman/listinfo/python-list

Decision on python technologies

2011-09-22 Thread Navkirat Singh
Hi Guys, I have been a python developer for a bit now and for the life of me I am not being able to decide something. I am trying to develop a web based application in python. I am torn between using python 2 or 3. All the good frameworks are still in 2.x. Now, cherrypy, sqlalchemy and jinja2 supp

Re: Python deadlock using subprocess.popen and communicate

2011-09-22 Thread Atherun
On Sep 22, 12:24 am, Thomas Rachel wrote: > Am 22.09.2011 05:42 schrieb Atherun: > > > I'm pretty sure thats the problem, this is a generic catch all > > function for running subprocesses.  It can be anything to a simple > > command to a complex command with a ton of output.  I'm looking for a > >

ANN: Urwid 1.0.0 - Console UI Library

2011-09-22 Thread Ian Ward
Announcing Urwid 1.0.0 -- Urwid home page: http://excess.org/urwid/ Manual: http://excess.org/urwid/wiki/UrwidManual Tarball: http://excess.org/urwid/urwid-1.0.0.tar.gz About this release: === This is a major feature release for Urwid: It's the first

Re: static statements and thread safety

2011-09-22 Thread MRAB
On 22/09/2011 08:45, Eric Snow wrote: A recent thread on the python-ideas list got me thinking about the possibility of a static statement (akin to global and nonlocal). I am wondering if an implementation would have to address thread safety concerns. I would expect that static variables would

Re: Negativ nearest interger?

2011-09-22 Thread joni
On Sep 22, 1:44 pm, Jussi Piitulainen wrote: > joni writes: > > Have a simple question in the Integer calculator in Python 2.65 and > > also 2.7.. > > > The consol showing: > > > Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) > ... > > >>> -7/3 > > -3 > > > -3 are more wrong than -2. Negativ num

Re: python install on locked down windows box?

2011-09-22 Thread Steven D'Aprano
Chris Withers wrote: > Hi All, > > Is there a way to install python on a locked down Windows desktop? > (ie: no compilers, no admin rights, etc) (1) Bribe or blackmail the fascist system administrator. (2) Hack into the system with any of dozens of unpatched vulnerabilities that will give you a

Re: Context manager with class methods

2011-09-22 Thread Mel
Mel wrote: > This seems to work: > > > > class MetaWith (type): > @classmethod > def __enter__(cls): > print("__enter__") > > @classmethod > def __exit__(cls, exc_type, exc_value, traceback): > print("__exit__") > > class With (object): > __metaclass__ = Met

Re: Context manager with class methods

2011-09-22 Thread Mel
Gavin Panella wrote: > Hi, > > On Python 2.6 and 3.1 the following code works fine: > > class Foo(object): > > @classmethod > def __enter__(cls): > print("__enter__") > > @classmethod > def __exit__(cls, exc_type, exc_value, traceback): >

Re: Environment variables not visible from Python

2011-09-22 Thread Ben Finney
Thomas Rachel writes: > Am 22.09.2011 12:16 schrieb Ben Finney: > > -- > > \ “As far as the laws of mathematics refer to reality, they are | > >`\not certain, and as far as they are certain, they do not refer | > > _o__) to reality.” —Albert Einstein, 1

Re: Context manager with class methods

2011-09-22 Thread Thomas Rachel
Am 22.09.2011 12:21 schrieb Gavin Panella: Hi, On Python 2.6 and 3.1 the following code works fine: class Foo(object): @classmethod def __enter__(cls): print("__enter__") @classmethod def __exit__(cls, exc_type, exc_value, traceback):

Re: Environment variables not visible from Python

2011-09-22 Thread Thomas Rachel
Am 22.09.2011 12:16 schrieb Ben Finney: -- \ “As far as the laws of mathematics refer to reality, they are | `\not certain, and as far as they are certain, they do not refer | _o__) to reality.” —Albert Einstein, 1983 | Ben Finney So, he said what in

Re: Negativ nearest interger?

2011-09-22 Thread Jussi Piitulainen
joni writes: > Have a simple question in the Integer calculator in Python 2.65 and > also 2.7.. > > The consol showing: > > Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) ... > >>> -7/3 > -3 > >>> > > -3 are more wrong than -2. Negativ number seems not to round to > nearest interger, but the

Re: httplib's HEAD request, and https protocol

2011-09-22 Thread Yaşar Arabacı
Ok, nevermind. Appereantly there is such a thing as HTTPSConnection. I thought httplib auto-handled https connections.. 22 Eylül 2011 13:43 tarihinde Yaşar Arabacı yazdı: > Hi, > > I wrote a function to get thorugh redirections and find a final page for a > given web-page. But following function

Negativ nearest interger?

2011-09-22 Thread joni
Have a simple question in the Integer calculator in Python 2.65 and also 2.7.. The consol showing: Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) [GCC 4.4.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> 7.0/3 #fist to show floiting-point calculation 2.3

Re: Environment variables not visible from Python

2011-09-22 Thread Steven D'Aprano
Ben Finney wrote: > Steven D'Aprano writes: > >> I don't understand why some environment variables are not visible from >> Python. > > Not all variables are environment variables. Variables only become > environment variables if exported to the environment; the ‘export’ > command is one way to

Re: Execute code after Shut Down command given --- How?

2011-09-22 Thread Steven D'Aprano
Virgil Stokes wrote: > I would like to execute some Python code (popup message to be displayed) > when > Windows Vista/7 is shut down. That is, this code should execute after > "Shut Down" is given from the "Shut Down Windows" popup, but before the > actual shut down sequence starts. > > How to

Execute code after Shut Down command given --- How?

2011-09-22 Thread Virgil Stokes
I would like to execute some Python code (popup message to be displayed) when Windows Vista/7 is shut down. That is, this code should execute after "Shut Down" is given from the "Shut Down Windows" popup, but before the actual shut down sequence starts. How to write Python code to accomplish

httplib's HEAD request, and https protocol

2011-09-22 Thread Yaşar Arabacı
Hi, I wrote a function to get thorugh redirections and find a final page for a given web-page. But following function gives maximum recursion error for any https pages I tried. Do you know what might be the problem here? def getHeadResponse(url,response_cache = {}): try: return respon

Context manager with class methods

2011-09-22 Thread Gavin Panella
Hi, On Python 2.6 and 3.1 the following code works fine: class Foo(object): @classmethod def __enter__(cls): print("__enter__") @classmethod def __exit__(cls, exc_type, exc_value, traceback): print("__exit__") with Foo

Re: Environment variables not visible from Python

2011-09-22 Thread Ben Finney
Steven D'Aprano writes: > I don't understand why some environment variables are not visible from > Python. Not all variables are environment variables. Variables only become environment variables if exported to the environment; the ‘export’ command is one way to do that. -- \ “As far a

Re: python install on locked down windows box?

2011-09-22 Thread Glenn Hutchings
You could try Portable Python (http://www.portablepython.com). No need to install anything! -- http://mail.python.org/mailman/listinfo/python-list

python install on locked down windows box?

2011-09-22 Thread Chris Withers
Hi All, Is there a way to install python on a locked down Windows desktop? (ie: no compilers, no admin rights, etc) cheers, Chris -- Simplistix - Content Management, Batch Processing & Python Consulting - http://www.simplistix.co.uk -- http://mail.python.org/mailman/listinfo/python

Re: Odd behavior with imp.reload and logging

2011-09-22 Thread Andrew Berg
On 2011.09.22 03:25 AM, Steven D'Aprano wrote: > Objects left lying around from before the reload will keep references > open to the way things were before the reload. This often leads to > confusion when modules are edited, then reloaded. (Been there, done that.) I'll keep that in mind. My modul

Re: Odd behavior with imp.reload and logging

2011-09-22 Thread Steven D'Aprano
On Wed, 21 Sep 2011 23:47:55 -0500, Andrew Berg wrote: > On 2011.09.21 11:22 PM, Steven D'Aprano wrote: >> You could >> try something like this (untested): > That works. Thanks! > This makes me wonder what else stays around after a reload Practically everything. A reload doesn't delete anything,

Re: static statements and thread safety

2011-09-22 Thread Chris Angelico
On Thu, Sep 22, 2011 at 6:16 PM, Eric Snow wrote: > That's a good point.  So, isn't the default arguments hack in the same > boat with regards to threads? > > Maybe I'm just misunderstanding the thread concept in Python.  Threads > have separate execution stacks but share interpreter global state,

Re: Graphing

2011-09-22 Thread John Ladasky
I'm using matplotlib and I'm happy with it. Quick plotting is easy using the pyplot interface, which resembles the popular software package MATLAB. As your ambitions grow, matplotlib has many sophisticated tools waiting for you. -- http://mail.python.org/mailman/listinfo/python-list

Re: static statements and thread safety

2011-09-22 Thread Eric Snow
On Thu, Sep 22, 2011 at 2:06 AM, Chris Angelico wrote: > On Thu, Sep 22, 2011 at 5:45 PM, Eric Snow > wrote: >> I would expect that static variables would work pretty much the same >> way as default arguments > > Could you just abuse default arguments to accomplish this? > > def accumulate(n,sta

Re: Odd behavior with imp.reload and logging

2011-09-22 Thread Chris Angelico
On Thu, Sep 22, 2011 at 5:59 PM, Andrew Berg wrote: > That's quite unappealing for a few reasons. First, that would likely > require writing an entirely new bot (I'm not even that familiar with the > current one; I've only been writing a module for it). Ah, then yeah, it's probably not a good ide

Re: static statements and thread safety

2011-09-22 Thread Chris Angelico
On Thu, Sep 22, 2011 at 5:45 PM, Eric Snow wrote: > I would expect that static variables would work pretty much the same > way as default arguments Could you just abuse default arguments to accomplish this? def accumulate(n,statics={'sum':0}): statics['sum']+=n return statics['sum'] >>>

Re: Odd behavior with imp.reload and logging

2011-09-22 Thread Andrew Berg
On 2011.09.22 01:46 AM, Chris Angelico wrote: > I think Pike may be a good choice for you. That's quite unappealing for a few reasons. First, that would likely require writing an entirely new bot (I'm not even that familiar with the current one; I've only been writing a module for it). Also, I don'

static statements and thread safety

2011-09-22 Thread Eric Snow
A recent thread on the python-ideas list got me thinking about the possibility of a static statement (akin to global and nonlocal). I am wondering if an implementation would have to address thread safety concerns. I would expect that static variables would work pretty much the same way as default

Re: Python deadlock using subprocess.popen and communicate

2011-09-22 Thread Thomas Rachel
Am 22.09.2011 05:42 schrieb Atherun: I'm pretty sure thats the problem, this is a generic catch all function for running subprocesses. It can be anything to a simple command to a complex command with a ton of output. I'm looking for a better solution to handle the case of running subprocesses

Re: Environment variables not visible from Python

2011-09-22 Thread Thomas Rachel
Am 22.09.2011 08:12 schrieb Steven D'Aprano: I don't understand why some environment variables are not visible from Python. [steve@wow-wow ~]$ echo $LINES $COLUMNS $TERM 30 140 xterm [steve@wow-wow ~]$ python2.6 Python 2.6.6 (r266:84292, Dec 21 2010, 18:12:50) [GCC 4.1.2 20070925 (Red Hat 4.1.2-