+ 16

Why functions considered first class objects in Python

Explain me plz.

22nd May 2018, 10:35 PM
Mustafa Asaad
Mustafa Asaad - avatar
4 Antworten
+ 24
Did someone say Functional Programming? Basically, with first class functions you can use freshest programming paradigm where you hate states and embrace cosmic predestination. If you're interested, look up Functional Programming, possibly learn Haskel or something, end friendships because they cannot see the light in this dark world of state.
23rd May 2018, 6:22 AM
BlazingMagpie
BlazingMagpie - avatar
+ 11
Because it’s useful to be able to pass functions to functions and return functions from functions, for example for list manipulation via map
22nd May 2018, 11:38 PM
Max
Max - avatar
+ 5
class Cat:#giving class a name Cat def __init__(self, color, legs):#def __init__ function, argument are self,color,legs. Self-it is mandatory to put self inside it for access data inside class.color&legs are of variables like name and age self.color = color#if any function in child class contains function like Cat(x,y) x will be taken as color and y will be as legs count. self.legs = legs felix = Cat("ginger", 4)#here color is Ginger and leg is 4 rover = Cat("dog-colored", 4)#color will be dog-colored legs will be 4. stumpy = Cat("brown", 3)#here color is brown and leg is 3 Very simple:p (stumpy has 3 legs lol 😂)
21st May 2020, 11:55 AM
NARESH KUMAR
NARESH KUMAR - avatar
0
It is first object in programming we studied.
8th Nov 2022, 10:46 PM
Evgeny Popov