class Questions

7

Solved

I have a Python module that contains a number of classes, each representing a particular physical material with its properties (e.g., density, specific heat). Some of the properties are just float ...
Crinkumcrankum asked 19/2, 2014 at 14:31

6

Oftentimes when browsing code, I'll come across something like this: public class Fruity { private IOrange _Orange; public Fruity() { _Orange = new Orange() as IOrange; } public void Prepa...
Pleopod asked 5/4, 2013 at 9:43

2

I am receiving binary data in a string. I want to encode that into Base64. Is there any class to do that operation (I want an API).
Prenomen asked 17/6, 2011 at 11:50

2

Solved

I've been using Jackson to serialize/deserialize objects for years and have always found it needlessly complicated to use TypeReference<T> to deserialize List etc. I created a simple helper f...
Diseased asked 11/4, 2020 at 1:6

7

Solved

I want to make a stub to prevent time.sleep(..) to sleep to improve the unit test execution time. What I have is: import time as orgtime class time(orgtime): '''Stub for time.''' _sleep_speed_...
Steal asked 3/4, 2014 at 11:53

6

First question: I am working with pandas' DataFrames and I am frequently running the same routines as part of data pre-processing and other things. I'd like to write some of these routines as meth...
Glyco asked 21/12, 2017 at 4:19

4

Solved

The error says: AttributeError: 'list' object has no attribute 'cost' I am trying to get a simple profit calculation to work using the following class to handle a dictionary of bicycles: class...
Maxilliped asked 29/3, 2015 at 22:2

5

Solved

I had an error in a Typescript class method declaration, but I don't understand how the error message relates back to the bug. The message seems to be saying that 'this' is of type any, but we ar...
Glarum asked 19/5, 2019 at 2:44

2

I really hate to write this question because I'm kind-of "research guy" and, well, I always find what I'm searching for... But this one bugs me a lot and I can't find the answer anywhere... So, her...
Impaction asked 30/11, 2013 at 15:19

5

Solved

I recently started creating classes with powershell 5. While I was following this awesome guide https://xainey.github.io/2016/powershell-classes-and-concepts/#methods I was wondering if it is pos...
Hilde asked 5/12, 2016 at 15:17

1

Solved

I have a struct with a class member I'd like to make const because it should never be changed after the constructor: struct S { S(const double pp) : p(pp){} const double p; }; However, I ...
Titmouse asked 22/4, 2024 at 3:10

1

I have two PowerShell classes that are inter-dependent: Class A: class A { [int] hidden $i [B] hidden $b_ A([int] $i) { $this.i = $i } [void] set_b([B] $b) { $this.b_ = $b } [B] get_b(...
Capello asked 4/8, 2021 at 20:28

9

Solved

I've been cleaning up some code from a module I'm extending and I can't seem to find a way to Pythonify this code: global_next_id = 1 class Obj: def __init__(self): global global_next_id self....
Winglet asked 25/12, 2011 at 3:55

7

If I want the function name I can simply include %(funcName)s in the Formatter. But how do I get the name of the class containing the logging call instead? I've gone through the documentation for ...
Befitting asked 12/9, 2011 at 8:18

3

Solved

I have the following code: def __static_func(name): print 'Name = ' + name class A: def __init__(self, name): self.name = name def fun(self): __static_func(self.name) a = A('foo') a.fun() ...
Tearful asked 17/10, 2018 at 11:17

5

Solved

Here is the thing. I have a main class called A. I want this class to extend class B. class A extends B {} But in fact, I want the class B to extend C, D or E on a specific condition: class B e...
Leipzig asked 4/3, 2017 at 18:16

9

Solved

So I need to have some routes inside a class, but the route methods need to have the self attr (to access the class' attributes). However, FastAPI then assumes self is its own required argument and...
Morelos asked 11/9, 2020 at 20:20

7

Solved

I know that you can split a form out in twig and choose to not render the label for a particular field, but I can't help but think that you must be able to do this from the form class. The 'label' ...
Refugee asked 15/5, 2012 at 14:27

7

I am trying to run all the functions in my class without typing them out individually. class Foo(object): def __init__(self,a,b): self.a = a self.b=b def bar(self): print self.a def foobar...
Eolic asked 6/5, 2016 at 15:3

15

Solved

We're often told we should protect encapsulation by making getter and setter methods (properties in C#) for class fields, instead of exposing the fields to the outside world. But there are many tim...
Graphic asked 25/7, 2009 at 1:4

6

Solved

I have been experimenting with ES6 classes and am wondering if you can change class names dynamically? For example class [Some dynamic name] {};
Savoirfaire asked 9/11, 2015 at 9:14

14

Imagine I have a class Family. It contains a List of Person. Each (class) Person contains a (class) Address. Each (class) Address contains a (class) PostalCode. Any "intermediate" class c...
Ure asked 30/4, 2012 at 22:29

6

Solved

In Python, is it possible to get the object, say Foo, that contains another object, Bar, from within Bar itself? Here is an example of what I mean: class Foo(object): def __init__(self): self.bar...
Scruggs asked 28/5, 2012 at 23:52

16

Solved

I am using tailwindcss for the first time and especially in a react app. I followed the documentation, read some articles and watched some videos. I have my react-app running but tailwindcss classe...
Bezanson asked 27/10, 2020 at 15:28

23

Solved

It's a bit difficult to implement a deep object copy function. What steps you take to ensure the original object and the cloned one share no reference?
Avalon asked 15/9, 2008 at 15:39

© 2022 - 2025 — McMap. All rights reserved.