On Wed, Mar 4, 2015 at 6:50 AM, Abhishek Talwar/HYD/TCS <
abhishek.tal...@tcs.com> wrote:

> While working on a bug for keystoneclient I have replaced sys.exit with
> return. However, the code reviewers want that the output should be on
> stderr(as sys.exit does). So how can we get the output on stderr.

The print function allows you to specify a file:

    >>> from __future__ import print_function
    >>> import sys
    >>> print('something to', file=sys.stderr)

The __future__ import is needed for Python 2.6/2.7 because print was
changed to a function in Python 3.

blog: http://www.traceback.org
twitter: http://twitter.com/dstanek
www: http://dstanek.com
OpenStack Development Mailing List (not for usage questions)
Unsubscribe: openstack-dev-requ...@lists.openstack.org?subject:unsubscribe

Reply via email to