|
From: Eric F. <eri...@ny...> - 2001-04-28 11:25:38
|
is there documentation for this?
---
Eric Freudenthal // Courant Institute // New York University
office: 212-998-3345 // cell:917-279-6208
715 Broadway, Room 1011, New York, NY 10003
cell pager: eri...@fr... (100 char limit)
-----Original Message-----
From: jyt...@li...
[mailto:jyt...@li...]On Behalf Of
jyt...@li...
Sent: Thursday, April 26, 2001 12:10 PM
To: jyt...@li...
Subject: Jython-users digest, Vol 1 #133 - 12 msgs
Send Jython-users mailing list submissions to
jyt...@li...
To subscribe or unsubscribe via the World Wide Web, visit
http://lists.sourceforge.net/lists/listinfo/jython-users
or, via email, send a message with subject or body 'help' to
jyt...@li...
You can reach the person managing the list at
jyt...@li...
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Jython-users digest..."
Today's Topics:
1. Re: implementing an interface (multple inheritance) (Finn Bock)
2. Re: Jython on MacOS X? (Michael Rose)
3. Re: Jython on MacOS X? (Deirdre Saoirse Moen)
4. Re: Jython on MacOS X? (Michael Rose)
5. Re: Jython on MacOS X? (Deirdre Saoirse Moen)
6. Package cache dir (Adam Berger)
7. Re: Jython on MacOS X? (Deirdre Saoirse Moen)
8. RE: Running auto-discovered methods (Neil Benn)
9. RE: Running auto-discovered methods (brian zimmer)
10. Re: Jython on MacOS X? (Michael Rose)
11. Re: Jython on MacOS X? (Deirdre Saoirse Moen)
12. Re: Package cache dir (Robert W. Bill)
--__--__--
Message: 1
From: bc...@wo... (Finn Bock)
To: jyt...@li...
Cc: "Eric Freudenthal" <eri...@ny...>
Subject: Re: [Jython-users] implementing an interface (multple inheritance)
Date: Wed, 25 Apr 2001 18:59:08 GMT
[Eric Freudenthal]
>I would like to integrate some jython into a java source tree. Some of my
>python modules will need to import classes defined in this project, and in
>at least one case, I need to implement a jython class with multiple
>inheritance from a java class and a java interface. How must I do this?
See other post in the thread.
>Finally, are jython objects serializable?
Yes, but when reading a serialized stream you must use the
org.python.util.PythonObjectInputStream
instead of the normal ObjectInputStream class. This utility class will
help when resolving python classes that subclass java classes.
regards,
finn
--__--__--
Message: 2
Date: Wed, 25 Apr 2001 22:29:15 +0200
From: Michael Rose <ro...@te...>
To: "jyt...@li..."
<jyt...@li...>
Subject: Re: [Jython-users] Jython on MacOS X?
--On Wednesday, April 25, 2001 10:59 AM -0700 Deirdre Saoirse Moen
<de...@de...> wrote:
>
>
> Has anyone else installed Jython on MacOS X? If so, where did you install
> it?
I've installed it with no problem - just follow the Unix instructions, not
the MacOS instruction. You can install anywhere you want. It's handy to
make a link from the jython shell script into /usr/local/bin
>
> b) I wanted to see if I could write Jython code that hooked up to
> Interface Builder
>
There are a few people experimenting with this,( and some trying the same
thing working on the CPython and Objective-C route). Interesting
possibilities.
HTH
Michael
--__--__--
Message: 3
Date: Wed, 25 Apr 2001 13:43:08 -0700
To: Michael Rose <ro...@te...>, jyt...@li...
From: Deirdre Saoirse Moen <de...@de...>
Subject: Re: [Jython-users] Jython on MacOS X?
>--On Wednesday, April 25, 2001 10:59 AM -0700 Deirdre Saoirse Moen
>I've installed it with no problem - just follow the Unix instructions, not
>the MacOS instruction. You can install anywhere you want. It's handy to
>make a link from the jython shell script into /usr/local/bin
Yay. :)
>> b) I wanted to see if I could write Jython code that hooked up to
>> Interface Builder
>>
>There are a few people experimenting with this,( and some trying the same
>thing working on the CPython and Objective-C route). Interesting
>possibilities.
I hadn't really thought about doing it this way, but it seemed that it
might need a whole bunch more wrappering to do it that way, or am I wrong?
I'm completely new to JPython and the only Java I know comes from
Peet's.... (but I am the listmom for tu...@py..., so I know python,
though I've never really mixed it with other languages)
In other words, if there's an AppKit class for NSObject, and I need to add
a controller subclass, I can do that directly in Jython?
It seems like the CPython would require wrapping NSObject, right? Or am I
missing something?
--
_Deirdre Stash-o-Matic: http://weirdre.com http://deirdre.net
"I love deadlines. I like the whooshing sound they make as they fly by."
- Douglas Adams
--__--__--
Message: 4
Date: Wed, 25 Apr 2001 22:59:17 +0200
From: Michael Rose <ro...@te...>
To: Deirdre Saoirse Moen <de...@de...>,
"jyt...@li..."
<jyt...@li...>
Subject: Re: [Jython-users] Jython on MacOS X?
Deirdre writes:
> I hadn't really thought about doing it this way, but it seemed that it
> might need a whole bunch more wrappering to do it that way, or am I wrong?
You are right. I think there's a project for this on SourceForge called
PyObjC.
> In other words, if there's an AppKit class for NSObject, and I need to add
> a controller subclass, I can do that directly in Jython?
>
> It seems like the CPython would require wrapping NSObject, right? Or am I
> missing something?
No, you're not missing anything. You've just run into the pervasive 'Law of
Conservation of Difficulty'. Java/jython integration is much easier, but
Interface Builder is basically Objective-C with bridges for the Java
versions of AppKit classes. I have no wise words on the best approach, but
I'm also taking a fist shot at the Jython/Java way.
Michael
************************************************
Assoc. Prof. Michael Rose
Center for Tele-Information, Technical University of Denmark
(45) 45 25 51 72 mailto:ro...@te...
Off the Desktop - http://converge.cti.dtu.dk/news
'and what is the use of a computer' thought Alice 'without pictures or
conversation' with apologies to Lewis Carroll
*************************************************
--__--__--
Message: 5
Date: Wed, 25 Apr 2001 14:01:27 -0700
To: Michael Rose <ro...@te...>, jyt...@li...
From: Deirdre Saoirse Moen <de...@de...>
Subject: Re: [Jython-users] Jython on MacOS X?
>Deirdre writes:
>
>> I hadn't really thought about doing it this way, but it seemed that it
>> might need a whole bunch more wrappering to do it that way, or am I
wrong?
>You are right. I think there's a project for this on SourceForge called
>PyObjC.
Cool, thanks for the link, I hadn't known about it.
>> In other words, if there's an AppKit class for NSObject, and I need to
add
>> a controller subclass, I can do that directly in Jython?
>>
>> It seems like the CPython would require wrapping NSObject, right? Or am I
>> missing something?
>No, you're not missing anything. You've just run into the pervasive 'Law of
>Conservation of Difficulty'. Java/jython integration is much easier, but
>Interface Builder is basically Objective-C with bridges for the Java
>versions of AppKit classes. I have no wise words on the best approach, but
>I'm also taking a fi[r]st shot at the Jython/Java way.
Coolness. Well, I've been going through the Java tutorial today and I think
I have the hang of it. I did some ObjC programming when RDR2 came out, but
that was three years ago.
Back to the project....
--
_Deirdre Stash-o-Matic: http://weirdre.com http://deirdre.net
"I love deadlines. I like the whooshing sound they make as they fly by."
- Douglas Adams
--__--__--
Message: 6
Date: Wed, 25 Apr 2001 23:01:22 -0700 (PDT)
From: Adam Berger <sir...@ya...>
To: jyt...@li...
Subject: [Jython-users] Package cache dir
When I use a script to run Jython, and my current
directory isn't Jython's home directory, I get the
message:
*sys-package-mgr*: can't create package cache dir,
'/cachedir/packages'
Jython 2.1a1 on java1.3.0 (JIT: jitc)
The python.home property and classpaths are
initialized correctly. What am I missing?
Adam
__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/
--__--__--
Message: 7
Date: Thu, 26 Apr 2001 01:26:46 -0700
To: Michael Rose <ro...@te...>, jyt...@li...
From: Deirdre Saoirse Moen <de...@de...>
Subject: Re: [Jython-users] Jython on MacOS X?
I have a few more questions.....
1) I basically want to code in python.
2) I'm confused by the examples. I understand how I can use a .py file with
jython. What I'm not clear on is how I'd do that within the confines of
Project Builder/Interface Builder, which calls javac.
So, ultimately what I'd like is NOT to recompile python as Java (though I
could I suppose) but rather write python in a way that Java is happy with.
I'm obviously missing something because it's not clear to me at all, but if
I could just step over this hurdle, I'd have a project....
--
_Deirdre Stash-o-Matic: http://weirdre.com http://deirdre.net
"I love deadlines. I like the whooshing sound they make as they fly by."
- Douglas Adams
--__--__--
Message: 8
Reply-To: <nei...@ca...>
From: "Neil Benn" <nei...@ca...>
To: <jyt...@li...>
Subject: RE: [Jython-users] Running auto-discovered methods
Date: Thu, 26 Apr 2001 09:32:48 +0100
Hello,
That's great, thanks for posting that message Brian, I've looked at
the
link you posted but I can't seem to find any information about 'walking the
path' as you mentioned to discover the arguments. Would it be possible to
elaborate on that point please?
Much appreciated.
Cheers,
Neil
-----Original Message-----
From: jyt...@li...
[mailto:jyt...@li...]On Behalf Of brian
zimmer
Sent: 21 April 2001 15:10
To: Scott Knight; jython
Subject: RE: [Jython-users] Running auto-discovered methods
Scott,
Here's an example of what I think you are looking for (it works equally well
on a [Java|Python] [class|instance]:
>>> class Test:
... def go(self):
... print "invoked go"
... def went(self):
... print "invoked went"
...
>>> t = Test()
>>> dir(t.__class__)
['__doc__', '__module__', 'go', 'went']
>>> for a in dir(t.__class__):
... if a[0:2] <> "__":
... getattr(t, a)()
...
invoked go
invoked went
>>>
Notice the line:
getattr(t, a)()
The built-in 'getattr' retuns a method bound on the instance t, similar to a
Method object in Java. In Java, to execute the Method,
you would call:
m.invoke(instance, params)
in Python you use the callable nature of objects and invoke it by:
m(params)
since the method is already bound to the instance you don't need to pass it
as a param as you do in Java since in Java the Method is
always bound to the class, not an instance.
For a more indepth look at when the method is bound to an instance and when
to a class:
>>> getattr(Test, "go")
<unbound method Test.go>
>>> getattr(t, "go")
<method Test.go of Test instance at 3335245>
>>> getattr(Test, "go")(t)
invoked go
>>> getattr(t, "go")()
invoked go
>>>
Notice that when I get the method from the class, I need to pass an instance
to invoke it, fulfilling the contract for sending a
'self' argument.
Also note that neither go() or went() required arguments in my example. If
you really want to blindly invoke methods you'll need to
figure out if they require arguments. In general, the invoker knows the
arguments required, such as the callback in os.path.walk().
You might want to check out this as well:
http://www.diveintopython.org/apihelper_getattr.html
hope this helps,
brian
> -----Original Message-----
> From: jyt...@li...
> [mailto:jyt...@li...]On Behalf Of Scott
> Knight
> Sent: Saturday, April 21, 2001 7:52 AM
> To: jython
> Subject: [Jython-users] Running auto-discovered methods
>
>
> A few days ago, Neil Benn queried "Self Describing Scripts in Jython"
> and appears to be wanting to do something similar to what I need:
> something analogous to Java's Reflection. I can easily get a list of
> the method names in a class. I can't figure out how to invoke the
> method given it's name in string form. What I am really after is to
> cycle through all of the method names in the list and run them all,
> rather than type up a method that calls each of a couple hundred methods
> statically.
> --
> Scott Knight mailto:sc...@sc...
> http://www.scottknight.com/
>
> _______________________________________________
> Jython-users mailing list
> Jyt...@li...
> http://lists.sourceforge.net/lists/listinfo/jython-users
_______________________________________________
Jython-users mailing list
Jyt...@li...
http://lists.sourceforge.net/lists/listinfo/jython-users
--__--__--
Message: 9
Reply-To: <bz...@zi...>
From: "brian zimmer" <bz...@zi...>
To: <nei...@ca...>, <jyt...@li...>
Subject: RE: [Jython-users] Running auto-discovered methods
Date: Thu, 26 Apr 2001 06:47:52 -0500
Neil,
What I was trying to say was some functions require a number of arguments
and it's not easily discerned at runtime the number or the
types of those arguments unless the caller knows it ahead of time. So just
blindly calling methods discovered from dir() will most
likely result in a number of 'not enough arguments' errors.
A number of python modules provide some sort of naming convention to handle
this issue, such as xmllib when you subclass the default
parser. At each start of an element in the document it looks for a method
called 'start_ELEMENTNAME' to invoke with the attributes
of the element. This is a documented feature and how the caller of the
method knows what and how many arguments to pass.
http://www.python.org/doc/current/lib/module-xmllib.html
os.path.walk() is a method that walks through the filesystem path. At each
directory it invokes a callable function, supplied by
the user, with three argument '(args, root, files)'. Again, this is
documented. If the caller didn't know the callback expected
these three arguments an Error would occur.
http://www.python.org/doc/current/lib/module-os.path.html
I hope this clarifies things a bit. My point is if you want to invoke
random methods on an instance, the general pythonic way of
doing so is adopting a naming convention (such as xmllib or unittest) and
only calling methods that adhere to the naming scheme.
It's the simplest and safest way to know the methods you are calling expect
you to be calling them.
brian
> -----Original Message-----
> From: jyt...@li...
> [mailto:jyt...@li...]On Behalf Of Neil Benn
> Sent: Thursday, April 26, 2001 3:33 AM
> To: jyt...@li...
> Subject: RE: [Jython-users] Running auto-discovered methods
>
>
> Hello,
>
> That's great, thanks for posting that message Brian, I've looked at
the
> link you posted but I can't seem to find any information about 'walking
the
> path' as you mentioned to discover the arguments. Would it be possible to
> elaborate on that point please?
>
> Much appreciated.
>
> Cheers,
>
> Neil
>
> -----Original Message-----
> From: jyt...@li...
> [mailto:jyt...@li...]On Behalf Of brian
> zimmer
> Sent: 21 April 2001 15:10
> To: Scott Knight; jython
> Subject: RE: [Jython-users] Running auto-discovered methods
>
>
> Scott,
>
> Here's an example of what I think you are looking for (it works equally
well
> on a [Java|Python] [class|instance]:
>
> >>> class Test:
> ... def go(self):
> ... print "invoked go"
> ... def went(self):
> ... print "invoked went"
> ...
> >>> t = Test()
> >>> dir(t.__class__)
> ['__doc__', '__module__', 'go', 'went']
> >>> for a in dir(t.__class__):
> ... if a[0:2] <> "__":
> ... getattr(t, a)()
> ...
> invoked go
> invoked went
> >>>
>
> Notice the line:
>
> getattr(t, a)()
>
> The built-in 'getattr' retuns a method bound on the instance t, similar to
a
> Method object in Java. In Java, to execute the Method,
> you would call:
>
> m.invoke(instance, params)
>
> in Python you use the callable nature of objects and invoke it by:
>
> m(params)
>
> since the method is already bound to the instance you don't need to pass
it
> as a param as you do in Java since in Java the Method is
> always bound to the class, not an instance.
>
> For a more indepth look at when the method is bound to an instance and
when
> to a class:
>
> >>> getattr(Test, "go")
> <unbound method Test.go>
> >>> getattr(t, "go")
> <method Test.go of Test instance at 3335245>
> >>> getattr(Test, "go")(t)
> invoked go
> >>> getattr(t, "go")()
> invoked go
> >>>
>
> Notice that when I get the method from the class, I need to pass an
instance
> to invoke it, fulfilling the contract for sending a
> 'self' argument.
>
> Also note that neither go() or went() required arguments in my example.
If
> you really want to blindly invoke methods you'll need to
> figure out if they require arguments. In general, the invoker knows the
> arguments required, such as the callback in os.path.walk().
>
> You might want to check out this as well:
>
> http://www.diveintopython.org/apihelper_getattr.html
>
> hope this helps,
>
> brian
>
> > -----Original Message-----
> > From: jyt...@li...
> > [mailto:jyt...@li...]On Behalf Of Scott
> > Knight
> > Sent: Saturday, April 21, 2001 7:52 AM
> > To: jython
> > Subject: [Jython-users] Running auto-discovered methods
> >
> >
> > A few days ago, Neil Benn queried "Self Describing Scripts in Jython"
> > and appears to be wanting to do something similar to what I need:
> > something analogous to Java's Reflection. I can easily get a list of
> > the method names in a class. I can't figure out how to invoke the
> > method given it's name in string form. What I am really after is to
> > cycle through all of the method names in the list and run them all,
> > rather than type up a method that calls each of a couple hundred methods
> > statically.
> > --
> > Scott Knight mailto:sc...@sc...
> > http://www.scottknight.com/
> >
> > _______________________________________________
> > Jython-users mailing list
> > Jyt...@li...
> > http://lists.sourceforge.net/lists/listinfo/jython-users
>
>
> _______________________________________________
> Jython-users mailing list
> Jyt...@li...
> http://lists.sourceforge.net/lists/listinfo/jython-users
>
>
> _______________________________________________
> Jython-users mailing list
> Jyt...@li...
> http://lists.sourceforge.net/lists/listinfo/jython-users
--__--__--
Message: 10
Date: Thu, 26 Apr 2001 17:22:12 +0200
From: Michael Rose <ro...@te...>
To: Deirdre Saoirse Moen <de...@de...>,
"jyt...@li..."
<jyt...@li...>
Subject: Re: [Jython-users] Jython on MacOS X?
--On Thursday, April 26, 2001 1:26 AM -0700 Deirdre Saoirse Moen
<de...@de...> wrote:
> 2) I'm confused by the examples. I understand how I can use a .py file
> with jython. What I'm not clear on is how I'd do that within the confines
> of Project Builder/Interface Builder, which calls javac.
PB/IB are currently 'Python Challenged' - it's not possible to actually run
a .py file from inside project builder.
> So, ultimately what I'd like is NOT to recompile python as Java (though I
> could I suppose) but rather write python in a way that Java is happy with.
>
The only other thing that is possible is to use the Python Interpreter in
your Java classes. In other words, Java has to be in control, but you can
call Jython classes from there. It's a passable middle ground for now.
Good luck
Michael
************************************************
Assoc. Prof. Michael Rose
Center for Tele-Information, Technical University of Denmark
(45) 45 25 51 72 mailto:ro...@te...
Off the Desktop - http://converge.cti.dtu.dk/news
'and what is the use of a computer' thought Alice 'without pictures or
conversation' with apologies to Lewis Carroll
*************************************************
--__--__--
Message: 11
Date: Thu, 26 Apr 2001 09:01:32 -0700
To: Michael Rose <ro...@te...>, jyt...@li...
From: Deirdre Saoirse Moen <de...@de...>
Subject: Re: [Jython-users] Jython on MacOS X?
>PB/IB are currently 'Python Challenged' - it's not possible to actually run
>a .py file from inside project builder.
I'm aware of that.
> The only other thing that is possible is to use the Python Interpreter in
>your Java classes. In other words, Java has to be in control, but you can
>call Jython classes from there. It's a passable middle ground for now.
Are you saying it would have to be like the embedded example (as in
http://www.jython.org/docs/embedding.html )? Because that's really ugly
imho.
Or is there a way to get the headers right so that one can simply subclass
(as in http://www.jython.org/docs/subclassing.html )? Because if there is,
I don't quite understand what to put at the top.
Sorry to be dense, but I'm dealing with too many variables to make me happy.
:)
--
_Deirdre Stash-o-Matic: http://weirdre.com http://deirdre.net
"I love deadlines. I like the whooshing sound they make as they fly by."
- Douglas Adams
--__--__--
Message: 12
Date: Thu, 26 Apr 2001 16:03:46 -0500 (CDT)
From: "Robert W. Bill" <rb...@di...>
To: Adam Berger <sir...@ya...>
cc: <jyt...@li...>
Subject: Re: [Jython-users] Package cache dir
Hello Adam,
On Wed, 25 Apr 2001, Adam Berger wrote:
> When I use a script to run Jython, and my current
> directory isn't Jython's home directory, I get the
> message:
>
> *sys-package-mgr*: can't create package cache dir,
> '/cachedir/packages'
> Jython 2.1a1 on java1.3.0 (JIT: jitc)
This is usually the result of permission problems. A mkdir cachedir;
chmod a+rw cachedir in the Jython directory should fix it.
> The python.home property and classpaths are
> initialized correctly. What am I missing?
The value of python.home is where you should add and chmod the cachedir.
Cheers,
Robert
--__--__--
_______________________________________________
Jython-users mailing list
Jyt...@li...
http://lists.sourceforge.net/lists/listinfo/jython-users
End of Jython-users Digest
|