Python standard library
Posted: Sat Apr 18, 2009 3:58 pm
When I coding the cobra and want to use a Python standard library, is there the way?
Discussion about the Cobra programming language.
http://cobra-language.com/forums/
These questions are fine.arisawa wrote:sorry, off topic
Cobra uses the .NET/Mono libraries. So if you want to find the built-in functions for something you can search Google for "C# read directories" or whatever you like. Eventually, we'll have a cross platform library that runs on both .NET and JVM, but that won't be for awhile.arisawa wrote:Does not Cobra follow it by built-in function of Python?
It's supposed to, but I just tried "#!/usr/bin/cobra" on my Mac and it failed for reasons that I researched before. Basically, unix is not very flexible in allowing the pound-bang command to be another script which is what "/usr/bin/cobra" is. I was able to do this though:arisawa wrote:Does Cobra have pound-bang line? the example?
#!/bin/bash cobra
class X
def main
print 'Hello.'
#!/bin/bash /usr/bin/cobra
...
No problem.arisawa wrote:because I learn Cobra, Python and C# in side by side, I meet with such a confusion and questions well.
use IronPython.Hosting
use IronPython.Runtime.Types
use IronPython.Runtime.Operations
class Program
def main is shared
""" Test docstring """
engine = PythonEngine()
code = 'print "This is IronPython"'
engine.execute(code)
Chuck wrote:Would make a nice wiki page. hint, hint.
use System.Windows.Forms
use IronPython.Hosting
class Calc inherits Form
var tb as TextBox
var pe as PythonEngine = PythonEngine()
var s as Str = Str()
cue init
base.init
.text = 'SimpleCalc'
flp = FlowLayoutPanel(parent=this, dock=DockStyle.Fill, flowDirection=FlowDirection.TopDown)
.tb = TextBox(parent=flp)
b = Button(text='done', parent=flp)
listen b.click, ref .handleClick
.pe.globals.add('TextBox', .tb)
.pe.globals.add('Str', .s)
def handleClick(sender, args as EventArgs)
.pe.execute('TextBox.Text =' + 'Str.Pack('+.tb.text+')')
class Str
def pack(n as int) as String
return n.toString
class Program
def main is shared
Application.run(Calc())
engine = PythonEngine()
file = 'test.py'
engine.executeFile(file)