Take the 2-minute tour ×

Hi I ve a script in iron python where a variable mite contain special characters. Ex name- megha_lohit url - http://url.com

if name == megha_lohit: print 'success' else raise testcaseexception(failed)

Here the code doesnt pass the if loop and enters teh else part failing the test case , even though name = megha_lohit(right hand side expression), same case is with url too. Could somebody help me out

share|improve this question
We'll be happy to help once you translate the gibberish to English :P –  Aurum Aquila Apr 26 '11 at 4:25
@Aurum aquila:its english in simple words...i ve clearly mentioned tat it is not able to accept special characters like: " :" "`" "_" (colon, escape , underscore)i hope u got it now!!!! –  meghana Lohit Apr 26 '11 at 7:12

1 Answer 1

up vote 0 down vote accepted

By design variable names cannot contain ":" and "`". Underscores are ok. Maybe your problem is something else in your code.

IronPython 2.7 ( on .NET 4.0.30319.1
>>> a_foo= "hello"
>>> a:foo= "hello"
  File "<stdin>", line 1
    a:foo= "hello"

SyntaxError: unexpected token ':'

>>> a`foo= "hello"
  File "<stdin>", line 1
    a`foo= "hello"

SyntaxError: unexpected token '`'

share|improve this answer
Hi, There is a method which will retrieve a value and return it to the variable assigned ex: title = self.GetTitleOfTheMovie() which may return a value like this "The Ranger:Part-2". When i compare this value with the if loop, it says the strings are not equal. Ex if title == "The Ranger:Part-2" print 'success' else print 'failure'. It prints failure. What mite be the reason for it not to pass the if loop even though the title value and right hand side expression are equal??? Here title contains the special character ":" –  meghana Lohit Apr 27 '11 at 4:08
If I code your example up it works. So there must be a difference between your values. Perhaps one has extra whitespace, a return character, non-breaking space - something. If you are still stuck, post a new questions with more code and sample information. –  WombatPM Apr 27 '11 at 12:56

Your Answer


