# Print in Python? NOT OUT!

**URL:** <https://forum.dynamobim.com/t/print-in-python-not-out/85326>\
**Category:** Developers\
**Created:** [January 25, 2023, 10:53am UTC](https://forum.dynamobim.com/t/print-in-python-not-out/85326 "2023-01-25T10:53:18Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alien](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alien/32/40701_2.png) [@Alien](https://forum.dynamobim.com/u/Alien)\
**Post date:** [January 25, 2023, 10:53am UTC](https://forum.dynamobim.com/t/print-in-python-not-out/85326/1 "2023-01-25T10:53:18Z")

</div>

Opening old graphs in R23 you get information to tell you that Python has been upgraded.

Reading through the info I notice it mentions print statements.

When would you use a print statement in Dynamo Python?

**I am talking about `print`, not OUT.**

Print doesn’t work in Dynamo like it does in pure Python.  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/1/41fb4313b3e14d2ef569616a00e04c7e7b6d3b0f.png)

---

<div class="post-metadata">

**Author:** ![Draxl\_Andreas](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/draxl_andreas/32/145744_2.png) [@Draxl\_Andreas](https://forum.dynamobim.com/u/Draxl_Andreas)\
**Post date:** [January 25, 2023, 11:04am UTC](https://forum.dynamobim.com/t/print-in-python-not-out/85326/2 "2023-01-25T11:04:30Z")

</div>

@Alien ,

at least there is no error 😉

 ![grafik](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/5/8555f2ff1dae9f67c21d865282747311605df9ab.png)

---

<div class="post-metadata">

**Author:** ![Alien](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alien/32/40701_2.png) [@Alien](https://forum.dynamobim.com/u/Alien)\
**Post date:** [January 25, 2023, 11:05am UTC](https://forum.dynamobim.com/t/print-in-python-not-out/85326/3 "2023-01-25T11:05:33Z")

</div>

Hahah!!  
But what is is for?!

---

<div class="post-metadata">

**Author:** ![Draxl\_Andreas](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/draxl_andreas/32/145744_2.png) [@Draxl\_Andreas](https://forum.dynamobim.com/u/Draxl_Andreas)\
**Post date:** [January 25, 2023, 11:06am UTC](https://forum.dynamobim.com/t/print-in-python-not-out/85326/4 "2023-01-25T11:06:35Z")

</div>

@Alien ,

i do not use print at all.

---

<div class="post-metadata">

**Author:** ![Alien](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alien/32/40701_2.png) [@Alien](https://forum.dynamobim.com/u/Alien)\
**Post date:** [January 25, 2023, 11:07am UTC](https://forum.dynamobim.com/t/print-in-python-not-out/85326/5 "2023-01-25T11:07:03Z")

</div>

Me neither. Hence my question 😆

---

<div class="post-metadata">

**Author:** ![leonard.moelders](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/leonard.moelders/32/108216_2.png) [@leonard.moelders](https://forum.dynamobim.com/u/leonard.moelders)\
**Post date:** [January 25, 2023, 11:07am UTC](https://forum.dynamobim.com/t/print-in-python-not-out/85326/6 "2023-01-25T11:07:39Z")

</div>

In Dynamo for Revit you use TaskDialog to prompt something for the user:

```auto
import clr
import sys
sys.path.append('C:\Program Files (x86)\IronPython 2.7\Lib')
clr.AddReference("RevitAPIUI")
import Autodesk 
from Autodesk.Revit.UI import (TaskDialog, TaskDialogCommonButtons,
								TaskDialogCommandLinkId, TaskDialogResult)

title = 'Task Dialog Title'
dialog = TaskDialog(title)

# Properties
dialog.MainInstruction = 'Text Header'
dialog.MainContent = 'Text Content'
dialog.FooterText = 'Footer Text'
dialog.VerificationText = 'Verification Text'
# dialog.ExpandedContent = expanded_content

# Settings
dialog.TitleAutoPrefix = False
dialog.AllowCancellation = True

# Add Button
dialog.CommonButtons = TaskDialogCommonButtons.Ok | TaskDialogCommonButtons.Yes

# Set Default Button
dialog.DefaultButton = TaskDialogResult.None

# Add Command Link
dialog.AddCommandLink(TaskDialogCommandLinkId.CommandLink1,
					  'Command Button Text',
					  'Command Button Sub Text')
dialog.AddCommandLink(TaskDialogCommandLinkId.CommandLink2,
					  'Command Button Text 2',
					  'Command Button Sub Text 2')

result = dialog.Show()

if result == TaskDialogResult.Ok:
	print('Dialog was OK')
if result == TaskDialogResult.Yes:
	print('Dialog was Yes')
if result == TaskDialogResult.Cancel:
	print('Dialog was Cancelled')
if result == TaskDialogResult.CommandLink1:
	print('Button Was Pressed')
if result == TaskDialogResult.CommandLink2:
	print('Button 2 Was Pressed')
if dialog.WasVerificationChecked():
	print('Verification was Checked')

```

---

<div class="post-metadata">

**Author:** ![Alien](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alien/32/40701_2.png) [@Alien](https://forum.dynamobim.com/u/Alien)\
**Post date:** [January 25, 2023, 11:09am UTC](https://forum.dynamobim.com/t/print-in-python-not-out/85326/7 "2023-01-25T11:09:51Z")

</div>

ooo, didn’t know you could do that. Thanks 🙂

---

<div class="post-metadata">

**Author:** ![solamour](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/solamour/32/153516_2.png) [@solamour](https://forum.dynamobim.com/u/solamour)\
**Post date:** [January 25, 2023, 8:21pm UTC](https://forum.dynamobim.com/t/print-in-python-not-out/85326/8 "2023-01-25T20:21:55Z")

</div>

The `print()` statement goes to the console in Dynamo - useful when you need to check things in loops 🙂

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/e/5e911f9bdeab8aeff9d8b901894dd8ab8ab79771.png)

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [January 25, 2023, 11:34pm UTC](https://forum.dynamobim.com/t/print-in-python-not-out/85326/9 "2023-01-25T23:34:00Z")

</div>

> [@solamour](#):
>
> useful when you need to check things in loops 🙂

Other uses I have found with it:

- When you need to debug something but don’t want to break a larger workflow by changing the out value.
- When you want a way to ensure there is a log of the failure but do t want to build a logging system, as the entirety of the console is saved for each session. (Think try/ except where the except instead of returning the value to Dynamo prints it to the console/log)
- When you want to use the same code in a non-Dynamo Python engine.

---

<div class="post-metadata">

**Author:** ![Alien](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alien/32/40701_2.png) [@Alien](https://forum.dynamobim.com/u/Alien)\
**Post date:** [January 26, 2023, 11:55am UTC](https://forum.dynamobim.com/t/print-in-python-not-out/85326/10 "2023-01-26T11:55:53Z")

</div>

> [@solamour](#):
>
> to the console in Dynamo - useful when you

I’m in R21 mainly… and that doesn’t seem to work for me.  
Is it just for R23?

---

<div class="post-metadata">

**Author:** ![Alien](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alien/32/40701_2.png) [@Alien](https://forum.dynamobim.com/u/Alien)\
**Post date:** [January 26, 2023, 11:57am UTC](https://forum.dynamobim.com/t/print-in-python-not-out/85326/11 "2023-01-26T11:57:49Z")

</div>

To think of all the time I’ve spent removing the word print from real python stuff when putting it in Dyno!

And shoving in a load of, TEST lists to check my outputs.

---

<div class="post-metadata">

**Author:** ![leonard.moelders](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/leonard.moelders/32/108216_2.png) [@leonard.moelders](https://forum.dynamobim.com/u/leonard.moelders)\
**Post date:** [January 26, 2023, 12:18pm UTC](https://forum.dynamobim.com/t/print-in-python-not-out/85326/12 "2023-01-26T12:18:38Z")

</div>

In Dynamo for Revit go to `View` and check `Show Console` the Shortcut is Ctrl+Shift+Up

---

<div class="post-metadata">

**Author:** ![Alien](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alien/32/40701_2.png) [@Alien](https://forum.dynamobim.com/u/Alien)\
**Post date:** [January 26, 2023, 12:20pm UTC](https://forum.dynamobim.com/t/print-in-python-not-out/85326/13 "2023-01-26T12:20:26Z")

</div>

I’m not having issues accessing the console…  
My console does not display those items.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/8/48a3bf2ff0f3f4a6286f7ea8e583afd130c6a314.png)

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [January 26, 2023, 3:32pm UTC](https://forum.dynamobim.com/t/print-in-python-not-out/85326/14 "2023-01-26T15:32:56Z")

</div>

I believe you need to be in a newer version.

---

<div class="post-metadata">

**Author:** ![solamour](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/solamour/32/153516_2.png) [@solamour](https://forum.dynamobim.com/u/solamour)\
**Post date:** [January 26, 2023, 4:19pm UTC](https://forum.dynamobim.com/t/print-in-python-not-out/85326/15 "2023-01-26T16:19:02Z")

</div>

We introduced this feature in `Dynamo 2.8` - as per the [_Release Notes_](https://github.com/DynamoDS/Dynamo/wiki/Release-Notes) on the Github Wiki 🙂

---

<div class="post-metadata">

**Author:** ![Alien](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alien/32/40701_2.png) [@Alien](https://forum.dynamobim.com/u/Alien)\
**Post date:** [January 26, 2023, 4:22pm UTC](https://forum.dynamobim.com/t/print-in-python-not-out/85326/16 "2023-01-26T16:22:12Z")

</div>

Wait, you expect people to read stuff? 😑

Srsly though, good to know! I’ll keep a look out when I use new Dyno 🙂  
Am still struggling with the new look and the search box moving tho ☹

---

<div class="post-metadata">

**Author:** ![solamour](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/solamour/32/153516_2.png) [@solamour](https://forum.dynamobim.com/u/solamour)\
**Post date:** [January 26, 2023, 4:30pm UTC](https://forum.dynamobim.com/t/print-in-python-not-out/85326/17 "2023-01-26T16:30:56Z")

</div>

> [@Alien](#):
>
> Wait, you expect people to read stuff? 😑

🤓 🧐 😬 🙄 🫤 😅

I’m curious about your thoughts on the Search Box moving: Do you mean the Right-click search or Library? Or other? Theoretically the former two should be in the same place, just graphically different.

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [January 26, 2023, 4:31pm UTC](https://forum.dynamobim.com/t/print-in-python-not-out/85326/18 "2023-01-26T16:31:09Z")

</div>

> [@Alien](#):
>
> Wait, you expect people to read stuff?

You sound like the majority of my coworkers. 😆

---

<div class="post-metadata">

**Author:** ![Alien](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alien/32/40701_2.png) [@Alien](https://forum.dynamobim.com/u/Alien)\
**Post date:** [January 26, 2023, 4:33pm UTC](https://forum.dynamobim.com/t/print-in-python-not-out/85326/19 "2023-01-26T16:33:54Z")

</div>

> [@Search box in Dyno for R23](https://forum.dynamobim.com/t/search-box-in-dyno-for-r23/85327):
>
> In previous versions of Dynamo the search box is always visible: [image] In R23 it’s not. [image] Can I get it to remain visible?

^^ This one.

---

<div class="post-metadata">

**Author:** ![c.poupin](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/c.poupin/32/89152_2.png) [@c.poupin](https://forum.dynamobim.com/u/c.poupin)\
**Post date:** [January 26, 2023, 8:43pm UTC](https://forum.dynamobim.com/t/print-in-python-not-out/85326/20 "2023-01-26T20:43:19Z")

</div>

FYI, if you really need this, we can redirect the `stdout` to the OUT variable with an in-memory file-like object

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/1/1/11f297024c966113d81deb1bd20824fa23606a20.png)

```auto
import sys
if sys.version_info.major >= 3 :
    from io import StringIO    
else:
    from cStringIO import StringIO
sys.stdout = StringIO()

alphabet = [chr(i) for i in range(ord('a'),ord('z')+1)]
def funtest():
    global dict_
    for numb, alpha in zip(range(1,60,1), alphabet):
        dict_[numb] = alpha
dict_ = {}
print("Start Test")
funtest()
print(dict_)
print("End Test")
sys.stdout.seek(0)
OUT = sys.stdout.read()

```
