~jasper/type_stack_calc

ref: 6aca66fb1a7cf1e10f7dd3263f04537c8ff37590 type_stack_calc/type_stack_calc/base/named.py -rw-r--r-- 413 bytes
6aca66fb — Jasper den Ouden Apparently `to_c` can already read ahead one, hopefully its this simple... 1 year, 1 month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
class Named:
    """Adds a name and/or waits for it be notified of a name."""
    def __init__(self, name=None):
        self.given_name, self.seen_name = name, None

    @property
    def name(self): return self.given_name or self.seen_name
 
    @property
    def c_name(self): return self.given_name or self.seen_name

    def notify_name(self, name):
        if self.seen_name is None: self.seen_name = name