From niki at vintech.bg Mon Mar 1 03:43:53 2004 From: niki at vintech.bg (Niki Spahiev) Date: Mon Mar 1 03:45:01 2004 Subject: [Python.NET] Anyone or anything happening here? In-Reply-To: <778972756.20040227224749@gmx.net> References: <9BDC80F712DD0C4CB5FBF48D2ED3DD8B44AEF8@msgusawmb02.ads.autodesk.com> <778972756.20040227224749@gmx.net> Message-ID: <4042F7C9.6070900@vintech.bg> Leonard :paniq: Ritter wrote: > i know that is a bit offtopic but: > > does something like a strong-typed x86 c++/python cross-compiler > exist? or something that lies on the path to it? > > if yes, that would be rule. Google for pyrex. HTH Niki Spahiev From j_lorentsen at hotmail.com Thu Mar 11 09:16:05 2004 From: j_lorentsen at hotmail.com (Jill-Connie Lorentsen) Date: Thu Mar 11 09:11:08 2004 Subject: [Python.NET] Showing modal .NET dialogs from Python Message-ID: I am new to this, so please excuse me if I'm not making myself 100% clear. My colleague is writing a modal dialog using .NET. I want to show it from Python, but I can't figure out how. I guess it'll be something like: import CLR import CLR.System.Windows.Forms as MyForm from MyColleaguesFile import MyColleaguesForm MyForm = MyColleaguesForm MyForm.Show() I've looked at the helloform, splitter and wordwin examples, the mailinglist archive etc, but I feel like I'm missing something. Is it even possible to do what I want to do? Thanks! Jill -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythondotnet/attachments/20040311/5e60fc82/attachment.html From mikeandvivkelly at yahoo.co.uk Thu Mar 11 09:40:09 2004 From: mikeandvivkelly at yahoo.co.uk (=?iso-8859-1?q?Mike=20and=20Viv=20Kelly?=) Date: Thu Mar 11 09:40:51 2004 Subject: [Python.NET] Showing modal .NET dialogs from Python Message-ID: <20040311144009.35174.qmail@web86103.mail.ukl.yahoo.com> Hi Jill. Have a look at the documentation where it describes using 'Assembly.LoadWithPartialName'. I think you need to do something like this: from CLR.System.Reflection import Assembly Assembly.LoadWithPartialName("MyColleaguesFile") from CLR.MyColleaguesFile import MyColleaguesForm Then you can use the class natively. The above assumes that the assembly can be located in the existing path (e.g. current working directory). If not, add its location to sys.path. Also assumed is that the namespace for the class is the same as the assembly file name. If not, use the correct one in the third line above, e.g. CLR.MyColleaguesNamespace. Mike --------------------------------- From: pythondotnet-bounces@python.org [mailto:pythondotnet-bounces@python.org] On Behalf Of Jill-Connie Lorentsen Sent: 11 March 2004 04:16 To: pythondotnet@python.org Subject: [Python.NET] Showing modal ..NET dialogs from Python I am new to this, so please excuse me if I'm not making myself 100% clear. My colleague is writing a modal dialog using ..NET. I want to show it from Python, but I can't figure out how. I guess it'll be something like: import CLR import CLR.System.Windows.Forms as MyForm from MyColleaguesFile import MyColleaguesForm MyForm = MyColleaguesForm MyForm.Show() I've looked at the helloform, splitter and wordwin examples, the mailinglist archive etc, but I feel like I'm missing something. Is it even possible to do what I want to do? Thanks! Jill --------------------------------- Yahoo! Messenger - Communicate instantly..."Ping" your friends today! Download Messenger Now -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythondotnet/attachments/20040311/3f1faeed/attachment.html From j_lorentsen at hotmail.com Thu Mar 11 10:07:05 2004 From: j_lorentsen at hotmail.com (Jill-Connie Lorentsen) Date: Thu Mar 11 10:02:09 2004 Subject: [Python.NET] Showing modal .NET dialogs from Python Message-ID: Thanks for a quick response, Mike. Just one thing, - what kind of file is "MyColleaguesFile", .py, .cpp, h, .dll...? (my colleague hasn't finished his part of the project yet, and he doesn't know much about this either...) Jill -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythondotnet/attachments/20040311/96b592b9/attachment.html From mikeandvivkelly at yahoo.co.uk Thu Mar 11 10:11:12 2004 From: mikeandvivkelly at yahoo.co.uk (=?iso-8859-1?q?Mike=20and=20Viv=20Kelly?=) Date: Thu Mar 11 10:11:15 2004 Subject: [Python.NET] Showing modal .NET dialogs from Python Message-ID: <20040311151112.67522.qmail@web86109.mail.ukl.yahoo.com> It will probably be a .DLL because it will be a .NET Assembly. --------------------------------- From: pythondotnet-bounces@python.org [mailto:pythondotnet-bounces@python.org] On Behalf Of Jill-Connie Lorentsen Sent: 11 March 2004 05:07 To: pythondotnet@python.org Subject: [Python.NET] Showing modal ..NET dialogs from Python Thanks for a quick response, Mike. Just one thing, - what kind of file is "MyColleaguesFile", .py, .cpp, .h, .dll...? (my colleague hasn't finished his part of the project yet, and he doesn't know much about this either...) Jill --------------------------------- Yahoo! Messenger - Communicate instantly..."Ping" your friends today! Download Messenger Now -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythondotnet/attachments/20040311/23d4a80e/attachment.html From CSkaryd at TheOPALGroup.com Thu Mar 11 10:00:39 2004 From: CSkaryd at TheOPALGroup.com (Chris C. Skaryd) Date: Thu Mar 11 10:18:57 2004 Subject: [Python.NET] Showing modal .NET dialogs from Python In-Reply-To: References: Message-ID: <40507F17.2080803@TheOPALGroup.com> If I'm reading your message correctly, all you need to do is say MyForm.ShowDialog() as opposed to MyForm.Show() Jill-Connie Lorentsen wrote: > I am new to this, so please excuse me if I'm not making myself > 100% clear. > > My colleague is writing a modal dialog using .NET. I want to > show it from Python, but I can't figure out how. > > I guess it'll be something like: > > import CLR > import CLR.System.Windows.Forms as MyForm > from MyColleaguesFile import MyColleaguesForm > > MyForm = MyColleaguesForm > > MyForm.Show() > > I've looked at the helloform, splitter and wordwin examples, the > mailinglist archive etc, but I feel like I'm missing something. Is > it even possible to do what I want to do? > > Thanks! > > Jill > >------------------------------------------------------------------------ > >_________________________________________________ >Python.NET mailing list - PythonDotNet@python.org >http://mail.python.org/mailman/listinfo/pythondotnet > -- ____________________________________________________ Chris C. Skaryd - CSkaryd@TheOPALGroup.com 27887 Clemens Rd. Suite 2, Cleveland, OH 44145-1167 Tel: 440-871-OPAL Ext. 22 / Fax: 440-871-6722 From awatters at connotate.com Thu Mar 11 09:49:04 2004 From: awatters at connotate.com (Aaron Watters) Date: Thu Mar 11 10:35:21 2004 Subject: [Python.NET] Showing modal .NET dialogs from Python References: Message-ID: <002501c40778$00008300$3e01a8c0@youcantagit.com> Just guessing: I think you probably need to start up a "main window" before you do a modal dialog in order to get background threads that handle GUI events started. But I'm way out of my areas of expertise here. -- Aaron Watters ----- Original Message ----- From: Jill-Connie Lorentsen To: pythondotnet@python.org Sent: Thursday, March 11, 2004 9:16 AM Subject: [Python.NET] Showing modal .NET dialogs from Python I am new to this, so please excuse me if I'm not making myself 100% clear. My colleague is writing a modal dialog using .NET. I want to show it from Python, but I can't figure out how. I guess it'll be something like: import CLR import CLR.System.Windows.Forms as MyForm from MyColleaguesFile import MyColleaguesForm MyForm = MyColleaguesForm MyForm.Show() I've looked at the helloform, splitter and wordwin examples, the mailinglist archive etc, but I feel like I'm missing something. Is it even possible to do what I want to do? Thanks! Jill ------------------------------------------------------------------------------ _________________________________________________ Python.NET mailing list - PythonDotNet@python.org http://mail.python.org/mailman/listinfo/pythondotnet -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythondotnet/attachments/20040311/b74de9ad/attachment.html From mckay_sean at yahoo.com Fri Mar 12 14:03:11 2004 From: mckay_sean at yahoo.com (Sean McKay) Date: Fri Mar 12 14:03:15 2004 Subject: [Python.NET] Using a .Net DLL In-Reply-To: Message-ID: <20040312190311.49909.qmail@web21407.mail.yahoo.com> Hi, I'm trying to come up with a port of a python project into C# (to speed it up, and get experience with C#), and I'm having problems using the C# DLL I've created. I've added it to the GAC... Here is the Python code, and also the C# code.. Any help is appreciated! Thanks, Sean >>> import CLR >>> import CLR.nltk >>> from CLR.nltk import Set >>> dir(Set) ['__doc__', '__name__'] >>> from CLR.nltk.Set import Set >>> dir(Set) ['Equals', 'Finalize', 'GetHashCode', 'GetType', 'MemberwiseClone', 'ReferenceEquals', 'ToString', '__and__', '__call__', '__class__', '__cmp__', '__contains__', '__delattr__', '__delitem__', '__doc__', '__eq__', '__getattribute__', '__getitem__', '__hash__', '__init__', '__iter__', '__len__', '__module__', '__new__', '__or__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setitem__', '__str__', '__sub__', 'contains', 'copy', 'count', 'dict', 'difference', 'elements', 'f_measure', 'intersection', 'precision', 'recall', 'union'] >>> a = Set([5,3,2,1]) Traceback (most recent call last): File "", line 1, in ? TypeError: 'MethodObject' object is not callable C# code: namespace nltk { namespace Set { public class Set { protected Dict dict ; public Set(Dict idict) { dict = idict; } public Set(params object[] list) { __init__(list); } private void __init__(params object[] list) { dict = new Dict(); foreach (object name in list) dict[name.ToString()] = 1; } public string[] elements() { return dict.GetKeys; } public Set union(Set other) { Dict newDict = new Dict(); foreach (string key in dict.Keys) newDict[key] = 1; foreach (string key in other.elements()) newDict[key] = 1; return new Set(newDict); } public bool contains(object element) { return dict.Contains(element.ToString()); } public bool contains(string element) { return dict.Contains(element); } public Set intersection(Set other) { Dict newDict = new Dict(); foreach (string key in dict.Keys) if (other.contains(key)) newDict[key] = 1; return new Set( newDict); } public Set difference(Set other) { Dict newDict = new Dict(); foreach (string key in dict.Keys) if (!other.contains(key)) newDict[key] = 1; return new Set(newDict); } public Set __and__(Set other) { return intersection(other); } public Set __or__(Set other) { return union(other); } public Set __sub__(Set other) { return difference(other); } public bool __contains__(string element) { return dict.Contains(element); } public Set copy() { Dict newDict = new Dict(); foreach (string key in dict.Keys) newDict[key] = 1; return new Set(newDict); } public float precision(Set other) { int guessed = other.elements().Length; if (guessed==0) return 0; int found = intersection(other).elements().Length; return (float) found / guessed; } public float recall(Set other) { int toFind = elements().Length; if (toFind == 0) return 0; int found = intersection(other).elements().Length; return (float) found / toFind; } public float f_measure(Set other, float alpha) { float p = precision(other); float r = recall(other); if (p==0 || r==0) return 0; return 1/(alpha/p + (1-alpha)/r); } public float f_measure(Set other) { return f_measure(other, (float)0.5); } public string __repr__() { return string.Format("[{0}]",string.Join(", ",elements())).Replace("[","{").Replace("]","}"); } public int __len__() { return dict.GetKeys.Length; } public int count() { return __len__(); } public int __cmp__(Set other) { if (other.count() > count()) return -1; else if (other.count() == count()) return 0; else return 1; } public bool __eq__(Set other) { return (other == this); } public virtual int __hash__() { return dict.GetHashCode(); } } __________________________________ Do you Yahoo!? Yahoo! Search - Find what you’re looking for faster http://search.yahoo.com From mckay_sean at yahoo.com Fri Mar 12 16:14:39 2004 From: mckay_sean at yahoo.com (Sean McKay) Date: Fri Mar 12 16:14:42 2004 Subject: [Python.NET] Using a .Net DLL In-Reply-To: Message-ID: <20040312211439.48924.qmail@web21401.mail.yahoo.com> My apologies! I'll add the Dict code.. (btw, some closing brackets are probably missing, as well as possibly some using statements, I was trying to cut stuff out for brevity). Thanks for looking at this... Sean using System; using System.Collections; using System.Collections.Specialized; using System.IO; namespace nltk { namespace probability { public delegate ProbDist CreateProbDistDelegate(FreqDist fdist, params object[] args); #region Helper Classes public class Dict: Hashtable { private ArrayList keys = new ArrayList(); public override object this[ object key ] { get { return( base[key] ); } set { if (!keys.Contains(key)) keys.Add(key); base[key] = value; } } public string[] GetKeys { get { string[] results = new string[keys.Count]; keys.CopyTo(results); return( results); } } public override string ToString() { string result = ""; foreach (string key in Keys) { result += key + ":" + base[key].ToString() + " "; } return result; } public override void Add( object key, object value ) { if (!keys.Contains(key)) keys.Add(key); base.Add(key, value); } public override void Remove( object key ) { keys.Remove(key); base.Remove( key ); } public int Length { get { return base.Count; } } } #endregion --- Thane wrote: > Sean, I can't get your C# code to compile. The complaint is about > "Dict". > __________________________________ Do you Yahoo!? Yahoo! Search - Find what you’re looking for faster http://search.yahoo.com From brian at zope.com Fri Mar 12 16:54:44 2004 From: brian at zope.com (Brian Lloyd) Date: Fri Mar 12 16:54:59 2004 Subject: [Python.NET] Using a .Net DLL In-Reply-To: <20040312190311.49909.qmail@web21407.mail.yahoo.com> Message-ID: Hi Sean - What I think you're trying to do here hadn't really occured to me before ;) Generally, you don't need to make your C# class "pythonic" in any way (__xxx__ methods, etc.) The idea of defining things like __and__ in C# is interesting. It may work for some "special" methods - I've never really tried it. It generally _won't_ work for __init__ though - that one is special on a few different levels. You really don't need a special Pythonic constructor - I suggest just removing that and making it a regular constructor overload (which should work fine from Python). Brian Lloyd brian@zope.com V.P. Engineering 540.361.1716 Zope Corporation http://www.zope.com > -----Original Message----- > From: pythondotnet-bounces@python.org > [mailto:pythondotnet-bounces@python.org]On Behalf Of Sean McKay > Sent: Friday, March 12, 2004 2:03 PM > To: pythondotnet@python.org > Subject: [Python.NET] Using a .Net DLL > > > Hi, > > I'm trying to come up with a port of a python project into C# (to speed it > up, and get experience with C#), and I'm having problems using the C# DLL > I've created. I've added it to the GAC... Here is the Python code, and > also the C# code.. Any help is appreciated! > > Thanks, > Sean > > >>> import CLR > >>> import CLR.nltk > >>> from CLR.nltk import Set > >>> dir(Set) > ['__doc__', '__name__'] > >>> from CLR.nltk.Set import Set > >>> dir(Set) > ['Equals', 'Finalize', 'GetHashCode', 'GetType', 'MemberwiseClone', > 'ReferenceEquals', 'ToString', '__and__', '__call__', '__class__', > '__cmp__', '__contains__', '__delattr__', '__delitem__', '__doc__', > '__eq__', '__getattribute__', '__getitem__', '__hash__', '__init__', > '__iter__', '__len__', '__module__', '__new__', '__or__', '__reduce__', > '__reduce_ex__', '__repr__', '__setattr__', '__setitem__', '__str__', > '__sub__', 'contains', 'copy', 'count', 'dict', 'difference', 'elements', > 'f_measure', 'intersection', 'precision', 'recall', 'union'] > >>> a = Set([5,3,2,1]) > Traceback (most recent call last): > File "", line 1, in ? > TypeError: 'MethodObject' object is not callable > > C# code: > > namespace nltk > { > namespace Set > { > public class Set > { > protected Dict dict ; > > public Set(Dict idict) > { > dict = idict; > } > > public Set(params object[] list) > { > __init__(list); > } > > private void __init__(params object[] list) > { > > dict = new Dict(); > foreach (object name in list) > dict[name.ToString()] = 1; > } > > public string[] elements() > { > return dict.GetKeys; > } > > public Set union(Set other) > { > Dict newDict = new Dict(); > foreach (string key in dict.Keys) > newDict[key] = 1; > > foreach (string key in other.elements()) > newDict[key] = 1; > > return new Set(newDict); > } > > public bool contains(object element) > { > return dict.Contains(element.ToString()); > } > > public bool contains(string element) > { > return dict.Contains(element); > } > > public Set intersection(Set other) > { > Dict newDict = new Dict(); > foreach (string key in dict.Keys) > if (other.contains(key)) > newDict[key] = 1; > return new Set( newDict); > } > > public Set difference(Set other) > { > Dict newDict = new Dict(); > foreach (string key in dict.Keys) > if (!other.contains(key)) > newDict[key] = 1; > return new Set(newDict); > } > > public Set __and__(Set other) > { > return intersection(other); > } > > public Set __or__(Set other) > { > return union(other); > } > > public Set __sub__(Set other) > { > return difference(other); > } > > public bool __contains__(string element) > { > return dict.Contains(element); > } > > public Set copy() > { > Dict newDict = new Dict(); > foreach (string key in dict.Keys) > newDict[key] = 1; > return new Set(newDict); > } > > public float precision(Set other) > { > int guessed = other.elements().Length; > if (guessed==0) return 0; > int found = > intersection(other).elements().Length; > return (float) found / guessed; > > } > > public float recall(Set other) > { > int toFind = elements().Length; > if (toFind == 0) return 0; > int found = > intersection(other).elements().Length; > return (float) found / toFind; > } > > public float f_measure(Set other, float alpha) > { > float p = precision(other); > float r = recall(other); > if (p==0 || r==0) return 0; > return 1/(alpha/p + (1-alpha)/r); > } > > public float f_measure(Set other) > { > return f_measure(other, (float)0.5); > } > > public string __repr__() > { > return string.Format("[{0}]",string.Join(", > ",elements())).Replace("[","{").Replace("]","}"); > } > > public int __len__() > { > return dict.GetKeys.Length; > } > > public int count() > { > return __len__(); > } > > public int __cmp__(Set other) > { > if (other.count() > count()) > return -1; > else if (other.count() == count()) > return 0; > else return 1; > } > > public bool __eq__(Set other) > { > return (other == this); > } > > public virtual int __hash__() > { > return dict.GetHashCode(); > } > } > > > > > __________________________________ > Do you Yahoo!? > Yahoo! Search - Find what youre looking for faster > http://search.yahoo.com > > _________________________________________________ > Python.NET mailing list - PythonDotNet@python.org > http://mail.python.org/mailman/listinfo/pythondotnet > From mckay_sean at yahoo.com Fri Mar 12 17:05:22 2004 From: mckay_sean at yahoo.com (Sean McKay) Date: Fri Mar 12 17:05:26 2004 Subject: [Python.NET] Using a .Net DLL In-Reply-To: Message-ID: <20040312220522.51154.qmail@web21412.mail.yahoo.com> Thane, I figured out the problem.. it turns out that I had an old version of the DLL in the GAC (and at one point an old one copied to the Python.Net directory).. when I updated the GAC (and deleted the one in the Python.Net directory) I was able to successfully initialize the Set object. Thanks for looking into this. I wouldn't have figured it out if you hadn't shown it working on your box! Sean --- Thane wrote: > Code is good. See output below. I suspect that Python.NET can't see > something... > > I'll keep playing with it and try to duplicate your error. > > --Thane > > ----------- PYTHON OUTPUT ----------------- > Python 2.3.2 (#49, Oct 2 2003, 20:02:00) [MSC v.1200 32 bit (Intel)] on > win32 > Type "copyright", "credits" or "license" for more information. > >>> Running initialization script, please stand by... > >>> import CLR.nltk > >>> from CLR.nltk import Set > >>> dir(Set) > ['__doc__', '__name__'] > >>> from CLR.nltk.Set import Set > >>> dir(Set) > ['Equals', 'Finalize', 'GetHashCode', 'GetType', 'MemberwiseClone', > 'ReferenceEquals', 'ToString', '__and__', '__call__', '__class__', > '__cmp__', '__contains__', '__delattr__', '__delitem__', '__doc__', > '__eq__', '__getattribute__', '__getitem__', '__hash__', '__init__', > '__iter__', '__len__', '__module__', '__new__', '__or__', '__reduce__', > '__reduce_ex__', '__repr__', '__setattr__', '__setitem__', '__str__', > '__sub__', 'contains', 'copy', 'count', 'dict', 'difference', > 'elements', > 'f_measure', 'intersection', 'precision', 'recall', 'union'] > >>> a = Set(1) > Traceback (most recent call last): > File "", line 1, in ? > TypeError: no constructor matches given arguments > >>> a = Set([1,2]) > >>> a > > >>> b = Set([5,3,2,1]) > >>> b > > >>> b.contains(3) > True > >>> > __________________________________ Do you Yahoo!? Yahoo! Finance: Get your refund fast by filing online. http://taxes.yahoo.com/filing.html From brian at zope.com Fri Mar 12 17:16:57 2004 From: brian at zope.com (Brian Lloyd) Date: Fri Mar 12 17:17:11 2004 Subject: [Python.NET] Using a .Net DLL In-Reply-To: Message-ID: Ah - I see now, the __init__ is private so it isn't getting into the Python class dict, so my recommendation was wrong (I still think bad things would happen if the __init__ got into the class dict). Brian Lloyd brian@zope.com V.P. Engineering 540.361.1716 Zope Corporation http://www.zope.com > -----Original Message----- > From: pythondotnet-bounces@python.org > [mailto:pythondotnet-bounces@python.org]On Behalf Of Brian Lloyd > Sent: Friday, March 12, 2004 4:55 PM > To: mckay_sean@yahoo.com; pythondotnet@python.org > Subject: RE: [Python.NET] Using a .Net DLL > > > Hi Sean - > > What I think you're trying to do here hadn't really occured to > me before ;) > > Generally, you don't need to make your C# class "pythonic" in any > way (__xxx__ methods, etc.) The idea of defining things like > __and__ in C# is interesting. It may work for some "special" > methods - I've never really tried it. > > It generally _won't_ work for __init__ though - that one is > special on a few different levels. You really don't need a > special Pythonic constructor - I suggest just removing that > and making it a regular constructor overload (which should > work fine from Python). > > > Brian Lloyd brian@zope.com > V.P. Engineering 540.361.1716 > Zope Corporation http://www.zope.com > > > > -----Original Message----- > > From: pythondotnet-bounces@python.org > > [mailto:pythondotnet-bounces@python.org]On Behalf Of Sean McKay > > Sent: Friday, March 12, 2004 2:03 PM > > To: pythondotnet@python.org > > Subject: [Python.NET] Using a .Net DLL > > > > > > Hi, > > > > I'm trying to come up with a port of a python project into C# > (to speed it > > up, and get experience with C#), and I'm having problems using > the C# DLL > > I've created. I've added it to the GAC... Here is the Python code, and > > also the C# code.. Any help is appreciated! > > > > Thanks, > > Sean > > > > >>> import CLR > > >>> import CLR.nltk > > >>> from CLR.nltk import Set > > >>> dir(Set) > > ['__doc__', '__name__'] > > >>> from CLR.nltk.Set import Set > > >>> dir(Set) > > ['Equals', 'Finalize', 'GetHashCode', 'GetType', 'MemberwiseClone', > > 'ReferenceEquals', 'ToString', '__and__', '__call__', '__class__', > > '__cmp__', '__contains__', '__delattr__', '__delitem__', '__doc__', > > '__eq__', '__getattribute__', '__getitem__', '__hash__', '__init__', > > '__iter__', '__len__', '__module__', '__new__', '__or__', '__reduce__', > > '__reduce_ex__', '__repr__', '__setattr__', '__setitem__', '__str__', > > '__sub__', 'contains', 'copy', 'count', 'dict', 'difference', > 'elements', > > 'f_measure', 'intersection', 'precision', 'recall', 'union'] > > >>> a = Set([5,3,2,1]) > > Traceback (most recent call last): > > File "", line 1, in ? > > TypeError: 'MethodObject' object is not callable > > > > C# code: > > > > namespace nltk > > { > > namespace Set > > { > > public class Set > > { > > protected Dict dict ; > > > > public Set(Dict idict) > > { > > dict = idict; > > } > > > > public Set(params object[] list) > > { > > __init__(list); > > } > > > > private void __init__(params object[] list) > > { > > > > dict = new Dict(); > > foreach (object name in list) > > dict[name.ToString()] = 1; > > } > > > > public string[] elements() > > { > > return dict.GetKeys; > > } > > > > public Set union(Set other) > > { > > Dict newDict = new Dict(); > > foreach (string key in dict.Keys) > > newDict[key] = 1; > > > > foreach (string key in other.elements()) > > newDict[key] = 1; > > > > return new Set(newDict); > > } > > > > public bool contains(object element) > > { > > return dict.Contains(element.ToString()); > > } > > > > public bool contains(string element) > > { > > return dict.Contains(element); > > } > > > > public Set intersection(Set other) > > { > > Dict newDict = new Dict(); > > foreach (string key in dict.Keys) > > if (other.contains(key)) > > newDict[key] = 1; > > return new Set( newDict); > > } > > > > public Set difference(Set other) > > { > > Dict newDict = new Dict(); > > foreach (string key in dict.Keys) > > if (!other.contains(key)) > > newDict[key] = 1; > > return new Set(newDict); > > } > > > > public Set __and__(Set other) > > { > > return intersection(other); > > } > > > > public Set __or__(Set other) > > { > > return union(other); > > } > > > > public Set __sub__(Set other) > > { > > return difference(other); > > } > > > > public bool __contains__(string element) > > { > > return dict.Contains(element); > > } > > > > public Set copy() > > { > > Dict newDict = new Dict(); > > foreach (string key in dict.Keys) > > newDict[key] = 1; > > return new Set(newDict); > > } > > > > public float precision(Set other) > > { > > int guessed = other.elements().Length; > > if (guessed==0) return 0; > > int found = > > intersection(other).elements().Length; > > return (float) found / guessed; > > > > } > > > > public float recall(Set other) > > { > > int toFind = elements().Length; > > if (toFind == 0) return 0; > > int found = > > intersection(other).elements().Length; > > return (float) found / toFind; > > } > > > > public float f_measure(Set other, float alpha) > > { > > float p = precision(other); > > float r = recall(other); > > if (p==0 || r==0) return 0; > > return 1/(alpha/p + (1-alpha)/r); > > } > > > > public float f_measure(Set other) > > { > > return f_measure(other, (float)0.5); > > } > > > > public string __repr__() > > { > > return string.Format("[{0}]",string.Join(", > > ",elements())).Replace("[","{").Replace("]","}"); > > } > > > > public int __len__() > > { > > return dict.GetKeys.Length; > > } > > > > public int count() > > { > > return __len__(); > > } > > > > public int __cmp__(Set other) > > { > > if (other.count() > count()) > > return -1; > > else if (other.count() == count()) > > return 0; > > else return 1; > > } > > > > public bool __eq__(Set other) > > { > > return (other == this); > > } > > > > public virtual int __hash__() > > { > > return dict.GetHashCode(); > > } > > } > > > > > > > > > > __________________________________ > > Do you Yahoo!? > > Yahoo! Search - Find what youre looking for faster > > http://search.yahoo.com > > > > _________________________________________________ > > Python.NET mailing list - PythonDotNet@python.org > > http://mail.python.org/mailman/listinfo/pythondotnet > > > > > _________________________________________________ > Python.NET mailing list - PythonDotNet@python.org > http://mail.python.org/mailman/listinfo/pythondotnet > From j_lorentsen at hotmail.com Thu Mar 25 07:26:21 2004 From: j_lorentsen at hotmail.com (Jill-Connie Lorentsen) Date: Thu Mar 25 07:27:06 2004 Subject: [Python.NET] How to use "out" or "ref" on method parameter list Message-ID: I have a DotNet class with methods with the following signature: public bool MyMethod(out int myVariable) { myVariable = 5; return true } Does anybody know how I cancall them from Python via CLR? I've tried MyMethod(a), where a has been an empty list, a list with one element, an integer etc, but nomatter what i get an error saying TypeError: no method matches given arguments Can anybody help? Jill -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythondotnet/attachments/20040325/f970b70e/attachment.html From brian at zope.com Thu Mar 25 10:03:02 2004 From: brian at zope.com (Brian Lloyd) Date: Thu Mar 25 10:03:16 2004 Subject: [Python.NET] How to use "out" or "ref" on method parameter list In-Reply-To: Message-ID: Hi Jill - Python for .NET doesn't yet handle in, in/out, ref etc. parameters yet. This is one of the (surprisingly few) places where the Python model doesn't match well with .NET. In the future, I expect that Python will return a tuple of (result, outparam, outparam...) to handle out params, but its not there yet. A quick workaround would be to implement a helper method that calls MyMethod and returns the modified int as its result, then call that from Python. (If you need both the bool result and the int, you could return a struct, etc.) Hope this helps! Brian Lloyd brian@zope.com V.P. Engineering 540.361.1716 Zope Corporation http://www.zope.com -----Original Message----- From: pythondotnet-bounces@python.org [mailto:pythondotnet-bounces@python.org]On Behalf Of Jill-Connie Lorentsen Sent: Thursday, March 25, 2004 7:26 AM To: pythondotnet@python.org Subject: [Python.NET] How to use "out" or "ref" on method parameter list I have a DotNet class with methods with the following signature: public bool MyMethod(out int myVariable) { myVariable = 5; return true } Does anybody know how I cancall them from Python via CLR? I've tried MyMethod(a), where a has been an empty list, a list with one element, an integer etc, but nomatter what i get an error saying TypeError: no method matches given arguments Can anybody help? Jill -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythondotnet/attachments/20040325/2383f5a8/attachment.html From awatters at connotate.com Thu Mar 25 10:39:36 2004 From: awatters at connotate.com (Aaron Watters) Date: Thu Mar 25 10:39:25 2004 Subject: [Python.NET] scary fun (who needs SystemExit?) Message-ID: <001401c4127f$60a74ce0$3e01a8c0@youcantagit.com> Just fiddling around here: C:\misc\PythonNet-1.0-beta3>python Python 2.3.2 (#49, Oct 2 2003, 20:02:00) [MSC v.1200 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import CLR >>> L = CLR.System.Diagnostics.Process.GetProcesses() >>> for x in L: ... if x.ProcessName == u"python": ... x.Kill() C:\misc\PythonNet-1.0-beta3> This is one of very many scary things that can be done very easily using Python.Net. (I haven't tried to see what happens if it attempts to kill all the other processes before committing suicide...) Too much rope? Anyways, this is certainly a great way to fiddle around with the Libraries. thanks again. -- Aaron Watters -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythondotnet/attachments/20040325/24455fb2/attachment.html From brian at zope.com Thu Mar 25 11:05:42 2004 From: brian at zope.com (Brian Lloyd) Date: Thu Mar 25 11:06:26 2004 Subject: [Python.NET] scary fun (who needs SystemExit?) In-Reply-To: <001401c4127f$60a74ce0$3e01a8c0@youcantagit.com> Message-ID: > Just fiddling around here: > > C:\misc\PythonNet-1.0-beta3>python > Python 2.3.2 (#49, Oct 2 2003, 20:02:00) [MSC v.1200 32 bit (Intel)] on win32 > Type "help", "copyright", "credits" or "license" for more information. > >>> import CLR > >>> L = CLR.System.Diagnostics.Process.GetProcesses() > >>> for x in L: > ... if x.ProcessName == u"python": > ... x.Kill() > C:\misc\PythonNet-1.0-beta3> > > This is one of very many scary things that can be done very easily > using Python.Net. (I haven't tried to see what happens if it attempts > to kill all the other processes before committing suicide...) > > Too much rope? I've tried to be clear in the readme that Python for .NET does not (and in many ways, cannot) play by the .NET security rules. So it provides not only as much rope as you want, but also AKs, C4 and the odd thermal detonator ;) The nature of the integration (CPython rather than a managed reimplementation) makes that unlikely to change, as it needs a pretty high level of rights (reflection, memory access, etc.) to run at all. If IronPython ever happens (or some other pure-managed implementation) it should be a be a much better citizen in this regard. My sense is that security integration is usually either a non-issue for the app in question or a total showstopper when people evaluate scripting solutions for .NET. It would be nice to have tight integration so that both groups could use Python ;^) Brian Lloyd brian@zope.com V.P. Engineering 540.361.1716 Zope Corporation http://www.zope.com From andrew at shellscape.org Mon Mar 29 01:02:24 2004 From: andrew at shellscape.org (Andrew Powell) Date: Mon Mar 29 02:30:13 2004 Subject: [Python.NET] MSScriptControl Objects Message-ID: Hello all. Newcommer to the newsgroups so please let me know if Im not adhering to any policy. Ive setup an app (.NET app) which is using the MSScriptControl. I have the ActivePython package installed and the ActiveScript engine for Python registered. Thats all peachykeen. Im running into a problem whereby Objects that Ive extended to the script arent being 'seen' correctly by the engine. Other languages such as VBScript, JScript and RubyScript are dealing with and using the objects just fine. The following is an error that the pyscript engine returned upon using an object ive named 'Graphics'. The following error occurs when I try to use the methods, properties or subclasses of any object extended to the script via MSScriptControl.AddObject. Error Number : -2147352567 Description : Traceback (most recent call last): File "