Logo QF-Test

Finding valuable answers
in the Mailing List Archive.

 

Free Trial  Download  Buy

Thomas Max, QF-Test training and support

Use the full-text search on our web site to find helpful tips on the mailing list.

Thomas Max, 
Sr. Software Engineer & Trainer, QFS

2016 up to now | 2015 | 2014 | 2013 | 2012 | 2011 | 2010 | 2009 | 2008 | 2007

(older archive entries before 2007 are not shown here, but included in the onsite-search)

Mailing List - Entries of 2007


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [QF-Test] Help required to typecast String to List in SUTScript


  • Subject: Re: [QF-Test] Help required to typecast String to List in SUTScript
  • From: "Alfred Mathavan" <amathava@?.com>
  • Date: Fri, 11 May 2007 05:39:42 -0600

Robert,

Thanks you very much.
I appreciate.

Greetings,
Alfred

-----Original Message-----
From: Robert Lahmer, QFS support [mailto:support@?.de]
Sent: Friday, May 11, 2007 5:00 PM
To: qftest-list@?.de
Cc: Alfred Mathavan
Subject: Re: [QF-Test] Help required to typecast String to List in SUTScript



Hello Alfred,

your QF-Test variable globalList is a string, so I think a simple typecast
won't help. But you can split the string into its elements like this:

import string

globalList="'172.31.11.181','172.26.20.158','172.31.11.184'"
globalList = string.replace(globalList, "'", "")
# split returns a list - make a tuple of it, if you like
IPList=tuple(string.split(globalList,","))
print type(IPList)
print IPList
list=list(IPList)
print len(list)
print list


The output is:

org.python.core.PyTuple
('172.31.11.181', '172.26.20.158', '172.31.11.184')
3
['172.31.11.181', '172.26.20.158', '172.31.11.184']


Best regards,
    Robert



--On Freitag, Mai 11, 2007 02:51:13 -0600 Alfred Mathavan
<amathava@?.com> wrote:

> Hi All,
>
>
>
> I have configured JYDT (Jython Development Tool) in eclipse v3.2
>
> Click here -> http://www.redrobinsoftware.net/jydt/ for more information
> on JYDT.
>
>
>
> After Configuration of JYDT in Eclipse I am able to develop and execute
> Jython programs in Eclipse IDE.
>
>
>
> For E.g.:
>
> IPList='172.31.11.181','172.26.20.158','172.31.11.184','172.31.11.200','
> 172.31.11.186','172.31.11.183',
>
> print type(IPList)
>
> print IPList
>
>
>
> list=list(IPList)
>
> print len(list)
>
> print list
>
>
>
> Output:
>
> <type 'tuple'>
>
> ('172.31.11.181', '172.26.20.158', '172.31.11.184', '172.31.11.200',
> '172.31.11.186', '172.31.11.183')
>
> 6
>
> ['172.31.11.181', '172.26.20.158', '172.31.11.184', '172.31.11.200',
> '172.31.11.186', '172.31.11.183']
>
>
>
> When I try to get the same with QF-Test SUT Script with a slight change
> in the IPList variable type I goof up.
>
> I am not sure how to typecast a String variable to a tuple (or) List.
>
>
>
> In QFTest I have a variable called globalList with the value
> '172.31.11.181','172.26.20.158','172.31.11.184','172.31.11.200','172.31.
> 11.186','172.31.11.183',
>
>
>
> I try to get the same output that I got in Eclipse from my SUT Script.
>
>
>
> The 2 approaches that I tried are:-
>
> Approach 1
>
> IPList=globalList
>
> print type(IPList)
>
> print IPList
>
>
>
> list=list(IPList)
>
> print len(list)
>
> print list
>
> Output 1
>
> org.python.core.PyString
>
> '172.31.11.181','172.26.20.158','172.31.11.184','172.31.11.200','172.31.
> 11.186','173.34.3.3','172.31.11.183',
>
> 109
>
> ["'", '1', '7', '2', '.', '3', '1', '.', '1', '1', '.', '1', '8', '1',
> "'", ',', "'", '1', '7', '2', '.', '2', '6', '.', '2', '0', '.', '1',
> '5', '8', "'", ',', "'", '1', '7', '2', '.', '3', '1', '.', '1', '1',
> '.', '1', '8', '4', "'", ',', "'", '1', '7', '2', '.', '3', '1', '.',
> '1', '1', '.', '2', '0', '0', "'", ',', "'", '1', '7', '2', '.', '3',
> '1', '.', '1', '1', '.', '1', '8', '6', "'", ',', "'", '1', '7', '3',
> '.', '3', '4', '.', '3', '.', '3', "'", ',', "'", '1', '7', '2', '.',
> '3', '1', '.', '1', '1', '.', '1', '8', '3', "'", ',']
>
>
>
>
>
> Approach 2
>
>             IPList=[globalList]
>
> print type(IPList)
>
> print IPList
>
>
>
> list=list(IPList)
>
> print len(list)
>
> print list
>
> Output 2
>
> org.python.core.PyList
>
> ["'172.31.11.181','172.26.20.158','172.31.11.184','172.31.11.200','172.3
> 1.11.186','173.34.3.3','172.31.11.183',"]
>
> 1
>
> ["'172.31.11.181','172.26.20.158','172.31.11.184','172.31.11.200','172.3
> 1.11.186','173.34.3.3','172.31.11.183',"]
>
>
>
> Any help to get the exact list from the SUT Script?
>
>
>
> Greetings,
>
> Alfred
>
>
>
>
>
>



--
Robert Lahmer
Quality First Software GmbH                http://www.qfs.de
Tulpenstr. 41                           Tel: +49 8171 919874
DE-82538 Geretsried                     Fax: +49 8171 919876
GF: Gregor Schmid, Karlheinz Kellerer     HRB München 140833



Videos Downloads Documentation Buy Free Trial