# f3()  formats as f999999.999 where f means float (See endnotes)
# MicroPython doesn't process complex numbers
# described in 155.html
import re    # to check for regular expressions in a string
def f3(x):
    isDone=False
    xFloat=3.14159
    xType="q"
    xReturn=""
    #print("into f3 xReturn:"+xReturn)
    # process a string
    #if isinstance(x,(float,int,str,list,dict,tuple)):
    
    if isinstance(x,(float,int,str)):
        if isinstance(x,str):
            if x.endswith("jJ"):
                isJend=True
            else:
                isJend=False
            #print("isJend:",isJend)
            #if(x.endswith("j)") or (x.endswith("J)"):
            #if((x.endswith("j")) or ((x.endswith("J")):
            if isJend:
                #almost complex but without the "(" and ")"
                xReturn="c" + "("+c+")"
                xType="c"
                isDone=True
            else:
                #not complex
                try:
                    xFloat=float(x)
                    xType="f"
                    isDone=True
                except:
                    xReturn="s"+x
                    isDone=True
                #end try
            #end if
        # process an integer value
        elif isinstance(x,int):
            xFloat=float(x)
            xType="i"
            isDone=True
        # process a float value
        elif isinstance(x,float):
            xFloat=x
            xType="f"
            isDone=True
        #end if instances of int,float,str,
    else:   #presume boolean
        if(bool(x)==1):
            xFloat=float(1)
            xType="b"
            isDone=True
        #end if
        if(bool(x)==0):
            xFloat=float(0)
            xType="b"
            isDone=True
        #end if
        #end of bool processing
    #end if    
    
   
    #process unknown type
    
    if isDone==False:
        #nothing was recognized
        xReturn="u??????.???"
    else:
        if xReturn=="":
            #create something to return
            xReturn=xType + str(xFloat)
        else:
            #something was created to be returned
            #doh="doh"
            pass
        #end if
    #end if

    #print("xReturn:"+xReturn)
    return xReturn
#end def f3
#/f3_v00.py.txt