Skip to main content

All Questions

Tagged with
1 vote
1 answer
40 views

Triggering method with change in object property

I have an array of dataframe objects (columns of a larger dataframe) that I am passing into the Dataframe_Builder_Update class. I am able to successfully update the date and associated calculation of ...
steezebutter's user avatar
0 votes
2 answers
2k views

TypeError: object of type 'property' has no len()

I have this code of a class that contains a list _offers of custom Offer objects. For this list I created a property to allow access to it: class OffersManager: _offers: list[Offer] = [] ...
Itay Dvash's user avatar
0 votes
1 answer
386 views

How can the following: "axes.yaxis.set_major_formatter(FuncFormatter(f))" work since yaxis should be an attribute of AXIS and not of AXES objects?

Practicing on visualization as a Python newbie I have encountered this conceptual issue that got me thinking, Infact I managed to change the price format on the y axis of a boxplot , from scientific ...
Leonardo Melia's user avatar
-1 votes
1 answer
343 views

Python 3.7 Class Property Returns Object

I am trying to create a class with properties. Every time I access the property, no matter how I try, I get <property object at xxx>. I am running version 3.7.8 in Visual Studio Community 2019....
Infobound's user avatar
-1 votes
1 answer
360 views

Python: How to: attribute of an instance which depends on flag, which is itself an attribute of that instance / object

Consider the following minimal example for my question: class MyClass: a = False b = 0 if a: b = 1 MCinst = MyClass() Here MCinst has two attributes, MCinst.a and MCinst.b with ...
Britzel's user avatar
  • 235
0 votes
2 answers
457 views

Method that can alter multiple properties within an object in Python [duplicate]

I am trying to use a method within an object to selectively change specific properties of that object. I haven't been able to figure out how to get the method to recognize the values that I pass to it ...
Jack s's user avatar
  • 1
0 votes
0 answers
215 views

Python: Property setter using hasattr to provide validation and immutability

I'm using a property to provide validation and self encapsulation for attributes of a class. The attribute should also be immutable. I'm currently have something like this: def __init__(self, ...
Steven's user avatar
  • 869
2 votes
2 answers
1k views

Set default (initial) value for descriptor

Assume we got the following code: class NonNegative(): def __set_name__(self, owner, name): self.name = name def __get__(self, instance, owner): if instance is None: ...
Sebastian Nielsen's user avatar
0 votes
2 answers
364 views

How to have multiple versions of the same object, each with different properties

I'm making a text based version of Skyrim and I'm unable to find a way to make enchantments/smithing bonuses work. I have a class for weapons and a class for armor. I have an object for each weapon ...
Tyler's user avatar
  • 1
0 votes
1 answer
2k views

How to make Multiply function inside a Class Python

What am I missing here in the code or in function area? any pieces of advice? if anybody knows a very good place to study from it object-oriented programming please tell me and thanks. class Square():...
Encode.to.code's user avatar
0 votes
0 answers
83 views

Accessing Python Dictionary mappings from JSON load()

I am using JSON to parse an object to a Python object. I have an array that looks like this: arr=['a','b','c'] and the JSON data looks like this: {"a":"hhh","b":1,"c":"nnnn"} I load the data ...
Ken George's user avatar
3 votes
2 answers
140 views

how do I create a dict with all fields and properties of a python object?

Suppose if I have a class as shown below, class TestClass(object): def __init__(self): self.name = 'Marty' self.age = 25 self.place = 'CL' @property def country(...
All Іѕ Vаиітy's user avatar
5 votes
1 answer
11k views

Apply `map` over property in python

I'd like to map over a property, so I tried map(lambda o: cls.prop(o), list_of_objects) The property is defined in an external library as: @property def prop(self): However, I get a TypeError ...
A Sz's user avatar
  • 1,034
1 vote
1 answer
52 views

How to I have a default object property and have the option of setting it?

I've been reading about setting object properties, but I was confused and haven't succeeded in attempts. I want create a new object. i.e. Thissle = yt_video() Then, if I run Thissle.url I want a ...
Stack Johan's user avatar
0 votes
0 answers
23 views

Iterate & Print over each Method/Attribute of an object

I'm sure this is something simple but can't get to work. I want to iterate over all the attr and methods of a defined variable. However I keep one of 3 errors: None (returned several times) ... has ...
Kervvv's user avatar
  • 801

15 30 50 per page