Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 how to test if a value is or is like a dictionary
i have a function that needs to test if a value given to it in an argument is a dictionary or not. doing isinstance(thevalue,dict) is not good enough when the value comes from os.environ. but i would want the test to be positive for os.environ and anything like it as well as any genuine dictionary. what kind of test would work?
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.

>>> import os >>> import >>> isinstance(os.environ, True >>> isinstance({}, True
buran and Skaperen like this post
Craig "Ichabod" O'Brien -
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures


Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  split and test tweet data Jmekubo 1 76 May-08-2019, 10:48 AM
Last Post: michalmonday
  Convert List of Dictionary to dictionary of dictionary list in python kk230689 2 152 Apr-27-2019, 03:13 AM
Last Post: perfringo
  Test Case Assertion Error moga2003 10 383 Mar-18-2019, 01:06 AM
Last Post: moga2003
  test pattern and add result in a table sam1975 1 123 Mar-05-2019, 02:41 PM
Last Post: sam1975
  new python package test ramkrishna 0 101 Feb-25-2019, 12:18 PM
Last Post: ramkrishna
  How to make loop go back to the beginning if test evaluaes to True. FWendeburg 1 160 Feb-13-2019, 01:26 AM
Last Post: stullis
  unit test roll die saladgg 5 662 Nov-06-2018, 11:39 PM
Last Post: stullis
  Having issues getting a multiple choice test program to work Py_JohnS 2 450 Sep-01-2018, 11:06 PM
Last Post: Py_JohnS
  Mix-in class tree file not running the self test code. arjunsingh2908 3 495 Aug-14-2018, 05:46 PM
Last Post: arjunsingh2908
  pytest fixture in thrown error while in the test file runs OzzieOzzum 1 443 Jul-31-2018, 12:12 PM
Last Post: OzzieOzzum

Forum Jump:

Users browsing this thread: 1 Guest(s)