Re: Importing a class, please help...

2006-02-05 Thread Alex Martelli
anon <[EMAIL PROTECTED]> wrote:

> Xavier
> 
> Yes I meant Python.  I have also been using Jython and I am VERY WELL aware
> what a JAR is.  Jython has the ability to call methods stored in classes in
> a JAR.  I was only asking if this could be done with Python also.

Classic Python is able to import Python modules from a .zip file; it
would be a reasonably easy tweak to allow the extension to be .jar or
.foo or .zap as well as .zip -- but they'd still have to be Python
modules.  Java classes use a completely different bytecode from Classic
Python: if you need to access such JVM bytecode, use Jython instead.


Alex
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Importing a class, please help...

2006-02-05 Thread Terry Hancock
On Sun, 5 Feb 2006 10:41:51 -0500
"anon" <[EMAIL PROTECTED]> wrote:
> Newbie to Python and I have a question please.  I am using
> Windows XP, SPE  0.8.2.a and Python24.  I have done this:
> 
> import sys
> print sys.path
> 
> no problem there, sys imports just fine.  I have a folder
> that I called  c\JavaProjects\PythonTesting and it shows
> up in the output from sys.path  above.  I have dropped a
> very simple Jar in that folder and I have attempted  to do
> an Import on it.  This is where things fail.  I cannot see
> the  contents of my Jar.  What am I missing here?

As others have pointed out, ".jar" is going to be Java
bytecode, and from that strange looking path (was, I assume
supposed to be "C:\JavaProjects\PythonTesting"), it looks
very much like you really wanted to be using Jython (a.k.a
"Java Python") rather than Python (a.k.a. "C Python").

Perhaps you have both Jython and Python 2.4 installed and
you are launching the latter when you meant the former?

In any case, C Python cannot load Java classes (that's the
main raison d'etre for Jython).

 -- 
Terry Hancock ([EMAIL PROTECTED])
Anansi Spaceworks http://www.AnansiSpaceworks.com

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Importing a class, please help...

2006-02-05 Thread anon
Xavier

Yes I meant Python.  I have also been using Jython and I am VERY WELL aware 
what a JAR is.  Jython has the ability to call methods stored in classes in 
a JAR.  I was only asking if this could be done with Python also.

You ask "why the hell would a Python script be able to read a JAR..".  Well, 
I was simply asking a newbie question.  The only way to gather knowladge is 
by asking questions.

You know, an old college proffesor I had was very knowladgeable and wise. 
He always took the time to answer questions, no matter how 'stupid' they 
would sound.  One can make a bigger impression on folks by stepping down a 
couple of steps and give a polite answer.  I mean no disrespect, just a 
suggestion when you post answers to folks like me who are just getting 
started with a new language...

regards


"Xavier Morel" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> anon wrote:
>> Would somebody please drop me a hint, please?
>>
> Yeah, the definition of "JAR" is Java ARchive, why the hell would a Python 
> script be able to read a JAR in the first place (truth is it is, a JAR 
> file is nothing but a renamed ZIP, therefore the zipfile module allows you 
> to read it's content) and -- more importantly -- import Java classes.
>
> Notice the difference between *Python* script and *Java* class? That's 
> because they're two different languages.
> If you want to use Java classes and modules in a Pythonic context, you 
> want Jython (http://www.jython.org/) not Python (http://www.python.org/) 


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Importing a class, please help...

2006-02-05 Thread Xavier Morel
Jorgen Grahn wrote:
 > You are rude to an obvious newbie here ... please keep in mind that 
today's
 > stupid newbies are tomorrow's Python professionals.
 >
I didn't mean to be rude and apologize if that's the way it came out.

> Maybe he /is/ running Jython and failed to explain that properly?
 >
No, he explicitely stated that he's using Python 2.4 (I'm pretty sure 
Jython's latest release is 2.1) and SPE (which didn't handle Jython last 
time I tried it)

> If I
> understand things correctly, jar files are not tied to Java but to the java
> bytecode format -- which Java and Jython share.
> 
Yes, it's used to store/package compiled java classes (.class bytecode 
files) and various metadata associated to the classes (resources, ...) 
and therefore tied to the bytecode (or the JVM) indeed.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Importing a class, please help...

2006-02-05 Thread Magnus Lycka
Jorgen Grahn wrote:
>>Yeah, the definition of "JAR" is Java ARchive, why the hell would a 
>>Python script be able to read a JAR in the first place
> 
> You are rude to an obvious newbie here ... 
Agreed. I don't think it was intended, but we should be
cautious with our language when we address strangers...

> Maybe he /is/ running Jython and failed to explain that properly? 
Not likely, since he wrote "python24". I think the newest Jython
is 2.2a1...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Importing a class, please help...

2006-02-05 Thread Jorgen Grahn
On Sun, 05 Feb 2006 17:16:38 +0100, Xavier Morel <[EMAIL PROTECTED]> wrote:
> anon wrote:
>> Would somebody please drop me a hint, please?
>> 
> Yeah, the definition of "JAR" is Java ARchive, why the hell would a 
> Python script be able to read a JAR in the first place

You are rude to an obvious newbie here ... please keep in mind that today's
stupid newbies are tomorrow's Python professionals.

...
> If you want to use Java classes and modules in a Pythonic context, you 
> want Jython (http://www.jython.org/) not Python (http://www.python.org/)

Maybe he /is/ running Jython and failed to explain that properly? If I
understand things correctly, jar files are not tied to Java but to the java
bytecode format -- which Java and Jython share.

In either case, we'd need more information from the original poster.

/Jorgen

-- 
  // Jorgen Grahn   R'lyeh wgah'nagl fhtagn!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Importing a class, please help...

2006-02-05 Thread Xavier Morel
anon wrote:
> Would somebody please drop me a hint, please?
> 
Yeah, the definition of "JAR" is Java ARchive, why the hell would a 
Python script be able to read a JAR in the first place (truth is it is, 
a JAR file is nothing but a renamed ZIP, therefore the zipfile module 
allows you to read it's content) and -- more importantly -- import Java 
classes.

Notice the difference between *Python* script and *Java* class? That's 
because they're two different languages.
If you want to use Java classes and modules in a Pythonic context, you 
want Jython (http://www.jython.org/) not Python (http://www.python.org/)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Importing a class, please help...

2006-02-05 Thread Jorge Godoy
"anon" <[EMAIL PROTECTED]> writes:

> to do an Import on it.  This is where things fail.  I cannot see the 
> contents of my Jar.  What am I missing here?

That JARs are for Java and yo're using Python?


-- 
Jorge Godoy  <[EMAIL PROTECTED]>

"Quidquid latine dictum sit, altum sonatur."
- Qualquer coisa dita em latim soa profundo.
- Anything said in Latin sounds smart.
-- 
http://mail.python.org/mailman/listinfo/python-list


Importing a class, please help...

2006-02-05 Thread anon
Hi,

Newbie to Python and I have a question please.  I am using Windows XP, SPE 
0.8.2.a and Python24.  I have done this:

import sys
print sys.path

no problem there, sys imports just fine.  I have a folder that I called 
c\JavaProjects\PythonTesting and it shows up in the output from sys.path 
above.  I have dropped a very simple Jar in that folder and I have attempted 
to do an Import on it.  This is where things fail.  I cannot see the 
contents of my Jar.  What am I missing here?

Would somebody please drop me a hint, please?  I would HIGHLY appreciate an 
example; does anybody know of a website or page that would show me how to do 
this?  I realize this is a simple question and I appreciate any help 
somebody would give me.

Regards,
joe 


-- 
http://mail.python.org/mailman/listinfo/python-list