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
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
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
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?
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
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
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),
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 =
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:
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
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
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
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
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
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 ...
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,
[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
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
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.
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
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
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
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
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
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... }
[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
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
--
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(),
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
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
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
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
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
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
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
35 matches
Mail list logo