richieking 44 Master Poster

with better check with unique number. I think its not a good idea using enumerate function. Since enumearte repeates the number once new directory of files/ data in called.
I use anydbm alot and i think the best way is to use a counter with a dict. Then you check with the last dict call incrementing by 1 and use that for next key.

import anydbm


ddf = anydbm.open("ns.cdx",'r')

unique =  len(ddf.keys())


db =    anydbm.open("ns.cdx",'c')
for x in range(300):
    for y in reversed(range(1,4)):
       db[str(unique)]    =   str(y)
       unique = int(unique)
       unique  +=   1

print("Key  | Values \n ")
print "="*50
for x in ddf.keys():
    print x ,":", ddf[x]
db.close()
ddf.close()

from my htc phone. hope you get my idea ;)

richieking 44 Master Poster

More user friendly :)

def prompt(acts):
    while True:
        print """
              Please select one of the choices\n
              ==================================\n\n
              north\t south\n
              east\t west\n"""
            
        m = input("choice please: ")
        message = m.lower()[0]
        if message == "n":
            acts['north']
            break

        elif message == "e":
            acts['east']
            break

        elif message == "s":
            acts['south']
            break
        
        elif message == "w":
            acts['west']
            break
        else:
            print('Illegal option "%s"'%m)
richieking 44 Master Poster

pickle works like any other DB if you know how to use it very well.

You can save the file into a pckle and provide its it by incrementing the entries.

If you are new with python or having problem with pickle, I recommend anydb module for you which comes as a standard instalation with python.The module works like a dict.

from my HTC phone. :)

richieking 44 Master Poster

When lis pop. it removes the item from the stack.

Take it like you got items ...

llist = [1,2,3,4,5,6,7,]
llist.pop(3)
##
removes  : 4th item

The pop means give out. So when you give out, you dont still have that.
Like you cant eat your cake and have it stuff. :)
Hope you get the idea.....

richieking 44 Master Poster

Just save the path to the movie file into the database. Then you call the movie name from the data base by splitting the path. eg...

filename= pathtofile.split("/")[-1].split(".")[0]

Then you get the filename
:)

richieking 44 Master Poster

At least you show some appreciation by upvoting or something before asking for some more my friend.
:)

richieking 44 Master Poster

Gris you forgot about provideing the first word.

line[0]

Nice job mate :)

richieking 44 Master Poster

You should be fine with this
This will print to a fie if you got no printer in place
:)

import wx
import os.path


class MainWindow(wx.Frame):
    def __init__(self, filename='noname.txt'):
        super(MainWindow, self).__init__(None, size=(400,200))
        self.filename = filename
        self.dirname = '.'
        self.CreateInteriorWindowComponents()
        self.CreateExteriorWindowComponents()
        self.log= open("foo.log",'w+')
        
    def CreateInteriorWindowComponents(self):
        ''' Create "interior" window components. In this case it is just a
            simple multiline text control. '''
        self.control = wx.TextCtrl(self, style=wx.TE_MULTILINE)

    def CreateExteriorWindowComponents(self):
        ''' Create "exterior" window components, such as menu and status
            bar. '''
        self.CreateMenu()
        self.CreateStatusBar()
        self.SetTitle()

    def CreateMenu(self):
        fileMenu = wx.Menu()
        for id, label, helpText, handler in \
            [(wx.ID_ABOUT, '&About', 'Information about this program',
                self.OnAbout),
             (wx.ID_OPEN, '&Open', 'Open a new file', self.OnOpen),
             (wx.ID_SAVE, '&Save', 'Save the current file', self.OnSave),
             (wx.ID_SAVEAS, 'Save &As', 'Save the file under a different name',
                self.OnSaveAs),
                
                (wx.ID_PRINT, '&Print', 'Print the current document',
                self.OnPrint),
             (None, None, None, None),
             (wx.ID_EXIT, 'E&xit', 'Terminate the program', self.OnExit)]:
            if id == None:
                fileMenu.AppendSeparator()
            else:
                item = fileMenu.Append(id, label, helpText)
                self.Bind(wx.EVT_MENU, handler, item)

        menuBar = wx.MenuBar()
        menuBar.Append(fileMenu, '&File') # Add the fileMenu to the MenuBar
        self.SetMenuBar(menuBar)  # Add the menuBar to the Frame

    def SetTitle(self):
        # MainWindow.SetTitle overrides wx.Frame.SetTitle, so we have to
        # call it using super:
        super(MainWindow, self).SetTitle('Editor %s'%self.filename)


    # Helper methods:

    def defaultFileDialogOptions(self):
        ''' Return a dictionary with file dialog options that can be
            used in both the save file dialog as well as in the open
            file dialog. '''
        return dict(message='Choose a file', defaultDir=self.dirname,
                    wildcard='*.*')

    def askUserForFilename(self, **dialogOptions):
        dialog = wx.FileDialog(self, **dialogOptions)
        if dialog.ShowModal() == wx.ID_OK:
            userProvidedFilename = True …
richieking 44 Master Poster

Here you are as you wanted buddy
:)

import wx
import os.path


class MainWindow(wx.Frame):
    def __init__(self, filename='noname.txt'):
        super(MainWindow, self).__init__(None, size=(400,200))
        self.filename = filename
        self.dirname = '.'
        self.CreateInteriorWindowComponents()
        self.CreateExteriorWindowComponents()
        self.prin=4004
        
    def CreateInteriorWindowComponents(self):
        ''' Create "interior" window components. In this case it is just a
            simple multiline text control. '''
        self.control = wx.TextCtrl(self, style=wx.TE_MULTILINE)

    def CreateExteriorWindowComponents(self):
        ''' Create "exterior" window components, such as menu and status
            bar. '''
        self.CreateMenu()
        self.CreateStatusBar()
        self.SetTitle()

    def CreateMenu(self):
        fileMenu = wx.Menu()
        for id, label, helpText, handler in \
            [(wx.ID_ABOUT, '&About', 'Information about this program',
                self.OnAbout),
             (wx.ID_OPEN, '&Open', 'Open a new file', self.OnOpen),
             (wx.ID_SAVE, '&Save', 'Save the current file', self.OnSave),
             (wx.ID_SAVEAS, 'Save &As', 'Save the file under a different name',
                self.OnSaveAs),
                
                (wx.ID_PRINT, '&Print', 'Print the current document',
                self.OnPrint),
             (None, None, None, None),
             (wx.ID_EXIT, 'E&xit', 'Terminate the program', self.OnExit)]:
            if id == None:
                fileMenu.AppendSeparator()
            else:
                item = fileMenu.Append(id, label, helpText)
                self.Bind(wx.EVT_MENU, handler, item)

        menuBar = wx.MenuBar()
        menuBar.Append(fileMenu, '&File') # Add the fileMenu to the MenuBar
        self.SetMenuBar(menuBar)  # Add the menuBar to the Frame

    def SetTitle(self):
        # MainWindow.SetTitle overrides wx.Frame.SetTitle, so we have to
        # call it using super:
        super(MainWindow, self).SetTitle('Editor %s'%self.filename)


    # Helper methods:

    def defaultFileDialogOptions(self):
        ''' Return a dictionary with file dialog options that can be
            used in both the save file dialog as well as in the open
            file dialog. '''
        return dict(message='Choose a file', defaultDir=self.dirname,
                    wildcard='*.*')

    def askUserForFilename(self, **dialogOptions):
        dialog = wx.FileDialog(self, **dialogOptions)
        if dialog.ShowModal() == wx.ID_OK:
            userProvidedFilename = True
            self.filename = dialog.GetFilename()
            self.dirname = dialog.GetDirectory()
            self.SetTitle() # Update the window title with the …
richieking 44 Master Poster

mmmmmmmmmmmmm not bad. I jus dont see any real life need for this algo. besides There should be a better way than this.
:)

richieking 44 Master Poster

if i were you, i will just convert and use cpicle or anydb

richieking 44 Master Poster

Here is your full working code.

I just changed few thing.

def distanceConverter(dfrom, funit, dto, tunit):
    print dfrom
    print dto
    print funit
    print tunit


def distance():
    msg="1) Millimeters \n"
    msg+="2) Centimeters \n"
    print msg
#prints list of from options
    choice=raw_input("Select unit to convert from:")

    if choice in ('1','millimeters','Millimeters'):
        dfrom=1
        funit="millimeters"
    elif choice in ('2','centimeters','Centimeters'):
        dfrom=2
        funit="centimeters"
    else:
        print "Invalid entry. Please select 1 or 2"

    print msg
    choice=raw_input("Select unit to convert to:")

    if choice in ('1','millimeters','Millimeters'):
        dto=1
        tunit="millimeters"
    elif choice in('2','centimeters','Centimeters'):
        dto=2
        tunit="centimeters"
    else:
        print "Invalid entry. Please select 1 or 2"


    distanceConverter(dfrom,funit,dto,tunit)

def mass():
    print "mass function tester"
def velocity():
    print "velocity function tester"


def main():
    msg="Welcome to Rob's Unit Converter Build 1.0."
    print msg
#prints the opening message and list of unit options
    msg="1) Distance \n"
    msg+="2) Mass/Weight \n"
    msg+="3) Velocity"
    print msg
    choice=4
    while choice>3:
        choice=input("Please select the unit type:")
        if choice==1:
            distance()
        elif choice==2:
            mass()
        elif choice==3:
            velocity()
        else:
            print "Invalid selection, please enter 1, 2, or 3."
if __name__=='__main__':
    main()

Happy codding :)

richieking 44 Master Poster

backslash is native to windows as forwardslash to linux/unix/bsd file path. if you want to write an app. for network , then your good choice shout be forwardslash.

richieking 44 Master Poster

You are welcome goodfriend :)
you can upvote me a lil and close the thread
Thanks

richieking 44 Master Poster

just start your wxpy app. and when you see your window. just hit ALT tab are the menu underline will be visible.

richieking 44 Master Poster

rscubelek

strip() can save a lot when taking user inputs.
Try and split() your user inputs and you have saved yourself 80% of worries. check this out.

foo=" hello" #1
foo="hello"  #2

The 2 foos variables are not the sane from user inputs with the check of equality sign ==.

They are only the same after strip() is called.
:)

richieking 44 Master Poster

There are 3 things going on with your script.
1. a is global variable assigned the value of 10.
2. You function is a function that has a default value set. that is global a which got the value of 10.
due to that

foo()

will print the default value which is

def foo(x=10)

because a=10. So when you call

foo()

it will return the default value.

Try and call foo(a) on line 6. This will print the current value of a which is 5.

3.Variable scope and function definations are very simple once you master them.
As you can see.

foo()

took no value. As long as you dont give a value to

foo()

.... It will keep printing the value of first a which is 10.

Try and change the value of first a and call

foo()

without a value to see.

Hope you get the idea. happy codding :)

richieking 44 Master Poster

But you can toggle the menu-underline by pressing ALT tab.

richieking 44 Master Poster

Sorry mate but this is windows thing not wxpython.

Check this out....

Right click the Desktop/Properties/Appearance/Effects/Hide underlined
letters

And you can toggle the menu-underline by pressing ALT tab.

richieking 44 Master Poster

on line 53.... you have wx.EXPAND flat set but you have not given the permission to expand. Change to this,,,,,,,,,

sizer.Add(myEditor, 1, wx.EXPAND)

1 is the proportion/permission. so change the 0 to 1 anywhere you want to expand.
If you got more than one expand... Then you increase the proportion of the bigger control you want to .

;)

ShadyTyrant commented: Found solution +2
richieking 44 Master Poster

Here you go my friend :)

file1="".join('99 root S 5176 95 41.2 8.3 snmpd'.split()[5:6])
file2= "".join('99 root S 5176 95 1.0 8.3 snmpd'.split()[5:6])

print(float(file1)- float(file2))
## output
40.2

Hope it helps.

richieking 44 Master Poster

yep...

because pyserial has included it.
example.,,,,

import serial
ser = serial.Serial (0 , baudrate = 57600 , timeout = 1) #open serial port (1) - 1
line = ser.readline() ## will get the implementation of FileList method readline() if you dont have a local readline() method define

ser.close()
richieking 44 Master Poster

Very simple.

You can inherit one class into another if you need its functionality.
That is why we got import in python, #include<> in C,C++ , ...etc.

Anytime you import.... You build your class with that module's class methods but they are not native to your class. That is without the native imported class.... things will break down.

Hope you got it. :)

richieking 44 Master Poster

yep snippsat.
good job ;)

richieking 44 Master Poster
>>> d="hello"
>>> d[0]
'h'
>>>

from idle.

richieking 44 Master Poster

Yea sorry mate. Realize is for toolbar. Is my mistake. This happends when dealing with so manythings at one time. I will run your code on windows box now.

richieking 44 Master Poster

On my Ubuntu linux Box There is nothing wrong with your code. the underline is seen.

add this line after line 24

self.SetManubar(menuBar)
menuBar.Realize()

after that.

This help on windows ok.
;)

richieking 44 Master Poster

As Grib said. Its always a good idea to overide and declare just after the

def __ini__()

Not only for threading but all. It will save you from pain.
Also i will like an open server binding. line 31.
with that, the server can be used any where.

Secondly, client side.
number 17-19 i personaly dont like that. Put the logic in a while loop.
Bring them under line 21.

richieking 44 Master Poster

I think besides the problem of newbie readabilty....

There is nothing major wrong with this solution.
Anyway thanks guys.
:)

richieking 44 Master Poster

Grib

You eat and drink python..!
What a man! ;)

Tcll commented: I love Grib, he's amazing! =3 +4
richieking 44 Master Poster

well then close the thread my friend
;)

richieking 44 Master Poster
wx.TextCtrl(panel,-1,style=wx.TE_MULTILINE|wx.TE_RICH2)

wxpython will save textctrl as text format. It will keep basic formating like indentaions,spaces, etc.

But to save to doc,docx or other format. You will have to convert to that format.
;)

richieking 44 Master Poster

Well how about this then?
;)

alis="""
'site-website-20110105-101303.jpa', 'site-website-20110106-163312.jpa', 
'site-website-20110108-094822.jpa', 'site-website-20110108-095834.jpa',
 'site-website-20110109-203148.jpa', 'site-website-20110110-040326.jpa', 
 'site-www.website-20110109-040402.jpa', 'site-www.website-20110111-040219.jpa' """.split(",")

alis.sort()
info=([(x.split("-")[2:3],([z.split(".")[0] for z in x.split("-")[3:4]])) for x in alis])
richieking 44 Master Poster

mmmmmm not bad

richieking 44 Master Poster

Well i think your code here is not complete to trace all the errors.
But The global name display is a method . so do this where ever you call the display method.

display() # This will call a function dispaly(). Note that display is not the same as display().

Happy coding :)

richieking 44 Master Poster

what exactly do you want to calculate?

can you be more specific?
:)

richieking 44 Master Poster

And how do you intend to work with this data format?

richieking 44 Master Poster

can you post your code so far?

richieking 44 Master Poster

hhhmmmmm

Slash12.. I think your algo. is too long to solve this case. Refactor i thing is needed.
:)

richieking 44 Master Poster

Happy Newyear.
This is your newyear gift.

str="4:14.4-17M,5:14.4-2e13M,6:14.4-4e9M,7:14.4-8e,22:28.4-35M,\
23:28.4-2e30M,24:28.4-4e26M,25:28.4-8e18M,26:28.4-16e2M,27:28.4-18e,\
28:14.16-36M,29:14.16-2e32M,30:14.16-4e28M,31:14.16-8e20M"

d=[c for c in str.split(",")]
print([int(f.split(":")[0]) for f in d ])

##out Put
[4, 5, 6, 7, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]

And if you like it. you can upvote me a lil ok? :)

richieking 44 Master Poster

try this.
very simple

import time
boom=59

while boom >0:
    time.sleep(1)
    print(boom)
    boom -=1
richieking 44 Master Poster

Why that didnt worked? How come? :)

richieking 44 Master Poster

Panel helps event to have special precision and on window paltform, it give a diffenet frame colour.

richieking 44 Master Poster

MAy be converting the c++ script to python wont be that easy. I just tried and i think is insane idea. whops!

Look why not write a python script to implement the same functionalities. May be the interfaces of this C++ will not be the same but at least will produce the same results.
:)

richieking 44 Master Poster

Its turtleworld your own written module or what.
;)

richieking 44 Master Poster

Pay attention to line 23 of tonyjv+ code.

That is the solution to why your data was not what you wanted.

Goodluck
:)

richieking 44 Master Poster

Is it a wamp installation?

if yes and you are on Win OS. turn on hiddend files .
on xp. got to mycomputer -> menu list ->look for Tools -> folder Option and you will get a pop up. look for turn hidden file on.

Its a radio button.

Go back to your Wamp and look for .htaccess file. Just remove it.

2. If its not there...
Do you realize also that your url extension got encoding of foo+bar+spam... its eg.

question. Did you encoded that yourself or the file input did.?
If you did... Then you must make sure you decode that before you parse the url looking for the said link.

2. If your file name is spaced eg.. hello world.php ..., make sure you put them together like hello_world.php or anyway you like.
But they must be together.


If this trouble shooting does not help you. remove and install the server again.

;)

richieking 44 Master Poster

homescore = array('i',[])

visitingscore = array('i',[])

Python uses list keyword or this sign [] as array.
That is pythonic system.

richieking 44 Master Poster

What webserver are you useing?
:)

richieking 44 Master Poster

You are welcome. Please close the thread as solved. PM me anytime.