Re: The dimensions of a tuple

2008-01-25 Thread bg_ie
On 25 Jan, 12:03, John Machin <[EMAIL PROTECTED]> wrote:
> On Jan 25, 9:26 pm, [EMAIL PROTECTED] wrote:
>
> > Hi,
>
> > I wish to pass an argument to a function which will inset rows in a
> > db. I wish to have the follow possibilities -
>
> > ("one","two")
> > (("one","two"),("three","four"))
>
> > The first possibility would mean that one row is added with "one and
> > "two" being its column values. The second possibility means that two
> > rows are added.
>
> > So to do this I need to establish the dimension of the duple. Is it a
> > one dimentional or two dimentional. How do I do this?
>
> isinstance(arg[0], tuple)
>
> ... but I wouldn't do it that way. I'd use a list of tuples, not a
> tuple of tuples, to allow for ease of building the sequence with
> list.append, and two functions:
>
> insert_one(("one", "two"))
> insert_many([("one", "two")])
> insert_many([("one", "two"), ("three", "four")])
>
> Which of those 2 functions calls the other depends on which you'd use
> more often.
>
> HTH,
> John

Thanks for the tip regarding the list of tuples!
-- 
http://mail.python.org/mailman/listinfo/python-list


The dimensions of a tuple

2008-01-25 Thread bg_ie
Hi,

I wish to pass an argument to a function which will inset rows in a
db. I wish to have the follow possibilities -

("one","two")
(("one","two"),("three","four"))

The first possibility would mean that one row is added with "one and
"two" being its column values. The second possibility means that two
rows are added.

So to do this I need to establish the dimension of the duple. Is it a
one dimentional or two dimentional. How do I do this?

Thanks,

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


Re: Connecting to Sql Server from Python

2008-01-24 Thread bg_ie
On 24 Jan, 17:16, Mike Driscoll <[EMAIL PROTECTED]> wrote:
> On Jan 24, 9:44 am, [EMAIL PROTECTED] wrote:
>
>
>
>
>
> > Hi,
>
> > I have an sql server from which I'd like to read and write to. The
> > connection string is as follows -
>
> > "Data Source=localhost\SQLExpress;Initial Catalog=Test;Integrated
> > Security=True;Pooling=False"
>
> > Other properties as they appear in Visual Studio 2005 include -
>
> > Data Provider: .NET Framework Data Provider for SQL Server
> > State: Open
> > Type: Microsoft SQL Server
>
> > So my question is, how might I connect to my Test Catalog and update
> > data within its tables via perl,
>
> > Thanks,
>
> > Barry.
>
> If you want to do this in Perl, then why are you asking on a Python
> list? In Python, there are many ways to accomplish this task. Take a
> look at SQLAlchemy, SQLObject, pymssql or the adodb package.
>
> http://pymssql.sourceforge.net/www.sqlalchemy.orghttp://www.sqlobject.org/http://phplens.com/lens/adodb/adodb-py-docs.htm
>
> Mike- Dölj citerad text -
>
> - Visa citerad text -

Woops, I ment Python...
-- 
http://mail.python.org/mailman/listinfo/python-list


Connecting to Sql Server from Python

2008-01-24 Thread bg_ie
Hi,

I have an sql server from which I'd like to read and write to. The
connection string is as follows -

"Data Source=localhost\SQLExpress;Initial Catalog=Test;Integrated
Security=True;Pooling=False"

Other properties as they appear in Visual Studio 2005 include -

Data Provider: .NET Framework Data Provider for SQL Server
State: Open
Type: Microsoft SQL Server

So my question is, how might I connect to my Test Catalog and update
data within its tables via perl,

Thanks,

Barry.

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


Launching a wx GUI from within our python framework

2008-01-07 Thread bg_ie
Hi,

At my work we have a framework writen in python which allows us to
test our equipment. This framework is quite large and uses a Singelton
called frameworkExec which we pass around between objects in order to
share functionailty. For example, frameWorkExec stores an instance of
the BatteryManagement module which I use to set the voltage during
certain tests.

I've just writen a gui using wx which I wish to use to calibrate our
voltage supply. I launch this app at the moment within python win as
follows -

app = VoltageCalibrationApp(0)
app.MainLoop()

class VoltageCalibrationApp(wx.App):
 def OnInit(self):

  voltageCalibration = {}
  voltageCalibration[0.0] = 1.2
  voltageCalibration[9.0] = 10.1
  voltageCalibration[22.0] = 22.7
  voltageCalibration[24.0] = 24.8
  voltageCalibration[30.0] = 31.1
  voltageCalibration[35.0] = 36.9

  frame = VoltageCalibrationFrame(None, -1, 'Voltage Calibration',
voltageCalibration)
  frame.Show(True)
  frame.Centre()
  return True

I hope that by adding the code above into the framework, I will be
able to call this app as part of the framework before the execution of
certain tests, as follows -

app = VoltageCalibrationApp(0)
app.MainLoop()
test1.run()
test2.run()

As you can see in the VoltageCalibrationApp class, I am currently
hardcoding voltageCalibration. Rather than doing this, I wish to store
them in our singleton which is available at the scope at which I
create my VoltageCalibrationApp instance. But I can't figure our a way
of referencing my singleton with the OnInit function. Normally, you
would pass the reference via __init__

How can I do this?

Thanks,

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


An Object's Type

2007-12-05 Thread bg_ie
Hi,

Is it possible to find out if an object is of a certain type or of a
type derived from this type?

Thanks,

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


Enum class with ToString functionality

2007-09-10 Thread bg_ie
Hi,

I have the following class -

class TestOutcomes:
PASSED = 0
FAILED = 1
ABORTED = 2

plus the following code -

testResult = TestOutcomes.PASSED

testResultAsString
if  testResult == TestOutcomes.PASSED:
testResultAsString = "Passed"
elif testResult == TestOutcomes.FAILED :
testResultAsString = "Failed"
else:
testResultAsString = "Aborted"

But it would be much nicer if I had a function to covert to string as
part of the TestOutcomes class. How would I implement this?

Thanks,

Barry

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


Re: Python Path Dictionary

2007-08-22 Thread bg_ie
On 21 Aug, 21:45, "Chris Mellon" <[EMAIL PROTECTED]> wrote:
> On 8/21/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > On 21 Aug, 17:42, Gary Herron <[EMAIL PROTECTED]> wrote:
> > > [EMAIL PROTECTED] wrote:
> > > > Hi,
>
> > > > Do the Python Paths come in the form of a dictionary where I can
> > > > access a particular path my its key in the registry?
>
> > > > For example, in PythonWin Tools>>Edit Python Paths shows the name as
> > > > well of the address of each path
>
> > > > Thanks,
>
> > > > Aine
>
> > > If by "Python Paths" you mean the list of directories searched when
> > > doing an import, then it is a list (not a dictionary and you can access
> > > it as sys.path.
>
> > > Here it is on both my Linux and Windows systems:
>
> > > >>> import sys
> > > >>> sys.path
>
> > > ['', '/usr/lib/portage/pym', '/usr/lib/python25.zip',
> > > '/usr/lib/python2.5', '/usr/lib/python2.5/plat-linux2',
> > > '/usr/lib/python2.5/lib-tk', '/usr/lib/python2.5/lib-dynload',
> > > '/usr/lib/python2.5/site-packages',
> > > '/usr/lib/python2.5/site-packages/Numeric',
> > > '/usr/lib/python2.5/site-packages/PIL',
> > > '/usr/lib/python2.5/site-packages/gtk-2.0']
>
> > > >>> import sys
> > > >>> sys.path
>
> > > ['', 'C:\\WINDOWS\\system32\\python24.zip', 'C:\\cygwin\\home\\Gary',
> > > 'c:\\python24\\DLLs', 'c:\\python24\\lib',
> > > 'c:\\python24\\lib\\plat-win', 'c:\\python24\\lib\\lib-tk',
> > > 'c:\\python24', 'c:\\python24\\lib\\site-packages',
> > > 'c:\\python24\\lib\\site-packages\\Numeric',
> > > 'c:\\python24\\lib\\site-packages\\PIL',
> > > 'c:\\python24\\lib\\site-packages\\gtk-2.0',
> > > 'c:\\python24\\lib\\site-packages\\win32',
> > > 'c:\\python24\\lib\\site-packages\\win32\\lib',
> > > 'c:\\python24\\lib\\site-packages\\Pythonwin']
>
> > Thanks.
>
> > Yeah, that's exactly what I'm talking about, but I don't want the
> > list, I want to access a certain path by name. I'm guessing I'm going
> > to have to write a function to do this that reads the value from the
> > registry.
>
> The elements of the path don't have names - they are a list of
> directories. You are mistaking Pythonwins configuration options (like
> where it searches for modules) for the python path.
>
> Note that the registry entry "PythonPath" (which is not respected by
> Python, but used by Pythonwin to override the default python path) is
> a semi-colon separated list, not a series of keys.- Dölj citerad text -
>
> - Visa citerad text -

Your right with regard to Python Win! Although, it can be both a semi-
colon seperated list and/or a set of keys. On my PC I have a default
key under python paths (with a list of paths), plus a set of keys with
their own individul paths. I can therefore install my python code in
any directory and manipulate these keys to find the modules I need.

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

File handle not being released by close

2007-07-30 Thread bg_ie
Hi,

I'm in the process of writing some code and noticed a strange problem
while doing so. I'm working with PythonWin 210 built for Python 2.5. I
noticed the problem for the last py file processed by this script,
where the concerned tmp file is only actually written to when
PythonWin is closed. In other words, after I run this script, one of
the generated tmp files has a size of 0kB. I then close PythonWin and
it is then written to.

I'm guessing the garbage collector is causing the file to be written,
but shouldn't close do this?

/Barry

import os, time, string

dir = 'c:\\temp1'

def listAllFile(fileNames,dir,files):
  def f1(a,dir=dir): return os.path.join(dir,a)
  files2 = map(f1, files)
  fileNames.extend(files2)

fileNames = []
os.path.walk(dir,listAllFile,fileNames)

for fileName in fileNames:
  fileBeginning = os.path.splitext(fileName)[0]
  fileEnd   = os.path.splitext(fileName)[1]

  if fileEnd == ".py":
print fileName
f=open(fileBeginning+".tmp", 'w')
f.write("Hello")
f.close

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


Re: Dictionary of Dictionaries

2007-03-05 Thread bg_ie
On 5 Mar, 11:45, "Amit Khemka" <[EMAIL PROTECTED]> wrote:
> On 5 Mar 2007 02:22:24 -0800, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > I have the following -
>
> > messagesReceived = dict.fromkeys(("one","two"), {})
>
> This will create a dictionary "messagesReceived", with all the keys
> referring to *same instance* of the (empty) dictionary.
> (   try: messagesReceived = dict( [(k,{}) for k in ('one', 'two') ] )   )
>
>
>
> > messagesReceived['one']['123'] = 1
> > messagesReceived['two']['121'] = 2
> > messagesReceived['two']['124'] = 4
>
> > This gives:
>
> > {'two': {'121': 2, '123': 1, '124': 4}, 'one': {'121':
> > 2, '123': 1, '124': 4}}
>
> And hence the results !
>
> HTH,
>
> --
> 
> Amit Khemka -- onyomo.com
> Home Page:www.cse.iitd.ernet.in/~csd00377
> Endless the world's turn, endless the sun's Spinning, Endless the quest;
> I turn again, back to my own beginning, And here, find rest.

Thanks for your help!

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


Dictionary of Dictionaries

2007-03-05 Thread bg_ie
Hi,

I have the following -

messagesReceived = dict.fromkeys(("one","two"), {})

messagesReceived['one']['123'] = 1
messagesReceived['two']['121'] = 2
messagesReceived['two']['124'] = 4

This gives:

{'two': {'121': 2, '123': 1, '124': 4}, 'one': {'121':
2, '123': 1, '124': 4}}

but I expected -

{'one': {'121': 2, }, 'two': {'123': 1, '124': 4}}

What am I doing wrong?

Thanks,

Barry.

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


Building a dictionary from a tuple of variable length

2007-03-05 Thread bg_ie
Hi,

I have the following tuple -

t = ("one","two")

And I can build a dictionary from it as follows -

d = dict(zip(t,(False,False)))

But what if my tuple was -

t = ("one","two","three")

then I'd have to use -

d = dict(zip(t,(False,False,False)))

Therefore, how do I build the tuple of Falses to reflect the length of
my t tuple?

Thanks for your help,

Barry.

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


Copy a module build to another machine

2007-02-26 Thread bg_ie
Hi,

I have downloaded the source for PyXML-0.8.4, which has no binaries
available for Python 2.5. Therefore I built it myself doing something
like this -

python2.5 setup.py build
python2.5 setup.py install

having installed cygwin (with gcc). Now lets say I'd like to install
PyXML-0.8.4 on a number of other machines running the same os, what
files would I need to copy, and to where, in order to install PyXML
with just the line -

python2.5 setup.py install

In other words, I don't want to have to install cygwin on all these
machines and build for each machine. Instead I want to create a simple
install.

Thanks for your help,

Barry.

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


Finding non ascii characters in a set of files

2007-02-23 Thread bg_ie
Hi,

I'm updating my program to Python 2.5, but I keep running into
encoding problems. I have no ecodings defined at the start of any of
my scripts. What I'd like to do is scan a directory and list all the
files in it that contain a non ascii character. How would I go about
doing this?

Thanks,

Barry.

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


Finding a tuple in a tuple

2007-02-22 Thread bg_ie
Hi,

Lists say I have the following tuple -

t1 = ("ONE","THREE","SIX")

and then the following tuples -

t2 = ("ONE","TWO","THREE")

t3 = ("TWO","FOUR","FIVE","SIX")

t4 = ("TWO",)

t5 = ("TWO","FIVE")

What I want to do is return true if any member of tuple t1 is found in
the remaining tuples.

Therefore -

2) ("ONE","TWO","THREE") : TRUE

3) ("TWO","FOUR","FIVE","SIX") : TRUE

4) ("TWO",) FALSE

5) ("TWO","FIVE")

How do I do this?

Cheers,

Barry.

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


Building Python Pagage for Newer Python Version

2007-02-19 Thread bg_ie
Hi,

I have just downloaded the source for PyXML-0.8.4, which I would like
to build for Python 2.5. How exactly do I go about doing this?

Thanks for your help,

Barry.

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


Getting a class name from within main

2007-02-07 Thread bg_ie
Hi,

Lets say I have the following class -

class MyClass:
def __init__(self):
print (__name__.split("."))[-1]

if __name__ == '__main__':
MyClassName = "MyClass"

I can print the name of the class from within the class scope as seen
above in the init, but is there any way of printing it from within the
main without creating an object of the MyClass type. I need to assign
the name of the class within my script, to a variable in main.

Thanks,

Barry.

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


COM makepy util finds multiple versions of my COM object

2007-02-02 Thread bg_ie
Hi,

I have a problem where an earlier version of my Com object is being
used by makepy for early binding. In makepy I see -

MyCom (1.0)
MyCom (1.0)
MyCom (2.0)

I created version 2 of my Com object hoping that this would solve the
problem but makepy is still using an earlier version. I can solve the
problem by editing the registry, but this problem now exists on a
number of computers...

Any ideas as to how I might solve this one?

I'm using build 210 of pythonwin.

Thanks for your help,

Barry.

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


Re: Why do I have to call del explicitly for com objects?

2007-01-19 Thread bg_ie

Gabriel Genellina skrev:

> <[EMAIL PROTECTED]> escribió en el mensaje
> news:[EMAIL PROTECTED]
>
> > I'm creating objects in my python script belonging to a COM object
> > which I dispatch using win32com.client.DispatchEx. Hence, dllhost.dll
> > is the concerned process. The problem is that the objects destructor
> > within the com object is not called if the object lives past a certain
> > number of seconds. For example, this function will not call the
> > destructor concerned with obj unless the sleep is commented out.
> >
> > def fnction:
> >  obj = comobj.createACertainObject()
> >  obj.doStuff()
> >  sleep(10)
> >  obj.doMoreStuff()
> >  #del obj
>
> I don't understand the case.
> del does not invoke a destructor, just decrements the object's reference
> count. When the rc reaches zero, the object is a candidate for GC. That is,
> "some time in the future", the GC would destroy it (unless it's part of a
> circular reference chain...)
> So, *inside* your function, there is a reference held by the local variable
> obj. It is decremented automatically when you exit the function (and obj
> gets out of scope) or if you explicitely use del.
> You can use sys.getrefcount() to see how many references an object has. (The
> output is +1 because getrefcount() has a temporary reference to the object
> too).
>
> py> x="Hello World"
> py> sys.getrefcount(x)
> 2
>
> See how many references your obj have. After calling doStuff or doMoreStuff,
> you can have more references if those functions store `self` somewhere, or
> pass it to another method that does so.
>
> > It seems to me that the GC forgets about obj after a certain amount of
> > time. I can force the destructor to be called using del obj at the end
> > of my function, but why do I have to call this explicitly?
> If del obj works at the end, exiting the function should work too. Both ways
> you decrement the rc. There is something *more* in here.
>
> --
> Gabriel Genellina

Thanks for the reply. I tried using a longer sleep before the del but
the destructor wasn't called this time. I guess del is not the issue
here what so ever. As far as I can see, the garbage collector forgets
about my object after a certain period of time. The fix i'm using now
is to use Destruct functions in my CoM object which I call explicitly.

def fnction:
  obj = comobj.createACertainObject()
  obj.doStuff()
  sleep(10)
  obj.doMoreStuff()
  obj.Destruct()

I'd still love to know what the issue is here.

Thanks,

Barry.

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


Why do I have to call del explicitly for com objects?

2007-01-19 Thread bg_ie
Hi,

I'm creating objects in my python script belonging to a COM object
which I dispatch using win32com.client.DispatchEx. Hence, dllhost.dll
is the concerned process. The problem is that the objects destructor
within the com object is not called if the object lives past a certain
number of seconds. For example, this function will not call the
destructor concerned with obj unless the sleep is commented out.

def fnction:
  obj = comobj.createACertainObject()
  obj.doStuff()
  sleep(10)
  obj.doMoreStuff()
  #del obj

It seems to me that the GC forgets about obj after a certain amount of
time. I can force the destructor to be called using del obj at the end
of my function, but why do I have to call this explicitly?

Thanks for your help,

Barry.

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


Establishing if an Object is Defined

2007-01-10 Thread bg_ie
Hi,

The following code works -

one = 1
if one == 1:
  ok = 1
print ok

but this does not, without exception -

one = 2
if one == 1:
  ok = 1
print ok

How do I establish before printing ok if it actually exists so as to
avoid this exception?

Thanks for your help,

Barry.

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


A simple array in Python

2007-01-09 Thread bg_ie
Hi,

I have the following enum -

class State:
Fire = 0
Water = 1
Earth = 2

And I want a variable which holds a value for each of these states,
something like -

myState1[State.Fire] = 10
myState1[State.Earth] = 4

myState2[State.Fire] = 20
myState2[State.Earth] = 24

How do I do this?

Thanks Barry.

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


Re: Python Wrapper for C# Com Object

2007-01-04 Thread bg_ie

Thomas Heller skrev:

> [EMAIL PROTECTED] schrieb:
> > [EMAIL PROTECTED] skrev:
> >
> >> Hi,
> >>
> >> I wish to write a Python wrapper for my C# COM object but am unsure
> >> where to start. I have a dll and a tlb file, and I can use this object
> >> in C via the following code -
> >>
> >> // ConsolApp.cpp : Defines the entry point for the console application.
> >> //
> >> #include "stdafx.h"
> >> #include "windows.h"
> >> #include "stdio.h"
> >> #import "C:\Documents and Settings\X\Mina dokument\Visual Studio
> >> 2005\Projects\X_COMObject\X_COMObject\bin\Debug\X_COMObject.tlb"
> >> using namespace X_COMObject;
> >>
> >> int _tmain(int argc, _TCHAR* argv[])
> >> {
> >>CoInitialize(NULL);
> >>
> >>X_COMObject::XCOM_InterfacePtr p(__uuidof(X_COMObject::XCOM_Class));
> >>XCOM_Interface *X_com_ptr ;
> >>X_com_ptr = p ;
> >>X_com_ptr->SetID(10);
> >>int x = X_com_ptr->GetID();
> >>printf("%d",x);
> >>getchar();
> >>
> >>return 0;
> >> }
> >>
> >> Can anyone offer me some tips as to how to do this in Python?
> >>
> >> Thanks very much for your help,
> >>
> >> Barry.
> >
> > This is what I've done so far, but I know I'm not doing this correctly.
> > Can anyone help me out?
> >
> > #import pythoncom
> > #pythoncom.CoInitialize()
>
> The above is unneeded if you use comtypes as below (and is unneeded
> when using pythoncom, as well).
>
> > from comtypes.client import GetModule, CreateObject
> >
> > module = GetModule("C:\\Documents and Settings\\X\\Mina
> > dokument\\Visual Studio
> > 2005\\Projects\\X_COMObject\\X_COMObject\\bin\\Debug\\X_COMObject.tlb")
> >
> You don't intantiate the interface, you have to instantiate the COM object.
> Something like
>
>   CreateObject("XCOM_Class")
>
> but of course you have to use the correct argument in the call - the progid
> of the COM object.
> Alternatively you can use the CoClass from the typelibrary, look into the
> generated module in the comtypes\gen directory for a class derived from
> comtypes.CoClass.
>
> InternetExplorer, for example, can be started in these ways:
>
> # using the progid:
> ie = CreateObject("InternetExplorer.Application")
>
> # using the clsid:
> ie = CreateObject("{0002DF01---C000-0046}")
>
>
> # using the coclass from the generated module:
> mod = GetModule("shdocvw.dll")
> ie = CreateObject(mod.InternetExplorer)
>
> Thomas

Thanks very much for your help.

I tried running the following code -

import win32com.client
scanObj = win32com.client.Dispatch("X_COMObject")

but im getting the following error -

Traceback (most recent call last):
  File
"C:\Python22\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py",
line 310, in RunScript
exec codeObject in __main__.__dict__
  File "C:\Python25\test.py", line 20, in ?
scanObj = win32com.client.Dispatch("Scania_COMObject")
  File "C:\Python22\Lib\site-packages\win32com\client\__init__.py",
line 95, in Dispatch
dispatch, userName =
dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
  File "C:\Python22\Lib\site-packages\win32com\client\dynamic.py", line
98, in _GetGoodDispatchAndUserName
return (_GetGoodDispatch(IDispatch, clsctx), userName)
  File "C:\Python22\Lib\site-packages\win32com\client\dynamic.py", line
78, in _GetGoodDispatch
IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx,
pythoncom.IID_IDispatch)
com_error: (-2147221005, 'Invalid Class String', None, None)

I ran my C++ code again and it works fine. I also checked COM Browser
and my X_COMObject is present and I'm spelling it right.

Any ideas what the problem migth be?

Thanks again,

Barry.

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


Re: Python Wrapper for C# Com Object

2006-12-29 Thread bg_ie

[EMAIL PROTECTED] skrev:

> [EMAIL PROTECTED] skrev:
>
> > Hi,
> >
> > I wish to write a Python wrapper for my C# COM object but am unsure
> > where to start. I have a dll and a tlb file, and I can use this object
> > in C via the following code -
> >
> > // ConsolApp.cpp : Defines the entry point for the console application.
> > //
> > #include "stdafx.h"
> > #include "windows.h"
> > #include "stdio.h"
> > #import "C:\Documents and Settings\X\Mina dokument\Visual Studio
> > 2005\Projects\X_COMObject\X_COMObject\bin\Debug\X_COMObject.tlb"
> > using namespace X_COMObject;
> >
> > int _tmain(int argc, _TCHAR* argv[])
> > {
> > CoInitialize(NULL);
> >
> > X_COMObject::XCOM_InterfacePtr p(__uuidof(X_COMObject::XCOM_Class));
> > XCOM_Interface *X_com_ptr ;
> > X_com_ptr = p ;
> > X_com_ptr->SetID(10);
> > int x = X_com_ptr->GetID();
> > printf("%d",x);
> > getchar();
> >
> > return 0;
> > }
> >
> > Can anyone offer me some tips as to how to do this in Python?
> >
> > Thanks very much for your help,
> >
> > Barry.
>
> This is what I've done so far, but I know I'm not doing this correctly.
> Can anyone help me out?
>
> #import pythoncom
> #pythoncom.CoInitialize()
>
> from comtypes.client import GetModule, CreateObject
>
> module = GetModule("C:\\Documents and Settings\\X\\Mina
> dokument\\Visual Studio
> 2005\\Projects\\X_COMObject\\X_COMObject\\bin\\Debug\\X_COMObject.tlb")
>
> dir(module)
>
> interface = module.XCOM_Interface()
>
> dir(interface)
>
> interface.SetID()
>
> #pythoncom.CoUnitialize()
>
>
> Traceback (most recent call last):
>   File "C:/Python25/test.py", line 14, in 
> interface.SetID()
> TypeError: Expected a COM this pointer as first argument

Can anyone help me with this?

Thanks,

Barry.

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


Re: Python Wrapper for C# Com Object

2006-12-28 Thread bg_ie

[EMAIL PROTECTED] skrev:

> Hi,
>
> I wish to write a Python wrapper for my C# COM object but am unsure
> where to start. I have a dll and a tlb file, and I can use this object
> in C via the following code -
>
> // ConsolApp.cpp : Defines the entry point for the console application.
> //
> #include "stdafx.h"
> #include "windows.h"
> #include "stdio.h"
> #import "C:\Documents and Settings\X\Mina dokument\Visual Studio
> 2005\Projects\X_COMObject\X_COMObject\bin\Debug\X_COMObject.tlb"
> using namespace X_COMObject;
>
> int _tmain(int argc, _TCHAR* argv[])
> {
>   CoInitialize(NULL);
>
>   X_COMObject::XCOM_InterfacePtr p(__uuidof(X_COMObject::XCOM_Class));
>   XCOM_Interface *X_com_ptr ;
>   X_com_ptr = p ;
>   X_com_ptr->SetID(10);
>   int x = X_com_ptr->GetID();
>   printf("%d",x);
>   getchar();
>
>   return 0;
> }
>
> Can anyone offer me some tips as to how to do this in Python?
>
> Thanks very much for your help,
>
> Barry.

This is what I've done so far, but I know I'm not doing this correctly.
Can anyone help me out?

#import pythoncom
#pythoncom.CoInitialize()

from comtypes.client import GetModule, CreateObject

module = GetModule("C:\\Documents and Settings\\X\\Mina
dokument\\Visual Studio
2005\\Projects\\X_COMObject\\X_COMObject\\bin\\Debug\\X_COMObject.tlb")

dir(module)

interface = module.XCOM_Interface()

dir(interface)

interface.SetID()

#pythoncom.CoUnitialize()


Traceback (most recent call last):
  File "C:/Python25/test.py", line 14, in 
interface.SetID()
TypeError: Expected a COM this pointer as first argument

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


Python Wrapper for C# Com Object

2006-12-28 Thread bg_ie
Hi,

I wish to write a Python wrapper for my C# COM object but am unsure
where to start. I have a dll and a tlb file, and I can use this object
in C via the following code -

// ConsolApp.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "windows.h"
#include "stdio.h"
#import "C:\Documents and Settings\X\Mina dokument\Visual Studio
2005\Projects\X_COMObject\X_COMObject\bin\Debug\X_COMObject.tlb"
using namespace X_COMObject;

int _tmain(int argc, _TCHAR* argv[])
{
CoInitialize(NULL);

X_COMObject::XCOM_InterfacePtr p(__uuidof(X_COMObject::XCOM_Class));
XCOM_Interface *X_com_ptr ;
X_com_ptr = p ;
X_com_ptr->SetID(10);
int x = X_com_ptr->GetID();
printf("%d",x);
getchar();

return 0;
}

Can anyone offer me some tips as to how to do this in Python?

Thanks very much for your help,

Barry.

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


Newbie: Installing packages on windows

2006-12-11 Thread bg_ie
Hi,

I'm reading the python tutorials on docs.python.org, but I'm still not
sure how install a package. I have downloaded pylint in zip form from
www.logilab.org, but I'm unsure what to do with it. The file I wish to
test (i.e. the file I have writen myself) is located in C:\Python25\

Hope you can help,

Barry.

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