# Browse tags printing folder

**URL:** <https://forum.inductiveautomation.com/t/browse-tags-printing-folder/60498>\
**Category:** Ignition\
**Tags:** ignition78, scripting, vision\
**Created:** [June 8, 2022, 3:39pm UTC](https://forum.inductiveautomation.com/t/browse-tags-printing-folder/60498 "2022-06-08T15:39:45Z")\
**Posts on this page:** 3\
**Page:** 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:** [June 9, 2022, 4:52pm UTC](https://forum.inductiveautomation.com/t/browse-tags-printing-folder/60498/22 "2022-06-09T16:52:58Z")

</div>

Well, the short answer is that I cheated a bit 🙂 It helps a lot to just know about this stuff already; discoverability isn't great.

But, starting from the top with changes I made:

> [@paul-griffith](#):
>
> `from com.inductiveautomation.ignition.common import TypeUtilities`

`TypeUtilities` is a _Java_ class we use everywhere in Ignition. Conveniently, Jython allows you to bring in Java classes just like they're Python code. Java uses reverse-domain-name addressing for packages (because class names must be globally unique) - the `com.inductiveautomation` isn't looking anything up over the internet or anything, it's basically just addressing the local dependency.  
We publish a Javadoc for each new release - a bundled set of documentation explaining our (public) code: [Javadocs & Notable API Changes · inductiveautomation/ignition-sdk-examples Wiki · GitHub](https://github.com/inductiveautomation/ignition-sdk-examples/wiki/Javadocs-&-Notable-Api-Changes)

You can search for `TypeUtilities` in any of those: [TypeUtilities](https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.16/com/inductiveautomation/ignition/common/TypeUtilities.html)  
And find the `getInitValueForClass` method:  
[TypeUtilities](https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.16/com/inductiveautomation/ignition/common/TypeUtilities.html#getInitValueForClass(java.lang.Class))

Note that this takes a single argument of type `Class` - Java's equivalent to Python's `type()`. More on that in a minute.

> [@paul-griffith](#):
>
> `paths.append((tag.path, TypeUtilities.getInitValueForClass(tag.dataType.javaType)))`

This line is adding a _tuple_ (constructed with parentheses) to the existing `paths` _list_.  
Another way to write it would be:  
`paths.append(tuple(tag.path, TypeUtilities.getInitValueForClass(tag.dataType.javaType)))`  
A tuple is an immutable sequence of values. In this case, we're using two elements, but a tuple can have any number of elements (including zero).  
The first element is the tag's path. For the second, we're using the TypeUtilities method we found earlier to store the type-appropriate "initial" value. To get that initial value, we start from the tag object's `dataType`. I had initially thought the same as @lrose, that the `dataType` would be a string, but it turns out to be an instance of [`DataType`](https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.16/com/inductiveautomation/ignition/common/sqltags/model/types/DataType.html) - you can find this out by doing a `print type(tag.dataType)`, which will give you something like this: `<type 'com.inductiveautomation.ignition.common.sqltags.model.types.DataType'>`  
If you look at the `DataType` class (which you can find in the Javadocs linked above for ~most arbitrary classes you find in Ignition), you'll see it has a `getJavaType()` method. Java doesn't have properties, and instead generally uses "getter" and "setter" methods to retrieve or change a given object's properties. Jython conveniently unwraps these `getX/setX` methods into properties - so `tag.dataType.javaType` is _actually_ calling `tag.dataType.getJavaType()` for you. This retrieves a `Class` instance for us, which we then pass to the TypeUtilities method.

So at this point your `paths` list is going to be a data structure that looks like this:

```auto
[
	("intPath", 0),
	("stringPath", "")
]

```

But `system.tag.writeAll` requires _two_ lists - paths, and values. So we're going to use the builtin function [`zip`](https://docs.python.org/2.7/library/functions.html#zip) to (confusingly) _unzip_ the list we have, by spreading `paths` into it with the `*` operator. If it helps - this is _not_ something I remember how to do offhand. Instead I googled for 'python list of tuples into two lists' and found this StackOverflow thread: [python - How to convert list of tuples to multiple lists? - Stack Overflow](https://stackoverflow.com/questions/8081545/how-to-convert-list-of-tuples-to-multiple-lists)

So `list(zip(*paths))` unzips our list, which means our data will look like this:

```auto
[
	("intPath", "stringPath"),
	(0, "")
]

```

We can then use _another_ Python function called unpacking to turn that new list into two new variables, which is what the `paths, values =` part is doing:

> **[Unpacking in Python: Beyond Parallel Assignment](https://stackabuse.com/unpacking-in-python-beyond-parallel-assignment/)**
>
> Unpacking uses \* to assign multiple variables from a single iterable in one assignment statement. This makes your Python code cleaner and quicker to write.

---

<div class="post-metadata">

**Author:** ![gregory.sachs](https://avatars.discourse-cdn.com/v4/letter/g/e47774/32.png) [@gregory.sachs](https://forum.inductiveautomation.com/u/gregory.sachs)\
**Post date:** [October 14, 2024, 1:26pm UTC](https://forum.inductiveautomation.com/t/browse-tags-printing-folder/60498/23 "2024-10-14T13:26:37Z")

</div>

Just a note, at risk of resurrecting a dead topic, but in hopes of saving someone else some time-I could not get system.tag.browseTags to work inside of a UDT. At least on 8.1.29, it does not seem to get the correct tag scope for the browse. I believe you would need to construct the entire tag path to use this inside a UDT. Quite happy to be wrong!

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [October 14, 2024, 3:11pm UTC](https://forum.inductiveautomation.com/t/browse-tags-printing-folder/60498/24 "2024-10-14T15:11:20Z")

</div>

> [@gregory.sachs](#):
>
> system.tag.browseTags

`system.tag.browseTags()` is not an available system function in 8.1

It was available in 7.9, it has modified, and the named shortened to `system.tag.browse()` in 8.1

For what it's worth this post is tagged Ignition 7.8

[Previous page](https://forum.inductiveautomation.com/t/browse-tags-printing-folder/60498.md?page=1)
