class_docstr: Wrap GValue in a Python class.
  
  This class wraps :class:`.GValue` in a convenient interface. You can use
  instances of this class to get and set :class:`.GObject` properties.
  
  On construction, :class:`.GValue` is all zero (empty). You can pass it to
  a get function to have it filled by :class:`.GObject`, or use init to
  set a type, set to set a value, then use it to set an object property.
  
  GValue lifetime is managed automatically.
class_docstr_tok: ["Wrap","GValue","in","a","Python","class",".","This","class","wraps",":","class",":","`",".GValue","`","in","a","convenient","interface",".","You","can","use","instances","of","this","class","to","get","and","set",":","class",":","`",".GObject","`","properties",".","On","construction",",",":","class",":","`",".GValue","`","is","all","zero","(","empty",")",".","You","can","pass","it","to","a","get","function","to","have","it","filled","by",":","class",":","`",".GObject","`",",","or","use","init","to","set","a","type",",","set","to","set","a","value",",","then","use","it","to","set","an","object","property",".","GValue","lifetime","is","managed","automatically","."]
docstr: Turn a string into a flag value ready to be passed into libvips.
  
          
docstr_tok: ["Turn","a","string","into","a","flag","value","ready","to","be","passed","into","libvips","."]
code: def to_flag(gtype, value):
      """Turn a string into a flag value ready to be passed into libvips."""
  
      if isinstance(
          value, basestring if _is_PY2 else str
      ):  # noqa: F821
          flag_value = vips_lib.vips_flags_from_nick(
              b"pyvips", gtype, _to_bytes(value)
          )
          if flag_value < 0:
              raise Error(
                  "no value {0} in gtype {1} ({2})".format(
                      value, type_name(gtype), gtype
                  )
              )
      else:
          flag_value = value
  
      return flag_value
  
file_path: pyvips/pyvips/gvalue.py
imports: from __future__ import division
  from __future__ import unicode_literals
  import logging
  import numbers
  import sys
  import pyvips
  from pyvips import ffi, vips_lib, gobject_lib, glib_lib, Error, _to_bytes, _to_string, type_name, type_from_name, at_least_libvips
label_desc: Use image node_id 4 for calling the GValue obj's underlying member method code with example usage: obj.to_flag(gtype, value) and returns: flag_value