Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

# This file is part of the pyMOR project (http://www.pymor.org). 

# Copyright Holders: Rene Milk, Stephan Rave, Felix Schindler 

# License: BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) 

 

from __future__ import absolute_import, division, print_function 

 

 

class Named(object): 

    '''Mixin for objects with a name. 

 

    Attributes 

    ---------- 

    name 

        Property returning the object's name. If no name has 

        been set, a random name is created from the class name 

        and a uuid4. 

    ''' 

 

    __name = None 

 

    @property 

    def name(self): 

        if self.__name is None: 

            import uuid 

            self.__name = '{}_{}'.format(self.__class__.__name__, uuid.uuid4()) 

        return self.__name 

 

    @name.setter 

    def name(self, n): 

        self.__name = n