jlm699 320 Veteran Poster

I am not sure. I used this link from my school.
http://www.ifi.uio.no/~inf3330/software/index-basic.html

Try right-clicking the Deploy installer and seeing if there's an option to run it as admin or similar.

jlm699 320 Veteran Poster

Sorry, I don't understand you. What are you trying to say about Python 2.5? It's what I use, even though Python 2.6 is out now (or the early releases for 3.0).

I believe his question was in regards to the OP.

He was asking why he is still using 2.4 instead of 2.5 or later. And then he asked if he stuck with 2.4 because of a "special function"... I think

jlm699 320 Veteran Poster

Which version of python are you using?

This is irrelevant. I've never used Vista, but I've heard of other people on this forum complaining about it... I think I remember something about right-clicking the file and choosing "Run as Administrator"... or something similar. Maybe you can see if that is an option when you right click on the Python installer

jlm699 320 Veteran Poster

In windows I use notepad++. I've tried that ecplise plugin (the name escapes me) and I liked that also.

In *nix, its always vim for me though.

+1 verbatim

jlm699 320 Veteran Poster

Yes, you would need to import turtle. Here's a good place to start: docs.

And an excerpt from that site:

Because [turtle] uses Tkinter for the underlying graphics, it needs a version of python installed with Tk support.

So make sure you've got a more recent version of python.

Finally, a typical for loop:

for x in [1,2,3,4,5]:
    print x

Instead of a hard list you could use range(1,6) or better yet xrange(1,6); however the above example gives you a better idea of what's happening. Try typing that into your favorite Python interpreter to see what happens.

jlm699 320 Veteran Poster

It helps when you tell us what "doesn't work". Do you get an error, does your computer light on fire, what?

jlm699 320 Veteran Poster

Wrap your code in code tags:
[code=python] # Code here

[/code]

jlm699 320 Veteran Poster

Save it to a text file:

f = open('my_file.txt', 'w')
#
f.write( '%s\n%s\n' % ( usr_name, usr_number ) )
f.close()
jlm699 320 Veteran Poster

Wrap code in code tags:
[code=python] # Code here

[/code]
Also, read the forum rules about homework, and about asking questions in general.

jlm699 320 Veteran Poster

Wrap your code in code tags. It will make it readable for us and it won't lose the indentation.

[code=python] # Code here

[/code]

jlm699 320 Veteran Poster

* I understand that the spaceing is off, but it is because of the quote box

Instead of quote use code tags:
[code=python] The code goes in here and doesn't lose formatting

[/code]

jlm699 320 Veteran Poster

Ah sorry, sometimes I just forget to explain myself ;)

Let me break it down:

>>> f = open('Schedule.txt')
>>> r = f.readlines()
>>> f.close()

So we open the file with the open() function. This function takes the path to the file as its first argument, and the mode that you want as the second argument, returning a file handle. If the second argument is not provided it defaults to Read mode.

Alternately you can do open( my_file, 'r' ) to specify read. Similarly, open( my_file, 'w' ) opens a file for writing; however keep in mind that an existing file will be cleared out or created anew if it doesn't. Using a mode of 'a' would be append (ie, don't clear an existing file add onto the end). The link above explains in detail other modifiers that can be used with the modes, such as + and 'b'

Next line I asked the file handle to return a list containing each line as a single element. I could've alternately used read() to get the entire block of text as a string, but that's ugly. You could roll your own iteration by using readline(), which will read a single line at a time and update the file handle to always know the position of the "cursor", so that you can call repeated readline()'s until EOF is reached.

Finally we close the file handle.

>>> data_found = 0
>>> for each_line in r: …
jlm699 320 Veteran Poster

Let's do this one step at a time. The text file is kind of ugly, but here's a quick example of extracting info.

>>> f = open('Schedule.txt')
>>> r = f.readlines()
>>> f.close()
>>>
>>> data_found = 0
>>> for each_line in r:
...     if not data_found:
...         if each_line.strip()[:4] == 'Time':
...             data_found = 1
...             my_data = {}
...             for each_entry in [ i.strip() for i in each_line.split('  ') if i ]:
...                 my_data[each_entry] = ''
...     else:
...         if each_line[:3] != '   ' and each_line.strip():
...             print [ i.strip() for i in each_line.strip().split('  ') if i ]
...     
['08:30AM', 'DOE, JANE', '3######', '##/##/####', '4MDC', '###-###-####', 'FES', '40', 'XXXX MD,XXXXXX', 'PNL', 'MFG', '3XXXXXXX']
['08:30AM', 'DOE, JANE', '3######', '##/##/####', '5UNI', '###-###-####', 'FES', '40', 'XXXX MD,XXXXXX', 'PNL', 'MFG', '3XXXXXXX']
['09:20AM', 'DOE, JANE', '3######', '##/##/####', '5UNI', '###-###-####', 'IGS', '40', 'XXXX MD,XXXXXX', 'PNL', 'MFG', '3XXXXXXX']
['09:20AM', 'DOE, JANE', '3######', '##/##/####', '5PPO', '###-###-####', 'IGS', '40', 'XXXX MD,XXXXXX', 'PNL', 'MFG', '3XXXXXXX']
['10:10AM', 'DOE, JANE', '3######', '##/##/####', '4OMH', '###-###-####', 'UFU', '40', 'XXXX MD,XXXXXX', 'PNL', 'MFG', '3XXXXXXX']
['10:10AM', 'DOE, JANE', '3######', '##/##/####', '4MPE', '###-###-####', 'AMN', '40', 'XXXX MD,XXXXXX', 'PNL', 'MFG', '3XXXXXXX']
>>> my_data
{'Hm/Wk Phone': '', 'Appt#': '', 'Loc': '', 'DOB': '', 'Provider': '', 'Patient Name': '', 'Dept': '', 'MRN': '', 'FSC1': '', 'Time': '', 'Dur': '', 'Typ': ''}
>>>

Now we'll need to put some thought into how we want to handle this. We could set up a list and for each patient record, fill in my_data structure, and then deep copy it into …

jlm699 320 Veteran Poster

You can look into pyAudio
HTH

jlm699 320 Veteran Poster

Looks like you can do that according to this post

jlm699 320 Veteran Poster

I think that when trying to run a python program you should be doing

os.execv( 'C:\\Python24\\python.exe', 'C:\\Python24\\development\\radar\\nra.py')

ie, you're not actually executing the program, you're executing Python and asking it to interpret your script nra.py

HTH

jlm699 320 Veteran Poster
print p.Hi                     #This prints the location...

get <__main__.add instance at 0x00A98FD0>
Um... why?

Because you asked for it ;)

print p.Hi()                     #This prints the location...

HTH

jlm699 320 Veteran Poster

If CenterOnParent is centering on the screen that means your dialog isn't being called with the proper parent. You probably have None set for this value when calling the dialog. Double-check your code to make sure you're providing the object with the proper arguments on initialization.

HTH

jlm699 320 Veteran Poster

What errors are you getting and where?

I've used this in the past for splitting a Status Bar and writing text to the last section (ie [ Index 0 | Index 1 | Index 2 ] ):

self.sb = self.CreateStatusBar(3)
self.sb.SetStatusWidths([-2, -1, 150])
self.SetStatusText('My Text', 2)

SetStatusText is not a function of the status bar but of the frame containing said status bar, which may be the reason for your error.

HTH

jlm699 320 Veteran Poster

Look into pyXLreader. There are plenty of tutorials and example code on the Googles

jlm699 320 Veteran Poster

Refer to this post

jlm699 320 Veteran Poster

*Ahem* You're missing your colon(s)

def getfibnum():
...
def main():
jlm699 320 Veteran Poster

It's called py2app

jlm699 320 Veteran Poster

When you post code it helps the other forum members out if it is readable. In order to make it readable and not lose the indentation and structure, you must wrap your code in code tags like so:
[code=python] # Code goes in here!

[/code]

On initial inspection I see that your line c = int(raw_input("Enter fibonacci numer") is missing a closing parenthesis. Please repost your code with the code tags and I'll take a nother gander... Also, what exactly is your error?

jlm699 320 Veteran Poster

Perhaps use subprocess to make a system call to ./PythonXX/pythonw.exe <path_to_pygame_program> ; there's been a number of threads on here about using subprocess to open pipes to perform certain actions.

jlm699 320 Veteran Poster
if prompt == "look around" or prompt == "look":

Another solution for this problem that will help if you had a third option would be this:

if prompt in [ 'look around', 'look', 'observe', 'admire' ]:

So if you use the in keyword, it'll match it to any value within the iterable container (list). This can clean up a lot of statements like that.

jlm699 320 Veteran Poster

You can't necessarily "add additional keys to existing values", unless you simply meant add additional key/value pairs to the existing dictionary. Here's some examples of adding elements to a dictionary:

>>> d = {'a':1, 'b':2, 'c':3}
>>> d['d'] = 4
>>> d['a'] = [ d['a'], 12, 13 ]
>>> d['e'] = []
>>> d['e'].append('foobar')
>>> d
{'a': [1, 12, 13], 'c': 3, 'b': 2, 'e': ['foobar'], 'd': 4}
>>>
jlm699 320 Veteran Poster

Explain what you mean by "scans a program". Do you mean communicate with a running program ? Or scan a text file?

jlm699 320 Veteran Poster

Wrap the code tags in [noparse][/noparse] tags.

jlm699 320 Veteran Poster
fraction1 = float(fraction) * 2
    fraction1 = str(fraction1)
    binfrac1 = fraction1[0]
    if "1" in binfrac1:
        fraction1 = float(fraction1)
        fraction1 - 1
    binfrac1 = str(binfrac1)

This logic is flawed. All you're doing is doubling the "fraction" portion of the number, and checking to see if the first number is a 1, at which point you subtract "1" from the number... I haven't done fractional binary conversions in a long time, but can't you just multiply the fraction by ten until it's a whole number, and then push that numberthrough the same logic that you use for the binint portion? Then you'll only need to adjust for decimal at the end.

jlm699 320 Veteran Poster

Please use code tags so that your indentation is not lost, and so that we may better read your posts.

Code tags go like this:
[code=python] # MY code goes between these tags!

[/code]

jlm699 320 Veteran Poster

Look through the Demo for those two functions. These each make the respective element.

jlm699 320 Veteran Poster

just wanted to say that i found that that www.diveintopython.org was not down so you can use that if you want.

That's odd. Yesterday it was definitely down. Even Down for everyone or just me gave me

Huh? doesn't look like a site on the interwho.

Strange...

jlm699 320 Veteran Poster

And don't forget about help()

>>> help( input )
Help on built-in function input in module __builtin__:

input(...)
    input([prompt]) -> value
    
    Equivalent to eval(raw_input(prompt)).

>>>

You can use that on most any function to get info on usage, and a short explanation

jlm699 320 Veteran Poster

Yes, studying Python 3.0 or an earlier version (apart from 2.6) will not really make much difference to you. The fundamental changes are really hidden in the advanced features mostly (besides integer division and class creation I believe).

If you start with 2.5, you'll still have all the basics and be able to jump into 3.0 swinging.

jlm699 320 Veteran Poster

If you make a list of the file names, then use a Throbber and initialize it with the list of filenames, then you can simply set the value of the throbber to the index of the image (this is really easy if it's simply a steady increment of indices.

jlm699 320 Veteran Poster

The Dive Into Python book has a great explanation/tutorial/exercises for the re module.

NOTE: It appears that diveintopython.org/ is down ?! I don't know what's going on over there but Google will help you find copies of the book elsewhere, if you're so inclined.

jlm699 320 Veteran Poster

Here's a little example of using a dictionary:

>>> d = {"inchtocm":2.54, "metertocm":100}
>>> d.keys()
['metertocm', 'inchtocm']
>>> d.values()
[100, 2.54]
>>> for elem in d:
...     print elem, d[elem]
...     
metertocm 100
inchtocm 2.54
>>> d["foottoinch"] = 12
>>> for elem in d:
...     print elem, d[elem]
...     
foottoinch 12
metertocm 100
inchtocm 2.54
>>> feet = 5
>>> inches = feet * d["foottoinch"]
>>> inches
60
>>>
jlm699 320 Veteran Poster

(if the path to your file is C:\aTest\HelloMP1.py , because \ is the character used by python to escape characters in litteral string, so "\a" does not mean backslash followed by a, but the character whith hexadecimal code \x07. If you want to write a backslash followed by a, you can write "\\a" (double every backslash).

To avoid this mess, you can make use of the os.path tools:

import os

my_file_path = os.path.join( 'C:\\', 'aTest', 'HelloMP1.py' )
open( my_file_path )
# Etc...
jlm699 320 Veteran Poster

Sometimes, if the module isn't in the same place, it is a matter of the path. At the begging of your progam you can do something like:

import sys
sys.path.append('/path/tomy/module')
from MyMod import moduleA

However I don't know how Eclipse as an IDE differs in terms of working directory...

jlm699 320 Veteran Poster

One more thing:
In python, a list is like a vector in C?

It is similar in that it has built-in functionality for appending, inserting, removing, etc.

jlm699 320 Veteran Poster

I suggest a slight modification to your function, as you can make use of Python's built-in file iteration, instead of rolling your own.

def getlist( data ):
    nrlist=[]
    for each_line in data:
        try:
            nrlist.append( float( aux ) )
        except ValueError:
            print "Introdu date numerice!" #Its in romanian.. meaning "Enter numeric data!."
    return list

Python knows that when a file handle is iterated over, that it should iterate line by line (so the use of each_line was arbitrary, it's just for your understanding... it could've just as well been r, or n or your favorite variable name...)

You can also reduce the float() and append() calls into a single line for simplicity.

Finally, by placing return list outside of the for loop, it will return once processing has completed. Now, when you called the function via list = getList() you should verify that the function returned some values via:

if not list:
    print "No numerical entries found!"

This brings me to my final suggestion. See how the word "list" is highlighted in purple in your block of code (and mine)? That is a clue that list is a reserved word. Look at the following:

>>> list("12345")
['1', '2', '3', '4', '5']
>>> a = (1,2,3,4,5)
>>> list(a)
[1, 2, 3, 4, 5]
>>>

list, int, float, str, chr, etc.... these are all instances of class types that will convert things into the specified class, and thus should not be used as variable names. By declaring a …

jlm699 320 Veteran Poster

While you don't need to specifically declare variables, you still need to make sure that you've got them in the correct scope.

So first thing I notice is that your function us trying to read from data; however data doesn't exist in your function, only in the part that calls the function. A way around this would be to pass data to getList via getList( data ) , which would require a change to the line def getList( data ): , naturally...

Now your problem is that you're opening data, but haven't declared what data is. But also, you say data=open(data, "r") ... which is not good form. open() will return a file handle to data. But you've initially intended data to contain the name/path of the file. This means that after opening the file, if you wanted to re-use the filename or path (which ever data was supposed to be), it would be erased and instead you'd be dealing with the file handle.

Do something like this

my_file = '/usr/data/file_fun.txt'
data = open( my_file, 'r' )

list = getList( data )
jlm699 320 Veteran Poster

I did this and had a hell of a time figuring it out!

Go to Run -> "Run...", then type in C:\PythonXX\pythonw.exe "$(FULL_CURRENT_PATH)" ** Note I use pythonw.exe, you can just as easily use the standard python.exe (I just hate that console window), and when you've got that hit the "Save..." button for a dialog where you can name it and assign a shortcut to it.

*Note: Ctrl + R was already taken (and I'm too used to it from CodeEditor) so I went to Settings -> "Shortcut Mapper..." to give my python run command the Ctrl + R and moved whatever that used to be occupied to something else

Just dug this out of my bookmarks: Notepad++ Run external tools

jlm699 320 Veteran Poster

companies which use python, from the Nasa to Google.

Don't forget IBM ;)

jlm699 320 Veteran Poster

Also system calls would work:

import os

os.system('chmod 755 /usr/myfile')
jlm699 320 Veteran Poster

Please use code tags
[code=python] *Your code goes between these tags

[/code]

Infinite loop= while True: Put the things you want to repeat inside the loop.
Initialization goes before the loop.

jlm699 320 Veteran Poster

That is:
s = "---> Increased"
print "Today's stock price: %f %s" % (50.4625, s)

You got it ;)

jlm699 320 Veteran Poster

you need to use the file handle and not the loaded object when you dump. You should just reopen the file for reading or writing and not worry about a+.

#User Access for Password.py
import cPickle as p
import sys

my_file = 'systemaccess.txt'
file_handle = open( my_file, 'r' )
temp = p.load( file_handle )
file_handle.close()

def EP(self):
    if self.lower() == 'exit':
        print 'Exiting Program.'
        sys.exit()
        
print 'Welcome to the System Account Setup.'
print 'Enter Exit to end the program at any time.'
Username = raw_input('Please enter the username you desire: ')
EP(Username.lower())
Password = raw_input('Enter your desired password: ')
EP(Password.lower())

if Username.lower() in temp:
    print 'That username already exists.'
else:
    temp[Username.lower()] = Password.lower()
    file_handle = open( my_file, 'w' )
    p.dump(temp, file_handle)
    file_handle.close()
jlm699 320 Veteran Poster

if It was avote, I'll give mine to wxpy!

+1