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:

11810 questions
1914
votes
15 answers

How to know if an object has an attribute in Python

Is there a way in Python to determine if an object has some attribute? For example: >>> a = SomeClass() >>> a.someProperty = value >>> a.property Traceback (most recent call last): File "", line 1, in AttributeError: SomeClass…
Lucas Gabriel Sánchez
  • 34,344
  • 20
  • 53
  • 81
886
votes
7 answers

What are differences between AssemblyVersion, AssemblyFileVersion and AssemblyInformationalVersion?

There are three assembly version attributes. What are differences? Is it ok if I use AssemblyVersion and ignore the rest? MSDN says: AssemblyVersion: Specifies the version of the assembly being attributed. AssemblyFileVersion: Instructs a…
Jakub Šturc
  • 32,938
  • 24
  • 85
  • 107
781
votes
20 answers

Difference between id and name attributes in HTML

What is the difference between the id and name attributes? They both seem to serve the same purpose of providing an identifier. I would like to know (specifically with regards to HTML forms) whether or not using both is necessary or encouraged for…
yogibear
  • 12,787
  • 8
  • 27
  • 30
527
votes
5 answers

Why use Ruby's attr_accessor, attr_reader and attr_writer?

Ruby has this handy and convenient way to share instance variables by using keys like attr_accessor :var attr_reader :var attr_writer :var Why would I choose attr_reader or attr_writer if I could simply use attr_accessor? Is there something like…
Voldemort
  • 17,051
  • 43
  • 135
  • 257
395
votes
14 answers

Python dictionary from an object's fields

Do you know if there is a built-in function to build a dictionary from an arbitrary object? I'd like to do something like this: >>> class Foo: ... bar = 'hello' ... baz = 'world' ... >>> f = Foo() >>> props(f) { 'bar' : 'hello', 'baz' :…
Julio César
  • 10,916
  • 9
  • 34
  • 44
357
votes
1 answer

List view getListItemXmlAttributes method fails with child publication items

I have created a JS class to populate SG/Folder list view data, when items are modified. (As per Jaime's approach) Everything works great when I operate on items in the publication they're created in. Ex: I open a component or page and the custom…
Warner Soditus
  • 4,133
  • 2
  • 12
  • 10
350
votes
16 answers

How can I create an object and add attributes to it?

I want to create a dynamic object (inside another object) in Python and then add attributes to it. I tried: obj = someobject obj.a = object() setattr(obj.a, 'somefield', 'somevalue') but this didn't work. Any ideas? edit: I am setting the…
John
  • 18,327
  • 36
  • 105
  • 149
347
votes
27 answers

Accessing dict keys like an attribute?

I find it more convenient to access dict keys as obj.foo instead of obj['foo'], so I wrote this snippet: class AttributeDict(dict): def __getattr__(self, attr): return self[attr] def __setattr__(self, attr, value): self[attr]…
Izz ad-Din Ruhulessin
  • 5,245
  • 7
  • 24
  • 27
339
votes
5 answers

Specify multiple attribute selectors in CSS

What is the syntax for doing something like: input[name="Sex" AND value="M"] Basically, I want to select the input element that has the attribute name="Sex" as well as the attribute value="M": Elements…
John
  • 28,573
  • 67
  • 217
  • 373
314
votes
22 answers

private final static attribute vs private final attribute

In Java, what's the difference between: private final static int NUMBER = 10; and private final int NUMBER = 10; Both are private and final, the difference is the static attribute. What's better? And why?
okami
284
votes
5 answers

How do I remove the "extended attributes" on a file in Mac OS X?

I have an AppleScript script that runs a stress test. Part of the test is to open, save, and close certain files. Somehow, the files have picked up some "extended attributes" that prohibit the files from being saved. That causes the stress test to…
tames
  • 2,849
  • 3
  • 15
  • 4
282
votes
2 answers

correct way to define class variables in Python

I noticed that in Python, people initialize their class attributes in two different ways. The first way is like this: class MyClass: __element1 = 123 __element2 = "this is Africa" def __init__(self): #pass or something else The other…
jeanc
  • 3,723
  • 4
  • 18
  • 26
257
votes
10 answers

When to use setAttribute vs .attribute= in JavaScript?

Has a best-practice around using setAttribute instead of the dot (.) attribute notation been developed? E.g.: myObj.setAttribute("className", "nameOfClass"); myObj.setAttribute("id", "someID"); or myObj.className = "nameOfClass"; myObj.id =…
Francisc
  • 66,160
  • 57
  • 172
  • 264
253
votes
15 answers

Select elements by attribute

I have a collection of checkboxes with generated ids and some of them have an extra attribute. Is it possible to use JQuery to check if an element has a specific attribute? For example, can I verify if the following element has the attribute…
Ciprian Grosu
  • 2,821
  • 3
  • 18
  • 14
247
votes
7 answers

How to change an element's title attribute using jQuery

I have an form input element and want to change its title attribute. This has to be easy as pie, but for some reason I cannot find how to do this. How is this done, and where and how should I be searching on how to do this?
Brian
  • 7,505
  • 8
  • 32
  • 28
1
2 3
99 100