Re: [Tutor] More and more OT - Python/Java

2005-01-12 Thread Kent Johnson
Liam Clarke wrote:
Out of curiousity, having poked around XML while learning about the
JScript DOM, what are you using it for?
Lots...one project I worked on, we used XML as the native file format and dom4j trees as the object 
model. In other words, when you saved a document, you got an XML file; when you read a document, it 
was stored internally as a dom4j tree. (The program was written in Jython so it used Java libraries.)

The project was basically a domain-specific editor. Using XML and dom4j worked out great. One thing 
I really like is that when the domain model is a dom model, you can use XPath as a query language on 
your model. Big chunks of the application were data-driven and most of the data tables used XPath to 
describe the piece of the model they needed.

I have written quite a bit about this project on my blog - start at www.kentsjohnson.com and look 
for blog entries and essays about dom4j, xpath and Meccano (the name of the project).

Another project I worked on had to manipulate a tree structure stored in a database. I built a dom4j 
tree in memory to represent the database tree and did my analysis on that. Very handy.

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


Re: [Tutor] More and more OT - Python/Java

2005-01-12 Thread Liam Clarke
XML, XPath, XML Schema all have basic tutorials at www.w3schools.org

Out of curiosity, how does a node function in a DOM? I'm not very good
at manipulating DOM's, I can do the basics, mainly by passing object
IDs to JS functions, which feels like cheating.




On Wed, 12 Jan 2005 07:57:02 -0500, Kent Johnson <[EMAIL PROTECTED]> wrote:
> Guillermo Fernandez Castellanos wrote:
> > I have not been able to find any recent XML/Python tutorial on the
> > web.
> 
> There is a Python and XML topic guide at python.org
> http://pyxml.sourceforge.net/topics/
> 
> Uche Ogbuji writes regularly about Python and XML for xml.com
> http://www.xml.com/pub/au/84
> 
> Does the xml.dom library have a XPath and XQuery or any SQL-like
> > support? I've understood that it's a pretty basic library...
> 
> My impression is the built-in stuff is pretty basic. If you want to use SAX 
> and DOM for XML in
> Python, the 4Suite add-on is pretty standard.
> http://4suite.org/index.xhtml
> 
> I've also heard good things about libxml2; it includes XPath support
> http://xmlsoft.org/python.html
> 
> IMO Fredrik Lundh's ElementTree package is the easiest way to work with XML 
> from Python. It supports
> a subset of XPath and he has just released a compiled C version
> http://effbot.org/zone/element-index.htm
> 
> Kent
> 
> >
> > Thanks,
> >
> > 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
> 


-- 
'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] More and more OT - Python/Java

2005-01-12 Thread Kent Johnson
Guillermo Fernandez Castellanos wrote:
I have not been able to find any recent XML/Python tutorial on the
web. 
There is a Python and XML topic guide at python.org
http://pyxml.sourceforge.net/topics/
Uche Ogbuji writes regularly about Python and XML for xml.com
http://www.xml.com/pub/au/84
Does the xml.dom library have a XPath and XQuery or any SQL-like
support? I've understood that it's a pretty basic library...
My impression is the built-in stuff is pretty basic. If you want to use SAX and DOM for XML in 
Python, the 4Suite add-on is pretty standard.
http://4suite.org/index.xhtml

I've also heard good things about libxml2; it includes XPath support
http://xmlsoft.org/python.html
IMO Fredrik Lundh's ElementTree package is the easiest way to work with XML from Python. It supports 
a subset of XPath and he has just released a compiled C version
http://effbot.org/zone/element-index.htm

Kent
Thanks,
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 and more OT - Python/Java

2005-01-12 Thread Yigal Duppen
On Wednesday 12 January 2005 09:40, Alan Gauld wrote:
> > I ask that because I'm writting a little program that will make
> > queries over a 1500 entries database, with very simple queries. I
>
> need
>
> > an answer in 1 or 2 seconds. I'm using SQLite now, but i wanted
> > something that depends as little as possible of external
>
> dependencies
>
> > (as a database).
>
> 1500 entries shouldn't be a problem for queries either using DOM
> (in memory) or XPath or even XQuery. If your app grows to 15
> it might stat to be a problem, and if you get over a million
> entries I'd definitely start thinking about regular RDBMS.
>
> The other feature is that for ~1500 entries the size of the
> files will be about the same but anything bigger than that
> and the XML version will quickly start to fill your disks...

I actually have some realy life experience with using XML files instead of a 
database, and it's a bit of a mixed blessing. 

A big advantage of XML over a relational database is the built-in support for 
hierarchical structuring. When you're mainly reasoning about trees (in this 
particular case, parse trees) the relational solution is a bit... messy. 

For example, to find all assignment statements at the top-level of a function, 
XPath allows you to say something like:
//function-definition/[EMAIL PROTECTED]"assign"]
the equivalent is SQL is not so nice. 


On the other hand, the amount of XML our project produced was *huge*, and much 
of the processing time of the project went into parsing XML. Furthermore, 
while XPath allows for very cute queries, no XPath implementation is as 
optimized as SQL. 

All in all, I'd never advise XML as a database.


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


Re: [Tutor] More and more OT - Python/Java

2005-01-12 Thread Yigal Duppen
On Wednesday 12 January 2005 00:34, Max Noel wrote:
> > As a bonus, I've decided to have a look at XSL, which allows me to
> > format a XML file for display in a web browser. It entirely changed my
> > perception of web programming.
> > I intend to program an on-line browser-based game with some friends
> > of mine later in the year (in Python of course -- I converted them),
> > and now that I've seen what XML and XSL can do, we're so going to use
> > them for data output: the data is in dynamically-generated XML, which
> > links to a (static) XSL stylesheet to tell the browser how to render
> > that data.

Hi Max,

While I agree that the XML + XSL -> HTML architecture *sounds* very nice, in 
real life it's not so sweet. I've worked on some projects that used this 
approach and IMHO, the biggest problem is the debugging of XSL output -- XSL 
scripts are a horror to read, and the complex matching rules often make it 
very hard to discover which template caused which error. 

In this case I'd suggest a templating language, such as TAL (part of Zope, 
http://www.zope.org) or a different language. 

At my work (Java) we now use JSP, a Java templating language; debugging time 
has significantly decreased by using this instead of XSL. 

> > Doing things that way has many advantages:
> > 1) Data is separate from formatting. That's always a Good Thing(TM).
> > If I someday decide that I don't like the way the site looks, I
> > theoretically only need to recreate a stylesheet, without touching
> > anything else. (boom! Instant skins!)

You're completely right, but as I pointed out, XSLT is not the only option.

> > 2) Most of the "HTML rendering" is going to be done by the user's
> > browser. This, and the way XSL stylesheets are constructed will
> > prevent many bad HTML issues.

HTML rendering is usually not an issue for web-based programs. And if it is, a 
bit of front-end caching usually can save a lot more time. After all, whether 
you have to render HTML or XML, you do have to render something. 

As for the bad HTML issues, the same issues (unclosed tags, wrong attributes) 
do exist when rendering XML. 

> > 3) For the same reason, it will save bandwidth. The XML data will
> > probably take less space than the fully-formatted stuff I'd have to
> > spit out with "regular" HTML, and the XSL stylesheet can probably be
> > cached by the user's browser.

As Alan pointed out, this might very well not be true :-)

> > 4) In the same line of reasoning, it'll also save CPU time: XML data,
> > being smaller, is generated faster than the equivalent HTML. Granted,
> > the stylesheet is another server request, but it's static, so it puts
> > virtually no load on a server.

My answer to this is the same as nr 2. 



Yigal

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


Re: [Tutor] More and more OT - Python/Java

2005-01-12 Thread Alan Gauld
> I have not been able to find any recent XML/Python tutorial on the
> web. Does the xml.dom library have a XPath and XQuery or any
SQL-like
> support? I've understood that it's a pretty basic library...

I don't thoink there's XPath or XQuery in Python yet. There
is a thread on this on comp.lang.python just now - try a Google
Groups search - but I haven't been following it.

Alan G.

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


Re: [Tutor] More and more OT - Python/Java

2005-01-12 Thread Alan Gauld
>  You are standing in front of a stump. A path leads north.

>  N 

Probably more like:


   you
   
   in front of
   stump
   
   
   path
   leads NOrth
   


And the XSL will join the bits together using XPathstyle
references to "fill in the blanks":

 are 
a . A



> and you have a XSL that works like a CSS?
>
> descript  {font:arial, align:center}
> exits style:bolder

And yes you can have that too.

> Is that a good paraphrasing? How browser dependent would that be? Do
> most browsers support XML & XSL?

Very few do at present, only the latest generation. But given many
folks are still using Netscape 4 and IE 4 and even the latest
versions have haphasard XML support we are quite a long way away from
unified presentationof XML via browsers.

Fortunately theres another technology which can turn XML into HTML,
called XSLT and it takes the XSL above and spits out normal HTML to
the browser, which is what happens most of the time and the user
is blissfully ignorant that XML is underneath the covers.

> What's SAX DOM? I know what a DOM is, but what's the SAX?

Both are parsers. DOM reads the whole structure into memory
and accesses it like a tree.
SAX parses the file as its being read and recognises key
elements and activates a parsing function. THuis in the XML
above you could instruct the parser to call one of your
functions everytime it found a  tag, passing
in the whole content of that tag. Your function then handles
only the data inside the tag that it is intersted in.
Its faster and saves memory, but is strictly read-only,
and read once - you can't change the data and you can't
go back a step, you need to restart from the top.

Both approaches have their advantages.

> my Python docs when I was poking XMLParser. If/when I work with XML,
> would you recommend Python's standard modules for it?

Yes, Python has good XML support and can use DOM or SAX.

Alan G.

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


Re: [Tutor] More and more OT - Python/Java

2005-01-12 Thread Guillermo Fernandez Castellanos
> 1500 entries shouldn't be a problem for queries either using DOM
> (in memory) or XPath or even XQuery. If your app grows to 15
> it might stat to be a problem, and if you get over a million
> entries I'd definitely start thinking about regular RDBMS.
Hi,

No it will not go further... let's say 2000 entries not to take any risk.

I have not been able to find any recent XML/Python tutorial on the
web. Does the xml.dom library have a XPath and XQuery or any SQL-like
support? I've understood that it's a pretty basic library...

Thanks,

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


Re: [Tutor] More and more OT - Python/Java

2005-01-12 Thread Alan Gauld
> I ask that because I'm writting a little program that will make
> queries over a 1500 entries database, with very simple queries. I
need
> an answer in 1 or 2 seconds. I'm using SQLite now, but i wanted
> something that depends as little as possible of external
dependencies
> (as a database).

1500 entries shouldn't be a problem for queries either using DOM
(in memory) or XPath or even XQuery. If your app grows to 15
it might stat to be a problem, and if you get over a million
entries I'd definitely start thinking about regular RDBMS.

The other feature is that for ~1500 entries the size of the
files will be about the same but anything bigger than that
and the XML version will quickly start to fill your disks...

Alan G.

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


Re: [Tutor] More and more OT - Python/Java

2005-01-12 Thread Alan Gauld
> > 3) For the same reason, it will save bandwidth. The XML data will
> > probably take less space than the fully-formatted stuff I'd have
to
> > spit out with "regular" HTML, and the XSL stylesheet can probably
be
> > cached by the user's browser.

This is a common misperception that should have been corrected by now.
XML won;t save you any bandwidth over traditional HTML, in fact it
will require significantly more - 50-100% in practice.

The reason for this is that you still need to send the formatting
info along with the data but now it will be done as two, usually
three,
separate http GET messages: one for the XML, one for the XSL stytle
sheet,
(or two for the HTML/XHTML plus CSS style sheet) due to the
duplication
of tagging between the files plus the http overheads this will
invariably
result in extra bandwidth over a single HTML file with data embeded.

On subsequent updates of the same page it might seem like a
bandwidth saving is possible, and thats true compared to a complete
page refresh, but best practice today refreshes web pages by
using JavaScript to update the fields in life via a binary message,
so copmpared to best practive XML will again increase bandwidth
- typically by 5-10 times in this case.

> > 4) In the same line of reasoning, it'll also save CPU time: XML
data,
> > being smaller, is generated faster than the equivalent HTML.

Its not much smaller and requires more tagging information, plus
you need to run a validation check for "well formedness" so the
CPU gain is minimal at the server and the extra cost of parsing
at the browser is significant... Your users could expect to see
a 1-2 second slowdown in response time.


This is something of a hot button for me just now -= I see XML
being pushed because it makes life easier for developers but
it incurs extra costs almost everywhere else. Given that in
a typical project, development costs are only 20-30% of the
total the net effect is to increase project costs and reduce
performance. IMHO far too few software engineers have been
trained to properly engineer their solutions taking account
of whole-life costs, they only see the programming effort.


Alan G.


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


Re: [Tutor] More and more OT - Python/Java

2005-01-12 Thread Alan Gauld
> Only thing I've seen that uses XML (remember I'm a n00bie in Python,
> Java, Jscript and HTML, so I don't see the real indepth stuff) is
MSN
> Messenger for it's logs. And MS IE can parse that XML.

XML is rapidly becoming the de-facto standard in data exchange
formats between businesses(B2B). In addition the SOAP protocol
for web services (aka remote procedurecalls over the web) uses
XML so more and more business applications will be using XML.

The more extreme XML fans also think it can be used internally
as glue between in-house applications (sales-orders-inventory-billing
etc) however I personally think the heavy processing and bandwidth
demands of XML might delay that vision.

HTH,

Alan g

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


Re: [Tutor] More and more OT - Python/Java

2005-01-11 Thread Max Noel
On Jan 12, 2005, at 01:40, Liam Clarke wrote:
So, you've got the XML like -
 You are standing in front of a stump. A path leads north. 

 N 

and you have a XSL that works like a CSS?
descript  {font:arial, align:center}
exits style:bolder
Is that a good paraphrasing? How browser dependent would that be? Do
most browsers support XML & XSL?
	Yup, that'd be the idea. IIRC most browsers support XML and XSL. (not 
sure, I'll have to check)

PS
What's SAX DOM? I know what a DOM is, but what's the SAX? I saw it in
my Python docs when I was poking XMLParser. If/when I work with XML,
would you recommend Python's standard modules for it?
	SAX is just another way of parsing XML. It's very sequential in 
nature, so it's not good if you need to re-access a previous node from 
the document, but since it doesn't load the entire document in memory 
(doesn't build a tree out of it), it uses less memory than DOM, and 
scales much better (obviously).

	I haven't tried Python's XML parsers yet, but I understand Python 
supports both SAX and DOM, so it should be okay...

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


Re: [Tutor] More and more OT - Python/Java

2005-01-11 Thread Max Noel
On Jan 12, 2005, at 00:49, Guillermo Fernandez Castellanos wrote:
Does that mean that you use XML as a database to store data and make
queries, or that you store your information as XML in a database (as
MySQL)?
	Nope, nothing that fancy, I'm afraid. Just your run-off-the-mill "load 
from XML/save to XML" file operations.

I ask that because I'm writting a little program that will make
queries over a 1500 entries database, with very simple queries. I need
an answer in 1 or 2 seconds. I'm using SQLite now, but i wanted
something that depends as little as possible of external dependencies
(as a database).
	You should stick to SQLite. After all, it was designed exactly for 
what you're doing. Well, AFAIK at least.

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


Re: [Tutor] More and more OT - Python/Java

2005-01-11 Thread Liam Clarke
So, you've got the XML like - 


 You are standing in front of a stump. A path leads north. 
 N 

and you have a XSL that works like a CSS? 

descript  {font:arial, align:center}
exits style:bolder

Is that a good paraphrasing? How browser dependent would that be? Do
most browsers support XML & XSL?

PS 

What's SAX DOM? I know what a DOM is, but what's the SAX? I saw it in
my Python docs when I was poking XMLParser. If/when I work with XML,
would you recommend Python's standard modules for it?


Regards,

Liam Clarke
On Tue, 11 Jan 2005 23:34:30 +, Max Noel <[EMAIL PROTECTED]> wrote:
> (yes, forgot to CC the list again -- argh!)
> 
> Begin forwarded message:
> 
> > From: Max Noel <[EMAIL PROTECTED]>
> > Date: January 11, 2005 23:33:44 GMT
> > To: Liam Clarke <[EMAIL PROTECTED]>
> > Subject: Re: [Tutor] More and more OT - Python/Java
> >
> >
> > On Jan 11, 2005, at 23:15, Liam Clarke wrote:
> >
> >> Out of curiousity, having poked around XML while learning about the
> >> JScript DOM, what are you using it for?
> >>
> >> AFAIK, you make up your own tags, and then parse them and display
> >> them, and anyone else could create data using your tags.
> >>
> >> Only thing I've seen that uses XML (remember I'm a n00bie in Python,
> >> Java, Jscript and HTML, so I don't see the real indepth stuff) is MSN
> >> Messenger for it's logs. And MS IE can parse that XML.
> >>
> >> I've been curious as to how it's implemented.
> >>
> >> So yeah, if you want to share your experiences.
> >>
> >> Regards,
> >>
> >> Liam Clarke
> >
> >   Well, I plan to use it as a data storage format for a university
> > project (crowd simulation in a shopping center -- coded in Java). I
> > hate binary data formats, and XML is a good unified way to store data
> > as ASCII text, so I figured I'd use it.
> >   Also, XML files can be parsed without too much work, so I can write
> > scripts that will manipulate my data files, in any language ("any"
> > meaning "Python", there).
> >
> >   As a bonus, I've decided to have a look at XSL, which allows me to
> > format a XML file for display in a web browser. It entirely changed my
> > perception of web programming.
> >   I intend to program an on-line browser-based game with some friends
> > of mine later in the year (in Python of course -- I converted them),
> > and now that I've seen what XML and XSL can do, we're so going to use
> > them for data output: the data is in dynamically-generated XML, which
> > links to a (static) XSL stylesheet to tell the browser how to render
> > that data.
> >   Doing things that way has many advantages:
> > 1) Data is separate from formatting. That's always a Good Thing(TM).
> > If I someday decide that I don't like the way the site looks, I
> > theoretically only need to recreate a stylesheet, without touching
> > anything else. (boom! Instant skins!)
> > 2) Most of the "HTML rendering" is going to be done by the user's
> > browser. This, and the way XSL stylesheets are constructed will
> > prevent many bad HTML issues.
> > 3) For the same reason, it will save bandwidth. The XML data will
> > probably take less space than the fully-formatted stuff I'd have to
> > spit out with "regular" HTML, and the XSL stylesheet can probably be
> > cached by the user's browser.
> > 4) In the same line of reasoning, it'll also save CPU time: XML data,
> > being smaller, is generated faster than the equivalent HTML. Granted,
> > the stylesheet is another server request, but it's static, so it puts
> > virtually no load on a server.
> >
> > -- 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?"
> >
> >
> --
> 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
> 


-- 
'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] More and more OT - Python/Java

2005-01-11 Thread Guillermo Fernandez Castellanos
Hi,

Just out of curiosity,

> >   Well, I plan to use it as a data storage format for a university
> > project (crowd simulation in a shopping center -- coded in Java). I
> > hate binary data formats, and XML is a good unified way to store data
> > as ASCII text, so I figured I'd use it.
> >   Also, XML files can be parsed without too much work, so I can write
> > scripts that will manipulate my data files, in any language ("any"
> > meaning "Python", there).
Does that mean that you use XML as a database to store data and make
queries, or that you store your information as XML in a database (as
MySQL)?

I ask that because I'm writting a little program that will make
queries over a 1500 entries database, with very simple queries. I need
an answer in 1 or 2 seconds. I'm using SQLite now, but i wanted
something that depends as little as possible of external dependencies
(as a database).

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


Re: [Tutor] More and more OT - Python/Java

2005-01-11 Thread Liam Clarke
Out of curiousity, having poked around XML while learning about the
JScript DOM, what are you using it for?

AFAIK, you make up your own tags, and then parse them and display
them, and anyone else could create data using your tags.

Only thing I've seen that uses XML (remember I'm a n00bie in Python,
Java, Jscript and HTML, so I don't see the real indepth stuff) is MSN
Messenger for it's logs. And MS IE can parse that XML.

I've been curious as to how it's implemented.

So yeah, if you want to share your experiences.

Regards,

Liam Clarke


On Tue, 11 Jan 2005 02:19:17 +, Max Noel <[EMAIL PROTECTED]> wrote:
> >   dom4j? What is it? Is it part of the standard Java distribution? If
> > not, where can it be found?
> 
> Update: Okay, looks like it's time to go to bed. The link was in
> bright blue and somehow I didn't see it. D'oh.
> 
> -- 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
> 


-- 
'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] More and more OT - Python/Java

2005-01-10 Thread Max Noel
	dom4j? What is it? Is it part of the standard Java distribution? If 
not, where can it be found?
	Update: Okay, looks like it's time to go to bed. The link was in 
bright blue and somehow I didn't see it. D'oh.

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


Re: [Tutor] More and more OT - Python/Java

2005-01-10 Thread Max Noel
On Jan 11, 2005, at 01:38, Kent Johnson wrote:
Max Noel wrote:
A good follow-up to that would be McMillan & Wiggleswrorth's 
"Java Programming - Advanced Topics", through which I'm currently 
reading. It has some really good stuff, including things about XML 
parsing with SAX and DOM...
I may actually be about to understand how to use SAX and DOM, 
w00t! (*prepares a bottle of Champagne*)
If you are processing XML with Java you really owe it to yourself to 
learn about dom4j. Then you won't *have* to understand SAX and DOM, 
w00t w00t!
	dom4j? What is it? Is it part of the standard Java distribution? If 
not, where can it be found?

(thanks for the pointer, anyway ^^)
-- 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


Re: [Tutor] More and more OT - Python/Java

2005-01-10 Thread Kent Johnson
Max Noel wrote:
A good follow-up to that would be McMillan & Wiggleswrorth's "Java 
Programming - Advanced Topics", through which I'm currently reading. It 
has some really good stuff, including things about XML parsing with SAX 
and DOM...
I may actually be about to understand how to use SAX and DOM, w00t! 
(*prepares a bottle of Champagne*)
If you are processing XML with Java you really owe it to yourself to learn about dom4j. Then you 
won't *have* to understand SAX and DOM, w00t w00t!

:-)
http://www.dom4j.org
Kent
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] More and more OT - Python/Java

2005-01-10 Thread Max Noel
On Jan 10, 2005, at 22:00, Liam Clarke wrote:
Hehe, I'm not up to collections yet... working through Learning Java
by O'Reilly.
	If you already know a bit about OOP, I would recommend that you read 
bruce Eckel's "Thinking in Java". An excellent book, freely available 
on-line (do a quick Google search), and it taught me in 1 week all I 
needed to understand my courses (which dealt with OO analysis and 
design, Swing GUIs and some ore advanced topics).
	A good follow-up to that would be McMillan & Wiggleswrorth's "Java 
Programming - Advanced Topics", through which I'm currently reading. It 
has some really good stuff, including things about XML parsing with SAX 
and DOM...
	I may actually be about to understand how to use SAX and DOM, w00t! 
(*prepares a bottle of Champagne*)

(Why can't a non-static
method comparison be called from a static reference? What does that
mean anyway?
Er... What was your code like? (before and after correcting 
the error)

it was (off top of head here)
public class dude
{
public static void main(String [] args) {
System.out.print(args[0]);
if (doComp(args[0]));
{
System.out.println(" is true");
}
else
{
System.out.println(" is false");
  }
private boolean doComp(String x) {
   int j = new int(x);   #I can't quite remember how I did
this precisely.
   if (j==1)
  {
  return True;
  }
   else
  {
   return False;
   }
 }
}
	Okay, I understand the problem, and it's quite logical once you know 
the reason.

	Basically, static methods and variables are class methods/variables. 
That is, they're bound to the class as a whole and not to any instance 
of it (in fact, they can be used without instanciating the class at 
all).
	Non-static members are instance members. They are bound to and act 
upon specific instances of the class. Thus, you can't use them before 
instanciating the class first.

So, if I have a class called Foo which has the following:
public static void bar()
public void baz()
	I can use bar() straight away, by calling Foo.bar().
	But if I want to use baz(), I first have to instanciate Foo, with 
something like Foo blah = new Foo(); and then call blah.baz(), which 
will then return whatever baz() computes based on blah's state.

	I guess that if you want your program to be wholly procedural, you 
need to make all your functions (methods) static, then.
	But if you're doing that, you're misusing Java. OO programming is 
where it shines.

I have no startup lag really.
	I stand corrected. But my other point is still valid -- see the Great 
Language Shootout Benchmarks for "better" (and customizable) language 
benchmarks.

*sigh* I have no net at home at moment, which is very frustrating when
I want to d/l documentation & editors. For the mo, it's all Notepad.
Ick.
	I feel your pain. Coding in any language is a chore with Notepad -- it 
comes down to whichever language requires the least (keyboard) typing 
being the least unpleasant to use. And Java, unlike Python, requires a 
lot of typing.

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