Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python's equivalent of C# LINQ's select

Tags:


I'm quite new to python, and happen to have used C# for some time now. I saw that there was a filter method to use with the collections, which seems to be the equivalent of the LINQ's where clause.
I wondered, is there also an equivalent for the LINQ's select statement in python?
Example: my_collection.select(my_object => my_object.my_property) would return a collection of the my_property of each object in my_collection.

like image 488
Alexandre Deschamps Avatar asked Nov 05 '10 02:11

Alexandre Deschamps


People also ask

Is Python similar to C?

Python is an interpreted, high-level, general-purpose programming language. C is a general-purpose, procedural computer programming language. Interpreted programs execute slower as compared to compiled programs. Compiled programs execute faster as compared to interpreted programs.

Is Python a version of C?

CPython is the reference implementation of the Python programming language. Written in C and Python, CPython is the default and most widely used implementation of the Python language. CPython can be defined as both an interpreter and a compiler as it compiles Python code into bytecode before interpreting it.

Is Python coded with C?

Python code can make calls directly into C modules. Those C modules can be either generic C libraries or libraries built specifically to work with Python. Cython generates the second kind of module: C libraries that talk to Python's internals, and that can be bundled with existing Python code.

What does C stand for in Python?

c command Specify the command to execute (see next section). This terminates the option list (following options are passed as arguments to the command). - anything afterward is passed as options to python script or command, not interpreted as an option to interpreter itself.


1 Answers

[my_object.my_property for my_object in my_collection] 
like image 115
Ignacio Vazquez-Abrams Avatar answered Sep 27 '22 22:09

Ignacio Vazquez-Abrams