from lyte import say from lyteML import H import makemyHTML if say(): say('Here is how I develop using the lyte system.') say('<h1> Introducing the H object from lyteML.py</h1>') H = H.add('html') H.add('body') H.body.add('h2', 'Look ma, no tags') H.body.add('ul') H.body.ul.add('li', 'item?') H.body.ul.add('li', 'second item?') H.body.add( 'h2', 'see the nicely formatted HTML below? We generate unique IDs too') H.body.addChild( 'h2', 'For more information, see <a href="lyteML.html">lyteML.html</a> and lytemMLpy' ) say(H.toHTML())
</body> <script type="text/javascript">var compiler = RapydScript.create_embedded_compiler(); eval(compiler.compile(hereDoc(`##### Python zone begins {my__main__} ## Python zone ends`))); </script> </html> """ #print(template) writeout.writeout(f'{myName}.html', template ) print(f'RS', '-b', f'{myName}.py', '-o', f'{myName}.js \n') RS('-b', f'{myName}.py', '-o', f'{myName}.js') plopen(f'{myName}.html') if __name__== '__main__': ##LYTEML--INCLUDE THIS: say('this is {myName} (makemyHTML.html)') say(f'this is {myName} (makemyHTML.html)') say('<hr/>', "<i>note that variables (like myName) that can't be defined by javascript in the browser are unavailable</i>")
import a from lyte import say, whereami import makemyHTML if whereami(__name__).visible: say('this is b.py')
def illuminate( someKeyConcepts='formatted strings, parameters, and values' ): say("The def command defines a command.") say('This one is called "simple"') say(f"to illustrate {someKeyConcepts} ")
import lyte from vpython import box box() lyte.say('this is lyte saying in glowtest.py') def f(): print('this is a function') f() print("14:51:20 03/20/18 EDT") D={1:1, 2:2} print(f'{D}= {D} {type(D)}' )
from lyte import say, whereami, explain, blurt from mockvpython import box, cone, color import makemyVPHTML whereami = explain(__name__) if whereami.visible: box() cone() say('say') print('print') blurt('blurt')
from lyte import explain, say, blurt, whereami import makemyVPHTML whereami = explain(__name__) if whereami.visible: say(whereami) say('once in shell, once in browser') say(1, 2, 3, 'four')
from lyte import say import makemyHTML say('hello')
import lyte lyte.blurt('alert for all seasons') lyte.say('say what?') lyte.runRS() lyte.webMe()
import lyte lyte.say(f'==={lyte.language} === {lyte.context}') lyte.runRS(quiet=True) lyte.webMe(quiet=True)
def shift(c, howMuch=1): return chr(ord(c) + howMuch) def encoder(message): message = list(message) for i in range(len(message)): message[i] = shift(message[i], howMuch=secret_number) return ''.join(message) def decoder(message): message = list(message) for i in range(len(message)): message[i] = shift(message[i], howMuch=-secret_number) return ''.join(message) if __name__ == '__main__': message = 'this is a test' encoded_message = encoder(message) lyte.say( f' {message} -->encoded--> {encoded_message} -->decoded--> {decoder(encoded_message)} ' ) lyte.webMe()
indents = [] for i in range(ID.count('.')): indents.append(indent) return (''.join(indents)) indent = make_indents(t._IDnum) return f"""{indent}<{t._tag} id="{t._ID}" {t.attrs()}>\t\t\t{t._text} {HTMLs(t.children())}{indent}</{t._tag}> """### ^^^^^^^^^^^^^^ we recurse into children by way of HTMLs H = tag('html') import makemyHTML if say(): ##LYTEML--INCLUDE say('this is lyteML') H = H.add( 'html' ) #tag is called implicitly by add and addChild, but we have to start somewhere. H.add('head') # creates H.head H.add('body').add('h1', 'lyteML') # you can chain adds H.body.add('p', "lyte <b>M</b>arkup <b>L</b>anguage") # inline HTML works H.body.add('h1', 'another heading') # creates H.body.h1 (etc.) H.body.add('h2', 'the <i>add</i> command' ) # overwrites H.body.h1 (but preserves the element) H.body.add('p', "Text strings are optional; can include <i>html</i>" ) #inline HTML works
from lyte import explain, say say('top saying', __name__, str(say())) print('top printing', __name__, str(say())) import makemyHTML if say(): say('saying', __name__, str(say())) print('printing', __name__, str(say()))
from lyte import say, language, context, alert_ #print('doc', document) #if context != 'browser': alert=print if __name__ == '__main__': say(f'saying: {language} in {context}') #Lyte REQUIRES PYTHON3 print(f'printing: {language} in {context}') alert_(f'alerting: {language} in {context}') if context == 'browser': say('') say('look in the console for print output') import pyonly #pyonly.runRapydscript() pyonly.makeHTMLandJS()