473,467 Members | 1,550 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Do int.__lt__/__gt__/etc. exist?

I'm just curious. I've been trying to demonstrate functional thinking
in Python, but I can't find these methods for int objects. It would be
immensely helpful for something like:

filter(4 .__lt__, range(10))

As opposed to:

filter(lambda a: 4 < a, range(10))
Sep 7 '05 #1
2 1576
On Wed, 07 Sep 2005 00:02:49 GMT
Chris Dutton wrote:
I'm just curious. I've been trying to demonstrate functional thinking
in Python, but I can't find these methods for int objects. It would be
immensely helpful for something like:

filter(4 .__lt__, range(10))

As opposed to:

filter(lambda a: 4 < a, range(10))


Python is neither pure object nor pure functional language. There is an
"operator" module, with its operator.lt, but it is not exactly what you need.
You still need lambda with it.

The recommended way to do what you want is

result = [x for x in xrange(10) if 4 < x]

--
jk
Sep 7 '05 #2

"Chris Dutton" <cd*****@gmail.com> wrote in message
news:J6qTe.120678$Hk.14664@pd7tw1no...
I'm just curious. I've been trying to demonstrate functional thinking
in Python, but I can't find these methods for int objects. It would be
immensely helpful for something like:

filter(4 .__lt__, range(10))


Do dir(int) and you will find that int has .__cmp__ but not the individual
compares (at least in 2.2).

tjr

Sep 7 '05 #3

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

Similar topics

9
by: jeanfor | last post by:
I get a http 500 error on all asp pages. When turning off the friendly message box, the message is "Class does not exist". What is the fix for that? This affect all asp pages incling the default...
12
by: zhisol | last post by:
how can i check if file exist in current directory (in javascript)? -- pozdr;) zhisol
0
by: Dirk Försterling | last post by:
Hi all, a few days ago, I upgraded from PostgreSQL 7.2.1 to 7.4, following the instructions in the INSTALL file, including dump and restore. All this worked fine without any error (message). ...
4
by: Mike | last post by:
Hi, I am looking for function in .Net library that let me know if exist any file if I specified template. Eg: I specify "*.txt" and if any file (1.txt, 2.txt, .. ) exists then I can get True...
52
by: paytam | last post by:
Hi all Can anyone tell me how can I check that a file exist or no.I mean when you use this commands FILE *fp; if(!fp) //Could not open the file doen't show why it can not open it,may be the...
9
by: Emanuele Aina | last post by:
I have some code which does a lot of "in" on lists containing objects with no __eq__ defined. It all goes fast until I add the __lt__() method: then I have a slowdown comparable to the one I get...
1
by: sword | last post by:
This my first starting a new topic in English. I want to ask if I want to judge whether a file exists how I should do. I program with C++. Thank you.
3
by: kang jia | last post by:
hi, currently i am doing booking car online and one of the function is cancel and update booking. if the booking number users entered in is not exist. it will redirect the page stating that the...
3
by: moltendorf | last post by:
I copied the files from my "test" database on my old server (MySQL was not running) to my new server ("./mysql/data/test" folder), and after starting the server, SHOW TABLES; shows all of the tables...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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...
0
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.