[Tutor] Running RPG game again.
Hi, I'm trying to make the RPG game to be able to run again. But, when I type "run", nothing happens. thanks. --- import random print \ """ Warrior - damage: 10~60 Archer - damage: 0~100 HP of Player: 100 HP of the monster: 300""" wp = raw_input("\n\nSelect between warrior and archer: ") mob = 300 hit = 0 hp = 100 dmg = 0 atk = 0 run = "" while True: while (mob > 0): hit += 1 mob = mob - dmg hp = hp - atk if wp == "warrior": dmg = random.randrange(50) + 10 atk = random.randrange(10) elif wp == "archer": dmg = random.randrange(100) atk = random.randrange(5) else: print "\nError" print "\n", hit, "hits" print "HP of", wp,":", hp,"/100" print "HP of the monster:", mob,"/300" print "\nYou defeated the monster by", hit,"hits,", dmg,"damage" run = raw_input("\nrun or exit ") if run == "run": continue else: break --- _ FREE pop-up blocking with the new MSN Toolbar - get it now! http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] CGI-script and multilingual output (HTTP_ACCEPT_LANGUAGE)
Well, I'm thinking about providing my site (at least some part of it) both in Finnish and English and would like to do it right. So, I decided that maybe I should try to use HTTP_ACCEPT_LANGUAGE, or am I completely wrong? I have some questions about it, though. I can access it through os.environ['HTTP_ACCEPT_LANGUAGE'] but have no idea how I should parse it. I mean, for example from my Firefox the output is like this 'fi,en;q=0.5' and because I'm not very good programmer, I don't know what would be the best way to check if surfer wants it in Finnish or in English. I could do something like this. languages = os.environ['HTTP_ACCEPT_LANGUAGE'].split(',') for temp in languages: if temp[:2] == 'fi' or temp[0:2] == 'en' language = temp[:2] break But I just doubt that it isn't the best or the right way to do it. I tried some Googling, but because don't know the proper terms, it wasn't very successful. So, any ideas would be very welcome! Yours, -- Olli Rajala <>< Tampere, Finland http://www.students.tut.fi/~rajala37/ "In theory, Theory and Practice should be the same. But in practice, they aren't." - Murphy's Proverbs ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] "classmethods"
Kent Johnson wrote: > Try this: > > def fromFile(path): > adict = {} > alist = [] > #... > #some part to read a file and to process data > return MyClass(parameter1,parameter2,...,d) > fromFile = staticmethod(fromFile) > > then client code will look like this: > aClass = MyClass.fromFile('a/file/path') A few more notes: - There is no need to make fromFile a staticmethod of MyClass, it could also be a module level function. Writing it as a staticmethod puts it in the namespace of MyClass which may be handy. - If you intend to subclass MyClass, the subclass constructors have compatible signatures and you want to be able to create subclasses with the same factory, a classmethod might work better. >>> class A(object): ... def __init__(self, val): ... self.val = val ... def show(self): ... print 'A.val:', self.val ... def factory(cls, val): ... return cls(val) ... factory = classmethod(factory) ... >>> a=A.factory(3) # calls A.factory(A, 3) >>> a.show() A.val: 3 >>> >>> class B(A): ... def show(self): ... print 'B.val:', self.val ... >>> b=B.factory(22) # calls A.factory(B, 22) >>> b.show() B.val: 22 - Finally, if you are using Python 2.4, you may prefer the decorator syntax for defining classmethods and staticmethods: class A(object): ... @classmethod def factory(cls, val): return cls(val) Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] difference between [[], [], []] and 3*[[]]
Hello, What's the difference between "[[], [], []]" and "3*[[]]" ? >>> a,b,c = [[], [], []] >>> id(a) 20609520 >>> id(b) 20722000 >>> id(c) 20721712 These ID is mutually different. But, >>> a,b,c = 3*[[]] >>> id(a) 20455728 >>> id(b) 20455728 >>> id(c) 20455728 >>> These are the same. On the other hand, >>> 3*[[]] [[], [], []] "[[], [], []]" is equal to "3*[[]]" or not ? After all, what should I do if I want to initialize a lot of lists ? For example a = [], b = [], c = [],, z = [] Thanks in advance, Mitsuo ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Retrieving Webpage Source, a Problem with 'onclick'
Hi, I am trying to loop over all of the links in a given webpage and retrieve the source of each of the child pages in turn. My problem is that the links are in the following form: [begin html] link1 link2 link3 link4 [end html] So clicking the links appears to call the Javascript function gS to dynamically create pages. I can't figure out how to get urllib/urllib2 to work here as the URL of each of these links is http://www.thehomepage.com/#. I have tried to get mechanize to click each link, once again it doesn't send the onclick request and just goes to http://www.thehomepage.com/# This blog (http://blog.tomtebo.org/programming/lagen.nu_tech_2.html) strongly suggests that the easiest way to do this is to use IE and COM automation (which is fine as I am working on a windows PC) so I have tried importing win32com.client and actually getting IE to click the link: [begin code] ie = Dispatch("InternetExplorer.Application") ie.Visible = 1 ie.Navigate('http://www.thehomepage.com') #it takes a little while for page to load if ie.Busy: sleep(2) #Print page title print ie.LocationName test=ie.Document.links ie.Navigate(ie.Document.links(30)) [end code] Which should just click the 30th link on the page. As with the other methods this takes me to http://www.thehomepage/# and doesn't call the Javascript. If somebody who has more experience in these matters could suggest a course of action I would be grateful. I'm more than happy to use any method (urllib, mechanize, IE & COM as tried so far) just so long as it works :) Thanks in advance, Craig. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python in HTML
> it would be a smart idea if I could figure out how to somehow replace > the javascript in the html with python. However, everything I've seen > online seems to require installing something on the server, which I The problem lies not on the server but on the client. JavaScript support is embedded in every popular browser so it just works, but none of them know about python. Even if they did it would require the user to have Python installed, which you can't assume. It is possible to embed python in web pages on Windows and IE, using ActiveX scripting (Now called WSH) and the winall package includes a script to activate it. However that will still require the end users to have Python installed and the WSH feature for Python turned on - quite unlikely outside a closed user community. So sadly its back to JavaScript I'm afraid. OTOH I didn't find JavaScript to be too terrible, what kind of problems are you having? PS I couldn't reply to the original message because it had beebn digitally signed. Please don't do that when posting to public mailing lists folks! (Well, not if you want a reply!) Alan G Author of the Learn to Program web tutor http://www.freenetpages.co.uk/hp/alan.gauld ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Exceptions for checking root, files
Hi, I never haven't worked with exceptions, and I'm a little confused. In my programs I always build a function to check things as: - The user that runned the script is root - All the files and directories with whom I am going to work exist - etc else the program exits. Does this checks can be runned from an exception? P.S.: I did read http://www.python.org/doc/current/tut/node10.html ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] main()
if __name__ == '__main__': what is the meaning and importance of this code line. I have been able to glean some information. When you call a script __name__ is set to the "Name" of the script called. example: python Hope.py __name__ = Hope but why would I want to do this if __name__ == '__main__': here a code snippet that I am trying to work through # # MAIN # if __name__ == '__main__': import sys filename = sys.argv[1] f = open(filename) generate(semantic(parse(scan(f f.close() I feel that if I am calling the script Hope.py than the above code should never get to run because __name__ is equal to "Hope" so why even write it. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] difference between [[], [], []] and 3*[[]]
Mitsuo Hashimoto wrote: > Hello, > > What's the difference between "[[], [], []]" and "3*[[]]" ? [[], [], []] makes a list containing references to three different lists. 3*[[]] makes a list with three references to the *same* list. This can cause surprising behavior: >>> l=3*[[]] >>> l [[], [], []] >>> l[0].append(1) >>> l [[1], [1], [1]] Because each list in l is the same, changing one changes them all. This is probably not what you want. > After all, what should I do if I want to initialize a lot of lists ? > For example a = [], b = [], c = [],, z = [] Why do you want to do this? Often using a dict is a good solution to this type of question. For example: >>> import string >>> d={} >>> for c in string.ascii_lowercase: ... d[c] = [] ... >>> d {'a': [], 'c': [], 'b': [], 'e': [], 'd': [], 'g': [], 'f': [], 'i': [], 'h': [], 'k': [], 'j': [], 'm': [], 'l': [], 'o': [], 'n': [], 'q': [], 'p': [], 's': [], 'r': [], 'u': [], 't': [], 'w': [], 'v': [], 'y': [], 'x': [], 'z': []} >>> Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Retrieving Webpage Source, a Problem with 'onclick'
You may be interested in Pamie: http://pamie.sourceforge.net/ Kent Craig Booth wrote: > Hi, > >I am trying to loop over all of the links in a given webpage and > retrieve the source of each of the child pages in turn. > >My problem is that the links are in the following form: > > [begin html] > link1 > link2 > link3 > link4 > [end html] > > So clicking the links appears to call the Javascript function gS to > dynamically create pages. > > I can't figure out how to get urllib/urllib2 to work here as the URL of > each of these links is http://www.thehomepage.com/#. > > I have tried to get mechanize to click each link, once again it doesn't > send the onclick request and just goes to http://www.thehomepage.com/# > > This blog (http://blog.tomtebo.org/programming/lagen.nu_tech_2.html) > strongly suggests that the easiest way to do this is to use IE and COM > automation (which is fine as I am working on a windows PC) so I have tried > importing win32com.client and actually getting IE to click the link: > > [begin code] > > ie = Dispatch("InternetExplorer.Application") > ie.Visible = 1 > ie.Navigate('http://www.thehomepage.com') > > #it takes a little while for page to load > if ie.Busy: > sleep(2) > > #Print page title > print ie.LocationName > > test=ie.Document.links > ie.Navigate(ie.Document.links(30)) > > [end code] > > Which should just click the 30th link on the page. As with the other > methods this takes me to http://www.thehomepage/# and doesn't call the > Javascript. > >If somebody who has more experience in these matters could suggest a > course of action I would be grateful. I'm more than happy to use any > method (urllib, mechanize, IE & COM as tried so far) just so long as it > works :) > >Thanks in advance, > Craig. > > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Running RPG game again.
> I'm trying to make the RPG game to be able to run again. > But, when I type "run", nothing happens. It's because your continue statement on line 45 loops around to line 19 (I double checked in the debugger). Then it checks if the monster is still alive (AGAIN) on line 20, but the monster is already dead, so the whole inner while loop is skipped and the program will jump straight to line 43 again. You might want to change your outermost while loop to something like this: iloveplaying=1 while iloveplaying: (move all the variable setup inside the main while loop that way the monster is reborn every time you play) while (mob>0): (do all the fighting stuff here as normal) run = raw_input("\nrun or exit ") if run != "run": iloveplaying=0 Alan ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Debugger?
Hi, I see so many errors when i execute my programs. Where can i get debugger for python? or How can i debug a prgram? Thanks. _ Express yourself instantly with MSN Messenger! Download today it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Checking and showing all errors before of exit
Is there any way of checking all possible errors, show you all error messages, and then exit. If i use :: sys.exit("error message") :: it only shows this error message before of exit. Thanks in advance! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] main()
Servando Garcia wrote: > > if __name__ == '__main__': > > what is the meaning and importance of this code line. I have been > able to glean some information. When you call a script __name__ is set > to the "Name" of the script called. example: python Hope.py > __name__ = Hope When Hope.py is a module imported into another script, then __name__ equals the name of the module as you say. Like this: ### HopeModule.py print __name__ ### Hope.py import HopeModule That will print 'HopeModule' if you run python Hope.py But if the scrip itself is run, __name__ will equal '__main__': ### Hope.py print __name__ Now python Hope.py prints '__main__', contrary to what you said. Did you try it? If your installation does otherwise, it seems there is something wrong. > but why would I want to do this if __name__ == '__main__': From the above it follows that code following if __name__ == '__main__': gets executed when the script itself is run, but not when it is import edas a module by another script. > here a code snippet that I am trying to work through > > # > # MAIN > # > > if __name__ == '__main__': > import sys > filename = sys.argv[1] > f = open(filename) > generate(semantic(parse(scan(f > f.close() > > I feel that if I am calling the script Hope.py than the above code > should never get to run because __name__ is equal to "Hope" so why even > write it. Did you try that? The code should really be executed. -- If I have been able to see further, it was only because I stood on the shoulders of giants. -- Isaac Newton Roel Schroeven ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] main()
> able to glean some information. When you call a script __name__ is set > to the "Name" of the script called. example: python Hope.py > __name__ = Hope Actually no. When you *import* a file its name is set to the file name(or more acurately the module name) When you run a file from the command line like python Hope.py then __name__ is set to __main__ > but why would I want to do this if __name__ == '__main__': So this line lets you create code that is executed when the file is run from the command line but not when the file is imported. Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Debugger?
> I see so many errors when i execute my programs. > > Where can i get debugger for python? or How can i debug a prgram? import pdb gets you the standard python debugger. But IDLE and Pythonwin etc have their own builtin graphical debuggers too. But if you are getting a lot of errors the debugger is the wrong place to look. DEbuggers are for deep diagnostics when the simple things fail and usually only used on a single obscure fault at a time. To deal with lots of errors use the >>> prompt to try things out before committing them to a file. THen import the "finished" file and try exercising the functions classes one by one from the >>> prompt. Finally insert print statements at suitable points, and only after doing all of that try the debugger. The best debugger of all is the one between your ears! Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python in HTML
Alan G wrote: > The problem lies not on the server but on the client. > JavaScript support is embedded in every popular browser so it just > works, but none of them know about python. Even if they did it would > require the user to have Python installed, which you can't assume. > > It is possible to embed python in web pages on Windows and IE, using > ActiveX scripting (Now called WSH) and the winall package includes a > script to activate it. However that will still require the end users > to have Python installed and the WSH feature for Python turned on > - quite unlikely outside a closed user community. > > So sadly its back to JavaScript I'm afraid. OTOH I didn't find > JavaScript > to be too terrible, what kind of problems are you having? > > PS > I couldn't reply to the original message because it had beebn > digitally signed. Please don't do that when posting to public mailing > lists folks! (Well, not if you want a reply!) > > Alan G > Author of the Learn to Program web tutor > http://www.freenetpages.co.uk/hp/alan.gauld Well, my problems in particular have been getting a bit of code to work at all, and when working, get it to behave as it should. It's really a trivial bit of code. All it does is control the behavior of a 'darkplayer' - a javscript mp3 player - for an online journal. The specific bit of code I'm having trouble with is the part that selects a random song from the playlist. To make sure every song is selected at least once, i tried to copy the playlist and have it choose songs from the copy, removing each song as it is played, and refilling the copy when it is empty. The code follows (apologies in advance for tabbing issues as it was edited in notepad): http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701 type=application/x-oleobject height=0 standby="Loading Microsoft Windows Media Player components..." width=0 classid=CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95> song names here (removed to save space/time) -- Email: singingxduck AT gmail DOT com AIM: singingxduck Programming Python for the fun of it. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Retrieving Webpage Source, a Problem with 'onclick'
Wow, I was going to give a rundown of how to use COM, but use that PAMIE instead to do it, it's way easier. If you do want to use COM & win32all instead, just bear in mind that the way to simulate an OnClick is to use taken from the blog you quoted) - ie.Document.frames(1).Document.forms(0).all.item(\"buttonSok\").click() But yeah, use PAMIE instead. Regards, Liam Clarke PS Cheers for the link also Kent.On 5/22/05, Kent Johnson <[EMAIL PROTECTED]> wrote: You may be interested in Pamie:http://pamie.sourceforge.net/KentCraig Booth wrote:> Hi,>>I am trying to loop over all of the links in a given webpage and > retrieve the source of each of the child pages in turn.>>My problem is that the links are in the following form:>> [begin html]> link1 > link2> link3 > link4> [end html]>> So clicking the links appears to call the _javascript_ function gS to > dynamically create pages.>> I can't figure out how to get urllib/urllib2 to work here as the URL of> each of these links is http://www.thehomepage.com/# .>> I have tried to get mechanize to click each link, once again it doesn't> send the onclick request and just goes to http://www.thehomepage.com/# >> This blog (http://blog.tomtebo.org/programming/lagen.nu_tech_2.html)> strongly suggests that the easiest way to do this is to use IE and COM > automation (which is fine as I am working on a windows PC) so I have tried> importing win32com.client and actually getting IE to click the link:>> [begin code]>> ie = Dispatch(" InternetExplorer.Application")> ie.Visible = 1> ie.Navigate('http://www.thehomepage.com')>> #it takes a little while for page to load> if ie.Busy :> sleep(2)>> #Print page title> print ie.LocationName>> test=ie.Document.links> ie.Navigate(ie.Document.links(30))>> [end code]>> Which should just click the 30th link on the page. As with the other > methods this takes me to http://www.thehomepage/# and doesn't call the> _javascript_.>>If somebody who has more experience in these matters could suggest a > course of action I would be grateful. I'm more than happy to use any> method (urllib, mechanize, IE & COM as tried so far) just so long as it> works :)>>Thanks in advance, > Craig.>> ___> Tutor maillist - Tutor@python.org> http://mail.python.org/mailman/listinfo/tutor>___Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor-- 'There is only one basic human right, and that is to do as you damn well please.And with it comes the only basic human duty, to take the consequences.' ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] While loop exercise
Hi, I just finished the chapter which includes while loop, if-else-elif structure and randrange(). Can anyone suggest me 3 exercises to remind of the chapter? Exercises shouldn't be too difficult because i'm newbie! Looking forward to writing some programs! Thanks. _ FREE pop-up blocking with the new MSN Toolbar - get it now! http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python in HTML
> specific bit of code I'm having trouble with is the part that selects a > random song from the playlist. To make sure every song is selected at > least once, i tried to copy the playlist and have it choose songs from > the copy, removing each song as it is played, and refilling the copy > when it is empty. OK, so what happened? Did you start just making the copy and playing the songs from the copy? Did that work OK? Does the random number generation work - I assume you tested that by just writing out the sequence of numbers first? And finally when you use the random numbvers to select songs does it pick the songs as you expect? I still don't know what we are looking for as a problem? But writing code in Javaript is like any other language, except the debugging environment of poorer! You start doing the easy things and build on features one by one, fixing as you go. As soon as you get a feature working put it in a function. It keeps the working code and experimental stuff separate! Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python in HTML
Alan G wrote: >OK, so what happened? >Did you start just making the copy and playing the songs from the >copy? >Did that work OK? > >Does the random number generation work - I assume you tested that by >just writing out the sequence of numbers first? > >And finally when you use the random numbvers to select songs does it >pick the songs as you expect? > >I still don't know what we are looking for as a problem? > >But writing code in Javaript is like any other language, except >the debugging environment of poorer! You start doing the easy things >and build on features one by one, fixing as you go. As soon as you >get a feature working put it in a function. It keeps the working code >and experimental stuff separate! > >Alan G. > Well, like I said, the darkplayer is on an online journal, which means that the only output possible is modifying the option strings of songs as they are played or something similar. I do know that the random number generator works, and the songs played always match the option selected. However, this was before adding the bit about copying the songs and playing from the copy. The last fully functional version (without the 'play all songs once' feature) is as follows: http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701 type=application/x-oleobject height=0 standby="Loading Microsoft Windows Media Player components..." width=0 classid=CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95> removed -- Email: singingxduck AT gmail DOT com AIM: singingxduck Programming Python for the fun of it. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python in HTML
> Well, like I said, the darkplayer is on an online journal, which means > that the only output possible is modifying the option strings of songs > as they are played or something similar. I do know that the random > number generator works, and the songs played always match the option > selected. However, this was before adding the bit about copying the > songs and playing from the copy. The last fully functional version > (without the 'play all songs once' feature) is as follows: > > codeBase=http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701 > > type=application/x-oleobject height=0 standby="Loading Microsoft > Windows > Media Player components..." width=0 > classid=CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95> > It's a bit off list topic, but I am interested to know how much functionality you have been successful to get going. I tried something very similar with Quicktime and Javascript, but seemed to wind up at a dead-end. My (premature?) conclusion was that once the audio player object was loaded, I could not reset certain parameters _in_that_object_ such as I would need to have it play an arbitrary file (url). My javascript was successful in changing the page parameters, as verified with DOM and print statements, but there seemed nothing to trigger the audio player to recognize those new parameters. IMO the great thing about Javascript is that you have a whole gui & application tied to it, so you can do a lot with very little code (sheer candy!); but the downside follows, that there you are utilizing a complex, fixed framework which constrains what you can do (bitter aftertaste)... and, of course, the development environment is not quite Pythonic. I hope you can get your Javascript - Windows Media Player interface to work. Unfortunately, I do not know how Python could be used within that interface... Good luck! Eric Pederson http://www.songzilla.blogspot.com ::: domainNot="@something.com" domainIs=domainNot.replace("s","z") ePrefix="".join([chr(ord(x)+1) for x in "do"]) mailMeAt=ePrefix+domainIs ::: ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python in HTML
Well Orri, I found one bug, but I don't know if this'll fix it, it's in your copy playlist bit though. > for (var index = 0; index < songs.length; playable++) >{ >playable[index] = songs[index]; >} >} I believe you want to increment index, not playable. Um, man, that's what I hate about _javascript_, it fails silently. I've never met a _javascript_ console... /me ponders Firefox plugin. Good luck, Liam ClarkeOn 5/22/05, EJP <[EMAIL PROTECTED]> wrote: > Well, like I said, the darkplayer is on an online journal, which means> that the only output possible is modifying the option strings of songs> as they are played or something similar. I do know that the random > number generator works, and the songs played always match the option> selected. However, this was before adding the bit about copying the> songs and playing from the copy. The last fully functional version > (without the 'play all songs once' feature) is as follows:>> > codeBase="" href="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701"> http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701> type=application/x-oleobject height=0 standby="Loading Microsoft> Windows> Media Player components..." width=0 > classid="">> It's a bit off list topic, but I am interested to know how much functionality you have been successful to get going. I tried something very similar with Quicktime and _javascript_, but seemed to wind up at a dead-end. My (premature?) conclusion was that once the audio player object was loaded, I could not reset certain parameters _in_that_object_ such as I would need to have it play an arbitrary file (url).My _javascript_ was successful in changing the page parameters, as verified with DOM and print statements, but there seemed nothing to trigger the audio player to recognize those new parameters.IMO the great thing about _javascript_ is that you have a whole gui & application tied to it, so you can do a lot with very little code (sheer candy!); but the downside follows, that there you are utilizing a complex, fixed framework which constrains what you can do (bitter aftertaste)... and, of course, the development environment is not quite Pythonic.I hope you can get your _javascript_ - Windows Media Player interface to work. Unfortunately, I do not know how Python could be used within that interface...Good luck!Eric Pedersonhttp://www.songzilla.blogspot.com:::domainNot="@ something.com"domainIs=domainNot.replace("s","z")ePrefix="".join([chr(ord(x)+1) for x in "do"])mailMeAt=ePrefix+domainIs::: ___Tutor maillist - Tutor@python.orghttp://mail.python.org/mailman/listinfo/tutor -- 'There is only one basic human right, and that is to do as you damn well please.And with it comes the only basic human duty, to take the consequences.' ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python in HTML
Oops, I'm lazy - https://addons.mozilla.org/extensions/moreinfo.php?application=firefox&category=Developer%20Tools&numpg=10&id=216 There's a _javascript_ debugger.On 5/22/05, Liam Clarke <[EMAIL PROTECTED]> wrote: Well Orri, I found one bug, but I don't know if this'll fix it, it's in your copy playlist bit though. > for (var index = 0; index < songs.length; playable++) >{ >playable[index] = songs[index]; >} >} I believe you want to increment index, not playable. Um, man, that's what I hate about _javascript_, it fails silently. I've never met a _javascript_ console... /me ponders Firefox plugin. Good luck, Liam ClarkeOn 5/22/05, EJP < [EMAIL PROTECTED]> wrote: > Well, like I said, the darkplayer is on an online journal, which means> that the only output possible is modifying the option strings of songs> as they are played or something similar. I do know that the random > number generator works, and the songs played always match the option> selected. However, this was before adding the bit about copying the> songs and playing from the copy. The last fully functional version > (without the 'play all songs once' feature) is as follows:>> > codeBase="" href="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" target="_blank" > http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701> type=application/x-oleobject height=0 standby="Loading Microsoft> Windows> Media Player components..." width=0 > classid="">> It's a bit off list topic, but I am interested to know how much functionality you have been successful to get going. I tried something very similar with Quicktime and _javascript_, but seemed to wind up at a dead-end. My (premature?) conclusion was that once the audio player object was loaded, I could not reset certain parameters _in_that_object_ such as I would need to have it play an arbitrary file (url).My _javascript_ was successful in changing the page parameters, as verified with DOM and print statements, but there seemed nothing to trigger the audio player to recognize those new parameters.IMO the great thing about _javascript_ is that you have a whole gui & application tied to it, so you can do a lot with very little code (sheer candy!); but the downside follows, that there you are utilizing a complex, fixed framework which constrains what you can do (bitter aftertaste)... and, of course, the development environment is not quite Pythonic.I hope you can get your _javascript_ - Windows Media Player interface to work. Unfortunately, I do not know how Python could be used within that interface...Good luck!Eric Pedersonhttp://www.songzilla.blogspot.com :::domainNot="@ something.com"domainIs=domainNot.replace("s","z")ePrefix="".join([chr(ord(x)+1) for x in "do"])mailMeAt=ePrefix+domainIs::: ___Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor -- 'There is only one basic human right, and that is to do as you damn well please.And with it comes the only basic human duty, to take the consequences.' -- 'There is only one basic human right, and that is to do as you damn well please.And with it comes the only basic human duty, to take the consequences.' ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor