# CPython3: Warning: cannot convert object to target type

**URL:** <https://forum.dynamobim.com/t/cpython3-warning-cannot-convert-object-to-target-type/54369>\
**Category:** Developers\
**Tags:** python\
**Created:** [August 23, 2020, 3:29pm UTC](https://forum.dynamobim.com/t/cpython3-warning-cannot-convert-object-to-target-type/54369 "2020-08-23T15:29:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![infeeeee](https://avatars.discourse-cdn.com/v4/letter/i/e480ec/32.png) [@infeeeee](https://forum.dynamobim.com/u/infeeeee)\
**Post date:** [August 23, 2020, 3:29pm UTC](https://forum.dynamobim.com/t/cpython3-warning-cannot-convert-object-to-target-type/54369/1 "2020-08-23T15:29:13Z")

</div>

Hello

I’m trying to use CPython 3 in Dynamo 2.7 sandbox.

If I assign a custom class to the OUT variable I get the following error:

> Warning: CPythonEvaluator.EvaluatePythonScript operation failed.  
> cannot convert object to target type

I could reproduce the warning with this basic script I found on the forum:

> [@Class, how can i use them - practicaly?](https://forum.dynamobim.com/t/class-how-can-i-use-them-practicaly/33878/6):
>
> You need to instantiate the class rather than simply passing the class itself. i.e. OUT should be MyClass() rather than MyClass. Both of the following are valid (although the first is a better approach):

This works with IronPython2:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/a/c/accbadfda9260ae686698aec686309580eb49e99.png)

But I get this warning with CPython3:

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

My question is, is this a bug? Or I should use custom classes differently in Python3 or in CPython?

I’m not that super familiar with python, and I couldn’t find any related information about this error on the internet. Sorry if I should use classes differently in python 3, or this is not implemented yet in dynamo.

Thanks!

P.S: the script in question, so you don’t have to type it:

```python
class MyClass:
	def f(self):
		return 'Hello World'
OUT = MyClass

```

---

<div class="post-metadata">

**Author:** ![Michael\_Kirschner2](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/michael_kirschner2/32/75576_2.png) [@Michael\_Kirschner2](https://forum.dynamobim.com/u/Michael_Kirschner2)\
**Post date:** [August 23, 2020, 9:23pm UTC](https://forum.dynamobim.com/t/cpython3-warning-cannot-convert-object-to-target-type/54369/2 "2020-08-23T21:23:19Z")

</div>

try in 2.8 or 2.9

---

<div class="post-metadata">

**Author:** ![infeeeee](https://avatars.discourse-cdn.com/v4/letter/i/e480ec/32.png) [@infeeeee](https://forum.dynamobim.com/u/infeeeee)\
**Post date:** [August 23, 2020, 10:29pm UTC](https://forum.dynamobim.com/t/cpython3-warning-cannot-convert-object-to-target-type/54369/3 "2020-08-23T22:29:21Z")

</div>

It works, thank you!
