<｜begin▁of▁sentence｜>### Instruction:
Given a NetworkX graph with weighted edges, how can you create a custom class to encapsulate the attributes of the edges, specifically focusing on the 'weight' attribute?
### Response:
```python
import networkx as nx
from random import randint

# Create an example graph with random edge attributes
g = nx.Graph()
[g.add_edge(i, i+1, weight=randint(1,10)) for i in range(5)]

# Function to initialize AttributeSpecification with custom attributes
class AttributeSpecification:
    def __init__(self, graph, attr_name):
        self.graph = graph
        self.attr_name = attr_name
        self.attributes = {edge: data[attr_name] for edge, data in self.graph.edges.items()}

# Initialize AttributeSpecification with the 'weight' attribute
attribute_spec = AttributeSpecification(g, 'weight')
print(attribute_spec.attributes)
```
<|EOT|>
