I have some old programs from back in the times when python 3.1 came out.
In the program I often used the Callable()
to pass a function and it's parameters like this to my TKinter application:
tvf.mi(datei_bu, text=datei_opt, command=Callable(exec_datei_opts, datei_opt))
Now I wanted to use my programs again but the callable
- Object was gone. In the web I found that this functionality was removed in python 3.2, and none of the alternatives worked for me.
Finally I decided to reinstall python 3.1. However, I have no idea if it is possible to have multiple python 3 versions installed at the same time or how to 'create' a shell command for this version when I want to use this special version.
My questions are:
Callable
- Object that was removed?It does not seem that Python ever had Callable
built in. You may have confused it with callable
predicate which indeed was removed and then brought back:
New in version 3.2: This function was first removed in Python 3.0 and then brought back in Python 3.2.
All references of Callable
on the web that I could find point to swampy package (a by-product of Think Python book), which has swampy.Gui.Callable
:
class Callable(object):
"""Wrap a function and its arguments in a callable object.
Callables can can be passed as a callback parameter and invoked later.
This code is adapted from the Python Cookbook 9.1, page 302,
with one change: if call is invoked with args and kwds, they
are added to the args and kwds stored in the Callable.
"""
def __init__(self, func, *args, **kwds):
self.func = func
self.args = args
self.kwds = kwds
def __call__(self, *args, **kwds):
d = dict(self.kwds)
d.update(kwds)
return self.func(*self.args+args, **d)
def __str__(self):
return self.func.__name__
You can also look at answers to this question, where OP wanted to reimplement Callable
for the same purpose.
If you still want to try to install the old version of Python 3, you can give the following a try. I assume that Raspbian is Debian-based distro and the same commands apply. Here's the Dockerfile
that verifies that you can do it on Debian Jessie-compatibe system. You can try the RUN
commands from it in your shell:
FROM debian:jessie
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install --no-install-recommends --yes software-properties-common && \
add-apt-repository ppa:deadsnakes/ppa && \
# The PPA is designed for Ubuntu, but the trick makes it work
# because Debian Jessie is compatible with Ubuntu Trusty #
# on package-level
sed -i 's/jessie/trusty/g' \
/etc/apt/sources.list.d/deadsnakes-ppa-jessie.list && \
apt-get update && \
apt-get install --no-install-recommends --yes python3.1
CMD python3.1