All Projects → gabrielcnr → python-ls

gabrielcnr / python-ls

Licence: MIT license
Think about Python's dir builtin with recursive search capabilities

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to python-ls

chrome-trace
Process Chrome trace logs in Node.
Stars: ✭ 15 (-65.91%)
Mutual labels:  devtools
VirionTools
A handy plugin for developers who wish to compile and inject virions without using Poggit.
Stars: ✭ 17 (-61.36%)
Mutual labels:  devtools
svelte-toy
A toy for svelte data stores
Stars: ✭ 73 (+65.91%)
Mutual labels:  devtools
devtools-highlighter
DevTools extension that finds and highlights elements in the page
Stars: ✭ 29 (-34.09%)
Mutual labels:  devtools
code-fold
Write the pattern, then let your code write itself.
Stars: ✭ 13 (-70.45%)
Mutual labels:  devtools
epirus-cli
Epirus SDK CLI
Stars: ✭ 18 (-59.09%)
Mutual labels:  devtools
hitboxtracker
🔨 Dev-tool that demonstrates on client-side true position of the hitboxes calculated by server
Stars: ✭ 34 (-22.73%)
Mutual labels:  devtools
clockwork-firefox
Clockwork - php dev tools integrated to your browser - Firefox add-on
Stars: ✭ 22 (-50%)
Mutual labels:  devtools
pandacash-cli
🐼Fast Bitcoin Cash RPC client for testing and development (inspired by ganache-cli)
Stars: ✭ 19 (-56.82%)
Mutual labels:  devtools
rx-devtools
DevTools for RxJS
Stars: ✭ 30 (-31.82%)
Mutual labels:  devtools
objbrowser
GUI for Python object introspection
Stars: ✭ 111 (+152.27%)
Mutual labels:  inspection
grav-plugin-devtools
Grav Devtools Plugin
Stars: ✭ 36 (-18.18%)
Mutual labels:  devtools
gitcount
A command-line tool to estimate the time spent on a git project, based on a very simple heuristic
Stars: ✭ 25 (-43.18%)
Mutual labels:  devtools
exlcode-chrome
EXLcode - VS Code-based Online IDE Chrome Extension
Stars: ✭ 18 (-59.09%)
Mutual labels:  devtools
hotelier
Tray App for Hotel Process Manager
Stars: ✭ 46 (+4.55%)
Mutual labels:  devtools
prosemirror-dev-toolkit
Injectable developer tools for ProseMirror rich-text editors implemented in Svelte and TypeScript.
Stars: ✭ 44 (+0%)
Mutual labels:  devtools
vue
Vue integration for Nano Stores, a tiny state manager with many atomic tree-shakable stores
Stars: ✭ 25 (-43.18%)
Mutual labels:  devtools
audria
audria - A Utility for Detailed Ressource Inspection of Applications
Stars: ✭ 35 (-20.45%)
Mutual labels:  inspection
PowerColorLS
PowerShell script to display a colorized directory and file listing with icons
Stars: ✭ 35 (-20.45%)
Mutual labels:  dir
devtools
A simple set of tools for teams building live Carbon pages.
Stars: ✭ 31 (-29.55%)
Mutual labels:  devtools

python-ls

A better replacement for Python's built-in dir function with searching in mind.

Build Status PyPI PythonVersions

Sometimes when you're developing using Python's interactive shell, or IPython, or working with a Jupyter Notebook or even debugging using pdb, you find yourself having to navigate through complex object structures. If you're not entirely familiar with the class in hand you usually have two options: resort to the documentation of the libraries and projects you're working with, or put the explorer's hat on and go down a trial-and-error route, using Python's builtin dir function to see which attributes and functions an object may have and then take a good guess on the next object you will be inspecting.

There must be a better way, right?

Well, now yes, you have ls to help you with that task. If you have rough idea of what you're looking for, you can search for that "thing" by name (fingers crossed here: hopefully the developers of the APIs/libraries you're dealing with were careful enough about their naming conventions). Even if (often) your target object may be a few levels deep down the object structure.

ls goes recursively through your object structure, it tries to visit attributes searching for the name you're looking for. It also considers dictionary keys if it stumbles across dictionaries, and in the end it prints out the matching occurrences and tells you their types too.

>>> ls(ls, 'code', depth=3)
func_code                                                                             code
func_code.co_code                                                                      str    200
func_code.co_code.decode()                                      builtin_function_or_method
func_code.co_code.encode()                                      builtin_function_or_method
func_code.co_filename.decode()                                  builtin_function_or_method
func_code.co_filename.encode()                                  builtin_function_or_method
func_code.co_lnotab.decode()                                    builtin_function_or_method
func_code.co_lnotab.encode()                                    builtin_function_or_method
func_code.co_name.decode()                                      builtin_function_or_method
func_code.co_name.encode()                                      builtin_function_or_method
func_globals['xdir'].func_code                                                        code
func_globals['iter_ls'].func_code                                                     code

Install

pip install python-ls

ls available as builtin

python-ls will inject the ls function in the __builtin__ namespace at installation step.

It does this by using a .pth file which simply performs that injection.

Security

If you're running this against objects that have properties, lazy attributes or any other dynamic code, keep in mind that ls will try to fetch the value of the property/lazy attribute using getattr(). This will cause the body of the function to be executed, so you can imagine already the potential hazard here, right?

TODO: make a default unsafe=False kwarg and then only visit properties if unsafe is explicitly set to True.

About the name ls

Python has dir as a builtin. The equivalent of that command-line command in GNU/Linux world is ls. We had considered calling it xdir, which by the way is a function that works like dir() by returning a list of occurrences to you.

Contribute!

Please send your issues, bug reports and, even more welcome, your Pull Requests ;-)

Enjoy!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].