~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/_static_tuple_py.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-10-17 01:21:38 UTC
  • mfrom: (4739.4.2 2.1-st-from-sequence)
  • Revision ID: pqm@pqm.ubuntu.com-20091017012138-b962gzlvdccl73ut
(jam) Add StaticTuple.from_sequence()

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
    def intern(self):
52
52
        return _interned_tuples.setdefault(self, self)
53
53
 
 
54
    @staticmethod
 
55
    def from_sequence(seq):
 
56
        """Convert a sequence object into a StaticTuple instance."""
 
57
        if isinstance(seq, StaticTuple):
 
58
            # it already is
 
59
            return seq
 
60
        return StaticTuple(*seq)
 
61
 
 
62
 
54
63
 
55
64
# Have to set it to None first, so that __new__ can determine whether
56
65
# the _empty_tuple singleton has been created yet or not.