PyAWS, Fermat’s Last Theorem, and search diversity

I use the Amazon API to check wishlists programmatically, and back in March I mentioned that it was being upgraded in a way that would break the Python wrapper I’d been using for years. Readers pointed me to a new wrapper called PyAWS, but I found that it didn’t offer the one thing I needed: A simple way to retrieve all the ISBNs on a wishlist.

I solved the problem for myself with a few lines of code, but neglected to include them. Today, that March entry received a hilarious comment:

I came here searching for a way to retrieve my Amazon wishlist using PyAWS… You’re the top query (out of a grand total of 5!) for pyaws wishlist amazon.

However, reading the blog article above, I had flashbacks of Fermat’s Last Theorem:

“After poring over this mysterious PyAWS, I found a wonderfully simple way of retrieving a wishlist like with PyAmazon. However the margin of this blog post is too narrow to contain the few lines of Python code required.”

:-)

Could you please post the said few lines of codes to retrieve a wishlist with PyAWS? Would be much appreciated. I’d rather not have to pore over the whole Amazon API documentation to learn how to retrieve a simple wishlist or two with PyAWS.

Sorry about that! Here’s what I’m currently doing. It’s not PyAWS, just a regex hack of the raw XML output from REST queries.

import urllib2,re

def getAmazonWishlist(aws_access_id,wishlist_id):
  url = 'http://webservices.amazon.com/onca/xml?Service=\
    AWSECommerceService&AWSAccessKeyId=%s&ListId=%s\
    &ListType=WishList&Operation=ListLookup' %\ 
    (aws_access_id, wishlist_id)
  s = urllib2.urlopen(url).read()
  pages = re.findall('<TotalPages>(.+?)</TotalPages>',s)[0]
  for page in range(int(pages)): 
    url = 'http://webservices.amazon.com/onca/xml?Service=\
      AWSECommerceService&AWSAccessKeyId=%s&ListId=%s\
      &ProductPage=%s&ListType=WishList&Operation=ListLookup\
      &ResponseGroup=ListFull' %\ 
      (aws_access_id, wishlist_id, page+1)
    s += urllib2.urlopen(url).read()
  return re.findall('<ASIN>(.+?)</ASIN>.+?<Title>(.+?)<',s)

(Ironically the margin of this blog post is too narrow for the few lines of Python code required, so I’ve split those lines where indicated.)

By the way, DoubleSearch reveals that although Google currently finds only 5 results for pyaws wishlist amazon, Live Search finds 9. More importantly, if the blog entries from Rich Burridge and me are indeed the most relevant results, Live Search puts them first.

That’s not always true, of course. Often Google does better. But not always. In any case, even when the first pages of results from both engines are equally relevant, they’ll likely differ in ways that DoubleSearch invites you notice.

If you’re inclined to dismiss what I’m about to say because I’m employed as a Microsoft evangelist, then fair enough, move along, there’s nothing to see here. But if you’ve followed me over the years and continue to trust my instincts, then hear me out on this. I’ve always believed in, and acted on, the principle of diversity. If you think the same way, then you use more than one operating system, more than one programming language, more than one application in many categories.

So why would you use only one search engine?

If you haven’t tried Live Search in a while, you’ll find that it’s improved quite a bit. I’m not saying it’s better than Google, but I am saying it’s usefully different. Given the central importance of search, I argue that it’s in everyone’s interest to exploit that diversity.

Now arguably most people don’t care about diversity. There’s a strong impulse to find one way to do something, and then stick with it. People don’t readily adopt new behavior. To help them along, you need to minimize disruption.

To that end, I’ve been asking some friends and associates to give DoubleSearch a try. Specifically, I’m asking them to make it their browser’s default search provider, then let me know how long they keep it and, if they drop it, why.

I know there are logistical issues with DoubleSearch. In particular, given the side-by-side-in-frames presentation, it’s awkward to click through on a search result. You’d rather right-click and open in a new tab. Some people already have that habit, others don’t, their experiences will differ accordingly.

I’m sure there are deeper cognitive issues as well. For example, I find it useful to compare the two result pages side-by-side, but others — maybe many others — will just find that distracting.

Anyway, if you do try this experiment for yourself, feel free to comment here on how it goes.

Posted in Uncategorized

7 thoughts on “PyAWS, Fermat’s Last Theorem, and search diversity

  1. Ah, the old “this XML is too hard to parse correctly, and too easy to parse with regex” style; I recognize that approach.

    I suspect that this reduces to three lines of shell script with curl and grep and sed, but the margins are too narrow to include the code. (I’ll post it somewhere if I can get it down to that.)

  2. I have in fact found Live Search usefully different in some cases, for example I have recommended it to my children for searching images and for some searches, but I found that they seem to prefer Google.
    I also enjoy a9.com for music related searches.
    To be fair Google is a lot of search engines glued together and result streams are mixed sometimes usefully, for example code searches or music searches are specialized.

  3. I love the doublesearch – I wrote on something similar a while back and called it Mihooglia (http://opoli.org/?p=53). I realized I’d gotten to a place of psychological lock-in with Google, a standing assumption that G was better in every circumstance but I lacked the tools to make an objective and inexpensive comparison of search results.
    Anyway – I’m jumping into DS now.

    Many thanks,
    -cc

  4. I think there is an issue with doublesearch right now. Live.com is requiring me to prove I am not a machine running some sort of DoS attack. I have to play the enter the characters game. Live.com works if I got straight there, so I think the issue is how it sees searches from DS.

  5. CLARIFICATION ON THE COUNTEREXAMPLES TO FERMAT’S LAST THEOREM
    By E. E. Escultura

    Although all issues related to the resolution of Fermat’s last theorem have been fully debated worldwide since 1997 and NOTHING had been conceded from my side I have seen at least one post expressing some misunderstanding. Let me, therefore, make the following clarification:

    1) The decimal integers N.99… , N = 0, 1, …, are well-defined nonterminating decimals among the new real numbers [8] and are isomorphic to the ordinary integers, i.e., integral parts of the decimals, under the mapping, d* -> 0, N+1 -> N.99… Therefore, the decimal integers are integers [3]. The kernel of this isomorphism is (d*,1) and its image is (0,0.99…). Therefore, (d*)^n = d* since 0^n = 0 and (0.99…)^n = 0.99… since 1^n = 1 for any integer n > 2.

    2) From the definition of d* [8], N+1 – d* = N.99… so that N.99… + d* = N+1. Moreover, If N is an integer, then (0.99…)^n = 0.99… and it follows that ((0.99,..)10)^N = (9.99…)10^N, ((0.99,..)10)^N + d* = 10^N, N = 1, 2, … [8].

    3) Then the exact solutions of Fermat’s equation are given by the triple (x,y,z) = ((0.99…)10^T,d*,10^T), T = 1, 2, …, that clearly satisfies Fermat’s equation,
    x^n + y^n = z^n, (F)

    for n = NT > 2. The counterexamples are exact because the decimal integers and the dark number d* involved in the solution are well-defined and are not approximations.

    4) Moreover, for k = 1, 2, …, the triple (kx,ky,kz) also satisfies Fermat’s equation. They are the countably infinite counterexamples to FLT that prove the conjecture false [8]. They are exact solutions, not approximation. One counterexample is, of course, sufficient to disprove a conjecture.

    The following references include references used in the consolidated paper [8] plus [2] which applies [8]

    References

    [1] Benacerraf, P. and Putnam, H. (1985) Philosophy of Mathematics, Cambridge University Press, Cambridge, 52 – 61.
    [2] Brania, A., and Sambandham, M., Symbolic Dynamics of the Shift Map in R*, Proc. 5th International
    Conference on Dynamic Systems and Applications, 5 (2008), 68–72.
    [3] Corporate Mathematical Society of Japan , Kiyosi Itô, Encyclopedic dictionary of mathematics (2nd ed.), MIT Press, Cambridge, MA, 1993
    [4] Escultura, E. E. (1997) Exact solutions of Fermat’s equation (Definitive resolution of Fermat’s last theorem, 5(2), 227 – 2254.
    [5] Escultura, E. E. (2002) The mathematics of the new physics, J. Applied Mathematics and Computations, 130(1), 145 – 169.
    [6] Escultura, E. E. (2003) The new mathematics and physics, J. Applied Mathematics and Computation, 138(1), 127 – 149.
    [7] Escultura, E. E., The new real number system and discrete computation and calculus, 17 (2009), 59 – 84.
    [8] Escultura, E. E., Extending the reach of computation, Applied Mathematics Letters, Applied Mathematics Letters 21(10), 2007, 1074-1081.
    [9] Escultura, E. E., The mathematics of the grand unified theory, in press, Nonlinear Analysis, Series A:
    Theory, Methods and Applications; online at Science Direct website
    [10] Escultura, E. E., The generalized integral as dual of Schwarz distribution, in press, Nonlinear Studies.
    [11] Escultura, E. E., Revisiting the hybrid real number system, Nonlinear Analysis, Series C: Hybrid Systems, 3(2) May 2009, 101-107.
    [12] Escultura, E. E., Lakshmikantham, V., and Leela, S., The Hybrid Grand Unified Theory, Atlantis (Elsevier Science, Ltd.), 2009, Paris.
    [13] Counterexamples to Fermat’s last theorem, http://users.tpg.com.au/pidro/
    [14] Kline, M., Mathematics: The Loss of Certainty, Cambridge University Press, 1985.

    E. E. Escultura
    Research Professor
    V. Lakshmikantham Institute for Advanced Studies
    GVP College of Engineering, JNT University
    Madurawada, Vishakhapatnam, AP, India
    http://users.tpg.com.au/pidro/

Leave a Reply