473,654 Members | 3,107 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to convert a ">" into a >

Hello All,

In a wx GUI, I would like to let the user choose between >, < or =.
So, I created a combobox and when the user chooses ">" for instance, I
wanted to return (the objective is to send the operator into another
complex method):
Example:
if variable == ">":
return >

But this is invalid syntax.

How can I transform a ">" into the operator ie without parenthesis,
so that I can load it into another function ?

Thanks in advance

Dominique
Jun 27 '08 #1
4 1206
On Jun 21, 9:17 pm, dominique <MyDom...@gmail .comwrote:
Hello All,

In a wx GUI, I would like to let the user choose between >, < or =.
So, I created a combobox and when the user chooses ">" for instance, I
wanted to return (the objective is to send the operator into another
complex method):
Example:
if variable == ">":
return >

But this is invalid syntax.

How can I transform a ">" into the operator ie without parenthesis,
so that I can load it into another function ?
Look at the operator module. In your above example:

return {
'>': operator.gt,
'=': operator.eq,
'<': operator.lt,
}[variable]

Cheers,
John
Jun 27 '08 #2
On Jun 21, 1:37 pm, John Machin <sjmac...@lexic on.netwrote:
>
Look at the operator module. In your above example:

return {
'>': operator.gt,
'=': operator.eq,
'<': operator.lt,
}[variable]

Cheers,
John
Thanks a lot John
Dominique
Jun 27 '08 #3
dominique <My******@gmail .comwrote:
>On Jun 21, 1:37 pm, John Machin <sjmac...@lexic on.netwrote:
>>
Look at the operator module. In your above example:

return {
'>': operator.gt,
'=': operator.eq,
'<': operator.lt,
}[variable]

Thanks a lot John
Dominique
Yes, but you need to remember that what you are getting is not literally an
operator. That is, if you store that return value in a variable called
"op", you can't say this:

if x op y:
....

Instead, what you have is a function, so you'll have to write it:

if op( x, y ):
--
Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Jun 27 '08 #4
On Jun 22, 6:45 am, Tim Roberts <t...@probo.com wrote:
dominique <MyDom...@gmail .comwrote:
On Jun 21, 1:37 pm, John Machin <sjmac...@lexic on.netwrote:
Look at the operator module. In your above example:
return {
'>': operator.gt,
'=': operator.eq,
'<': operator.lt,
}[variable]
Thanks a lot John
Dominique

Yes, but you need to remember that what you are getting is not literally an
operator. That is, if you store that return value in a variable called
"op", you can't say this:

if x op y:
....

Instead, what you have is a function, so you'll have to write it:

if op( x, y ):
--
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.
Thanks for the tip.
Dominique
Jun 27 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2793
by: Eric A. Forgy | last post by:
Hello, I am just learning Java and am trying to write a method that does something like //=========================================== public Static List find(double array,double val,String relationalOp) { List list = new ArrayList();
1
6820
by: Christian Schmidbauer | last post by:
Hello! I prepare my XML document like this way: ------------------------------------------------------- PrintWriter writer; Document domDocument; Element domElement; // Root tag
7
2086
by: Diandian Zhang | last post by:
Does anyone have an idea, how to do it? Thanks in advance!
6
1417
by: Eidolon | last post by:
Anyone know of a way, or a control, which would allow me to clip text with a "..." displayed at the end? We have a product comparison page, with products lied up side by side... one of the fields displayed is the manufacturer, and some of them have VERY long names, so id like to when the name is long, convert it from "Mr Joe Shmoes Super Duper Electronics Builder" to "Mr Joe Shmoes Sup..." instead of having it crunch all the other...
2
6838
by: andrew007 | last post by:
I do xml / xslt transformation using asp.net but I found any value (w/xml format) in xml node html-encoded to &lt and &gt format if it's > or < tag. Since I have sub xml data in a parent xml node as a value. Check out the following problem. I want to convert the value in <WpDatesXml> node to have a valid "<" and ">" instead of &lt or &gt format so that I can use this xml for another use. Please help! <NewDataSet> <Table1>
0
1565
by: ZSP747 | last post by:
Now,I prepare to write a English-Chinese dictionary.So I want find a function or library can convert the words from one form to another,such as "boys"->"boy","became->become","went"->"go". Because there is so many unregular convertions in English then I think it will be a hard work if do it by myself. Thanks.
5
1790
by: ZSP747 | last post by:
Now,I prepare to write a English-Chinese dictionary. So I want find a function or library can convert the words from one form to another,such as "boys"->"boy","became->become","went"->"go". Because there is so many unregular convertions in English then I think it will be a hard work if do it by myself. Thanks.
5
2648
by: John Nagle | last post by:
This, which is from a real web site, went into BeautifulSoup: <param name="movie" value="/images/offersBanners/sw04.swf?binfot=We offer fantastic rates for selected weeks or days!!&blinkt=Click here And this came out, via prettify: <addresssnippet siteurl="http%3A//apartmentsapart.com" url="http%3A//www.apartmentsapart.com/Europe/Spain/Madrid/FAQ"> <param name="movie" value="/images/offersBanners/sw04.swf?binfot=We offer
1
4308
by: ismailc | last post by:
Hi, I need help please. Update system to to new version & moved on to .Net2 But now my code that worked in my .Net1 xslt does not work. .Net1 fine: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:asp="remove" xmlns:igchart="remove" xmlns:igsch="remove"> &lt;td class='rowDet' id="td_<xsl:value-of select='@name' />"&gt; .Net2 don't work: <xsl:stylesheet...
0
8375
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8290
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8707
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7306
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6161
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5622
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4294
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2714
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1916
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.