Changing a closed-over value Icon

Changing a closed-over value

Changing a closed-over value (in a "cell") script allows you to change

Changing a closed-over valueOverview

Editor: In most languages with closures, it is possible to change a closed-over value and have the change visible in other closures which share a reference to the same variable. Python's syntax makes this impossible.

Even if you're content (I am) with the work-around-- putting your changeable values inside a mutable object like a list-- it may occasionally happen that you wish you could change the closed-over values, found in "cell" objects in a function's func_closure tuple. Another recipe I submitted shows how to get at the values in standard Python; this one will demonstrate a way to actually change that value, so that functions which also close over that value (share a reference to the same cell) will see the change.

NEW

Fixed some bugs.

Changing a closed-over valueInformation

Version
1.0
Date
04.15.10
License
Language
English
File Size
N/A
Developer
Category
SubCategory
Operating Systems
Windows ,Linux,Mac OS,BSD,Solaris
System Requirements
No additional system requirements.
Iterator to return items N-at-a-time Icon
Returns N-tuples built from the incoming items from another iterator
Get the IP address of a network interface Icon
SIOCGIFADDR ioctl to find the IP address associated with a network interface
More
Principal Component Analysis (PCA) Icon
A class that carries out Principal Component Analysis (PCA).
Free
getch() Icon
A small utility class to read single characters from standard input
Album Track List Generator Icon
Album Track List Generator allows you to extract artist, album title and track t
Free
Dendrogram drawing Icon
This recipe draws a dendrogram (horizontal format used for evolutionary trees)
Disk Dumper Icon
This recipe will display a hex dump of the disk specified on the command line.
Complex Boolean Regular Expression Class Icon
Need to look for the occurence of words in a string or group of words
Free
Display an Image from a specified file Icon
Reads an image file from the filename specified as the 1st parameter
Free
Quickslice decorator Icon
Quickslice decorator script defines a decorator that allows for an abbreviated
Free
More