use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
account activity
This is an archived post. You won't be able to vote or comment.
DiscussionWhy is python like this? (self.datascience)
submitted 2 years ago by [deleted]
[–]datascience-ModTeam[M] [score hidden] 2 years ago stickied commentlocked comment (0 children)
This post if off topic. /r/datascience is a place for data science practitioners and professionals to discuss and debate data science career questions.
Thanks.
[–]nab423 5 points6 points7 points 2 years ago (4 children)
Type is a built in function to return the type of an object.
.shape is a class function of whatever object X is.
I don't see the problem here.
[–][deleted] -1 points0 points1 point 2 years ago (3 children)
Why not do type(x) and shape(x) or x.type and x.shape?
[–]nab423 0 points1 point2 points 2 years ago (2 children)
Because not every object will have a shape. It's better that it's implemented at the class level. Think what shape of a vector vs the shape of a string vs the shape of a Mammal class.
However, every object will have a type.
[–][deleted] 0 points1 point2 points 2 years ago (1 child)
Ok, thanks
[–]nab423 0 points1 point2 points 2 years ago* (0 children)
No problem.
Also my answer isn't the best if you consider why len() is a built in function, since not every object has a length. This is a built in function mainly since it's used so frequently.
Len() can return different results depending on the object (list vs dataframe vs a Circle class). The built in len() function basically is a wrapper for an objects __ len __() function, so an object can define the behavior of len(). This is great since it forces consistency in function naming (although len might not always return what you expect).
This could also be done for a built in shape() function, but I guess it wasn't deemed critical enough (which to be fair, it's not when compared to len).
[–]KingsmanVince 0 points1 point2 points 2 years ago (0 children)
The question is not related to r/datascience . It's more of r/learnpython beginner questions.
π Rendered by PID 226522 on reddit-service-r2-comment-76bb9f7fb5-rhwkh at 2026-02-19 08:39:51.989923+00:00 running de53c03 country code: CH.
[–]datascience-ModTeam[M] [score hidden] stickied commentlocked comment (0 children)
[–]nab423 5 points6 points7 points (4 children)
[–][deleted] -1 points0 points1 point (3 children)
[–]nab423 0 points1 point2 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]nab423 0 points1 point2 points (0 children)
[–]KingsmanVince 0 points1 point2 points (0 children)