[ python-Feature Requests-1297986 ] hashable and mutable functions

SourceForge.net noreply at sourceforge.net
Thu Sep 22 08:27:48 CEST 2005


Feature Requests item #1297986, was opened at 2005-09-21 19:55
Message generated for change (Settings changed) made by birkenfeld
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1297986&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
>Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: ChristianJ (cybb20)
Assigned to: Nobody/Anonymous (nobody)
Summary: hashable and mutable functions

Initial Comment:
It is not easy to check if an object is hashable, ie
hasattr(list(), '__hash__') -> True 


try: hash(list())
except TypeError: pass

seems to be a possible way to see if an object is
hashable, however it is not satisfiable that this
information needs to be retrieved by using exception
handling.

My proposal:
There should be a hashable(obj) function returning a
bool object and additionally it would be nice to have
something like ismutable(obj) function, possibly as
built-in functions.

Reason:
callable() is a built-in function and returns
information about an object whether it's callable or
not, that is a basic info about this object. 
If an object is hashable or mutable is a state of an
object that is also very important to know.


----------------------------------------------------------------------

Comment By: Reinhold Birkenfeld (birkenfeld)
Date: 2005-09-22 08:27

Message:
Logged In: YES 
user_id=1188172

> try: hash(list())
> except TypeError: pass
> 
> seems to be a possible way to see if an object is
> hashable, however it is not satisfiable that this
> information needs to be retrieved by using exception
> handling.

Why?

> My proposal:
> There should be a hashable(obj) function returning a
> bool object and additionally it would be nice to have
> something like ismutable(obj) function, possibly as
> built-in functions.

How should "ismutable" be implemented?

> Reason:
> callable() is a built-in function and returns
> information about an object whether it's callable or
> not, that is a basic info about this object.
> If an object is hashable or mutable is a state of an
> object that is also very important to know.

It's easier to ask for forgiveness than permission.

Even callable() has been called a mistake. Just call
it and see where you come.

So, -1.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1297986&group_id=5470


More information about the Python-bugs-list mailing list