#jython IRC Log (v0.9)

Index

IRC Log for 2011-05-22

Timestamps are in GMT/BST.

[1:00] * lopex (lopex@84-10-213-252.dynamic.chello.pl) Quit ()
[2:08] * wmeissner (~wmeissner@2406:a000:f005:9e00:225:ff:fe4d:e0c3) Quit (Quit: wmeissner)
[2:17] * clajo04_ (~clajo04_@pool-108-41-219-3.nycmny.fios.verizon.net) has joined #jython
[5:10] * shashank (~shashank@c-98-245-87-8.hsd1.co.comcast.net) has joined #jython
[5:58] * shashank (~shashank@c-98-245-87-8.hsd1.co.comcast.net) Quit (Ping timeout: 240 seconds)
[6:37] * jabley (~jabley@cpc1-farn4-0-0-cust318.6-2.cable.virginmedia.com) has joined #jython
[7:56] * jabley (~jabley@cpc1-farn4-0-0-cust318.6-2.cable.virginmedia.com) Quit (Quit: jabley)
[10:28] * MarderIII (~marderii@enneman.demon.nl) has joined #jython
[10:35] * jabley (~jabley@cpc1-farn4-0-0-cust318.6-2.cable.virginmedia.com) has joined #jython
[10:50] * jabley (~jabley@cpc1-farn4-0-0-cust318.6-2.cable.virginmedia.com) Quit (Quit: jabley)
[11:23] * thobe (~Adium@c83-249-235-76.bredband.comhem.se) has joined #jython
[11:32] * lopex (lopex@84-10-213-252.dynamic.chello.pl) has joined #jython
[13:39] * shashank (~shashank@c-98-245-87-8.hsd1.co.comcast.net) has joined #jython
[14:05] * lopex (lopex@84-10-213-252.dynamic.chello.pl) Quit ()
[14:21] * MarderIII (~marderii@enneman.demon.nl) Quit (Quit: [IRSSI] Life is too short. Grab a quickie every chance ya get)
[16:10] * shashank (~shashank@c-98-245-87-8.hsd1.co.comcast.net) Quit (Ping timeout: 248 seconds)
[16:28] * thobe (~Adium@c83-249-235-76.bredband.comhem.se) Quit (Quit: Leaving.)
[16:56] * thobe (~Adium@c83-249-235-76.bredband.comhem.se) has joined #jython
[17:11] * MarderIII (~marderii@enneman.demon.nl) has joined #jython
[17:21] * lopex (lopex@84-10-213-252.dynamic.chello.pl) has joined #jython
[17:52] * lopex (lopex@84-10-213-252.dynamic.chello.pl) Quit (Ping timeout: 250 seconds)
[18:02] * MarderIII (~marderii@enneman.demon.nl) Quit (Quit: [IRSSI] Fear...is that little dark room where negatives are developed)
[18:10] * lolsuper_ (~super_@unaffiliated/lolsuper-/x-9881387) has joined #jython
[18:14] * lopex (lopex@84-10-213-252.dynamic.chello.pl) has joined #jython
[18:25] * lolsuper_ (~super_@unaffiliated/lolsuper-/x-9881387) Quit (Quit: Leaving)
[18:25] * lolsuper_ (~super_@unaffiliated/lolsuper-/x-9881387) has joined #jython
[18:39] * jython-newbie (~raul@201.12.117.35) has joined #jython
[18:39] <jython-newbie> Hello
[18:39] <jython-newbie> I am trying to compile my java code
[18:40] <jython-newbie> but there is an error
[18:40] <jython-newbie> it says:
[18:40] <jython-newbie> SomaFabrica.java:4: package org.python.core does not exist
[18:40] <jython-newbie> import org.python.core.PyObject;
[18:41] <jython-newbie> Why I cannot import "org.python.core.PyObject" ?
[18:42] <agronholm> jython-newbie: because you don't have jython.jar in your build path?
[18:43] <agronholm> that's pretty much the case in all java building?
[18:43] <agronholm> if you can't import something, it's not on the build path
[18:44] <jython-newbie> How can I put the "jython.jar" in my build path? The file "jython.jar" and my codes are inside the same directory.
[18:52] <jython-newbie> Do I have to put my "jython.jar" and my java code in other directory to the system recognize the "org.python.core.PyObject" ?
[18:56] * stakkars_ (~tismer@brln-4db9694e.pool.mediaWays.net) has joined #jython
[19:11] * thobe (~Adium@c83-249-235-76.bredband.comhem.se) Quit (Ping timeout: 240 seconds)
[19:12] * thobe (~Adium@c83-249-235-76.bredband.comhem.se) has joined #jython
[19:13] * thobe1 (~Adium@c83-249-235-76.bredband.comhem.se) has joined #jython
[19:16] * thobe (~Adium@c83-249-235-76.bredband.comhem.se) Quit (Ping timeout: 260 seconds)
[19:19] * jabley (~jabley@cpc1-farn4-0-0-cust318.6-2.cable.virginmedia.com) has joined #jython
[19:21] <jython-newbie> How do I know my sys.path?
[19:24] <jython-newbie> agronholm: I've created a file "Soma.py" and I am trying to use this code in my Java code "interpreter.exec("from Soma import Soma");", where "Soma" is my file "Soma.py", but my file "Soma.py" must be in the sys.path. Where my sys.path?
[19:29] <agronholm> where is your sys.path...?
[19:29] <agronholm> that doesn't compute
[19:30] <agronholm> jython-newbie: why sys.path anyway
[19:31] <agronholm> jython-newbie: it's better if you just read the appropriate parts from the jython book
[19:31] <jython-newbie> I am trying to compile my code on NetBeans and it shows this message to me:
[19:31] <jython-newbie> Exception in thread "main" Traceback (most recent call last):
[19:31] <jython-newbie> File "<string>", line 1, in <module>
[19:31] <jython-newbie> ImportError: No module named Soma
[19:31] <jython-newbie> Java Result: 1
[19:32] <agronholm> just read the jython book: http://www.jython.org/jythonbook/en/1.0/index.html
[19:32] <jython-newbie> I've read
[19:32] <jython-newbie> it
[19:32] <agronholm> no you haven't
[19:32] <agronholm> you'd know by know that you cannot do that
[19:32] <jython-newbie> I did this: http://wiki.python.org/jython/JythonMonthly/Articles/October2006/3
[19:32] <agronholm> 2006, seriously?
[19:32] <agronholm> Jython 2.5 didn't even exist then
[19:33] <agronholm> http://wiki.python.org/jython/JythonFaq/EmbeddingJython
[19:34] <jython-newbie> I wasted my time again... there are lots and lots of texts about previous Jythons...
[19:34] <jython-newbie> This link that you passed to me there is:
[19:35] <jython-newbie> Using PythonInterpreter in Factories to instantiate python classes
[19:35] <agronholm> yes
[19:35] <jython-newbie> So, I've read the "Simple and Efficient Jython Object Factories from CharlieGroves"
[19:35] <jython-newbie> Doesn't it work anymore?
[19:35] <agronholm> so, you understand that you cannot compile python modules to java classes, right?
[19:36] <jython-newbie> the text "Simple and Efficient Jython Object Factories from CharlieGroves" doesn't work?
[19:36] <agronholm> you need to use the object factory approach
[19:36] <agronholm> you can use python code through an embedded PythonInterpreter
[19:36] <agronholm> in your Java code
[19:36] <agronholm> that's how I do it
[19:38] <agronholm> just don't try to make .class files for direct importing
[19:38] <agronholm> like so many others do
[19:39] <agronholm> it does not work with jython 2.5
[19:39] <jython-newbie> I know that
[19:39] <jython-newbie> agronholm: I am doing actually what you are saying to me
[19:40] <jython-newbie> *exactly
[19:40] <jython-newbie> I am using the object factory approach
[19:41] <agronholm> what was that thing before then
[19:44] <jython-newbie> agronholm: Did you read the text "Simple and Efficient Jython Object Factories" from the link that you passed to me?
[19:45] <agronholm> that was your link
[19:46] <agronholm> but what of it?
[19:46] * plankton (~kvirc@201-14-52-39.cscgo701.dsl.brasiltelecom.net.br) has joined #jython
[19:49] <jython-newbie> agronholm: I did exactly what that text said
[19:49] <jython-newbie> it is the object factory approach
[19:49] <agronholm> so where did you encounter difficulties
[19:50] <jython-newbie> There is a line that uses the PythonInterpreter
[19:50] <agronholm> yeah?
[19:51] <jython-newbie> it uses the method exec from the class PythonInterpreter
[19:51] <agronholm> and?
[19:51] <jython-newbie> interpreter.exec("from Building import Building");
[19:51] <jython-newbie> so
[19:51] <jython-newbie> the Building is the Building.py
[19:51] <jython-newbie> and it must be in the sys.path to work
[19:52] <agronholm> or in your classpath
[19:52] <jython-newbie> yes
[19:52] * plankton (~kvirc@201-14-52-39.cscgo701.dsl.brasiltelecom.net.br) Quit (Quit: KVIrc 4.0.2 Insomnia http://www.kvirc.net/)
[19:52] <agronholm> so put it there?
[19:52] <jython-newbie> I did the same, but my file is named "Soma.py"
[19:52] <jython-newbie> and I don't know where my classpath is to paste my "Soma.py" there
[19:53] <agronholm> well I'm no Netbeans expert but certainly you can see it in the run configuration?
[19:53] <agronholm> at least that is how it works with Eclipse
[20:07] <jython-newbie> Is there the package "org.jython.book.interfaces" in Jython? Or is it a package made by others?
[20:10] <jython-newbie> I am not understading this "package" and "import" from the example code of jython book
[20:10] <agronholm> a package is a directory containing __init__py
[20:10] <agronholm> __init__.py
[20:11] <jython-newbie> so... the "org" already exist but the "jython" is made by me inside the "org" ?
[20:12] <agronholm> that applies to Python packages
[20:12] <agronholm> and Java interfaces don't go to Python packages
[20:13] <agronholm> just read the book and don't skip critical parts
[20:13] <agronholm> why do you want to use Jython btw
[20:16] <agronholm> and what are you using it for?
[20:19] * jabley (~jabley@cpc1-farn4-0-0-cust318.6-2.cable.virginmedia.com) Quit (Ping timeout: 246 seconds)
[20:22] <jython-newbie> I want to use a class already made in python, but I have to make the code in Java.
[20:22] <jython-newbie> agronholm: Look my code in Java - http://pastebin.com/m0Xfiw6n
[20:23] <jython-newbie> at the end of the code I commented with the error which is been on NetBeans when I try to compile it
[20:24] <jython-newbie> Does it make sense to you? Or I am doing everything wrong?
[20:25] <agronholm> why jython.book.interfaces?
[20:25] <jython-newbie> I just copied from Jython Book 1.0
[20:25] <agronholm> surely you want to use your own package names instead the examples from the jython book
[20:26] <agronholm> ok so where is your python code then
[20:26] <agronholm> in the same directory as the rest?
[20:26] <jython-newbie> my python code is with my .java codes
[20:26] <jython-newbie> yes
[20:26] <agronholm> in org/jython/book/util/?
[20:27] <jython-newbie> no
[20:27] * jabley (~jabley@cpc1-farn4-0-0-cust318.6-2.cable.virginmedia.com) has joined #jython
[20:27] <agronholm> is your other code not there then?
[20:27] <jython-newbie> I created a package...
[20:27] <jython-newbie> no
[20:28] <agronholm> package org.jython.book.util;
[20:28] <agronholm> the first line in your java class
[20:28] <jython-newbie> ok... I will change it
[20:28] <agronholm> it won't work unless it's in that package
[20:32] <jython-newbie> all my files are in: /home/raul/?rea\ de\ Trabalho/Engenharia\ de\ Producao\Dantzig\SomaTeste\src\somateste
[20:34] <agronholm> so src is among your classpath entries?
[20:35] <jython-newbie> I think so
[20:36] <jython-newbie> I created a projet on NetBeans and I chose this directory to save my files
[20:36] <jython-newbie> by netbeans
[20:37] <agronholm> is Java your primary language
[20:39] <jython-newbie> I just know how to program in C language, but I know a little bit of Java and Python
[20:39] <jython-newbie> agronholm: See the new code - http://pastebin.com/y4s6udx7
[20:42] * stakkars_ (~tismer@brln-4db9694e.pool.mediaWays.net) Quit (Quit: schnarch)
[20:43] <agronholm> then you just need the __init__.py there to mark it as a python package
[20:50] <jython-newbie> I have to put the "Main.java" and the "Soma.py" in the same directory?
[20:50] * jabley (~jabley@cpc1-farn4-0-0-cust318.6-2.cable.virginmedia.com) Quit (Quit: jabley)
[20:50] <agronholm> if you do it this way
[20:50] <jython-newbie> It is
[20:50] <agronholm> then from somateste.Soma import Soma
[20:51] <jython-newbie> hm
[20:51] <jython-newbie> it didn't work
[20:52] <jython-newbie> interpreter.exec("from somateste.Soma import Soma");
[20:53] <jython-newbie> I tried also:
[20:53] <jython-newbie> interpreter.exec("from somateste import Soma");
[20:54] <agronholm> I think jimbaker claimed this should work
[20:54] <agronholm> are you sure you put __init__.py in that directory?
[20:56] <jython-newbie> where is the __init__.py ?
[20:56] <jython-newbie> I just have the file "Soma.py" that I've created
[20:57] <agronholm> just put an empty file called __init__.py in that directory
[20:57] <jython-newbie> ok
[20:57] <agronholm> it will indicate that the directory is a python package
[20:59] <jython-newbie> I copied the file "__init__.py" from /jython2.5.2/Lib/colletions inside the somateste directory
[20:59] <agronholm> it's just an empty file
[21:00] <jython-newbie> the same result with empty file
[21:01] <jython-newbie> .
[21:01] <jython-newbie> Exception in thread "main" Traceback (most recent call last):
[21:01] <jython-newbie> File "<string>", line 1, in <module>
[21:01] <jython-newbie> ImportError: cannot import name Soma
[21:01] <jython-newbie> Java Result: 1
[21:01] <agronholm> can you make a copy of everything in a zip file for me?
[21:01] <jython-newbie> yes
[21:02] <jython-newbie> accept please
[21:04] <jython-newbie> the code is in /SomaTeste/src/somateste
[21:05] <jython-newbie> I made the directories "fabrica" and "interfaces" to make like the example in Jython Book
[21:06] <jython-newbie> fabrica means factory
[21:10] <jython-newbie> agronholm: I have to go. Do you have any idead why my code doesn't work?
[21:10] <jython-newbie> *idea
[21:10] <agronholm> trying it now
[21:10] <jython-newbie> I have to go, but I will let my computer on.
[21:11] <jython-newbie> I will be back later and then I will chat to you again. Ok?
[21:11] <agronholm> k
[21:11] <jython-newbie> Thank you very much for your help!
[21:11] <jython-newbie> see you later
[21:11] <agronholm> a second
[21:12] <jython-newbie> ?
[21:12] <agronholm> ok I got somewhere with this
[21:12] <agronholm> I put the python code in a different directory
[21:13] <jython-newbie> where did you put the python code?
[21:13] <jython-newbie> did the Main work?
[21:13] <agronholm> I just made a dummy directory "tt"
[21:13] <agronholm> and from tt.Soma import Soma in the factory class
[21:13] <agronholm> tt of course contains __init__.py
[21:15] <jython-newbie> so... you made: /somateste/fabrica/tt ??
[21:15] <jython-newbie> or /somateste/tt ??
[21:15] <agronholm> just /tt
[21:15] <jython-newbie> what's wrong with the name "somateste" ?
[21:16] <jython-newbie> so you just renamed the "somateste" to "tt" ?
[21:16] <agronholm> I never said I renamed anything
[21:16] <agronholm> I said I made a directory named "tt"
[21:16] <agronholm> so the java code is in a different directory
[21:17] <jython-newbie> and tt is in somateste
[21:17] <jython-newbie> so... /somateste/tt/files.py
[21:17] <agronholm> jesus
[21:17] <agronholm> I said /tt
[21:17] <agronholm> not /somateste/tt
[21:20] <jython-newbie> so "tt" and "bin", "boot", "dev"... are in the same directory that is /
[21:20] <agronholm> what the heck?
[21:20] <agronholm> somatest is not in your root directory is it?
[21:20] <jython-newbie> ok
[21:21] <jython-newbie> I got it now
[21:23] <jython-newbie> instead of tt I created "pycodes"
[21:23] <jython-newbie> but...
[21:23] <jython-newbie> .
[21:23] <jython-newbie> Exception in thread "main" Traceback (most recent call last):
[21:23] <jython-newbie> File "__pyclasspath__/pycodes/Soma.py", line 5, in __init__
[21:23] <jython-newbie> AttributeError: read-only attr: num1
[21:23] <jython-newbie> Java Result: 1
[21:24] <agronholm> then you have to fix your code
[21:24] <jython-newbie> ok
[21:26] <agronholm> I see the problem
[21:27] <agronholm> you should use self._num1 and self._num2 for the private variables
[21:29] <jython-newbie> in Soma.py ?
[21:29] <agronholm> yes
[21:30] <jython-newbie> ...
[21:30] <jython-newbie> def __init__(self, num1, num2):
[21:30] <jython-newbie> self.num1 = num1
[21:30] <jython-newbie> self.num2 = num2
[21:30] <jython-newbie> ...
[21:30] <agronholm> I know what it looks like
[21:30] <agronholm> now make the changes
[21:30] <jython-newbie> but it's already with self
[21:30] <jython-newbie> --> self.num1 = num1
[21:31] <agronholm> are you not able to see the difference between what I suggested and the present state?
[21:31] <jython-newbie> I'm sorry but I don't program in Python...
[21:31] <agronholm> it just requires the ability to READ
[21:31] <agronholm> self._num1 <- see the _ before "num1"?
[21:32] <jython-newbie> I'm very sorry
[21:32] <jython-newbie> now I see
[21:33] <jython-newbie> IT WORKED! I'M SO HAPPY!
[21:33] <jython-newbie> Thank you very much
[21:33] <jython-newbie> I didn't understand why I had to use the underline
[21:33] <agronholm> because of some jython magic that makes get* methods descriptors
[21:34] <agronholm> so having a getNum1 makes it the getter for "num1"
[21:34] <agronholm> automatically
[21:34] <agronholm> and because you don't have a corresponding setNum1 method, the attribute becomes read-only
[21:35] <jython-newbie> thanks! ;)
[21:35] <jython-newbie> Now, I gotta go.
[21:36] * jython-newbie is now known as jython-newbie-aw
[21:36] * jython-newbie-aw is now known as jython-newbie-of
[21:36] * jython-newbie-of is now known as jynewbie-off
[23:53] * juneau001_ (~juneau@50.44.61.62) has joined #jython
[23:56] * juneau001 (~juneau@50.44.50.111) Quit (Ping timeout: 276 seconds)
[23:56] * juneau001_ is now known as juneau001

Index

These logs were automatically created by JythonLogBot_ on irc.freenode.net using a slightly modified version of the Java IRC LogBot (github).