Author | Message | Time |
---|---|---|
Topaz | 1. What, if there is, the equivalent of SendMessage() in Python? 2. How do you make calls to DLLs written in C++ and, if possible, VB6? 3. What library is used for socket work? (hard to phrase... see: mswinsck.dll from VB6) 4. Are optimizations automatically done by the interpreter? | May 15, 2006, 9:31 AM |
Myndfyr | I'm pretty sure I can answer question 2 for you, but don't take it as canon. C++ DLLs are specialized DLLs -- linkers have to do special work to import them. This is because, to avoid overlap in function names, they're mangled in a very specific way. You most likely can't import C++ DLLs unless they expose COM through ATL, which leads me to my response about VB6. Unless Python provides a way to access COM, you're out of luck with VB6, since VB6 doesn't compile traditional PE DLLs. | May 15, 2006, 10:04 AM |
Yegg | [quote author=Topaz link=topic=14983.msg152487#msg152487 date=1147685501] 1. What, if there is, the equivalent of SendMessage() in Python?[/quote] Well, Python can interface with the Windows API. [quote author=Topaz link=topic=14983.msg152487#msg152487 date=1147685501] 2. How do you make calls to DLLs written in C++ and, if possible, VB6?[/quote] http://starship.python.net/crew/theller/ctypes/ [quote author=Topaz link=topic=14983.msg152487#msg152487 date=1147685501] 3. What library is used for socket work? (hard to phrase... see: mswinsck.dll from VB6)[/quote] Python has it's own socket library which is very easy to use. [quote author=Topaz link=topic=14983.msg152487#msg152487 date=1147685501] 4. Are optimizations automatically done by the interpreter?[/quote] I believe so, I'm no Python expert. | May 15, 2006, 7:39 PM |
Myndfyr | [quote author=Yegg link=topic=14983.msg152509#msg152509 date=1147721968] http://starship.python.net/crew/theller/ctypes/ [/quote] He said C++. Meaning, he wants to use C++ classes. C DLLs and C++ DLLs are very different. | May 15, 2006, 8:06 PM |
Yegg | [quote author=MyndFyre[vL] link=topic=14983.msg152510#msg152510 date=1147723570] [quote author=Yegg link=topic=14983.msg152509#msg152509 date=1147721968] http://starship.python.net/crew/theller/ctypes/ [/quote] He said C++. Meaning, he wants to use C++ classes. C DLLs and C++ DLLs are very different. [/quote] I havn't used ctypes in quite some time, but does it not support both types of DLLs? Also, what makes the two DLLs different? | May 15, 2006, 10:34 PM |
Topaz | [quote author=Yegg link=topic=14983.msg152509#msg152509 date=1147721968] [quote author=Topaz link=topic=14983.msg152487#msg152487 date=1147685501] 1. What, if there is, the equivalent of SendMessage() in Python?[/quote] Well, Python can interface with the Windows API. [quote author=Topaz link=topic=14983.msg152487#msg152487 date=1147685501] 2. How do you make calls to DLLs written in C++ and, if possible, VB6?[/quote] http://starship.python.net/crew/theller/ctypes/ [quote author=Topaz link=topic=14983.msg152487#msg152487 date=1147685501] 3. What library is used for socket work? (hard to phrase... see: mswinsck.dll from VB6)[/quote] Python has it's own socket library which is very easy to use. [quote author=Topaz link=topic=14983.msg152487#msg152487 date=1147685501] 4. Are optimizations automatically done by the interpreter?[/quote] I believe so, I'm no Python expert. [/quote] Would you like to specify, instead of just giving yes or no answers? | May 15, 2006, 11:11 PM |
St0rm.iD | 1. If you've downloaded the win32 extensions for Python (and I'm sure you have, they're usually installed automatically, http://starship.python.net/crew/mhammond/): [code] import win32api win32api.SendMessage(...) import win32con # for constants [/code] 2. You'll probably want to use ActiveX. See http://www.python.org/windows/win32com/QuickStartClientCom.html . You also might want to wrap a C library around it and use ctypes, which is included in Python 2.5, and available at the link above. 3. Most people just use the built-in socket library ("import socket") and maybe non-blocking I/O ("import select"). If you want to access HTTP URLs, "import urllib2", or if you want to serve up web pages, "import SimpleHTTPServer". If you're looking for a hardcore (and I mean hardcore) networking framework built on Python, see www.twistedmatrix.com. 4. Yeah. If you need any more, Psyco is your man (http://psyco.sourceforge.net/). All you have to do is: [code] import psyco psyco.full() [/code] | May 15, 2006, 11:21 PM |
Topaz | Thanks! | May 16, 2006, 10:26 PM |
Topaz | I'll continue to add questions as I run into problems: 5. What is / how would I use arg? I've seen it around, but I can't find any documentation on it (checked MSDN, Google - just code involving it, no explanations). | May 18, 2006, 6:00 AM |
FrOzeN | [quote author=Topaz link=topic=14983.msg152674#msg152674 date=1147932031] 5. What is / how would I use arg? I've seen it around, but I can't find any documentation on it (checked MSDN, Google - just code involving it, no explanations). [/quote] Not sure if this is what you ment, but I'll take a stab. If you mean 'arg' as-in 'argc/argv', eg: [code]int main(int argc, char *argv[]);[/code] Then argc is an integer containing the amount of arguements (determined by spaces) that are in the command line, and argv[] would be a character array with each part. Eg, If you did ran the program like "yourprogram.exe Hello Something -c -bla" argc would be 4, argv[0] would be "Hello", argv[1] = "Something", argv[2] = "-c" and argv[4] = "-bla". [EDIT] Eh, that was C++. Anyway 'arg' essentially stands for "Command Line Arguments". This will explain it better for Python. | May 18, 2006, 6:44 AM |
St0rm.iD | [code] import sys print sys.argv [/code] | May 18, 2006, 1:00 PM |
rabbit | [quote author=FrOzeN link=topic=14983.msg152676#msg152676 date=1147934678] [quote author=Topaz link=topic=14983.msg152674#msg152674 date=1147932031] 5. What is / how would I use arg? I've seen it around, but I can't find any documentation on it (checked MSDN, Google - just code involving it, no explanations). [/quote] Not sure if this is what you ment, but I'll take a stab. If you mean 'arg' as-in 'argc/argv', eg: [code]int main(int argc, char *argv[]);[/code] Then argc is an integer containing the amount of arguements (determined by spaces) that are in the command line, and argv[] would be a character array with each part. Eg, If you did ran the program like "yourprogram.exe Hello Something -c -bla" argc would be 4, argv[0] would be "Hello", argv[1] = "Something", argv[2] = "-c" and argv[4] = "-bla". [EDIT] Eh, that was C++. Anyway 'arg' essentially stands for "Command Line Arguments". This will explain it better for Python. [/quote]You're almost correct. In C/++, argv[0] is always how the program name. IE: if you did 'yourprogram.exe Hello Stuff', argv[0] would be "yourprogram.exe", but if you did 'yourprogram Goodbye Moo', argv[0] would be "yourprogram". | May 18, 2006, 6:33 PM |
Topaz | Thanks, everyone. | May 18, 2006, 10:30 PM |
Kp | [quote author=rabbit link=topic=14983.msg152699#msg152699 date=1147977197]You're almost correct. In C/++, argv[0] is always how the program name. IE: if you did 'yourprogram.exe Hello Stuff', argv[0] would be "yourprogram.exe", but if you did 'yourprogram Goodbye Moo', argv[0] would be "yourprogram". [/quote] You too, are almost correct. :) argv[0] is chosen by the calling application, just as all other argv[] values are. It's traditional for shells to place the program's name in argv[0], but they're not required to do so. | May 18, 2006, 11:26 PM |
rabbit | Windows does it, and based on what's been said, that's the primary platform, so that's what I went with. | May 19, 2006, 12:48 AM |
Kp | No, Windows does not do it. Even on Windows, it's traditional, but not mandatory for argv[0] to be the program's name. My Windows programs routinely pass junk in argv[0] (a dash, a letter, an underscore - something easy to hardcode). | May 19, 2006, 1:44 AM |
Topaz | 6. What is the equivalent of the switch/select case statement in Python? (Python is great so far, but I've been needing to read a lot of documentation as well as code so I know how to use so-so function :)) | May 19, 2006, 6:23 AM |
kamakazie | [quote author=rabbit link=topic=14983.msg152721#msg152721 date=1147999683] Windows does it, and based on what's been said, that's the primary platform, so that's what I went with. [/quote] http://blogs.msdn.com/oldnewthing/archive/2004/01/14/58579.aspx [quote author=Topaz link=topic=14983.msg152745#msg152745 date=1148019799] 6. What is the equivalent of the switch/select case statement in Python? (Python is great so far, but I've been needing to read a lot of documentation as well as code so I know how to use so-so function :)) [/quote] http://www.google.com/search?hl=en&q=python+switch&btnG=Google+Search | May 19, 2006, 7:54 AM |
Yegg | [quote author=Topaz link=topic=14983.msg152745#msg152745 date=1148019799] 6. What is the equivalent of the switch/select case statement in Python? [/quote] The equivalent is a lot of elif's :). | May 19, 2006, 6:34 PM |
Topaz | [quote author=Yegg link=topic=14983.msg152794#msg152794 date=1148063681] [quote author=Topaz link=topic=14983.msg152745#msg152745 date=1148019799] 6. What is the equivalent of the switch/select case statement in Python? [/quote] The equivalent is a lot of elif's :). [/quote] Thanks. 7. What is the equivalent of the 'SendMessageByString' API? It's not available in the win32gui or win32api libraries - it merely posts text to a specified handle. | May 20, 2006, 1:10 AM |
K | SendMessageByString is a just a declaration (used in Visual Basic) of SendMessage with either the LPARAM or WPARAM defined as a string. You can just use SendMessage and pass a pointer of the appropriate type. | May 20, 2006, 1:53 AM |
warz | Python has no switch statements? Eww? Edit: After looking into this furthur, I guess that map method (thats what its called? dictionary map or something?) isn't that bad. | May 20, 2006, 5:26 AM |
Topaz | AFAIK, if/elif does essentially the same thing as a switch statement, in terms of operation. | May 20, 2006, 5:27 AM |
Topaz | 8. How would I go about making my code look like this [code]insertString 'string'[/code] instead of the present [code]insertString('string')[/code] | May 25, 2006, 2:50 AM |
St0rm.iD | [quote author=Topaz link=topic=14983.msg153149#msg153149 date=1148525437] 8. How would I go about making my code look like this [code]insertString 'string'[/code] instead of the present [code]insertString('string')[/code] [/quote] You wouldn't. EDIT: though you can use operator overloading to achieve similar results: [code] mybuffer << "string" [/code] Play around with adding a __lshift__ method to your code. | May 25, 2006, 3:45 AM |