
Research
Security News
The Landscape of Malicious Open Source Packages: 2025 Mid‑Year Threat Report
A look at the top trends in how threat actors are weaponizing open source packages to deliver malware and persist across the software supply chain.
Supply Chain Security
Vulnerability
Quality
Maintenance
License
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
cons
An implementation of cons
in Python.
The cons
package attempts to emulate the semantics of Lisp/Scheme's cons
as closely as possible while incorporating all the built-in Python sequence types:
>>> from cons import cons, car, cdr
>>> cons(1, [])
[1]
>>> cons(1, ())
(1,)
>>> cons(1, [2, 3])
[1, 2, 3]
In general, cons
is designed to work with collections.abc.Sequence
types.
According to the cons
package, None
corresponds to the empty built-in list
, as nil
does in some Lisps:
>>> cons(1, None)
[1]
The cons
package follows Scheme-like semantics for empty sequences:
>>> car([])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ConsError: Not a cons pair
>>> cdr([])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ConsError: Not a cons pair
By default, str
types are not considered cons-pairs, although they are sequences:
>>> cons("a", "string")
ConsPair('a' 'a string')
This setting can be overridden and other types can be similarly excluded from consideration by registering classes with the abc
-based classes MaybeCons
and NonCons
.
list
, tuple
, Iterator
, OrderedDict
.>>> from collections import OrderedDict
>>> cons(('a', 1), OrderedDict())
OrderedDict([('a', 1)])
cons
behavior can be changed and support for new collections can be added through the generic functions cons.core._car
and cons.core._cdr
.unification
.>>> from unification import unify, reify, var
>>> unify([1, 2], cons(var('car'), var('cdr')), {})
{~car: 1, ~cdr: [2]}
>>> reify(cons(1, var('cdr')), {var('cdr'): [2, 3]})
[1, 2, 3]
>>> reify(cons(1, var('cdr')), {var('cdr'): None})
[1]
pip install cons
First obtain the project source:
git clone git@github.com:pythological/python-cons.git
Create a virtual environment and install the development dependencies:
$ pip install -r requirements.txt
Set up pre-commit
hooks:
$ pre-commit install --install-hooks
FAQs
An implementation of Lisp/Scheme-like cons in Python.
We found that cons demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A look at the top trends in how threat actors are weaponizing open source packages to deliver malware and persist across the software supply chain.
Security News
ESLint now supports HTML linting with 48 new rules, expanding its language plugin system to cover more of the modern web development stack.
Security News
CISA is discontinuing official RSS support for KEV and cybersecurity alerts, shifting updates to email and social media, disrupting automation workflows.