1a0428e9eSAndrew Rist#************************************************************** 2cdf0e10cSrcweir# 3a0428e9eSAndrew Rist# Licensed to the Apache Software Foundation (ASF) under one 4a0428e9eSAndrew Rist# or more contributor license agreements. See the NOTICE file 5a0428e9eSAndrew Rist# distributed with this work for additional information 6a0428e9eSAndrew Rist# regarding copyright ownership. The ASF licenses this file 7a0428e9eSAndrew Rist# to you under the Apache License, Version 2.0 (the 8a0428e9eSAndrew Rist# "License"); you may not use this file except in compliance 9a0428e9eSAndrew Rist# with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir# 11a0428e9eSAndrew Rist# http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir# 13a0428e9eSAndrew Rist# Unless required by applicable law or agreed to in writing, 14a0428e9eSAndrew Rist# software distributed under the License is distributed on an 15a0428e9eSAndrew Rist# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16a0428e9eSAndrew Rist# KIND, either express or implied. See the License for the 17a0428e9eSAndrew Rist# specific language governing permissions and limitations 18a0428e9eSAndrew Rist# under the License. 19cdf0e10cSrcweir# 20a0428e9eSAndrew Rist#************************************************************** 21cdf0e10cSrcweir 22cdf0e10cSrcweir# Pseudo const 23cdf0e10cSrcweirclass _const: 24cdf0e10cSrcweir class ConstError(TypeError): pass 25cdf0e10cSrcweir def __setattr__(self, name, value): 26*7d9fa7c3SPedro Giffuni if name in self.__dict__: 27*7d9fa7c3SPedro Giffuni raise self.ConstError("Can't rebind const(%s)"%name) 28cdf0e10cSrcweir self.__dict__[name] = value 29cdf0e10cSrcweir 30cdf0e10cSrcweirimport sys 31cdf0e10cSrcweirsys.modules[__name__] = _const() 32