Re: Python Boolean Logic

2017-09-22 Thread steve . ferg . bitbucket
You have a lot of assignment statements, but nothing that produces output.  Try 
adding statements like this at appropriate places...

print ("bool_one = ", bool_one)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to increment date by week?

2013-06-04 Thread steve . ferg . bitbucket
pyfdate -- http://www.ferg.org/pyfdate/

from pyfdate import Time 
w = Time(2013,1,2) # start with January 2, 2013, just for example

# print the ISO weeknumber and date for 52 weeks
# date looks like this: October 31, 2005
for i in range(52):
w = w.plus(weeks=1)
print (w.weeknumber, w.d)


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


Re: accessing an OLE Automation (IDispatch) server from python which requires the use of out params

2012-12-11 Thread bitbucket
On Tuesday, December 11, 2012 3:42:35 AM UTC-5, Paul Kölle wrote:
 Before switching technologies I'd check if this solves your problem 
 
 http://geekswithblogs.net/Lance/archive/2009/01/14/pass-by-reference-parameters-in-powershell.aspx
  
 
 TL;DR IMHO out parameters are basically pointers (pass by reference) 
 
 and need to be passed like GetSettingValue(name, [ref]$value)...
 

Thanks for the suggestion.  I believe the [ref] syntax was one of the things I 
tried, but it didn't work in the context of OLE Automation (IDispatch) calls.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: accessing an OLE Automation (IDispatch) server from python which requires the use of out params

2012-12-11 Thread bitbucket
On Monday, December 10, 2012 8:16:43 PM UTC-5, Mark Hammond wrote:
 out params are best supported if the object supplied a typelib - then 
 Python knows the params are out and does the right thing automagically. 
   If out params are detected, the result of the function will be a tuple 
 of (real_result, out_param1, ...)
 
 Even if no typelib is supported, you can access them with a little pain 
 via the win32com.client.Dispatch() object.  You might like to follow up 
 to the python-wi...@python.org mailing list where many people will be 
 able to help.
 
 HTH,
 
 Mark

Mark, thanks for the reply.  In this case, I have a type library and attempted 
to use MakePy but it doesn't seem to be working as expected.

I was reading through CH12 of your Python Programming on Win32 book 
(http://oreilly.com/catalog/pythonwin32/chapter/ch12.html).  I was hopeful 
given your description of MakePy that I could get this to work.  It appears 
that you're saying MakePy will convert byref args in a function over to 
return values.

For example, the IDL in the server includes the following 3 functions.

[id(1)] void ShowMessage(BSTR msg);
[id(2)] void GetSettingValue(BSTR settingName, BSTR* 
settingValue);
[id(3)] void SetSettingValue(BSTR settingName, BSTR 
settingValue);

The thorny one is the GetSettingValue since it takes the out param.  When I run 
MakePy, it generates the below.

def ShowMessage(self, msg=defaultNamedNotOptArg):
return self._oleobj_.InvokeTypes(1, LCID, 1, (24, 0), ((8, 
0),),msg
)

def GetSettingValue(self, settingName=defaultNamedNotOptArg, 
settingValue=defaultNamedNotOptArg):
return self._oleobj_.InvokeTypes(2, LCID, 1, (24, 0), ((8, 0), 
(16392, 0)),settingName
, settingValue)

def SetSettingValue(self, settingName=defaultNamedNotOptArg, 
settingValue=defaultNamedNotOptArg):
return self._oleobj_.InvokeTypes(3, LCID, 1, (24, 0), ((8, 0), 
(8, 0)),settingName
, settingValue)

I noticed that the argument type is different for the out param (16392 instead 
of 8).  However, it doesn't appear to me that its generating return values 
instead of args (though I'm not very experienced in python).

I tried invoking these in python.  The ShowMessage and SetSettingValue work 
great.  I can't get the GetSettingValue to work though.  Perhaps there's a 
different syntax I need when using the MakePy generated code?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: accessing an OLE Automation (IDispatch) server from python which requires the use of out params

2012-12-11 Thread bitbucket
On Tuesday, December 11, 2012 10:48:53 AM UTC-5, bitbucket wrote:

 I noticed that the argument type is different for the out param (16392 
 instead of 8).  However, it doesn't appear to me that its generating return 
 values instead of args (though I'm not very experienced in python).


I see that the value 16392 is really VT_BYREF | VT_BSTR and 8 is just VT_BSTR.  
So in that case it appears MakePy is taking noticed at least of the VT_BYREF 
and including that in the generated code (since it uses 16392).

So maybe there's a special way I need to call the generated wrapper?
-- 
http://mail.python.org/mailman/listinfo/python-list


accessing an OLE Automation (IDispatch) server from python which requires the use of out params

2012-12-10 Thread bitbucket
I have an existing Windows application which provides an OLE Automation 
(IDispatch) interface.  I'm not able to change that interface.  I'd like to 
call it from a scripting language.  I figure this would provide a nice quick 
way to invoke on the app.

I initially tried this with Windows Powershell but ran into the following 
problem.  I was able to create the object and invoke simple methods on it.  
However the interface for this app has methods which take out params.  i.e. you 
pass in a reference to a variable and the server fills in the value.  I 
couldn't get that to work.  I finally gave up and decided it was just a 
limitation of Powershell, not being able to work with those out params.

My next thought was to do it in python.  I've been reading up on python and 
I've found a decent amount of into out there on doing OLE and I'm optimistic.  
But, I thought that I'd ask the question before digging too much farther into 
it...

When calling an OLE Automation (IDispatch) server from python can I make use of 
out params defined by the interface?

To get more specific, here's an example from the server's IDL for one of its 
methods.

[id(15), helpstring(method GetSettingValue)] VARIANT_BOOL 
GetSettingValue(BSTR settingName, BSTR* settingValue);

As you can see, you have to pass in an out param for settingValue.  The server 
fills this in for you.  And this is what I couldn't get to work in Powershell.

Anyone know whether or not OLE from python will allow passing in out params?  
Do you think this will work?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: accessing an OLE Automation (IDispatch) server from python which requires the use of out params

2012-12-10 Thread bitbucket
On Monday, December 10, 2012 3:58:33 PM UTC-5, Terry Reedy wrote:
 I believe the easiest way to do that is to install the pywin extensions
 
 http://sourceforge.net/projects/pywin32/?source=directory
 
 I assume it can handle out params.

That definitely looks like a good starting point.  Just hoping someone knows 
whether or not it'll support the out params before I spend too much time 
digging into it.
-- 
http://mail.python.org/mailman/listinfo/python-list


problem with pydoc under python 2.6.1

2009-03-05 Thread steve . ferg . bitbucket
Has anybody encountered problems running pydoc with version 2.6.1?
I'm getting an error message that pydoc cannot import namedtuple
(details below).
(I'm running under 64-bit Windows Vista, although that probably is not
important.)

Here's my batch file, pydoc_test.bat:
 =
 @echo on
 set pyver=python25
 python c:\%pyver%\Lib\pydoc.py -w easygui

 set pyver=python26
 python c:\%pyver%\Lib\pydoc.py -w easygui
 =

Here's what I get:
 =
 c:\pydev\easygui\v086pydoc_test.bat

 c:\pydev\easygui\v086set pyver=python25

 c:\pydev\easygui\v086python c:\python25\Lib\pydoc.py -w easygui
 wrote easygui.html

 c:\pydev\easygui\v086set pyver=python26

 c:\pydev\easygui\v086python c:\python26\Lib\pydoc.py -w easygui
 Traceback (most recent call last):
   File c:\python26\Lib\pydoc.py, line 55, in module
 import sys, imp, os, re, types, inspect, __builtin__, pkgutil
   File c:\python26\Lib\inspect.py, line 42, in module
 from collections import namedtuple
 ImportError: cannot import name namedtuple
 

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


Re: problem with pydoc under python 2.6.1

2009-03-05 Thread steve . ferg . bitbucket
Problem solved

Yinon's messages prompted me to take another look at my own code
(below).  I realized that in the batch file I am looking for pydoc.py
in different locations for Python25 and Python26, but I am executing
python.exe without changing the path.  Which means that I am executing
the same version of Python in both cases.

 =
 @echo on
 set pyver=python25
 python c:\%pyver%\Lib\pydoc.py -w easygui

 set pyver=python26
 python c:\%pyver%\Lib\pydoc.py -w easygui
 =

The path was pointing to Python25, so when I ran against the 2.5
version of Pydoc it worked fine; when I ran against the 2.6 version of
Pydoc, I got an error.

I modified my batch file to also reset the PATH after pyver was set,
and then Pydoc worked fine in both cases.

Maybe somebody out there will find this an instructive mistake.  My
thanks to Yinon; certainly for me his mistake was an instructive one.
--
http://mail.python.org/mailman/listinfo/python-list


Looking for tips on running Python version 2.6 and 3.0 together on same *WINDOWS* machine

2009-02-24 Thread steve . ferg . bitbucket
I'm looking for tips on installing and running Python version 2.6 and
version 3.0 together on same Windows machine.

I'd like to install both 2.6 and 3.0 together on the same Windows
(Vista) machine, so I can test programs under both versions.

Is it possible to install both versions on the same Windows machine in
such a way that they are both asily available and don't interfere with
one another?  I'm concerned, for example, that if I install both, the
second installation will over-write some Python entry in the registry.

I'd like something fairly simple -- I will be sharing this information
with others in my workgroup for whom  virtualenv is not an option.

I googled around, but couldn't find anything that seemed to address
this specific question.  If anybody knows of a URL with this
information (a 2 to 3 Conversion FAQs?) that would be great.

Any help would be greatly appreciated.

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