Package pyxb :: Package utils :: Module types_
[hide private]
[frames] | no frames]

Source Code for Module pyxb.utils.types_

 1  # -*- coding: utf-8 -*- 
 2  # Copyright 2013, Peter A. Bigot 
 3  # 
 4  # Licensed under the Apache License, Version 2.0 (the "License"); you may 
 5  # not use this file except in compliance with the License. You may obtain a 
 6  # copy of the License at: 
 7  # 
 8  #            http://www.apache.org/licenses/LICENSE-2.0 
 9  # 
10  # Unless required by applicable law or agreed to in writing, software 
11  # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 
12  # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 
13  # License for the specific language governing permissions and limitations 
14  # under the License. 
15   
16  """This module provides references to built-in Python types. 
17   
18  In Python 2.x these are in the types module.  In Python 3. those 
19  references have been removed in favor of explicit use of the natural 
20  Python type.  We need these in contexts where the binding of the type 
21  identifier (e.g., C{int}) has changed to the class representing the 
22  XML Schema datatype of the same name (viz., C{xsd:int} or 
23  L{pyxb.binding.datatypes.int}), so provide a way to get back to the 
24  underlying Python type. 
25  """ 
26   
27  # This module has to be types_ else the following import tries to 
28  # read this module.  Hurrah for eliminating relative imports! 
29  import types 
30   
31  IntType = types.IntType 
32  """The type underlying C{int}.""" 
33   
34  LongType = types.LongType 
35  """The type underlying C{long} (for Python 2).  Same as L{IntType} in Python 3.""" 
36   
37  FloatType = types.FloatType 
38  """The type underlying C{float}""" 
39   
40  StringTypes = types.StringTypes 
41  """The type underlying generic text types.  This changes from Python 2 (C{basestr}) to Python 3 (C{str}).""" 
42   
43  BooleanType = types.BooleanType 
44  """The type underlying C{bool}""" 
45   
46  ListType = types.ListType 
47  """The type underlying C{list}""" 
48   
49  TextType = types.UnicodeType    #!python3! 
50  #python3:TextType = str 
51  """The type used to represent text in either Python 2 (C{unicode}) or Python 3 (C{str}).""" 
52   
53  DataType = types.StringType     #!python3! 
54  #python3:DataType = bytes 
55  """The type used to represent data (8-bit) in either Python 2 (C{str}) or Python 3 (C{bytes}).""" 
56