Questions tagged [self]

A keyword used in instance methods to refer to the object on which they are working.

In many object-oriented programming languages, self (also called this or Me) is a keyword that is used in instance methods to refer to the object on which they are working. Languages like and others such as , and use self. uses self or super; and languages which derive in style from it (such as , , and ) generally use this. Visual Basic uses Me.

Invoking a method on the self searches for the method implementation of the method in the usual manner, starting in the dispatch table of the receiving object’s class.

Example:

[self startThread];
self.hostReach = YES;
BOOL value = self.hostReach;

Here, self is a variable name that can be used in any number of ways, even assigned a new value.

Inside an instance method, self refers to the instance; inside a class method, self refers to the class object.

1538 questions
-1
votes
2 answers

MySQL - get min and max values for id's in group

Updated: TABLE: mydata id trans_id CURRENT CUST_DATE ------------------------------------ 16 2362 152.40 2015-05-11 16 2363 146.80 2015-05-26 16 1669 147.00 2015-06-16 16 1979 …
rdugge
  • 348
  • 1
  • 11
-1
votes
1 answer

What does __init__(self) mean in Python?

I am currently studying Python and I have seen in many source codes that uses init(self) but I do not know about it. I'm a newbie so please explain it easily.
K-C-J
  • 1
  • 3
-1
votes
1 answer

How do I remove a self ssl certificate on debian 8,?

I bought an ssl certificate and after installing it, it doesn't work. Support says i need to remove self signed certificate. I'm running on debian 8, apache2. Company is ovh. Everything is inside a vps. I've uploadd all the files where they should…
-1
votes
1 answer

Use of self when creating objects in Python

I made several classes which are doing the same thing, but I still don't completely understand the difference, and which is best to use. Also, the 4th object is not working. It says 'NameError: name 'self' is not defined', although I don't…
User01
  • 99
  • 7
-1
votes
1 answer

wxlua self changing value?

I'm trying to draw some stuff using wxlua. ExampleClass = {} function ExampleClass:New(someWxPanel) local obj = {} setmetatable(obj, self) self.__index = self self.m_panel = someWxPanel return obj end function ExampleClass:OnPaint() …
Piglet
  • 27,501
  • 3
  • 20
  • 43
-1
votes
1 answer

use timeit.Timer() to time a function with two arguments in a class

I am trying to use timeit to get the run time of one of the function in the with two arguments, but I keep getting error: cannot import name make_heap() class queueHeap(): def make_heap(self, alist): i = len(alist)//2 …
Joe
  • 1
  • 2
-1
votes
1 answer

Understanding author's choice for assigning datetime.datetime = self

I am trying to understand the following code, specifically line 5 (the line that is commented out, I commented that out myself). >>> class PartyTime(): ... def __call__(self,*args): ... imp.reload(datetime) ... …
ApathyBear
  • 9,057
  • 14
  • 56
  • 90
-1
votes
1 answer

ruby self in an instance methods in a module

class Player include Playable attr_reader :points attr_accessor :health, :name def initialize(name, health=100, points=0) @name = name.capitalize @health = health …
Jwan622
  • 11,015
  • 21
  • 88
  • 181
-1
votes
2 answers

Calling a python function that requires self

I'm trying to call a method in the class "User" in the twitter python api (Line 653): https://code.google.com/p/python-twitter/source/browse/twitter.py. All of the methods require a 'self' argument, how do I pass it to the method? I read how to use…
nick28
  • 67
  • 3
  • 15
-1
votes
1 answer

Issue when trying to initialise an annotationView

I want to convert a custom MKAnnotationView written in Obj-C to Swift and I am having an error when I want to initWithAnnotation. Below I will provide both the ObjC and The Swift code: class JPThumbnailAnnotationView:…
tudoricc
  • 709
  • 1
  • 12
  • 31
-1
votes
2 answers

Form values not passing to self in php

Rephrased Question: I'm updating a web app from a stand alone PHP page to something that is database driven and has admin controls (old page: uoflclimbingclub.com/everestchallenge/elevationcounter/). I'm using a form on two different pages: an admin…
Lei-Lonnie
  • 794
  • 11
  • 34
-1
votes
2 answers

How do I write the $_SERVER["PHP_SELF"] that's already in a php echo

I have a form that is written in PHP that will call the page upon itself (I don't know if I say this right). echo('

Voeg een loadscript toe

"…
-1
votes
1 answer

TypeError: get_edge() takes exactly 3 arguments (2 given)

I am working with a program to merge some DNA sequence, and this program got TypeError: get_edge() takes exactly 3 arguments (2 given). Is there anyway to avoid it? Here is the code: def path(self, path, flip=False): from vic.utils.iter import…
Aeron
  • 1
  • 1
-1
votes
1 answer

Make PHP methods work with both $this and self

Is it possible to simply make methods work with both static calls and instantiated object calls. For example: class MyClass { private static $instance = null; private $my_value = 'Foo'; public function __construct() { …
McShaman
  • 3,627
  • 8
  • 33
  • 46
-1
votes
1 answer

Embedded Python: TypeError: code() takes exactly 2 arguments (1 given)

Our tool has python embedded. We defined a function which takes 'two' arguments (but only one user argument): def code(self, device): return tools.code(self, device) Everything works well when they actually call the function with one…
ftl25
  • 51
  • 1
  • 6