python (65.1k questions)
javascript (44.2k questions)
reactjs (22.7k questions)
java (20.8k questions)
c# (17.4k questions)
html (16.3k questions)
r (13.7k questions)
android (12.9k questions)
creating an object from a class in python in shortest form
I have this class in python, for crating an empty Box type dictionary, Box is a library for extending ways of working with dictionaries:
from box import Box
class Ipsm():
def __init__(self):
...
JON
Votes: 0
Answers: 1
Python, refrencing class variables with self in method declaration
I'm trying to reference a variable tha I declared in init as a default value for one of my class methods but i get the NameError: name 'self' is not defined.
class A:
def __init__(self, f):
...
erfan moradzadeh
Votes: 0
Answers: 2
How to create a Python dataclass with a prop that depends on the output from a default_factory
I'm trying to use the dataclasses default_factory field to dynamically add a property (id) while also still being able to create a subsequent property (id_with_appended_str) whose default value depend...
Jamie.Sgro
Votes: 0
Answers: 0
What is the 'self' keyword doing exactly in this Class method?
class Restaurant
attr_accessor :average_rating, :city
def initialize(city, name)
@city = city
@name = name
@number_of_ratings = 0
@sum_of_ratings = 0
end
def rate(new_rate...
BuiltByDan
Votes: 0
Answers: 2