Profile Picture

How to use standard Python libs

Posted By RobertoColombo Last Year
You don't have permission to rate!
Author
Message
RobertoColombo
RobertoColombo
Posted Last Year
View Quick Profile
Distinguished Member

Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)

Group: Forum Members
Last Active: Last Month
Posts: 1.6K, Visits: 3.0K
Hi,

the following code generates an error at the line where isdigit() is used.
isdigit() is part of standard Python libs, so I wonder how to get it working.

import RLPy

def run_script():
    val = 100
    
    if val.isdigit():
        print("it is a digit")
    else:
        print("it is not a digit")

Thanks

  Roberto



My PC:
OS: Windows 10 Pro English 64-bit / CPU: Intel i7-9700 3.6GHz / MB: ASUS ROG Strix Z390  RAM: 32GB DDR4 2.6GHz / HD: 2TB+3TB  /  
SSD: 2x512GB Samsung 860 EVO / 
VB: Palit GTX2080 TI GamingPro 11GB / AB: embedded in the MB and VB (audio from the VB with an HDMI splitter) / DirectX: 12

Kelleytoons
Kelleytoons
Posted Last Year
View Quick Profile
Distinguished Member

Distinguished Member (17.0K reputation)Distinguished Member (17.0K reputation)Distinguished Member (17.0K reputation)Distinguished Member (17.0K reputation)Distinguished Member (17.0K reputation)Distinguished Member (17.0K reputation)Distinguished Member (17.0K reputation)Distinguished Member (17.0K reputation)Distinguished Member (17.0K reputation)

Group: Forum Members
Last Active: 3 hours ago
Posts: 5.6K, Visits: 11.0K
Actually, isdigit() refers to a string.

This works in iClone Python:
str = "1234"
print(str.isdigit())

returns true.



Alienware Aurora R7, Win 10, i7-8700k, 4.7GHz CPU, 32GB RAM, GTX Titan XP (12GB), Samsung 960 Pro 2TB M-2 SSD, TB+ Disk space
Mike "ex-genius" Kelley
RobertoColombo
RobertoColombo
Posted Last Year
View Quick Profile
Distinguished Member

Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)

Group: Forum Members
Last Active: Last Month
Posts: 1.6K, Visits: 3.0K
Hi Mike,

oh... that's right.
So, I need to check how to use for a function input parameter (that's the diea: to check whether it is a number)...

  Roberto

My PC:
OS: Windows 10 Pro English 64-bit / CPU: Intel i7-9700 3.6GHz / MB: ASUS ROG Strix Z390  RAM: 32GB DDR4 2.6GHz / HD: 2TB+3TB  /  
SSD: 2x512GB Samsung 860 EVO / 
VB: Palit GTX2080 TI GamingPro 11GB / AB: embedded in the MB and VB (audio from the VB with an HDMI splitter) / DirectX: 12

Kelleytoons
Kelleytoons
Posted Last Year
View Quick Profile
Distinguished Member

Distinguished Member (17.0K reputation)Distinguished Member (17.0K reputation)Distinguished Member (17.0K reputation)Distinguished Member (17.0K reputation)Distinguished Member (17.0K reputation)Distinguished Member (17.0K reputation)Distinguished Member (17.0K reputation)Distinguished Member (17.0K reputation)Distinguished Member (17.0K reputation)

Group: Forum Members
Last Active: 3 hours ago
Posts: 5.6K, Visits: 11.0K
Well, it has to be *something* to begin with -- either it's a number, or it's a string that may or may not contain numbers.

If it's a string and you're not sure if it's all digits, you can use that function (so "A103" would return false).  

And if you're not sure what type it is, use the function type().



Alienware Aurora R7, Win 10, i7-8700k, 4.7GHz CPU, 32GB RAM, GTX Titan XP (12GB), Samsung 960 Pro 2TB M-2 SSD, TB+ Disk space
Mike "ex-genius" Kelley
Edited
Last Year by Kelleytoons
RobertoColombo
RobertoColombo
Posted Last Year
View Quick Profile
Distinguished Member

Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)

Group: Forum Members
Last Active: Last Month
Posts: 1.6K, Visits: 3.0K
Ok, my point is to check function parameters for type consistency.
I am an old C programmer and I learnt to use strict conventions... that's why Python for me is just too loose...

My PC:
OS: Windows 10 Pro English 64-bit / CPU: Intel i7-9700 3.6GHz / MB: ASUS ROG Strix Z390  RAM: 32GB DDR4 2.6GHz / HD: 2TB+3TB  /  
SSD: 2x512GB Samsung 860 EVO / 
VB: Palit GTX2080 TI GamingPro 11GB / AB: embedded in the MB and VB (audio from the VB with an HDMI splitter) / DirectX: 12

Kelleytoons
Kelleytoons
Posted Last Year
View Quick Profile
Distinguished Member

Distinguished Member (17.0K reputation)Distinguished Member (17.0K reputation)Distinguished Member (17.0K reputation)Distinguished Member (17.0K reputation)Distinguished Member (17.0K reputation)Distinguished Member (17.0K reputation)Distinguished Member (17.0K reputation)Distinguished Member (17.0K reputation)Distinguished Member (17.0K reputation)

Group: Forum Members
Last Active: 3 hours ago
Posts: 5.6K, Visits: 11.0K
Yeah, Python won't do that.  

Here's some explanation of this process: https://stackoverflow.com/questions/402504/how-to-determine-a-python-variables-type



Alienware Aurora R7, Win 10, i7-8700k, 4.7GHz CPU, 32GB RAM, GTX Titan XP (12GB), Samsung 960 Pro 2TB M-2 SSD, TB+ Disk space
Mike "ex-genius" Kelley
justaviking
justaviking
Posted Last Year
View Quick Profile
Distinguished Member

Distinguished Member (14.2K reputation)Distinguished Member (14.2K reputation)Distinguished Member (14.2K reputation)Distinguished Member (14.2K reputation)Distinguished Member (14.2K reputation)Distinguished Member (14.2K reputation)Distinguished Member (14.2K reputation)Distinguished Member (14.2K reputation)Distinguished Member (14.2K reputation)

Group: Forum Members
Last Active: 3 hours ago
Posts: 7.4K, Visits: 22.5K
@Roberto and Mike,

It's fun and fascination watching the two of you work together.  I'm sorry you need to do all this reverse engineering and forensic discovery to figure out how it should work, and never knowing for sure if it's a bug, a documentation error, or user error.

On behalf of all the people who will benefit from your pioneering efforts, "Thank you!"




iClone 7... Character Creator... Substance Designer/Painter... Blender... Audacity...
Desktop (homebuilt) - Windows 7, i7-3770k CPU, GTX 1080 GPU (8GB), 16GB RAM, Asus P8Z77-V Pro motherboard, 500 GB SSD, terabytes of disk space, dual  monitors.
Laptop - Windows 10, MSI GS63VR STEALTH-252, 16GB RAM, GTX 1060 (6GB), 256GB SSD and 1TB HDD

RobertoColombo
RobertoColombo
Posted Last Year
View Quick Profile
Distinguished Member

Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)

Group: Forum Members
Last Active: Last Month
Posts: 1.6K, Visits: 3.0K
Yeah...

Mike has promised to invite me in Florida if I can help him... right Mike ? Wink

My PC:
OS: Windows 10 Pro English 64-bit / CPU: Intel i7-9700 3.6GHz / MB: ASUS ROG Strix Z390  RAM: 32GB DDR4 2.6GHz / HD: 2TB+3TB  /  
SSD: 2x512GB Samsung 860 EVO / 
VB: Palit GTX2080 TI GamingPro 11GB / AB: embedded in the MB and VB (audio from the VB with an HDMI splitter) / DirectX: 12

Edited
Last Year by RobertoColombo
Kelleytoons
Kelleytoons
Posted Last Year
View Quick Profile
Distinguished Member

Distinguished Member (17.0K reputation)Distinguished Member (17.0K reputation)Distinguished Member (17.0K reputation)Distinguished Member (17.0K reputation)Distinguished Member (17.0K reputation)Distinguished Member (17.0K reputation)Distinguished Member (17.0K reputation)Distinguished Member (17.0K reputation)Distinguished Member (17.0K reputation)

Group: Forum Members
Last Active: 3 hours ago
Posts: 5.6K, Visits: 11.0K
You and Dennis are always welcome here (we don't have a ton of guest room, but I'm sure we can work something out).



Alienware Aurora R7, Win 10, i7-8700k, 4.7GHz CPU, 32GB RAM, GTX Titan XP (12GB), Samsung 960 Pro 2TB M-2 SSD, TB+ Disk space
Mike "ex-genius" Kelley
RobertoColombo
RobertoColombo
Posted Last Year
View Quick Profile
Distinguished Member

Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)Distinguished Member (6.4K reputation)

Group: Forum Members
Last Active: Last Month
Posts: 1.6K, Visits: 3.0K
Could be more than just an idea... Smile



My PC:
OS: Windows 10 Pro English 64-bit / CPU: Intel i7-9700 3.6GHz / MB: ASUS ROG Strix Z390  RAM: 32GB DDR4 2.6GHz / HD: 2TB+3TB  /  
SSD: 2x512GB Samsung 860 EVO / 
VB: Palit GTX2080 TI GamingPro 11GB / AB: embedded in the MB and VB (audio from the VB with an HDMI splitter) / DirectX: 12




Reading This Topic