sneekula 969 Nearly a Posting Maven

Ever since I got my Ubuntu notebook computer, I can't fail to notice how fast it starts up (and shuts down) compared to my Windows Vista notebook. Other than the system itself, the virus program seems to take more and more time as it checks for seemingly millions of possible virus attacks. More and more viruses are added each minute, and there will come a time when it takes hours to check them all. At that point Windows will have died, or at least its users will get too angry to use it.

That doesn't even count the many rather pesky and time consuming upgrades of Vista and the virus programs. Worst of those are the once that insist that the computer be rebooted! It takes my Vista machine close to five minutes to do so.

sneekula 969 Nearly a Posting Maven

Ummm well my isp seems to have provided plenty of rest stops on my connection.

You should go over there and use them.

sneekula 969 Nearly a Posting Maven

Genetically altered grain for instance could create something like a misfolded protein called a prion. This was the agent that caused mad-cow-disease in the brains of cows and other animals and then spread to humans. It is more hideous than the flu because it takes several years to develop and the prions are not destroyed by cooking. With the ever increasing population, there is pressure to improve grain yields by genetic means.

Just trying to be cheerful!

sneekula 969 Nearly a Posting Maven

I am thinking of the old time machine story, where people rather than pigs were raised for food.

sneekula 969 Nearly a Posting Maven

Steamed shrimp on linguini with a lemon, white wine, garlic sauce. I am feasting like a king!

sneekula 969 Nearly a Posting Maven

The wx demos sugg because there is too much code bloat! You may be able to figure it out anyway.

BTW, your console code could stand major improvement.

sneekula 969 Nearly a Posting Maven

The easiest way is to use a wx.RadioBox:

import wx

class MyFrame(wx.Frame):
    def __init__(self, parent=None):
        wx.Frame.__init__(self, parent, wx.ID_ANY, size=(300, 160))
        # match to the number of radiobuttons
        self.mychoices = ['image1', 'image2', 'image3', 'image4']

        # create a box with 4 radio buttons, no labels here
        label_choices = [' ', ' ', ' ', ' ']
        self.radiobox = wx.RadioBox(self, wx.ID_ANY,
            " click on a button ",
            choices=label_choices, style=wx.VERTICAL)
        # bind mouse click to an action
        self.radiobox.Bind(wx.EVT_RADIOBOX, self.onAction)

        # show present selection
        self.onAction(None)

    def onAction(self, event):
        """show the selected choice"""
        index = self.radiobox.GetSelection()
        s = "Selected " + self.mychoices[index]
        # show the result in the frame title
        self.SetTitle(s)


app = wx.App(0)
MyFrame().Show()
app.MainLoop()
sneekula 969 Nearly a Posting Maven

The simplest way is to use Python's built-in rot13 encoder. Write one program to give you the encoded password:

# program to rot13 encode a given password, here 'nixon'
# copy the result into your program that needs this password
# and then use encode('rot13') to match user password

password = 'nixon'
encoded_password = password.encode('rot13')

print(encoded_password)  # avkba

Then use the encoded password in your main program, This way you don't give away the password in your code:

# program to use a rot13 encoded password, here 'avkba'

print('I will tell you a story if you enter the correct password')

# loop until the correct password has been entered
while True:
    # for Python3 remove 'raw_'
    pw = raw_input("Enter the password: ")
    if pw.encode('rot13') == 'avkba':
        print("Well, here is my story ...")
        break
    else:
        print("password did not match, try again!")
sneekula 969 Nearly a Posting Maven

Lots of good folks have talked this over. It's fun to explore the few new things introduced in Python3, but if you want to produce programs, you better stick with the production level Python25 or now Python26 versions.

sneekula 969 Nearly a Posting Maven

Portable Python installs a portable version of Python right on an inexpensive USB flash drive (plan on 150MB for each version). You can use the flash drive now on Windows computers that do not have Python installed. It comes in Python25, Python26 and Python30 flavors. See:
http://www.portablepython.com/releases/

In your case download Portable Python 1.1 based on Python 3.0.1 and install it on your flash drive. Then load your .py or better .pyc file (python byte code file to protect your source a little) and run (you may need a little batch file to do this) it from the flash drive. That installation also comes with the PyScripter IDE, a great program to write and run your python code.

sneekula 969 Nearly a Posting Maven

you guys sure? Boa looks like it's something I would have written in TP7 when I was a kid... but first looks may be deceiving :)

I've tried Glade3 as well, converted the .glade file to .xml, but couldn't manage to get the script to read it properly for some reason.
btw, can I use glade with the wx module?

On my Ubuntu machine I installed SPE (written in wxPython) and it has wxGlade as a designer tool, seems to work okay. However, the output is an XML file again. You can use wxPython code to import these XML files as resource files.

I filed this code that Vegaseat left some a time ago:

# use an xml resource string or file to create widgets
# you can create .xrc or .xml files with something like wxGlade
# wxGlade from: http://wxglade.sourceforge.net/
# source: vegaseat

import  wx
import  wx.xrc  as  xrc

class MyFrame(wx.Frame):
    def __init__(self, parent, title):
        wx.Frame.__init__(self, parent, wx.ID_ANY, title, size=(400, 300))

        self.toggle = True

        # load the xml resource file
        # should be in your working folder or use full path
        res = xrc.XmlResource('resource.xrc')

        '''
        # or you can use a resource string directly
        res = xrc.EmptyXmlResource()
        res.LoadFromString(xml_resource)
        '''

        # create the panel from the resource
        self.panel = res.LoadPanel(self, 'MyPanel')
        # bind mouse click to the button in the resource
        self.Bind(wx.EVT_BUTTON, self.onClick,
            id=xrc.XRCID('ColourButton'))
        self.Bind(wx.EVT_BUTTON, self.showInfo,
            id=xrc.XRCID('InfoButton'))

    def onClick(self, event):
        """do something with the button click"""
        if self.toggle:
            self.panel.SetBackgroundColour('green')
            self.toggle = False
        else:
            self.panel.SetBackgroundColour('red')
            self.toggle …
sneekula 969 Nearly a Posting Maven

The nice thing about using a GUI toolkit is that you have a large number of widgets available to supply the data input. Here is a Tkinter Temperature Converter example using radio buttons to select the type of conversion and a scale (slider) to set the temperature. Notice that the result is updated as changes to the inputs are made:

#!/usr/bin/env python

# use Tkinter's scale/slider and radiobutton widgets
# for input data to convert temperature values

import Tkinter as tk

def on_click():
    """radio button clicked, change results too"""
    on_move()

def on_move(value=0):
    """use slider position to calculate and display result"""
    # radio button1 is set convert C to F
    if rb_v.get() == id_rb1:
        c = scale.get()
        f = c*9/5.0 + 32
        result = "%s celsius --> %s Fahrenheit" % (c, f)
    # radio button2 is set convert F to C
    else:
        f = scale.get()
        c = (f - 32)*5/9.0
        result = "%s Fahrenheit --> %s Celsius" % (f, c)
    label['text'] = result

root = tk.Tk()
root.title('Temperature Converter')
# use width x height + x_offset + y_offset (no spaces!)
root.geometry("620x110+30+50")

# used by the radio button_id
rb_v  = tk.IntVar()

# the radio buttons allow selection of Celsius or Fahrenheit
id_rb1 = 101
rb1 = tk.Radiobutton(root, text='Celsius to Fahrenheit',
    value=id_rb1, variable=rb_v, command=on_click)
id_rb2 = 102
rb2 = tk.Radiobutton(root, text='Fahrenheit to Celsius',
    value=id_rb2, variable=rb_v, command=on_click)
# start with rb1 selected
rb_v.set(id_rb1)

# the scale (or slider) selects the temperature
# from -50 to +300
# (from_ is used because from is a …
sneekula 969 Nearly a Posting Maven

"Life is what you pour into it!"
-- from a bottle ot Pyramid Hefeweizen

sneekula 969 Nearly a Posting Maven

My girlfriend's parents are here from Austria, and she cooked a real American meal for the party. Yes, I mean "spaghetti with meat sauce". Great tasting sauce made from scratch using tomatoes, onions, mushrooms, ground beef, asiago cheese, garlic, basil, red pepper and few other things that are her secret.

sneekula 969 Nearly a Posting Maven

Humanity will become extinct with the next nuclear war. Nuclear war is much more likely to happen in our lifetimes than a nasty metor or solar flare.

An interesting film on the History Channel this morning speculating about why the dinosaurs became extincet some 65 million years ago. Current scientific thinking is that it was causes by a number of different actions -- volcanic ash, metors, and changing weather conditions. All those conditions could happen again, but I suspect nuclear war will wipe us out first.

With Pakistan seemingly falling into the hands of extremist religious elements, it won't take too long and they will have their hands on the nuclear arsenal there. India will have to respond.

sneekula 969 Nearly a Posting Maven

I find designers rather cumbersome, they throw in more code than you want to have, and you have a much harder time fleshing out to working program.

You are better off collecting a set of working templates of the various widgets you are interested in, and copy and paste from there to create your program.

If you use the wxPython GUI toolkit then Boa-Constructor isn't too bad, since it also is a regular IDE that you can write and run your programs with. It does create Python code rather than XML code.

On my Ubuntu machine I installed SPE (written in wxPython) and it has wxGlade as a designer tool, seems to work okay. This way you can test out your code quickly.

sneekula 969 Nearly a Posting Maven

Tuple elements can be accessed by their index:

my_tup = ('fdasf','dfasf','asdf')
print my_tup[0]  # --> fdasf
print my_tup[2]  # --> asdf
sneekula 969 Nearly a Posting Maven

Write a program that lists all the fonts available on your computer, and apply the selected font to a sample text.

sneekula 969 Nearly a Posting Maven

Can be as simple as:

pw = "pass word"
pw = pw.replace(" ", "")

print(pw)  # -->  password
sneekula 969 Nearly a Posting Maven

If you want to import custom module xyq via the Pythonpath
create a file xyq.pth and stick it into a directory python
will look into, like
for Windows:
C:\Python25\Lib\site-packages
for Linux:
/usr/lib/python2.5/site-packages

The .pth file contains a line showing the directory
in which module xyq is located, for instance:
for Windows:
C:\Python25\Mymodules
for Linux in your case:
/home/doriad/Scripts/Python/

sneekula 969 Nearly a Posting Maven

The easiest way is to create a dictionary where the key is the (x,y) location tuple and the value is the (r,g,b) color tuple of the pixel:

#!/usr/bin/env python

# image data analysis using PIL, keep track of pixel value
# (r,g,b) and location (x,y) with a (x,y):(r,g,b) dictionary

from PIL import Image

# the french_flag test file is a 24X16 bitmap and
# has a simple blue-white-red, left to right pattern
img = Image.open("french_flag.bmp")
width, height = img.size

#print width, height

pixel_list = list(img.getdata())

# create a (x,y):(r,g,b) dictionary
# where (x,y) are the location coordinates an image point
# and (r,g,b) is the value of the pixel at that point
pixel_dict = {}
ix = 0
# rows
for y in range(height):
    # columns
    for x in range(width):
        pixel_dict[(x, y)] = pixel_list[ix]
        #print x, y, ix
        ix += 1

# testing ...
# show contents of the first row
y = 0
for x in range(width):
    print( "(%d, %d): %s"% (x, y, pixel_dict[(x, y)]) )

'''
print('-'*20)

# show contents of the dictionary sorted by (x, y) coordinates
for k, v in sorted(pixel_dict.items()):
    print k, v
'''

print('-'*20)

# get the pixel (r, g, b) value at point (x, y)
x = 1
y = 10
print(pixel_dict[(x, y)])
scru commented: that's easy but very wasteful. you end up with three copies of the exact same data in memory, and for images that can be a lot. +6
sneekula 969 Nearly a Posting Maven

Google uses C++ for speed of execution and Python for speed of development. They make a good pair.

sneekula 969 Nearly a Posting Maven

A spinach, artichoke, chicken Lean Pocket and a bottle of Pyramid Hefeweizen ale.

sneekula 969 Nearly a Posting Maven

Tkinter has the reputation to look kind of homely on Windows computers. Actually, on my Ubuntu/Linux computer it doesn't look bad at all. Here is a typical listbox example using the Tkinter GUI toolkit that comes with just about every Python installation. Yes, if you use the new Python3, it comes with Tkinter too. Just remember that Tkinter is now a package and you have to import tkinter rather than Tkinter:

#!/usr/bin/env python

# create a scrollable listbox using Tkinter
# load the listbox with tasty cheese data
# and select your favorite cheese with the mouse
# with Python3 use   import tkinter as tk

import Tkinter as tk

def get_list(event):
    """
    function to read the listbox selection
    and put the result in a label widget
    """
    # get selected line index
    index = listbox.curselection()[0]
    # get the line's text
    seltext = listbox.get(index)
    # put the selected text in the label
    label['text'] = seltext

root = tk.Tk()
root.title("Cheeses")
# use width x height + x_offset + y_offset (no spaces!)
root.geometry("180x300+30+50")

# create a label (width in characters)
s = "Click on a cheese"
label = tk.Label(root, text= s, width=15)
label.grid(row=0, column=0)

# create a listbox (height in characters/lines)
# give it a nice yellow background (bg) color
listbox = tk.Listbox(root, height=15, bg='yellow')
listbox.grid(row=1, column=0)

# the Tkinter listbox does not automatically scroll, you need
# to create a vertical scrollbar to the right of the listbox
yscroll = tk.Scrollbar(command=listbox.yview, orient=tk.VERTICAL)
yscroll.grid(row=1, column=1, sticky='n'+'s')
listbox.configure(yscrollcommand=yscroll.set)

cheese_list = [
'Feta', 'Limburger', …
sneekula 969 Nearly a Posting Maven

A simple addition to the if statement will help you to treat spaces different:

#!/usr/bin/python

# remove duplicates from text (leave spaces)

text = 'The quick brown fox jumps over the lazy dog'

# create an empty string
new_text = ""
# iterate over all characters of the text
for c in text:
    # check if c is a space or not in new_text
    if c.isspace() or c not in new_text:
        # concatinate c to new_text
        new_text += c

print(new_text)

"""
my result -->
The quick brown fx jmps v t lazy dg
"""

The first line is for my Ubuntu/Linux machine, it shows it where the Python interpreter is located. Windows will ignore this line.

sneekula 969 Nearly a Posting Maven

If you want to show friends some of your great Python programs, I recommend this approach:

Portable Python installs a portable version of Python right on a small and inexpensive USB flash drive (plan on at least 150MB). You can use the flash drive now on Windows computers that do not have Python installed. It comes in Python25, Python26 and Python30 flavors. It's free, see:
http://www.portablepython.com/releases/

Portable Python 1.1 based on Python 2.5.4
Django-1.0.2-final (for web site creation)
IPython-0.9.1
Matplotlib-0.98.5.2 (for plotting graphs)
Numpy-1.2.1 (high speed arrays for science)
PIL-1.1.6 (the Python Image Library)
Py2exe-0.6.9 (for distributing .exe files)
PyGame-1.8.1 (a game toolkit)
PyReadline-1.5
PyScripter v1.9.9.6 ( a nice IDE)
PyWin32-212
Rpyc-2.60
Scipy-0.7.0b1
SPE-0.8.4.c (another nice IDE)
VPython-3.2.11 (3D modeling)
wxPython-unicode-2.8.9.1 (GUI toolkit)

Portable Python 1.1 based on Python 2.6.1
Django-1.0.2-final
IPython-0.9.1
PIL-1.1.6
Py2exe-0.6.9
PyGame-1.8.1
PyReadline-1.5
PyScripter v1.9.9.6
PyWin32-212
Rpyc-2.60
SPE-0.8.4.c
wxPython-unicode-2.8.9.1

Portable Python 1.1 based on Python 3.0.1
PyScripter v1.9.9.6
Rpyc-2.60

Might even work on Linux machines if they have "Wine" installed.

sneekula 969 Nearly a Posting Maven

Python code can be written so it almost reads like pseudo code:

word = "Apple"

# create an empty string
new_word = ""
# iterate through word one  character at a time
for c in word:
    # check if c is already in new_word
    if c not in new_word:
        new_word += c

print(new_word)  # Aple
sneekula 969 Nearly a Posting Maven

You could do something like this:

prompt = "Enter your five character user ID; "
user_id = 'THE' + raw_input(prompt)
sneekula 969 Nearly a Posting Maven

Yeah, i get this a lot with wxPython. Something on the lines of
wx.App must be created first. And IDLE will not freeze, but it will not run the code again until you restart it.

Hmm, interesting, never had that happen. Can you show a small sample code where this happens? Also, what is your operatings system? Is it a particular version of wxPython? There were some buggy versions out about 2 years ago.

Also IDLE on Windows machines can have problems with certain firewall settings.

sneekula 969 Nearly a Posting Maven

Here is a comparison of some common Python GUI toolkits. These were created on my Ubuntu/Linux machine, because I could never get PyGTK to go on my Windows Vista machine. I followed the installation routine carefully, but there was always a dll missing, or an entry point wasn't found, or a version missmatch, so I gave up. GTK and PyGTK are more natural on Linux.

Let's take a look at typical PyGTK code:

#!/usr/bin/env python

# display an image using PyGTK + GTK

import pygtk
pygtk.require('2.0')
import gtk

class ShowImage(object):

    def __init__(self):
        # create the main window, and
        window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        # attach destroy signal to terminate the application
        window.connect("destroy", lambda w: gtk.main_quit())
        window.set_border_width(10)
        window.show()

        # a horizontal box to hold the buttons
        hbox = gtk.HBox()
        hbox.show()
        window.add(hbox)
        
        # pick an image file you have in the working directory, or give
        # the full path, can be a .jpg, .png, ,gif, .bmp image file
        # (filenames are case sensitive on Ubuntu/Linux)
        image_file = "LAKE2.gif"
        image = gtk.Image()
        image.set_from_file(image_file)
        image.show()
        # create a button to contain the image widget
        # auto adjusts to image size
        button = gtk.Button()
        button.add(image)
        button.show()
        hbox.pack_start(button)


ShowImage()
gtk.main()

The same test program using PyQT, PyQT installs easily on Windows and Linux machines:

#!/usr/bin/env python

# display an image using PyQT

import sys
from PyQt4 import QtGui

class MyImage(QtGui.QWidget):
    def __init__(self, parent, width, height):
        QtGui.QWidget.__init__(self, parent)

        # pick an image file you have in the working directory, or give
        # the full path, can …
Nick Evan commented: Good post +17
bumsfeld commented: keep going +11
sneekula 969 Nearly a Posting Maven

There might be something wrong with your boot order. Here is the spiel from the Ubuntu site:
1.
Restart your computer with the CD still inserted in the drive
2.
When the computer restarts, look very carefully at the initial screen it shows. Look for an option such as <F10> Boot Order or Press DEL to enter setup and press the key which is noted (e.g. the Delete key). There are many different variations, so please see your computer manual if you are unsure which button you need to press.
3.
Find the options relating to Boot Order, Boot Sequence or similar. Ensure that your CD drive is first in the boot order by following the instructions on-screen.
4.
Once satisfied that your CD is first in the boot order, save your changes and restart the computer. It should now start from the Ubuntu installation CD.

On my Vista machine it was the F10 key (press just at the right time during the boot up) that allowed me to set the boot order. I can also press the Escape key during the boot up and change to another medium like a flashcard.

sneekula 969 Nearly a Posting Maven

On problem #1 you are a little messed up. You need to send a list of elements to the your function that contains elements that the len() function can be applied to, like strings for instance. Then you return a list of these lengths.
BTW, do not use 'list' as a variable name.

Since you are talking about the length of strings, I assume that problem #2 asks you to return the list of strings in the order of length. So a list like
mylist =
would be:
mylist = [ 'of', 'list', 'strings']
or:
mylist =

sneekula 969 Nearly a Posting Maven

I have an HP DV9000 notebook with Vista, and created a Knoppix 6.1 live Linux Flashcard. I can boot it up and select Linux, but the 'wirless' switch will not activate, even so physically it is in the on position. It almost looks like there is a software( HP Wireless Assistant) override. There is a little LED on the 'wireless' switch that will go from red to blue, if the wireless works. Vista will turn it blue, but Linux is not sending the right code to the lousy switch.

Does anybody have experience with this goofy HP setup?

sneekula 969 Nearly a Posting Maven

If your last name is Hitler, that is bad enough!
There are people with the last name of Bush in this country that are suffering.

sneekula 969 Nearly a Posting Maven

The world will end in 2038 when the "real" millenium-bug hits.

The vast majority of embedded systems (which are designed to stay in place for decades) do not use a 64 bit integer to store time (In seconds since the UNIX epoch on 1/1/1970) and will overflow, leading to errors.

The problem is that most of these systems are mission-critical systems usually in an embedded role, meaning it will be hard to rectify this problem.

Most of that stuff will be hopelessly outdated by that time. Maybe a few museum pieces will croak.

cwarn23 commented: good one +0
sneekula 969 Nearly a Posting Maven

Hang around with stupid people, they are more likely to listen to you!

sneekula 969 Nearly a Posting Maven

Do get an understanding girlfriend you need to join a local church. She will teach you good manners and good English.

sneekula 969 Nearly a Posting Maven

Are they also hiring monkeys and paying peanuts?

That's the other company.

sneekula 969 Nearly a Posting Maven

goats are awesome. they can just clear right through thorny blackberry bushes in no time. dandelions are gone, too.

they're a really popular alternative even in the city. here in seattle, we have some neighbors who have goats and rent them out.

One of the few lawn
mowers that can give milk.

sneekula 969 Nearly a Posting Maven

Sooner or later some engineers will manage to create a smart robot. Smart enough to consider humans as a pest.

Sulley's Boo commented: your avatar is cute, and so are your thoughts =D +6
sneekula 969 Nearly a Posting Maven

It's time again to poll the well educated folks at DaniWeb about the possible cause of the end of humanity on earth.

sneekula 969 Nearly a Posting Maven

Mosquitoes have 47 teeth.

sneekula 969 Nearly a Posting Maven

Nice, but don't walk around their lawn in bare feet :) If you have ever stepped on a wet pasture pattie with bare feet then you know what I mean.

It soothes sore feet!

BTW, goats love beer!
http://www.roadsideamerica.com/story/2227

sneekula 969 Nearly a Posting Maven

Q: "How many folks does it take at GM to screw in a light bulb?
A: "Two, if the bulb is large enough."

sneekula 969 Nearly a Posting Maven

Two things:

1) Separate the code that goes into the loop from code that does not loop by using proper indentations

2) Unless this is an exercise in writelines(), it is better to build a temporary string with the names entered in the loop, and then write that temporary string to the file after your break out of the loop. Otherwise you have to worry about appending a file, and if the file exists to start with an empty file.

Here is your code corrected to work properly:

# Anna Huang
# Programming Assignment 16

# start with empty temp string
temp = ""
while True:
    name = raw_input("Enter your name (just Enter to exit): ")
    if name:
        # build up the temp string and end the name with a space
        temp += name + ' '  # same as: temp = temp + name + ' '
    else:
        break

#print temp

fw = open("pa16names.txt", "w")
# write the temp string to file
fw.write(temp)
fw.close()

fr = open ("pa16names.txt", "r")
print "The names you've entered into the text file are:", fr.read()
fr.close()

Please read the comments so you can learn something at least.

sneekula 969 Nearly a Posting Maven

The May 2009 issue of "Linux Pro" magazine has a "Knoppix 6.1" live DVD included. I set my Vista machine to boot with CD, and with the DVD in the CD/DVD drive, it will boot up with Knoppix Linux (similar to Ubuntu).

Too make life easier, I used a utility (on the DVD) to burn the Knoppix OS onto a 8G Flashcard which also allows about 4G to be used to establish a read/write sector. Now I can boot up without the DVD, and just have to press the Esc key during boot up to switch to the Flashcard and the Knoppix OS comes up.

I still like Ubuntu better, maybe the next Ubuntu release will show up as a live DVD on one of the Linux magazines. Just love to say goodbye to that lousy Vista OS!

sneekula 969 Nearly a Posting Maven

Another way would be to give your secret text string a marker ending, like '~~' and stop encoding or decoding when detected.

sneekula 969 Nearly a Posting Maven

Python is a modern language that has borrowed advanced programming concepts from a number of other languages like C++, Java, Lisp and Haskell. It would be very hard to express these in C.

sneekula 969 Nearly a Posting Maven

I played with it a little, but I am not sure about the complete algorithm. This is as far as I came:

# use linear and quadratic probing to find collision in an integer list
# incomplete:
# function quadratic_probe() needs to get all index values!!!!

import random

def linear_probe(n, r_list):
    """
    a linear probe checks every element in r_list
    """
    for ix in range(len(r_list)):
        if n == r_list[ix]:
            if test_print:
                print("ix = %s" % ix)
            return True
    return False

def quadratic_probe(n, r_list):
    """
    a quadratic probe checks the r_list every n^2 element
    if not found it shifts the probing
    needs work to reach all index values!!!!
    """
    # for test
    qix_list = []
    r_len = len(r_list)
    q_len = int(len(r_list)**0.5)
    shift = 0
    for shift in range(0, r_len):
        for ix in range(shift, q_len):
            qix = ix**2 + shift
            qix_list.append(qix)
            if test_print:
                print("ix=%s  shift=%s  qix=%s" % (ix, shift, qix))
            if r_list[qix] == n:
                if test_print:
                    print(sorted(qix_list))
                return True
    if test_print:
        print(sorted(qix_list))
    return False
    
# for debugging set to True
test_print = True

# create a list of count random integers in the range low to high-1
low = 100  #1000
high = 120  #12000
count = 17  #9000
r_list = random.sample(range(low, high), count)

# test the first 10 elements
print(r_list[:10])
#print(len(r_list))

# now create a another randomm integer in the range low to high-1
n = random.randrange(low, high)
# testing ...
print("n = %s" % n)

# and probe the list for collision (does the value exist?)

if linear_probe(n, r_list): …
sneekula 969 Nearly a Posting Maven

The red value of the first pixel. Then when you decode you read this length value first and use it in your loop for the next length characters.