What is the key difference between self in ruby and self in python

0 votes
What are the domains where ruby is preferred over python?
Jul 26, 2019 in Python by Waseem
• 4,540 points
1,084 views

1 answer to this question.

0 votes

Ruby and Python are actually very different languages (although they do share many similarities) even if Ruby has a syntax that can be written to look like Python (with the inclusion of end keywords) ;-)

Ruby is message-based (it was heavily influenced by SmallTalk-80) and "messages" are sent to objects. Ruby supports an implicit receiver (explicitly known as self) for a given scope. In Ruby self is not a variable, but rather an expression that evaluates to the current object context.

Python is property-based (for lack of a better term I know) and is thus more similar to SELF and JavaScript as functions are executed directly (instead of messages being passed). Python has no self keyword and it is merely convention that self is used as the name of the first parameter of a method -- which is how Python passes around the current object context.

answered Jul 30, 2019 by Mohammad
• 3,230 points

Related Questions In Python

+1 vote
1 answer

What is the difference between range and xrange functions in Python 2.X?

xrange only stores the range params and ...READ MORE

answered Aug 22, 2018 in Python by Priyaj
• 58,020 points
2,394 views
0 votes
5 answers
+2 votes
2 answers

What is the difference between print and return in python?

Return statements end the execution of a ...READ MORE

answered Aug 26, 2019 in Python by anonymous
8,034 views
0 votes
0 answers

What is the difference between isdigit, isnumeric and isdecimal in python?

Can you give examples for each of ...READ MORE

May 31, 2019 in Python by Waseem
• 4,540 points
2,256 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,434 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,790 points
4,070 views
0 votes
1 answer

What are the key differences between python and java?

There are a lot of pressing  topics ...READ MORE

answered Aug 2, 2019 in Python by Mohammad
• 3,230 points
687 views
0 votes
1 answer

What are the key differences between python 2 and python 3?

The key differences include changes in the ...READ MORE

answered Aug 14, 2019 in Python by Mohammad
• 3,230 points
1,062 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP