ipython like features in pyshell/pycrust

I have added some small features to pyshell/pycrust that are similar to ipython :

  • calling functions even without ending parentheses :

dir
→ dir()
[‘builtins’, ‘doc’, ‘file’, ‘name’, ‘a’, ‘filling’, ‘magic’, ‘notebook’, ‘pp’, ‘shell’, ‘yam’, ‘yaml’]

  • magical functions that takes the rest of the line whatever is it as a string parameter (and I implemented a few) :

pwd
‘/home/nevare’
cd Desktop
‘/home/nevare/Desktop’
exe date
‘samedi 24 mars 2007, 20:11:38 (UTC+0100)\n’

  • a special magical function : ‘?’ that can be placed before or after an object and returns its doc

?dir
Python Library Documentation: built-in function dir in module builtin

dir(…)
dir([object]) → list of strings

Return an alphabetized list of names comprising (some of) the attributes
of the given object, and of attributes reachable from it:

Would you be interested in having me commenting a bit my code and make a patch that could be integrated in pyshell ?

I would also like to give it a better completion (it is limited for the time being).

And also had some features that enable people to write python modules entirely in a shell. Like :
export.file = ‘~/Desktop/parrot.py’
class parrot

math.init = …
def isDead(self,…):

math.isDead = isDead
math.isMoving = …
export(math)

And it would export refactored source code of the math class and all its modifications to the .py file.
Don’t you think that would be cool ?

I suppose you wouldn’t be interested to have me work on it for the
summer of code. (well I understand it’s not really related to core of
wxpython).

I may still do it someday … if I find the time and energy.

Olivier Lauzanne

Nevare Stark wrote:

I have added some small features to pyshell/pycrust that are similar to ipython :

- calling functions even without ending parentheses :
>>> dir
--> dir()
['__builtins__', '__doc__', '__file__', '__name__', 'a', 'filling', 'magic', 'notebook', 'pp', 'shell', 'yam', 'yaml']

- magical functions that takes the rest of the line whatever is it as a string parameter (and I implemented a few) :
>>> pwd
'/home/nevare'
>>> cd Desktop
'/home/nevare/Desktop'
>>> exe date
'samedi 24 mars 2007, 20:11:38 (UTC+0100)\n'

- a special magical function : '?' that can be placed before or after an object and returns its doc
>>> ?dir
Python Library Documentation: built-in function dir in module __builtin__

dir(...)
    dir([object]) -> list of strings
       Return an alphabetized list of names comprising (some of) the attributes
    of the given object, and of attributes reachable from it:

Would you be interested in having me commenting a bit my code and make a patch that could be integrated in pyshell ?

Yes, these sound like useful things. Please also add ways for the user to discover these features at runtime, such as text in the help dialog or etc. Maybe it's time we gave PyShell/PyCrust a real help document...

I would also like to give it a better completion (it is limited for the time being).

In what way?

And also had some features that enable people to write python modules entirely in a shell. Like :
export.file = '~/Desktop/parrot.py'
class parrot
    ...
math.__init__ = ...
def isDead(self,...):
    ...
math.isDead = isDead
math.isMoving = ...
export(math)

And it would export refactored source code of the math class and all its modifications to the .py file.
Don't you think that would be cool ?

Cool? Yes. Useful? Maybe. Something that would be commonly used? I don't know. I guess I would have to see it in action to be able to decide if I really like it or not.

I suppose you wouldn't be interested to have me work on it for the summer of code. (well I understand it's not really related to core of wxpython).

I think it would certainly apply as a SoC project. PyShell has become an important part of wxPython, and I think that any SoC projects that benefit things related to wxPython are just as important to the project as a whole as those that are related to the core. Go ahead and submit a proposal.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Just wanted to chime in to say I was a firm devotee of PyShell, but
eventually I had to give it up because it lacked features available in
ipython.

Something to watch out for, though, is that I believe ipython also has
the goal of eventually breaking free of the tyranny of gnu readline
and becoming a truly reusable component that could work with any front
end. If/when that happens then it would probably make more sense to
actually incorporate ipython's command processor into wxShell rather
than re-implementing ipython's features one by one.

I don't really understand your proposed module writing feature, but I
will say that I find typing functions directly into python to be very
frustrating. It would be nice to have a little pop-up multi-line text
editor for times when you want to enter a short function directly.

--bb

···

On 3/26/07, Robin Dunn <robin@alldunn.com> wrote:

Nevare Stark wrote:
> I have added some small features to pyshell/pycrust that are similar to
> ipython :
>
> - calling functions even without ending parentheses :
> >>> dir
> --> dir()
> ['__builtins__', '__doc__', '__file__', '__name__', 'a', 'filling',
> 'magic', 'notebook', 'pp', 'shell', 'yam', 'yaml']
>
> - magical functions that takes the rest of the line whatever is it as a
> string parameter (and I implemented a few) :
> >>> pwd
> '/home/nevare'
> >>> cd Desktop
> '/home/nevare/Desktop'
> >>> exe date
> 'samedi 24 mars 2007, 20:11:38 (UTC+0100)\n'
>
> - a special magical function : '?' that can be placed before or after an
> object and returns its doc
> >>> ?dir
> Python Library Documentation: built-in function dir in module __builtin__
>
> dir(...)
> dir([object]) -> list of strings
>
> Return an alphabetized list of names comprising (some of) the attributes
> of the given object, and of attributes reachable from it:
>
> Would you be interested in having me commenting a bit my code and make a
> patch that could be integrated in pyshell ?

Yes, these sound like useful things. Please also add ways for the user
to discover these features at runtime, such as text in the help dialog
or etc. Maybe it's time we gave PyShell/PyCrust a real help document...

>
> I would also like to give it a better completion (it is limited for the
> time being).

In what way?

>
> And also had some features that enable people to write python modules
> entirely in a shell. Like :
> export.file = '~/Desktop/parrot.py'
> class parrot
> ...
> math.__init__ = ...
> def isDead(self,...):
> ...
> math.isDead = isDead
> math.isMoving = ...
> export(math)
>
> And it would export refactored source code of the math class and all its
> modifications to the .py file.
> Don't you think that would be cool ?

Cool? Yes. Useful? Maybe. Something that would be commonly used? I
don't know. I guess I would have to see it in action to be able to
decide if I really like it or not.

>
> I suppose you wouldn't be interested to have me work on it for the
> summer of code. (well I understand it's not really related to core of
> wxpython).

I think it would certainly apply as a SoC project. PyShell has become
an important part of wxPython, and I think that any SoC projects that
benefit things related to wxPython are just as important to the project
as a whole as those that are related to the core. Go ahead and submit a
proposal.