Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Using "<script type="text/python></script>" syntax ?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  18 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Hypee  
View profile  
 More options Jun 20 2011, 5:30 am
From: Hypee <pascal.hy...@gmail.com>
Date: Mon, 20 Jun 2011 02:30:09 -0700 (PDT)
Local: Mon, Jun 20 2011 5:30 am
Subject: Using "<script type="text/python></script>" syntax ?
Hi,

Was anybody being able to make work the "billearney" cloned version of
Skulpt which is supposed to allow use of the <script type="text/
python></script> syntax ?

The example provided in this cloned version didn't work for me out of
the box, seems that's "deps.js" is calling for some Closures libs/
files that are not in the repository.

It also seems that this functionality isn't included in the master
branch of Skulpt.

Thanks !


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Billy Earney  
View profile  
 More options Jun 21 2011, 8:31 am
From: "Billy Earney" <billy.ear...@gmail.com>
Date: Tue, 21 Jun 2011 07:31:43 -0500
Local: Tues, Jun 21 2011 8:31 am
Subject: RE: [Skulpt] Using "<script type="text/python></script>" syntax ?
Hypee,

I've been able to get basic scripts working, but once you add an import, etc
it would bomb.  Not sure of the best (or correct way) to import python code
in Skulpt..

If someone could produce an example in which a library was imported, that
might help..


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Brad Miller  
View profile  
 More options Jun 22 2011, 5:34 pm
From: Brad Miller <bonel...@gmail.com>
Date: Wed, 22 Jun 2011 16:34:10 -0500
Local: Wed, Jun 22 2011 5:34 pm
Subject: Re: [Skulpt] Using "<script type="text/python></script>" syntax ?

Just to be sure... You do know that in order to import a library you need to add the builtin.js script to your source. It must come after you include skulpt.js

for example:

<script type="text/javascript" src="_static/skulpt.js"></script>
<script type="text/javascript" src="_static/builtin.js"></script>

Once you have builtin.js then import should work as usual.

Brad
--
Brad Miller
Sent with Sparrow (http://www.sparrowmailapp.com)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Hypee  
View profile  
 More options Jun 22 2011, 6:23 pm
From: Hypee <pascal.hy...@gmail.com>
Date: Wed, 22 Jun 2011 15:23:30 -0700 (PDT)
Local: Wed, Jun 22 2011 6:23 pm
Subject: Re: Using "<script type="text/python></script>" syntax ?
@Billy

Thanks for the quick answer !

In your Skult version, the "/example/Example1.html" seems to correctly
compile the code inside <script type="text/python> (which is already
quite amazing). But unfortunately, it doesn't seems to execute the
generated/compiled javascript code, or am I missing something ?

Might you give some info on how you achieved to make the <script
type="text/python> thing work ? (I mean what files did you modify).

@Brad

Do you mean that it's possible to make an "import myModule" that will
import the "myModule.py" file located in the same folder than
the .html file, without having to create an "/src/lib/myModule" folder
+ "_init_.py" file + recompiling with "m dist" ?

Regards,

Pascal


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Hypee  
View profile  
 More options Jun 22 2011, 6:39 pm
From: Hypee <pascal.hy...@gmail.com>
Date: Wed, 22 Jun 2011 15:39:46 -0700 (PDT)
Local: Wed, Jun 22 2011 6:39 pm
Subject: Re: Using "<script type="text/python></script>" syntax ?
@Billy

Ok, I found your SkulptInit function in init.js.
Will play with it !

On Jun 23, 12:23 am, Hypee <pascal.hy...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Billy Earney  
View profile  
 More options Jun 22 2011, 7:44 pm
From: Billy Earney <billy.ear...@gmail.com>
Date: Wed, 22 Jun 2011 18:44:36 -0500
Local: Wed, Jun 22 2011 7:44 pm
Subject: Re: [Skulpt] Using "<script type="text/python></script>" syntax ?

Brad,

Look at the init.js script.  It accesses the DOM and reads the contents
between the <script type="text/python"> ... </script> tags, and then
sends it to a skulpt function to parse it, and then execute it.

I've also created a myread function (that overrides read) which uses
XMLHTTPRequest to download the python file..

I'm having some trouble at this point.  ( get a Typeerror: a is
undefined)..   Not sure what is causing this.  I know the file is being
read in properly but after that something is wrong..

comment out the import myTest and it works fine.  uncomment the import
myTest, and I get the error above.  Paste the code from myTest.py inside
the script tags and it works (and parses, and executes) fine.

Does anyone have any suggestions?

Would be cool to get this working, and then to get python to access the
DOM, would be very awesome! :)

  script.html
< 1K Download

  myTest.py
< 1K Download

  init.js
2K Download

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Billy Earney  
View profile  
 More options Jun 22 2011, 8:15 pm
From: Billy Earney <billy.ear...@gmail.com>
Date: Wed, 22 Jun 2011 19:15:58 -0500
Local: Wed, Jun 22 2011 8:15 pm
Subject: Re: [Skulpt] Using "<script type="text/python></script>" syntax ?

I received an email stating that the js file was filtered, so here is a copy
in which I've changed the file extension.

On Wed, Jun 22, 2011 at 6:44 PM, Billy Earney <billy.ear...@gmail.com>wrote:

  init.js.txt
2K Download

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Brad Miller  
View profile  
 More options Jun 23 2011, 12:41 pm
From: Brad Miller <bonel...@gmail.com>
Date: Thu, 23 Jun 2011 11:41:59 -0500
Local: Thurs, Jun 23 2011 12:41 pm
Subject: Re: [Skulpt] Re: Using "<script type="text/python></script>" syntax ?

--
Brad Miller
Sent with Sparrow (http://www.sparrowmailapp.com)

No, all modules that you import have to be built into the builtin.js file that gets created when you run m dist or m docbi .

Brad


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Billy Earney  
View profile  
 More options Jun 23 2011, 2:07 pm
From: Billy Earney <billy.ear...@gmail.com>
Date: Thu, 23 Jun 2011 13:07:33 -0500
Local: Thurs, Jun 23 2011 2:07 pm
Subject: Re: [Skulpt] Re: Using "<script type="text/python></script>" syntax ?

Brad,

Thanks for the response.  That is sad news.  I was hoping to be able to
import py files in the same (or from a different directory).  It seems to me
that this could be a possibility.  I'm not sure how much Skulpt would need
to be modified to get it to work, but I could see a lot of potential , if
this feature was implemented.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Brad Miller  
View profile  
 More options Jun 23 2011, 3:41 pm
From: Brad Miller <bonel...@gmail.com>
Date: Thu, 23 Jun 2011 14:41:24 -0500
Local: Thurs, Jun 23 2011 3:41 pm
Subject: Re: [Skulpt] Re: Using "<script type="text/python></script>" syntax ?

I agree. In the long run that would be a cool approach. I think I've learned enough about the guts of skulpt that I could probably do it, but unfortunately its pretty far down on my priority list right now. I can accomplish everything I need for my current usage of skulpt using the builtin.js approach.

Brad

--
Brad Miller
Sent with Sparrow (http://www.sparrowmailapp.com)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Billy Earney  
View profile  
 More options Jun 25 2011, 9:16 am
From: Billy Earney <billy.ear...@gmail.com>
Date: Sat, 25 Jun 2011 08:16:29 -0500
Local: Sat, Jun 25 2011 9:16 am
Subject: Re: [Skulpt] Re: Using "<script type="text/python></script>" syntax ?

Brad,

Can you explain the builtin.js approach?   I've played with the code a
little, and I'm failing to figure out how to import a module.

Thanks!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Billy Earney  
View profile  
 More options Jun 25 2011, 5:45 pm
From: Billy Earney <billy.ear...@gmail.com>
Date: Sat, 25 Jun 2011 16:45:59 -0500
Local: Sat, Jun 25 2011 5:45 pm
Subject: Re: [Skulpt] Re: Using "<script type="text/python></script>" syntax ?

Brad,

I saw your blog at
http://blog.bonelakesoftware.com/2011/03/adding-module-to-skulpt.html which
describes some basics of Skulpt.  I'm using your builtinRead function.  I
believe skulpt is able to find my module (which is a python module), but I
get an error "TypeError: a.tp$setattr is not a function".  Is it possible to
create a module named myTest.py and place it in the src/lib directory and
have it work?

Here's the test module I'm playing with:

class myTest:
   def __init__(self, c):
       self._c=c

   def run(self, b):
       return self._c+b

I've double checked and the builtin.js file contains the myTest class and I
have added builtin.js after skulpt.js in my html file.

Any help or guidance is appreciated..

Thanks!

Billy

On Sat, Jun 25, 2011 at 8:16 AM, Billy Earney <billy.ear...@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Hypee  
View profile  
 More options Jun 25 2011, 8:13 pm
From: Hypee <pascal.hy...@gmail.com>
Date: Sat, 25 Jun 2011 17:13:14 -0700 (PDT)
Local: Sat, Jun 25 2011 8:13 pm
Subject: Re: Using "<script type="text/python></script>" syntax ?
First, thanks for tips on how to make the <script type="text/python">,
that's now working fine on my side.

For the module, create a folder "/src/lib/test" and create a
"__init.py__" in it with your code.
Compile with "m dist", then, in your .html page, do :

<script type="text/python">
import test
t = test.myTest( 1 )
print t.run( 2 )
</script>

You can also create Javascript modules in the same way, the structure
& communication is a little bit more tricky, but that's the way to go
to be able to communicate between Python/Javascript/DOM.

To allow import of "non compiled modules", we should be able to use
your XHR method. Either to do a dirty "str_replace" of "import
myModule.py" by the content of the module (lets says that adding .py
means it's a non compiled module) or modifying the existing import
function to handle that case.

Regards,

Pascal

On Jun 25, 11:45 pm, Billy Earney <billy.ear...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Brad Miller  
View profile  
 More options Jun 27 2011, 5:50 pm
From: Brad Miller <bonel...@gmail.com>
Date: Mon, 27 Jun 2011 16:50:48 -0500
Local: Mon, Jun 27 2011 5:50 pm
Subject: Re: [Skulpt] Re: Using "<script type="text/python></script>" syntax ?

Billy,

The way I've tested it is to create a subdirectory under lib and then put my python module code in __init__.py

when you run ./m dist that will compile the python to javascript and store it in builtin.js.

I'm not sure why you are getting the error below but it sounds like you might be seeing Python in builtin.js which is not good.

Brad
--
Brad Miller


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Billy Earney  
View profile  
 More options Jun 28 2011, 6:36 pm
From: Billy Earney <billy.ear...@gmail.com>
Date: Tue, 28 Jun 2011 17:36:25 -0500
Local: Tues, Jun 28 2011 6:36 pm
Subject: Re: [Skulpt] Re: Using "<script type="text/python></script>" syntax ?

Brad,

Enclosed is my builtin.js file when I do a ./m dist

The python code is being inserted into the builtin.js file,and isn't being
compiled into javascript.  Is there a step I should do before ./m dist?

Thanks!

  builtin.js.txt
145K Download

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Brad Miller  
View profile  
 More options Jun 29 2011, 2:26 pm
From: Brad Miller <bonel...@gmail.com>
Date: Wed, 29 Jun 2011 13:26:04 -0500
Local: Wed, Jun 29 2011 2:26 pm
Subject: Re: [Skulpt] Re: Using "<script type="text/python></script>" syntax ?

Billy,

Two things:

1. I don't know what I was talking about when I said no python in the builtin.js file. I just double checked how my example worked and there it was. So thats not the issue.

2. I took your builtin.js that you sent me and dropped it into my test environment. I tried the following program:

import myTest

x = myTest.myTest(2)
print x.run(3)

And it worked just fine.  Now I did this using a textarea and the run script I posted on my blog, not in a <script> tag. So that would seem to point to the script tag not necessarily anything in skulpt proper. I haven't looked at the branch that implements <script type="text/python"> so I can't really comment.

Sorry for the mis-information before.

Brad

--
Brad Miller


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Billy Earney  
View profile  
 More options Jun 29 2011, 2:58 pm
From: "Billy Earney" <billy.ear...@gmail.com>
Date: Wed, 29 Jun 2011 13:58:24 -0500
Local: Wed, Jun 29 2011 2:58 pm
Subject: RE: [Skulpt] Re: Using "<script type="text/python></script>" syntax ?

No problem.  I’ll look at this a little later today, and hopefully I can get it running.

From: skulpt@googlegroups.com [mailto:skulpt@googlegroups.com] On Behalf Of Brad Miller
Sent: Wednesday, June 29, 2011 1:26 PM
To: skulpt@googlegroups.com
Subject: Re: [Skulpt] Re: Using "<script type="text/python></script>" syntax ?

Billy,

Two things:

1.  I don't know what I was talking about when I said no python in the builtin.js file.  I just double checked how my example worked and there it was.  So thats not the issue.

2.  I took your builtin.js that you sent me and dropped it into my test environment.  I tried the following program:

import myTest

x  = myTest.myTest(2)

print x.run(3)

And it worked just fine.   Now I did this using a textarea and the run script I posted on my blog, not in a <script> tag.  So that would seem to point to the script tag not necessarily anything in skulpt proper.  I haven't looked at the branch that implements <script type="text/python">  so I can't really comment.

Sorry for the mis-information before.

Brad

--
Brad Miller

On Tuesday, June 28, 2011 at 5:36 PM, Billy Earney wrote:

Brad,

Enclosed is my builtin.js file when I do a ./m dist

The python code is being inserted into the builtin.js file,and isn't being compiled into javascript.  Is there a step I should do before ./m dist?

Thanks!

On Mon, Jun 27, 2011 at 4:50 PM, Brad Miller <bonel...@gmail.com> wrote:

Billy,

The way I've tested it is to create a subdirectory under lib and then put my python module code in __init__.py

when you run ./m dist  that will compile the python to javascript and store it in builtin.js.

I'm not sure why you are getting the error below but it sounds like you might be seeing Python in builtin.js which is not good.

Brad

--
Brad Miller

On Saturday, June 25, 2011 at 4:45 PM, Billy Earney wrote:

Brad,

I saw your blog at http://blog.bonelakesoftware.com/2011/03/adding-module-to-skulpt.html which describes some basics of Skulpt.  I'm using your builtinRead function.  I believe skulpt is able to find my module (which is a python module), but I get an error "TypeError: a.tp$setattr is not a function".  Is it possible to create a module named myTest.py and place it in the src/lib directory and have it work?

Here's the test module I'm playing with:

class myTest:
   def __init__(self, c):
       self._c=c

   def run(self, b):
       return self._c+b

I've double checked and the builtin.js file contains the myTest class and I have added builtin.js after skulpt.js in my html file.

Any help or guidance is appreciated..

Thanks!

Billy

On Sat, Jun 25, 2011 at 8:16 AM, Billy Earney <billy.ear...@gmail.com> wrote:

Brad,

Can you explain the builtin.js approach?   I've played with the code a little, and I'm failing to figure out how to import a module.

Thanks!

On Thu, Jun 23, 2011 at 2:41 PM, Brad Miller <bonel...@gmail.com> wrote:

I agree.  In the long run that would be a cool approach.  I think I've learned enough about the guts of skulpt that I could probably do it, but unfortunately its pretty far down on my priority list right now.  I can accomplish everything I need for my current usage of skulpt using the builtin.js approach.

Brad

--
Brad Miller
Sent with Sparrow <http://www.sparrowmailapp.com>

On Thursday, June 23, 2011 at 1:07 PM, Billy Earney wrote:

Brad,

Thanks for the response.  That is sad news.  I was hoping to be able to import py files in the same (or from a different directory).  It seems to me that this could be a possibility.  I'm not sure how much Skulpt would need to be modified to get it to work, but I could see a lot of potential , if this feature was implemented.

On Thu, Jun 23, 2011 at 11:41 AM, Brad Miller <bonel...@gmail.com> wrote:

--
Brad Miller
Sent with Sparrow <http://www.sparrowmailapp.com>

On Wednesday, June 22, 2011 at 5:23 PM, Hypee wrote:

@Billy

Thanks for the quick answer !

In your Skult version, the "/example/Example1.html" seems to correctly
compile the code inside <script type="text/python> (which is already
quite amazing). But unfortunately, it doesn't seems to execute the
generated/compiled javascript code, or am I missing something ?

Might you give some info on how you achieved to make the <script
type="text/python> thing work ? (I mean what files did you modify).

@Brad

Do you mean that it's possible to make an "import myModule" that will
import the "myModule.py" file located in the same folder than
the .html file, without having to create an "/src/lib/myModule" folder
+ "_init_.py" file + recompiling with "m dist" ?

No, all modules that you import have to be built into the builtin.js file that gets created when you run m dist  or m docbi .  

Brad

Regards,

Pascal

Attachments:

- builtin.js.txt


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Billy Earney  
View profile  
 More options Jun 29 2011, 8:24 pm
From: Billy Earney <billy.ear...@gmail.com>
Date: Wed, 29 Jun 2011 19:24:36 -0500
Local: Wed, Jun 29 2011 8:24 pm
Subject: Re: [Skulpt] Re: Using "<script type="text/python></script>" syntax ?

Brad,

Thanks for helping me with this.  I believe I have it working, thanks to the
example you give below.  Also I believe I have the dynamic import thingee
solved as well.  I've created a myExample.py script (and it isn't in the
builtin.js file), and was able to import it by using
<script src="myExample.py" type="text/python"></script>

So we could use builtin.js for the regular py files that come with python
(random, math, etc), and the above format could be another option of
dynamically adding one or more .py files without using the builtin.js
technique..

How to reproduce:

save the attachments.

mv dist.7z.txt dist.7z
mv example.7z.txt example
7za x dist.7z
7za x example.7z

cd example
open script.html in a browser and if the page says  Hello World, then 15,
and then good bye!.  The dynamic import worked and compiled properly..

There might be a better way of doing this.  When I parse the script tag
(which contains the src attribute), I look for and download the file
(myExample.py) and then I place it in the builitin['files'] data structure.
After that, skulpt doesn't know if its really part of builtin.js or not.

Like I said, there could be a better way of doing this, but I guess this is
a start. :)

Let me know if you have trouble replicating my results..

This could lead to some great things! :)

Billy

  dist.7z.txt
81K Download

  example.7z.txt
5K Download

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »