Questions tagged [attributes]

The attributes tag should be used for any issues relating to a property of an object, element, or file, etc.

In computing, an attribute is a specification that defines a property of an object, element, or file. It may also refer to or set the specific value for a given instance of such.

For clarity, attributes should more correctly be considered metadata. An attribute is frequently and generally a property of a property.

However, in actual usage, the term attribute can and is often treated as equivalent to a property, depending on the technology being discussed.

An attribute of an object usually consists of a name and a value; of an element, a type or class name; of a file, a name and extension.

  • Each named attribute has an associated set of rules called operations: one doesn't sum characters or manipulate and process an integer array as an image object — one doesn't process text as type floating point (decimal numbers).
  • It follows that an object definition can be extended by imposing data typing: a representation format, a default value, and legal operations (rules) and restrictions ("Division by zero is not to be tolerated!") are all potentially involved in defining an attribute, or conversely, may be spoken of as attributes of that object's type. A JPEG file is not decoded by the same operations (however similar they may be—these are all graphics data formats) as a PNG or BMP file, nor is a floating point typed number operated upon by the rules applied to typed long integers.

See also:

13044 questions
4
votes
1 answer

Sharing initialisation of a roles attribute between the attribute and methods

I have a permissions attribute which takes a list of enum values for roles: [CheckRoles(SystemRole.ID.Admin, SystemRole.ID.User)] public class MyController : Controller { .... } However, in other parts of the code I…
Simon Parker
  • 1,656
  • 15
  • 37
4
votes
1 answer

Python MacOS Loop Files Get File Info

I am trying to loop through all mp3 files in my directory in MacOS Monterrey and for every iteration get the file's more info attributes, like Title, Duration, Authors etc. I found a post saying use xattr, but when i create a variable with xattr it…
Jorge
  • 336
  • 1
  • 4
  • 15
4
votes
0 answers

Rider shows a warning that a variable can be null even if an attribute is present that it is not null

I created a regular TryGet method, but added the NotNullWhen(true) attribute to its out parameter, which means that the variable cannot be null if the method returns true. When using the method further, Rider writes a warning that the variable can…
Nikita
  • 41
  • 1
4
votes
1 answer

Xslt using a wildcard when selecting by attribute

so I have this assignment and they are asking for data given by Xslt This is what I've got: So the $param0 is given by a jquery transform function. My problem is how can I select all of…
Sentinel
  • 197
  • 8
4
votes
1 answer

How to get the attributes override properties?

Does not work Attribute.GetCustomAttribute: using System; class Program { static void Main() { var p = typeof(MyClass2).GetProperty("Value"); var a = Attribute.GetCustomAttribute(p, typeof(ObsoleteAttribute), true); …
Anton
  • 560
  • 6
  • 21
4
votes
0 answers

How do I use attributes on fields on a custom derive macro?

I'm writing my derive macro: use proc_macro::{self, TokenStream}; #[proc_macro_derive(MyMacro, attributes(my_attr))] pub fn my_macro(input: TokenStream) -> TokenStream { ... TokenStream::from(my_generated_code) } with the attributes which will…
4
votes
3 answers

Setting MaximumLength on a StringLengthAttribute in code

I'm working on some code which use DataAnnotation attributes on viewmodels, and overrides some of the attributes programmatically under certain circumstances. Changing ErrorMessage on various types of ValidationAttributes, no problem. Changing…
Carson63000
  • 4,215
  • 2
  • 24
  • 38
4
votes
2 answers

Is it legal to create your own CSS attributes?

I'm working on a windowing application for a website of mine. Right now, I have each individual window set up as a in the body of the site. I add new windows by literally adding the appropriate code to the end of the body element, and delete them…
Blank
  • 7,088
  • 12
  • 49
  • 69
4
votes
1 answer

Can a C++20 [[likely]] or [[unlikely]] attribute be used on the condition of a do-while loop?

I have tried placing C++20's [[likely]] and [[unlikely]] attributes at various locations around the condition of a do-while loop, and it seems placing them at the end of the line after the semicolon is accepted by all three major compilers: int…
invexed
  • 645
  • 3
  • 10
4
votes
1 answer

Thread Safe Python Property/Attribute?

I have code like the following: class SomeSharedData(object): def __init__(self): self._lock = RLock() self._errors = 0 @property def errors(self): with self._lock: return self._errors …
morrog
  • 664
  • 1
  • 8
  • 17
4
votes
0 answers

Prettier: error formatting valid handlebars/html code

This is my first interaction on Stackoverflow! Is there a way, under vscode, using prettier or another solution, to format the following handlebars/HTML template:
Click…
4
votes
1 answer

what should be x in __attribute__ ((aligned(x)))

I get it that variable alignment is needed for efficiency. What I do not get is how to determine the proper size of the alignment. From my understanding aligned value should always be set to the word size of the processor (i.e 4 bytes on a 32 bit…
nik
  • 8,387
  • 13
  • 36
  • 44
4
votes
1 answer

XPath doesn't match attributes without namespace as prefix

Currently I'm trying to read different install.rdf files of Firefox extensions via PHP's SimpleXML. Unfortunately there's no predefined structure how they have to look. They are always using two namespaces,…
Sebastian Zartner
  • 18,808
  • 10
  • 90
  • 132
4
votes
2 answers

python not recognizing function within imported module

I am working in Jupyter notebook. I created a simple module called conv.py for converting miles to km. When I try to import this module in a separate code (in the same directory) the import seems to go successfully but it doesn't recognize either of…
ningineering
  • 61
  • 1
  • 5
4
votes
2 answers

jQuery maxlength attribute problem with textareas

With jQuery version 1.2.3 I'm trying to add nodes after textarea elements with attribute 'maxlength' but it doesn't work: $("textarea[@maxlength]").after("Aint working"); This is the HTML code: