How to check data type in robot framework? - python-2.7

I read this
But when i'm passing string value in the variable at that time i'm getting error
Code :
type(${value}).__name__
Error:
Evaluating expression 'type(Robot).__name__' failed: NameError: name 'Robot' is not defined
String value converting as a variable
Please help me.

You should remove brackets {} around value and leave only $value.
Update to comment:
Robotframework treats everything as string unless you explicitly convert it to other datatype.
${value_str} Set Variable 4
${value_number} Convert To Number ${value_str}
${type1} Evaluate type($value_str).__name__
${type2} Evaluate type($value_number).__name__
Log ${type1}
Log ${type2}

Related

Format timestamp inside a set-column sentence

I'm developing a data fusion pipeline. It contains a wrangler node where I'm trying to create a new field that will contain the system date in timestamp format (yyyy-MM-dd'T'HH-mm-ss).
I've tried using the sentence:
set-column :sysdate (${logicalStartTime(yyyy-MM-dd'T'HH-mm-ss)})
But I receive the error:
Caused by: io.cdap.wrangler.api.DirectiveParseException: Error encountered while parsing 'set-column' : Error encountered while compiling '( 2022 -12-01T16-29-32 ) ' at line '1' and column '14'. Make sure a valid jexl transformation is provided.
Which would be the correct sentence?
I've tried:
set-column :sysdate (${logicalStartTime(yyyy-MM-ddHH-mm-ss)})
Which will result in something like "1877", as it substracts the numbers, and also tried:
set-column :sysdate (${logicalStartTime(yyyyMMddHHmmss)})
but the format isn't correct and can only be written if the field is a String.
You have the correct method, just incorrect syntax. The syntax you are looking for is set-column :sysdate ${logicalStartTime(yyyy-MM-dd'T'HH-mm-ss)}, you have to remove (). Then you can convert the string in datetime pattern in this format parse-as-datetime :sysdate "yyyy-MM-dd'T'HH-mm-ss".

Error - Cannot assign to value: function call returns immutable value

I'm doing an introductory iOS developer's course, and am doing a cat-years calculator as an exercise. The following code returns the error:
Int(AgeInCatYears.text!) = CatsROld!
Error - Cannot assign to value: function call returns immutable value
In case it's important, the var CatsROld was set equal to Int(humanYears.text!)! * 7 one line earlier.
Any advice?
If you are setting value to the Label or textField then you need to simply set value (as String) to its property text, but you are try to convert the value to Int and then you assigning value of CatsROld to it, that is the reason you are getting this error. So simply write like AgeInCatYears.text = "\(CatsROld!)"
AgeInCatYears.text = "\(CatsROld!)"
Note: You are force wrapping CatsROld value with !, if you are 100% sure that it will not nil then its ok other wise you need to use if let or guard for optional wrapping.

check whether the given date value is valid or not in python with django

I need to check whether the given input value of date is valid or not in python. I normally used datetime.strptime is to check for date. Am getting Value Error doesn't match format when i given the input value date '06-06-'. It's wrong only but i want to display the output like invalid.
if (datetime.strptime(s,'%m-%d-%y')):
print "valid"
else:
print "Invalid"
1 . s = '06-06-15'
when i given the input value like above, it display the correct output value "Valid"
s = '06-06-'
when i given the input value like above, am getting error like time data '06-13' does not match format '%m-%d-%y'. But i want to display the output "Invalid"
Please anyone suggest me to do that. Thanks in advance.
This is just how it works.
ValueError is raised if the date_string and format can’t be parsed by
time.strptime()
Just turn it to
datetime.strptime(s,'%m-%d-%y'):
print "valid"
except ValueError:
print "Invalid"

int() argument must be a string or a number, not 'Vec2D'

I face a problem below.When I run another function related to this 'if',type error is "int() argument must be a string or a number, not 'Vec2D' ",then I cut off the int(),and the type error changes to "slice indices must be integers or None or have an index method ",wtf,waiting for someone's brilliant help.
def singleOrder(argument):
global position
global direction
if argument==']':
lastPosition=position[len(position)-1]
lastDirection=direction[len(direction)-1]
turtle.setposition(lastPosition)
turtle.setheading(lastDirection)
position=position[:int(lastPosition)]
direction=direction[:int(lastDirection)]
Removing the last element of a list is easy:
del L[-1]

How to test for missing attribute in XSL?

What I have is following:
<xsl:variable name="myvar" select=".//spss:category[((not #varName) or #varName=$colVarName) and #text=$series]/spss:cell/#text"/>
What it should do is select the text of the spss:cell's text-Attribute as long as it is a child of a spss:category that has
either a varName Attribute with a value equal to $colVarName
OR no varName Attribute at all
What is happening is following error message (sorry translating here, so just the gist of it):
Expected Token ')'. Found Token '#'.
.//spss:category[((not -->#<-- varName) or #varName=$colVarName...
Problem Solved! (See below)
OK, I think I found the mistake:
not must be used with parenthesis, so instead of
(not #varName) or #varName=$colVarName
it should have been
not(#varName) or #varName=$colVarName
indeed - not() is a function that returns the boolean opposite of whatever is between the parens. If necessary - it will cast its argument to a boolean. In this case, an empty node set casts automatically to false, so if #varName gives you an empty node set, not(#varName) will be true.