On Jan 28, 8:27 am, Lie Ryan wrote:
> On 01/28/10 11:28, Brian D wrote:
>
>
>
> > I've tackled this kind of problem before by looping through a patterns
> > dictionary, but there must be a smarter approach.
>
> > Two addresses. Note that the first has incorrectly transposed the
> > direction and s
> Correction:
>
> [snip] the expression "parts[1 : -1]" means gather list items from the
> second element in the list (index value 1) to one index position
> before the end of the list. [snip]
MRAB's solution was deserving of a more complete solution:
>>> def parse_address(address):
# Ha
On 01/28/10 11:28, Brian D wrote:
> I've tackled this kind of problem before by looping through a patterns
> dictionary, but there must be a smarter approach.
>
> Two addresses. Note that the first has incorrectly transposed the
> direction and street name. The second has an extra space in it befo
On Jan 28, 7:40 am, Brian D wrote:
> > > [snip]
> > > Regex doesn't gain you much. I'd split the string and then fix the parts
> > > as necessary:
>
> > > >>> def parse_address(address):
> > > ... parts = address.split()
> > > ... if parts[-2] == "S":
> > > ... parts[1 : -1] = [pa
> > [snip]
> > Regex doesn't gain you much. I'd split the string and then fix the parts
> > as necessary:
>
> > >>> def parse_address(address):
> > ... parts = address.split()
> > ... if parts[-2] == "S":
> > ... parts[1 : -1] = [parts[-2]] + parts[1 : -2]
> > ... parts[1 : -1]
On Jan 27, 7:27 pm, MRAB wrote:
> Brian D wrote:
> > I've tackled this kind of problem before by looping through a patterns
> > dictionary, but there must be a smarter approach.
>
> > Two addresses. Note that the first has incorrectly transposed the
> > direction and street name. The second has an
On Jan 27, 6:35 pm, Paul Rubin wrote:
> Brian D writes:
> > I've tackled this kind of problem before by looping through a patterns
> > dictionary, but there must be a smarter approach.>
> > Two addresses. Note that the first has incorrectly transposed the
> > direction and street name.
>
> I
Brian D wrote:
I've tackled this kind of problem before by looping through a patterns
dictionary, but there must be a smarter approach.
Two addresses. Note that the first has incorrectly transposed the
direction and street name. The second has an extra space in it before
the street type. Clearly
Brian D writes:
> I've tackled this kind of problem before by looping through a patterns
> dictionary, but there must be a smarter approach.>
> Two addresses. Note that the first has incorrectly transposed the
> direction and street name.
If you're really serious about it (e.g. you are the p
I've tackled this kind of problem before by looping through a patterns
dictionary, but there must be a smarter approach.
Two addresses. Note that the first has incorrectly transposed the
direction and street name. The second has an extra space in it before
the street type. Clearly done by someone
10 matches
Mail list logo