Show More
@@ -9,4 +9,4 b' from .widget_int import IntTextWidget, BoundedIntTextWidget, IntSliderWidget, In' | |||||
9 | from .widget_selection import RadioButtonsWidget, ToggleButtonsWidget, DropdownWidget, SelectWidget |
|
9 | from .widget_selection import RadioButtonsWidget, ToggleButtonsWidget, DropdownWidget, SelectWidget | |
10 | from .widget_selectioncontainer import TabWidget, AccordionWidget |
|
10 | from .widget_selectioncontainer import TabWidget, AccordionWidget | |
11 | from .widget_string import HTMLWidget, LatexWidget, TextWidget, TextareaWidget |
|
11 | from .widget_string import HTMLWidget, LatexWidget, TextWidget, TextareaWidget | |
12 |
from .interaction import interact, interactive, |
|
12 | from .interaction import interact, interactive, const |
@@ -246,17 +246,3 b' class const(HasTraits):' | |||||
246 | description = Unicode('', help="Any Python object") |
|
246 | description = Unicode('', help="Any Python object") | |
247 | def __init__(self, value, **kwargs): |
|
247 | def __init__(self, value, **kwargs): | |
248 | super(const, self).__init__(value=value, **kwargs) |
|
248 | super(const, self).__init__(value=value, **kwargs) | |
249 |
|
||||
250 | def annotate(**kwargs): |
|
|||
251 | """Python 3 compatible function annotation for Python 2.""" |
|
|||
252 | if not kwargs: |
|
|||
253 | raise ValueError('annotations must be provided as keyword arguments') |
|
|||
254 | def dec(f): |
|
|||
255 | if hasattr(f, '__annotations__'): |
|
|||
256 | for k, v in kwargs.items(): |
|
|||
257 | f.__annotations__[k] = v |
|
|||
258 | else: |
|
|||
259 | f.__annotations__ = kwargs |
|
|||
260 | return f |
|
|||
261 | return dec |
|
|||
262 |
|
@@ -223,6 +223,21 b' else:' | |||||
223 | filename = fname |
|
223 | filename = fname | |
224 | builtin_mod.execfile(filename, *where) |
|
224 | builtin_mod.execfile(filename, *where) | |
225 |
|
225 | |||
|
226 | ||||
|
227 | def annotate(**kwargs): | |||
|
228 | """Python 3 compatible function annotation for Python 2.""" | |||
|
229 | if not kwargs: | |||
|
230 | raise ValueError('annotations must be provided as keyword arguments') | |||
|
231 | def dec(f): | |||
|
232 | if hasattr(f, '__annotations__'): | |||
|
233 | for k, v in kwargs.items(): | |||
|
234 | f.__annotations__[k] = v | |||
|
235 | else: | |||
|
236 | f.__annotations__ = kwargs | |||
|
237 | return f | |||
|
238 | return dec | |||
|
239 | ||||
|
240 | ||||
226 | # Parts below taken from six: |
|
241 | # Parts below taken from six: | |
227 | # Copyright (c) 2010-2013 Benjamin Peterson |
|
242 | # Copyright (c) 2010-2013 Benjamin Peterson | |
228 | # |
|
243 | # |
General Comments 0
You need to be logged in to leave comments.
Login now