Giter VIP home page Giter VIP logo

ptpython's People

Contributors

0az avatar baldulin avatar beader avatar carlwgeorge avatar derekbrokeit avatar dongweiming avatar gitaarik avatar gpotter2 avatar graingert avatar jonathanslenders avatar julian avatar kingarrrt avatar mikaeilorfanian avatar msabramo avatar nasyxx avatar ndevenish avatar nightmachinery avatar notafile avatar orivej avatar roee30 avatar rpdelaney avatar rth avatar sblondon avatar teroyks avatar timgates42 avatar timofurrer avatar timsavage avatar tony avatar tpoliaw avatar vxgmichel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ptpython's Issues

function signature hint toolbar doesn't appear in windows

Hi, in this screenshot it looks like ptpython is hinting the argument list to the currently typed function. I've been playing around with ptpython and am unable to trigger this feature. So, two questions -- How do I enable function hinting in ptpython, and second, where/how is the hinting accomplished in the source code?

Thanks!

does not work on windows

installed with pip as recommended on your page. Trying to run:

D:>ptpython
In [1]:

[F4] Emacs 1/1 [F6] Paste mode (off) [F2] Sidebar - CPython 3.3.5 T
raceback (most recent call last):
File "C:\Python\3.3-64\Scripts\ptpython-script.py", line 9, in
load_entry_point('ptpython==0.5', 'console_scripts', 'ptpython')()
File "C:\Python\3.3-64\lib\site-packages\ptpython\entry_points\run_ptpython.py", line 62, in run
no_colors=no_colors, startup_paths=startup_paths)
File "C:\Python\3.3-64\lib\site-packages\ptpython\repl.py", line 208, in embed
repl.start_repl(startup_paths=startup_paths)
File "C:\Python\3.3-64\lib\site-packages\ptpython\repl.py", line 51, in start_repl
on_exit=AbortAction.RAISE_EXCEPTION)
File "C:\Python\3.3-64\lib\site-packages\prompt_toolkit\interface.py", line 290, in read_input
next(g)
File "C:\Python\3.3-64\lib\site-packages\prompt_toolkit\interface.py", line 344, in _read_input
self._redraw()
File "C:\Python\3.3-64\lib\site-packages\prompt_toolkit\interface.py", line 230, in _redraw
self.renderer.render(self, self.layout, self.style)
File "C:\Python\3.3-64\lib\site-packages\prompt_toolkit\renderer.py", line 324, in render
style=style, grayed=(cli.is_aborting or cli.is_exiting),
File "C:\Python\3.3-64\lib\site-packages\prompt_toolkit\renderer.py", line 164, in output_screen_diff
current_pos = move_cursor(screen.cursor_position)
File "C:\Python\3.3-64\lib\site-packages\prompt_toolkit\renderer.py", line 50, in move_cursor
output.cursor_up(current_y - new.y)
File "C:\Python\3.3-64\lib\site-packages\prompt_toolkit\terminal\win32_output.py", line 166, in cursor_up
sr = self._screen_buffer_info().dwCursorPosition
AttributeError: 'NoneType' object has no attribute 'dwCursorPosition'

D:>pip list
docopt (0.6.2)
ipython (3.1.0)
jedi (0.8.1)
pip (6.1.1)
prompt-toolkit (0.31)
ptpython (0.5)
Pygments (2.0.2)
PyMySQL (0.6.1)
pyreadline (2.0)
redis (2.9.1)
setuptools (14.3)
six (1.9.0)
SQLAlchemy (0.9.3)
tornado (3.3.dev1)
wcwidth (0.1.4)
wheel (0.22.0)

multiple python versions

There seems to be no way to switch python versions for ptpython. I have 2.7 and 3.4 installed concurrently. If I use pip I can reinstall whichever one i need to use and it'll work that way, but then I have to use pip every time I need to switch. Is there a better way to handle this?

clarification, IPython, IPython notebook

This looks like a very interesting project. However, from reading the README, some things remained unclear for me, so maybe you can clarify that in the README?

  • What exactly are the differences to IPython?
  • Does it have a web frontend? Or any other graphical frontend?
  • Does it work together with IPython QtConsole or IPython Notebook?

ptpython in cygwin

when I use ptpython in cygwin I get this symbols [13;1R in the prompt

$ ptpython
In [1]: [13;1R

matplotlib integration seems a bit broken with ptipython

It feels like the matplotlib integration (which runs in a separate event loop) is a bit broken by ptipython, this will probably be a problem for anyone using matplotlib.

I'm using Linux Mint 17.1 (Ubuntu 14.04), Python 3.4.2 (Anaconda), IPython 2.2.0, today's <master> for ptipython.

If I run this in either ipython or ptipython, the plt.show() correctly causes a graph window to be drawn:

In [1]: import matplotlib.pyplot as plt
In [2]: plt.plot([1,2,3])
Out[2]: [<matplotlib.lines.Line2D at 0x7f04cd208278>]
In [3]: plt.show()  <-- graph window gets drawn

If the above (lines 2 & 3) are repeated in either ipython or ptipython, the graph will show again (so it feels like matplotlib integration is working in ptipython).

Note that in this mode (without using %matplotlib or passing in --pylab) the .show() is blocking.

If I run a vanilla ipython (i.e. $ ipython, not $ ipython --pylab), the %matplotlib magic works and the event-loop is non-blocking. This is the usual interactive development process if you're working with charts:

In [1]: %matplotlib
Using matplotlib backend: Qt4Agg

In [2]: import matplotlib.pyplot as plt

In [3]: plt.plot([1,2,3])
Out[3]: [<matplotlib.lines.Line2D at 0x7f2adff4bef0>]  
<-- graph windows pops up, no need to call plt.show(), interactive prompt is still interactive

If I run the same using $ ptipython, I don't get a graph window. If I add plt.show() then I also don't get a graph window. It looks like the matplotlib integration is a bit broken.

Some (possibly unhelpful) notes:

I'll also note that autocompletion on e.g. plt.plot( gets slow, this is a Jedi problem (and Rope too) with matplotlib, scipy etc and has been noted in e.g. the GVim forums. Somebody is bound to mention this soon so you ought to be aware of it.

User Configuration

I makes Completion menu into toolbar, but when I close session, It turns back to the original.

Maybe It should be user-configurable.

Provide an ability to configure hotkeys

Hello. I've got a problem with "Execute" (Meta+Enter) in Paste mode because I'm using i3wm and the same hotkeys already assigned to "Open terminal" command. I'm sure that I'm not the only one who have this issue. Can you consider this improvement? Thanks!

can't get character \ to work

When i press \ nothing happens,
It works in Python console, in ipython but not for ptpython or ptipython

I use
Python 3.4 (32 bits) om Windows 7

is it possible to change the color style?

Hi,

I see there is PythonStyle class at style.py. For my dark background, the color style is not very readable.

Is there a simple way to configure that? I can try a monkey patch but...well...

Thanks,
Damien

Get run shortcuts to work properly on Windows

Currently, when you have a multiline input ctrl-enter doesn't execute anymore but just adds lines (you have to press esc before to make it run).

I know this is outlined in the FAQ, but it's really annoying ๐Ÿ˜ž - can it be solved?

Save config from menu

It'd be nice if there were a way to do basic configuration from within pt(i)python like if you change to Vi mode, or colorscheme choices and save those options. Additionally what is the option to set the code color scheme? In your example you have the UI option detailed as repl.use_ui_colorscheme('blue')

command-history-matcher in ptipython no longers works as per ipython

The command-history-matcher (is there a better name?) in IPython lets you do the following:

In[1]: %run <somescript>
In[2]> %ru<hit-up-arrow>  

and then it'll cycle through previous commands in In that match with "%ru", so you can quickly jump back to an earlier command

This works in IPython but doesn't work in pyipython, the ptipython behaviour is to cycle through Jedi "%ru" autocomplete commands, rather than to cycle through the command history.

Jedi has control here so the old behaviour has presumably been cut out. Possibly one approach is to let the user hit a key like Esc to stop using Jedi, then to fall back on the previous arrow-up, arrow-down behaviour?

Based on my usage patterns I'd say this is not a deal breaker (as I can still start with an empty input line and just hit arrow-up a few times)

Workaround: "ru" uses the incremental-backwards-search just as it would in IPython to find a previous command.

Different Colorscheme

I am not happy with the current colorscheme of ptpython, so I tried changing the colors present in file /usr/local/lib/python2.7/dist-packages/ptpython/style.py but restarting ptpython resulted in no change. Am I doing something wrong?

IMHO, there should be an easier way to change colors.

Python 3

This is not really a issue. I just don't know how to use it with Python 3. How can I use it with ptpython? Thanks in advance

Eliminate Paste Mode

I'm sure there's a history behind it and a good rationale for initially adding it, but is there any possibility of getting rid of it? I'd prefer to not have to choose between clipboard access and "returning".

Cannot run `ptipython` before running `ptpython`

Thanks for this library! I tried running ptipython immediately after install, and got this traceback after every attempted execution. Once I forcibly exited, I ran a ptpython session just fine, and when I came back to ptipython, all was well.

FileNotFoundError                         Traceback (most recent call last)
/Users/ssilvester/anaconda/lib/python3.4/site-packages/ptpython/ipython.py in r)
    196         print('')
    197         try:
--> 198             string = self._cli.run().text
    199 acs   3/3   [F6] Paste mode (off)          [F2] Options - CPython 3.4.3
    200             # In case of multiline input, make sure to append a newline,

/Users/ssilvester/anaconda/lib/python3.4/site-packages/prompt_toolkit/interface)
    271                 self._redraw()
    272
--> 273                 self.eventloop.run(self.input, self.create_eventloop_ca)
    274         finally:
    275             # Clean up renderer. (This will leave the alternate screen,e

/Users/ssilvester/anaconda/lib/python3.4/site-packages/prompt_toolkit/eventloop)
     64                     # Feed input text.
     65                     data = stdin_reader.read()
---> 66                     inputstream.feed(data)
     67                     callbacks.redraw()
     68

/Users/ssilvester/anaconda/lib/python3.4/site-packages/prompt_toolkit/terminal/)
    300             if c == '\r':
    301                 c = '\n'
--> 302             self._input_parser.send(c)
    303
    304     def flush(self):

/Users/ssilvester/anaconda/lib/python3.4/site-packages/prompt_toolkit/terminal/)
    252                 # Exact matches found, call handlers..
    253                 if (flush or not is_prefix_of_longer_match) and match:
--> 254                     self._call_handler(match, prefix)
    255                     prefix = ''
    256

/Users/ssilvester/anaconda/lib/python3.4/site-packages/prompt_toolkit/terminal/)
    281                 self._call_handler(k, insert_text)
    282         else:
--> 283             self.feed_key_callback(KeyPress(key, insert_text))
    284
    285     def feed(self, data):

/Users/ssilvester/anaconda/lib/python3.4/site-packages/prompt_toolkit/interface)
    604         """
    605         # Feed the key and redraw.
--> 606         self.cli.input_processor.feed_key(key_press)
    607
    608     def redraw(self):

/Users/ssilvester/anaconda/lib/python3.4/site-packages/prompt_toolkit/key_bindi)
    163             self.beforeKeyPress.fire()
    164
--> 165         self._process_coroutine.send(key_press)
    166
    167         if key_press.key != Keys.CPRResponse:

/Users/ssilvester/anaconda/lib/python3.4/site-packages/prompt_toolkit/key_bindi)
    135                 # Exact matches found, call handler.
    136                 if not is_prefix_of_longer_match and matches:
--> 137                     self._call_handler(matches[-1], key_sequence=buffer)
    138                     buffer = []
    139

/Users/ssilvester/anaconda/lib/python3.4/site-packages/prompt_toolkit/key_bindi)
    174         event = Event(weakref.ref(self), arg=arg, key_sequence=key_sequ,
    175                       previous_key_sequence=self._previous_key_sequence)
--> 176         handler.call(event)
    177         self._registry.on_handler_called.fire(event)
    178

/Users/ssilvester/anaconda/lib/python3.4/site-packages/prompt_toolkit/key_bindi)
     24
     25     def call(self, event):
---> 26         return self._handler(event)
     27
     28     def __repr__(self):

/Users/ssilvester/anaconda/lib/python3.4/site-packages/prompt_toolkit/key_bindi)
     28                 if safe_before:
     29                     event.cli.current_buffer.save_to_undo_stack()
---> 30                 handler_func(event)
     31             return handler_func
     32         return decorator

/Users/ssilvester/anaconda/lib/python3.4/site-packages/prompt_toolkit/key_bindi)
    177         else:
    178             if b.accept_action.is_returnable:
--> 179                 b.accept_action.validate_and_handle(event.cli, b)
    180
    181     @handle(Keys.ControlK, filter= ~has_selection)

/Users/ssilvester/anaconda/lib/python3.4/site-packages/prompt_toolkit/buffer.py)
     71                 self.handler(cli, buffer)
     72
---> 73             buffer.append_to_history()
     74
     75

/Users/ssilvester/anaconda/lib/python3.4/site-packages/prompt_toolkit/buffer.py)
    889         # history is already the same.)
    890         if self.text and (not len(self._history) or self._history[-1] !:
--> 891             self._history.append(self.text)
    892
    893     def _search(self, search_state):

/Users/ssilvester/anaconda/lib/python3.4/site-packages/prompt_toolkit/history.p)
     70
     71         # Save to file.
---> 72         with open(self.filename, 'ab') as f:
     73             write = lambda t: f.write(t.encode('utf-8'))
     74

FileNotFoundError: [Errno 2] No such file or directory: '/Users/ssilvester/.ptp'

run ptipython in bash give error: No module named terminal.embed

I install with

pip install ptpython

the ptpython works ok, but when I try to run ptipython, it give the follow errors.

Traceback (most recent call last):
  File "/usr/local/bin/ptipython", line 9, in <module>
    load_entry_point('ptpython==0.5', 'console_scripts', 'ptipython')()
  File "/usr/local/lib/python2.7/dist-packages/ptpython/entry_points/run_ptipython.py", line 35, in run
    from ptpython.ipython import embed
  File "/usr/local/lib/python2.7/dist-packages/ptpython/ipython.py", line 25, in <module>
    from IPython.terminal.embed import InteractiveShellEmbed as _InteractiveShellEmbed
ImportError: No module named terminal.embed

I have tried to install terminal but it still not work.

Emacs run-python support ?

Hi @jonathanslenders , I love ptpython very much !

I would like to know how to support emacs' command M-x run-python ?

Before ptpython, I use Ipython for this:

(when (executable-find "ipython")
   (setq
    python-shell-interpreter "ipython"
    python-shell-interpreter-args ""
    python-shell-prompt-regexp "In \\[[0-9]+\\]: "
    python-shell-prompt-output-regexp "Out\\[[0-9]+\\]: "
    python-shell-completion-setup-code
    "from IPython.core.completerlib import module_completion"
    python-shell-completion-module-string-code
    "';'.join(module_completion('''%s'''))\n"
    python-shell-completion-string-code
    "';'.join(get_ipython().Completer.all_completions('''%s'''))\n")
 )

UnicodeDecodeError: 'ascii' codec can't decode byte 0x85 in position 0: ordinal

Typing class Test(object :


class Test(objectTraceback (most recent call last):
  File "C:\Python27\Scripts\ptpython-script.py", line 9, in <module>
    load_entry_point('ptpython==0.4', 'console_scripts', 'ptpython')()
  File "C:\Python27\lib\site-packages\ptpython\entry_points\run_ptpython.py", line 62, in run
    no_colors=no_colors, startup_paths=startup_paths)
  File "C:\Python27\lib\site-packages\ptpython\repl.py", line 208, in embed7.8
    repl.start_repl(startup_paths=startup_paths)
  File "C:\Python27\lib\site-packages\ptpython\repl.py", line 51, in start_repl
    on_exit=AbortAction.RAISE_EXCEPTION)
  File "C:\Python27\lib\site-packages\prompt_toolkit\interface.py", line 290, in read_input
    next(g)
  File "C:\Python27\lib\site-packages\prompt_toolkit\interface.py", line 356, in _read_input
    loop_result = self.eventloop.loop()
  File "C:\Python27\lib\site-packages\prompt_toolkit\eventloop\win32.py", line 44, in loop
    keys = self._console_input_reader.read()
  File "C:\Python27\lib\site-packages\prompt_toolkit\terminal\win32_input.py", line 121, in read
    key_presses = self._event_to_key_presses(ev)
  File "C:\Python27\lib\site-packages\prompt_toolkit\terminal\win32_input.py", line 141, in _event_to_key_presses
    result = KeyPress(ev.AsciiChar.decode('ascii'), ev.AsciiChar.decode('ascii'))
UnicodeDecodeError: 'ascii' codec can't decode byte 0x85 in position 0: ordinal
not in range(128)

I'm a windows with a french locale with Python 2.7. Remember, for your software to deal with non ascii characters :

  • use utf8 for all files;
  • use "from future import unicode_literals" for all files
  • when you got an input, use your_input.decode(input_encoding). User input, sql query, file reading, downloads are all inputs.
  • when you got an ouput, use your_ouput.encode(output_encoding). Terminal printing, sqlquery, writting in a file, HTTP post are all outputs.

Strange parsing errors

While typing the following lambda expression with two arguments, lambda a, b: a if a > b else b, I got a parsing error

It was fine at first

lambda a, b: a 

until I typed "space" and i, the error popped up

lambda a, b: a iException in thread Thread-18:
Traceback (most recent call last):
  File "/Users/zhangxiaowei/anaconda/lib/python3.4/site-packages/jedi/cache.py", line 141r
    return getattr(self, name)
AttributeError: 'UserContextParser' object has no attribute '__parser'

During handling of the above exception, another exception occurred:idebar - CPython 3.4.3

Traceback (most recent call last):
  File "/Users/zhangxiaowei/anaconda/lib/python3.4/site-packages/jedi/parser/__init__.py"s
    clear_names(c.children)
AttributeError: 'Name' object has no attribute 'children'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/zhangxiaowei/anaconda/lib/python3.4/site-packages/ptpython/utils.py", linet
    namespaces=[locals, globals])
  File "/Users/zhangxiaowei/anaconda/lib/python3.4/site-packages/jedi/api/__init__.py", l_
    self._parser.module())
  File "/Users/zhangxiaowei/anaconda/lib/python3.4/site-packages/jedi/parser/user_contexte
    return self._parser().module
  File "/Users/zhangxiaowei/anaconda/lib/python3.4/site-packages/jedi/cache.py", line 143r
    result = func(self)
  File "/Users/zhangxiaowei/anaconda/lib/python3.4/site-packages/jedi/parser/user_contextr
    parser = Parser(self._grammar, self._source, self._path)
  File "/Users/zhangxiaowei/anaconda/lib/python3.4/site-packages/jedi/parser/__init__.py"_
    self.module = p.parse(self._tokenize(tokenizer))
  File "/Users/zhangxiaowei/anaconda/lib/python3.4/site-packages/jedi/parser/pgen2/parse.e
    if self.addtoken(type, value, prefix, start_pos):
  File "/Users/zhangxiaowei/anaconda/lib/python3.4/site-packages/jedi/parser/pgen2/parse.n
    value, start_pos, prefix, self.addtoken)
  File "/Users/zhangxiaowei/anaconda/lib/python3.4/site-packages/jedi/parser/__init__.py"y
    self._stack_removal(grammar, stack, index + 1, value, start_pos)
  File "/Users/zhangxiaowei/anaconda/lib/python3.4/site-packages/jedi/parser/__init__.py"l
    clear_names(children=node[1])
  File "/Users/zhangxiaowei/anaconda/lib/python3.4/site-packages/jedi/parser/__init__.py"s
    clear_names(c.children)
  File "/Users/zhangxiaowei/anaconda/lib/python3.4/site-packages/jedi/parser/__init__.py"s
    clear_names(c.children)
  File "/Users/zhangxiaowei/anaconda/lib/python3.4/site-packages/jedi/parser/__init__.py"s
    self._scope_names_stack[-1][c.value].remove(c)
KeyError: 'a'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/zhangxiaowei/anaconda/lib/python3.4/threading.py", line 920, in _bootstrapr
    self.run()
  File "/Users/zhangxiaowei/anaconda/lib/python3.4/threading.py", line 868, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/zhangxiaowei/anaconda/lib/python3.4/site-packages/prompt_toolkit/interfacen
    CompleteEvent(text_inserted=True)))
  File "/Users/zhangxiaowei/anaconda/lib/python3.4/site-packages/prompt_toolkit/contrib/rs
    self._get_completions_for_match(m, complete_event))
  File "/Users/zhangxiaowei/anaconda/lib/python3.4/site-packages/prompt_toolkit/contrib/rs
    for i in items:
  File "/Users/zhangxiaowei/anaconda/lib/python3.4/site-packages/prompt_toolkit/contrib/rh
    for completion in completer.get_completions(document, complete_event):
  File "/Users/zhangxiaowei/anaconda/lib/python3.4/site-packages/ptpython/completer.py", s
    script = get_jedi_script_from_document(document, self.get_locals(), self.get_globals()
  File "/Users/zhangxiaowei/anaconda/lib/python3.4/site-packages/ptpython/utils.py", linet
    except jedi.common.MultiLevelStopIteration:
AttributeError: 'module' object has no attribute 'MultiLevelStopIteration'

Exception in thread Thread-19:
Traceback (most recent call last):
  File "/Users/zhangxiaowei/anaconda/lib/python3.4/site-packages/jedi/cache.py", line 141r
    return getattr(self, name)
AttributeError: 'UserContextParser' object has no attribute '__parser'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/zhangxiaowei/anaconda/lib/python3.4/site-packages/jedi/parser/__init__.py"s
    clear_names(c.children)
AttributeError: 'Name' object has no attribute 'children'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/zhangxiaowei/anaconda/lib/python3.4/site-packages/ptpython/utils.py", linet
    namespaces=[locals, globals])
  File "/Users/zhangxiaowei/anaconda/lib/python3.4/site-packages/jedi/api/__init__.py", l_
    self._parser.module())
  File "/Users/zhangxiaowei/anaconda/lib/python3.4/site-packages/jedi/parser/user_contexte
    return self._parser().module
  File "/Users/zhangxiaowei/anaconda/lib/python3.4/site-packages/jedi/cache.py", line 143r
    result = func(self)
  File "/Users/zhangxiaowei/anaconda/lib/python3.4/site-packages/jedi/parser/user_contextr
    parser = Parser(self._grammar, self._source, self._path)
  File "/Users/zhangxiaowei/anaconda/lib/python3.4/site-packages/jedi/parser/__init__.py"_
    self.module = p.parse(self._tokenize(tokenizer))
  File "/Users/zhangxiaowei/anaconda/lib/python3.4/site-packages/jedi/parser/pgen2/parse.e
    if self.addtoken(type, value, prefix, start_pos):
  File "/Users/zhangxiaowei/anaconda/lib/python3.4/site-packages/jedi/parser/pgen2/parse.n
    value, start_pos, prefix, self.addtoken)
  File "/Users/zhangxiaowei/anaconda/lib/python3.4/site-packages/jedi/parser/__init__.py"y
    self._stack_removal(grammar, stack, index + 1, value, start_pos)
  File "/Users/zhangxiaowei/anaconda/lib/python3.4/site-packages/jedi/parser/__init__.py"l
    clear_names(children=node[1])
  File "/Users/zhangxiaowei/anaconda/lib/python3.4/site-packages/jedi/parser/__init__.py"s
    clear_names(c.children)
  File "/Users/zhangxiaowei/anaconda/lib/python3.4/site-packages/jedi/parser/__init__.py"s
    clear_names(c.children)
  File "/Users/zhangxiaowei/anaconda/lib/python3.4/site-packages/jedi/parser/__init__.py"s
    self._scope_names_stack[-1][c.value].remove(c)
KeyError: 'a'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/zhangxiaowei/anaconda/lib/python3.4/threading.py", line 920, in _bootstrapr
    self.run()
  File "/Users/zhangxiaowei/anaconda/lib/python3.4/threading.py", line 868, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/zhangxiaowei/anaconda/lib/python3.4/site-packages/ptpython/python_input.pyn
    script = get_jedi_script_from_document(document, self.get_locals(), self.get_globals()
  File "/Users/zhangxiaowei/anaconda/lib/python3.4/site-packages/ptpython/utils.py", linet
    except jedi.common.MultiLevelStopIteration:
AttributeError: 'module' object has no attribute 'MultiLevelStopIteration'

Not work in virtualenv

Traceback (most recent call last):
File "/home/dos/.virtualenvs/accommodirect/bin/ptpython", line 5, in
from pkg_resources import load_entry_point
File "/home/dos/.virtualenvs/accommodirect/lib/python2.7/site-packages/pkg_resources/init.py", line 3018, in
working_set = WorkingSet._build_master()
File "/home/dos/.virtualenvs/accommodirect/lib/python2.7/site-packages/pkg_resources/init.py", line 614, in _build_master
return cls._build_from_requirements(requires)
File "/home/dos/.virtualenvs/accommodirect/lib/python2.7/site-packages/pkg_resources/init.py", line 627, in _build_from_requirements
dists = ws.resolve(reqs, Environment())
File "/home/dos/.virtualenvs/accommodirect/lib/python2.7/site-packages/pkg_resources/init.py", line 805, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: jedi>=0.8.1

pip freeze | grep jedi
jedi==0.8.1-final0

feature request, for a better completion experiments.

hi, the ptpython is really awesome. the line edit was always what I want. the vi/emacs keybinds really go beyond my hope for python-shell.

the complete is beautiyf too. use the old ipython, the completion always pollute my screen too much.
but there was a problem, most time I really donot remember what the attr or function I was looking for. the old ipython give all of it, so I may choose. the ptipython give only some of it, I have to ... to
look through it. that's not good.

I request you may look at the zsh completion. It output all the output under the current cursor but not pollute the screen, and when you finish edit, it clear the completion-output.

Interactive mode with ptipython

ptipython --vi --interactive=<file_name>

I cannot seem to get this working. Am I missing something or this feature does not exist?

`%load` command does not work in ptipython

When using ipython in ptpython mode (aka ptipython), I found the %load magic command does not work for me. The %load command is intend to load a file onto the ipython frontend so that people can edit & run it, when it runs normally in ipython, it looks like this:

image

But in ptipython nothing happens:

image

Until now most commands I used commonly works fine, only %load failed to work, if more happens, I will keep on report it here. BTW, here is a list of complete magic commands in ipython.

Versions:
Python 2.7.9
ipython==3.2.1
ptpython==0.18

Ptipython within django extensions

ptipython ignores both /home/shane/ptpython/config.py and ~/.pythonrc.py
when run from django extensions, aka python manage.py shell_plus. There doesn't seem to be anyway to override those configurations

Connect to existing kernel

ptipython does not appear to have a command line option to connect to an existing kernel.

Is there anything similar to the command below that forces ptipython to use an existing kernel rather than creating a new one

ipython console --existing

Autocomplete doesn't work on windows

I've installed it on windows 8.1 and python 2.7.9. Output is colored and everything but I don't get any autocompletion. I tried pressing TAB - is autocomplete bound to a different key?!

ptipython ImportError: No module named IPython.terminal.embed

$ ptipython 
Traceback (most recent call last):
  File "/home/arthur/.virtualenvs/ptpython/bin/ptipython", line 9, in <module>
    load_entry_point('prompt-toolkit==0.21', 'console_scripts', 'ptipython')()
  File "/home/arthur/.virtualenvs/ptpython/local/lib/python2.7/site-packages/pkg_resources.py", line 353, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/home/arthur/.virtualenvs/ptpython/local/lib/python2.7/site-packages/pkg_resources.py", line 2321, in load_entry_point
    return ep.load()
  File "/home/arthur/.virtualenvs/ptpython/local/lib/python2.7/site-packages/pkg_resources.py", line 2048, in load
    entry = __import__(self.module_name, globals(),globals(), ['__name__'])
  File "/home/arthur/.virtualenvs/ptpython/local/lib/python2.7/site-packages/prompt_toolkit/contrib/entry_points/ptipython.py", line 22, in <module>
    from prompt_toolkit.contrib.ipython import embed
  File "/home/arthur/.virtualenvs/ptpython/local/lib/python2.7/site-packages/prompt_toolkit/contrib/ipython.py", line 18, in <module>
    from IPython.terminal.embed import InteractiveShellEmbed as _InteractiveShellEmbed
ImportError: No module named IPython.terminal.embed

"!system cmd" does not work becase of syntax validation

This section of repr.py makes it possible to run system commands when the line is prefixed with !, but the syntax validator prevents the execution for a ! on the beginning of a line is syntax error in python.

I fixed it temporally by adding if document.text.lstrip().startswith('!'): return to the beginning of PythonValidator.validate but I am not sure if it is the right place for it.

add banner argument in ptpython.repl.embed

There is no option to display a banner text when instantiating a new shell from ptpython.repl.embed.
Both IPython.terminal.embed.InteractiveShellEmbed and bpython.embed have a banner argument that I can pass a text to display to.

RuntimeError: dictionary changed size during iteration (Traceback @ #pyconfr2014 )

When typing tab for completion after "import os." I get. This might be a jedi bug but am posting it here first.

In [3]: import os.Exception in thread Thread-49:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
    self.run()
  File "/home/arthur/.virtualenvs/ptpython/local/lib/python2.7/site-packages/prompt_toolkit/eventloop/base.py", 
    callback()
  File "/home/arthur/.virtualenvs/ptpython/local/lib/python2.7/site-packages/prompt_toolkit/__init__.py", line 3
    completions = list(line.completer.get_completions(document))
  File "/home/arthur/.virtualenvs/ptpython/local/lib/python2.7/site-packages/prompt_toolkit/contrib/python_input
    completions = script.completions()
  File "/home/arthur/.virtualenvs/ptpython/local/lib/python2.7/site-packages/jedi/api/__init__.py", line 157, in
    completions = get_completions(user_stmt, b)
  File "/home/arthur/.virtualenvs/ptpython/local/lib/python2.7/site-packages/jedi/api/__init__.py", line 136, in
    return self._simple_complete(path, like)
  File "/home/arthur/.virtualenvs/ptpython/local/lib/python2.7/site-packages/jedi/api/__init__.py", line 648, in
    return super(Interpreter, self)._simple_complete(path, like)
  File "/home/arthur/.virtualenvs/ptpython/local/lib/python2.7/site-packages/jedi/api/__init__.py", line 228, in
    names = s.get_defined_names(on_import_stmt=True)
  File "/home/arthur/.virtualenvs/ptpython/local/lib/python2.7/site-packages/jedi/evaluate/imports.py", line 94,
    for scope in self.follow():
  File "/home/arthur/.virtualenvs/ptpython/local/lib/python2.7/site-packages/jedi/evaluate/imports.py", line 171
    module, rest = self._importer.follow_file_system()
  File "/home/arthur/.virtualenvs/ptpython/local/lib/python2.7/site-packages/jedi/evaluate/cache.py", line 39, i
    rv = function(obj, *args, **kwargs)
  File "/home/arthur/.virtualenvs/ptpython/local/lib/python2.7/site-packages/jedi/evaluate/imports.py", line 365
    module, rest = self._follow_sys_path(sys_path_mod)
  File "/home/arthur/.virtualenvs/ptpython/local/lib/python2.7/site-packages/jedi/evaluate/imports.py", line 469
    return _load_module(path, source, sys_path=sys_path), rest
  File "/home/arthur/.virtualenvs/ptpython/local/lib/python2.7/site-packages/jedi/evaluate/imports.py", line 527
    return load(source) if cached is None else cached.module
  File "/home/arthur/.virtualenvs/ptpython/local/lib/python2.7/site-packages/jedi/evaluate/imports.py", line 523
    cache.save_parser(path, name, p)
  File "/home/arthur/.virtualenvs/ptpython/local/lib/python2.7/site-packages/jedi/cache.py", line 241, in save_p
    ParserPickling.save_parser(n, item)
  File "/home/arthur/.virtualenvs/ptpython/local/lib/python2.7/site-packages/jedi/cache.py", line 302, in save_p
    pickle.dump(parser_cache_item, f, pickle.HIGHEST_PROTOCOL)
RuntimeError: dictionary changed size during iteration

"ImportError: cannot import name windll" on Mac OS X

When I launch on Mac OS X 10.9.5, Python 2.7.5 I get the error below. I also get the same error in a new virtualenv.

I guess this might be a prompt_toolkit bug but I thought I'd start here.

Thanks.

โžœ ~ ptpython
Traceback (most recent call last):
File "/usr/local/bin/ptpython", line 7, in
from ptpython.entry_points.run_ptpython import run
File "/Library/Python/2.7/site-packages/ptpython/entry_points/run_ptpython.py", line 25, in
from ptpython.repl import embed, enable_deprecation_warnings, run_config
File "/Library/Python/2.7/site-packages/ptpython/repl.py", line 16, in
from prompt_toolkit.application import AbortAction
File "/Library/Python/2.7/site-packages/prompt_toolkit/init.py", line 16, in
from .interface import CommandLineInterface
File "/Library/Python/2.7/site-packages/prompt_toolkit/interface.py", line 22, in
from .input import StdinInput, Input
File "/Library/Python/2.7/site-packages/prompt_toolkit/input.py", line 14, in
from .terminal.win32_input import raw_mode, cooked_mode
File "/Library/Python/2.7/site-packages/prompt_toolkit/terminal/win32_input.py", line 1, in
from ctypes import windll, pointer
ImportError: cannot import name windll

FileNotFoundError: [Errno 2] No such file or directory: '/home/angerer/.ptpython/history'

when executing any first of code in ptipython, i get this:

FileNotFoundError                         Traceback (most recent call last)
/usr/lib/python3.4/site-packages/ptpython/ipython.py in raw_input(self, prompt)
    196         print('')ore        
    197         try:    display     
--> 198             string = self._cli.run().text
    199 acs   1/1   [F6] Paste mode (off)                                                                                                                                              [F2] Options - CPython 3.4.3 
    200             # In case of multiline input, make sure to append a newline to the input,

/usr/lib/python3.4/site-packages/prompt_toolkit/interface.py in run(self, reset_current_buffer)
    272                 self._redraw()
    273 
--> 274                 self.eventloop.run(self.input, self.create_eventloop_callbacks())
    275         finally:
    276             # Clean up renderer. (This will leave the alternate screen, if we use

/usr/lib/python3.4/site-packages/prompt_toolkit/eventloop/posix.py in run(self, stdin, callbacks)
     85                     # Feed input text.
     86                     data = stdin_reader.read()
---> 87                     inputstream.feed(data)
     88                     callbacks.redraw()
     89 

/usr/lib/python3.4/site-packages/prompt_toolkit/terminal/vt100_input.py in feed(self, data)
    300             if c == '\r':
    301                 c = '\n'
--> 302             self._input_parser.send(c)
    303 
    304     def flush(self):

/usr/lib/python3.4/site-packages/prompt_toolkit/terminal/vt100_input.py in _input_parser_generator(self)
    252                 # Exact matches found, call handlers..
    253                 if (flush or not is_prefix_of_longer_match) and match:
--> 254                     self._call_handler(match, prefix)
    255                     prefix = ''
    256 

/usr/lib/python3.4/site-packages/prompt_toolkit/terminal/vt100_input.py in _call_handler(self, key, insert_text)
    281                 self._call_handler(k, insert_text)
    282         else:
--> 283             self.feed_key_callback(KeyPress(key, insert_text))
    284 
    285     def feed(self, data):

/usr/lib/python3.4/site-packages/prompt_toolkit/interface.py in feed_key(self, key_press)
    605         """
    606         # Feed the key and redraw.
--> 607         self.cli.input_processor.feed_key(key_press)
    608 
    609     def redraw(self):

/usr/lib/python3.4/site-packages/prompt_toolkit/key_binding/input_processor.py in feed_key(self, key_press)
    163             self.beforeKeyPress.fire()
    164 
--> 165         self._process_coroutine.send(key_press)
    166 
    167         if key_press.key != Keys.CPRResponse:

/usr/lib/python3.4/site-packages/prompt_toolkit/key_binding/input_processor.py in _process(self)
    135                 # Exact matches found, call handler.
    136                 if not is_prefix_of_longer_match and matches:
--> 137                     self._call_handler(matches[-1], key_sequence=buffer)
    138                     buffer = []
    139 

/usr/lib/python3.4/site-packages/prompt_toolkit/key_binding/input_processor.py in _call_handler(self, handler, key_sequence)
    174         event = Event(weakref.ref(self), arg=arg, key_sequence=key_sequence,
    175                       previous_key_sequence=self._previous_key_sequence)
--> 176         handler.call(event)
    177         self._registry.on_handler_called.fire(event)
    178 

/usr/lib/python3.4/site-packages/prompt_toolkit/key_binding/registry.py in call(self, event)
     24 
     25     def call(self, event):
---> 26         return self._handler(event)
     27 
     28     def __repr__(self):

/usr/lib/python3.4/site-packages/prompt_toolkit/key_binding/bindings/utils.py in wrapper(event)
     28                 if safe_before:
     29                     event.cli.current_buffer.save_to_undo_stack()
---> 30                 handler_func(event)
     31             return handler_func
     32         return decorator

/usr/lib/python3.4/site-packages/prompt_toolkit/key_binding/bindings/basic.py in _(event)
    177         else:
    178             if b.accept_action.is_returnable:
--> 179                 b.accept_action.validate_and_handle(event.cli, b)
    180 
    181     @handle(Keys.ControlK, filter= ~has_selection)

/usr/lib/python3.4/site-packages/prompt_toolkit/buffer.py in validate_and_handle(self, cli, buffer)
     71                 self.handler(cli, buffer)
     72 
---> 73             buffer.append_to_history()
     74 
     75 

/usr/lib/python3.4/site-packages/prompt_toolkit/buffer.py in append_to_history(self)
    898         # history is already the same.)
    899         if self.text and (not len(self._history) or self._history[-1] != self.text):
--> 900             self._history.append(self.text)
    901 
    902     def _search(self, search_state):

/usr/lib/python3.4/site-packages/prompt_toolkit/history.py in append(self, string)
     70 
     71         # Save to file.
---> 72         with open(self.filename, 'ab') as f:
     73             write = lambda t: f.write(t.encode('utf-8'))
     74 

FileNotFoundError: [Errno 2] No such file or directory: '/home/angerer/.ptpython/history'

Exception in jedi crashes ptpython

The following crashes ptpython, it exists (with status 1) immediately after entering the '=' sign.

In [1]: import aiohttp
In [2]: aiohttp.ProxyConnector(proxy=Traceback (most recent call last):
  File "/home/pgy/.pyenv/versions/3.4.3/bin/ptpython", line 11, in <module>
    sys.exit(run())                            
  File "/home/pgy/.pyenv/versions/3.4.3/lib/python3.4/site-packages/ptpython/entry_pointn
    startup_paths=startup_paths)               
  File "/home/pgy/.pyenv/versions/3.4.3/lib/python3.4/site-packages/ptpython/repl.py", ld
    cli.run()                                  
  File "/home/pgy/.pyenv/versions/3.4.3/lib/python3.4/site-packages/prompt_toolkit/intern
    self.eventloop.run(self.input, self.create_eventloop_callbacks())
  File "/home/pgy/.pyenv/versions/3.4.3/lib/python3.4/site-packages/prompt_toolkit/eventn
    c()                                        
  File "/home/pgy/.pyenv/versions/3.4.3/lib/python3.4/site-packages/prompt_toolkit/interw
    is_done=self.is_done)                      
  File "/home/pgy/.pyenv/versions/3.4.3/lib/python3.4/site-packages/prompt_toolkit/render
    extended_height=size.rows,
  File "/home/pgy/.pyenv/versions/3.4.3/lib/python3.4/site-packages/prompt_toolkit/layoun
    c.write_to_screen(cli, screen, WritePosition(xpos, ypos, width, s))r - CPython 3.4.3 
  File "/home/pgy/.pyenv/versions/3.4.3/lib/python3.4/site-packages/prompt_toolkit/layoun
    c.write_to_screen(cli, screen, WritePosition(xpos, ypos, s, height))
  File "/home/pgy/.pyenv/versions/3.4.3/lib/python3.4/site-packages/prompt_toolkit/layoun
    c.write_to_screen(cli, screen, WritePosition(xpos, ypos, width, s))
  File "/home/pgy/.pyenv/versions/3.4.3/lib/python3.4/site-packages/prompt_toolkit/layoun
    width = fl.content.width(cli).preferred
  File "/home/pgy/.pyenv/versions/3.4.3/lib/python3.4/site-packages/prompt_toolkit/layouh
    preferred_width = self.content.preferred_width(cli)
  File "/home/pgy/.pyenv/versions/3.4.3/lib/python3.4/site-packages/prompt_toolkit/layouh
    text = ''.join(t[1] for t in self.get_tokens(cli))
  File "/home/pgy/.pyenv/versions/3.4.3/lib/python3.4/site-packages/ptpython/layout.py",s
    for i, p in enumerate(sig.params):
  File "/home/pgy/.pyenv/versions/3.4.3/lib/python3.4/site-packages/jedi/evaluate/cache.r
    rv = function(obj, *args, **kwargs)
  File "/home/pgy/.pyenv/versions/3.4.3/lib/python3.4/site-packages/jedi/api/classes.py"s
    return [_Param(self._evaluator, p.name) for p in params]
  File "/home/pgy/.pyenv/versions/3.4.3/lib/python3.4/site-packages/jedi/api/classes.py">
    return [_Param(self._evaluator, p.name) for p in params]
  File "/home/pgy/.pyenv/versions/3.4.3/lib/python3.4/site-packages/jedi/evaluate/cache.r
    rv = function(obj, *args, **kwargs)
  File "/home/pgy/.pyenv/versions/3.4.3/lib/python3.4/site-packages/jedi/evaluate/cache._
    return super(CachedMetaClass, self).__call__(*args, **kwargs)
  File "/home/pgy/.pyenv/versions/3.4.3/lib/python3.4/site-packages/jedi/api/classes.py"_
    super(Definition, self).__init__(evaluator, definition)
  File "/home/pgy/.pyenv/versions/3.4.3/lib/python3.4/site-packages/jedi/api/classes.py"_
    self._definition = evaluator.wrap(self._name.get_definition())
AttributeError: 'Operator' object has no attribute 'get_definition'

IPython+Ubuntu won't autocomplete on %run

Hello, I've just seen your rather awesome library. Some of it works great, a common feature that I use ("%run ") doesn't work. Maybe I'm missing something?

I'm on Ubuntu (Linux Mint 17.1 based on Ubuntu 14.04), using Python 3.4.2 (via Anaconda) with ptpython 0.4 (installed using pip today) and IPython 2.2.0. I'm using a default Ubuntu terminal.

If I type:
$ ptipython
...
In [1]: open("i
insert_pickle_into_elasticsearch.py File <- really neat autocompletion!
but if I try:
In [1]: %run i <- nothing happens, no autocompleteion
and if I continue to type the filename (e.g. "%run insert_") and try tab, nothing happens and there are no options. Does Jedi know about %run filename completion?

If I use the exclamation-mark shell convention:
In [1]: !autopep8 -i insert_
to run a shell command outside of IPython, tab completion fails here too (but if I type the full filename, autopep8 works as expected).

Both the above examples work with tab completion inside a normal IPython shell.

Sidenote - I'm not sure how the keybindings work on other platforms but if I use Ctrl-Shift-N (as noted in your README "Tab and shift+tab complete the input. In Vi-mode, you can also use Ctrl+N and Ctrl+P.") then I get a new Ubuntu Terminal (!).

I'll keep tabs on this, it looks most promising!

Confirmation on exit

Hi, I am wondering why ptpython doesn't ask confirm to exit.

As you know, Ctrl+D is used for backspace on some platforms.
So, when using ptpython, I often hit Ctrl+D by mistake and ptpython exits unintentionally.

I wrote some code to prevent this as ipython does.
Does someone agree with me?

ptpython can't import a local package named `test`

I've got a 'test' package in the top-level of my project that I'm trying to import a file from, but ptpython (and ptipython) won't let me. It seems to be picking the test package from the python standard library instead. Plain python (and plain ipython) do not have this problem. This is on python3, though I haven't tested with python2.

Steps to reproduce:

$ mkdir python-test
$ cd python-test
$ mkvirtualenv -p /usr/local/bin/python3 python-test
$ pip install ptpython
$ mkdir test
$ touch test/__init__.py
$ touch test/schema_data.py

And demonstration of the bug:

$ python
Python 3.4.1 (default, Aug 24 2014, 21:31:55)
[GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import test.schema_data
>>> quit()
$ ptpython
In [1]: import test.schema_data
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'test.schema_data'
No module named 'test.schema_data'

In [2]: import test

In [3]: test
Out[3]: <module 'test' from '/usr/local/Cellar/python3/3.4.1_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/test/__init__.py'>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.