Re: [Tutor] mamelauncher (fwd)

2005-09-14 Thread Alan G

> There actually seems to be a bit of a problem in the
> interaction with the system when it launches mame.
> 
> If I run this:
> 
> import os
> 
> def run_mame_selection(selection):
>os.system("C:\\mame096b\\mame.exe"+ selection)
>  
> #main
> selection = " tnzs"
> run_mame_selection(selection)
> raw_input()
> 
> mame reports files missing, but I can launch the game
> manually- I suspect that this is some sort of error
> that occurs normally but is bypassed on launch and
> that  my one-shot attempt to launch the thing cannot
> handle. I think I need to have a wee look at
> subprocess!

Subprocess is not likely to help. This is more likely to 
do with getting the right command set up for system to execute.

How did you get on with Danny's suggestions for launching Pacman?

When you launch it directly are you in the same directory 
as the game? Could it be looking for files in the current 
directory and not finding them where the python script lives?

Switching to Subprocess might have a few advantages later, 
but for now is simply going to distract from the real problem.

Also can you post the error messages you get, its much easier 
for us to figure out where the errors are occuring if we see 
the full error text.

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


Re: [Tutor] (no subject)

2005-09-14 Thread Alan G
>I am new to Python, about 1 day. And I downloaded from
> python.org Pythong2.4, it has the command line and
> junk. But what actuall program compiles the source of
> python into a program? 

When you run a python script python compiles the source 
internally before executing it. If your program imports 
modules, the imported code gets converted into compiled 
code and you will see it in the form of .pyc files.

Python works in a similar fashion to VB and Java in that 
it executes compiled byte code, not native machine code.
The Python program has the same function as both the 
Java compiler and JVM interpreter.

If you use Jython instead of Python you will find a separate 
python compiler that produces true Java code that then 
can be run under any JVM.

If you want to produce standalone windows executables 
there are several tools available, the simplest and 
most widely used being py2exe. This is not part of the 
standard distribution however. Basically what all these 
tools do is wrap the Python program and all of the 
modules you use into one single executable file - so 
its quite big and if you distribute several programs 
you duplicate python with each one!! In this case 
distributing the python scripts with a one-off version
of Python is a better option.

The included distutils package can simplify that process.

> And also, is Python capable of writing an OS?

Not really since python requires the python program to 
be present in some form and it itself needs an underlying 
OS. You could write an OS simulation as a learning 
excercise but it would need a minimal OS underlying it.
Python is a high level programming language aimed at 
developing applications with the minimum effort. If you 
really need to twiddle the bits n' bytes you are better 
off with C or assembler, just be prepared to write a 
lot of code...

HTH,

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


Re: [Tutor] Python as operating system?

2005-09-14 Thread Alan G
> MrEd/DrScheme is another compelling example of a system that could 
> be
> considered a high-level operating system, given the environment that 
> they
> expose.  The paper: 
> http://www.ccs.neu.edu/scheme/pubs/icfp99-ffkf.pdf
> talks about this in more detail.]

I have a friend who teaches Common Lisp programming at Columbia
University and he wrote a virtual Operating System in Lisp for
his courses. These pseudo OS environments are useful for learning
and allowing 'safe' modification of the OS without getting into
the murky deails of C but ultimately they all need a real OS
underneath to talk to the hardware.

Alan G. 

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


Re: [Tutor] Another regular expression question

2005-09-14 Thread Alan G
Hi Bernard,

> Hello, yet another regular expression question :-)
>
> So I have this xml file that I'm trying to find a 
> specific tag in. 

I'm always suspicious when I see regular expression 
and xml/html in the same context. regex are not good 
for parsing xml/html files and it's usually much easier 
to use a proper parser - such as beautiful soup.

http://www.crummy.com/software/BeautifulSoup/

Is there any special reason why you are using a regex 
sledgehammer to crack this particular nut? Or is it 
just to gain experience using regex?

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


Re: [Tutor] (no subject)

2005-09-14 Thread Carlos Eduardo Sotelo Pinto
Hi List.
All of you are right. It is similar to java, vb, but how it work?

Well, python script generates a compiled bytecode the first time that 
yuou run the main script in a machinne, and the interpreter execute this 
byte code.

It could be slower than a compiled language, because use an interpreter 
to run, but it is faster than a interepreted language, because the 
interpreted language ot generated a byt code, this one reads the secripts.

About operating system, it coulbe posible, but not at all. First to run 
an operative systems you need a low level language, like assembler, it 
could began the os, but the kernel could be in python.
just a c library or gcc and python interpreter. if you use assembler to 
run with c, u can use python for your python os


Alan G wrote:
>>I am new to Python, about 1 day. And I downloaded from
>>python.org Pythong2.4, it has the command line and
>>junk. But what actuall program compiles the source of
>>python into a program? 
> 
> 
> When you run a python script python compiles the source 
> internally before executing it. If your program imports 
> modules, the imported code gets converted into compiled 
> code and you will see it in the form of .pyc files.
> 
> Python works in a similar fashion to VB and Java in that 
> it executes compiled byte code, not native machine code.
> The Python program has the same function as both the 
> Java compiler and JVM interpreter.
> 
> If you use Jython instead of Python you will find a separate 
> python compiler that produces true Java code that then 
> can be run under any JVM.
> 
> If you want to produce standalone windows executables 
> there are several tools available, the simplest and 
> most widely used being py2exe. This is not part of the 
> standard distribution however. Basically what all these 
> tools do is wrap the Python program and all of the 
> modules you use into one single executable file - so 
> its quite big and if you distribute several programs 
> you duplicate python with each one!! In this case 
> distributing the python scripts with a one-off version
> of Python is a better option.
> 
> The included distutils package can simplify that process.
> 
> 
>>And also, is Python capable of writing an OS?
> 
> 
> Not really since python requires the python program to 
> be present in some form and it itself needs an underlying 
> OS. You could write an OS simulation as a learning 
> excercise but it would need a minimal OS underlying it.
> Python is a high level programming language aimed at 
> developing applications with the minimum effort. If you 
> really need to twiddle the bits n' bytes you are better 
> off with C or assembler, just be prepared to write a 
> lot of code...
> 
> HTH,
> 
> 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
> 


-- 
Atentamente:

**  ,= ,-_-. =.
|Carlos E. Sotelo Pinto(KrLoS)   | ((_/)o o(\_))
|GNU/Linux User Registered # 379182  |  `-'(. .)`-'
|Tildes omitidas voluntariamente |  \_/
**
Bitacora de Vuelo 
Sociedad Peruana de Computacion 
Grupo de Usuarios GNU/Linux Arequipa 
Grupo de Usuarios Debian Arequipa 
Grupo de Usuarios Debian Peru 

La actitud del hacker:
Los hackers resuelven problemas y construyen cosas, y creen en la 
libertad y la ayuda voluntaria mutua. Para ser aceptado como hacker, 
deberás comportarte como si tuvieras esta actitud en tu interior. Y para 
comportarte como si tuvieras esta actitud, deberás creerte de verdad 
dicha actitud.





__ 
Renovamos el Correo Yahoo! 
Nuevos servicios, más seguridad 
http://correo.yahoo.es
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Another regular expression question

2005-09-14 Thread Bernard Lebel
Thanks Alan,

I'll check BeautifulSoup asap.

I'm using regex simply because I have no clue where to start to parse
XML. I have read the various xml tools available in the Python
library, however I'm a complete loss at what to make out of them. Many
of them seem to use some programming standards, wich I am completely
unfamiliar with (this is the first time that I dig into XML writing
and parsing).

I don't know where to start to learn about all these standards, and as
usual with new programming things, the documentation is hard to
swallow (it usually is written more as a reference than a proper user
guide/tutorial). I have to admit this is very frustrating, so if I'm
looking at things from a wrong perspective please advise me, I need
it.

So right now I'm just taking a shortcut and using ultra-simple
re-based parser to retrieve the tags I'm looking for. I know it will
probably be slow, but hopefully I'll get familiar with sophisticated
parsing in the future and improve my code. As it stands right now,
even the re syntax is not super easy to learn.


Kent: That works (of course!). Thanks a bunch once again!


Thanks
Bernard

On 9/14/05, Alan G <[EMAIL PROTECTED]> wrote:
> Hi Bernard,
> 
> > Hello, yet another regular expression question :-)
> >
> > So I have this xml file that I'm trying to find a
> > specific tag in.
> 
> I'm always suspicious when I see regular expression
> and xml/html in the same context. regex are not good
> for parsing xml/html files and it's usually much easier
> to use a proper parser - such as beautiful soup.
> 
> http://www.crummy.com/software/BeautifulSoup/
> 
> Is there any special reason why you are using a regex
> sledgehammer to crack this particular nut? Or is it
> just to gain experience using regex?
> 
> Alan G.
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Another regular expression question

2005-09-14 Thread Kent Johnson
Bernard Lebel wrote:
> Thanks Alan,
> 
> I'll check BeautifulSoup asap.
> 
> I'm using regex simply because I have no clue where to start to parse
> XML. I have read the various xml tools available in the Python
> library, however I'm a complete loss at what to make out of them. Many
> of them seem to use some programming standards, wich I am completely
> unfamiliar with (this is the first time that I dig into XML writing
> and parsing).
> 
> I don't know where to start to learn about all these standards, and as
> usual with new programming things, the documentation is hard to
> swallow (it usually is written more as a reference than a proper user
> guide/tutorial). I have to admit this is very frustrating, so if I'm
> looking at things from a wrong perspective please advise me, I need
> it.

I agree that the Python XML story is confusing even for the files in the 
standard library. Worse, the (IMO) best solutions are not to be found in the 
standard lib or PyXML at all.

The std lib and PyXML are based on the DOM and SAX standards. These standards 
were designed to be "language-neutral" - there are implementations in Python, 
Java and other languages. The good side of this is, if you learn how to use 
them, the knowledge is pretty portable to other languages. The bad side is, the 
APIs defined by the standard are IMO clunky and painful to use, especially in 
Python.

There is a current thread on comp.lang.python discussing this with good 
suggestions and pointers to more info:
http://groups.google.com/group/comp.lang.python/browse_frm/thread/a48891aa645ead13/dcd8fdc20b4b191b?hl=en#dcd8fdc20b4b191b

My personal preference is ElementTree. Beautiful Soup is good too though I have 
only tried it with HTML. If I was running on Linux I would try lxml which uses 
the ElementTree API and adds full XPath support. Amara looks like the Cadillac 
solution - big and cushy. I haven't tried it. Uche's articles (referenced in 
the thread above) have pointers to many other choices but these seem to be the 
most popular.

My favorite XML lib is actually dom4j which is in Java. It works great with 
Jython.

Kent

> 
> So right now I'm just taking a shortcut and using ultra-simple
> re-based parser to retrieve the tags I'm looking for. I know it will
> probably be slow, but hopefully I'll get familiar with sophisticated
> parsing in the future and improve my code. As it stands right now,
> even the re syntax is not super easy to learn.

For what you are doing re seems fine to me. You can get in trouble using re's 
with XML because of nested tags, variations in spelling and order, probably a 
bunch of other things. But for simple stuff it can work fine.

Kent

> 
> 
> Kent: That works (of course!). Thanks a bunch once again!
> 
> 
> Thanks
> Bernard
> 
> On 9/14/05, Alan G <[EMAIL PROTECTED]> wrote:
> 
>>Hi Bernard,
>>
>>
>>>Hello, yet another regular expression question :-)
>>>
>>>So I have this xml file that I'm trying to find a
>>>specific tag in.
>>
>>I'm always suspicious when I see regular expression
>>and xml/html in the same context. regex are not good
>>for parsing xml/html files and it's usually much easier
>>to use a proper parser - such as beautiful soup.
>>
>>http://www.crummy.com/software/BeautifulSoup/
>>
>>Is there any special reason why you are using a regex
>>sledgehammer to crack this particular nut? Or is it
>>just to gain experience using regex?
>>
>>Alan G.
>>
> 
> ___
> 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] More IDE's (was: Boa-Constructor)

2005-09-14 Thread George Flaherty
Yeah, I have been using PyDev with Eclipse. It is pretty good, since with the 
latest version the debugger is working and they have include the ability to add 
additional paths in the PYTHONPATH variable.

I honestly would prefer to use Emacs, but I have not found any tool that 
provides code-completion with python. Until I have been using Eclipse (with 
Emacs running minimized :)

-g

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of D. Hartley
Sent: Tuesday, September 13, 2005 10:27 PM
To: Python tutor
Subject: [Tutor] More IDE's (was: Boa-Constructor)

This thread made me wonder:

Is anyone out there using Eclipse and PyDev? (I started using Eclipse when I 
was toying around in Jython, and know others that are using it for C/C++, but I 
am curious if others have tried out PyDev and what they think).

~Denise
___
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] Another regular expression question

2005-09-14 Thread Bernard Lebel
Thanks for that pointer Kent, I'll check it out. Also thanks for
letting me know I'm not nuts! :-)

Alan's suggestion about BeautifulSoup is actually excellent. The
documentation is nice and the tool is very easy to use.

However is it normal that to parse a 2618 lines xml file it takes
20-30 seconds or so?


Thanks
Bernard



On 9/14/05, Kent Johnson <[EMAIL PROTECTED]> wrote:
> Bernard Lebel wrote:
> > Thanks Alan,
> >
> > I'll check BeautifulSoup asap.
> >
> > I'm using regex simply because I have no clue where to start to parse
> > XML. I have read the various xml tools available in the Python
> > library, however I'm a complete loss at what to make out of them. Many
> > of them seem to use some programming standards, wich I am completely
> > unfamiliar with (this is the first time that I dig into XML writing
> > and parsing).
> >
> > I don't know where to start to learn about all these standards, and as
> > usual with new programming things, the documentation is hard to
> > swallow (it usually is written more as a reference than a proper user
> > guide/tutorial). I have to admit this is very frustrating, so if I'm
> > looking at things from a wrong perspective please advise me, I need
> > it.
> 
> I agree that the Python XML story is confusing even for the files in the 
> standard library. Worse, the (IMO) best solutions are not to be found in the 
> standard lib or PyXML at all.
> 
> The std lib and PyXML are based on the DOM and SAX standards. These standards 
> were designed to be "language-neutral" - there are implementations in Python, 
> Java and other languages. The good side of this is, if you learn how to use 
> them, the knowledge is pretty portable to other languages. The bad side is, 
> the APIs defined by the standard are IMO clunky and painful to use, 
> especially in Python.
> 
> There is a current thread on comp.lang.python discussing this with good 
> suggestions and pointers to more info:
> http://groups.google.com/group/comp.lang.python/browse_frm/thread/a48891aa645ead13/dcd8fdc20b4b191b?hl=en#dcd8fdc20b4b191b
> 
> My personal preference is ElementTree. Beautiful Soup is good too though I 
> have only tried it with HTML. If I was running on Linux I would try lxml 
> which uses the ElementTree API and adds full XPath support. Amara looks like 
> the Cadillac solution - big and cushy. I haven't tried it. Uche's articles 
> (referenced in the thread above) have pointers to many other choices but 
> these seem to be the most popular.
> 
> My favorite XML lib is actually dom4j which is in Java. It works great with 
> Jython.
> 
> Kent
> 
> >
> > So right now I'm just taking a shortcut and using ultra-simple
> > re-based parser to retrieve the tags I'm looking for. I know it will
> > probably be slow, but hopefully I'll get familiar with sophisticated
> > parsing in the future and improve my code. As it stands right now,
> > even the re syntax is not super easy to learn.
> 
> For what you are doing re seems fine to me. You can get in trouble using re's 
> with XML because of nested tags, variations in spelling and order, probably a 
> bunch of other things. But for simple stuff it can work fine.
> 
> Kent
> 
> >
> >
> > Kent: That works (of course!). Thanks a bunch once again!
> >
> >
> > Thanks
> > Bernard
> >
> > On 9/14/05, Alan G <[EMAIL PROTECTED]> wrote:
> >
> >>Hi Bernard,
> >>
> >>
> >>>Hello, yet another regular expression question :-)
> >>>
> >>>So I have this xml file that I'm trying to find a
> >>>specific tag in.
> >>
> >>I'm always suspicious when I see regular expression
> >>and xml/html in the same context. regex are not good
> >>for parsing xml/html files and it's usually much easier
> >>to use a proper parser - such as beautiful soup.
> >>
> >>http://www.crummy.com/software/BeautifulSoup/
> >>
> >>Is there any special reason why you are using a regex
> >>sledgehammer to crack this particular nut? Or is it
> >>just to gain experience using regex?
> >>
> >>Alan G.
> >>
> >
> > ___
> > Tutor maillist  -  Tutor@python.org
> > http://mail.python.org/mailman/listinfo/tutor
> >
> >
> 
> ___
> 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] Another regular expression question

2005-09-14 Thread Kent Johnson
Bernard Lebel wrote:
> Thanks for that pointer Kent, I'll check it out. Also thanks for
> letting me know I'm not nuts! :-)
> 
> Alan's suggestion about BeautifulSoup is actually excellent. The
> documentation is nice and the tool is very easy to use.
> 
> However is it normal that to parse a 2618 lines xml file it takes
> 20-30 seconds or so?

That seems slow to me unless the lines are really long! How many bytes is the 
file? But I don't have much experience with BeautifulSoup.

ElementTree is fast and cElementTree (the C implementation) is really fast. I 
have used it to read, process and write a 28 MB XML file, it took about 10 
seconds.

Kent

> 
> 
> Thanks
> Bernard
> 
> 
> 
> On 9/14/05, Kent Johnson <[EMAIL PROTECTED]> wrote:
> 
>>Bernard Lebel wrote:
>>
>>>Thanks Alan,
>>>
>>>I'll check BeautifulSoup asap.
>>>
>>>I'm using regex simply because I have no clue where to start to parse
>>>XML. I have read the various xml tools available in the Python
>>>library, however I'm a complete loss at what to make out of them. Many
>>>of them seem to use some programming standards, wich I am completely
>>>unfamiliar with (this is the first time that I dig into XML writing
>>>and parsing).
>>>
>>>I don't know where to start to learn about all these standards, and as
>>>usual with new programming things, the documentation is hard to
>>>swallow (it usually is written more as a reference than a proper user
>>>guide/tutorial). I have to admit this is very frustrating, so if I'm
>>>looking at things from a wrong perspective please advise me, I need
>>>it.
>>
>>I agree that the Python XML story is confusing even for the files in the 
>>standard library. Worse, the (IMO) best solutions are not to be found in the 
>>standard lib or PyXML at all.
>>
>>The std lib and PyXML are based on the DOM and SAX standards. These standards 
>>were designed to be "language-neutral" - there are implementations in Python, 
>>Java and other languages. The good side of this is, if you learn how to use 
>>them, the knowledge is pretty portable to other languages. The bad side is, 
>>the APIs defined by the standard are IMO clunky and painful to use, 
>>especially in Python.
>>
>>There is a current thread on comp.lang.python discussing this with good 
>>suggestions and pointers to more info:
>>http://groups.google.com/group/comp.lang.python/browse_frm/thread/a48891aa645ead13/dcd8fdc20b4b191b?hl=en#dcd8fdc20b4b191b
>>
>>My personal preference is ElementTree. Beautiful Soup is good too though I 
>>have only tried it with HTML. If I was running on Linux I would try lxml 
>>which uses the ElementTree API and adds full XPath support. Amara looks like 
>>the Cadillac solution - big and cushy. I haven't tried it. Uche's articles 
>>(referenced in the thread above) have pointers to many other choices but 
>>these seem to be the most popular.
>>
>>My favorite XML lib is actually dom4j which is in Java. It works great with 
>>Jython.
>>
>>Kent
>>
>>
>>>So right now I'm just taking a shortcut and using ultra-simple
>>>re-based parser to retrieve the tags I'm looking for. I know it will
>>>probably be slow, but hopefully I'll get familiar with sophisticated
>>>parsing in the future and improve my code. As it stands right now,
>>>even the re syntax is not super easy to learn.
>>
>>For what you are doing re seems fine to me. You can get in trouble using re's 
>>with XML because of nested tags, variations in spelling and order, probably a 
>>bunch of other things. But for simple stuff it can work fine.
>>
>>Kent
>>
>>
>>>
>>>Kent: That works (of course!). Thanks a bunch once again!
>>>
>>>
>>>Thanks
>>>Bernard
>>>
>>>On 9/14/05, Alan G <[EMAIL PROTECTED]> wrote:
>>>
>>>
Hi Bernard,



>Hello, yet another regular expression question :-)
>
>So I have this xml file that I'm trying to find a
>specific tag in.

I'm always suspicious when I see regular expression
and xml/html in the same context. regex are not good
for parsing xml/html files and it's usually much easier
to use a proper parser - such as beautiful soup.

http://www.crummy.com/software/BeautifulSoup/

Is there any special reason why you are using a regex
sledgehammer to crack this particular nut? Or is it
just to gain experience using regex?

Alan G.

>>>
>>>___
>>>Tutor maillist  -  Tutor@python.org
>>>http://mail.python.org/mailman/listinfo/tutor
>>>
>>>
>>
>>___
>>Tutor maillist  -  Tutor@python.org
>>http://mail.python.org/mailman/listinfo/tutor
>>
> 
> ___
> 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] Another regular expression question

2005-09-14 Thread Bernard Lebel
The file size is 112 Kb. Most lines look this way:




I'll give a try to ElementTree.


Bernard



On 9/14/05, Kent Johnson <[EMAIL PROTECTED]> wrote:
> Bernard Lebel wrote:
> > Thanks for that pointer Kent, I'll check it out. Also thanks for
> > letting me know I'm not nuts! :-)
> >
> > Alan's suggestion about BeautifulSoup is actually excellent. The
> > documentation is nice and the tool is very easy to use.
> >
> > However is it normal that to parse a 2618 lines xml file it takes
> > 20-30 seconds or so?
> 
> That seems slow to me unless the lines are really long! How many bytes is the 
> file? But I don't have much experience with BeautifulSoup.
> 
> ElementTree is fast and cElementTree (the C implementation) is really fast. I 
> have used it to read, process and write a 28 MB XML file, it took about 10 
> seconds.
> 
> Kent
> 
> >
> >
> > Thanks
> > Bernard
> >
> >
> >
> > On 9/14/05, Kent Johnson <[EMAIL PROTECTED]> wrote:
> >
> >>Bernard Lebel wrote:
> >>
> >>>Thanks Alan,
> >>>
> >>>I'll check BeautifulSoup asap.
> >>>
> >>>I'm using regex simply because I have no clue where to start to parse
> >>>XML. I have read the various xml tools available in the Python
> >>>library, however I'm a complete loss at what to make out of them. Many
> >>>of them seem to use some programming standards, wich I am completely
> >>>unfamiliar with (this is the first time that I dig into XML writing
> >>>and parsing).
> >>>
> >>>I don't know where to start to learn about all these standards, and as
> >>>usual with new programming things, the documentation is hard to
> >>>swallow (it usually is written more as a reference than a proper user
> >>>guide/tutorial). I have to admit this is very frustrating, so if I'm
> >>>looking at things from a wrong perspective please advise me, I need
> >>>it.
> >>
> >>I agree that the Python XML story is confusing even for the files in the 
> >>standard library. Worse, the (IMO) best solutions are not to be found in 
> >>the standard lib or PyXML at all.
> >>
> >>The std lib and PyXML are based on the DOM and SAX standards. These 
> >>standards were designed to be "language-neutral" - there are 
> >>implementations in Python, Java and other languages. The good side of this 
> >>is, if you learn how to use them, the knowledge is pretty portable to other 
> >>languages. The bad side is, the APIs defined by the standard are IMO clunky 
> >>and painful to use, especially in Python.
> >>
> >>There is a current thread on comp.lang.python discussing this with good 
> >>suggestions and pointers to more info:
> >>http://groups.google.com/group/comp.lang.python/browse_frm/thread/a48891aa645ead13/dcd8fdc20b4b191b?hl=en#dcd8fdc20b4b191b
> >>
> >>My personal preference is ElementTree. Beautiful Soup is good too though I 
> >>have only tried it with HTML. If I was running on Linux I would try lxml 
> >>which uses the ElementTree API and adds full XPath support. Amara looks 
> >>like the Cadillac solution - big and cushy. I haven't tried it. Uche's 
> >>articles (referenced in the thread above) have pointers to many other 
> >>choices but these seem to be the most popular.
> >>
> >>My favorite XML lib is actually dom4j which is in Java. It works great with 
> >>Jython.
> >>
> >>Kent
> >>
> >>
> >>>So right now I'm just taking a shortcut and using ultra-simple
> >>>re-based parser to retrieve the tags I'm looking for. I know it will
> >>>probably be slow, but hopefully I'll get familiar with sophisticated
> >>>parsing in the future and improve my code. As it stands right now,
> >>>even the re syntax is not super easy to learn.
> >>
> >>For what you are doing re seems fine to me. You can get in trouble using 
> >>re's with XML because of nested tags, variations in spelling and order, 
> >>probably a bunch of other things. But for simple stuff it can work fine.
> >>
> >>Kent
> >>
> >>
> >>>
> >>>Kent: That works (of course!). Thanks a bunch once again!
> >>>
> >>>
> >>>Thanks
> >>>Bernard
> >>>
> >>>On 9/14/05, Alan G <[EMAIL PROTECTED]> wrote:
> >>>
> >>>
> Hi Bernard,
> 
> 
> 
> >Hello, yet another regular expression question :-)
> >
> >So I have this xml file that I'm trying to find a
> >specific tag in.
> 
> I'm always suspicious when I see regular expression
> and xml/html in the same context. regex are not good
> for parsing xml/html files and it's usually much easier
> to use a proper parser - such as beautiful soup.
> 
> http://www.crummy.com/software/BeautifulSoup/
> 
> Is there any special reason why you are using a regex
> sledgehammer to crack this particular nut? Or is it
> just to gain experience using regex?
> 
> Alan G.
> 
> >>>
> >>>___
> >>>Tutor maillist  -  Tutor@python.org
> >>>http://mail.python.org/mailman/listinfo/tutor
> >>>
> >>>
> >>
> >>___
> >>Tutor maillist  -  Tutor@python.org
> >>http://mail.python.

Re: [Tutor] Another regular expression question

2005-09-14 Thread Kent Johnson
Bernard Lebel wrote:
> The file size is 112 Kb. Most lines look this way:
> 
> 
> 
> 
> I'll give a try to ElementTree.

To get you started:

from elementtree import ElementTree
doc = ElementTree.parse('myfile.xml')
for sceneobject in doc.findall('//sceneobject'):
  if sceneobject.get('type') == 'CameraRoot':
# this is a sceneobject that you want
print sceneobject.get('name')

One gotcha - if your XML uses namespaces, you have to prefix the namespace to 
the tag name in findall(). It will look something like
  d.findall('//{http://www.imsproject.org/xsd/imscp_rootv1p1p2}resource')

Let us know how long that takes...

Kent

> 
> 
> Bernard
> 
> 
> 
> On 9/14/05, Kent Johnson <[EMAIL PROTECTED]> wrote:
> 
>>Bernard Lebel wrote:
>>
>>>Thanks for that pointer Kent, I'll check it out. Also thanks for
>>>letting me know I'm not nuts! :-)
>>>
>>>Alan's suggestion about BeautifulSoup is actually excellent. The
>>>documentation is nice and the tool is very easy to use.
>>>
>>>However is it normal that to parse a 2618 lines xml file it takes
>>>20-30 seconds or so?
>>
>>That seems slow to me unless the lines are really long! How many bytes is the 
>>file? But I don't have much experience with BeautifulSoup.
>>
>>ElementTree is fast and cElementTree (the C implementation) is really fast. I 
>>have used it to read, process and write a 28 MB XML file, it took about 10 
>>seconds.
>>
>>Kent
>>
>>
>>>
>>>Thanks
>>>Bernard
>>>
>>>
>>>
>>>On 9/14/05, Kent Johnson <[EMAIL PROTECTED]> wrote:
>>>
>>>
Bernard Lebel wrote:


>Thanks Alan,
>
>I'll check BeautifulSoup asap.
>
>I'm using regex simply because I have no clue where to start to parse
>XML. I have read the various xml tools available in the Python
>library, however I'm a complete loss at what to make out of them. Many
>of them seem to use some programming standards, wich I am completely
>unfamiliar with (this is the first time that I dig into XML writing
>and parsing).
>
>I don't know where to start to learn about all these standards, and as
>usual with new programming things, the documentation is hard to
>swallow (it usually is written more as a reference than a proper user
>guide/tutorial). I have to admit this is very frustrating, so if I'm
>looking at things from a wrong perspective please advise me, I need
>it.

I agree that the Python XML story is confusing even for the files in the 
standard library. Worse, the (IMO) best solutions are not to be found in 
the standard lib or PyXML at all.

The std lib and PyXML are based on the DOM and SAX standards. These 
standards were designed to be "language-neutral" - there are 
implementations in Python, Java and other languages. The good side of this 
is, if you learn how to use them, the knowledge is pretty portable to other 
languages. The bad side is, the APIs defined by the standard are IMO clunky 
and painful to use, especially in Python.

There is a current thread on comp.lang.python discussing this with good 
suggestions and pointers to more info:
http://groups.google.com/group/comp.lang.python/browse_frm/thread/a48891aa645ead13/dcd8fdc20b4b191b?hl=en#dcd8fdc20b4b191b

My personal preference is ElementTree. Beautiful Soup is good too though I 
have only tried it with HTML. If I was running on Linux I would try lxml 
which uses the ElementTree API and adds full XPath support. Amara looks 
like the Cadillac solution - big and cushy. I haven't tried it. Uche's 
articles (referenced in the thread above) have pointers to many other 
choices but these seem to be the most popular.

My favorite XML lib is actually dom4j which is in Java. It works great with 
Jython.

Kent



>So right now I'm just taking a shortcut and using ultra-simple
>re-based parser to retrieve the tags I'm looking for. I know it will
>probably be slow, but hopefully I'll get familiar with sophisticated
>parsing in the future and improve my code. As it stands right now,
>even the re syntax is not super easy to learn.

For what you are doing re seems fine to me. You can get in trouble using 
re's with XML because of nested tags, variations in spelling and order, 
probably a bunch of other things. But for simple stuff it can work fine.

Kent



>Kent: That works (of course!). Thanks a bunch once again!
>
>
>Thanks
>Bernard
>
>On 9/14/05, Alan G <[EMAIL PROTECTED]> wrote:
>
>
>
>>Hi Bernard,
>>
>>
>>
>>
>>>Hello, yet another regular expression question :-)
>>>
>>>So I have this xml file that I'm trying to find a
>>>specific tag in.
>>
>>I'm always suspicious when I see regular expression
>>and xml/html in the same context. regex are not good
>>for parsing xml/html files and it's usually much easier
>

Re: [Tutor] IDEs

2005-09-14 Thread Matt Williams
I've used both PyDev and Wing IDE.

PyDev seems good, and is getting better. 
Wing is pay-for (although only $40 or so), but can be trialled. I thought
it was good, but had a huge problem trying to get it to play with a C library
I was using...

I've never managed to get Boa-Constructor to run...

As regards using wxPython - I thought it was ok, but frankly Glade was s
much easier..

(all IMHO)

Matt

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


Re: [Tutor] Another regular expression question

2005-09-14 Thread Bernard Lebel
Hi Kent,

Well even before reading your last email I gave it a go, just parsing
the xml file and trying out some basic functions. It ran in less than
two seconds. I don't know why BeautifulSoup is taking so long...

Thanks for the "to get you started"!


Bernard



On 9/14/05, Kent Johnson <[EMAIL PROTECTED]> wrote:
> Bernard Lebel wrote:
> > The file size is 112 Kb. Most lines look this way:
> >
> > 
> >
> >
> > I'll give a try to ElementTree.
> 
> To get you started:
> 
> from elementtree import ElementTree
> doc = ElementTree.parse('myfile.xml')
> for sceneobject in doc.findall('//sceneobject'):
>   if sceneobject.get('type') == 'CameraRoot':
> # this is a sceneobject that you want
> print sceneobject.get('name')
> 
> One gotcha - if your XML uses namespaces, you have to prefix the namespace to 
> the tag name in findall(). It will look something like
>   d.findall('//{http://www.imsproject.org/xsd/imscp_rootv1p1p2}resource')
> 
> Let us know how long that takes...
> 
> Kent
> 
> >
> >
> > Bernard
> >
> >
> >
> > On 9/14/05, Kent Johnson <[EMAIL PROTECTED]> wrote:
> >
> >>Bernard Lebel wrote:
> >>
> >>>Thanks for that pointer Kent, I'll check it out. Also thanks for
> >>>letting me know I'm not nuts! :-)
> >>>
> >>>Alan's suggestion about BeautifulSoup is actually excellent. The
> >>>documentation is nice and the tool is very easy to use.
> >>>
> >>>However is it normal that to parse a 2618 lines xml file it takes
> >>>20-30 seconds or so?
> >>
> >>That seems slow to me unless the lines are really long! How many bytes is 
> >>the file? But I don't have much experience with BeautifulSoup.
> >>
> >>ElementTree is fast and cElementTree (the C implementation) is really fast. 
> >>I have used it to read, process and write a 28 MB XML file, it took about 
> >>10 seconds.
> >>
> >>Kent
> >>
> >>
> >>>
> >>>Thanks
> >>>Bernard
> >>>
> >>>
> >>>
> >>>On 9/14/05, Kent Johnson <[EMAIL PROTECTED]> wrote:
> >>>
> >>>
> Bernard Lebel wrote:
> 
> 
> >Thanks Alan,
> >
> >I'll check BeautifulSoup asap.
> >
> >I'm using regex simply because I have no clue where to start to parse
> >XML. I have read the various xml tools available in the Python
> >library, however I'm a complete loss at what to make out of them. Many
> >of them seem to use some programming standards, wich I am completely
> >unfamiliar with (this is the first time that I dig into XML writing
> >and parsing).
> >
> >I don't know where to start to learn about all these standards, and as
> >usual with new programming things, the documentation is hard to
> >swallow (it usually is written more as a reference than a proper user
> >guide/tutorial). I have to admit this is very frustrating, so if I'm
> >looking at things from a wrong perspective please advise me, I need
> >it.
> 
> I agree that the Python XML story is confusing even for the files in the 
> standard library. Worse, the (IMO) best solutions are not to be found in 
> the standard lib or PyXML at all.
> 
> The std lib and PyXML are based on the DOM and SAX standards. These 
> standards were designed to be "language-neutral" - there are 
> implementations in Python, Java and other languages. The good side of 
> this is, if you learn how to use them, the knowledge is pretty portable 
> to other languages. The bad side is, the APIs defined by the standard are 
> IMO clunky and painful to use, especially in Python.
> 
> There is a current thread on comp.lang.python discussing this with good 
> suggestions and pointers to more info:
> http://groups.google.com/group/comp.lang.python/browse_frm/thread/a48891aa645ead13/dcd8fdc20b4b191b?hl=en#dcd8fdc20b4b191b
> 
> My personal preference is ElementTree. Beautiful Soup is good too though 
> I have only tried it with HTML. If I was running on Linux I would try 
> lxml which uses the ElementTree API and adds full XPath support. Amara 
> looks like the Cadillac solution - big and cushy. I haven't tried it. 
> Uche's articles (referenced in the thread above) have pointers to many 
> other choices but these seem to be the most popular.
> 
> My favorite XML lib is actually dom4j which is in Java. It works great 
> with Jython.
> 
> Kent
> 
> 
> 
> >So right now I'm just taking a shortcut and using ultra-simple
> >re-based parser to retrieve the tags I'm looking for. I know it will
> >probably be slow, but hopefully I'll get familiar with sophisticated
> >parsing in the future and improve my code. As it stands right now,
> >even the re syntax is not super easy to learn.
> 
> For what you are doing re seems fine to me. You can get in trouble using 
> re's with XML because of nested tags, variations in spelling and order, 
> probably a bunch of other things. But for simple stuff it can work fine.
> 
> Kent
> 
> 
> >

Re: [Tutor] IDEs

2005-09-14 Thread Tim Johnson
* Matt Williams <[EMAIL PROTECTED]> [050914 07:27]:
> I've used both PyDev and Wing IDE.
> 
> PyDev seems good, and is getting better. 
> Wing is pay-for (although only $40 or so), but can be trialled. I thought
> it was good, but had a huge problem trying to get it to play with a C library
> I was using...
> 
> I've never managed to get Boa-Constructor to run...
> 
> As regards using wxPython - I thought it was ok, but frankly Glade was s
> much easier..
 
  I use both (g)vim and emacs/Xemacs. You can compile the python
  interpreter directly into vim and that gives you access to all kinds
  of goodies from the vim community.

  The two forks of emacs both support a full-blown programming language
  of their own (elisp) that gives you in many ways a "mini-os" at
  your fingertips.

  And with Xemacs you can even have bitmaps for your backgroud, but
  of course that can be distracting, if you are (for instance) coding
  over the top of Mariah Carey.

  For Windows, the finest Shareware edit IMHO is Boxer.
  But if I programmed only in Python and only on windows, I'd
  use PythonWin.

  MTCW
  tim
  

-- 
Tim Johnson <[EMAIL PROTECTED]>
  http://www.alaska-internet-solutions.com
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Another regular expression question

2005-09-14 Thread Alan G
> However is it normal that to parse a 2618 lines xml file 
> it takes 20-30 seconds or so?

Only if you are running it on an original Palm Pilot!

Seriously, I'd expect it to be more like 2-3 seconds.
Something fishy there.

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


Re: [Tutor] IDEs

2005-09-14 Thread nephish
Matt Williams wrote:

>I've used both PyDev and Wing IDE.
>
>PyDev seems good, and is getting better. 
>Wing is pay-for (although only $40 or so), but can be trialled. I thought
>it was good, but had a huge problem trying to get it to play with a C library
>I was using...
>
>I've never managed to get Boa-Constructor to run...
>
>As regards using wxPython - I thought it was ok, but frankly Glade was s
>much easier..
>
>(all IMHO)
>
>Matt
>
>___
>Tutor maillist  -  Tutor@python.org
>http://mail.python.org/mailman/listinfo/tutor
>
>  
>
Yup, exactly why i use glade!
sk
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] IDEs

2005-09-14 Thread Alan G
>  For Windows, the finest Shareware edit IMHO is Boxer.

Editor religious wars are nearly as bad as programming 
language wars but I can't resist.

My favourite windows editor these days is gvim. I've never got 
round to adding the python scripting feature, mainly because 
I try not to customize it too much. But its simple, fast and 
works the same on Linux, Mac and Windoze...

I used to be an emacs zealot but for some reason emacs never 
seemed comfortable on Windows.

>  But if I programmed only in Python and only on windows, I'd
>  use PythonWin.

Pythonwin is better than IDLE, but I still prefer gvim and a 
command line prompt. Although I confess to firing up Pyhonwin 
occasionally to use it's debugger!

Alan G.

PS I'm playing with JSP at the moment and am very impressed 
with the open source NetBeans IDE. It would be nice if someone 
modified it to work with Python! :-)

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


Re: [Tutor] IDEs

2005-09-14 Thread Kent Johnson
Alan G wrote:
> PS I'm playing with JSP at the moment and am very impressed 
> with the open source NetBeans IDE. It would be nice if someone 
> modified it to work with Python! :-)

How about Jython? See https://coyote.dev.java.net/

Kent

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


Re: [Tutor] More IDE's (was: Boa-Constructor)

2005-09-14 Thread Terry Kemmerer




Thanks. This was going to be another question of mine, as to what was wrong with going the Emacs and Vim directions.

Terry


On Wed, 2005-09-14 at 09:40 -0400, George Flaherty wrote:


Yeah, I have been using PyDev with Eclipse. It is pretty good, since with the latest version the debugger is working and they have include the ability to add additional paths in the PYTHONPATH variable.

I honestly would prefer to use Emacs, but I have not found any tool that provides code-completion with python. Until I have been using Eclipse (with Emacs running minimized :)

-g

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of D. Hartley
Sent: Tuesday, September 13, 2005 10:27 PM
To: Python tutor
Subject: [Tutor] More IDE's (was: Boa-Constructor)

This thread made me wonder:

Is anyone out there using Eclipse and PyDev? (I started using Eclipse when I was toying around in Jython, and know others that are using it for C/C++, but I am curious if others have tried out PyDev and what they think).

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




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


[Tutor] Retrieving the text of a XML tag with ElementTree

2005-09-14 Thread Bernard Lebel
Hello,

Let say I have this XML chunk:





  

  

  False


I wish to retrieve the "False" between the opening/closing tags.
I thought I could use something like:


from elementtree.ElementTree import parse

oTree = parse( r'C:\temp\Camera_Root.xml' )

for oXMLObject in oTree.findall( '//sceneobject' ):
if oXMLObject.attrib[ 'type' ] == 'CameraRoot':

oXMLProps = oXMLObject.find( 'properties' )

# We found the tag
for oXMLProp in oXMLProps.findall( 'property' ):
if oXMLProp.attrib[ 'name' ] == 'Visibility':
print oXMLProp.text


Now the print statements prints an empty line, wich is obviously not
what I'm after :-)


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


Re: [Tutor] Retrieving the text of a XML tag with ElementTree

2005-09-14 Thread Bernard Lebel
Oops, false alarm.

I was reading the wrong tag (the  tag instead of a
 one).


Sorry!
Bernard



On 9/14/05, Bernard Lebel <[EMAIL PROTECTED]> wrote:
> Hello,
> 
> Let say I have this XML chunk:
> 
> 
> 
> 
> 
>   
> 
>type="visibility">
> 
>fullname="Camera_Root.visibility.viewvis" type="Parameter"
> sourceclassname="nosource">False
> 
> 
> I wish to retrieve the "False" between the opening/closing tags.
> I thought I could use something like:
> 
> 
> from elementtree.ElementTree import parse
> 
> oTree = parse( r'C:\temp\Camera_Root.xml' )
> 
> for oXMLObject in oTree.findall( '//sceneobject' ):
> if oXMLObject.attrib[ 'type' ] == 'CameraRoot':
> 
> oXMLProps = oXMLObject.find( 'properties' )
> 
> # We found the tag
> for oXMLProp in oXMLProps.findall( 'property' ):
> if oXMLProp.attrib[ 'name' ] == 'Visibility':
> print oXMLProp.text
> 
> 
> Now the print statements prints an empty line, wich is obviously not
> what I'm after :-)
> 
> 
> Thanks
> Bernard
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Retrieving the text of a XML tag with ElementTree

2005-09-14 Thread Kent Johnson


Bernard Lebel wrote:
> Hello,
> 
> Let say I have this XML chunk:
> 
> 
> 
> 
> 
>   
> 
>type="visibility">
> 
>fullname="Camera_Root.visibility.viewvis" type="Parameter"
> sourceclassname="nosource">False
> 
> 
> I wish to retrieve the "False" between the opening/closing tags.
> I thought I could use something like:
> 
> 
> from elementtree.ElementTree import parse
> 
> oTree = parse( r'C:\temp\Camera_Root.xml' )
> 
> for oXMLObject in oTree.findall( '//sceneobject' ):
>   if oXMLObject.attrib[ 'type' ] == 'CameraRoot':
>   
>   oXMLProps = oXMLObject.find( 'properties' )
>   
>   # We found the tag
>   for oXMLProp in oXMLProps.findall( 'property' ):
>   if oXMLProp.attrib[ 'name' ] == 'Visibility':
>   print oXMLProp.text
> 
> 
> Now the print statements prints an empty line, wich is obviously not
> what I'm after :-)

You have to dig a little more, the text is part of the  element, not 
the  element. Something like
for oXMLProp in oXMLProps.findall( 'property' ):
if oXMLProp.attrib[ 'name' ] == 'Visibility':
for param in oXMLProp.findall('.//parameter'):
print param.text

I really wish ElementTree supported full XPath expressions. If it did this 
whole thing would almost be a one-liner - something like

for param in oTree.findall( '//[EMAIL PROTECTED]"CameraRoot"]/properties/[EMAIL 
PROTECTED]"Visibility"]/parameters/parameter'):
  print param.text

Sigh. XPath really rocks. Anyone want to port lxml to Windows?

Kent


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


[Tutor] Focus in tkinter

2005-09-14 Thread David Holland
I want to make the mouse focus in a GUI move to the
correct button/text entry widget.  Does anyone know
how to do this ?

Thanks in advance


David





___ 
Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide with voicemail 
http://uk.messenger.yahoo.com
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] IDEs

2005-09-14 Thread Tim Johnson
* Alan G <[EMAIL PROTECTED]> [050914 09:21]:
> >  For Windows, the finest Shareware edit IMHO is Boxer.
> 
> Editor religious wars are nearly as bad as programming 
> language wars but I can't resist.
 
   ERWs are a misdirection of energy IMHO. Talking about
 editors and languages *is* a good way to learn about
 the options available, however.

  If I were able to earn my living programming in only one language, I
  would use an editor the "fully understood" that language.  (thus
  pythonwin as an example). However, A typical work session for me would
  be writing code in python, rebol and javascript. In the same editor.
  With emacs/Xemacs I can customize so that I am using the same
  keystrokes for any language (say, navigating from one subroutine to
  another or inserting debugging stubs).

  Also, Emacs has a wonderful feature that I just can't live without:
  You can run a script interpreter within the editor and maintain
  asynchronous communication with it. It's called *comint mode*

  At the same time, I might be navigating among directories
  and text, html or other file resources and doing as-needs editing
  or search. Using Midnight Commander with vim as the default
  editor works wonderfully for this function and vim beats the
  pants off of emacs for adhoc editing and quick "on the fly"
  keymapping that might be needed for one particular editing
  session.

  BTW: Total Commander is a wonderful alternative to Midnight
   Commander on Windows. Shareware (about 39 bucks).

> My favourite windows editor these days is gvim. I've never got 
> round to adding the python scripting feature, mainly because 

  I would bet that compiling in the python binary on windows
  would be more daunting

> I try not to customize it too much. But its simple, fast and 
> works the same on Linux, Mac and Windoze...
 
  I echo that gvim works exactly the same on those various platforms
  for me. I have found that comint mode in emacs doesn't work
  right (for me) on windows. 

> I used to be an emacs zealot but for some reason emacs never 
> seemed comfortable on Windows.
> 
> >  But if I programmed only in Python and only on windows, I'd
> >  use PythonWin.
> 
> Pythonwin is better than IDLE, but I still prefer gvim and a 
> command line prompt. Although I confess to firing up Pyhonwin 
> occasionally to use it's debugger!
 
  Bottom line is: Everyone's circumstances and needs differ.
  It's great having all these options!
  --
  tj (writing this email with vim)

> Alan G.
> 
> PS I'm playing with JSP at the moment and am very impressed 
> with the open source NetBeans IDE. It would be nice if someone 
> modified it to work with Python! :-)
> 
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

-- 
Tim Johnson <[EMAIL PROTECTED]>
  http://www.alaska-internet-solutions.com
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] IDEs

2005-09-14 Thread Jorge Godoy
Tim Johnson <[EMAIL PROTECTED]> writes:

>   And with Xemacs you can even have bitmaps for your backgroud, but
>   of course that can be distracting, if you are (for instance) coding
>   over the top of Mariah Carey.

On the other hand, it will be easy (?) to find bugs on her nipples... ;-) 


-- 
Jorge Godoy  <[EMAIL PROTECTED]>

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


Re: [Tutor] Focus in tkinter

2005-09-14 Thread Michael Lange
On Wed, 14 Sep 2005 19:58:07 +0100 (BST)
David Holland <[EMAIL PROTECTED]> wrote:

> I want to make the mouse focus in a GUI move to the
> correct button/text entry widget.  Does anyone know
> how to do this ?
> 

Hi David,

to set the focus to a particular widget you need the focus_Set() method:

b = Button(parent)
b.focus_set()

Maybe you want to have a look at Frederik Lundh's excellent Tkinter books:

   

or the more complete, but a little outdated version:



I hope this helps

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


Re: [Tutor] IDEs

2005-09-14 Thread Alan G
>> with the open source NetBeans IDE. It would be nice if someone 
>> modified it to work with Python! :-)
>
> How about Jython? See https://coyote.dev.java.net/

My work is done for me!
I was seriously looking at wring a plug in to support Jython because
I couldn't see one listed on the official plug in page. It was looking 
a tad daunting, now I don't need to.

Excellent, thanks Kent.

Alan G.

PS Now off to find out what the heck 'Groovy' looks like! :-) 

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


[Tutor] running scripts with windows

2005-09-14 Thread Ed Hotchkiss
Hi everyone, I'm home for the next few weeks while I'm learning Python, and I'm not on a *NIX box, I'm using windows. How the hell do I run a Python script? Sorry if this is a 'dumb question'. -- edward hotchkiss 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] running scripts with windows

2005-09-14 Thread Jacob S.



Well, if your python installation went correctly, all you 
should have to do is save the script with a .py extension and then double click 
on it.
 
Jacob
 

  - Original Message - 
  From: 
  Ed 
  Hotchkiss 
  To: tutor@python.org 
  Sent: Wednesday, September 14, 2005 4:58 
  PM
  Subject: [Tutor] running scripts with 
  windows
  Hi everyone, I'm home for the next few weeks while I'm learning 
  Python, and I'm not on a *NIX box, I'm using windows. How the hell do I run a 
  Python script? Sorry if this is a 'dumb question'. -- 
  edward hotchkiss 
  
  

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


Re: [Tutor] running scripts with windows

2005-09-14 Thread John Fouhy
On 15/09/05, Ed Hotchkiss <[EMAIL PROTECTED]> wrote:
> Hi everyone, I'm home for the next few weeks while I'm learning Python, and
> I'm not on a *NIX box, I'm using windows. How the hell do I run a Python
> script? Sorry if this is a 'dumb question'. 

Step 1 - install python :-) http://www.python.org/ has Windows binaries.

Step 2 - make sure python.exe is in your path.  You can edit your path
by right-clicking on "My computer" and following your nose.

Step 3 - get a command shell (eg, Start->Run->"cmd"). cd to the
directory where your script is and tyoe "python [scriptname]".

You can also double-click on the script name in Windows Explorer, but
the disadvantage of that is that the shell goes away as soon as your
script finishes, which makes seeing output hard.

Finally, if you're accustomed to unix, you might like to install
Cygwin (http://www.cygwin.com/)  It gives you a bash shell in Windows.
 Quite nice.

HTH!

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


[Tutor] Curses and Konsole

2005-09-14 Thread Eric Guirbal
Hello,

I have been leaning Python for one week. My first project consist in doing  a
front end to a MySQL  database using the module curses. I have a little
display problem in a Konsole terminal. More precisely, when I apply the border
method, between each character _ one blank space is inserted. I checked the
variable $TERM. I think my program is clear because the same display problem
occur with Midnight Commander. By a similar problem posted on a debian list, I 
tried

import locale
locale.setlocale(locale.LC_ALL)

without success. On the other hand, it is ok in a xterm or rxvt 
terminal. I use python 2.3, ncurses 5.3 and Konsole 1.2.3 (KDE 3.1.3) and my
system is in iso-8859-15. All clue is welcome. 
Thanks.

-- 
Eric Guirbal

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


Re: [Tutor] (no subject)

2005-09-14 Thread Joseph Quigley
>
>
>> And also, is Python capable of writing an OS?
>  
>
Actually, yes. Google for "Python OS" and look for Unununium (or 
something like that. I can never remember). It has no kernel and to 
booting process may not exactly be in Python... but they say it's an OS 
written in Python and that it boots to the python interpreter.

Just a warning: it's no where near Mac OS (x), Windows (x) and Linux 2.x 
with a distro that you may be familiar with.

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


Re: [Tutor] Parsing os.popen(command) output

2005-09-14 Thread Travis Spencer
On 9/11/05, Bill Burns <[EMAIL PROTECTED]> wrote:
> Like I said, it does work but can it be improved upon?

The variable names could stand some improvement.  p, r, s, tmp, i,
etc. aren't very explanatory.  If you choose better names, your
coworkers, not to mention your future self, will be very thankful.

-- 

Regards,

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