Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7064445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:50:07+00:00 2026-05-28T04:50:07+00:00

I’ve been teaching myself python recently an came across and example where str.endswith took

  • 0

I’ve been teaching myself python recently an came across and example where str.endswith took a tuple as it’s first argument, which 2.4 doesn’t support. I decided to try and install a newer version of Python on my machine so I was more up to date. The machine is CentOs5.

As my user on the machine (not root) I pulled the package from here: http://www.python.org/ftp/python/2.6.7/, uncompressed it, did ./configure –prefix=/home/myusername/python/compiler/Python-2.6.7-installed, then ran make, make test (all okay) and then finally make altinstall for good measure (I know it shouldn’t be necessary to do altinstall as I specified a prefix but really don’t want to break regular python on this machine). When it first didn’t work I tried the make altinstall as root also, but it made no difference.

When I try to run a script against the binary I just get a bunch of gibberish like this:

./compiler/Python-2.6.7/Lib/test/test_re.pyc :   onXtd}|iti|iddddgdS(Nsu"     [\u002E\u3002\uFF0E\uFF61]"sa.b.cR$RHRX(R0RÑRÚR        RRY(R                                                                                                                                             R7((s@/home/yspendiff/python/compiler/Python-2.6.7/Lib/test/test_re.pyttest_bug_931848as
Cstidd}|i|iid|it|itidd}|i|i     id|i|i  ddS(Ns\ssa bii(ii(ii(
StopIterationRºRR(R                                          RRÓR       tnextRR4t
Rº((s@/home/yspendiff/python/compiler/Python-      2.6.7/Lib/test/test_re.pyttest_bug_581080js
 cCsatidd}|i|iid|i|iid|it|idS(Ns.*tasdfii(ii(ii(RRÓR     RÝRR4RÞ(R

and perhaps more pertinently lots of lines like these:

./compiler/Python-2.6.7/Lib/test/test_unicode.py :           self.assert_(u'asdf' not in '')
./compiler/Python-2.6.7/Lib/test/test_unicode.py :           self.assert_('asdf' not in u'')
./compiler/Python-2.6.7/Lib/test/test_unicode.py :           self.assert_(u'asdf' not in u'')
./compiler/Python-2.6.7/Lib/test/test_re.py :           iter = re.finditer(r".*", "asdf")
./compiler/Python-2.6.7/Lib/test/string_tests.py :           self.checkequal(True,  'asdf', '__contains__', 'asdf')
./compiler/Python-2.6.7-installed/lib/python2.6/test/test_unittest.py :               loader.loadTestsFromNames(['sdasfasfasdf'])
./compiler/Python-2.6.7-installed/lib/python2.6/test/test_unittest.py :               self.assertEqual(str(e), "No module named sdasfasfasdf")

That is just a few random lines out of hundreds. I haven’t messed around with any of the default options, have I pulled down a funny version or specified some funny compilation options. How do I turn it off so I can just code in peace!

The code is below if anyone is interested. I just call it with ./Findword.py asdf :

#!/home/myusername/python/compiler/Python-2.6.7-installed/bin/python2.6

### FindWord.py

import os                                 # for curdir()            #(A)
import os.path                            # for join(), isfile()    #(B)
import sys                                # for argv[], exit()      #(C)


if len( sys.argv ) != 2:                                            #(D)
    print "need a word or a single-quoted phrase to search for"     #(E)
    sys.exit(1)                                                     #(F)

def searchInFile( pattern, dirname, filenames ):                    #(G)
    for name in filenames:                                          #(H)
        name = os.path.join( dirname, name )                        #(I)
        if os.path.isfile( name ) and not name.endswith(('.pdf','.pl')):   #(J)
            FH = open( name, 'r' )                                  #(K)
            for eachline in FH:                                     #(L)
                if ( eachline.find( pattern ) != -1 ):              #(M)
                    print name, ':  ', eachline                     #(N)

os.path.walk( os.curdir, searchInFile, sys.argv[1] )                #(O)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T04:50:08+00:00Added an answer on May 28, 2026 at 4:50 am

    Pretty much exactly what you’re asking Python to do is happening. You’re telling it to find the word ‘asdf’ from whatever your current directory is, it’s finding it in binary files.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
i got an object with contents of html markup in it, for example: string
I'm making a simple page using Google Maps API 3. My first. One marker
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.