# Way to print for both perspective and vision projects?

**URL:** <https://forum.inductiveautomation.com/t/way-to-print-for-both-perspective-and-vision-projects/34793>\
**Category:** Ignition\
**Tags:** ignition80\
**Created:** [May 15, 2020, 5:33pm UTC](https://forum.inductiveautomation.com/t/way-to-print-for-both-perspective-and-vision-projects/34793 "2020-05-15T17:33:29Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [May 15, 2020, 6:00pm UTC](https://forum.inductiveautomation.com/t/way-to-print-for-both-perspective-and-vision-projects/34793/2 "2020-05-15T18:00:14Z")

</div>

```python
from __future__ import print_function
import __builtin__
from java.lang import IllegalArgumentException 

def print(*objects, **kwargs):
	sep = kwargs.pop("sep", ", ")
	end = kwargs.pop("end", "\n")
	message = sep.join(str(object) for object in objects)
	try:
		system.perspective.print(message)
	except IllegalArgumentException:
		system.util.getLogger("utils.print").info(message)
	except AttributeError:
		__builtin__.print(message, end=end) 

```

Dropped in a `utils` script module. I would definitely recommend _not_ naming a function `print` (notice the `from __future__ ` import that was required), but it’s technically possible.

It’ll try to use system.perspective.print; if that fails due to the `IllegalArgumentException` (meaning you’re on the gateway, but not inside Perspective) then it’ll bail out to a logging statement. But, if `system.perspective` is an `AttributeError`, meaning you’re not on the gateway at all, it just uses the builtin `print` function.

Note that performance on the non-happy path is going to be dramatically worse than the native `print` statement; throwing and catching exceptions is expensive. There’s probably a better way to only run the same logic once; @pturmel may have some ideas, but this works to at least prove the concept.

---

_[View the full topic](https://forum.inductiveautomation.com/t/way-to-print-for-both-perspective-and-vision-projects/34793)._
