{"id":16928573,"url":"https://github.com/gokcehan/picon","last_synced_at":"2025-07-23T17:05:09.627Z","repository":{"id":57452541,"uuid":"128543051","full_name":"gokcehan/picon","owner":"gokcehan","description":"Run your code in python interactive console from the command line","archived":false,"fork":false,"pushed_at":"2020-08-23T21:49:50.000Z","size":6,"stargazers_count":81,"open_issues_count":1,"forks_count":2,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-02-27T20:24:38.209Z","etag":null,"topics":["python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gokcehan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-04-07T15:42:09.000Z","updated_at":"2024-07-25T15:28:02.000Z","dependencies_parsed_at":"2022-09-02T10:10:55.047Z","dependency_job_id":null,"html_url":"https://github.com/gokcehan/picon","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gokcehan%2Fpicon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gokcehan%2Fpicon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gokcehan%2Fpicon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gokcehan%2Fpicon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gokcehan","download_url":"https://codeload.github.com/gokcehan/picon/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243852438,"owners_count":20358270,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["python"],"created_at":"2024-10-13T20:37:08.293Z","updated_at":"2025-03-17T07:31:54.150Z","avatar_url":"https://github.com/gokcehan.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Picon\n\n`picon` runs your code in python interactive console from the command line.\nBesides other purposes, it can be easily integrated to your editor to create a live worksheet environment.\nThis is useful to evaluate your code on the fly and show you the result right below the code within your editor:\n\n![demo-screencast](https://media.giphy.com/media/8cBhMZtAy4v0YdMrQJ/giphy.gif)\n\n## Installation\n\nYou can install `picon` as a python package using `pip`:\n\n    pip install picon\n\nOr you can download it from github and put it somewhere in `$PATH`:\n\n    curl https://raw.githubusercontent.com/gokcehan/picon/master/picon/picon.py -o picon\n    chmod +x picon\n    mkdir -p ~/.local/bin\n    mv picon ~/.local/bin\n\n## Usage\n\n`picon` is implemented as a thin wrapper around [code](https://docs.python.org/3/library/code.html) module to be used as a command line application.\nThere are three running modes available in `picon`.\nFollowing example code is used for demonstration:\n\n    $ cat demo.py\n    'hello world'\n\n    x = 42\n    x\n    print(x)\n\n    y\n\n    total = 0\n    for i in range(1000):\n        if i % 3 == 0 or i % 5 == 0:\n            total += i\n\n    total\n\nDefault mode evaluates the code and only shows the output.\nThis is similar to running your code with `python` but it uses interactive console semantics (see syntax section below):\n\n    $ picon demo.py\n    'hello world'\n    42\n    42\n    Traceback (most recent call last):\n      File \"\u003cconsole\u003e\", line 1, in \u003cmodule\u003e\n    NameError: name 'y' is not defined\n    233168\n\nLive mode shows the code and the output as in a live session.\nThis can be used to prepare programming notes or documentation:\n\n    $ picon demo.py -l\n    \u003e\u003e\u003e 'hello world'\n    'hello world'\n    \u003e\u003e\u003e\n    \u003e\u003e\u003e x = 42\n    \u003e\u003e\u003e x\n    42\n    \u003e\u003e\u003e print(x)\n    42\n    \u003e\u003e\u003e\n    \u003e\u003e\u003e y\n    Traceback (most recent call last):\n      File \"\u003cconsole\u003e\", line 1, in \u003cmodule\u003e\n    NameError: name 'y' is not defined\n    \u003e\u003e\u003e\n    \u003e\u003e\u003e total = 0\n    \u003e\u003e\u003e for i in range(1000):\n    ...     if i % 3 == 0 or i % 5 == 0:\n    ...         total += i\n    ...\n    \u003e\u003e\u003e total\n    233168\n\nAppend mode appends the output as comments below the code.\nA pipe character (`|`) is added to differentiate these comments from regular ones and strip them in consequent executions.\nThis mode is designed to be integrated to editors to create a live worksheet environment:\n\n    $ picon demo.py -a\n    'hello world'\n    #|'hello world'\n\n    x = 42\n    x\n    #|42\n    print(x)\n    #|42\n\n    y\n    #|Traceback (most recent call last):\n    #|  File \"\u003cconsole\u003e\", line 1, in \u003cmodule\u003e\n    #|NameError: name 'y' is not defined\n\n    total = 0\n    for i in range(1000):\n        if i % 3 == 0 or i % 5 == 0:\n            total += i\n\n    total\n    #|233168\n\n## Syntax\n\nSyntax of python interactive console differs from regular python in two main aspects.\nFirst, return values are automatically shown without a `print` statement:\n\n    $ cat return.py\n    x = 42\n    x\n    print(x)\n    $ python return.py\n    42\n    $ picon return.py\n    42\n    42\n\nSecond, blocks are separated with blank newlines in addition to indentation:\n\n    $ cat block.py\n    if True:\n        print('one')\n\n        print('two')\n    $ python block.py\n    one\n    two\n    $ picon block.py\n    one\n      File \"\u003cconsole\u003e\", line 1\n        print('two')\n        ^\n    IndentationError: unexpected indent\n\nHaving blank trailing spaces equal to the indentation works in interactive console but not in `picon`.\n\n## Vim Integration\n\nSimply running `:%!picon -a` evaluates the buffer content and puts the output as comments below the code.\nIn order to keep the cursor position fixed and join undo operations to a single step you can use a command similar to the following:\n\n    command! Picon exe 'normal m`' | silent! undojoin | exe '%!picon -a' | exe 'normal ``'\n\nYou may want to assign this command to either `BufWritePre` event to run on save and/or `CursorHold` event to run on idle as follows (see also `:h updatetime`):\n\n    autocmd Filetype python autocmd BufWritePre \u003cbuffer\u003e Picon\n    autocmd Filetype python autocmd CursorHold  \u003cbuffer\u003e Picon\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgokcehan%2Fpicon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgokcehan%2Fpicon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgokcehan%2Fpicon/lists"}