| Server IP : 217.160.0.135 / Your IP : 216.73.216.115 Web Server : Apache System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64 User : sws1074145052 ( 1074145052) PHP Version : 8.3.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /lib/python3/dist-packages/ipython_genutils/__pycache__/ |
Upload File : |
�
��X�+ � �, � d Z dgZ G d� de� � ZdS )zyA dict subclass that supports attribute style access.
Can probably be replaced by types.SimpleNamespace from Python 3.3
�Structc �n � e Zd ZdZdZd� Zd� Zd� Zd� Zd� Z d� Z
d � Zd
� Zd� Z
d� Zd
� Zd� Zdd�Zdd�ZdS )r aY A dict subclass with attribute style access.
This dict subclass has a a few extra features:
* Attribute style access.
* Protection of class members (like keys, items) when using attribute
style access.
* The ability to restrict assignment to only existing keys.
* Intelligent merging.
* Overloaded operators.
Tc �h � t � | dd� � t j | g|�R i |�� dS )a� Initialize with a dictionary, another Struct, or data.
Parameters
----------
args : dict, Struct
Initialize with one dict or Struct
kw : dict
Initialize with key, value pairs.
Examples
--------
>>> s = Struct(a=10,b=30)
>>> s.a
10
>>> s.b
30
>>> s2 = Struct(s,c=30)
>>> sorted(s2.keys())
['a', 'b', 'c']
� _allownewTN)�object�__setattr__�dict�__init__)�self�args�kws �;/usr/lib/python3/dist-packages/ipython_genutils/ipstruct.pyr zStruct.__init__ sB � �, ���4��d�3�3�3��
�d�(�T�(�(�(�R�(�(�(�(�(� c �x � | j s|| vrt d|z � � �t � | ||� � dS )a{ Set an item with check for allownew.
Examples
--------
>>> s = Struct()
>>> s['a'] = 10
>>> s.allow_new_attr(False)
>>> s['a'] = 10
>>> s['a']
10
>>> try:
... s['b'] = 20
... except KeyError:
... print('this is not allowed')
...
this is not allowed
z8can't create new attribute %s when allow_new_attr(False)N)r �KeyErrorr �__setitem__)r
�key�values r
r zStruct.__setitem__3 sR � �&