Python Forum
Search Results
Post Author Forum Replies Views Posted [asc]
    Thread: Flattening attribute access
Post: RE: Flattening attribute access

In my original case i get these 2 errors denpending on implimentation: from dataclasses import dataclass @dataclass class PrintMetaData: """Print meta data for attr.""" long: str abbr: ...
ruy General Coding Help 5 2,090 Jun-25-2021, 08:26 PM
    Thread: Flattening attribute access
Post: RE: Flattening attribute access

(Jun-25-2021, 07:19 PM)deanhystad Wrote: AttributeError would be the wrong type of error for this. Your code is looking for an attribute that it fails to find. That raises a NameError. I'm runing ...
ruy General Coding Help 5 2,090 Jun-25-2021, 08:18 PM
    Thread: Flattening attribute access
Post: RE: Flattening attribute access

(Jun-25-2021, 01:18 PM)deanhystad Wrote: Instead of this: try: return getattr(self.meta_data, name) except AttributeError: return self.__getattribute__(name)Y...
ruy General Coding Help 5 2,090 Jun-25-2021, 01:44 PM
    Thread: Flattening attribute access
Post: Flattening attribute access

Hi there I have a class PrintValue that contains as attribute an instances of another class PrintMetaData. In order to acess an attribute of the PrintMetaData object I would have to do something like...
ruy General Coding Help 5 2,090 Jun-25-2021, 12:09 PM
    Thread: Use of @property decorator
Post: RE: Use of @property decorator

Thanks a lot everyone. (Jun-09-2020, 04:02 PM)buran Wrote: In my opinion what you have now is better. I guess I can see why you would say so. The first code is much more simple and straightforward
ruy General Coding Help 16 6,584 Jun-09-2020, 04:57 PM
    Thread: Use of @property decorator
Post: RE: Use of @property decorator

Hi there, I've defined an attribute, wave_coef, with the property decorator. It is a function of other attributes. Is there any way to store this value and not have it calculated each time I call it?...
ruy General Coding Help 16 6,584 Jun-09-2020, 04:02 PM
    Thread: Use of @property decorator
Post: RE: Use of @property decorator

Yes my bad the self._temperature was defined in the setter. So in this example I end with the two attributes, one with the underscore one without. The one without being the one I should use to interac...
ruy General Coding Help 16 6,584 Jun-08-2020, 06:19 PM
    Thread: Use of @property decorator
Post: RE: Use of @property decorator

Thanks Yoriz, And how does python return self._temperature? That instance attribute was never definied. The interpreter actually returns self.temperature. And I noticed the in the code I posted the o...
ruy General Coding Help 16 6,584 Jun-08-2020, 06:01 PM
    Thread: Use of @property decorator
Post: Use of @property decorator

Hi there, I've noticed that when using the @property and @attribute_name.setter decorators all the examples I've found on the net always use an underscore before the variable name, even if in the __i...
ruy General Coding Help 16 6,584 Jun-08-2020, 05:11 PM
    Thread: Design of scantling calculation program. Newbie
Post: RE: Design of scantling calculation program. Newbi...

Thanls Gribouillis, that was my intuition also
ruy News and Discussions 2 2,984 Jun-03-2020, 02:37 PM
    Thread: Design of scantling calculation program. Newbie
Post: Design of scantling calculation program. Newbie

Hi there, I have basic coding knowledge and I'm trying to write my first project to hone out my skills. I've done plenty of tutorials, have a grasp on the basic syntax and logic (variables, loops, co...
ruy News and Discussions 2 2,984 Jun-02-2020, 06:59 PM

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020