Re: [Tutor] Python in HTML

2005-05-22 Thread Alan G
HI Orri,

> >OK, so what happened?

You still aren't telling us what happens. Its very hard to find
a fault in a program when you have no idea what the problem is.
The code is very likely doing what you have asked it to do,
so when we read it it will seem to 'work' at a superficial level.

Without a clear explanation of the problem you force the tutors
to read every line closely, and speaking personally, I don't have
enough free time for that, I need to know what I'm looking for.

> 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.

So you got a version working that played the sings in random order?
Or did you write separate programs, one that demonstrated the random
generator working and another that played songs with diffrerent
options?

> However, this was before adding the bit about copying the
> songs and playing from the copy.

So if you forget about playing the songs can you copy the songs and
generate a random selection from the copy?

Alan G.

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] installing python 2.4.1 over 2.4

2005-05-22 Thread Pujo Aji
Hello,

I have python 2.4.
I would like to install python 2.4.1, Should I uninstall python 2.4,
or just install 2.4.1?

Does it effect my ide such as pydev and komodo ?

Sincerely Yours,
pujo
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Python in HTML

2005-05-22 Thread Kent Johnson
Liam Clarke wrote:
> Um, man, that's what I hate about Javascript, it fails silently. I've 
> never met a Javascript console...
> 
> /me ponders Firefox plugin.

Firefox has a JavaScript console that can be helpful...

Kent

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Python in HTML

2005-05-22 Thread Liam Clarke
Yeah, I just found it. Embarrassed... document inspector is kinda cool too. On 5/23/05, Kent Johnson <[EMAIL PROTECTED]
> wrote:Liam Clarke wrote:> Um, man, that's what I hate about _javascript_, it fails silently. I've
> never met a _javascript_ console...>> /me ponders Firefox plugin.Firefox has a _javascript_ console that can be helpful...Kent-- '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

2005-05-22 Thread Orri Ganel
EJP 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=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
>:::
>
>
>  
>
Well, since my method of 'resetting parameters' is to use buttons, whose 
purpose is defined in the script, I'm not entirely sure that I'm really 
changing anything.  With the script I sent out, it worked in the sense 
that, every time the 'random' button was pressed, a song was selected 
randomly from the song list (meaning not every song was played before a 
song was re-played) and played.  However, as soon as the song ends, in 
order to select a new song, random must be pressed again.  Of course, it 
is possible at any time to select a song from the menu and hit play, 
just hit play to re-play the current song, pause the song, or stop it 
using the play, pause, and stop buttons.  As for the interface with 
Windows Media Player, that is handled entirely within 
"http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701";,
 
whatever it may be.  Less complicated versions of the darkplayer than 
mine can be found on many average journals at www.xanga.com.  It is only 
when i started fooling around with it that it started to behave oddly.  
I added the random button without much trouble, and changed the random 
number generator as well, but i can't seem to be able to get this to work.

-- 
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

2005-05-22 Thread Orri Ganel
Alan G wrote:

>HI Orri,
>
>  
>
>>>OK, so what happened?
>>>  
>>>
>
>You still aren't telling us what happens. Its very hard to find
>a fault in a program when you have no idea what the problem is.
>The code is very likely doing what you have asked it to do,
>so when we read it it will seem to 'work' at a superficial level.
>
>Without a clear explanation of the problem you force the tutors
>to read every line closely, and speaking personally, I don't have
>enough free time for that, I need to know what I'm looking for.
>
>  
>
>>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.
>>
>>
>
>So you got a version working that played the sings in random order?
>Or did you write separate programs, one that demonstrated the random
>generator working and another that played songs with diffrerent
>options?
>
>  
>
>>However, this was before adding the bit about copying the
>>songs and playing from the copy.
>>
>>
>
>So if you forget about playing the songs can you copy the songs and
>generate a random selection from the copy?
>
>Alan G.
>
>
>  
>
Well, the language being Javascript, I unfortunately don't know what 
happened, because there are no IDE's for Javascript; it just fails 
silently, as Liam put it.  The last working copy I had was one in which 
there was a random number generator selecting random songs directly from 
the song list, meaning that songs were re-played before every song had 
been played once.  Since this sciprt goes into a 'javascript module' in 
a webjournal, the opportunity to write separate scripts is limited.  It 
also doesn't help that there are no Javascript IDE's available.  As far 
as I know, the problem lies within some small syntax error.  Or, it may 
be a completely different problem. Due to the lack of output when 
Javascript crashes, I just don't know.

-- 
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

2005-05-22 Thread Orri Ganel

Kent Johnson wrote:


Liam Clarke wrote:

Um, man, that's what I hate about Javascript, it fails silently. I've 
never met a Javascript console...


/me ponders Firefox plugin.



Firefox has a JavaScript console that can be helpful...

Kent


Many thanks.  I was not aware of this.

--
Email: singingxduck AT gmail DOT com
AIM: singingxduck
Programming Python for the fun of it.



smime.p7s
Description: S/MIME Cryptographic Signature
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Python in HTML

2005-05-22 Thread Alan G
> >You still aren't telling us what happens. Its very hard to find
> >a fault in a program when you have no idea what the problem is.

> Well, the language being Javascript, I unfortunately don't know what
> happened, because there are no IDE's for Javascript; it just fails
> silently, as Liam put it.

OK, unlock that silence by using lots of print statements
(or document.write() in Javascript terms). Check the value
of the strings you are using, the current index etc by printing
them on the web page. Stub out the calls to the player until
you are sure you are passing the correct values in.

> there was a random number generator selecting random songs directly
from
> the song list, meaning that songs were re-played before every song
had
> been played once.

So it sounds like an error in the copy mechanism... Liam(?) already
pointed out one possible cause, but the key to working in any language
is to break the program into bite size pieces and get them working
bit by bit. Sometimes that means taking out a bit that was working
before.

> also doesn't help that there are no Javascript IDE's available.  As
far
> as I know, the problem lies within some small syntax error.

Actually there are a few JavaScript IDEs around, Microsoft do one
for example.

> be a completely different problem. Due to the lack of output when
> Javascript crashes, I just don't know.

There is a JavaScript console that you can display and it sometimes
gives you some clues too. But the best bet is lots of write()
statements
IMHO.

Also the fact its one big file shouldn't be a problem. Provided you
make liberal use of functions to encapsulate the functionality and
keep those together in the head of the html then the amount of code
scattered through the html should be manageable.

Alan G.

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] While loop exercise

2005-05-22 Thread Andrei
. ,  hotmail.com> writes:

> 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?

The standard exercise which includes all three would be a number guessing game
where the computer picks a number and the user guesses it (the opposite is also
possible, but then randrange is not useful). A while loop is standard in *any*
program that can be executed more than once. E.g. asking someone for a string is
a single line of code, but asking for an unlimited number of strings directly
requires a while loop.

> Looking forward to writing some programs!

At this stage there aren't many really useful application you can make, but you
should use your fantasy. Pick a subject you know something about and make a
simple application for it. I think there are lots of suitable subjects in maths,
physics and children's games, but you can find suitable subjects in lots of
other fields too.

Other possible small programs using while and if (randrange is a bit exotic and
not that useful):
- let the user input names and dates of birth. Calculate membership fee to a
club based on whether the person is a child, an adult or a senior citizen.
- a quadradic formula solver (would have to check whether the determinant < 0)
- a hangman game
- a free fall calculator (given an object that is dropped from a certain height,
calculate a table with its position as a function of time)
- a quiz program about some topic you like (could even use randrange in this one
to pick questions)
- a program which combines some of the programs above - e.g. allow the user to
play either number guessing or hangman.
- a hotel booking application which allows making reservations for one or
2-person rooms and applies a discount if the reservation is on a day between
monday and thursday. 

Yours,

Andrei

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] FS: Python Books

2005-05-22 Thread nf6q
Hello Everyone.

The following Python Books are in excess to my needs.
I prefer to sell as one lot.

XML Processing with Python by Sean McGrath.

Web Programming in Python by Thiruvathukal,Christopher,Shafaee

Programming Python by Mark Lutz

The Quick Python Book.


All books are in excellent condition and those that have a CD have them.

All four books for $65.00 including shipping via USPS Media Mail to CONUS.

PayPal prefer.

thanks

-- 

fernando


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] looking for a pattern in a lot of files

2005-05-22 Thread Jonas Melian
I've to looking for a pattern ('locale for') in a lot of files
(/dir/*_[A-Z][A-Z])

it's goes ok

any improvement about this code?
how print the actual file?
could i add an exception? by if there aren't files


for line in fileinput.input(glob.glob(os.path.join
(dir_locales, "*_[A-Z][A-Z]"))):
if re.search("locale for", line):
print line
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Python in HTML

2005-05-22 Thread Orri Ganel
Thanks to all who helped.  It looks like I figured out what the problem 
was, with the use of mozilla's DOM inspector, js debugger, and JSIDE (a 
javascript ide) that I downloaded after googling "javascript ide" (it 
appears to be quite good).  In any case, the whole issue was checking 
whether or not playable was empty.  I used a single = instead of 2:

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] looking for a pattern in a lot of files

2005-05-22 Thread Max Noel

On May 22, 2005, at 21:07, Jonas Melian wrote:

> for line in fileinput.input(glob.glob(os.path.join
> (dir_locales, "*_[A-Z][A-Z]"))):
> if re.search("locale for", line):
> print line

 If you're only looking for the occurrence of a string and not a  
regex pattern, you don't have to use regular expressions:


if "locale for" in line:
 print line


 Works just as well, and is faster.

-- Max
maxnoel_fr at yahoo dot fr -- ICQ #85274019
"Look at you hacker... A pathetic creature of meat and bone, panting  
and sweating as you run through my corridors... How can you challenge  
a perfect, immortal machine?"

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] [HELP]win32 shutdown, restart, logoff

2005-05-22 Thread Shidai Liu
Hi all,

Any one know how to make a shutdown, restart, logoff call in windows os like 98, 2000 and xp?
Implemented in python, can use python win32 extensions. But not os.system('rundll/shutodwn ...').

Thanks for your help.-- With best wishes!Shidai
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] difference between [[], [], []] and 3*[[]]

2005-05-22 Thread Mitsuo Hashimoto
2005/5/21, Kent Johnson <[EMAIL PROTECTED]>:

> 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]]

I see.

> Often using a dict is a good solution to this type of question.

I didn't notice a dict.

Thank you,

Mitsuo
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] __init__.py

2005-05-22 Thread Joseph Quigley
I've seen many (python) "plugins" (some located in site-packages [windows 
here]) with the name __init__.py.
What's their use?
class foo:
def __init__:
print "this starts first"
def foo1():
print "this comes later. Init initializes the chain of 
functions in this 
class

Now, i've never used a program (i can't seem to grasp all the self, and 
other things in OOP yet) with __init__ but I know what __init__ does in a 
class, not as a file name.
I'm asking this out of curiosity, not for help.
JQ

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] [HELP]win32 shutdown, restart, logoff

2005-05-22 Thread jfouhy
Quoting Shidai Liu <[EMAIL PROTECTED]>:

> Any one know how to make a shutdown, restart, logoff call in windows os
> like 98, 2000 and xp?

Try this: win32api.InitiateSystemShutdown(None, 'Kaboom!', 2000, False, False)

Parameters:
 1. Computer to shutdown (None for lcoalhost)
 2. Message to display.
 3. Time in ms to display message (0 for no message).
 4. Kill programs (False to allow user a chance to save their work).
 5. Reboot or shutdown.

If you are doing win32 programming, I strongly recommend Mark Hammond's book!
(since that's where I got this information)

Note that I have not tested this (in particular, it is possible I have the
orientation of the two boolean parameters wrong).

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] [HELP]win32 shutdown, restart, logoff

2005-05-22 Thread Shidai Liu
On 5/23/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
Quoting Shidai Liu <[EMAIL PROTECTED]
>:> Any one know how to make a shutdown, restart, logoff call in windows os> like 98, 2000 and xp?Try this: win32api.InitiateSystemShutdown(None, 'Kaboom!', 2000, False, False)Parameters:
 1. Computer to shutdown (None for lcoalhost) 2. Message to display. 3. Time in ms to display message (0 for no message). 4. Kill programs (False to allow user a chance to save their work). 5. Reboot or shutdown.
If you are doing win32 programming, I strongly recommend Mark Hammond's book!(since that's where I got this information)Note that I have not tested this (in particular, it is possible I have theorientation of the two boolean parameters wrong).

Thanks John.

I have the local machine's administration privilege. But my machine is
logged in a local network which disables shutdown, restart functions
(Group policy?). When I run the command as you point out, I got the
following messages

(5, 'InitiateSystemShutdown', 'Access is denied.')

I have noticed for some software which require restart, it can restart
properly. Does that mean software restart is possbile? If yes, any idea?
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] __init__.py

2005-05-22 Thread Shidai Liu
On 5/23/05, Joseph Quigley <[EMAIL PROTECTED]> wrote:
I've seen many (python) "plugins" (some located in site-packages [windowshere]) with the name __init__.py.What's their use?class foo:def __init__:print "this starts first"
def foo1():print
"this comes later. Init initializes the chain of functions in thisclassNow, i've never used a program (i can't seem to grasp all the self, andother things in OOP yet) with __init__ but I know what __init__ does in a
class, not as a file name.I'm asking this out of curiosity, not for help.JQ
__init__.py will be executed when a package is imported.

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] [HELP]win32 shutdown, restart, logoff

2005-05-22 Thread Tony Meyer
> I have the local machine's administration privilege.
[...]
> When I run the command as you point out, I got the following
> messages
>
> (5, 'InitiateSystemShutdown', 'Access is denied.')

The process itself needs to have the privilege.  This message has complete
instructions:



=Tony.Meyer

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] __init__.py

2005-05-22 Thread Joseph Quigley

>__init__.py will be executed when a package is imported.

Oh. So it will (for instance) compile .py to .pyc after the installation is 
finished.
Nice. Thanks,
 JQ 

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] __init__.py

2005-05-22 Thread Lee Cullens
Joseph,

I'm relatively new to Python, but I might be able to help with your  
question.

First, think of the convention "self" (or sometimes "me" in other  
languages) as a reference to a specific instance derived from a  
class.  When you reference an inherited  class method of an instance,  
the specific instance address is automatically passed as the first  
argument.  There is nothing special about the label "self" by itself  
(you could use instance_ref for example), but it is a convention that  
makes your code more easily understood.  If I've used any  
inappropriate Python terminology, maybe someone will correct such :~)

Now your real question.  In my limited Python experience so far the  
module (file) __init__.py is used with module packages (multiple  
directories involved).  Let's say you want to use "import  
dir1.dir2.mod" because you have structured you package something like:

dir0/
  dir1/
   __init__.py
   dir2/
__init__.py
mod.py
another_mod.py
   dir3/
__init__.py
yet_another_mod.py


Two things here:

1) The container directory (dir0) needs to be added to your module  
search path, unless it's the directory of the importing module.

2) Each directory named in the package import statement must contain  
a file called __init__.py   These may be empty files (used by Python  
in the package initialization phase) and are not meant to be executed  
directly.  However you could use such to create a data file, connect  
to a database, etc.


Package imports can be used to simplify your PYTHONPATH/.pth search  
path settings.  If you have cross-directory imports, you might make  
such relative to a common root directly.

We'll let the experts take it from there.

Lee C


On May 22, 2005, at 7:54 PM, Joseph Quigley wrote:


> I've seen many (python) "plugins" (some located in site-packages  
> [windows
> here]) with the name __init__.py.
> What's their use?
> class foo:
> def __init__:
> print "this starts first"
> def foo1():
> print "this comes later. Init initializes the chain of  
> functions in this
> class
>
> Now, i've never used a program (i can't seem to grasp all the self,  
> and
> other things in OOP yet) with __init__ but I know what __init__  
> does in a
> class, not as a file name.
> I'm asking this out of curiosity, not for help.
> JQ
>
> ___
> 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] looking for a pattern in a lot of files

2005-05-22 Thread Kent Johnson
Jonas Melian wrote:
> any improvement about this code?
> how print the actual file?

You can print the file name and line number using fileinput.filename() and 
fileinput.filelineno()

> could i add an exception? by if there aren't files

Set a flag if you print anything, check it at the end of the loop

Kent
> 
> 
> for line in fileinput.input(glob.glob(os.path.join
> (dir_locales, "*_[A-Z][A-Z]"))):
> if re.search("locale for", line):
> print line
> ___
> 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] Checking and showing all errors before of exit

2005-05-22 Thread Kent Johnson
Jonas Melian wrote:
> 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.

I don't understand your question. Can you give an example of what you would 
like to do?

Kent

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] installing python 2.4.1 over 2.4

2005-05-22 Thread Kent Johnson
The 2.4.1 installer will install over you existing 2.4 install. I don't think 
it will affect the ides.

Kent

Pujo Aji wrote:
> Hello,
> 
> I have python 2.4.
> I would like to install python 2.4.1, Should I uninstall python 2.4,
> or just install 2.4.1?
> 
> Does it effect my ide such as pydev and komodo ?
> 
> Sincerely Yours,
> pujo
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
> 

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor