473,396 Members | 1,836 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Find and slice problem

Hi guys, been going around in circles with this so I hope you can help!

My current situation is I'm using Grinder and Jython to test pages, but
the log on process is giving me some headaches. After entering the
correct username and password, you then need to enter 3 characters from
the security phrase. I'm attempting to read the HTML to find out with
characters I need (e.g. 1st, 3rd and 6th char) then look up those
values in the security phrase, but I'm getting stuck on the following
function:

<code>

def getValue(page,delimEnd) :
EndVar = page.find(delimEnd)
thisVar = page[EndVar-1:EndVar]
return thisVar

</code>

<unique code I'm using as a delimeter>
:</strong></td>
<td class="producttableinnerborder"></td>
<td></td>

<td><select name="char1">
</unique code I'm using as a delimeter>

the specific number I require proceeds the ':' at the start of the
code.

What I'm attemping to pass in is some multiline HTML(above) and pick up
the proceeding character, but it seems to be reading from the end of
the HTML instead! I've only been using this setup for a couple of days
so it's probably something simple, anyone care to enlighten me?

cheers,

Jon

Jan 17 '06 #1
1 1101
jo*****@yahoo.co.uk wrote:
Hi guys, been going around in circles with this so I hope you can help!

My current situation is I'm using Grinder and Jython to test pages, but
the log on process is giving me some headaches. After entering the
correct username and password, you then need to enter 3 characters from
the security phrase. I'm attempting to read the HTML to find out with
characters I need (e.g. 1st, 3rd and 6th char) then look up those
values in the security phrase, but I'm getting stuck on the following
function:

<code>

def getValue(page,delimEnd) :
EndVar = page.find(delimEnd)
thisVar = page[EndVar-1:EndVar]
return thisVar

</code>

What I'm attemping to pass in is some multiline HTML(above) and pick up
the proceeding character, but it seems to be reading from the end of
the HTML instead!


page.find(delimEnd) returns -1 if delimEnd is not found, and after that
you take page[-2:-1], i.e. second last character.

So you could add a test for that, if EndVar == -1 etc.
but I recommend using page.index(delimEnd) which raises an error if
delimEnd is not found.
Jan 18 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Roberto A. F. De Almeida | last post by:
I found that when using negative indices, the slice object passed to __getitem__ depends on the number of slices. An example to clarify: class a: def __getitem__(self, index): return index ...
108
by: Bryan Olson | last post by:
The Python slice type has one method 'indices', and reportedly: This method takes a single integer argument /length/ and computes information about the extended slice that the slice object would...
0
by: Clemens Hintze | last post by:
Hello, I have a question concerning the usage of default constructed std::slice instances. Our company currently validate the GNU-G++ 3.4 compiler against the ISO/IEC 14882:2003 standard for...
2
by: smichr | last post by:
It seems to me that the indices() method for slices is could be improved. Right now it gives back concrete indices for a range of length n. That is, it does not return any None values. Using an...
3
by: Bas | last post by:
Hi, stupid question, but would it be possible to somehow merge xrange (which is supposed to replace range in py3k) and slice? Both have very similar start, stop and step arguments and both are...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.