Jump to content

ThijsOnline

Convert integer to string

Recommended Posts

Hi guys,

 

My question is fairly easy i guess. I try to convert an integer to a string with the str() method. However the console gives me this feedback "Node Python. Output1 expected float, not str". Are there seperate string globals? 

 

Many thanks

Share this post


Link to post
Share on other sites

I understand programming in general, but not Python specific. However, it sounds like you're converting an integer variable to a string and trying to assign it to Output1. But Output1 doesn't accept strings, it only accepts floats. So you might need to convert the integer to a float rather than a string. In some languages, you don't need to convert it all because and integer is basically a float with all zeros after the number. i.e. int 1 = float 1.0. So maybe you don't have to convert it at all.

Share this post


Link to post
Share on other sites

Default ports, when you make a new Python node, are float (real). You should remove the output port (double click) and make a new one, type string.

 

This caught me out when I first used Python. I'd got into bad habits due to using XPresso, where anything can be connected to anything. Python is fairly strict in this matter.

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

YOUTUBE CHANNEL:

ABOUT US:

C4D Cafe is the largest CINEMA 4D community. We provide facilities for discussion, showcasing and learning our favorite software :)
×
×
  • Create New...