New to group

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • pythonnubie

    New to group

    Hi Everyone

    I am new to programming in general although I have read alot and
    done alot of experimentation as well as researched afew languages
    namely java python and visual basic . My conclusion is that python
    is one of the best because it eliminates the need to learn about
    access modifiers and form handlers so a user can concentrate
    primarliy on the nuts and bolts of the language .

    i have come across my first exeption using randrange . The exeption
    is " no such attribute " in module random

    platform is xp home and the python build is activestate 2.5

    All help much appreciated !

  • Jeff

    #2
    Re: New to group

    What does the code look like?

    Comment

    • Mike Driscoll

      #3
      Re: New to group

      On Mar 24, 1:53 pm, pythonnubie <exxf...@hotmai l.comwrote:
      Hi Everyone
      >
      I am new to programming in general although I have read alot and
      done alot of experimentation as well as researched afew languages
      namely java python and visual basic . My conclusion is that python
      is one of the best because it eliminates the need to learn about
      access modifiers and form handlers so a user can concentrate
      primarliy on the nuts and bolts of the language .
      >
      i have come across my first exeption using randrange . The exeption
      is " no such attribute " in module random
      >
      platform is xp home and the python build is activestate 2.5
      >
      All help much appreciated !
      Please post the code that throws this error along with the entire
      traceback.

      Thanks,

      Mike

      Comment

      • pythonnubie

        #4
        Re: New to group

        On Mar 24, 11:57 am, Jeff <jeffo...@gmail .comwrote:
        What does the code look like?
        # Random Access
        # Demonstrates string indexing
        # Michael Dawson - 1/27/03

        import random

        word = "index"
        print "The word is: ", word, "\n"

        high = len(word)
        low = -len(word)
        for i in range(10):
        position = random.randrang e(low, high)
        print "word[", position, "]\t", word[position]

        raw_input("\n\n Press the enter key to exit.")

        The code is an exerp from a chm file . I am petty sutre I am
        nmot getting a char map error from the copy/paste ! it looks
        simple enough !

        Comment

        • George Sakkis

          #5
          Re: New to group

          On Mar 24, 2:53 pm, pythonnubie <exxf...@hotmai l.comwrote:
          Hi Everyone
          >
          I am new to programming in general although I have read alot and
          done alot of experimentation as well as researched afew languages
          namely java python and visual basic . My conclusion is that python
          is one of the best because it eliminates the need to learn about
          access modifiers and form handlers so a user can concentrate
          primarliy on the nuts and bolts of the language .
          >
          i have come across my first exeption using randrange . The exeption
          is " no such attribute " in module random
          >
          platform is xp home and the python build is activestate 2.5
          Welcome aboard!

          There's definitely a randrange function in the random module, so
          something else must be wrong. To get the most out of this list and
          minimize wasted bandwidth, the most effective way usually consists of
          copying and pasting:
          1. The offending code (or just the relevant part if it's too big).
          2. The full traceback of the raised exception.

          Regards,
          George

          Comment

          • George Sakkis

            #6
            Re: New to group

            On Mar 24, 3:03 pm, pythonnubie <exxf...@hotmai l.comwrote:
            On Mar 24, 11:57 am, Jeff <jeffo...@gmail .comwrote:
            >
            What does the code look like?
            >
            # Random Access
            # Demonstrates string indexing
            # Michael Dawson - 1/27/03
            >
            import random
            >
            word = "index"
            print "The word is: ", word, "\n"
            >
            high = len(word)
            low = -len(word)
            for i in range(10):
            position = random.randrang e(low, high)
            print "word[", position, "]\t", word[position]
            >
            raw_input("\n\n Press the enter key to exit.")
            >
            The code is an exerp from a chm file . I am petty sutre I am
            nmot getting a char map error from the copy/paste ! it looks
            simple enough !
            It works fine on on Windows with standard Python 2.5. Something is
            probably wrong with your ActiveState installation.

            George

            Comment

            • Robert Kern

              #7
              Re: New to group

              pythonnubie wrote:
              On Mar 24, 11:57 am, Jeff <jeffo...@gmail .comwrote:
              >What does the code look like?
              >
              # Random Access
              # Demonstrates string indexing
              # Michael Dawson - 1/27/03
              >
              import random
              Make sure that you do not have a random.py module in the current directory.
              Python checks the current directory for modules before the standard directories.

              --
              Robert Kern

              "I have come to believe that the whole world is an enigma, a harmless enigma
              that is made terrible by our own mad attempt to interpret it as though it had
              an underlying truth."
              -- Umberto Eco

              Comment

              • Jeffrey Froman

                #8
                Re: New to group

                pythonnubie wrote:
                The exeption
                is " no such  attribute " in  module random
                Is your own source file named "random.py" by chance? If so, rename it, and
                be sure to remove the leftover random.pyc file as well.


                Jeffrey

                Comment

                • Peter Otten

                  #9
                  Re: New to group

                  pythonnubie wrote:
                  On Mar 24, 11:57 am, Jeff <jeffo...@gmail .comwrote:
                  >What does the code look like?
                  >
                  # Random Access
                  # Demonstrates string indexing
                  # Michael Dawson - 1/27/03
                  >
                  import random
                  >
                  word = "index"
                  print "The word is: ", word, "\n"
                  >
                  high = len(word)
                  low = -len(word)
                  for i in range(10):
                  position = random.randrang e(low, high)
                  print "word[", position, "]\t", word[position]
                  >
                  raw_input("\n\n Press the enter key to exit.")
                  >
                  The code is an exerp from a chm file . I am petty sutre I am
                  nmot getting a char map error from the copy/paste ! it looks
                  simple enough !
                  You have probably called your script random.py, and now it imports itself
                  instead of the random.py module in Python's standard library.

                  Rename your script to myrandom.py, remove the compiled version random.pyc in
                  the same folder, and you should be able to run it successfully.

                  Peter

                  Comment

                  Working...