Re: ILeo (IPython-Leo bridge); a marriage made in heaven?

2008-02-24 Thread shakeeb . alireza
 > Are you part of Leo? This smells like a marketing scheme to me.

Actually this is an example of a beautiful collaboration between
Edward (the progenitor of leo) and Ville (the ipython side).

Fantastic and elegant stuff, which you have to try to appreciate.

AK
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ILeo (IPython-Leo bridge); a marriage made in heaven?

2008-02-23 Thread Ville Vainio
On Feb 23, 10:54 pm, Ricardo Aráoz <[EMAIL PROTECTED]> wrote:

> Are you part of Leo? This smells like a marketing scheme to me.

Yes, Edward is part of Leo and I am part of IPython. In fact, most of
my income comes from selling IPython T-shirts at the local flea market
and I therefore have to resort to shady operations like this to pump
up my fading income. Hey, it pays the bills!

Seriously, though; this *is* cool stuff. I have an updated version of
the document here: http://vvtools.googlecode.com/files/ILeo_doc.txt
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ILeo (IPython-Leo bridge); a marriage made in heaven?

2008-02-23 Thread Ricardo Aráoz
Edward K Ream wrote:
>> Here is something cool that will rock your world (ok, excuse the slight 
>> hyperbole):
> 
> Many thanks for this posting, Ville.  It is indeed very cool:
> 
> - It shows how Leo can be used *now* as an IPython notebook.
> 
> - It expands the notion of what is possible with Leo/IPython/Python scripts.
> 
> Your ideas are destined to be of great importance to both the IPython and 
> Leo communities.
> I shall continue this discussion at:
> 
> http://groups.google.com/group/leo-editor/browse_thread/thread/3747a122f913cd7f
> 
> Edward
> 
> Edward K. Ream   email:  [EMAIL PROTECTED]
> Leo: http://webpages.charter.net/edreamleo/front.html
> 
> 
> 

Are you part of Leo? This smells like a marketing scheme to me.





-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ILeo (IPython-Leo bridge); a marriage made in heaven?

2008-02-23 Thread Edward K Ream
> Here is something cool that will rock your world (ok, excuse the slight 
> hyperbole):

Many thanks for this posting, Ville.  It is indeed very cool:

- It shows how Leo can be used *now* as an IPython notebook.

- It expands the notion of what is possible with Leo/IPython/Python scripts.

Your ideas are destined to be of great importance to both the IPython and 
Leo communities.
I shall continue this discussion at:

http://groups.google.com/group/leo-editor/browse_thread/thread/3747a122f913cd7f

Edward

Edward K. Ream   email:  [EMAIL PROTECTED]
Leo: http://webpages.charter.net/edreamleo/front.html



-- 
http://mail.python.org/mailman/listinfo/python-list


ILeo (IPython-Leo bridge); a marriage made in heaven?

2008-02-22 Thread Ville Vainio
Here is something cool that will rock your world (ok, excuse the
slight hyperbole):

Introduction


The purpose of ILeo, or leo-ipython bridge, is being a two-way
communication
channel between Leo and IPython. The level of integration is much
deeper than
conventional integration in IDEs; most notably, you are able to store
*data* in
Leo nodes, in addition to mere program code. The possibilities of this
are
endless, and this degree of integration has not been seen previously
in the python
world.

IPython users are accustomed to using things like %edit to produce non-
trivial
functions/classes (i.e. something that they don't want to enter
directly on the
interactive prompt, but creating a proper script/module involves too
much
overhead). In ILeo, this task consists just going to the Leo window,
creating a node
and writing the code there, and pressing alt+I (push-to-ipython).

Obviously, you can save the Leo document as usual - this is a great
advantage
of ILeo over using %edit, you can save your experimental scripts all
at one
time, without having to organize them into script/module files (before
you
really want to, of course!)


Installation


You need at least Leo 4.4.7, and the development version of IPython
(ILeo
will be incorporated to IPython 0.8.3).

You can get IPython from Launchpad by installing bzr and doing

bzr branch lp:ipython

and running "setup.py install".

You need to enable the 'ipython.py' plugin in Leo:

- Help -> Open LeoSettings.leo

- Edit @settings-->Plugins-->@enabled-plugins, add/uncomment
'ipython.py'

- Restart Leo. Be sure that you have the console window open (start
leo.py from console, or double-click leo.py on windows)

- Press alt+5 OR alt-x start-ipython to launch IPython in the console
that
started leo. You can start entering IPython commands normally, and Leo
will keep
running at the same time.

Accessing IPython from Leo
==

IPython code


Just enter IPython commands on a Leo node and press alt-I to execute
push-to-ipython to execute the script in IPython. 'commands' is
interpreted
loosely here - you can enter function and class definitions, in
addition to the
things you would usually enter at IPython prompt - calculations,
system commands etc.

Everything that would be legal to enter on IPython prompt is legal to
execute
from ILeo.

Results will be shows in Leo log window for convenience, in addition
to the console.

Suppose that a node had the following contents:
{{{
1+2
print "hello"
3+4

def f(x):
return x.upper()

f('hello world')
}}}

If you press alt+I on that done, you will see the following in Leo log
window (IPython tab):

{{{
In: 1+2
<2> 3
In: 3+4
<4> 7
In: f('hello world')
<6> 'HELLO WORLD'
}}}

(numbers like <6> mean IPython output history indices).


Plain Python code
-

If the headline of the node ends with capital P, alt-I will not run
the code
through IPython translation mechanism but use the direct python 'exec'
statement
(in IPython user namespace) to execute the code. It wont be shown in
IPython
history, and sometimes it is safer (and more efficient) to execute
things as
plain Python statements. Large class definitions are good candidates
for P
nodes.

Accessing Leo nodes from IPython


The real fun starts when you start entering text to leo nodes, and are
using
that as data (input/output) for your IPython work.

Accessing Leo nodes happens through the variable 'wb' (short for
"WorkBook")
that exist in the IPython user namespace. Nodes that are directly
accessible are
the ones that have simple names which could also be Python variable
names;
'foo_1' will be accessible directly from IPython, whereas 'my scripts'
will not.
If you want to access a node with arbitrary headline, add a child node
'@a foo'
(@a stands for 'anchor'). Then, the parent of '@a foo' is accessible
through
'wb.foo'.

You can see what nodes are accessible be entering (in IPython)
wb.. Example:

[C:leo/src]|12> wb.
wb.b   wb.tempfilewb.rfile   wb.NewHeadline
wb.bar wb.Docswb.strlist wb.csvr

Suppose that we had a node with headline 'spam' and body:

['12',+32]

we can access it from IPython (or from scripts entered into other Leo
nodes!) by doing:

C:leo/src]|19> wb.spam.v
  <19> ['12', 2254]

'v' attribute stands for 'value', which means the node contents will
be run
through 'eval' and everything you would be able to enter into IPython
prompt
will be converted to objects. This mechanism can be extended far
beyond direct
evaluation (see '@cl definitions').

'v' attribute also has a setter, i.e. you can do:

wb.spam.v = "mystring"

Which will result in the node 'spam' having the following text:

'mystring'

What assignment to 'v' does can be configured through generic
functions
(simplegeneric module, will be explained later).

Besides v, you can set the body text directly through wb.spam.b =
"some\nstring", headline by wb.spam.