
    Ed'                     \    d dl Zd dlZddlmZ ddlmZ dZ G d dee          Zd Z	d	 Z
dS )
    N   )ReprPrinter)
StrPrinter)AddInfinityIntegerMulNegativeInfinityPowZeroc                   6     e Zd ZdZd fd	Zd Zd Zd Z xZS )PythonPrinterzFA printer which converts an expression into its Python interpretation.Nc                     t                                          |           g | _        g | _        t          D ]2}d|z  }t          t          |          }t          t          ||           3d S )Nz	_print_%s)	super__init__symbols	functionsSTRPRINTgetattrr   setattrr   )selfsettingsnamef_namef	__class__s        5lib/python3.11/site-packages/sympy/printing/python.pyr   zPythonPrinter.__init__   sr    """  	. 	.D 4'F
F++AM61----	. 	.    c                     |j         j        }t          t          |          s#|| j        vr| j                            |           t          j        | |          S N)func__name__hasattrsympyr   appendr   _print_Function)r   exprr!   s      r   r&   zPythonPrinter._print_Function   sU    y!ud## 	(DN(B 	(N!!$''')$555r   c                     |                      |          }|| j        vr| j                            |           t          j        | |          S r    )_strr   r%   r   _print_Symbol)r   r'   symbols      r   r*   zPythonPrinter._print_Symbol!   sI    4% 	(L''''d333r   c                      t          d          )Nz*Modules in the expression are unacceptable)
ValueError)r   r'   s     r   _print_modulezPythonPrinter._print_module'   s    EFFFr   r    )	r"   
__module____qualname____doc__r   r&   r*   r.   __classcell__)r   s   @r   r   r      sw        PP
. 
. 
. 
. 
. 
.6 6 64 4 4G G G G G G Gr   r   c                 
   t          |          }|                    |           }d}i }|j        D ]}d|v rB|                    dd                              dd          }||t	          j        |          <   n|}t          j        |          rC	 |dz  }||j        vr3||j        vr*t	          j        |          |t	          j        |          <   nB||dz   |z   dz   z  }|j        D ]i}|}	t          j        |	          rC	 |	dz  }	|	|j        vr3|	|j        vr*t	          j	        |	          |t	          j	        |          <   nB||	dz   |z   dz   z  }j|r| 
                    |          }|d	|                    |          z   z  }|S )
zvReturn Python interpretation of passed expression
    (can be passed to the exec() function without any modifications) {}T_z = Symbol('z')
z = Function('ze = )r   doprintr   replacer$   Symbolkw	iskeywordr   Functionsubsr)   )
r'   r   printerexprpresult	renamings
symbolnamenewsymbolnamefunctionnamenewfunctionnames
             r   pythonrG   +   s     H%%GOOD!!EFIo H H
* 	'&..sB77??RHHM2?Iel:..//&M <&& 	$!8 %W->> (-|M'B'B el"$ $ % 	-.0:=GG) N N&<(( 	3&#7?: 'w/@@ */)H)H en$& & ' 	/$44|CgMM %		)$$
fw||E****FMr   c                 :    t          t          | fi |           dS )z!Print output of python() functionN)printrG   )r'   r   s     r   print_pythonrJ   [   s&    	&
"
"
"
"#####r   )keywordr;   r$   reprr   strr   r   r   rG   rJ    r   r   <module>rO      s                    G G G G GK G G G@- - -`$ $ $ $ $r   