AIML, Python, Java

2007-07-04 Thread Boris Ozegovic
Hi

I have a chatterbot written in AIML.  I am using PyAIML, and HTTP server as
a mediator between user and PyAIML.  Server calls PyAIML, and sends the
result string to the sensor network which is written in Java; and in the
end, server returns value from Java method.  Can I somehow call Java
methods inside Python code, or I must use Jython?  Can I use PyAIML in
Jython?  

-- 
Ne dajte da nas lažljivac Bandić truje:
http://cnn.blog.hr/arhiva-2007-06.html#1622776372
-- 
http://mail.python.org/mailman/listinfo/python-list


httplib module

2007-07-07 Thread Boris Ozegovic
Why do I get double new lines when geting data from server?  Example:

I have a following file:
--start-


Ovo je testni primjerak


--end---

And the code is:
conn = httplib.HTTPConnection("localhost:8000")
conn.request("GET", "/folder/index.html")
response = conn.getresponse()
reply = response.read()

print reply
\n\n\n\nOvo je testni primjerak\n\n\n\n\n\n

-- 
Ne dajte da nas lažljivac Bandić truje:
http://cnn.blog.hr/arhiva-2007-06.html#1622776372
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: httplib module

2007-07-07 Thread Boris Ozegovic
Boris Ozegovic wrote:

> Why do I get double new lines when geting data from server?  Example:

Fixed.

-- 
Ne dajte da nas lažljivac Bandić truje:
http://cnn.blog.hr/arhiva-2007-06.html#1622776372
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: httplib module

2007-07-08 Thread Boris Ozegovic
Steve Holden wrote:

>>> Why do I get double new lines when geting data from server?  Example:
> How? It's customary to include details when you've solved your own 
> problem in case someone else gets the same issue.

Ok.  In do_GET I had this two lines:

for line in file:
print line 

As you can see, print inserted another \n.  :-)

Correct code is:

for line in file:
print line, 

-- 
Ne dajte da nas lažljivac Bandić truje:
http://cnn.blog.hr/arhiva-2007-06.html#1622776372
-- 
http://mail.python.org/mailman/listinfo/python-list


cookielib

2007-08-10 Thread Boris Ozegovic
Hi

I have HTTP client which accepts cookies.  If client allready has cookie,
but that cookie has expired, server sends him new cookie, and in response
object Set-Cookie: header everything is fine, but if I reload request,
client sends expired cookie, and not the new one.  In cookiejar there is
only new and valid cookie, and if I use regular browser everything is fine.
The code is following:

urlopen = urllib2.urlopen
Request = urllib2.Request
cj = cookielib.LWPCookieJar()
COOKIEFILE = 'cookies.lwp'

if os.path.isfile(COOKIEFILE):
# if we have a cookie file already saved
# then load the cookies into the Cookie Jar
cj.load(COOKIEFILE)

opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
urllib2.install_opener(opener)
url = "http://localhost:8000/files/index.html";
params = {'question':question}
data = urllib.urlencode(params)
Request(url, data)
try:
response = urlopen(Request)
etc.

Only if I create new request object the new cookie is send, but I don't
want to create new object.  And idea?

-- 
Ne dajte da nas lažljivac Bandić truje:
http://cnn.blog.hr/arhiva-2007-06.html#1622776372
-- 
http://mail.python.org/mailman/listinfo/python-list


I Need help from all the group participants

2007-08-20 Thread Boris Ozegovic
Hi, 

I am working on some system, and the communication will take place through
the chatterbot which will be written in AIML (interpreter is written in
Python).  English is not my mother tongue, so I need huge favor:  if all of
you can write two sentences, so that I could have greater pattern base.
The first sentence is finding someone's heart rate, example: "Please, can
you tell me John's heart rate", and the other one is setting the alarm when
someone's heart rate is lower then x, and greater than y, example: "Can
you, please, send me information when John's heart rate is lower than 60,
and greater than 100".  You can manipulate time (right now, now, right this
moment), and everything else you can think about.

-- 
Ne dajte da nas lažljivac Bandić truje:
http://cnn.blog.hr/arhiva-2007-06.html#1622776372
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I Need help from all the group participants

2007-08-20 Thread Boris Ozegovic
[EMAIL PROTECTED] wrote:

> The only sentence that comes to mind is: 
> 
> "I hope I never find myself in a hospital that uses your system."

You are not funny. The system isn't for hospitals, it is for university
purposes.

-- 
Ne dajte da nas lažljivac Bandić truje:
http://cnn.blog.hr/arhiva-2007-06.html#1622776372
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I Need help from all the group participants

2007-08-20 Thread Boris Ozegovic
[EMAIL PROTECTED] wrote:

> I would be happy to help but I don't have a clear understand of what
> the poster needs.

Suppose you want to find out what is someone's pulse/heart rate, you can
ask question in many ways, syntaxically, but with same semantic.  One way
to find out someone's pulse is to ask: "What is John's pulse", other is
"Please, tell me, what is Jonh's pulse", or "Send me John's pulse
immediatelly!", etc.  So, if you can write some other question to find out
someone's pulse, please do, but, it would be great if your question would
have different pattern, e.g. "Please, tell me John's pulse immediatelly"
and "Tell me John's pulse right now" have the same pattern, because they
are syntaxically very alike.

-- 
Ne dajte da nas lažljivac Bandić truje:
http://cnn.blog.hr/arhiva-2007-06.html#1622776372
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I Need help from all the group participants

2007-08-20 Thread Boris Ozegovic
Jason wrote:

> I wonder what John's pulse is?  Display John's pulse.  I need to know
> John's pulse.  How many beats per minute is John's heart going?
> What's John's pulse rate?  How fast is John's heart rate?  How fast is
> John's blood pumping?  What is the rate of John's heart?  What is the
> rate of John's pulse?  How fast is John's heart beating?  What is the
> frequency of John's heart pulses?  What is the frequency of John's
> cardiac cycle?  How fast is John's cardiac cycle?  What is the rate of
> John's pulse?  I want the result of John's auscultation.  Give me
> John's heart beats, or give John death!

Wow!  Thank you very much!  

> If you're trying to do some natural language processing, you should

I'm doing project in AIML, www.alicebot.org/ , which will do all behind
work for me, and I only need to combine patterns, for example (if you are
interested  :) http://www.pandorabots.com/botmaster/en/tutorial?ch=6 , you
can see how AIML works.  Unfortunetly, the problem with NLP, and AIML, is
that you need programmer and someone with linguistic skills.  :) 

-- 
Ne dajte da nas lažljivac Bandić truje:
http://cnn.blog.hr/arhiva-2007-06.html#1622776372
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I Need help from all the group participants

2007-08-21 Thread Boris Ozegovic
Aaron wrote:

[...]
> Good luck.  

Thanks a lot for your help.

-- 
Ne dajte da nas lažljivac Bandić truje:
http://cnn.blog.hr/arhiva-2007-06.html#1622776372
-- 
http://mail.python.org/mailman/listinfo/python-list


localhost, ?!

2007-08-28 Thread Boris Ozegovic
Three machines, one at my home, other two at my job, in every machine there
is Win XP SP2 and Python 2.5

At home:
urllib2.urlopen("http://localhost";), everything is ok

At job:
urllib2.urlopen("http://localhost";)
raise BadStatusLine(line), after half a minute.

urllib2.urlopen("http://127.0.0.1";)
HTTP Error 503: Service Unavailable, immediately.

Anybody have slightest clue wthat is going on?  :-/

If I use urllib, then localhost works on every machine, and urllib2 works
on every machine when retreiving URLs outside localhost.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: localhost, ?!

2007-08-28 Thread Boris Ozegovic
Fabio Z Tessitore wrote:

> I think to have http://localhost working you need a web server (like 
> apache). maybe you have it at your home.

I do have Apache.  You can see that urllib, older module, works correctly.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: localhost, ?!

2007-08-28 Thread Boris Ozegovic
Bjoern Schliessmann wrote:

> Definitely a problem with the web server (503 means "service
> unavailable").

I did try on two servers, Apache and simple python server.  There was
identically error on both servers.
  
>> Anybody have slightest clue wthat is going on?  :-/
> 
> Try using wireshark or a similar tool to see what's going on on
> protocol level.

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


Python data visualization

2007-04-11 Thread Boris Ozegovic
Hi

I don't know if someone is familiar with Java JUNG, framework for data
visualization (http://jung.sourceforge.net/), I am interested is there
anything lik JUNG for Python?  

-- 
Greatest shits:
http://www.net.hr/vijesti/page/2007/03/30/0030006.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Best way to document Python code...

2007-01-22 Thread Boris Ozegovic
Adonis Vargas wrote:

> Then Python will generate a quick help interface for your module. I 

Hi

Does Python has API just like in Java, for example
http://java.sun.com/j2se/1.5.0/docs/api/allclasses-noframe.html ctrl-f and
than click on class you are searching for, and finally you get clean list
of all fields and methods.  Where can I find similar in Python, for
example, if I would like to see which methods list/dictionary has.

-- 
"kad imaš 7 godina glup si ko kurac, sve je predobro: autići i bageri u
kvartu.. to je život"
Drito Konj
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Sorting a list

2007-02-01 Thread Boris Ozegovic
John Salerno wrote:

> Hi everyone. If I have a list of tuples, and each tuple is in the form:
> 
> (year, text) as in ('1995', 'This is a citation.')
> 
> How can I sort the list so that they are in chronological order

L.sort()

-- 
"kad imaš 7 godina glup si ko kurac, sve je predobro: autići i bageri u
kvartu.. to je život"
Drito Konj
-- 
http://mail.python.org/mailman/listinfo/python-list


Jython

2007-02-03 Thread Boris Ozegovic
Hi

Why this doesn't work:

def go():
for line in open("bobo.txt", "r"):
print line

go()

python FileReader.py: everything ok
jython FileReader.py:

Traceback (innermost last):
  File "FileReader.py", line 6
  File "FileReader.py", line 3
AttributeError: __getitem__

-- 
"A mi smo stranci u vlastitoj zemlji zbog ljudskog sljama, lipa nasa
silovana"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Jython

2007-02-03 Thread Boris Ozegovic
[EMAIL PROTECTED] wrote:

> Files aren't lists and thus don't have the functions for iteration.

They do have iterator:

C:\Documents and Settings\Silovana Vjeverica\Desktop>python FileReader.py
'import site' failed; use -v for traceback
boris ozegovic
vedran ozegovic

-- 
"A mi smo stranci u vlastitoj zemlji zbog ljudskog sljama, lipa nasa
silovana"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Jython

2007-02-03 Thread Boris Ozegovic
Boris Ozegovic wrote:

> [EMAIL PROTECTED] wrote:
> 
>> Files aren't lists and thus don't have the functions for iteration.
> 
> They do have iterator:
> 
> C:\Documents and Settings\Silovana Vjeverica\Desktop>python FileReader.py
> 'import site' failed; use -v for traceback
> boris ozegovic
> vedran ozegovic

But apparently not in Jython...  Only Python.

Tnx, anyway

-- 
"A mi smo stranci u vlastitoj zemlji zbog ljudskog sljama, lipa nasa
silovana"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Jython

2007-02-03 Thread Boris Ozegovic
[EMAIL PROTECTED] wrote:

> Files aren't lists and thus don't have the functions for iteration.
> 
> Try:
> 
> def go():
> for line in open("bobo.txt", "r").readlines():
> print line
> 
> go()

For example, you can do even this:

import sys

for line in sys.stdin:
print line, 


python FileReader.py < bobo.tx

'import site' failed; use -v for traceback
boris ozegovic
vedran ozegovic

-- 
"A mi smo stranci u vlastitoj zemlji zbog ljudskog sljama, lipa nasa
silovana"
-- 
http://mail.python.org/mailman/listinfo/python-list


Module problem

2007-02-06 Thread Boris Ozegovic
Hi

I am writing some simple script, and when I start my script from command
line (python Imenik.py), everything works perfectly.  If I double clik the
same script in my desktop I get the following error:

"No module name import win32clipboard"

-- 
"A mi smo stranci u vlastitoj zemlji zbog ljudskog sljama, lipa nasa
silovana"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Module problem

2007-02-06 Thread Boris Ozegovic
Matimus wrote:

> Do you have more than one version of Python installed? Is
> win32clipboard installed for both versions? It could be that the

Yup, that was the problem.  Thanx!

-- 
"A mi smo stranci u vlastitoj zemlji zbog ljudskog sljama, lipa nasa
silovana"
-- 
http://mail.python.org/mailman/listinfo/python-list


Functions, parameters

2007-02-08 Thread Boris Ozegovic
Hi, I'am still learning Python and while reading Django tutorial couldn't
understand this part:

class Poll(models.Model):
question = models.CharField(maxlength=200)
pub_date = models.DateTimeField('date published')


# Django provides a rich database lookup API that's entirely driven by
# keyword arguments.
>>> Poll.objects.filter(question__startswith='What')

This 'question__startswith' is the problem.  What is the common idiom for
this type od arguments, so I can Google it?  I understand what this filter
is suppose to do, but don't know how it is done (this separation of Poll
atribute and startwith function).

-- 
http://www.nacional.hr/articles/view/23894/23
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Functions, parameters

2007-02-08 Thread Boris Ozegovic
Bruno Desthuilliers wrote:

> Why don't you just read the source code ? Django is free software, you 
> know !-)

Yes, I know.  :)  

> What about something like:
 
> def filter(self, **kw):
>for argname, value in kw.items():
>  fieldname, op = argname.split('__', 1)

Yes, this is what confused me in the first place: how to separate
arguments.  If you call split, and split returns list of String, then you
have fieldname = 'question' and startwith = 'what', and not references at
question and startwith, or am I missing something big.  

-- 
http://www.nacional.hr/articles/view/23894/23
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Functions, parameters

2007-02-08 Thread Boris Ozegovic
Paul Rubin wrote:

> Since split is applied to argname, it retrieves 'question' and 'startswith'.

Exactly.  :)  And, 'questions' and 'startswith' are two string, and not
references at Poll.question, or more precisely, instanceOfPoll.question.

I suppose this is what I was looking for:


__getattribute__(...)
x.__getattribute__('name') <==> x.name

Tnx guys.

-- 
http://www.nacional.hr/articles/view/23894/23
-- 
http://mail.python.org/mailman/listinfo/python-list


Django, one more newbie question

2007-02-09 Thread Boris Ozegovic
Umm, can somebody tell me which language is this one:

{% if latest_poll_list %}

{% for poll in latest_poll_list %}
{{ poll.question }}
{% endfor %}

{% else %}
No polls are available.
{% endif %}

Whole tutorial is on this page:
http://www.djangoproject.com/documentation/tutorial3/
 
endfor, endif, {{?  :)

-- 
http://www.nacional.hr/articles/view/23894/23
-- 
http://mail.python.org/mailman/listinfo/python-list


Module trouble [newbie]

2007-02-23 Thread Boris Ozegovic
Can somebody explaint this to me:

I have module a.py
A = 100
import b
print "A printing"
print "B is %s" % b.B

and module b.py
B = 2000
import a
print "B printing"
print "A is %s" % a.A

I thought that output would be:
B printing
A is 100
A printing
B is 2000

Because import b would execute b.py, and in b.py line "import a" would be
ignored, but my output is:

>>> import a
100
A printing
B is 100

??

:)

-- 
http://www.nacional.hr/articles/view/23894/23
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Module trouble [newbie]

2007-02-23 Thread Boris Ozegovic
Diez B. Roggisch wrote:

> Are you sure the above is what you really used for your test? Because your
> output features a single 100, which the above lacks a print-statement for.

Yeah, I cancelled the message, but synchronization allready happened.  :)

Problem was in some other place.

One more question: is calling import inside function definition poor
design?  e.g.

def foo():
   doSomething:
   import someModule
   someModule.doSomethin

-- 
http://www.nacional.hr/articles/view/23894/23
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Module trouble [newbie]

2007-02-23 Thread Boris Ozegovic
Diez B. Roggisch wrote:

> I use it sometimes myself, to avoid otherwise circular imports. 

Circular imports are the reason why I have module issues.  Last question:
if I put modules in some package and then try to import one I get
"AttributeError: 'module' object has no attribute 'a'

Code is:

a.py
A = 756
import someFolder.b as b
print "A printing"
print "B is %s" % b.B

b.py
B = 2000
import someFolder.a as a
print "B printing"
print "A is %s" % a.A

How can I do circular imports if I use packages?  Darn.  I don't remeber
this module gothcas when reading Learning Python.

-- 
http://www.nacional.hr/articles/view/23894/23
-- 
http://mail.python.org/mailman/listinfo/python-list


Pydev, Eclipse

2008-02-22 Thread Boris Ozegovic
Hi

Suppose I have three blocks:
if 1:
if 2:
if 3:
# here I want my cursor go back to second block (if 2:)

What is the standard shortcut for this?  ctrl+arrow keys aren't, arrow keys
alone aren't either.

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


Re: Pydev, Eclipse

2008-02-22 Thread Boris Ozegovic
Preston Landers wrote:

> Shift-Tab does it for me.  It can also dedent whole blocks if you have
> them selected.

Excellent.  Thank you.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Simple - looking for a way to do an element exists check..

2008-02-23 Thread Boris Ozegovic
Paul Rubin wrote:

>  if any(x[0]==element[0] for x in a): 

How come this list comprehension isn't in [] brackets?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Simple - looking for a way to do an element exists check..

2008-02-23 Thread Boris Ozegovic
TeroV wrote:

> It isn't list comprehension, it is generator expression 
> http://en.wikipedia.org/wiki/Python_syntax_and_semantics#Generator_expressions

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