question; C/C++ with Python

2008-12-25 Thread Hongtian
Hi friends, I have a C/C++ application and I wrote a .py file to extend it. The .py file includes some simple functions without import any other modules. Today, I want to update my .py file and import SMTP library in the file, but it seems fail to import SMTP library. So I want to ask: when the

Re: question; C/C++ with Python

2008-12-25 Thread Gabriel Genellina
En Thu, 25 Dec 2008 12:50:31 -0200, Hongtian hongtian.i...@gmail.com escribió: I have a C/C++ application and I wrote a .py file to extend it. The .py file includes some simple functions without import any other modules. And you embedded the Python interpreter into your application, I

video lectures on C, C++, Java, Python and other programming and Computer science.

2007-04-27 Thread AK444
Hi Friends, Check here http://freevideolectures.com/computerscience.html for video lectures on Programming languages like C, C++, Java, COBOL etc.., OS, Algorithms, Data Structures, RDBMS, Web designing, etc.. It also has amazing collection of video lectures and animations on all

c/c++ and python

2005-09-29 Thread Mattia Adami
Hi to all! I have a little problem. I want to develop an application in c/c++ that creates a window with gtk+ accordinly to the information on a xml file. The funcions that are called for manage the event should be written in python. I don't know how to do it, can you help me? Is it possible?

Re: c/c++ and python

2005-09-29 Thread Alessandro Bottoni
Mattia Adami wrote: Hi to all! I have a little problem. I want to develop an application in c/c++ that creates a window with gtk+ accordinly to the information on a xml file. The funcions that are called for manage the event should be written in python. I don't know how to do it, can you

Re: c/c++ and python

2005-09-29 Thread Mattia Adami
Thanks a lot, very clear and usefull anser! Yes, I know PyGTK and wxPython, but I want to develop a plugin for another application that requires c++. I guess that embedding is the appropriate way. Thanks. -- http://mail.python.org/mailman/listinfo/python-list

Re: Is there something similar to ?: operator (C/C++) in Python?

2005-06-30 Thread Antoon Pardon
Op 2005-06-29, Scott David Daniels schreef [EMAIL PROTECTED]: Roy Smith wrote: Andrew Durdin [EMAIL PROTECTED] wrote: Corrected version: result = [(lambda: expr0), lambda: expr1][bool(cond)]() Sorry, I thought cond was a standard boolean. Better is: result = [(lambda: true_expr),

Re: Is there something similar to ?: operator (C/C++) in Python?

2005-06-30 Thread Ron Adam
Antoon Pardon wrote: Op 2005-06-29, Scott David Daniels schreef [EMAIL PROTECTED]: Roy Smith wrote: Andrew Durdin [EMAIL PROTECTED] wrote: Corrected version: result = [(lambda: expr0), lambda: expr1][bool(cond)]() Sorry, I thought cond was a standard boolean. Better is: result =

Re: Is there something similar to ?: operator (C/C++) in Python?

2005-06-29 Thread Roy Smith
Andrew Durdin [EMAIL PROTECTED] wrote: Corrected version: result = [(lambda: expr0), lambda: expr1][bool(cond)]() I'd go one step further. Most people expect the first item to correspond to True and the second one to correspond to False. So: result = [(lambda: expr0), lambda:

Re: Is there something similar to ?: operator (C/C++) in Python?

2005-06-29 Thread Scott David Daniels
Roy Smith wrote: Andrew Durdin [EMAIL PROTECTED] wrote: Corrected version: result = [(lambda: expr0), lambda: expr1][bool(cond)]() Sorry, I thought cond was a standard boolean. Better is: result = [(lambda: true_expr), lambda: false_expr][not cond]() --Scott David Daniels [EMAIL

Re: Is there something similar to ?: operator (C/C++) in Python?

2005-06-28 Thread Mike Meyer
Riccardo Galli [EMAIL PROTECTED] writes: On Fri, 24 Jun 2005 09:00:04 -0500, D H wrote: Bo Peng wrote: I need to pass a bunch of parameters conditionally. In C/C++, I can do func(cond1?a:b,cond2?c:d,.) Is there an easier way to do this in Python? The answer is simply no, just use

Re: Is there something similar to ?: operator (C/C++) in Python?

2005-06-28 Thread Ron Adam
Mike Meyer wrote: Riccardo Galli [EMAIL PROTECTED] writes: On Fri, 24 Jun 2005 09:00:04 -0500, D H wrote: Bo Peng wrote: I need to pass a bunch of parameters conditionally. In C/C++, I can do func(cond1?a:b,cond2?c:d,.) Is there an easier way to do this in Python? The answer is

Re: Is there something similar to ?: operator (C/C++) in Python?

2005-06-28 Thread Scott David Daniels
Ron Adam wrote: Mike Meyer wrote: Riccardo Galli [EMAIL PROTECTED] writes: result = [value2,value1][cond] Or: result = [(lambda: expr0), lambda: expr1][cond]() Which is harder to understand than the if-based assignment even with 5-character expressions. --Scott David Daniels [EMAIL

Re: Is there something similar to ?: operator (C/C++) in Python?

2005-06-28 Thread Paul Rubin
Scott David Daniels [EMAIL PROTECTED] writes: result = [(lambda: expr0), lambda: expr1][cond]() Winner of the there should be one obvious way to do it award. ;-) -- http://mail.python.org/mailman/listinfo/python-list

Re: Is there something similar to ?: operator (C/C++) in Python?

2005-06-24 Thread D H
Peter Hansen wrote: D H wrote: Peter Hansen wrote: Bo Peng wrote: I need to pass a bunch of parameters conditionally. In C/C++, I can do func(cond1?a:b,cond2?c:d,.) Is there an easier way to do this in Python? Please read the FAQ to learn the answer and much other useful ...

Re: Is there something similar to ?: operator (C/C++) in Python?

2005-06-24 Thread Dave Brueck
D H wrote: Peter Hansen wrote: D H wrote: Peter Hansen wrote: Bo Peng wrote: Actually that's just one possible answer. Whether it's _the_ answer is obviously again a matter of opinion, and as usual we differ. Quit being such an idiot and refuting everything I say. The answer is simply no,

Re: Is there something similar to ?: operator (C/C++) in Python?

2005-06-24 Thread Richie Hindle
[Dave Brueck] Please keep the discussion civil; please help keep c.l.py a nice place to visit. +1 -- Richie Hindle [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Is there something similar to ?: operator (C/C++) in Python?

2005-06-24 Thread D H
Dave Brueck wrote: Please keep the discussion civil; please help keep c.l.py a nice place to visit. You didn't see Peter Hansen's previous post to which I made my reply, so I'd like to extend your recommendation to *everyone* here. Peter Hansen wrote: Doug, please stop making an idiot of

Re: Is there something similar to ?: operator (C/C++) in Python?

2005-06-24 Thread Riccardo Galli
On Fri, 24 Jun 2005 09:00:04 -0500, D H wrote: Bo Peng wrote: I need to pass a bunch of parameters conditionally. In C/C++, I can do func(cond1?a:b,cond2?c:d,.) Is there an easier way to do this in Python? The answer is simply no, just use an if statement instead. That's not true.

Re: Is there something similar to ?: operator (C/C++) in Python?

2005-06-24 Thread D H
Riccardo Galli wrote: On Fri, 24 Jun 2005 09:00:04 -0500, D H wrote: Bo Peng wrote: I need to pass a bunch of parameters conditionally. In C/C++, I can do func(cond1?a:b,cond2?c:d,.) Is there an easier way to do this in Python? The answer is simply no, just use an if statement

Re: Is there something similar to ?: operator (C/C++) in Python?

2005-06-24 Thread Steven D'Aprano
On Fri, 24 Jun 2005 12:54:34 -0500, D H wrote: Riccardo Galli wrote: On Fri, 24 Jun 2005 09:00:04 -0500, D H wrote: Bo Peng wrote: I need to pass a bunch of parameters conditionally. In C/C++, I can do func(cond1?a:b,cond2?c:d,.) Is there an easier way to do this in Python? The

Re: Is there something similar to ?: operator (C/C++) in Python?

2005-06-24 Thread D H
Steven D'Aprano wrote: On Fri, 24 Jun 2005 12:54:34 -0500, D H wrote: Riccardo Galli wrote: On Fri, 24 Jun 2005 09:00:04 -0500, D H wrote: Bo Peng wrote: I need to pass a bunch of parameters conditionally. In C/C++, I can do func(cond1?a:b,cond2?c:d,.) Is there an easier way to do

Re: Is there something similar to ?: operator (C/C++) in Python?

2005-06-20 Thread Ron Adam
Ron Adam wrote: You might be able to use a dictionary of tuples. call_obj = {(type_obj1,0):obj1a, (type_obj1,0):obj1b, (type_boj2,1):obj2a, (type_obj2,1):obj2b, etc... } call_obj[(type_of_obj,order)]() Regards, Ron This won't work

Re: Is there something similar to ?: operator (C/C++) in Python?

2005-06-20 Thread Peter Hansen
D H wrote: Peter Hansen wrote: Bo Peng wrote: I need to pass a bunch of parameters conditionally. In C/C++, I can do func(cond1?a:b,cond2?c:d,.) Is there an easier way to do this in Python? Please read the FAQ to learn the answer and much other useful ... The answer is no. Use if

Re: Is there something similar to ?: operator (C/C++) in Python?

2005-06-20 Thread Charles Krug
On Mon, 20 Jun 2005 06:36:42 GMT, Ron Adam [EMAIL PROTECTED] wrote: Ron Adam wrote: You might be able to use a dictionary of tuples. call_obj = {(type_obj1,0):obj1a, (type_obj1,0):obj1b, (type_boj2,1):obj2a, (type_obj2,1):obj2b, etc... }

Re: Is there something similar to ?: operator (C/C++) in Python?

2005-06-19 Thread Roy Smith
[EMAIL PROTECTED], Bo Peng [EMAIL PROTECTED] wrote: I have around 10 of them. Using these if/else, it will take 50 lines for a function call. It also bothers me to have 10 variables left in the namespace, in addition to finding 10 meaningful names. If you've got 10 different conditional

Re: Is there something similar to ?: operator (C/C++) in Python?

2005-06-19 Thread gene tani
If your test variable has specific values to branch on, the standard way is to have those values be keys in a dictionary, and do: branched_func_obj = dict_of_values.get(testvar) And the lambda hack is here, courtesy of Peter Norvig http://www.norvig.com/python-iaq.html --

Re: Is there something similar to ?: operator (C/C++) in Python?

2005-06-19 Thread Bo Peng
Roy Smith wrote: Can you give us some idea of what it is that you're trying to do? It pretty unusual to see a requirement like that. def func(type_of_obj1, type_of_obj2, .): callfunc( [ type_of_obj1 and obj1a() or obj1b(), type_of_obj2 and obj2a() or obj2b(),

Re: Is there something similar to ?: operator (C/C++) in Python?

2005-06-19 Thread Roy Smith
In article [EMAIL PROTECTED], Bo Peng [EMAIL PROTECTED] wrote: Roy Smith wrote: Can you give us some idea of what it is that you're trying to do? It pretty unusual to see a requirement like that. def func(type_of_obj1, type_of_obj2, .): callfunc( [ type_of_obj1 and

Re: Is there something similar to ?: operator (C/C++) in Python?

2005-06-19 Thread George Sakkis
Bo Peng wrote: Roy Smith wrote: Can you give us some idea of what it is that you're trying to do? It pretty unusual to see a requirement like that. def func(type_of_obj1, type_of_obj2, .): callfunc( [ type_of_obj1 and obj1a() or obj1b(), type_of_obj2 and obj2a() or

Re: Is there something similar to ?: operator (C/C++) in Python?

2005-06-19 Thread Ron Adam
Bo Peng wrote: Roy Smith wrote: Can you give us some idea of what it is that you're trying to do? It pretty unusual to see a requirement like that. def func(type_of_obj1, type_of_obj2, .): callfunc( [ type_of_obj1 and obj1a() or obj1b(), type_of_obj2 and obj2a() or

Re: Is there something similar to ?: operator (C/C++) in Python?

2005-06-19 Thread D H
Peter Hansen wrote: Bo Peng wrote: I need to pass a bunch of parameters conditionally. In C/C++, I can do func(cond1?a:b,cond2?c:d,.) Is there an easier way to do this in Python? Please read the FAQ to learn the answer and much other useful ... The answer is no. Use if

Is there something similar to ?: operator (C/C++) in Python?

2005-06-18 Thread Bo Peng
Hi, I need to pass a bunch of parameters conditionally. In C/C++, I can do func(cond1?a:b,cond2?c:d,.) In Python, I am using temporary variables like if cond1: para1 = a else: para1 = b # # a bunch of such if/else func(para1, para2,...) Is there an easier way to do this in

Re: Is there something similar to ?: operator (C/C++) in Python?

2005-06-18 Thread Roy Smith
Bo Peng [EMAIL PROTECTED] wrote: I need to pass a bunch of parameters conditionally. In C/C++, I can do func(cond1?a:b,cond2?c:d,.) Python does not have a ternary operator analogous to C's :?. There are some ugly hacks you can play with the logical operators to emulate :?, but in my

Re: Is there something similar to ?: operator (C/C++) in Python?

2005-06-18 Thread Bo Peng
In Python, I am using temporary variables like if cond1: para1 = a else: para1 = b # # a bunch of such if/else func(para1, para2,...) Yeah, that's how I would do it. How many of these things do you have? I have around 10 of them. Using these if/else, it will take 50 lines for