self Questions

1

Solved

This is cobbled together to illustrate the problem that I have with the switch function. I do not have problem printing "Left" "Right" endlessly. The point of switch is to swap the value of enum t...
Scuba asked 2/5, 2018 at 10:51

18

I'm learning the Python programming language and I've came across something I don't fully understand. In a method like: def method(self, blah): def __init__(?): .... .... What does se...
Kwangchowan asked 9/3, 2009 at 5:9

5

Solved

I read here that "self Refers to the current window or form". Self does not seem to refer to the current form in this case: <form><input type="text" onkeyup="alert(self.foo.value)" name...
Buss asked 9/7, 2010 at 20:45

1

Solved

I fully understand what is being passed to self in this example. I'm very confused on how it is being passed to self internally. Could someone help me understand? class Cars: def __init__(self, ...
Risley asked 23/3, 2018 at 3:44

2

Solved

I recently read the following line of code: use fmt::{self, Debug}; What does the self keyword in the above statement mean?
Neurotic asked 8/3, 2018 at 23:14

1

Solved

I'm trying to understand if there are differences between self and cls but I'm struggling, even though a lot of discussion on this topic exists. For instance: class maclass(): A = "class method" ...
Expurgate asked 20/2, 2018 at 8:0

2

Solved

In Raymond Hettinger's talk "Super considered super speak" at PyCon 2015 he explains the advantages of using super in Python in multiple inheritance context. This is one of the examples that Raymon...
Extramarital asked 4/5, 2015 at 23:23

3

Solved

Is it possible to access classes/objects reffered as self, static and $this in anonymous callbacks in PHP? Just like this: class Foo { const BAZ = 5; public static function bar() { echo self::B...
Elah asked 25/2, 2012 at 17:35

4

Solved

Question: when do I need to use self in my models in Rails? I have a set method in one of my models. class SomeData < ActiveRecord::Base def set_active_flag(val) self.active_flag = val self...

6

Solved

What does self mean in Objective-C? When and where should I use it? Is it similar to this in Java?
Errantry asked 21/8, 2009 at 11:50

2

Solved

if (view.annotation.title as String!) == "Helgoland " { currentLong = 7.889021 currentLat = 54.180210 url = "google.com" let alertController: UIAlertController = UIAlertController(title: "Cha...
Kiyohara asked 25/9, 2014 at 13:17

2

Solved

I got a small problem, let me start with the code class ViewController: UIViewController { @IBOutlet weak var LBoutput: UILabel! @IBAction func BTclick(sender: AnyObject) { var url = NSURL(stri...
Consalve asked 1/9, 2014 at 10:5

1

Solved

I'm brand new to Python, and I'm trying to learn how to work with classes. Does anyone know how come this is not working? Any additional tips about the keyword "self" would be greatly appreci...
Rochelrochell asked 13/6, 2017 at 4:52

1

Solved

I have a python class which has multiple methods. I have defined my methods via @staticmethod instance and I want to call other methods of my class from inside my main function(main_function). I th...
Murray asked 30/5, 2017 at 8:58

1

Solved

I am trying to use a method as a constructor inside another method. But when I do this I get the following TypeError: TypeError: function is not a constructor (evaluating 'new self.f(1)') and exa...
Endomorphic asked 17/4, 2017 at 8:8

3

Solved

class Neuralnetwork(object): def __init__(self, data): self.data = data def scan(self): print(self.data) def sigmoid(self, z): g = 1 / (1 + math.exp(-z)) return (g) a1 = sigmoid(7) pr...
Laborious asked 14/4, 2017 at 14:44

5

I'm new to coding and picked up some open source project to get the idea. I'm getting the error: Ambiguous reference to member 'subscript' in the code below: let pictures = ( selectedRestaur...
Brandnew asked 25/1, 2016 at 14:37

3

Solved

I am following Michael Hartl's RoR tutorial, and it is covering the basics of password encryption. This is the User model as it currently stands: class User < ActiveRecord::Base attr_accessor ...
Spinneret asked 13/6, 2011 at 6:12

1

Solved

I'm trying to write a class to randomly pick a number of songs from a dictionary. The whole point of it is to be able to simply type DJ.chooseListing() for example to execute the random selec...
Whimsical asked 23/2, 2017 at 20:47

1

Solved

I have a python script that contains a class. This class has a __del__ method for usual cleanup. If I delete the class during the normal execution of the script, I want some cleanup to be done. ...
Faso asked 20/1, 2017 at 14:15

1

Solved

I recently noticed that some codes do init of instances like ClassName.self() for example: let realm = try! Realm.self() From the output and the usage thereafter, it is just like as though witho...
Beaming asked 12/12, 2016 at 9:3

2

Solved

When implementing a trait, we often use the keyword self, a sample is as follows. I want to understand the representation of the many uses of self in this code sample. struct Circle { x: f64, y...
Crowboot asked 1/11, 2016 at 6:56

2

Solved

I was under the impression that methods within Python classes always require the self argument (I know that it doesn't actually have to be self, just some keyword). But, this class that I wrote doe...
Supermundane asked 1/10, 2016 at 7:10

4

Solved

In Python, this code is valid: class A: def __init__(me): me.foo = 17 def print_foo(myself): print(myself.foo) def set_foo(i, v): i.foo = v As you might already have noticed, the self p...
Restaurant asked 17/6, 2016 at 15:32

4

This question is in relation to posts at What does 'super' do in Python? , How do I initialize the base (super) class? , and Python: How do I make a subclass from a superclass? which descri...
Pascha asked 11/4, 2016 at 18:58

© 2022 - 2024 — McMap. All rights reserved.