Skip to main content

Easy creation of import hooks to test ideas.

Project description

ideas

Easy creation of custom import hooks to try out new ideas for Python's syntax.

ideas logo

Documentation

Everything you need (will eventually) be found here.

Installation

python -m pip install ideas

Dependencies

Python 3.6+. No third-party library is installed when you install ideas.

Some examples include might require to intall some third-party modules from Pypi.

Usage

Suppose that you want to use function as a keyword in Python, to mean the same thing as lambda, enabling you to write

# my_program.py

square = function x: x**2
print(f"{square(4)} is the square of 4.")

There is already an example import hook that allows you to do so. To use it, you could start by creating the following program

# Lets's call this 'loader.py'

from ideas.examples import function
function.add_hook()

import my_program

and then run

python loader.py

So, my_program.py , and any other module that could be loaded by it would recognize that function is a valid alternative to lambda.

Many more examples can be found in the documentation. To actually find out how you can create your own custom import hooks, you also need to refer to the documentation.

Tools

This project uses black for formatting, pytest for running tests, and flake8 for linting.

Contact

You can either file an issue or email me at Andre.Roberge@gmail.com.

License

MIT - see the file listed above.

Infrequently asked questions and comments

The following imaginary dialogue has been created before anyone else knew about this project.

Why?

Because it is fun. If this is not enough of a justification for you, have a look at motivation which contains a longer, and possibly more serious answer.

Is it safe to use in production code?

No.

But your example works perfectly well in my code; can I use it in my project?

I don't think you should if your project is to be used by anyone else but yourself.

I found a bug.

Wonderful, please file an issue so that I can perhaps fix it. Note however that some examples, which are known to fail in some contexts, would be too complex ensure that they always work in all contexts.

I found a cool use of import hooks in another project, different from all of your examples.

Please, give me the details and I will see if I can easily include a similar example and if I think it is worthwhile to do so.

Can I contribute code for a new example?

Yes, please, by all means. But I suggest that you first create an issue that gives an overview of what you wish to accomplish.

I think that the explanation you have written for X could be improved upon.

Please tell me more by filing an issue first and possibly creating a pull-request afterwards.

I have an idea for a new example, but do not know how to write the code for it.

First, make sure you go through all of the existing examples to confirm that none can easily be adapted to do what you want. If that is the case, file an issue ... but please don't be offended if I don't write code for it and end up closing the issue: I already have too many ideas of my own for this project, too many other projects, and not enough time to do all that I want.

In file X.py, you do not respect convention Y from PEP-8. This is unacceptable in a Python project.

Seriously? This project is all about exploring potential changes to Python's syntax, some of which are downright crazy, and you complain about a PEP-8 violation? ...

Ok, perhaps you can tell me and it might make sense to change what I wrote.

People from the Python-ideas mailing lists mentioned that I should look at this project for my idea, but I don't know where to start.

Please, have a look at the documentation. If you go through all the examples in the order that they are presented, you might learn how to implement your idea.

What about something like from __future__ import braces?

No. See Examples that will never be included.

You're no fun. Anyway, why this silly name for a project? The word "ideas" has nothing to do with import hooks in Python.

For this project, I was thinking of using importhook (singular) or importhooks (plural). However, there is already a project named importhook on Pypi and I thought that using the plural form would likely be just too confusing.

I settled on ideas as I am guessing that the main application would be for people to try out suggestions from or for python-ideas. A few days later, I came up with the above logo and this cemented my opinion that this choice of name might not such a bad idea.

Anyway, enough of this banter. If you want to know more about this project, please consult the documentation.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for ideas, version 0.0.3
Filename, size File type Python version Upload date Hashes
Filename, size ideas-0.0.3-py3-none-any.whl (20.3 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size ideas-0.0.3.tar.gz (15.6 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page