A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2001-April/065451.html below:

call of non-function (type string) error

call of non-function (type string) error call of non-function (type string) errorPaul Prescod paulp at ActiveState.com
Wed Apr 11 13:49:41 EDT 2001
Graham Guttocks wrote:
> 
> ...
> >>> CIPHER = "DES3"
> >>> import Crypto.Cipher
> >>> cipher = getattr(Crypto.Cipher, CIPHER)
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> AttributeError: DES3

As Andrew pointed out this is an annoying corner case where you probably
do have to use exec. I'm not really thrilled with all of these corner
cases in Python's package handling. 

On the other hand, once you have the module object you can use getattr
to get the "new" function out of the module. 

-- 
Take a recipe. Leave a recipe.  
Python Cookbook!  http://www.ActiveState.com/pythoncookbook


More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4