Ene Uran 638 Posting Virtuoso

Just a WAG, but it looks like you changed your OS permission/access level.

Ene Uran 638 Posting Virtuoso

Oh yes, Python has an array type, but you must import module array:

# module array has Python's array type

import array

# Python25 use 'c' as the character typecode
# Python30 uses unicode character typecode 'u'
char_array = array.array('c', 'hello world')

print(char_array[0])    # h
print(char_array)       # array('c', 'hello world')

# 'i' uses a signed integer of 2 bytes
int_array = array.array('i', [2, 4, -11])

print(int_array[2])     # -11
print(int_array)        # array('i', [2, 4, -11])

# 'f' uses 4 bytes and 'd' uses 8 bytes per element 
float_array = array.array('d', [1.0, 2.0, 3.14])

print(float_array[2])  # 3.14

for n in float_array:
    print(n)


# get more information on module array
help('array')

Arrays are sequence types and behave very much like lists, except that the type of objects stored in them is constrained. The type is specified at object creation time. Arrays use up less space in memory, for a limited number of applications this is important.

scru commented: You knowledge of Python is astounding +5
Ene Uran 638 Posting Virtuoso

In case you are looking for a project that you can apply your newly learned OOP concepts to, here is one suggestion:

Take a group of people and keep track of their personal information like first name, last name, gender, age, and let's say bowling score. You want to know who is the youngest bowler, who has the highest score, and is there an age-score relation.

Ene Uran 638 Posting Virtuoso

Welcome to this forum.

Since just about everything in Python is an object, you are doing OOP already. Look at it this way, a class is just one more convenient tool to group things together. If the class concept bothers you, you can do major programming without it.

After all, there are older computer languages like C that have no OOP, yet huge programs like entire operating systems (unix), and the core of Python have been written with it.

Ene Uran 638 Posting Virtuoso

Just an observation, I would avoid using variable names like l1, l2 and so on, they look a lot like numbers 11, 12.

Here is an example how to use Python function map():

q = [1, 2, 3, 4, 5]

# map applies float() to every element in the list q
qf = map(float, q)

print(qf)  # [1.0, 2.0, 3.0, 4.0, 5.0]
Ene Uran 638 Posting Virtuoso

Take a look at:
help(numpy.set_printoptions)

Ene Uran 638 Posting Virtuoso

Thanks jice! It was late in the day and I was thinking CSV rather than lists.

Ene Uran 638 Posting Virtuoso

As a general rule it is best to write these things the long way:
if x == 4 and y == 4:
or:
if x == False and y == False:
In case you don't remember the precendence rules, you can even use:
if (x == False) and (y == False):

Ene Uran 638 Posting Virtuoso

The str() function returns a normal string. Test it out:

s = u"a unicode string"

d = {}
d['a'] = s

print(d)  # {'a': u'a unicode string'}

d['b'] = str(s)  # str() converts s to a normal string

print(d)  # {'a': u'a unicode string', 'b': 'a unicode string'}
Ene Uran 638 Posting Virtuoso

Please do not mix tabs and spaces for indentations in your code. Makes a mess of your code when I copy it into my editor! Many editors have different spaces per tab settings. Use spaces only, preferably 4 spaces like most programmers use!

Your problem is here:

for j in array:
            distance=mag(array[disk].pos-array[j].pos)

The array is a list of sphere objects, so each j is a sphere object. In array[j] you are trying to use j as a numeric index into the array. Maybe you could use j directly as j.pos

Ene Uran 638 Posting Virtuoso

"If you feel a reluctant sneeze coming on, look at a bright light and it'll come" - one of the most ridiculous things I've ever heard, but is there any truth to it??

Vision is one of the most brain intensive task, and I can see how this would mask your will not to sneeze.

Close your eyes, if you want to think!

Ene Uran 638 Posting Virtuoso

"A person should not be too stupid. Stupid people are screwed first. "

Ezzaral commented: Excellent! :) +17
Ene Uran 638 Posting Virtuoso

According to former Fed Chairman Alan Greenspan, the US housing bubble accounted for up to 70% of GDP growth in recent years. This bubble of high risk junk mortgages drove up housing prices and was nothing but virtual/fake value.

Ene Uran 638 Posting Virtuoso

Obama openly talks and listens to the folks that actually suffer. Bush would have held his show in front of military folks at a some base. There is hope!

Ene Uran 638 Posting Virtuoso

Is that babble supposed to make any sense at all?

If you remember, there was a claim by McCain's election staff that he invented the Blackberry thing. That would make him a pretty old geek.

Ene Uran 638 Posting Virtuoso

Build yourself a small library of uniform wxPython templates and give them filenames you can find. You will be surprised how much help they provide in cutting and pasting a wxPython program together. There are hints of these templates in the "Starting wxPython" thread. For instance:
http://www.daniweb.com/forums/post626902-16.html

Ene Uran 638 Posting Virtuoso

First of all, do yourself and the rest of us a big favor and do not use tabs for indentations. As you can see, your code shows up badly in the Daniweb code area. Most of us use 4 spaces for indentation.

Here is an example of wxPython's GridSizer to display BitmapButtons in a nice grid. The bitmap images in this case are provided by wxPython's ArtProvider:

# exploring wxPython's GridSizer, ArtProvider and BitmapButton

import wx

class MyFrame(wx.Frame):
    def __init__(self, parent, mytitle, art_list):
        wx.Frame.__init__(self, parent, wx.ID_ANY, mytitle,
            size=(360, 255))
        self.SetBackgroundColour('green')
        
        self.art_list = art_list
        
        # main sizer forms a border
        vsizer = wx.BoxSizer(wx.VERTICAL)
        
        # wx.GridSizer(rows, cols, vgap, hgap)
        # art_list has 48 items so make it 6x8
        gsizer = wx.GridSizer(6, 8, 5, 5)

        self.btn = range(len(self.art_list))
        # fill the drid sizer using a loop
        for ix, art in enumerate(self.art_list):
            # set up a consecutive unique id for each button
            id = 1000 + ix
            bmp = wx.ArtProvider.GetBitmap(art, wx.ART_OTHER, (16, 16))
            self.btn[ix] = wx.BitmapButton(self, id, bitmap=bmp)
            # the gridsizer fills left to right one row at a time
            gsizer.Add(self.btn[ix], 0, wx.ALL|wx.EXPAND, border=2)
            self.btn[ix].Bind(wx.EVT_BUTTON, self.btnClick)

        # add to the main sizer and set
        vsizer.Add(gsizer, 0, wx.EXPAND|wx.ALL, border=10)
        self.SetSizer(vsizer)

    def btnClick(self, event):
        """do something"""
        # get the art_id of the button clicked from the art_list
        art_id = self.art_list[event.GetId() - 1000]
        # show the art_id in the frame title bar
        self.SetTitle(str(art_id))


# constants of art items in ArtProvider 
art_list = [
wx.ART_ADD_BOOKMARK, 
wx.ART_DEL_BOOKMARK, 
wx.ART_HELP_SIDE_PANEL,
wx.ART_HELP_SETTINGS, 
wx.ART_HELP_BOOK, 
wx.ART_HELP_FOLDER,
wx.ART_HELP_PAGE, 
wx.ART_GO_BACK, 
wx.ART_GO_FORWARD,
wx.ART_GO_UP,
wx.ART_GO_DOWN,
wx.ART_GO_TO_PARENT, …
Ene Uran 638 Posting Virtuoso

There is also pixel graphics and vector graphics. In the more common pixel graphics an image is made up of pixels with a given location and colour. In vector graphics the image is calculated using a series of mathematical operations. The advantage of vector graphics is that is smoothly scalable. Mind you that this is all mildly simplified.

One major application of vector graphics is in the movie animation industry. Also many electronic games us it. You can build for instance a landscape from a bunch of calculated coloured triangles.

Ene Uran 638 Posting Virtuoso

I want one!

Be careful! Most hamburgers are loaded with one of the worst fats you can eat, a recipe for an early departure.

Ene Uran 638 Posting Virtuoso

Love is a four letter word.

Ene Uran 638 Posting Virtuoso

My boyfriend cooked last evening! I wish I could have given the food to the hungry bear.

Ene Uran 638 Posting Virtuoso

Put your hand on a hot stove for a minute, and it seems like an hour. Sit with a pretty girl for an hour, and it seems like a minute. THAT'S relativity.

True only if you sit!

Ene Uran 638 Posting Virtuoso

I think it's McCain the Older!

Ene Uran 638 Posting Virtuoso

As long as there is no comma in your individual data elements, you can use function join() and replace() in this manner:

q = ['23', 'CL', '006', '2004', 'DBA8ORPU', '41', '8Y', '0', 'S0111P', '2']

s = ",".join(q).replace(",", " ")

print(s)

"""
my result -->
23 CL 006 2004 DBA8ORPU 41 8Y 0 S0111P 2
"""
Ene Uran 638 Posting Virtuoso

As girls get smarter, they are almost impossible to put up with.

Ene Uran 638 Posting Virtuoso

My advice, start out simple and make it work, then go more complex.

Ene Uran 638 Posting Virtuoso

raw_input gives gives a string, so for numbers you can do calculations with, you will have change the numeric string to a float:
total_sales = float(raw_input('Please enter your total sales: '))

Ene Uran 638 Posting Virtuoso

The 'u' implies the use of unicode (a more international character set).

Ene Uran 638 Posting Virtuoso

Two loops will do, or you can use a list comprehension:

rank = ("A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K")
suit = ("c", "h", "s", "d")

card = []
for r in rank:
    for s in suit:
        card.append(r+s)

card = tuple(card)
print(card)

"""
my result made pretty -->
('Ac', 'Ah', 'As', 'Ad', '2c', '2h', '2s', '2d', '3c', '3h', '3s', 
'3d', '4c', '4h', '4s', '4d', '5c', '5h', '5s', '5d', '6c', '6h', 
'6s', '6d', '7c', '7h', '7s', '7d', '8c', '8h', '8s', '8d', '9c', 
'9h', '9s', '9d', '10c', '10h', '10s', '10d', 'Jc', 'Jh', 'Js', 
'Jd', 'Qc', 'Qh', 'Qs', 'Qd', 'Kc', 'Kh', 'Ks', 'Kd')
"""
Ene Uran 638 Posting Virtuoso

Something like this should be faster, since it avoids the use of function calls:

text = """\
A list of Pythonyms ...

pythonanism: spending way too much time programming Python
pythoncology: the science of debugging Python programs
pythondemic: something bad that lots of Pyton programmers do
pythonerous: something hard to do in Python
pythong: a short piece of Python code that works
pythonorean: someone who knows the esoteric technical aspects of Python
pythonus: something you don't want to do in Python
pythonym: one of these words
ptyhoon: someone who is really bad at Python
sython: to use someone else's Python code
pythug: someone who uses python to crash computers
Pythingy: a function or tool that works, but that you don't understand
Pythonian: somebody that insists on using a very early version of python
PythUH? -  block of code that yields a very unexpected output
Pythealot:  a Python fanatic
"""

spaces = 0
for c in text:
    # add to the count of spaces
    if c == " ":
        spaces += 1

print( "This text has %d spaces" % spaces )
Ene Uran 638 Posting Virtuoso

Sorry, my bad, onCreateDb() is okay, didn't read it right.

Ene Uran 638 Posting Virtuoso

The way you have written it, onCreateTable() doesn't seem to return anything. Maybe you should write a simpler test program first.

Ene Uran 638 Posting Virtuoso

Man "I’d like to call you. What’s your number?"
Woman "It’s in the phone book."
Man "But I don’t know your name."
Woman "That’s in the phone book too."

William Hemsworth commented: hah xD +6
Ene Uran 638 Posting Virtuoso

A dying man gathered three of his best friends, a Lawyer, a Doctor and a Clergyman at his bed side and handed each of them an brown envelope containing $50,000 in cash. He asked them to put these envelopes into his coffin before it gets closed and buried, so he could have some money in his after-life.

After the funeral the Clergyman is in tears and confesses to the others that he took $20,000 out of the envelope for a good church cause. The Doctor admits that he donated $30,000 of the envelope's content for medical research. The Lawyer is upset with his two old friends, "Why, I put a personal check of the full amount in the envelope!"

Ene Uran 638 Posting Virtuoso

Once hyperinflation sets in, I would rather show up at the store with a sack of dollar bills than dollar coins.

Ene Uran 638 Posting Virtuoso

" The more you sweat in peace, the less you bleed in war."

Nice thought!

Religion is what keeps the poor from murdering the rich.
(Napoleon)

Ene Uran 638 Posting Virtuoso

A medium-rare eye of round beef steak, two eggs sunny side up, hash-browns, and my usual dark roast Maracaibo coffee.

Ene Uran 638 Posting Virtuoso

With all these additional 'forced users' maybe Microsoft stock will go up for a change? I am stuck with Vista at work and at home, and I hate it!

Ene Uran 638 Posting Virtuoso

Here is a typical example:

# use module pickle to save/dump and load a dictionary object
# or just about any other intact object

import pickle

# create the test dictionary
before_d = {}
before_d[1]="Name 1"
before_d[2]="Name 2"
before_d[3]="Name 3"

# pickle dump the dictionary
fout = open("dict1.dat", "w")
pickle.dump(before_d, fout)
fout.close()

# pickle load the dictionary
fin = open("dict1.dat", "r")
after_d = pickle.load(fin)
fin.close()

print before_d  # {1: 'Name 1', 2: 'Name 2', 3: 'Name 3'}
print after_d   # {1: 'Name 1', 2: 'Name 2', 3: 'Name 3'}

You could create a player dictionary like
player_name : [stats, inventory, position]
for instance
'thor' : [[80, 50], ['gun', 'gold'], [20, 120]]

Ene Uran 638 Posting Virtuoso

A typical application of what you want to achieve is this book page indexing program:

# create a page index using a word:pagenumber dictionary

def do_index(keyword, pagenumber, page_index):
    """
    if keyword exists add pagenumber to that particular list
    otherwise make new entry to index dictionary
    """
    page_index.setdefault(keyword, []).append(pagenumber)
    return page_index


page_index = {}
page_index = do_index('jump', 27, page_index)
page_index = do_index('girl', 45, page_index)
page_index = do_index('boy',99, page_index)
# appends 58 to pagenumber list at word 'jump'
page_index = do_index('jump', 58, page_index)   

print(page_index)

print('-'*50)

# print pagenumber(s) for one keyword
print(page_index['jump'])

print('-'*50)

# remove a pagenumber
page_index['jump'].remove(27)
print(page_index['jump'])

"""
my result -->
{'jump': [27, 58], 'boy': [99], 'girl': [45]}
--------------------------------------------------
[27, 58]
--------------------------------------------------
[58]
"""
Ene Uran 638 Posting Virtuoso

There is the Pyglet multimedia module from:
http://www.pyglet.org/index.html
You can download the Windows installer:
http://pyglet.googlecode.com/files/pyglet-1.1.2.msi
and the documentation:
http://pyglet.googlecode.com/files/pyglet-1.1.2-docs.zip


AVbin is a thin wrapper around FFmpeg a collection of audio and video codecs widely used in projects such as mplayer, xine, gstreamer and VLC.
It is needed to play .ogg and .mp3 sound files download:
avbin-win32-5.zip from http://code.google.com/p/avbin/
and install avbin.dll into Windows/System32 directory

AVbin and pyglet are also available for Unix/Linux systems.

Here is a typical pyglet example:

# load and show an animated gif file using module pyglet
# download module pyglet from: http://www.pyglet.org/download.html
# pyglet is available for Windows and Unix/Linux systems
# the animated dinosaur-07.gif file is in the public domain
# download from: http://www.gifanimations.com
# notice that the event loop uses a function decorator

import pyglet

# pick an animated gif file you have in the working directory
ag_file = "dinosaur-07.gif"
animation = pyglet.resource.animation(ag_file)
sprite = pyglet.sprite.Sprite(animation)

win = pyglet.window.Window(width=sprite.width, height=sprite.height)

# set window background color = (r, g, b, alpha)
# each value goes from 0.0 to 1.0
green = (0, 1, 0, 1)
pyglet.gl.glClearColor(*green)

@win.event
def on_draw():
    win.clear()
    sprite.draw()

pyglet.app.run()
Ene Uran 638 Posting Virtuoso

You could put the two windows in question onto a borderless (invisible) window.

Ene Uran 638 Posting Virtuoso

You can use simple string functions:

html = """\
<html>
<head>
   <title>Ordered List Example</title>
</head>
<body bgcolor="#FFFF00" text="#FF0000">
<OL STYLE = "font-family: comic sans ms; font-size:10pt">
   <LI>Religious tolerance</LI>
   <LI>Exact estimate</LI>
   <LI>Military Intelligence</LI>
   <LI>Passive aggression</LI>
   <LI>Tight slacks</LI>
   <LI>Business ethics</LI>
   <LI>Advanced BASIC</LI>
   <LI>Extinct Life</LI>
   <LI>Pretty ugly</LI>
   <LI>Genuine imitation</LI>
</OL>
</body>
</html>
"""

# erase just "<title>" 
print(html.replace("<title>", ""))

print('-'*50)

# erase "<title>" and "</title>"
print(html.replace("<title>", "").replace("</title>", ""))
Ene Uran 638 Posting Virtuoso

That task would be very specific to the Operating System you have. So, what OS do you have?

Ene Uran 638 Posting Virtuoso

To access Oracle databases you need to get module cx_Oracle. You need to download ad install the correct module for your version of Python and your version of Oracle.
see:
for info
http://www.orafaq.com/wiki/Python
and downloads
http://cx-oracle.sourceforge.net/

Ene Uran 638 Posting Virtuoso

Use SetBitmapSelected() only if you want the different image to show as long as the button is pressed. For what you have in mind, you may want to use SetBitmapLabel():

# playing with wxPython's
# wx.BitmapButton(parent, id, bitmap, pos, size, style)
# show a different image for selected (depressed) button
# change the button image on button click 

import wx

class MyFrame(wx.Frame):
    def __init__(self, parent, mytitle, mysize):
        wx.Frame.__init__(self, parent, wx.ID_ANY, mytitle, size=mysize)

        # create a BitmapButton as an input widget
        # pick a button image file you have (.bmp .jpg .gif or .png)
        image_file1 = r".\cards\Deck1.gif"
        self.image1 = wx.Bitmap(image_file1)
        image_file2 = r".\cards\DK.gif"
        self.image2 = wx.Bitmap(image_file2)
        
        self.button = wx.BitmapButton(self, wx.ID_ANY, bitmap=self.image1,
            pos=(10, 20),
            size=(self.image1.GetWidth()+15, self.image1.GetHeight()+15))
        # bind mouse click event to an action
        self.button.Bind(wx.EVT_BUTTON, self.on_click)
        # create an output widget
        self.label = wx.StaticText(self, wx.ID_ANY, "", pos=(10, 100))

    def on_click(self, event):
        """response to button press/click"""
        # changes the images on button click for 2.5 seconds
        self.button.SetBitmapLabel(self.image2)
        self.Update()
        wx.Sleep(2.5)
        self.button.SetBitmapLabel(self.image1)


app = wx.App()
# create a MyFrame instance and show the frame
MyFrame(None, 'testing the wx.BitmapButton()', (400, 300)).Show()
app.MainLoop()
Ene Uran 638 Posting Virtuoso

That may very well be true. I use a book and the documentation as my PyQt reference. I haven't really found a viable community to get help from.

As you pointed out, the licensing issue has turned of lot of usually "open Source" people off. I think PyQT has a lot of things going for it.

Ene Uran 638 Posting Virtuoso

I have used PyQT, it is okay, but the user base is tiny and there is precious little help and too few good examples out on the net. You post a question on PyQt and rarely ever get an answer.

Ene Uran 638 Posting Virtuoso

It directs wxPython where to show errors/consoleIO.
This will go to the console:
app = wx.App(redirect = False)
is the same as
app = wx.App(False)
or
app = wx.App(0)

This will go to a special window:
app = wx.App(True)
or since this is the default
app = wx.App()

When I develop a wxPython program with an IDE editor that has its own output windwow to show test prints and error messages, I use
app = wx.App(0)
Once everything works correctly, I simply remove the zero.

Ene Uran 638 Posting Virtuoso

Very nice! She is a lot more funny than most of the stuff on Comedy Central!