Re: pymacs?

2011-11-17 Thread Bastian Ballmann

Hi,

why not try out emacs-for-python 
https://github.com/gabrielelanaro/emacs-for-python
It's has everything included one needs as a python programmer on emacs 
and even if it's not your choice you can lookup pymacs configuration there.

HTH && have a nice day

Basti


Am 17.11.2011 00:42, schrieb Andrea Crotti:
After a long time, and since it was included iin python-mode, I wanted 
to try if I can

get ropemacs working finally.
I have tried many possible things, also in Emacs -Q, and I actually 
got it working

only once, apparently by pure luck with Emacs -Q:

(setq py-load-python-mode-pymacs-p nil)

(setq ca-pymacs-path (expand-file-name 
"~/Emacs-configuration/python-mode/pymacs"))

(add-to-list 'load-path ca-pymacs-path)
(setenv "PYMACS_PYTHON" "python2.7")
(require 'pymacs)

(pymacs-load "ropemacs" "rope-")
(setq ropemacs-confirm-saving 'nil)

The problem is that this configuration doesn't use python-mode.el but 
the standard python.el,

all my attempts to make this work on my normal configuration failed.
Did anyone got both correctly working?

Thanks..



--
Bastian Ballmann / Web Developer
Notch Interactive GmbH / Badenerstrasse 571 / 8048 Zürich
Phone +41 43 818 20 91 / www.notch-interactive.com

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


Re: Got some problems when using logging Filter

2011-11-17 Thread sword
On Nov 16, 10:50 pm, Peter Otten <__pete...@web.de> wrote:
> sword wrote:
> > Thanks for your reply. I tried to edit the source a bit, now the
> > main.py looks like this:
> > #main.py
> > import logging
> > from logging import Filter
> > import a
> > import b
>
> > logging.basicConfig(level=logging.DEBUG)
> > root = logging.getLogger()
> > root.addFilter(Filter("GoneWithTheWind")) #so I suppose no log msg
> > would pass this filter
>
> > logger = logging.getLogger("main")
> > logger.debug("main process")
> > a.print_log()
> > b.print_log()
>
> > 
> > And It still prints out all the log msg. :(
>
> Here's a little demo to explore how filtering works:
>
> $ cat demo.py
> import logging
> class Filter(logging.Filter):
>     def filter(self, record):
>         print "applying filter", self.name
>         return True
>
> logging.basicConfig()
>
> loggers = [logging.getLogger(path) for path in ["", "a", "a.b"]]
> for logger in loggers:
>     logger.addFilter(Filter("filter@" + logger.name))
>
> [handler] = logging.getLogger().handlers
> handler.addFilter(Filter("filter@handler"))
>
> for logger in loggers:
>     logger.critical("whatever")
> $ python demo.py
> applying filter filter@root
> applying filter filter@handler
> CRITICAL:root:whatever
> applying filter filter@a
> applying filter filter@handler
> CRITICAL:a:whatever
> applying filter fil...@a.b
> applying filter filter@handler
> CRITICAL:a.b:whatever
> $
>
> As you can infer from the output only the filter(s) of the original logger
> and of the handler(s) are applied.

Thanks, so if I want to see my own log out of all logs produced by
different module in the project, I should addFilter to each
corresponding logger. I thought I could add Filter in root and filter
out only the interested info from it before.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: unit-profiling, similar to unit-testing

2011-11-17 Thread Ulrich Eckhardt

Am 16.11.2011 15:36, schrieb Roy Smith:

It's really, really, really hard to either control for, or accurately
measure, things like CPU or network load.  There's so much stuff you
can't even begin to see.  The state of your main memory cache.  Disk
fragmentation.  What I/O is happening directly out of kernel buffers vs
having to do a physical disk read.  How slow your DNS server is today.


Fortunately, I am in a position where I'm running tests on one system 
(generic desktop PC) while the system to test is another one, and there 
both hardware and software is under my control. Since this is rather 
smallish and embedded, the power and load of the desktop don't play a 
significant role, the other side is usually the bottleneck. ;)




What I suggest is instrumenting your unit test suite to record not just
the pas/fail status of every test, but also the test duration.  Stick
these into a database as the tests run.  Over time, you will accumulate
a whole lot of performance data, which you can then start to mine.


I'm not sure. I see unit tests as something that makes sure things run 
correctly. For performance testing, I have functions to set up and tear 
down the environment. Then, I found it useful to have separate code to 
prime a cache, which is something done before each test run, but which 
is not part of the test run itself. I'm repeating each test run N times, 
recording the times and calculating maximum, minimum, average and 
standard deviation. Some of this is similar to unit testing (code to set 
up/tear down), but other things are too different. Also, sometimes I can 
vary tests with a factor F, then I would also want to capture the 
influence of this factor. I would even wonder if you can't verify the 
behaviour agains an expected Big-O complexity somehow.


All of this is rather general, not specific to my use case, hence my 
question if there are existing frameworks to facilitate this task. Maybe 
it's time to create one...




While you're running the tests, gather as much system performance data
as you can (output of top, vmstat, etc) and stick that into your
database too.  You never know when you'll want to refer to the data, so
just collect it all and save it forever.


Yes, this is surely something that is necessary, in particular since 
there are no clear success/failure outputs like for unit tests and they 
require a human to interpret them.



Cheers!

Uli

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


Re: staticmethod makes my brain hurt

2011-11-17 Thread Thomas Rachel

Am 17.11.2011 03:30 schrieb Roy Smith:

When I run this (python 2.6.1):

class C:
 @staticmethod
 def foo():
 pass

 print "inside", foo, callable(foo)

print "outside", C.foo, callable(C.foo)

I get:

inside  False
outside  True


Right. The reason is that on an attribute access, you get a __get__ call 
of the "real" attribute.


That is, if your class has a "regular" method, it is stored there as a 
formal function. But if you access it (C.f), you get 
C.__dict__["f"].__get__(None, C) (not sure about the arguments, but you 
should get the idea).


A functions __get__ returns a unbound or bound method, depending on its 
own arguments.


With a static method, you don't want this to happen. So you wrap your 
"regular" function into a staticmethod object, which has a __get__() 
method itself just returning the wrapped function object.


Look at this:

>>> class C(object): pass
...
>>> f=lambda *a:a
>>> C.f=f
>>> s=staticmethod(f)
>>> C.s=s
>>> # Now we test the access
...
>>> f
 at 0x00B43E30>
>>> s

>>> C.f
>
>>> C().f
 of <__main__.C object at 0x00B48810>>
>>> C.s
 at 0x00B43E30>
>>> C().s
 at 0x00B43E30>
>>> f.__get__(None, C)
>
>>> f.__get__(C(), C)
 of <__main__.C object at 0x00B48AD0>>
>>> s.__get__(None, C)
 at 0x00B43E30>
>>> s.__get__(C(), C)
 at 0x00B43E30>


That's how things work.

If you want to get back the "real" function from a staticmethod, you 
either call its __get__ with an arbitrary argument, or you do it the 
clean way and do a


def deref(s):
class C(object): s=s
return s.s

and so do a

class User(Document):
 @staticmethod
 def _get_next_id():
   [blah, blah, blah]
   return id

 user_id = IntField(required=True, default=deref(_get_next_id))


HTH,


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


problem in running script file (model-default.py)

2011-11-17 Thread Anushree Tripathi
When I run script file(i.e.,model-default.py) on IDLE interface,I m
getting this error:
read_al_373E> Protein specified in ALIGN_CODES(i) was not found in the
alignment file; ALIGN_CODES(   1) =  2hyd
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to insert my own module in front of site eggs?

2011-11-17 Thread Marc Christiansen
Roy Smith  wrote:
> I'm trying to use a custom version of mongoengine.  I cloned the git 
> repo and put the directory on my PYTHONPATH, but python is still 
> importing the system's installed version.  Looking at sys.path, it's 
> obvious why:
> 
> $ echo $PYTHONPATH 
> /home/roy/songza:/home/roy/lib/mongoengine
> 
 pprint.pprint(sys.path)
> ['',
> '/usr/local/lib/python2.6/dist-packages/selenium-2.0a5-py2.6.egg',
> '/usr/local/lib/python2.6/dist-packages/unittest2-0.5.1-py2.6.egg',
> 
> '/usr/local/lib/python2.6/dist-packages/pymongo-1.9-py2.6-linux-x86_64.eg
> g',
> '/usr/local/lib/python2.6/dist-packages/virtualenv-1.5.2-py2.6.egg',
> '/usr/local/lib/python2.6/dist-packages/mongoengine-0.5.2-py2.6.egg',
> '/home/roy/songza',
> '/home/roy/lib/mongoengine',
[...]

> The system eggs come before my path.  I found 
> http://mail.python.org/pipermail/distutils-sig/2006-July/006520.html in 
> the archives; it explains that eggs come before PYTHONPATH, but doesn't 
> explain how to get around this problem.  I emphatically agree with 
> Michael Bayer who said:
> 
>> I cant think of a  possible scenario where a path would explicitly
>> exist in PYTHONPATH,  non-egg or egg, where the user would still like the
>> system-wide installation to take precedence
> 
> So, is there any way to get my local copy of mongoengine loaded instead 
> of the system egg?  I could probably import sys, and do an egg-ectomy on 
> sys.path before importing mongoengine, but that's too gross to 
> contemplate.

The only way I found is to edit the easy_install.pth file and comment
the two lines starting with "import sys". You'll have to do that every
time you install/upgrade an egg via easy_install (and maybe setuptools).
In your case the right file should be
/usr/local/lib/python2.6/dist-packages/easy_install.pth

BTW: You could try pip (http://www.pip-installer.org/) instead of
easy_install, it doesn't mess with sys.path.

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


Re: problem in running script file (model-default.py)

2011-11-17 Thread Chris Rebert
On Thu, Nov 17, 2011 at 1:51 AM, Anushree Tripathi
 wrote:
> When I run script file(i.e.,model-default.py) on IDLE interface,I m
> getting this error:
> read_al_373E> Protein specified in ALIGN_CODES(i) was not found in the
> alignment file; ALIGN_CODES(   1) =  2hyd

Such an error is entirely specific to the particular script you are
running (and/or possibly due to a lack of command-line arguments since
you're running it via IDLE).
Either consult the script's documentation or author, or post the
script here. We can't debug/troubleshoot code we don't have access to.

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


ProgressBar - Python and Powershell

2011-11-17 Thread Nikunj.Badjatya
Hi All,

I am using Python 2.7, windows Env.
I have an Installer written in Python(45%) and Powershell(55%) which is used to 
install Virtual Machines at specific locations. It is single threaded.
I am trying to implement a ProgressBar  for this installer. So that the user 
will come to know the progress of the installation.
I am using pypi progressbar module.
The top script is in python which inturns calls powershell scripts using 
subprocess.call() and proceeds with the installation.

I am taking a shared file between python and powershell, so that diff functions 
can update their %age completion level in to the file. Ex. Func1() updates it 
to 5%,  func2() will add its own 5% to it.. and so on.
At the start of the (main.py) script I am creating a thread whose sole purpose 
would be to keep "READ" a temp file for a new entry in it.
Based on this entry I can have my thread update the progressbar on the console.

My questions are:

1.   Can I have a better shared mechanism between python and powershell.?  
As I am using a file here. Reading + writing in python and writing only in 
powershell.  !


2.   Does this thread mechanism work.? I am yet to implement and test it.! 
:P What can be the possible shortfalls.?



Thanks

Nikunj
Bangalore - India

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


Re: staticmethod makes my brain hurt

2011-11-17 Thread Dotan Cohen
On Thu, Nov 17, 2011 at 09:37, Ian Kelly  wrote:
> On Wed, Nov 16, 2011 at 11:44 PM, Dotan Cohen  wrote:
>> Try this (untested):
>>
>> class C:
>>   @staticmethod
>>   def foo():
>>       pass
>>
>>   print "inside", C.foo, callable(C.foo)
>
> If you had tested this, you would have found that you get a NameError,
> since C is not yet bound inside the class block where you define it.
>

I hadn't tested, I'm at work far from Idle. Just shooting from the hip.

For that matter, though, this does work in Java (I'm pretty sure but
again, untested right now).

-- 
Dotan Cohen

http://gibberish.co.il
http://what-is-what.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: staticmethod makes my brain hurt

2011-11-17 Thread Chris Angelico
On Thu, Nov 17, 2011 at 10:13 PM, Dotan Cohen  wrote:
> I'm at work far from Idle.

Taken out of context, I'm sure your boss is pleased. :)

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


Re: unit-profiling, similar to unit-testing

2011-11-17 Thread Roy Smith
In article ,
 Ulrich Eckhardt  wrote:

> Yes, this is surely something that is necessary, in particular since 
> there are no clear success/failure outputs like for unit tests and they 
> require a human to interpret them.

As much as possible, you want to automate things so no human 
intervention is required.

For example, let's say you have a test which calls foo() and times how 
long it takes.  You've already mentioned that you run it N times and 
compute some basic (min, max, avg, sd) stats.  So far, so good.

The next step is to do some kind of regression against past results.  
Once you've got a bunch of historical data, it should be possible to 
look at today's numbers and detect any significant change in performance.

Much as I loathe the bureaucracy and religious fervor which has grown up 
around Six Sigma, it does have some good tools.  You might want to look 
into control charts (http://en.wikipedia.org/wiki/Control_chart).  You 
think you've got the test environment under control, do you?  Try 
plotting a month's worth of run times for a particular test on a control 
chart and see what it shows.

Assuming your process really is under control, I would write scripts 
that did the following kinds of analysis:

1) For a given test, do a linear regression of run time vs date.  If the 
line has any significant positive slope, you want to investigate why.

2) You already mentioned, "I would even wonder if you can't verify the 
behaviour agains an expected Big-O complexity somehow".  Of course you 
can.  Run your test a bunch of times with different input sizes.  I 
would try something like a 1-2-5 progression over several decades (i.e. 
input sizes of 10, 20, 50, 100, 200, 500, 1000, etc)  You will have to 
figure out what an appropriate range is, and how to generate useful 
input sets.  Now, curve fit your performance numbers to various shape 
curves and see what correlation coefficient you get.

All that being said, in my experience, nothing beats plotting your data 
and looking at it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to insert my own module in front of site eggs?

2011-11-17 Thread Roy Smith
In article <1s1fp8-6la@pluto.solar-empire.de>,
 Marc Christiansen  wrote:

> > So, is there any way to get my local copy of mongoengine loaded instead 
> > of the system egg?  I could probably import sys, and do an egg-ectomy on 
> > sys.path before importing mongoengine, but that's too gross to 
> > contemplate.
> 
> The only way I found is to edit the easy_install.pth file and comment
> the two lines starting with "import sys". You'll have to do that every
> time you install/upgrade an egg via easy_install (and maybe setuptools).
> In your case the right file should be
> /usr/local/lib/python2.6/dist-packages/easy_install.pth
> 
> BTW: You could try pip (http://www.pip-installer.org/) instead of
> easy_install, it doesn't mess with sys.path.

But, you're talking about installers.  I'm talking about if I've already 
got something installed, how do I force one particular python process to 
pull in a local copy of a module in preference to the installed one?

In some cases, I own the machine and can make changes to /usr/local/lib 
if I want to.  But what about on a shared machine?  I don't want to (or 
perhaps can't) play with what's in /usr/local/lib just to make my stuff 
load first.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to insert my own module in front of site eggs?

2011-11-17 Thread Duncan Booth
Roy Smith  wrote:

> In some cases, I own the machine and can make changes to /usr/local/lib 
> if I want to.  But what about on a shared machine?  I don't want to (or 
> perhaps can't) play with what's in /usr/local/lib just to make my stuff 
> load first.
> 

Have you considered running your code in a virtualenv?
http://pypi.python.org/pypi/virtualenv

-- 
Duncan Booth http://kupuguy.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Use and usefulness of the as syntax

2011-11-17 Thread candide

Le 12/11/2011 13:29, Arnaud Delobelle a écrit :


-- The second case seems to be rather widespread and causes math attribute
to be private but I don't figure out why this matters.


This way math doesn't get bound in the global namespace when doing
"from module import *"




To contextualize more, I guess you are referring to the following 
situation :




# a.py
import math as _math


# b.py
from a import *

print _math.sin(0)   # raise a NameError
print math.sin(0)# raise a NameError



so the as syntax is also seful for hiding name, isn'it ?
--
http://mail.python.org/mailman/listinfo/python-list


Re: Use and usefulness of the as syntax

2011-11-17 Thread candide

Thanks to all




Le 12/11/2011 13:27, Chris Angelico a écrit :
> On Sat, Nov 12, 2011 at 10:56 PM, candide  wrote:
>> import foo as f
>>
>> equivalent to
>>
>> import foo
>> f = foo
>>
>
> Not quite, it's closer to:
>
> import foo
> f = foo
> del foo
>



Le 12/11/2011 13:43, Tim Chase a écrit :
> On 11/12/11 05:56, candide wrote:
>> First, could you confirm the following syntax
>>
>> import foo as f
>>
>> equivalent to
>>
>> import foo
>> f = foo
>
> and the issuing "del foo"
>




Correct, I missed this point : I didn't realize that importing is also 
binding.

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


Both Python 2.5.2 and 2.7.2 flop the same way under Win 7

2011-11-17 Thread W. eWatson
Months ago 2.5.2 stopped functioning on my Win7 PC, so a few days ago I 
uninstalled and installed. Same problem. If one right-clicks on a py 
file, IDLE is not shown in the menu as Edit with IDLE. After playing 
with matters I gave up, and uninstalled 2.5.2 and turned to 2.7.2. Same 
results.


If I look at a 2.4 install on my laptop, I get the desired reference to 
Edit with IDLE.


My guess is that Win 7 is behind this. If so, it's good-bye Python.

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


Re: How to insert my own module in front of site eggs?

2011-11-17 Thread Paul Rudin
Roy Smith  writes:


> But, you're talking about installers.  I'm talking about if I've already 
> got something installed, how do I force one particular python process to 
> pull in a local copy of a module in preference to the installed one?
>
> In some cases, I own the machine and can make changes to /usr/local/lib 
> if I want to.  But what about on a shared machine?  I don't want to (or 
> perhaps can't) play with what's in /usr/local/lib just to make my stuff 
> load first.

Maybe I'm missing something - but if I want to do this I just mess about
with sys.path at the top of my python script/program. Always seems to
work... is there a situation in which it doesn't?

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


Re: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7

2011-11-17 Thread ray

On Friday, November 18, 2011 12:55 AM, W. eWatson wrote:
Months ago 2.5.2 stopped functioning on my Win7 PC, so a few days ago 
I uninstalled and installed. Same problem. If one right-clicks on a py 
file, IDLE is not shown in the menu as Edit with IDLE. After playing 
with matters I gave up, and uninstalled 2.5.2 and turned to 2.7.2. 
Same results.


If I look at a 2.4 install on my laptop, I get the desired reference 
to Edit with IDLE.


My guess is that Win 7 is behind this. If so, it's good-bye Python.

Comments?
Why not good-bye Windows ? Actually you may want to try Vim, or gVim in 
Windows. I think the people who use IDLE is with really good patient.

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


Re: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7

2011-11-17 Thread spartan.the
On 17 Nov, 18:55, "W. eWatson"  wrote:
> Months ago 2.5.2 stopped functioning on my Win7 PC, so a few days ago I
> uninstalled and installed. Same problem. If one right-clicks on a py
> file, IDLE is not shown in the menu as Edit with IDLE. After playing
> with matters I gave up, and uninstalled 2.5.2 and turned to 2.7.2. Same
> results.
>
> If I look at a 2.4 install on my laptop, I get the desired reference to
> Edit with IDLE.
>
> My guess is that Win 7 is behind this. If so, it's good-bye Python.
>
> Comments?

I prefer "fail fast" approach too.

If right-click not working on Win7 is your reason to say good bye to
Python then better you do so.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7

2011-11-17 Thread John Gordon
In  "W. eWatson"  writes:

> Months ago 2.5.2 stopped functioning on my Win7 PC, so a few days ago I 
> uninstalled and installed. Same problem. If one right-clicks on a py 
> file, IDLE is not shown in the menu as Edit with IDLE. After playing 
> with matters I gave up, and uninstalled 2.5.2 and turned to 2.7.2. Same 
> results.

I'm not sure I'd describe the lack of IDLE in a context menu as
"python not functioning".

> If I look at a 2.4 install on my laptop, I get the desired reference to 
> Edit with IDLE.

> My guess is that Win 7 is behind this. If so, it's good-bye Python.

It was working originally, right?  So the problem can't really just be
Win 7.

Can you add IDLE manually to the associated applications list?

-- 
John Gordon   A is for Amy, who fell down the stairs
gor...@panix.com  B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"

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


Twisted 11.1.0 Released

2011-11-17 Thread Thomas Hervé

On behalf of Twisted Matrix Laboratories, I am pleased to announce the
release of Twisted 11.1.

Highlights of the 185 tickets closed include:

 * The poll reactor as default where applicable, instead of select
   everywhere.

 * A new SSL implementation only relying on OpenSSL for cryptography,
   (not I/O) making it more robust.

 * Several improvements to the fresh HTTP/1.1 client implementation,
   including proxy and cookie support.

 * My personal favorite: a new howto has been published on test-driven
   development with Twisted.

 * A special mention to the new abortConnection support on TCP and SSL
   connections, heroically pushed by Itamar and Jean-Paul, and the
   oldest ticket closed by this release.

This is the last release supporting Python 2.4 (the support on Windows stopped 
with 11.0).

For more information, see the NEWS file here:

 http://twistedmatrix.com/Releases/Twisted/11.1/NEWS.txt

Download it now from:

 http://pypi.python.org/packages/source/T/Twisted/Twisted-11.1.0.tar.bz2 or
 http://pypi.python.org/packages/2.5/T/Twisted/Twisted-11.1.0.win32-py2.5.msi or
 http://pypi.python.org/packages/2.6/T/Twisted/Twisted-11.1.0.win32-py2.6.msi or
 http://pypi.python.org/packages/2.7/T/Twisted/Twisted-11.1.0.win32-py2.7.msi

Thanks to the supporters of the Twisted Software Foundation and to the many 
contributors for this release.

--
Thomas

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


Re: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7

2011-11-17 Thread Steven D'Aprano
On Thu, 17 Nov 2011 08:55:36 -0800, W. eWatson wrote:

> Months ago 2.5.2 stopped functioning on my Win7 PC, so a few days ago I
> uninstalled and installed. Same problem. If one right-clicks on a py
> file, IDLE is not shown in the menu as Edit with IDLE. After playing
> with matters I gave up, and uninstalled 2.5.2 and turned to 2.7.2. Same
> results.

I find I get better results when I stop "playing with matters" and start 
treating them seriously :)

If you need help fixing the file associations on your Windows 7 machine, 
you'll probably get better advice on a dedicated Windows forum. Or even 
by googling for instructions:

https://duckduckgo.com/html/?q=how%20to%20fix%20windows%207%20file%20associations

 
> If I look at a 2.4 install on my laptop, I get the desired reference to
> Edit with IDLE.

So you're saying that Python is working on one laptop, but not on another 
machine?

Okay. Great. What's your point? You have a messed up installation on your 
Windows 7 box, and a working installation on your laptop. What would you 
like us to do? Commiserate? Laugh? Look into a crystal ball and tell you 
what you did wrong?

Can you run Python from the command line? If so, that tells you that 
Python is installed and working correctly. If Python is installed, then 
it sounds like a matter of getting the file associates fixed in the 
registry. Good luck.


> My guess is that Win 7 is behind this. If so, it's good-bye Python.
> 
> Comments?

Why not good-bye Windows 7?

This being Windows, have you run a virus scan with up to date 
definitions? Then run a *second* scan, using a completely different 
scanner, because no scanner can catch all viruses? And then run a good 
anti-spyware program. All of which will be irrelevant 99 times out of 
100, but you could be the 1% ...



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


Re: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7

2011-11-17 Thread W. eWatson

On 11/17/2011 9:39 AM, John Gordon wrote:

In  "W. eWatson"  writes:


Months ago 2.5.2 stopped functioning on my Win7 PC, so a few days ago I
uninstalled and installed. Same problem. If one right-clicks on a py
file, IDLE is not shown in the menu as Edit with IDLE. After playing
with matters I gave up, and uninstalled 2.5.2 and turned to 2.7.2. Same
results.


I'm not sure I'd describe the lack of IDLE in a context menu as
"python not functioning".


If I look at a 2.4 install on my laptop, I get the desired reference to
Edit with IDLE.



My guess is that Win 7 is behind this. If so, it's good-bye Python.


It was working originally, right?  So the problem can't really just be
Win 7.

Can you add IDLE manually to the associated applications list?

Not successfully. I tried it and pointed to idle.pyw. It gave a Invalid 
Win32 app.

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


Re: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7

2011-11-17 Thread W. eWatson

On 11/17/2011 9:39 AM, John Gordon wrote:

In  "W. eWatson"  writes:


Months ago 2.5.2 stopped functioning on my Win7 PC, so a few days ago I
uninstalled and installed. Same problem. If one right-clicks on a py
file, IDLE is not shown in the menu as Edit with IDLE. After playing
with matters I gave up, and uninstalled 2.5.2 and turned to 2.7.2. Same
results.


I'm not sure I'd describe the lack of IDLE in a context menu as
"python not functioning".

Well, yes, and I can run it from the command line.



If I look at a 2.4 install on my laptop, I get the desired reference to
Edit with IDLE.



My guess is that Win 7 is behind this. If so, it's good-bye Python.
This has been a nagging problem for far too long. I see no reason why a 
simple install should make such a difference with the way I get to IDLE. 
Maybe few people here like IDLE, but for my minimal needs, it's just fine.




It was working originally, right?  So the problem can't really just be
Win 7.
I installed it about April 2010, and it worked for months. I then 
stopped using it until around July 2011. It no longer worked in the IDLE 
sense.


Who really knows?



Can you add IDLE manually to the associated applications list?

Tried that by sending it directly to idle.pyw, but then trying to get 
there through the Edit with menu caused a "invalid Win32 app."

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


Re: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7

2011-11-17 Thread Chris Angelico
On Fri, Nov 18, 2011 at 7:31 AM, W. eWatson  wrote:
> I installed it [Windows 7] about April 2010, and it worked for months. I then 
> stopped
> using it until around July 2011. It no longer worked in the IDLE sense.
>

Microsoft have broken things in many Windowses, and it's often hard to
figure out whether the fault is with the Windows version or with the
application. MS several times went to ridiculous effort to try to
ensure that broken programs that ran under version X would still run
under version Y, to the extent of being bug-for-bug compatible.

If you're having issues, grab a spare computer, throw Linux on it (I
recommend Ubuntu or Debian, others will have other preferred distros),
and see if the issues remain. Or if you're having trouble with the
GUI, try things from the command line (Windows's command interpreter
is pretty weak compared to bash, but it's plenty powerful enough).

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


Re: unit-profiling, similar to unit-testing

2011-11-17 Thread Tycho Andersen
On Wed, Nov 16, 2011 at 09:36:40AM -0500, Roy Smith wrote:
> In article <95bcp8-bft@satorlaser.homedns.org>,
>  Ulrich Eckhardt  wrote:
> 
> > Hi!
> > 
> > I'm currently trying to establish a few tests here that evaluate certain 
> > performance characteristics of our systems. As part of this, I found 
> > that these tests are rather similar to unit-tests, only that they are 
> > much more fuzzy and obviously dependent on the systems involved, CPU 
> > load, network load, day of the week (Tuesday is virus scan day) etc.
> > 
> > What I'd just like to ask is how you do such things. Are there tools 
> > available that help? I was considering using the unit testing framework, 
> > but the problem with that is that the results are too hard to interpret 
> > programmatically and too easy to misinterpret manually. Any suggestions?
> 
> It's really, really, really hard to either control for, or accurately 
> measure, things like CPU or network load.  There's so much stuff you 
> can't even begin to see.  The state of your main memory cache.  Disk 
> fragmentation.  What I/O is happening directly out of kernel buffers vs 
> having to do a physical disk read.  How slow your DNS server is today.

While I agree there's a lot of things you can't control for, you can
get a more accurate picture by using CPU time instead of wall time
(e.g. the clock() system call). If what you care about is mostly CPU
time, you can control for the "your disk is fragmented", "your DNS
server died", or "my cow-orker was banging on the test machine" this
way.

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


Re: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7

2011-11-17 Thread MRAB

On 17/11/2011 20:31, W. eWatson wrote:

On 11/17/2011 9:39 AM, John Gordon wrote:

In "W. eWatson"
writes:


Months ago 2.5.2 stopped functioning on my Win7 PC, so a few days ago I
uninstalled and installed. Same problem. If one right-clicks on a py
file, IDLE is not shown in the menu as Edit with IDLE. After playing
with matters I gave up, and uninstalled 2.5.2 and turned to 2.7.2. Same
results.


I'm not sure I'd describe the lack of IDLE in a context menu as
"python not functioning".

Well, yes, and I can run it from the command line.



If I look at a 2.4 install on my laptop, I get the desired reference to
Edit with IDLE.



My guess is that Win 7 is behind this. If so, it's good-bye Python.

This has been a nagging problem for far too long. I see no reason why a
simple install should make such a difference with the way I get to IDLE.
Maybe few people here like IDLE, but for my minimal needs, it's just fine.



It was working originally, right? So the problem can't really just be
Win 7.

I installed it about April 2010, and it worked for months. I then
stopped using it until around July 2011. It no longer worked in the IDLE
sense.

Who really knows?



Can you add IDLE manually to the associated applications list?


Tried that by sending it directly to idle.pyw, but then trying to get
there through the Edit with menu caused a "invalid Win32 app."


Are you trying to associate .pyw with idle.pyw instead of with
pythonw.exe?
--
http://mail.python.org/mailman/listinfo/python-list


Re: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7

2011-11-17 Thread spartan.the
On Nov 17, 10:31 pm, "W. eWatson"  wrote:
> On 11/17/2011 9:39 AM, John Gordon wrote:> In  "W. 
> eWatson"  writes:
>
> >> Months ago 2.5.2 stopped functioning on my Win7 PC, so a few days ago I
> >> uninstalled and installed. Same problem. If one right-clicks on a py
> >> file, IDLE is not shown in the menu as Edit with IDLE. After playing
> >> with matters I gave up, and uninstalled 2.5.2 and turned to 2.7.2. Same
> >> results.
>
> > I'm not sure I'd describe the lack of IDLE in a context menu as
> > "python not functioning".
>
> Well, yes, and I can run it from the command line.
>
> >> If I look at a 2.4 install on my laptop, I get the desired reference to
> >> Edit with IDLE.
>
> >> My guess is that Win 7 is behind this. If so, it's good-bye Python.
>
> This has been a nagging problem for far too long. I see no reason why a
> simple install should make such a difference with the way I get to IDLE.
> Maybe few people here like IDLE, but for my minimal needs, it's just fine.
>
>
>
> > It was working originally, right?  So the problem can't really just be
> > Win 7.
>
> I installed it about April 2010, and it worked for months. I then
> stopped using it until around July 2011. It no longer worked in the IDLE
> sense.
>
> Who really knows?
>
>
>
> > Can you add IDLE manually to the associated applications list?
>
> Tried that by sending it directly to idle.pyw, but then trying to get
> there through the Edit with menu caused a "invalid Win32 app."

idle.pyw is not executable in Windows, but you can right-click it,
open, browse to pythonw.exe. Then it should work.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: unit-profiling, similar to unit-testing

2011-11-17 Thread spartan.the
On Nov 17, 4:03 pm, Roy Smith  wrote:
> In article ,
>  Ulrich Eckhardt  wrote:
>
> > Yes, this is surely something that is necessary, in particular since
> > there are no clear success/failure outputs like for unit tests and they
> > require a human to interpret them.
>
> As much as possible, you want to automate things so no human
> intervention is required.
>
> For example, let's say you have a test which calls foo() and times how
> long it takes.  You've already mentioned that you run it N times and
> compute some basic (min, max, avg, sd) stats.  So far, so good.
>
> The next step is to do some kind of regression against past results.
> Once you've got a bunch of historical data, it should be possible to
> look at today's numbers and detect any significant change in performance.
>
> Much as I loathe the bureaucracy and religious fervor which has grown up
> around Six Sigma, it does have some good tools.  You might want to look
> into control charts (http://en.wikipedia.org/wiki/Control_chart).  You
> think you've got the test environment under control, do you?  Try
> plotting a month's worth of run times for a particular test on a control
> chart and see what it shows.
>
> Assuming your process really is under control, I would write scripts
> that did the following kinds of analysis:
>
> 1) For a given test, do a linear regression of run time vs date.  If the
> line has any significant positive slope, you want to investigate why.
>
> 2) You already mentioned, "I would even wonder if you can't verify the
> behaviour agains an expected Big-O complexity somehow".  Of course you
> can.  Run your test a bunch of times with different input sizes.  I
> would try something like a 1-2-5 progression over several decades (i.e.
> input sizes of 10, 20, 50, 100, 200, 500, 1000, etc)  You will have to
> figure out what an appropriate range is, and how to generate useful
> input sets.  Now, curve fit your performance numbers to various shape
> curves and see what correlation coefficient you get.
>
> All that being said, in my experience, nothing beats plotting your data
> and looking at it.

I strongly agree with Roy, here.

Ulrich, I recommend you to explore how google measures appengine's
health here: http://code.google.com/status/appengine.

Unit tests are inappropriate here; any single unit test can answer
PASS or FAIL, YES or NO. It can't answer the question "how much".
Unless you just want to use unit tests. Then any arguments here just
don't make sense.

I suggest:

1. Decide what you want to measure. Measure result must be a number in
range (0..100, -5..5), so you can plot them.
2. Write no-UI programs to get each number (measure) and write it to
CSV. Run each of them several times take away 1 worst and 1 best
result, and take and average number.
3. Collect the data for some period of time.
4. Plot those average number over time axis (it's easy with CSV
format).
5. Make sure you automate this process (batch files or so) so the plot
is generated automatically each hour or each day.

And then after a month you can decide if you want to divide your
number ranges into green-yellow-red zones. More often than not you may
find that your measures are so inaccurate and random that you can't
trust them. Then you'll either forget that or dive into math
(statistics). You have about 5% chances to succeed ;)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7

2011-11-17 Thread Terry Reedy

On 11/17/2011 11:55 AM, W. eWatson wrote:

Months ago 2.5.2 stopped functioning on my Win7 PC, so a few days ago I
uninstalled and installed. Same problem. If one right-clicks on a py
file, IDLE is not shown in the menu as Edit with IDLE. After playing
with matters I gave up, and uninstalled 2.5.2 and turned to 2.7.2. Same
results.

If I look at a 2.4 install on my laptop, I get the desired reference to
Edit with IDLE.

My guess is that Win 7 is behind this. If so, it's good-bye Python.


I installed 3.3.2 on a new Win 7 machine and Edit with IDLE works fine. 
However, I almost never use that with Explorer to open files. I have 
IDLE pinned to the task bar so it is one click to start. If I edit a 
file, I want to run it, so I want a shell window open anyway. I usually 
open files to edit with the first three entries under the File menu: New 
File, Open, or Recent Files. Once I open a file in a particular 
directory (usually with Recent Files), Open initially looks for files in 
the same directory, which is usually what I want. So say hello again to 
Python, especially Python 3.


--
Terry Jan Reedy

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


Re: Monitoring/inventory client-server app

2011-11-17 Thread Irmen de Jong

On 17-11-2011 5:17, snorble wrote:

I'm writing a tool for monitoring the workstations and servers in our
office. I plan to have a server and a client service that runs on each
workstation and reports back to the server (heartbeat, disk free
space, etc).

So far I am considering XMLRPC, or a client service that just
downloads a Python file and runs it.

With XMLRPC I don't know how to easily add features without having to
update every client. Also while playing with XMLRPC I learned that
when you run a registered function, it runs it on the server. I was
hoping it would run on the client, so that when I get the machine's
computer name (or disk space, etc) it will return the client's info.
It seems with XMLRPC I would have to hard code the functionality into
the client (i.e. client gets it's computer name, then calls the XMLRPC
function to pass it to the server)? I was hoping it would work more
like, "pass some code to the client to be run on the client, and
report it to the server". Almost XMLRPC in the reverse direction.

With the download-and-run approach, it seems trivially easy to add new
functionality to the clients. Just save the updated Python file to the
server, and clients download it and run it.

Are there any standard approaches to problems like this that can be
recommended? Thank you.



The security implications are HUGE when you are thinking about 
transferring and executing arbitrary code over the network. Avoid this 
if at all possible. But if you can be 100% sure it's only trusted stuff, 
things are not so grim.


Have a look at Pyro, or even Pyro Flame:

http://packages.python.org/Pyro4/
http://packages.python.org/Pyro4/flame.html

Flame allows for very easy remote module execution and a limited way of 
transferring code to the 'other side'.


Also what is wrong with running an XMLrpc server, or Pyro daemon, on 
your client machines? This way your central computer can call registered 
methods (or remote objects in case of Pyro) on the client and execute 
code there (that reports all sorts of stuff you want to know). Or have 
each client call into a central server, where it reports that stuff 
itself. Many ways to skin a cat.


Regards,
Irmen de Jong

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


Re: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7

2011-11-17 Thread W. eWatson

On 11/17/2011 12:46 PM, spartan.the wrote:

On Nov 17, 10:31 pm, "W. eWatson"  wrote:

On 11/17/2011 9:39 AM, John Gordon wrote:>  In"W. 
eWatson"writes:


Months ago 2.5.2 stopped functioning on my Win7 PC, so a few days ago I
uninstalled and installed. Same problem. If one right-clicks on a py
file, IDLE is not shown in the menu as Edit with IDLE. After playing
with matters I gave up, and uninstalled 2.5.2 and turned to 2.7.2. Same
results.



I'm not sure I'd describe the lack of IDLE in a context menu as
"python not functioning".


Well, yes, and I can run it from the command line.


If I look at a 2.4 install on my laptop, I get the desired reference to
Edit with IDLE.



My guess is that Win 7 is behind this. If so, it's good-bye Python.


This has been a nagging problem for far too long. I see no reason why a
simple install should make such a difference with the way I get to IDLE.
Maybe few people here like IDLE, but for my minimal needs, it's just fine.




It was working originally, right?  So the problem can't really just be
Win 7.


I installed it about April 2010, and it worked for months. I then
stopped using it until around July 2011. It no longer worked in the IDLE
sense.

Who really knows?




Can you add IDLE manually to the associated applications list?


Tried that by sending it directly to idle.pyw, but then trying to get
there through the Edit with menu caused a "invalid Win32 app."


idle.pyw is not executable in Windows, but you can right-click it,
open, browse to pythonw.exe. Then it should work.


right-click on junk.py gives me a menu. I select Open with, and ... 
hmmm, whoops, in the latest install, 2.7.2, I did not give it access to 
idle.pyw.


My mistake above. I was talking about the previous 2.5.2 of install in 
Win7. Where I'm at is 2.7.2 now. However, I still find in very odd there 
is no Edit with IDLE when I right-click on junk.py. That's the way it 
worked on 2.5.2 on my XP and earlier, 2010, on Win7. Downright frustrating.


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


Re: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7

2011-11-17 Thread W. eWatson

On 11/17/2011 12:59 PM, MRAB wrote:

On 17/11/2011 20:31, W. eWatson wrote:

On 11/17/2011 9:39 AM, John Gordon wrote:

In "W. eWatson"
writes:


Months ago 2.5.2 stopped functioning on my Win7 PC, so a few days ago I
uninstalled and installed. Same problem. If one right-clicks on a py
file, IDLE is not shown in the menu as Edit with IDLE. After playing
with matters I gave up, and uninstalled 2.5.2 and turned to 2.7.2. Same
results.


I'm not sure I'd describe the lack of IDLE in a context menu as
"python not functioning".

Well, yes, and I can run it from the command line.



If I look at a 2.4 install on my laptop, I get the desired reference to
Edit with IDLE.



My guess is that Win 7 is behind this. If so, it's good-bye Python.

This has been a nagging problem for far too long. I see no reason why a
simple install should make such a difference with the way I get to IDLE.
Maybe few people here like IDLE, but for my minimal needs, it's just
fine.



It was working originally, right? So the problem can't really just be
Win 7.

I installed it about April 2010, and it worked for months. I then
stopped using it until around July 2011. It no longer worked in the IDLE
sense.

Who really knows?



Can you add IDLE manually to the associated applications list?


Tried that by sending it directly to idle.pyw, but then trying to get
there through the Edit with menu caused a "invalid Win32 app."


Are you trying to associate .pyw with idle.pyw instead of with
pythonw.exe?
What does pythonw.exe do for me? I would think all associations would be 
correct after an install.


The single thing I do not understand is why in my latest install of 
2.5.2 and 2.7.2 (2.5.2 was uninstalled before going to 2.7.2) on Win7 
that why a right-click on a py file does not show as a choice is "Edit 
with IDLE", as it does on my XP PC and my 2010 install of 2.5.2 on this 
Win 7 PC. To me that signals that something is wrong.

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


Re: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7

2011-11-17 Thread W. eWatson

On 11/17/2011 2:12 PM, Terry Reedy wrote:

On 11/17/2011 11:55 AM, W. eWatson wrote:

Months ago 2.5.2 stopped functioning on my Win7 PC, so a few days ago I
uninstalled and installed. Same problem. If one right-clicks on a py
file, IDLE is not shown in the menu as Edit with IDLE. After playing
with matters I gave up, and uninstalled 2.5.2 and turned to 2.7.2. Same
results.

If I look at a 2.4 install on my laptop, I get the desired reference to
Edit with IDLE.

My guess is that Win 7 is behind this. If so, it's good-bye Python.


I installed 3.3.2 on a new Win 7 machine and Edit with IDLE works fine.
However, I almost never use that with Explorer to open files. I have
IDLE pinned to the task bar so it is one click to start. If I edit a
file, I want to run it, so I want a shell window open anyway. I usually
open files to edit with the first three entries under the File menu: New
File, Open, or Recent Files. Once I open a file in a particular
directory (usually with Recent Files), Open initially looks for files in
the same directory, which is usually what I want. So say hello again to
Python, especially Python 3.

I have not found any successful way to get to IDLE. It's on on the 
right-click of a py menu, and, if I go the ...lib/idle.pyw, it fails 
with a "invalid Win32 app" msg.

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


Re: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7

2011-11-17 Thread Steven D'Aprano
On Thu, 17 Nov 2011 16:03:14 -0800, W. eWatson wrote:

> I have not found any successful way to get to IDLE. It's on on the
> right-click of a py menu, and, if I go the ...lib/idle.pyw, it fails
> with a "invalid Win32 app" msg.

If you associate .pyw files with pythonw.exe, and then open idle.pyw, 
does it work?

Failing that, go to your laptop where the associations are right, and see 
what they are, then duplicate the settings on your Windows 7 machine.




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


Re: How to insert my own module in front of site eggs?

2011-11-17 Thread Roy Smith
In article <874ny2fzn6@no-fixed-abode.cable.virginmedia.net>,
 Paul Rudin  wrote:

> Roy Smith  writes:
> 
> 
> > But, you're talking about installers.  I'm talking about if I've already 
> > got something installed, how do I force one particular python process to 
> > pull in a local copy of a module in preference to the installed one?
> >
> > In some cases, I own the machine and can make changes to /usr/local/lib 
> > if I want to.  But what about on a shared machine?  I don't want to (or 
> > perhaps can't) play with what's in /usr/local/lib just to make my stuff 
> > load first.
> 
> Maybe I'm missing something - but if I want to do this I just mess about
> with sys.path at the top of my python script/program. Always seems to
> work... is there a situation in which it doesn't?

What if the first import of a module is happening inside some code you 
don't have access to?

It just seems mind-boggling to me that PYTHONPATH doesn't preempt 
everything else.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to insert my own module in front of site eggs?

2011-11-17 Thread Roy Smith
In article ,
 Duncan Booth  wrote:

> Roy Smith  wrote:
> 
> > In some cases, I own the machine and can make changes to /usr/local/lib 
> > if I want to.  But what about on a shared machine?  I don't want to (or 
> > perhaps can't) play with what's in /usr/local/lib just to make my stuff 
> > load first.
> > 
> 
> Have you considered running your code in a virtualenv?
> http://pypi.python.org/pypi/virtualenv

I do that for some projects.  In fact, I suspect I will do that for all 
furture projects that I start from scratch.  For this particular one, 
there's a lot of stuff already installed in the system that I need.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7

2011-11-17 Thread Martin P. Hellwig

On 17/11/2011 23:54, W. eWatson wrote:


My mistake above. I was talking about the previous 2.5.2 of install in
Win7. Where I'm at is 2.7.2 now. However, I still find in very odd there
is no Edit with IDLE when I right-click on junk.py. That's the way it
worked on 2.5.2 on my XP and earlier, 2010, on Win7. Downright frustrating.



Well if I was still a windows administrator and you would be one of my 
users, I would first make sure that your profile or windows installation 
is not pooped as it definitively smells like that.


After being reassured that this is not the case I would then search the 
interwebs for something like "extending right click context menu".


Probably hitting something like this:

http://answers.microsoft.com/en-us/windows/forum/windows_7-desktop/how-can-i-customize-right-click-mouse-context-menu/5ea7104f-2213-41b9-9933-83f25da086d1

And after that searching where this 'idle' you speak of is actually 
located, probably finding something like this:


http://stackoverflow.com/questions/118260/how-to-start-idle-python-editor-without-using-the-shortcut-on-windows-vista

Then it rest me to combine them both, after promising myself not to 
install one version of a particular program 'for all users' and then 
'updating' for 'only me' as this can screw up the default settings quite 
badly.


But hey I haven't been a win admin since I switched over to FreeBSD 
years and years ago. I find it immensely reassuring that the problems I 
encounter on my systems are all my fault, well actually that is just the 
same as with windows, just less obvious there.


Luckily I am no longer an administrator either as I couldn't stand it 
anymore when users spill their frustrations, although perfectly 
understandable, unto those who are actually willing to help.


Something to do with attitude or so, speaking if which, I do apologize 
for my own attitude, but given the choice of just ignoring you or lacing 
my post with patronization I though that the latter one was the least 
bad of them two.


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


Re: unit-profiling, similar to unit-testing

2011-11-17 Thread Roy Smith
In article ,
 Tycho Andersen  wrote:

> While I agree there's a lot of things you can't control for, you can
> get a more accurate picture by using CPU time instead of wall time
> (e.g. the clock() system call). If what you care about is mostly CPU
> time [...]

That's a big if.  In some cases, CPU time is important, but more often, 
wall-clock time is more critical.  Let's say I've got two versions of a 
program.  Here's some results for my test run:

Version CPU Time Wall-Clock Time
   1 2 hours   2.5 hours
   2 1.5 hours 5.0 hours

Between versions, I reduced the CPU time to complete the given task, but 
increased the wall clock time.  Perhaps I doubled the size of some hash 
table.  Now I get a lot fewer hash collisions (so I spend less CPU time 
re-hashing), but my memory usage went up so I'm paging a lot and my 
locality of reference went down so my main memory cache hit rate is 
worse.

Which is better?  I think most people would say version 1 is better.

CPU time is only important in a situation where the system is CPU bound.  
In many real-life cases, that's not at all true.  Things can be memory 
bound.  Or I/O bound (which, when you consider paging, is often the same 
thing as memory bound).  Or lock-contention bound.

Before you starting measuring things, it's usually a good idea to know 
what you want to measure, and why :-)
-- 
http://mail.python.org/mailman/listinfo/python-list


What exactly is "pass"? What should it be?

2011-11-17 Thread John Ladasky
Hi folks,

I'm trying to write tidy, modular code which includes a long-running process.  
From time to time I MIGHT like to check in on the progress being made by that 
long-running process, in various ways.  Other times, I'll just want to let it 
run.  So I have a section of code which, generally, looks like this:

def _pass(*args):
pass

def long_running_process(arg1, arg2, arg_etc, report = _pass):
result1 = do_stuff()
report(result1)
result2 = do_some_different_stuff()
report(result2)
result3 = do_even_more_stuff()
report(result3)
return result3

This does what I want.  When I do not specify a report function, the process 
simply runs.  Typically, when I do supply a report function, it would print 
something to stdout, or draw an update through a GUI.

But this approach seems a tad cumbersome and unPythonic to me, particularly the 
part where I define the function _pass() which accepts an arbitrary argument 
list, and does nothing but... pass.

This has led me to ask the question, what exactly IS pass?  I played with the 
interpreter a bit.

IDLE 2.6.6   No Subprocess 
>>> pass
>>> pass()
SyntaxError: invalid syntax
>>> type(pass)
SyntaxError: invalid syntax

So, pass does not appear to be a function, nor even an object.  Is it nothing 
more than a key word?

And would there be any merit to having some syntactic sugar which allows pass 
to behave like the _pass() function I wrote, if it were called?

As you can see, I'm programming in Python 2.6.  I don't know whether pass is 
handled differently in Python 3.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: staticmethod makes my brain hurt

2011-11-17 Thread alex23
On Nov 17, 1:24 pm, Ethan Furman  wrote:
> If you do need to sometimes call it from a method then still leave off
> the '@staticmethod', and give 'self' a default of 'None':
>
>      def _get_next_id(self=None):
>        [blah, blah, blah]
>        return id
>
>      user_id = IntField(required=True, default=_get_next_id)

And if the OP needs it to be a staticmethod as well, he can just wrap
the nested function:

  gen_next_id = staticmethod(_gen_next_id)

I think I like this approach best. I'm annoyed that I forgot functions
declared in a class scope were callable within the definition :)

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


Re: Use and usefulness of the as syntax

2011-11-17 Thread alex23
On Nov 18, 1:48 am, candide  wrote:
> # a.py
> import math as _math
>
> # b.py
> from a import *
>
> print _math.sin(0)       # raise a NameError
> print math.sin(0)        # raise a NameError
>
> so the as syntax is also seful for hiding name, isn'it ?

Not exactly. It's the * import mechanism here that's ignoring any
bindings that begin with an underscore. If you had:

   _dummy = 1

...inside of a.py, it wouldn't be pulled in either. As you state
later, 'as' is purely a binding convenience.

Incidentally, you can still allow * import to bring in underscore-
prefixed bindings by adding them to an __all__:

__all__ = ['_dummy']
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What exactly is "pass"? What should it be?

2011-11-17 Thread Chris Rebert
On Thu, Nov 17, 2011 at 6:18 PM, John Ladasky  wrote:
> Hi folks,
>
> I'm trying to write tidy, modular code which includes a long-running process. 
>  From time to time I MIGHT like to check in on the progress being made by 
> that long-running process, in various ways.  Other times, I'll just want to 
> let it run.  So I have a section of code which, generally, looks like this:
>
> def _pass(*args):
>    pass
>
> def long_running_process(arg1, arg2, arg_etc, report = _pass):
>    result1 = do_stuff()
>    report(result1)
>    result2 = do_some_different_stuff()
>    report(result2)
>    result3 = do_even_more_stuff()
>    report(result3)
>    return result3
>
> This does what I want.  When I do not specify a report function, the process 
> simply runs.  Typically, when I do supply a report function, it would print 
> something to stdout, or draw an update through a GUI.
>
> But this approach seems a tad cumbersome and unPythonic to me, particularly 
> the part where I define the function _pass() which accepts an arbitrary 
> argument list, and does nothing but... pass.

Seems fine to me (good use of the null object pattern), although I
might define _pass() to instead take exactly 1 argument, since that's
all you ever call report() with in your example.

> This has led me to ask the question, what exactly IS pass?  I played with the 
> interpreter a bit.
>
> IDLE 2.6.6       No Subprocess 
 pass
 pass()
> SyntaxError: invalid syntax
 type(pass)
> SyntaxError: invalid syntax
>
> So, pass does not appear to be a function, nor even an object.  Is it nothing 
> more than a key word?

Correct:
http://docs.python.org/reference/simple_stmts.html#pass
http://docs.python.org/reference/lexical_analysis.html#keywords

Cheers,
Chris
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What exactly is "pass"? What should it be?

2011-11-17 Thread Chris Angelico
On Fri, Nov 18, 2011 at 1:18 PM, John Ladasky  wrote:
> def _pass(*args):
>    pass
>
> def long_running_process(arg1, arg2, arg_etc, report = _pass):
>

For some compactness at the expense of brevity, you could use a lambda:

def long_running_process(arg1, arg2, arg_etc, report = lambda msg: None):

Other than that, I think it's fine. (Actually, the lambda has a slight
advantage in self-documentation; in the main function's definition it
specifies that the 'report' argument is a function that takes one
argument, the message. (Or whatever that argument is. Name it
appropriately.)

If you call your dummy function something else, it may help
readability/self-documentation too. On the other hand, it may not.
YMMV.

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


Re: What exactly is "pass"? What should it be?

2011-11-17 Thread Dominic Binks

On 11/17/2011 6:45 PM, Chris Rebert wrote:

On Thu, Nov 17, 2011 at 6:18 PM, John Ladasky  wrote:

Hi folks,

I'm trying to write tidy, modular code which includes a long-running process.  
From time to time I MIGHT like to check in on the progress being made by that 
long-running process, in various ways.  Other times, I'll just want to let it 
run.  So I have a section of code which, generally, looks like this:

def _pass(*args):
pass

def long_running_process(arg1, arg2, arg_etc, report = _pass):
result1 = do_stuff()
report(result1)
result2 = do_some_different_stuff()
report(result2)
result3 = do_even_more_stuff()
report(result3)
return result3

This does what I want.  When I do not specify a report function, the process 
simply runs.  Typically, when I do supply a report function, it would print 
something to stdout, or draw an update through a GUI.

But this approach seems a tad cumbersome and unPythonic to me, particularly the 
part where I define the function _pass() which accepts an arbitrary argument 
list, and does nothing but... pass.


Seems fine to me (good use of the null object pattern), although I
might define _pass() to instead take exactly 1 argument, since that's
all you ever call report() with in your example.


This has led me to ask the question, what exactly IS pass?  I played with the 
interpreter a bit.

IDLE 2.6.6   No Subprocess 

pass
pass()

SyntaxError: invalid syntax

type(pass)

SyntaxError: invalid syntax

So, pass does not appear to be a function, nor even an object.  Is it nothing 
more than a key word?


It is a keyword that can appear in a position where a statement is 
required by the grammar but there is nothing to do.  For example if .. 
then .. else .. where nothing happens in the else condition is effectively:


  if :

  else:
pass

Bourne shell has a similar construct with the colon statement :

Another python example is where you need to catch an exception (or all 
exceptions but don't actually care about what they are)


  try:
 
  except:
 pass


Correct:
http://docs.python.org/reference/simple_stmts.html#pass
http://docs.python.org/reference/lexical_analysis.html#keywords

Cheers,
Chris



--
Dominic Binks: dbi...@codeaurora.org
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum
--
http://mail.python.org/mailman/listinfo/python-list


Re: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7

2011-11-17 Thread alex23
On Nov 18, 2:55 am, "W. eWatson"  wrote:
> Comments?

Are you using the vanilla installer or ActiveState's ActivePython? I
find the latter integrates better with Windows.

Also, out of curiousity, 32 or 64 bit Windows?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to insert my own module in front of site eggs?

2011-11-17 Thread alex23
On Nov 18, 11:36 am, Roy Smith  wrote:
> What if the first import of a module is happening inside some code you
> don't have access to?

No import will happen until you import something. As long as you
change sys.path before you do, all subsequent imports will use that
path.

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


Re: What exactly is "pass"? What should it be?

2011-11-17 Thread Ben Finney
John Ladasky  writes:

> So, pass does not appear to be a function, nor even an object. Is it
> nothing more than a key word?

Yes. Unlike some languages where the program is a collection of
expressions, a Python program is a series of statements which themselves
may or may not be expressions.

http://docs.python.org/reference/lexical_analysis.html>

-- 
 \  “I tell you the truth: some standing here will not taste death |
  `\before they see the Son of Man coming in his kingdom.” —Jesus, |
_o__) c. 30 CE, as quoted in Matthew 16:28 |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7

2011-11-17 Thread Dave Angel

On 11/17/2011 03:31 PM, W. eWatson wrote:

On 11/17/2011 9:39 AM, John Gordon wrote:



Can you add IDLE manually to the associated applications list?

Tried that by sending it directly to idle.pyw, but then trying to get 
there through the Edit with menu caused a "invalid Win32 app."


You've been told repeatedly that building an association to idle.pyw is 
useless.  It must be to something Windows understands, such as .exe, or 
.bat (or several other extensions, as I said in an earlier message)   So 
why waste our time telling us yet again that it doesn't work?




--

DaveA

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


Re: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7

2011-11-17 Thread W. eWatson

On 11/17/2011 7:59 PM, Dave Angel wrote:

On 11/17/2011 03:31 PM, W. eWatson wrote:

On 11/17/2011 9:39 AM, John Gordon wrote:



Can you add IDLE manually to the associated applications list?


Tried that by sending it directly to idle.pyw, but then trying to get
there through the Edit with menu caused a "invalid Win32 app."


You've been told repeatedly that building an association to idle.pyw is
useless. It must be to something Windows understands, such as .exe, or
.bat (or several other extensions, as I said in an earlier message) So
why waste our time telling us yet again that it doesn't work?



Because some  people think that's a solution, and ask. It's not. It 
leads to an error message.

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


Re: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7

2011-11-17 Thread W. eWatson

On 11/17/2011 4:24 PM, Steven D'Aprano wrote:

On Thu, 17 Nov 2011 16:03:14 -0800, W. eWatson wrote:


I have not found any successful way to get to IDLE. It's on on the
right-click of a py menu, and, if I go the ...lib/idle.pyw, it fails
with a "invalid Win32 app" msg.


If you associate .pyw files with pythonw.exe, and then open idle.pyw,
does it work?

Failing that, go to your laptop where the associations are right, and see
what they are, then duplicate the settings on your Windows 7 machine.

Sounds like a good idea except I've not used associations in so long 
under XP, I have no idea where to start. Control Panel. My Computer Tools?


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


Re: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7

2011-11-17 Thread W. eWatson

On 11/17/2011 7:04 PM, alex23 wrote:

On Nov 18, 2:55 am, "W. eWatson"  wrote:

Comments?


Are you using the vanilla installer or ActiveState's ActivePython? I
find the latter integrates better with Windows.

Also, out of curiousity, 32 or 64 bit Windows?

64-bit and plain old python msi installer.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Monitoring/inventory client-server app

2011-11-17 Thread snorble
On Nov 17, 4:31 pm, Irmen de Jong  wrote:
> On 17-11-2011 5:17, snorble wrote:
>
>
>
>
>
>
>
>
>
> > I'm writing a tool for monitoring the workstations and servers in our
> > office. I plan to have a server and a client service that runs on each
> > workstation and reports back to the server (heartbeat, disk free
> > space, etc).
>
> > So far I am considering XMLRPC, or a client service that just
> > downloads a Python file and runs it.
>
> > With XMLRPC I don't know how to easily add features without having to
> > update every client. Also while playing with XMLRPC I learned that
> > when you run a registered function, it runs it on the server. I was
> > hoping it would run on the client, so that when I get the machine's
> > computer name (or disk space, etc) it will return the client's info.
> > It seems with XMLRPC I would have to hard code the functionality into
> > the client (i.e. client gets it's computer name, then calls the XMLRPC
> > function to pass it to the server)? I was hoping it would work more
> > like, "pass some code to the client to be run on the client, and
> > report it to the server". Almost XMLRPC in the reverse direction.
>
> > With the download-and-run approach, it seems trivially easy to add new
> > functionality to the clients. Just save the updated Python file to the
> > server, and clients download it and run it.
>
> > Are there any standard approaches to problems like this that can be
> > recommended? Thank you.
>
> The security implications are HUGE when you are thinking about
> transferring and executing arbitrary code over the network. Avoid this
> if at all possible. But if you can be 100% sure it's only trusted stuff,
> things are not so grim.
>
> Have a look at Pyro, or even Pyro Flame:
>
> http://packages.python.org/Pyro4/http://packages.python.org/Pyro4/flame.html
>
> Flame allows for very easy remote module execution and a limited way of
> transferring code to the 'other side'.
>
> Also what is wrong with running an XMLrpc server, or Pyro daemon, on
> your client machines? This way your central computer can call registered
> methods (or remote objects in case of Pyro) on the client and execute
> code there (that reports all sorts of stuff you want to know). Or have
> each client call into a central server, where it reports that stuff
> itself. Many ways to skin a cat.
>
> Regards,
> Irmen de Jong

I'm thinking maybe the client service will have a small number of
generic features, such as reading WMI and SNMP values. That way the
server still dictates the work to be done (i.e. XMLRPC returns which
WMI/SNMP values to query), and the client remains relatively focused
and straightforward.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Monitoring/inventory client-server app

2011-11-17 Thread Alec Taylor
Maybe take a look outside python:

- Puppet

On Fri, Nov 18, 2011 at 3:49 PM, snorble  wrote:
> On Nov 17, 4:31 pm, Irmen de Jong  wrote:
>> On 17-11-2011 5:17, snorble wrote:
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> > I'm writing a tool for monitoring the workstations and servers in our
>> > office. I plan to have a server and a client service that runs on each
>> > workstation and reports back to the server (heartbeat, disk free
>> > space, etc).
>>
>> > So far I am considering XMLRPC, or a client service that just
>> > downloads a Python file and runs it.
>>
>> > With XMLRPC I don't know how to easily add features without having to
>> > update every client. Also while playing with XMLRPC I learned that
>> > when you run a registered function, it runs it on the server. I was
>> > hoping it would run on the client, so that when I get the machine's
>> > computer name (or disk space, etc) it will return the client's info.
>> > It seems with XMLRPC I would have to hard code the functionality into
>> > the client (i.e. client gets it's computer name, then calls the XMLRPC
>> > function to pass it to the server)? I was hoping it would work more
>> > like, "pass some code to the client to be run on the client, and
>> > report it to the server". Almost XMLRPC in the reverse direction.
>>
>> > With the download-and-run approach, it seems trivially easy to add new
>> > functionality to the clients. Just save the updated Python file to the
>> > server, and clients download it and run it.
>>
>> > Are there any standard approaches to problems like this that can be
>> > recommended? Thank you.
>>
>> The security implications are HUGE when you are thinking about
>> transferring and executing arbitrary code over the network. Avoid this
>> if at all possible. But if you can be 100% sure it's only trusted stuff,
>> things are not so grim.
>>
>> Have a look at Pyro, or even Pyro Flame:
>>
>> http://packages.python.org/Pyro4/http://packages.python.org/Pyro4/flame.html
>>
>> Flame allows for very easy remote module execution and a limited way of
>> transferring code to the 'other side'.
>>
>> Also what is wrong with running an XMLrpc server, or Pyro daemon, on
>> your client machines? This way your central computer can call registered
>> methods (or remote objects in case of Pyro) on the client and execute
>> code there (that reports all sorts of stuff you want to know). Or have
>> each client call into a central server, where it reports that stuff
>> itself. Many ways to skin a cat.
>>
>> Regards,
>> Irmen de Jong
>
> I'm thinking maybe the client service will have a small number of
> generic features, such as reading WMI and SNMP values. That way the
> server still dictates the work to be done (i.e. XMLRPC returns which
> WMI/SNMP values to query), and the client remains relatively focused
> and straightforward.
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What exactly is "pass"? What should it be?

2011-11-17 Thread John Ladasky
On Thursday, November 17, 2011 6:45:58 PM UTC-8, Chris Rebert wrote:

> Seems fine to me (good use of the null object pattern), although I
> might define _pass() to instead take exactly 1 argument, since that's
> all you ever call report() with in your example.

Oops, I over-simplified the calls to my report() function.  The truth is that 
report() can accept a variable argument list too.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What exactly is "pass"? What should it be?

2011-11-17 Thread John Ladasky
On Thursday, November 17, 2011 8:34:22 PM UTC-8, Dennis Lee Bieber wrote:
> On Thu, 17 Nov 2011 18:18:11 -0800 (PST), John Ladasky
>  declaimed the following in
> gmane.comp.python.general:
> > def _pass(*args):
> > pass
> >
>   This is the equivalent of
> 
> def _pass(*args):
>   return None
> 
> (functions with no explicit return statement implicitly return None)

OK, that works for me, and now I understand.

One of my questions was: would there be any merit to having the Python "pass" 
token itself defined exactly as _pass() is defined above?

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


Re: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7

2011-11-17 Thread Benjamin Kaplan
On Thu, Nov 17, 2011 at 11:21 PM, W. eWatson  wrote:
>
> On 11/17/2011 7:59 PM, Dave Angel wrote:
>>
>> On 11/17/2011 03:31 PM, W. eWatson wrote:
>>>
>>> On 11/17/2011 9:39 AM, John Gordon wrote:
>>> 

 Can you add IDLE manually to the associated applications list?

>>> Tried that by sending it directly to idle.pyw, but then trying to get
>>> there through the Edit with menu caused a "invalid Win32 app."
>>
>> You've been told repeatedly that building an association to idle.pyw is
>> useless. It must be to something Windows understands, such as .exe, or
>> .bat (or several other extensions, as I said in an earlier message) So
>> why waste our time telling us yet again that it doesn't work?
>>
>>
>>
> Because some  people think that's a solution, and ask. It's not. It leads to 
> an error message.


Checking my Python install, there should be an idle.bat file in there
too. Have you tried that?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What exactly is "pass"? What should it be?

2011-11-17 Thread Chris Angelico
On Fri, Nov 18, 2011 at 4:07 PM, John Ladasky  wrote:
> One of my questions was: would there be any merit to having the Python "pass" 
> token itself defined exactly as _pass() is defined above?

No, there wouldn't. The Python 'pass' statement is a special statement
that indicates a lack of anything to execute; a dummy function call
isn't this. What I would kinda like to see, though, is function
versions of many things. Your basic operators exist in the 'operator'
module, but the syntax is rather clunky; for comparison, Pike has
beautifully simple (if a little cryptic) syntax: back-tick followed by
the operator itself, very similar to the way C++ does operator
overloading.

In Python 2, back-tick has a special meaning. In Python 3, that
meaning is removed. Is the character now available for this
"function-version" syntax?

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


Re: What exactly is "pass"? What should it be?

2011-11-17 Thread Chris Rebert
On Thu, Nov 17, 2011 at 9:34 PM, Chris Angelico  wrote:
> On Fri, Nov 18, 2011 at 4:07 PM, John Ladasky  wrote:
>> One of my questions was: would there be any merit to having the Python 
>> "pass" token itself defined exactly as _pass() is defined above?
>
> No, there wouldn't. The Python 'pass' statement is a special statement
> that indicates a lack of anything to execute; a dummy function call
> isn't this. What I would kinda like to see, though, is function
> versions of many things. Your basic operators exist in the 'operator'
> module, but the syntax is rather clunky; for comparison, Pike has
> beautifully simple (if a little cryptic) syntax: back-tick followed by
> the operator itself, very similar to the way C++ does operator
> overloading.
>
> In Python 2, back-tick has a special meaning. In Python 3, that
> meaning is removed. Is the character now available for this
> "function-version" syntax?

Negative. I know this from personal experience.

Things that will Not Change in Python 3000
(http://www.python.org/dev/peps/pep-3099/ ):
"No more backticks."

Cheers,
Chris R.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What exactly is "pass"? What should it be?

2011-11-17 Thread alex23
On Nov 18, 12:59 pm, Chris Angelico  wrote:
> If you call your dummy function something else, it may help
> readability/self-documentation too.

Or replace the pass with a docstring for the same effect:

  def silent(*args):
"""Null Object to repress reporting"""

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


Re: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7

2011-11-17 Thread alex23
On Nov 18, 2:21 pm, "W. eWatson"  wrote:
> Because some  people think that's a solution, and ask. It's not. It
> leads to an error message.

No, people are saying "manually add IDLE _the correct way that Windows
can recognise_", not recommending you stuff random .pyw files into the
context menu and hope they work.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What exactly is "pass"? What should it be?

2011-11-17 Thread Steven D'Aprano
On Thu, 17 Nov 2011 21:07:23 -0800, John Ladasky wrote:

> One of my questions was: would there be any merit to having the Python
> "pass" token itself defined exactly as _pass() is defined above?

No.

The pass statement compiles to nothing at all. Your _pass() function 
compiles to a function object, which needs to be looked up at run time, 
then called, all of which takes time and memory.

To satisfy the compiler, but do nothing, the pass statement should stay a 
statement. When you need a "do nothing" function, either define one (two 
lines) in your application, or use a lambda in place (lambda *args: 
None). Either way, it is too trivial to be a built-in.

By the way, to answer your earlier question "what is pass?", you could do 
this in the interactive interpreter:

help("pass")




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


Re: How to insert my own module in front of site eggs?

2011-11-17 Thread Paul Rudin
Roy Smith  writes:

> In article <874ny2fzn6@no-fixed-abode.cable.virginmedia.net>,
>  Paul Rudin  wrote:
>
>> 
>> Maybe I'm missing something - but if I want to do this I just mess about
>> with sys.path at the top of my python script/program. Always seems to
>> work... is there a situation in which it doesn't?
>
> What if the first import of a module is happening inside some code you 
> don't have access to?

If you change sys.path first - before you do any imports - then any
other imports will surely come from the first thing on sys.path (unless
something else you import also changes sys.path)?



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


Re: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7

2011-11-17 Thread Terry Reedy

On 11/17/2011 7:03 PM, W. eWatson wrote:


I have not found any successful way to get to IDLE.


Use the start menu to start IDLE once. Then pin it to your taskbar.
If you do not have STart/ all programs / Python / IDLE, then your 
installation is bad.


As for the right click problem, you probably have something screwy in 
the registry. The python installer (or uninstaller) will not fix it (my 
experience on my old xp machine). You will have to do so manually.


--
Terry Jan Reedy

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


Passing DLL handle as an argument (in Windows)

2011-11-17 Thread Pekka Kytölä
Is it possible to pass my own dll's (already loaded) handle as an
argument to load/attach to the very same instance of dll? Thing is
that I've done plugin (dll) to a host app and the SDK's function
pointers are assigned once the dll is loaded in the host process. I'd
like to fire up python code with ShellExecuteEx from my plugin dll and
expose (wrap) these SDK funcs to that script. If I just load the dll
in python it will be different instance and the SDK function pointers
are all NULL. I tried passing the dll handle as lpParameter but in
vain.

Is this ShellExecute + dll handle passing even possible or do I need
to take a totally different route? What route that would be? Doesn't
have to be portable, just so it works in Windows environment.

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