Hello Guys.
This is a topic where users can come and write about anything python-related--if they need help with something, or want to show off their skills--this is the place.
So, let me get the ball rolling with a question:
How do you write a high score to a file and return it in some way within a program? Here is my code below. I politely ask that you tell me a way I could do it, but don't put code in for me. Code:
import random
def file_question():
    filename=raw_input("what is the name of the file you want to open?")
    return filename
filename = file_question()

def open_file(filename):
        infile = open(filename, "rb")
        infile = open('C:\\Users\\234265\\Desktop\\'+filename, 'rb')

    for line in infile:
        if counter%2=1:
        elif counter%2=0
            answer = line
    return trivia

trivia = open_file(filename)

def ask_questions()
    for question in questions:
            if guess=trivia[question]
        print "You got "+counter +"out of "+len(questions) +"right."
def play_again():
    asker=raw_input("would you like to play again?")
    if asker=="y":
    elif asker=="n":
        print "have a nice day."

I love audio gaming!

Thumbs up

Use can use the pickle module to pack and unpack lists, dictionaries, and other data for writing to a text document. Example:

import pickle

#write data
def write(data,name):
    tmp = open(name,'w')
    pack = pickle.dumps(data)

#read data
def read(name):
    tmp = open(name,'r')
    pack = tmp.read()
    data = pickle.loads(pack)
    return data

shopping = ['green eggs',1234,'ham',5678]
tmp = read('test.txt')
print tmp
-BrushTone v1.2.3: Accessible Paint Tool

Thumbs up

thanks. I have 2 more questions:
1. How do you print the items in a list without the brackets that a list usually contains?
2. What would be the best libraries for sound and screen reader usage in Python and sound usage, and what would be a good way to install them with dependencies included?

I love audio gaming!

Thumbs up

4 (edited by raven 2017-03-04 06:54:29)

for i in list:

For sound, there's libaudioverse at https://github.com/camlorn/libaudioverse

It's just a pip install libaudioverse away

for speech, there's accessible_output2, but you have to have to use the hg+ prefix, like this:

pip install hg+http://hg.q-continuum.net/libloader hg+http://hg.q-continuum.net/platform_utils hg+http://hg.q-continuum.net/accessible_output2

That should get you AO2+the dependencies.

Thumbs up

But keep in mind that libaudioverse does have some audio problems, as i noticed on games that used it like the shooter engine and the new death match. I don't know if the developer fixed it successfully, but if not you could use PyAL.

Thumbs up

To print a list without the brackets you can use this example:

shopping = ['green eggs',1234,'ham',5678]
print ', '.join(str(a) for a in shopping)

Other than the aforementioned accessible_output2, libaudioverse, and [PyAL] , there's also [Pyglet]. For screen readers there's also [Tolk] and [Pyttsx], although Pyttsx only supports native tts.

-BrushTone v1.2.3: Accessible Paint Tool

Thumbs up

okay I installed accessible_output2. I get the error that says that %1 is not a valid win32 application. What do I do to fix this?

I love audio gaming!

Thumbs up