Re: SocketServer and a Java applet listener

2005-08-29 Thread google

Steve Horsley schreef:

 [EMAIL PROTECTED] wrote:
  Dear newsgroup,
 
  I give up, I must be overseeing something terribly trivial, but I can't
  get a simple (Java) applet to react to incoming (python) SocketServer
  messages.
 
  Without boring you with the details of my code (on request available,
  though), here is what I do :
 
  I have a TCPServer and BaseRequestHandler .
  Connecting via telnet : everything goes OK.
 
  Connecting from Applet :
  problem 1 (worked around it) : java has some 'propietary' UTF-8 format,
  python's unicode doesn't seem to handle it correctly and I have to
  strip the first two bytes/chars , then all goes OK .
 

 Those 2 bytes are important! They are a string length indicator.
 Here are the docs that tell you that it puts a 2-byte length on
 the front:
 http://java.sun.com/j2se/1.5.0/docs/api/java/io/DataOutputStream.html#writeUTF(java.lang.String)
 If you are ignoring these bytes, then how can you be sure you
 have received the whole string? Please don't tell me you just
 hope that the whole string will always arrive in a single read()
 call. There is no guarantee of that. TCP does NOT have message
 boundaries, and TCP packets can be both fragmented and coalesced.

Ah, I see... I worked around this (see below), the workaround is
consistent with what you assume.
My question How to send/receive between python SocketServer and java
Applet (SocketListener) then seems to be boiling down to: How to
interface between python unicode and java read/writeUTF?


 Probably the same problem. If you didn't send a 2 byte length
 indicator first, then java's readUTF() will have tried to
 interpret the first 2 bytes that you did actually send as the
 string length, and may well simply be waiting patiently for the
 rest to arrive.

I just couldn't get read/writeUTF and python unicode to interface, so I
refactored the applet's socketlistener to convert the
socket.getInputStream to a BufferedInputReader on which I call the
readline() method.
I still skip the first two bytes in the python receiver which seems
harmless since python doesn't use the byte length.
On both sides I have other way to know when the end-of-message has been
reached. A timeout mechanism provides some safety for partial
transmission handling.


Thanks !



Thijs

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


Re: telnet.read_until() from telnetlib

2005-08-29 Thread Jacek Popławski
my newsreader told me that [EMAIL PROTECTED] wrote:
 Please post the minimum code necessary to duplicate the problem.

It's impossible, because I am writting performance tests for big commercial
project, I am trying to understand why they sometime fail. By definition of
read_until() it should return expected data (if it doesn't wait timeout
seconds).
Anyway, I am trying to use telnet.expect now, thanks.

-- 
Free Software - find interesting programs and change them
NetHack - meet interesting creatures, kill them and eat their bodies
Usenet - meet interesting people from all over the world and flame them
Decopter - unrealistic helicopter simulator, get it from http://decopter.sf.net
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: variable hell

2005-08-29 Thread Adriaan Renting
I'm sorry for top-posting and not marking quoted text, but my e-mail reader 
(Novell Groupwise 6 for Linux) does not mark quoted text. The only thing it 
does is the  $NAME $EMAIL $DATE  above the quoted text. Therefore I add 
my comments at the top. The only alternative I have is copying all text to an 
editor, adding quote marks by hand, then copying it back into a new e-mail 
message, but this takes to much of m time. If this is to confusing I will just 
stop posting in this list.

My original code was: exec(eval('a%s=%s' % (count, value)))
Then Rafi said: exec('a%s=%s' % (count, value))
To which I responded that his example does not work in my Python, and I think 
it's invalid.
Then Martin came with: exec 'a%s = %s' % (count, value)
This does work.
But he seems to keep telling me I'm quoting him wrong, while I'm quoting Rafi.

Furthermore I'm going with your suggestion of checking the imp, globals() and 
locals().

Adriaan Renting. 
 
Mike Meyer [EMAIL PROTECTED] 08/27/05 2:24 am  
[The context is totally hosed by top posting and failure to mark 
quoted text. I gave up on recovering it.] 
 
Adriaan Renting [EMAIL PROTECTED] writes: 
 
Not in my Python. 
 
for count in range(0, 10): 
... value = count 
... exec('a%s=%s' % (count, value)) 
 
You left in the extra set of quotes. Try this: 
 
for count in range(10): 
...  value = count 
...  exec 'a%s = %s' % (count, value) 
... 
dir() 
['__builtins__', '__doc__', '__file__', '__name__', 'a0', 'a1', 'a2', 'a3', 
'a4', 'a5', 'a6', 'a7', 'a8', 'a9', 'count', 'help', 'readline', 'rlcompleter', 
'sys', 'value'] 
 
I also removed the extraneous parens that you and Rafi both used - 
exec is a statement, not a function. 
 
Of course, your two examples are better done using imp and globals() or 
locals(). 
 
 mike 
 
dir() 
['__builtins__', '__doc__', '__name__', 'count', 'value'] 
for count in range(0, 10): 
... value = count 
... exec(eval('a%s=%s' % (count, value))) 
... 
dir() 
['__builtins__', '__doc__', '__name__', 'a0', 'a1', 'a2', 'a3', 'a4', 'a5', 
'a6', 'a7', 'a8', 'a9', 'count', 'value'] 
 
 
I myself use code like this to load user defined classes. 
exec(eval('from %s import %s' % (script, script))) 
exec(eval('self.user_class = %s()' % script)) 
self.user_class.run() 
 
But this can probably be done with the imp module too. 
  
rafi [EMAIL PROTECTED] 08/25/05 6:03 pm  
Adriaan Renting wrote: 
You might be able to do something along the lines of 
 
for count in range(0,maxcount): 
 value = values[count] 
 exec(eval('a%s=%s' % (count, value))) 
  
why using the eval? 
  
exec ('a%s=%s' % (count, value)) 
  
should be fine 
  
-- 
rafi 
  
Imagination is more important than knowledge. 
   (Albert Einstein) 
-- 
http://mail.python.org/mailman/listinfo/python-list 
 
 
-- 
Mike Meyer [EMAIL PROTECTED]http://www.mired.org/home/mwm/ 
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information. 
-- 
http://mail.python.org/mailman/listinfo/python-list 

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


Re: Lossless Number Conversion

2005-08-29 Thread Andreas Kostyrka
Am Sonntag, den 28.08.2005, 21:36 + schrieb Chris Spencer:
 Is there any library for Python that implements a kind of universal 
 number object. Something that, if you divide two integers, generates a 
 ratio instead of a float, or if you take the square root of a negative, 
 generates a complex number instead of raising an exception? Lisp has 
 something like this, and it makes number crunching much more convenient.

Yes and no. There isn't general solution. But for example you want to
allow complex number, just use cmath.

Andreas


signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: aproximate a number

2005-08-29 Thread Mikael Olofsson
Michael Sparks wrote:
 def approx(x):
 return int(x+1.0)

I doubt this is what the OP is looking for.

  approx(3.2)
4
  approx(3.0)
4

Others have pointed to math.ceil, which is most likely what the OP wants.

/Mikael Olofsson
Universitetslektor (Senior Lecturer [BrE], Associate Professor [AmE])
Linköpings universitet

---
E-Mail:  [EMAIL PROTECTED]
WWW: http://www.dtr.isy.liu.se/en/staff/mikael
Phone:   +46 - (0)13 - 28 1343
Telefax: +46 - (0)13 - 28 1339
---
Linköpings kammarkör: www.kammarkoren.com   Vi söker tenorer och basar!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: telnet.read_until() from telnetlib

2005-08-29 Thread Jacek Popławski
I have same problem with expect :-(

I am calling:

l=[expected]
result=self.telnet.expect(l,timeout)

it works in most cases, but sometimes (with exacly same expected value) it
returns -1,Nil,some text
the point is, that:
- connection is still active, so it should read more!
- it doesn't wait timeout seconds (I used time.time() to check that, time is
  zero, timeout is about 20s)!

In what case expect or read_until will stop reading without waiting for
timeout?

-- 
Free Software - find interesting programs and change them
NetHack - meet interesting creatures, kill them and eat their bodies
Usenet - meet interesting people from all over the world and flame them
Decopter - unrealistic helicopter simulator, get it from http://decopter.sf.net
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OpenSource documentation problems

2005-08-29 Thread Adriaan Renting
Marked -1 Flamebait, but I'll respond anyway.

I've read the documents he refers to, and although I agree that the Python docs 
aren't perfect, I do not agree with him on which points. I for example do think 
it's important to incude info on which versions of the language support a 
feature.
He seems to think the GNU man pages are nice, but I find them very awkward as 
they have no hierarchical organization, and most miss examples.

I do agree that a lot of OSS projects seem to lack somewhat in the 
documentation department, compared to a lot of commercial software. I would 
give the man page of gcc as an example, it's just one 6600 line blurb. The 
other part where a lot of OSS seems to be lacking is user interface design.

I think the cause is that the OSS movement is almost solely comprised of 
programmers, while in a commercial environment there will be a lot of 
documentation writers and interface designers (and marketing, etc...)
I know I write my own documentation for the code I create, but I know I'll not 
do as good a job as a separate good doc writer would. In general I think the 
programmers should not write the documentation, and should not be the sole 
designers of the UI either.

The good commercial docs are better because there it is understood how 
important this is. I myself have always liked the Borland documentation a lot.

The big question is: how to attract more doc writers to the OSS movement?

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


Re: Newbie question: Sub-interpreters for CAD program

2005-08-29 Thread Terry Hancock
On Saturday 27 August 2005 03:21 am, David MacQuigg wrote:
 The discouraging thing about the EDA tools situation is that no matter
 how loudly design engineers complain about the poor quality of the
 proprietary tools they are using, there is very little interest in
 participating in an open-source project.  They just can't see how it
 would ever do what their expensive tools do now.

Yes. I think this is analogous to the problems with word processors and
office workers.  The concern is driven I think by a fear of incompatibility.
It's certainly difficult to deal with the reality that  many people in business
insist on distributing information in whatever nasty variant of .doc format
their word processor happens to spit out, and it's not easy to be sure you
can read it.

Similarly, if you can't read AutoCAD formatted CAD files in a mechanical
design business, you're basically screwed.  That's a strong motivation to
keep using AutoCAD no matter how awful the program itself is.

It will take a really big, long-term push by a fair number of interested
people to give a free alternative a chance against such an entrenched
existing proprietary application.  In the long term, it would be worth it,
but a lot of people have to back it for a long time, and that's hard to
organize.

 There is a similar lack of interest in the academic community.  None
 of this is likely to lead to publications in scholarly journals.

I'm confused by what you meant by this.  Are you saying that academics
are afraid of using or creating open source CAD tools, or that they have
a lack of interest in tools development, because it won't generate papers
(directly anyway)?

--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks  http://www.anansispaceworks.com

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


Python built email message doesn't support OutLook Express

2005-08-29 Thread praba kar
Dear All,

   I am working in web based email system project.
 Here I try to build email message
from scratch. I used below code to build email
message

   msg =  email.MIMEBase('text','html')
   msg['Return-Path'] = user+'@'+domain
   msg['Date'] = formatdate(localtime=1)
   msg['Subject'] =  subject
   msg['From'] = from_name
   msg['To'] = to
   msg['Cc'] = cc
   msg.set_payload(Body of the email messagge)
   fh = os.popen('/bin/sendmail  %s'% (eachid),'w')
   fh.write(msg.as_string())
   fh.close()

This code will build plain email message properly.
But after building the message.  If a email user
download this mail through out look express then
this email message will display without any alignment.
 If a user type 3 paragraph message
outlook express display as a single line.  What
could be problem?.  Kindly let me know ASAP

regards
Prabahar




___ 
Too much spam in your inbox? Yahoo! Mail gives you the best spam protection for 
FREE! http://in.mail.yahoo.com
-- 
http://mail.python.org/mailman/listinfo/python-list


reg email packages work

2005-08-29 Thread praba kar
Dear All,

   I am working in web based email system project.
Here I try to build email message
from scratch. I used below code to build email
message

   msg =  email.MIMEBase('text','html')
   msg['Return-Path'] = user+'@'+domain
   msg['Date'] = formatdate(localtime=1)
   msg['Subject'] =  subject
   msg['From'] = from_name
   msg['To'] = to
   msg['Cc'] = cc
   msg.set_payload(Body of the email messagge)
   fh = os.popen('/bin/sendmail  %s'% (eachid),'w')
   fh.write(msg.as_string())
   fh.close()

This code will build plain email message properly.
But after building the message.  If a email user
download this mail through out look express then
this email message will display without any alignment.
 If a user type 3 paragraph message
outlook express display as a single line.  What
could be problem?.  Kindly let me know ASAP

regards
Prabahar



__ 
How much free photo storage do you get? Store your friends 'n family snaps for 
FREE with Yahoo! Photos http://in.photos.yahoo.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bug in string.find; was: Re: Proposed PEP: New style indexing,was Re: Bug in slice type

2005-08-29 Thread Magnus Lycka
Robert Kern wrote:
 If I may digress for a bit, my advisor is currently working on a project
 that is processing seafloor depth datasets starting from a few decades
 ago. A lot of this data was orginally to be processed using FORTRAN
 software, so in the idiom of much FORTRAN software from those days, 
 is often used to mark missing data. Unfortunately,  is a perfectly
 valid datum in most of the unit systems used by the various datasets.
 
 Now he has to find a grad student to traul through the datasets and
 clean up the really invalid 's (as well as other such fun tasks like
 deciding if a dataset that says it's using feet is actually using meters).

I'm afraid this didn't end with FORTRAN. It's not that long ago
that I wrote a program for my wife that combined a data editor
with a graph display, so that she could clean up time lines with
length and weight data for children (from an international research
project performed during the 90's). 99cm is not unreasonable as a
length, but if you see it in a graph with other length measurements,
it's easy to spot most of the false ones, just as mistyped year part
in a date (common in the beginning of a new year).

Perhaps graphics can help this grad student too? It's certainly much
easier to spot deviations in curves than in an endless line of
numbers if the curves would normally be reasonably smooth.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Writing portable applications

2005-08-29 Thread Ulrich Hobelmann
Mike Meyer wrote:
 I'm still waiting for an answer to that one - where's the Java toolkit
 that handles full-featured GUIs as well as character cell
 interfaces. Without that, you aren't doing the job that the web
 technologies do.

Where is the text-mode browser that would even run part of the web apps 
I use, like home-banking, all web forums, server configuration 
interfaces, etc.?  I think we should leave both these questions open. 
(In fact, as to UIs using Java, blech!  Haven't seen a really good one...)

 I just wonder who wrote fully standards compliant web browsers for
 those 90 platforms.
 Nobody. I doubt there's a fully standards compliant web browser
 Nobody, huh?  Then how could you run just ANY web application on those
 platforms?
 
 The same way you write POSIX applications in the face of buggy
 implementations - by working around the bugs in the working part of
 the implementation, and using conditional code where that makes a
 serious difference.

But as soon as some user of platform 54 tries your website, she'll 
encounter some weird behavior without even knowing why.  And maybe so 
will you, especially if you don't have that platform there for testing. 
  I don't understand how this web thing changes anything...  With POSIX 
at least you have a real bug-report for the guy responsible for it.  If 
a platform keeps being buggy, with no fixes coming, screw them.  Every 
user will see that sooner or later, and these platforms die.  Even 
Windows is quite stable/reliable after 10+ years NT!

 available for *any* platform, much less any non-trivial collection of
 them. You write portable web applications to the standards, and design
 them to degrade gracefully. Then you go back and work around any new
 Oh right, they degrade gracefully.  So without Javascript or cookies
 (the former is often not implemented) you get a HTML page with an
 error notice -- if you're lucky.
 
 You left off the important part of what I had to say - that the
 application be written by a moderately competent web author.

But if you can cater for all kinds of sub-platforms, then why not just 
provide a CLI as well as those GUI interfaces, when we're duplicating 
work to begin with? ;)

If it doesn't run without JS, then you lock out 90% of all alive 
platforms (and maybe 1% of all alive users :D) anyway.

 A server AND client for a simple protocol designed for its task
 (i.e. not FTP for instance) can be implemented in much less work than
 even designing even part of a web application backend that does that
 kind of stuff.
 
 Well, if it that easy (and web applications are dead simple), it
 should be done fairly frequently. Care to provide an example?

We have all the web standards, with various extensions over the years. 
Some FTP clients even don't crash if they see that some server doesn't 
yet support the extension from RFC [EMAIL PROTECTED]  Then there's tons of 
inter-application traffic in XML already, growing fast.  Then there are 
s-expressions (Lisp XML if you want).  Then probably thousands of ad-hoc 
line-based text protocols, but I don't know how well they can be 
extended.  There's CORBA.  Most web standards are simple, at least if 
you would subtract the weird stuff (and IMHO there should be new 
versions of everything with the crap removed).  XML is somewhat simple, 
just hook libxml.

There's NNTP.  There's RSS.  There's Atom.  The latter two emerged quite 
painlessly, even though you could maybe use some website for what they 
provide.  But this way you have lots of clients for lots of platforms 
already.

 You think you're done. A lot of developers think you can stop with
 the
 first one or two. You're all right for some applications. For others,
 you're not.  Personally, I like applications that run on all the
 platforms I use - and your set doesn't cover all three of those
 systems.
 Ok, I'd be interested to hear what those are.  VMS, RiscOS, Mac OS 9...?
 
 FreeBSD, OS X and a Palm Vx.

Didn't I say, a GUI for the Mac, for X11, and Windows?  That only leaves 
out the Palm.  I heard they aren't too hard to program for, either.  But 
I haven't heard of a really decent browser for pre-OS5 PalmOS (not sure 
about OS5).

 If a system's scheduler, or select implementation sucks, though, I'd
 complain to the vendor or simply abandon the platform for
 another. Competition is good :)
 
 Complaining to the vendor doesn't always get the bug fixed. And
 refusing to support a platform isn't always an option. Sometimes, you
 have to byte the bullet and work around the bug on that platform.

Sure, but you can tell your customers that unfortunately their system 
vendor refuses to fix a bug and ask THEM to ask that vendor.  Boy, will 
they consider another platform in the future, where bugs do get fixed ;)

 same thing applies to threads, except such code typically includes a
 third option of not using threads at all. And so on.
 Well, who doesn't do threads after several years of POSIX IMHO can't
 be taken 

sslerror: (8, 'EOF occurred in violation of protocol') ???

2005-08-29 Thread Robert
On some connections only from some computers/network setups I get this
error:

Traceback (most recent call last):
  File interactive input, line 1, in ?
  File ClientCookie\_urllib2_support.pyo, line 524, in open
  File ClientCookie\_urllib2_support.pyo, line 424, in http_response
  File ClientCookie\_urllib2_support.pyo, line 541, in error
  File urllib2.pyo, line 306, in _call_chain
  File ClientCookie\_urllib2_support.pyo, line 185, in http_error_302
  File ClientCookie\_urllib2_support.pyo, line 518, in open
  File urllib2.pyo, line 326, in open
  File urllib2.pyo, line 306, in _call_chain
  File ClientCookie\_urllib2_support.pyo, line 759, in https_open
  File ClientCookie\_urllib2_support.pyo, line 608, in do_open
  File httplib.pyo, line 712, in endheaders
  File httplib.pyo, line 597, in _send_output
  File httplib.pyo, line 564, in send
  File httplib.pyo, line 985, in connect
  File socket.pyo, line 73, in ssl
sslerror: (8, 'EOF occurred in violation of protocol')


The server is always the same and ok. but different
client-OS/proxies/firewalls/routers are in use.
What is the nature of this error? How is it possible that an EOF in
ssl-connections (during connect?) occures? What can be done to
handle/circumvent that problem?

Robert


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


Re: OpenSource documentation problems

2005-08-29 Thread Paul Rubin
Adriaan Renting [EMAIL PROTECTED] writes:
 He seems to think the GNU man pages are nice, but I find them very
 awkward as they have no hierarchical organization, and most miss examples.

The GNU man pages are an afterthought to meet expectations of Un*x
users who were used to man pages and the man command.  The good GNU
docs are in texinfo format, not man pages.  They have lots of examples
and they hierarchical structure and were designed to be navigated with
a pre-www hypertext browser or alternatively generate printed manuals.
These days there are also programs to render them as html so you can
navigate them with web browses.

 I do agree that a lot of OSS projects seem to lack somewhat in the
 documentation department, compared to a lot of commercial
 software. I would give the man page of gcc as an example, it's just
 one 6600 line blurb. The other part where a lot of OSS seems to be
 lacking is user interface design.

The man page only exists for the sake of users who insisted on having
a doc in that inferior format.  The official gcc doc is at:

   http://gcc.gnu.org/onlinedocs/gcc-4.0.1/gcc/

 The big question is: how to attract more doc writers to the OSS movement?

It's traditionally been a problem.  The FSF has hired a number of tech
writers over the years, and paid them to write docs.  That's one way.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bug in string.find; was: Re: Proposed PEP: New style indexing,was Re: Bug in slice type

2005-08-29 Thread Antoon Pardon
Op 2005-08-27, Terry Reedy schreef [EMAIL PROTECTED]:

 Paul Rubin http://phr.cx@NOSPAM.invalid wrote in message 
 news:[EMAIL PROTECTED]
 Terry Reedy [EMAIL PROTECTED] writes:
 The try/except pattern is a pretty basic part of Python's design.  One
 could say the same about clutter for *every* function or method that 
 raises
 an exception on invalid input.  Should more or even all be duplicated? 
 Why
 just this one?

 Someone must have thought str.find was worth having, or else it
 wouldn't be in the library.

 Well, Guido no longer thinks it worth having and emphatically agreed that 
 it should be added to one of the 'To be removed' sections of PEP 3000.

I think a properly implented find is better than an index.

If we only have index, Then asking for permission is no longer a
possibility. If we have a find that returns None, we can either
ask permission before we index or be forgiven by the exception
that is raised.

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


Re: Bug in string.find; was: Re: Proposed PEP: New style indexing, was Re: Bug in slice type

2005-08-29 Thread Antoon Pardon
Op 2005-08-27, Steve Holden schreef [EMAIL PROTECTED]:
 
 
 If you want an exception from your code when 'w' isn't in the string you 
 should consider using index() rather than find.

Sometimes it is convenient to have the exception thrown at a later
time.

 Otherwise, whatever find() returns you will have to have an if in 
 there to handle the not-found case.

And maybe the more convenient place for this if is in a whole different
part of your program, a part where using -1 as an invalid index isn't
at all obvious.

 This just sounds like whining to me. If you want to catch errors, use a 
 function that will raise an exception rather than relying on the 
 invalidity of the result.

You always seem to look at such things in a very narrow scope. You never
seem to consider that various parts of a program have to work together.

So what happens if you have a module that is collecting string-index
pair, colleted from various other parts. In one part you
want to select the last letter, so you pythonically choose -1 as
index. In an other part you get a result of find and are happy
with -1 as an indictation for an invalid index. Then these
data meet.

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


Re: Bug in string.find; was: Re: Proposed PEP: New style indexing,was Re: Bug in slice type

2005-08-29 Thread Robert Kern
Magnus Lycka wrote:
 Robert Kern wrote:
 
If I may digress for a bit, my advisor is currently working on a project
that is processing seafloor depth datasets starting from a few decades
ago. A lot of this data was orginally to be processed using FORTRAN
software, so in the idiom of much FORTRAN software from those days, 
is often used to mark missing data. Unfortunately,  is a perfectly
valid datum in most of the unit systems used by the various datasets.

Now he has to find a grad student to traul through the datasets and
clean up the really invalid 's (as well as other such fun tasks like
deciding if a dataset that says it's using feet is actually using meters).
 
 I'm afraid this didn't end with FORTRAN. It's not that long ago
 that I wrote a program for my wife that combined a data editor
 with a graph display, so that she could clean up time lines with
 length and weight data for children (from an international research
 project performed during the 90's). 99cm is not unreasonable as a
 length, but if you see it in a graph with other length measurements,
 it's easy to spot most of the false ones, just as mistyped year part
 in a date (common in the beginning of a new year).
 
 Perhaps graphics can help this grad student too? It's certainly much
 easier to spot deviations in curves than in an endless line of
 numbers if the curves would normally be reasonably smooth.

Yes! In fact, that was the context of the discussion when my advisor
told me about this project. Another student had written an interactive
GUI for exploring bathymetry maps. My advisor: That kind of thing would
be really great for this new project, etc. etc.

-- 
Robert Kern
[EMAIL PROTECTED]

In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die.
  -- Richard Harter

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


Re: variable hell

2005-08-29 Thread Robert Kern
Adriaan Renting wrote:

 My original code was: exec(eval('a%s=%s' % (count, value)))
 Then Rafi said: exec('a%s=%s' % (count, value))
 To which I responded that his example does not work in my Python, and I think 
 it's invalid.
 Then Martin came with: exec 'a%s = %s' % (count, value)
 This does work.
 But he seems to keep telling me I'm quoting him wrong, while I'm quoting Rafi.

Read more carefully. rafi did not put in the extraneous quotes.

rafi:
Adriaan Renting wrote: 

You might be able to do something along the lines of 

for count in range(0,maxcount): 
value = values[count] 
exec(eval('a%s=%s' % (count, value))) 

why using the eval? 
 
exec ('a%s=%s' % (count, value)) 
 
should be fine 
 
-- 
rafi 

See? No extra quotes.

-- 
Robert Kern
[EMAIL PROTECTED]

In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die.
  -- Richard Harter

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


Re: Question

2005-08-29 Thread [EMAIL PROTECTED]
Much more useful stuff for beginners is here:
http://wiki.python.org/moin/BeginnersGuide

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


Re: close failed: [Errno 0] No error goes to stdout

2005-08-29 Thread Yoav
I run a Java command line program. The point is, that it's not the 
program that output this error message for sure. And I don't expect 
popen3() to catch and report errors. I just want to keep my screen 
output clean, and I expect popen3() to run the program and not let 
anything slip to the screen, after all as I understood it is supposed to 
capture STDERR and STDOUT, but maybe I didn' t understand it right (it's 
quite probable). Anyway anyway I can do such a thing?

Thanks.

Peter Hansen wrote:
 Yoav wrote:
 
 I use the following code to the console output:

 def get_console(cmd):
 try:
 p_in, p_out, p_err = os.popen3(cmd)
 except:
 pass
 out_str = ''
 for obj in p_out:
 out_str = out_str + obj
 for obj in p_err:
 out_str = out_str + obj
 return out_str


 for some reason some exceptions (stderr outputs) are not captured by 
 the try method, and slip to the screen. Any one has any idea on how 
 can prevent from any output that I don't want to?
 The output I get on these exceptions is:
 close failed: [Errno 0] No error
 
 
 What makes you think the errors are getting past the try/except?  Could 
 they be printed by the program you are invoking with popen3() instead? 
 What does cmd equal when you get this failure?
 
 Maybe you are expecting that popen3() will somehow raise exceptions when 
 the called program fails, exceptions which the except statement would 
 catch.  That's not the case.
 
 -Peter
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Python built email message doesn't support OutLook Express

2005-08-29 Thread Meyer, Tony
 I used below code to build email message
[...]
   msg.set_payload(Body of the email messagge)
[...]
 This code will build plain email message properly.
 But after building the message.  If a email user
 download this mail through out look express then
 this email message will display without any alignment.

What do you mean without any alignment?  Text always has an alignment (unless 
the letters are scattered across the screen, I suppose).  You're sending a 
plain-text email (with a MIME type of 'html'), so it's up to the client (OE) to 
decide how to display it.

 If a user type 3 paragraph message
 outlook express display as a single line.

Are you putting line breaks in the message?

I suspect that what you're missing is that you're meaning to put some HTML in 
the message, and aren't (the content type hints at this).

=Tony.Meyer
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python built email message doesn't support OutLook Express

2005-08-29 Thread Sybren Stuvel
praba kar enlightened us with:
 This code will build plain email message properly.

It's not a plain email message. It's an html email without a plain
text part. Highly annoying to many people.

 But after building the message.  If a email user download this mail
 through out look express then this email message will display
 without any alignment.

Post the msg.as_string() output so we can see whay you're sending.

Sybren
-- 
The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself? 
 Frank Zappa
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python built email message doesn't support OutLook Express

2005-08-29 Thread praba kar
--- Sybren Stuvel
[EMAIL PROTECTED] wrote:

 praba kar enlightened us with:
  This code will build plain email message properly.
 
 It's not a plain email message. It's an html email
 without a plain
 text part. Highly annoying to many people.
 
  But after building the message.  If a email user
 download this mail
  through out look express then this email message
 will display
  without any alignment.
 
 Post the msg.as_string() output so we can see whay
 you're sending.
msg =  email.MIMEBase('text','html')
msg['Return-Path'] = user+'@'+domain
msg['Date'] = formatdate(localtime=1)
msg['Subject'] =  subject
msg['From'] = from_name
msg['To'] = to
msg['Cc'] = cc
msg.set_payload(Body of the email messagge)
fh = os.popen('/bin/sendmail  %s'% (eachid),'w')
fh.write(msg.as_string())
fh.close()
Here I am sending what I was built in the message
example to headers(address,cc address, subject) and
Body of the mail content (ie) msg.set_payload(Body of
the email messagge)  

regards
Prabahar






__ 
Free antispam, antivirus and 1GB to save all your messages 
Only in Yahoo! Mail: http://in.mail.yahoo.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SocketServer and a Java applet listener

2005-08-29 Thread Steve Horsley
[EMAIL PROTECTED] wrote:
 Steve Horsley schreef:
 
 
Probably the same problem. If you didn't send a 2 byte length
indicator first, then java's readUTF() will have tried to
interpret the first 2 bytes that you did actually send as the
string length, and may well simply be waiting patiently for the
rest to arrive.

 
 I just couldn't get read/writeUTF and python unicode to interface, so I
 refactored the applet's socketlistener to convert the
 socket.getInputStream to a BufferedInputReader on which I call the
 readline() method.
 I still skip the first two bytes in the python receiver which seems
 harmless since python doesn't use the byte length.
 On both sides I have other way to know when the end-of-message has been
 reached. A timeout mechanism provides some safety for partial
 transmission handling.
 

I would encourage you to re-think this.

There are two normal ways to delineate messages in the 
byte-stream: An explicit length indication up front (which java 
read/writeUTF chooses), or a unique end-of-message indication at 
the end such as your readline() for strings that end in linefeed.

HTTP is an interesting mixture of these - the header contains a 
content-length line telling you how long the payload is, but the 
header itslef is variable length, terminated by a blank line. In 
chunked encoding, there is a variable number of chunks, and the 
last chunk is marked as such in the header.

Anyway, either approach is good. But using timing to separate 
messages is Bad. There is always the chance that you will get 
bitten by strange timings happening later on.

If you choose to go for the java read/writeUTF approach, the 
2-byte length indicator goes Most Significant Byte first, so a 
100 char string would be preceded by 00 64 ... Also, the 
indicator gives the number of bytes after encoding, not the 
number of characters before encoding.

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


Re: Lossless Number Conversion

2005-08-29 Thread Raymond L. Buvel
Chris Spencer wrote:
 Is there any library for Python that implements a kind of universal
 number object. Something that, if you divide two integers, generates a
 ratio instead of a float, or if you take the square root of a negative,
 generates a complex number instead of raising an exception? Lisp has
 something like this, and it makes number crunching much more convenient.
 
 Chris

If you are on any Unix-like platform, you might want to check out clnum.
 It works like the gmpy package but has complex versions of rationals
and arbitrary precision floats.

http://calcrpnpy.sourceforge.net/clnum.html
-- 
http://mail.python.org/mailman/listinfo/python-list


CHANGE OF EMAIL ADDRESS NOTIFICATION

2005-08-29 Thread tracy
CHANGE OF EMAIL ADDRESS NOTIFICATION

Dear Clients, Suppliers  Friends,

Effective August 1st 2005, my new email address will be [EMAIL PROTECTED] 

During this transition period, I'll still be receiving mails from my old 
account. 


Thanks  Regards,
Tracy Taw

SWOT Brand Architecture Sdn Bhd
an entity of SWOT DESIGN GROUP
T.  603 7877 6000
F.  603 7877 9005
E.  [EMAIL PROTECTED]

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


Re: ideas for university project ??

2005-08-29 Thread Thomas Guettler
Am Fri, 26 Aug 2005 12:21:36 -0400 schrieb Steve Holden:

 Thomas Guettler wrote:
 Am Fri, 26 Aug 2005 11:49:34 +0100 schrieb Jon Hewer:

 you could port Python to the WRT54.
 The Linksys WRT54 is a WLAN-Router which runs Linux.
 See http://openwrt.org/
 I think it is a good project for a university. It is software
 and hardware related. 
 
  Thomas
 
 It would be a good final-year project, but you may want to try something 
 that hasn't already been done ... see
 
http://skreak.com/wrt54g/python.php

Hi,

I know this. This is NFS mounted. You could strip down python to get it
running standalone.

 Thomas

-- 
Thomas Güttler, http://www.thomas-guettler.de/


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


Re: Python built email message doesn't support OutLook Express

2005-08-29 Thread Diez B. Roggisch
That is not what Sybren requested - we need the message text. If you
send html, make sure your paragraphs are html paragraphs (enclosed in
p-tags) and not pure whitespace, as html ignores these.



Diez

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


Re: Jargons of Info Tech industry

2005-08-29 Thread axel
In comp.lang.perl.misc Mike Meyer [EMAIL PROTECTED] wrote:
 [EMAIL PROTECTED] writes:
 In comp.lang.perl.misc John Bokma [EMAIL PROTECTED] wrote:
 Chris Head [EMAIL PROTECTED] wrote:
 What advantages would those be (other than access from 'net cafes, but
 see below)?
 And workplaces. Some people have more then one computer in the house. My 
 partner can check her email when I had her over the computer. When I 
 want to check my email when she is using it, I have to change the 
 session, fire up Thunderbird (which eats away 20M), and change the 
 session back.
 Not a Windows solution, but I find the 'screen' utility invaluable as
 I can have my email, news, and an editor open in different screens
 and then when I need to move to a different machine, I can simply
 detach and reattach screen without disturbing anything that
 might be running.
 
 For a more  portable solution, check out VNC.
 
I know... but it is a bugger to set up and I believe it is no longer
freeware (if it ever was), and it does not have the stark simplicity
which screen has... I only need to have a compiled version of screen
on the machine on which I do most of my work and be able to ssh/telnet
to that machine without involving any additional software installations
on other machines.

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


Re: aproximate a number

2005-08-29 Thread Peter Hansen
Mikael Olofsson wrote:
 Michael Sparks wrote:
 
 def approx(x):
 return int(x+1.0)
 
 I doubt this is what the OP is looking for.
...
 Others have pointed to math.ceil, which is most likely what the OP wants.

I agree that's likely but, as Michael pointed out in the text you 
removed, his version does do what the OP's spec states, when interpreted 
literally.  Very likely there's a language issue involved, and Michael 
was aware of that as well, I'm sure.

Still, others had already posted on math.ceil(), so Michael was just 
trying to make sure that the OP realized his specification was 
inadequate and -- just in case he wanted something other than math.ceil 
-- he provided a valid alternative.

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


Re: close failed: [Errno 0] No error goes to stdout

2005-08-29 Thread Peter Hansen
(Please don't top-post.  It makes quoting difficult and it's hard for 
people to follow the conversation.)

Yoav wrote:
 I run a Java command line program. The point is, that it's not the 
 program that output this error message for sure. 

Okay.  Since you don't provide any proof, we'll have to take you at your 
word.

In that case, please provide the *complete traceback*, cut and pasted 
from your console window.  Don't just retype the error message. 
Generally people leave out crucial information when they do that.  The 
traceback (which Python will always print when it raises an exception) 
shows the failing line of code and the stack trace.  With it we can help 
you troubleshoot the problem.  Without it, you haven't provided enough 
information yet for anyone to do more than guess.

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


Pointers and ctypes

2005-08-29 Thread rubbishemail
Hello,
i've got a problem with pointers in the following function which i want
to use:

I16 __stdcall DO_ReadPort (U16 CardNumber, U16 Port, U32 *Value)

The function is supposed to read out the status of a digital port of
analog digital interface card.
I got this function from Dask.h which came with the card. The relevant
lines concerning this function are the following:

typedef short   I16;
typedef unsigned short  U16;
typedef unsigned long   U32;

I16 __stdcall DO_ReadPort (U16 CardNumber, U16 Port, U32 *Value)

I tried to implement this function into python:
# I16 __stdcall DO_ReadPort (U16 CardNumber, U16 Port, U32 *Value);
ReadOPort = dask.DO_ReadPort
ReadOPort.argtypes = [c_ushort, c_ushort, c_ulong]
ReadOPort.restype = c_short

I can't handle the pointer Value which should be an unsigned long
pointer. I'd be very happy, if u could give me a hint how to implement
this pointer into python.

Thanks a lot

Carlo and Pierre

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


NYC Opening

2005-08-29 Thread Kevin McGann

A major Investment Bank is searching for a strong Java or C++ developer that
can build Pipes to Electronic Exchanges and ECNs. This is a new Internal
Hedge Fund Business and they are looking for superb C++ or Java programmers
that can enable them to go live in 1-2 months and begin trading. THIS IS AN
OPPORTUNITY TO WORK IN THE BUSINESS UNIT OF A MAJOR TOP-TIERED BANK!
Required Skills:
-Expert Java or C++
-Extensive Multi-threading
-OOA/OOD Must have Design Patterns Experience
-Must have experience building Pipes/Connectivity Infrastructure/FIX
-Linux, Unix, SQL/RDBMS
Eventually this person will learn Stat/Arb business for Equities/FX and will
get to learn about trading strategies and work closely with Quants/Prop
Traders.
THEY ARE LOCATED IN NEW YORK, THIS IS FULL-TIME ONLY, WILL NOT CONSIDER
ANYONE FROM OUTSIDE THE US! THIS TEAM IS AN ELITE TEAM, YOU BETTER BE
GOOD

Also have numerous opportunities so if you program in C++ or Java send me an
email or give me a call.
-
Kevin M McGann
Senior Technology Recruiter
Continuity Partners Inc.
(212) 624-9187
www.cpi-search.com
[EMAIL PROTECTED]
-


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


Re: using common lisp with python.

2005-08-29 Thread Pierre Barbier de Reuille
[EMAIL PROTECTED] a écrit :
 is there a way to embed common lisp programs in python?
 
It depends on what you call embedding ... can you be more specifiv
about what you want ?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: variable hell

2005-08-29 Thread Adriaan Renting
Oops, you're completely right.

I'm sorry, it is indeed my mistake.
I was thinking people were telling me I was quoting Martin wrong, while I was 
quoting Rafi wrong. I'll promise not quote anybody anymore until I have an 
e-mail program that can quote/copy properly. As reading it in one window, then 
typing it in another to test it, then copying it back, obviously introduced a 
PEBKAC error.

Adriaan Renting

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


Re: Writing portable applications (Was: Jargons of Info Tech industry)

2005-08-29 Thread Henry Law
On Sat, 27 Aug 2005 14:35:05 -0400, Mike Meyer [EMAIL PROTECTED] wrote:

Ulrich Hobelmann [EMAIL PROTECTED] writes:
 Mike Meyer

I wonder could you guys stop cross-posting this stuff to
comp.lang.perl.misc?   The person who started this thread - a
well-known troll - saw fit to post it there, and now all your posts
are going there too. 
-- 

Henry LawManchester, England 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pointers and ctypes

2005-08-29 Thread F. Petitjean
Le 29 Aug 2005 06:19:17 -0700, [EMAIL PROTECTED] a écrit :
 Hello,
 i've got a problem with pointers in the following function which i want
 to use:

 I16 __stdcall DO_ReadPort (U16 CardNumber, U16 Port, U32 *Value)

 The function is supposed to read out the status of a digital port of
 analog digital interface card.
 I got this function from Dask.h which came with the card. The relevant
 lines concerning this function are the following:

 typedef short   I16;
 typedef unsigned short  U16;
 typedef unsigned long   U32;

 I16 __stdcall DO_ReadPort (U16 CardNumber, U16 Port, U32 *Value)

 I tried to implement this function into python:
 # I16 __stdcall DO_ReadPort (U16 CardNumber, U16 Port, U32 *Value);
 ReadOPort = dask.DO_ReadPort
 ReadOPort.argtypes = [c_ushort, c_ushort, c_ulong]
 ReadOPort.restype = c_short

 I can't handle the pointer Value which should be an unsigned long
 pointer. I'd be very happy, if u could give me a hint how to implement
 this pointer into python.

You can use the ctypes.byref() function (as it is in an argulent list):

  ReadOPort.argtypes = (c_ushort, c_ushort, ctypes.POINTER(c_ulong) )
  ReadOPort.restype = c_short
  status = c_ulong()  #  status value to be read
  number = c_ushort(1)   # CardNumber = 1
  port = c_ushort(11)
  rc = ReadOPort(number,  port, ctypes.byref(status))
  print rc, ststus

 Thanks a lot

 Carlo and Pierre

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


Re: NYC Opening

2005-08-29 Thread Diez B. Roggisch

Kevin McGann wrote:
 -Expert Java or C++

Now why exactly do you post that in c.l.python?

 THEY ARE LOCATED IN NEW YORK, THIS IS FULL-TIME ONLY, WILL NOT CONSIDER
 ANYONE FROM OUTSIDE THE US! THIS TEAM IS AN ELITE TEAM, YOU BETTER BE
 GOOD

I'm pretty sure you've some spelling wrong here, you certainly want
ELITE to be written as 733T to get the attention of the proper people.


SCNR,

Diez

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


Re: What are new-style classes?

2005-08-29 Thread Jan Danielsson
Vaibhav wrote:
 I recently heard about 'new-style classes'. I am very sorry if this
 sounds like a newbie question, but what are they? I checked the Python
 Manual but did not find anything conclusive. Could someone please
 enlighten me? Thanks!

   In short: They have inherited object from somewhere. (This is
probably technically inaccurate, but it's the only thing I have seen
which defines a 'new-style class').

   What it means *practically*, is that you can use properties. For a
long while I didn't really understand the point or properties, until I
needed them.

   I have written a flowcharting application in Python. All objects on
the flowchat are derived from a base object which has the attribute
text (all objects have some form of, sometimes internal only, title).
Problem is that when some objects change text, I want to perform some
recalculations. So I wrote a text property, which - in its
settext-method - does all the calculations if required.

That way, the application can till use:

obj.text = 'Blah'

..and still have the chance to act on the text change.

   I could have simply written a setText() method, but imho properties
are neater - but that's just a matter of opinion.


-- 
Kind Regards,
Jan Danielsson
Te audire no possum. Musa sapientum fixa est in aure.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pointers and ctypes

2005-08-29 Thread rubbishemail
thanks a bunch, i just got the answer myself. next time i think about
it a little longer. 
thanks again
carlo

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


Re: Pointers and ctypes

2005-08-29 Thread Mike C. Fletcher
F. Petitjean wrote:

Le 29 Aug 2005 06:19:17 -0700, [EMAIL PROTECTED] a écrit :
  

...

You can use the ctypes.byref() function (as it is in an argulent list):

  ReadOPort.argtypes = (c_ushort, c_ushort, ctypes.POINTER(c_ulong) )
  ReadOPort.restype = c_short
  status = c_ulong()  #  status value to be read
  number = c_ushort(1)   # CardNumber = 1
  port = c_ushort(11)
  rc = ReadOPort(number,  port, ctypes.byref(status))
  print rc, ststus
  

Just as an FYI, Thomas has recently added code which does the byref 
automatically.  The version of ctypes in CVS HEAD will allow you to pass 
in a c_ulong where the argtype is ctypes.POINTER(c_ulong).

Have fun,
Mike

-- 

  Mike C. Fletcher
  Designer, VR Plumber, Coder
  http://www.vrplumber.com
  http://blog.vrplumber.com

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


Re: python image thumbnail generator?

2005-08-29 Thread Fredrik Lundh
Paul Rubin wrote

 (1) Can this be done with python? If so, what module do I need to look 
 up?

 You could do it with PIL, or run jpegtran in an external process.
 jpegtran may be easier.

eh?  are you sure you know what jpegtran does?

JPEGTRAN(1) 
JPEGTRAN(1)

NAME
   jpegtran - lossless transformation of JPEG files

SYNOPSIS
   jpegtran [ options ] [ filename ]

DESCRIPTION
   jpegtran performs various useful transformations of JPEG files.  It 
can
   translate the coded representation from one variant of JPEG to 
another,
   for  example  from baseline JPEG to progressive JPEG or vice versa. 
It
   can also perform some rearrangements of the  image  data,  for 
example
   turning an image from landscape to portrait format by rotation.

   jpegtran  works  by rearranging the compressed data (DCT 
coefficients),
   without ever fully decoding the image /.../

/F 



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


Re: python image thumbnail generator?

2005-08-29 Thread Fredrik Lundh
Mike C. Fletcher wrote:

 The core function looks something like this:

 import Image # this is PIL

 def getThumbnail( filename, size = (32,32) ):
'''Get a thumbnail image of filename'''
image = Image.open(filename)
rx, ry = image.size[0]/float(size[0]), image.size[1]/float(size[1])
if rx  ry:
resize = int(size[0]), int(round(image.size[1]*(1.0/rx), 0))
else:
resize = int(round(image.size[0]*(1.0/ry), 0)), int(size[1])
image = image.resize( resize, Image.BILINEAR )

footnote: if you're creating thumbnails from JPEG or PhotoCD
images, using the thumbnail method can be a lot more efficient
(unlike resize, it tweaks the codec so it doesn't have to load the
entire full-sized image).

footnote 2: Image.ANTIALIAS is slower, but tends to give a
much better result than Image.BILINEAR, especiall for noisy
images.

/F 



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


Python and file locking - NFS or MySQL?

2005-08-29 Thread Christopher DeMarco
Hi all...

...I've got a Python script running on a bunch of boxen sharing some
common NFS-exported space.  I need (not want :) to lock files for
writing, and I need (not want :) to do it safely (i.e. atomically).
I'm doing this in Linux; NFS4 is available.  As I understand it, my
options are:

1.  Python's fcntl() is an interface to the fcntl(2) system call,
which is claimed to work mostly over NFS v = 3.

2.  open(2) is atomic on a local FS, I've read discussions that imply
that link(2) is atomic over NFS (is it?), so I can link from local
lockfile to remote target atomically.  I don't grok this; open(2) +
link(2) + stat(2) == 3 calls on my fingers.  HTH is this supposed to
work?

3.  Atomically update a MySQL database indicating that the file is
locked - MySQL has atomic transactions now, right?  And how good is
the Python MySQL API - IIRC Perl didn't have atomic transactions last
year; will this work in contemporary Python?

I've got a while (several weeks) to chew this problem over (my current
implementation is ``assert(Poof!  File locked)'').

What are my options for safely locking files via NFS?  I don't want to
get involved with NLM as my impression is it's being buggy and
unwieldy.  Thanks in advance!


I was present at an undersea, unexplained mass sponge migration.
-- 
Christopher DeMarco [EMAIL PROTECTED]
Alephant Systems (http://alephant.net)
PGP public key at http://pgp.alephant.net
+1 412 708 9660


signature.asc
Description: Digital signature
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: py-serial + CSV

2005-08-29 Thread McBooCzech
Thanks you all, guys, for your suggestions and help. Everything now
works great :)
Regards
Petr Jakes

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


Robust statistics and optimmization from Python

2005-08-29 Thread tkpmep
I use Python to generate a huge amount of data in a .csv file which I
then process using Excel. In particular, I use Excel's solver to solve
a number of non-linear equation, and then regress the results of
hundreds of calls to Solver against a set of known values, enabling me
to calibrate my model. This is a pain: i'd much rather perform all the
computations in Python and improve on Excels' regression as well.

Questions:
1. Is there a way to perform (or make a call to) a non-linear
optimization from Python?
2. Do Python packages for robust statistics (robust regression in
particular) exist. If so, which one would you recommend/

Thanks, as always, in advance for the guidance

Thomas Philips

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


python xml DOM? pulldom? SAX?

2005-08-29 Thread jog
Hi,
I want to get text out of some nodes of a huge xml file (1,5 GB). The
architecture of the xml file is something like this
parent
   page
titlebla/title
id/id
revision
  id/id
  textblablabla/text
revision
   /page
   page
   /page

/parent
I want to combine the text out of page:title and page:revision:text for
every single page element. One by one I want to index these combined
texts (so for each page one index)
What is the most efficient API for that?: SAX ( I don´t thonk so) DOM
or pulldom?
Or should I just use Xpath somehow.
I don`t want to do anything else with his xml file afterwards.
I hope someone will understand me.
Thank you very much
Jog

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


Re: overload builtin operator

2005-08-29 Thread Iain King

Robert Kern wrote:
 Shaun wrote:
  Thanks for your replies, obviously this isn't a simple thing to do so
  I'll take a different tack.
 
  The exact problem I am trying to solve here is to avoid the
  ZeroDivisionError in division.
  I have c++ code which delegates to python to calculate expressions on
  table cells. The values of the table cell are arbitary numbers and the
  expressions to be calculated are fairly simple python arithmetic and
  math functions.
 
  The problem being that some users want an expression like '(100/x)+ 3'
  where x=0 to return 3. So that dividing a number by zero results in 0.

 You have silly users.

You mean you don't?  Damn.  Can I have some of yours?

Iain

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


GIL, threads and scheduling - performance cost

2005-08-29 Thread adsheehan
Hi all,

Wondering if a GIL lock/unlock causes a re-schedule/contect swap when
embedding Python in a multi-threaded C/C++ app on Unix ?

If so, do I have any control or influence on this re-scheduling ?

The app suffers from serious performance degradation (compared to pure
c/C++) and high context switches that I suspect the GIL unlocking may
be aggravating ?

Thanks for any help.

Alan

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


Re: Robust statistics and optimmization from Python

2005-08-29 Thread Robert Kern
[EMAIL PROTECTED] wrote:
 I use Python to generate a huge amount of data in a .csv file which I
 then process using Excel. In particular, I use Excel's solver to solve
 a number of non-linear equation, and then regress the results of
 hundreds of calls to Solver against a set of known values, enabling me
 to calibrate my model. This is a pain: i'd much rather perform all the
 computations in Python and improve on Excels' regression as well.
 
 Questions:
 1. Is there a way to perform (or make a call to) a non-linear
 optimization from Python?

Look at scipy. http://www.scipy.org

In [1]: from scipy import optimize

In [2]: optimize?
...
Optimization Tools
==

 A collection of general-purpose optimization routines.

   fmin--  Nelder-Mead Simplex algorithm
 (uses only function calls)
   fmin_powell --  Powell's (modified) level set method (uses only
 function calls)
   fmin_cg --  Non-linear (Polak-Rubiere) conjugate gradient
algorithm
 (can use function and gradient).

   fmin_bfgs   --  Quasi-Newton method (can use function and gradient)
   fmin_ncg--  Line-search Newton Conjugate Gradient (can use
 function, gradient and hessian).
   leastsq --  Minimize the sum of squares of M equations in
 N unknowns given a starting estimate.

  Constrained Optimizers (multivariate)

   fmin_l_bfgs_b -- Zhu, Byrd, and Nocedal's L-BFGS-B constrained
optimizer
  (if you use this please quote their papers --
see help)

   fmin_tnc  -- Truncated Newton Code originally written by
Stephen Nash and
  adapted to C by Jean-Sebastien Roy.

   fmin_cobyla   -- Contrained Optimization BY Linear Approximation

 2. Do Python packages for robust statistics (robust regression in
 particular) exist. If so, which one would you recommend/

Offhand, I can't think of any, but it's easy enough to do maximum
likelihood with Laplacians and the functions above. If you find suitable
FORTRAN or C code that implements a particular robust algorithm, it
can probably wrapped for scipy relatively easily.

-- 
Robert Kern
[EMAIL PROTECTED]

In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die.
  -- Richard Harter

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


Re: trictionary?

2005-08-29 Thread Steven Bethard
Adam Tomjack wrote:
 I'd write it like this:
 
bin = {}
for start, end, AS, full in heard:
   week = int((start-startDate)/aWeek)
   counters = bin.setdefault(week, [0, 0])
   if full:
  counters[0] += 1
   else:
  counters[1] += 1
 
for week, (times_full, times_not_full) in bin.iteritems():
   print ...
 
 Seriously, use setdefault() as often as you can.  It may be a little 
 awkward at first, but after a little bit, you instantly know what it 
 means.  It takes out a whole if/else statement which will make your code 
 smaller and more readable at the same time.

However, you should be aware that it can make your code slower.  If the 
default value is expensive to create,

 value = dct.setdefault(key, expensive_func())

will often be slower and/or more memory intensive than

 try:
 value = dct[key]
 except KeyError:
 value = expensive_func()

or

 if key in dct:
 value = dct[key]
 else:
 value = expensive_func()

Personally, I waver back and forth between using setdefault.  It's kind 
of handy, but it never reads quite right.  While I've used it often 
enough to grok it pretty quickly, it's still consumes more of my mental 
processing than some other approaches.

I also tend to agree with the assessment[1] (I believe due to Raymond 
Hettinger) that setdefault is poorly designed, and should instead set a 
default value for the entire dictionary, e.g. so that you could do:

 counts = {}
 counts.setdefault(value=0)
 for elem in data:
 counts[elem] += 1

Unfortunately, this is pretty badly backwards incompatible, so I can 
only really hope for this change in Python 3.0 which is still a number 
of years off.

STeVe

[1]http://wiki.python.org/moin/Python3%2e0Suggestions#head-b384410f8b2dc16fd74c9eec764680e428643d73
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: overload builtin operator

2005-08-29 Thread Robert Kern
Iain King wrote:
 Robert Kern wrote:

You have silly users.
 
 You mean you don't?  Damn.  Can I have some of yours?

No, you may not. Mine! All mine!

-- 
Robert Kern
[EMAIL PROTECTED]

In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die.
  -- Richard Harter

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


Python port on Palm Treo?

2005-08-29 Thread Paul Watson
Has anyone done or worked on a port of Python to the Treo?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: trictionary?

2005-08-29 Thread Steven Bethard
[EMAIL PROTECTED] wrote:
 import csv
 temp1 = []
 temp2 = []
 reader = csv.reader(file(rpy_monsters.csv))
 for rec in reader:
   temp1.append(rec)
 for i in temp1[1:]:
   temp2.append((i[0],dict(zip(temp1[0][1:],i[1:]
 monsters = dict(temp2)

I would tend to write this as:

import csv
reader = csv.reader(file(rpy_monsters.csv))
labels = reader.next()[1:]
monsters = dict((row[0], dict(zip(labels, row[1:])))
 for row in reader)

which I believe gives equivalent output:

py csv_text = \
... 
name,hardiness,agility,friend,courage,room,weight,special_def_odds,armor,weapon,odds,dice,side,hits,reaction,desc
... PIRATE,5,20,0,10,26,300,0,0,11,60,1,10,0,not met,You see a man 
with a beard and a brass ring in his ear.  He is wearing clothes  made 
of silk and is wielding a very fancily engraved sword.
py f = StringIO.StringIO(csv_text)
py reader = csv.reader(f)
py labels = reader.next()[1:]
py monsters = dict((row[0], dict(zip(labels, row[1:])))
... for row in reader)
py monsters
{'PIRATE': {'reaction': 'not met', 'agility': '20', 'room': '26', 
'weight': '300', 'armor': '0', 'weapon': '11', 'hits': '0', 'side': 
'10', 'special_def_odds': '0', 'courage': '10', 'hardiness': '5', 
'desc': 'You see a man with a beard and a brass ring in his ear.  He is 
wearing clothes  made of silk and is wielding a very fancily engraved 
sword.', 'odds': '60', 'friend': '0', 'dice': '1'}}

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


Re: Jargons of Info Tech industry

2005-08-29 Thread T Beck

John Bokma wrote:
 T Beck [EMAIL PROTECTED] wrote:

 
[snip]
  alongside of it.  The internet is a free-flowing evolving place... to
  try to protect one little segment like usenet from ever evolving is
  just ensuring it's slow death, IMHO.

 And if so, who cares? As long as people hang out on Usenet it will stay.
 Does Usenet need al those extra gimmicks? To me, it would be nice if a
 small set would be available. But need? No.

 The death of Usenet has been predicted for ages. And I see only more and
 more groups, and maybe more and more people on it.

 As long as people who have to say something sensible keep using it, it
 will stay.

I suppose I was (as many people on the internet have a bad habit of
doing) being more caustic than was strictly necessary.  I don't really
forsee the death of usenet anytime soon, I just don't think the idea of
it evolving is necessarily bad.  I don't really have alot of vested
interest one way or the other, to be honest, and I'm perfectly happy
with the way it is.

I just think it's a naive view to presume it never will change, because
change is what the internet as a whole was built on.

I think I'll calmly butt out now  ^_^

-- T Beck

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


socket.gaierror from httplib

2005-08-29 Thread spamsink42
this code

h=httplib.HTTPConnection('euronext.com')
h.request('GET',
'http://www.euronext.com/home/0,3766,1732,00.html')

fails with this message

  File httplib.py, line 532, in connect
socket.SOCK_STREAM):
socket.gaierror: (-2, 'Name or service not known')

what am i doing wrong?

thanks
eric

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


Re: using common lisp with python.

2005-08-29 Thread [EMAIL PROTECTED]
basically, what I'm looking to do is use python as a bridge between C
and Common Lisp to create a virtual city that contains Artificial life.

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


Re: trictionary?

2005-08-29 Thread Steven Bethard
Randy Bush wrote:
 Steven Bethard wrote:
 It would probably help if you explained what the real problem is
 you're trying to solve.
 
 actually, that code fragment was meant to do that.  it's pretty much
 what i needed to do at that point, just the variable names made
 simple.

Yeah, I gathered that.  Sometimes though, you may not ever need to get 
to that point if the surrounding code can be properly reorganized. 
But I can't tell if that's possible unless you explain what the goal of 
the program is, not just how your current code tries to approach that goal.

So I'm going to try to pump you for a little more information here.  Is 
your goal to count, for each week, how many times it's full and how 
many times it's not full?  What do you use the counts for?  What does 
full mean?  Is it always a 0 or 1?  What's the importance of the 
output formatting?

 so, to do this using the real names, it looks like
 
for [start, end, AS, full] in heard:
   week = int((start-startDate)/aWeek)
   if week in bin:
  if full:
   bin[week][0] += 1
else:
   bin[week][1] += 1
   else:
  if full:
   bin[week] = [1, 0]
else:
   bin[week] = [0, 1]
...
for i, (j, k) in bin.iteritems():
   if j == 0:
print str(i) + ,, + str(k)
   elif k == 0:
print str(i) + , + str(j)
   else:
print str(i) + , + str(j) + , + str(k)

For the current code, I'd probably go with something like:

 for start, end, AS, full in heard:
 week = int((start-startDate)/aWeek)
 if week in bin:
 bin[week][not full] += 1
 else:
 # I'm assuming full takes the values 0 or 1
 # but if not, you can coerce it with bool()
 bin[week] = [full, int(not full)]
...
for i, (j, k) in bin.iteritems():
result = [str(i), j and str(j) or '']
# special-case k because if it's zero, the reference
# code drops a comma
if k:
result.append(str(k))
print ','.join(result)

But if you're just trying to count the number of times a week is full or 
not full, I'd probably do something like:

 for start, end, AS, full in heard:
 week = int((start-startDate)/aWeek)
 if week in bin:
 bin[week].append(full)
 else:
 bin[week] = [full]
...
for i, fulls in bin.iteritems():
j = sum(fulls)
k = len(fulls) - j
...


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


Re: GIL, threads and scheduling - performance cost

2005-08-29 Thread Pierre Barbier de Reuille
[EMAIL PROTECTED] a écrit :
 Hi all,
 
 Wondering if a GIL lock/unlock causes a re-schedule/contect swap when
 embedding Python in a multi-threaded C/C++ app on Unix ?
 
 If so, do I have any control or influence on this re-scheduling ?
 
 The app suffers from serious performance degradation (compared to pure
 c/C++) and high context switches that I suspect the GIL unlocking may
 be aggravating ?

Well, where do you observe this degradation ? When replacing part of the
C++ code by Python's code ? Or on C++ code running parallel to your
Python code ?

Because in the first case, well, this is just something natural ! Python
runtime overhead is much greater than C++ because of its dynamic nature
(it has to resolve all the symbols at runtime ...). And given the policy
for locking/releasing the GIL, I doubt it has serious performance issues
compared to the Python interpreter itself. If current performance is an
issue, consider implementing more in C/C++ ! This will be mainly true if
you currently have some heavy looping in Python. Python is very neat to
put together processor-intensive functions written in other languages,
but not to implement them. (as an exemple looh at that:
http://www.python.org/doc/essays/list2str.html )

 
 Thanks for any help.
 
 Alan
 

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


Re: GIL, threads and scheduling - performance cost

2005-08-29 Thread adsheehan
Merci Pierre,

Yes I agree and plan to move more to C/C++ and releasing the GIL when
entering C/C++.

I also need to understand my original question re GIL and rescheduling.
I fear that lock/unlock too often is also causing delays due to context
switching.

BTW do you have any hints/comments on SWIG/BOOST etc to glue PY and
C/C++ ?


Alan

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


Re: Jargons of Info Tech industry

2005-08-29 Thread Alan Balmer
Why on earth was this cross-posted to comp.lang.c.? Followups set.

On Mon, 29 Aug 2005 12:26:11 GMT, [EMAIL PROTECTED] wrote:

In comp.lang.perl.misc Mike Meyer [EMAIL PROTECTED] wrote:
 [EMAIL PROTECTED] writes:
 In comp.lang.perl.misc John Bokma [EMAIL PROTECTED] wrote:
 Chris Head [EMAIL PROTECTED] wrote:
 What advantages would those be (other than access from 'net cafes, but
 see below)?
 And workplaces. Some people have more then one computer in the house. My 
 partner can check her email when I had her over the computer. When I 
 want to check my email when she is using it, I have to change the 
 session, fire up Thunderbird (which eats away 20M), and change the 
 session back.
 Not a Windows solution, but I find the 'screen' utility invaluable as
 I can have my email, news, and an editor open in different screens
 and then when I need to move to a different machine, I can simply
 detach and reattach screen without disturbing anything that
 might be running.
 
 For a more  portable solution, check out VNC.
 
I know... but it is a bugger to set up and I believe it is no longer
freeware (if it ever was), and it does not have the stark simplicity
which screen has... I only need to have a compiled version of screen
on the machine on which I do most of my work and be able to ssh/telnet
to that machine without involving any additional software installations
on other machines.

Axel
-- 
Al Balmer
Balmer Consulting
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python xml DOM? pulldom? SAX?

2005-08-29 Thread tooper
Hi,

I'd advocate for using SAX, as DOM related methods implies loading the
complete XML content in memory whereas SAX grab things on the fly.
SAX method should therefore be faster and less memory consuming...

By the way, if your goal is to just combine the text out of page:title
and page:revision:text for every single page element, maybe you should
also consider an XSLT filter.

Regards,
Thierry

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


Re: Robust statistics and optimmization from Python

2005-08-29 Thread beliavsky
Robert Kern wrote:

snip

 If you find suitable
 FORTRAN or C code that implements a particular robust algorithm, it
 can probably wrapped for scipy relatively easily.

An alternative would be to call R (a free statistical package) from
Python, using something like the R/SPlus - Python Interface at
http://www.omegahat.org/RSPython/ . Many statistical algorithms,
including those for robust statistics, have been implemented in R,
usually by wrapping C or Fortran 77 code.

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


Re: python xml DOM? pulldom? SAX?

2005-08-29 Thread Michael Ekstrand
On 29 Aug 2005 08:17:04 -0700
jog [EMAIL PROTECTED] wrote:
 I want to get text out of some nodes of a huge xml file (1,5 GB). The
 architecture of the xml file is something like this
 [structure snipped]
 I want to combine the text out of page:title and page:revision:text
 for every single page element. One by one I want to index these
 combined texts (so for each page one index)
 What is the most efficient API for that?: SAX ( I don´t thonk so) DOM
 or pulldom?

Definitely SAX IMHO, or xml.parsers.expat. For what you're doing, an
event-driven interface is ideal. DOM parses the *entire* XML tree into
memory at once, before you can do anything - highly inefficient for a
large data set like this. I've never used pulldom, it might have
potential, but from my (limited and flawed) understanding of it, I
think it may also wind up loading most of the file into memory by the
time you're done.

SAX will not build any memory structures other than the ones you
explicitly create (SAX is commonly used to build DOM trees). With SAX,
you can just watch for any tags of interest (and perhaps some
surrounding tags to provide context), extract the desired data, and all
that very efficiently.

It took me a bit to get the hang of SAX, but once I did, I haven't
looked back. Event-driven parsing is a brilliant solution to this
problem domain.

 Or should I just use Xpath somehow.

XPath usually requires a DOM tree on which it can operate. The Python
XPath implementation (in PyXML) requires DOM objects. I see this as
being a highly inefficient solution.

Another potential solution, if the data file has extraneous
information: run the source file through an XSLT transform that strips
it down to only the data you need, and then apply SAX to parse it.

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


Re: python xml DOM? pulldom? SAX?

2005-08-29 Thread Fredrik Lundh
jog wrote:

 I want to get text out of some nodes of a huge xml file (1,5 GB). The
 architecture of the xml file is something like this

 I want to combine the text out of page:title and page:revision:text for
 every single page element. One by one I want to index these combined
 texts (so for each page one index)

here's one way to do it:

try:
import cElementTree as ET
except ImportError:
from elementtree import ElementTree as ET

for event, elem in ET.iterparse(file):
if elem.tag == page:
title = elem.findtext(title)
revision = elem.findtext(revision/text)
print title, revision
elem.clear() # won't need this any more

references:

http://effbot.org/zone/element-index.htm
http://effbot.org/zone/celementtree.htm (for best performance)
http://effbot.org/zone/element-iterparse.htm

/F 



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


Re: trictionary?

2005-08-29 Thread Randy Bush
 bin = {}
 for start, end, AS, full in heard:
week = int((start-startDate)/aWeek)
counters = bin.setdefault(week, [0, 0])
if full:
   counters[0] += 1
else:
   counters[1] += 1

yes!  thanks!

 Using an idea you used earlier, you could get smaller code by saying:
 for start, end, AS, full in heard:
week = int((start-startDate)/aWeek)
counters = bin.setdefault(week, [0, 0])
counters[not full] += 1
 Or
 for start, end, AS, full in heard:
week = int((start-startDate)/aWeek)
bin.setdefault(week, [0, 0])[not full] += 1
 Or even
 for start, end, AS, full in heard:
   bin.setdefault(int((start-startDate)/aWeek), [0, 0])[not full] += 1

as you say, too clever.

 Using lists to represent structs is perfectly fine if the list doesn't 
 live longer than about one screen of code.

i can definitely see that.  in last weeks installment, i buried a
complex trinary tree in a class.

thanks for the advice!

randy

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


Re: GIL, threads and scheduling - performance cost

2005-08-29 Thread Pierre Barbier de Reuille
[EMAIL PROTECTED] a écrit :
 Merci Pierre,
 
 Yes I agree and plan to move more to C/C++ and releasing the GIL when
 entering C/C++.
 
 I also need to understand my original question re GIL and rescheduling.
 I fear that lock/unlock too often is also causing delays due to context
 switching.

Well, concerning GIL and rescheduling, releasing a lock is very likely
to induce rescheduling and context switch, but it won't if the system
considers it worthless. But this is true that lock/unlock has a cost and
so, doing it too much will slow down your app.

 
 BTW do you have any hints/comments on SWIG/BOOST etc to glue PY and
 C/C++ ?

Well, for C I would recommand SWIG. For C++, I personnaly use
Boost.Python. However, you must know that SWIG did not support C++ well
when I had to choose between the two, so there was no question for me.
Then, somehow it depends on how you feel with the tools: SWIG depends on
a specific language and has its own tools while Boost is entirely
written in C++ and uses heavily templates. For performances, Boost
generate better code that SWIG, mainly because SWIG relies on Python
code that encapsulate the actual C functions while Boost does everything
in C++. Also, at least with G++, compiling Boost extension is very time-
and memory-consuming due to its heavy use of templates. As I don't use
SWIG, I don't know about the community, but at least for Boost.Python it
is quite active and questions on the mailing list are answered quickly
enough. Well, this is very quick but if you need more detailed
information, I recommend you to visit both websites.

 
 
 Alan
 

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


Re: Bug in string.find; was: Re: Proposed PEP: New style indexing,was Re: Bug in slice type

2005-08-29 Thread Steven Bethard
Antoon Pardon wrote:
 I think a properly implented find is better than an index.

See the current thread in python-dev[1], which proposes a new method, 
str.partition().  I believe that Raymond Hettinger has shown that almost 
all uses of str.find() can be more clearly be represented with his 
proposed function.

STeVe

[1]http://mail.python.org/pipermail/python-dev/2005-August/055781.html
-- 
http://mail.python.org/mailman/listinfo/python-list


ANN: PyDev 0.9.8 released

2005-08-29 Thread Fabio Zadrozny
Hi All,

PyDev - Python IDE (Python Development Enviroment for Eclipse) version 
0.9.8 has just been released.

Check the homepage (http://pydev.sourceforge.net/) for more details.

Details for Release: 0.9.8

Major highlights:
---

* Jython integrated.
* Jython debugger support added.

Others that are new and noteworthy:
-

* jython integration supports spaces for jython.jar and java install
* jython code-completion support for new style objects (jython 
2.2a1) has been enhanced.
* many templates were added
* the grammar evolved a lot, so, now you actually have decorators in 
the grammar, list comprehension on method calls and tuples and the new 
from xxx import (a,b,c) syntax.
* pylint supports spaces
* pylint is no longer distributed with pydev (it must be installed 
in the site-packages and its location must be specified in the preferences)
* some problems regarding 'zombie processes' after eclipse exit with 
the shells used for code-completion should be fixed

Special thanks
---

This release would not be possible without help from:

OctetString, for the financial support for making jython support possible!
Vitor Oba for debugger patches!

Cheers,

Fabio

-- 
Fabio Zadrozny
--
Software Developer

ESSS - Engineering Simulation and Scientific Software
www.esss.com.br

PyDev - Python Development Enviroment for Eclipse
pydev.sf.net
pydev.blogspot.com


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


Re: Jargons of Info Tech industry

2005-08-29 Thread Alan Balmer
On Fri, 26 Aug 2005 16:47:10 GMT, Chris Head [EMAIL PROTECTED]
wrote:

This point I agree with. There are some situations - 'net cafes included
- - where thick e-mail clients don't work. Even so, see below.

I use Portable Thunderbird, on a USB memory stick. All I need is a USB
port and an internet connection.
-- 
Al Balmer
Balmer Consulting
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Exploring outlook contents

2005-08-29 Thread Subir
Hi,

  I am trying to build an application to explore the contents of an
outlook .pst files. All the reference that I have seen uses the
registry to do so. Does any one know any other way of doing this. Also,
is anyone has any code which does something related to this, please let
me know.

-Subir

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


Re: trictionary?

2005-08-29 Thread Randy Bush
 So I'm going to try to pump you for a little more information here.  Is 
 your goal to count, for each week, how many times it's full and how 
 many times it's not full?  What do you use the counts for?  What does 
 full mean?  Is it always a 0 or 1?  What's the importance of the 
 output formatting?

'full' is boolean.  it says whether a particular bgp announcement
was for the entire ip address allocation, or is a longer prefix.
e.g., if an allocation was for 666.42.0.0/16 and we heard a bgp
announcement for 666.42.1.0/24 that is !full, while an announcement
for the prefix 666.42.0.0/16 is full.

you asked :-)

  for start, end, AS, full in heard:
  week = int((start-startDate)/aWeek)
  if week in bin:
  bin[week][not full] += 1
  else:
  # I'm assuming full takes the values 0 or 1
  # but if not, you can coerce it with bool()
  bin[week] = [full, int(not full)]

hmmm.  this also reads well.

as an old pascal and modula-2 bondage and discipline type, i gotta
say is it a breath of fresh air to be in a language and community
which care about how code reads more than how clever it is.

randy

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


Re: python xml DOM? pulldom? SAX?

2005-08-29 Thread Alan Kennedy
[jog]
  I want to get text out of some nodes of a huge xml file (1,5 GB). The
  architecture of the xml file is something like this

[snip]

  I want to combine the text out of page:title and page:revision:text
  for every single page element. One by one I want to index these
  combined texts (so for each page one index)
  What is the most efficient API for that?:
  SAX ( I don´t thonk so)

SAX is perfect for the job. See code below.

  DOM

If your XML file is 1.5G, you'll need *lots* of RAM and virtual memory 
to load it into a DOM.

  or pulldom?

Not sure how pulldom does it's pull optimizations, but I think it 
still builds an in-memory object structure for your document, which will 
still take buckets of memory for such a big document. I could be wrong 
though.

  Or should I just use Xpath somehow.

Using xpath normally requires building a (D)OM, which will consume 
*lots* of memory for your document, regardless of how efficient the OM is.

Best to use SAX and XPATH-style expressions.

You can get a limited subset of xpath using a SAX handler and a stack. 
Your problem is particularly well suited to that kind of solution. Code 
that does a basic job of this for your specific problem is given below.

Note that there are a number of caveats with this code

1. characterdata handlers may get called multiple times for a single xml 
text() node. This is permitted in the SAX spec, and is basically a 
consequence of using buffered IO to read the contents of the xml file, 
e.g. the start of a text node is at the end of the last buffer read, and 
the rest of the text node is at the beginning of the next buffer.

2. This code assumes that your revision/text nodes do not contain 
mixed content, i.e. a mixture of elements and text, e.g. 
revisiontextThis is a piece of brevision/b 
text/text/revision. The below code will fail to extract all 
character data in that case.

#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
import xml.sax

class Page:

   def append(self, field_name, new_value):
 old_value = 
 if hasattr(self, field_name):
   old_value = getattr(self, field_name)
 setattr(self, field_name, %s%s % (old_value, new_value))

class page_matcher(xml.sax.handler.ContentHandler):

   def __init__(self, page_handler=None):
 xml.sax.handler.ContentHandler.__init__(self)
 self.page_handler = page_handler
 self.stack = []

   def check_stack(self):
 stack_expr = / + /.join(self.stack)
 if '/parent/page' == stack_expr:
   self.page = Page()
 elif '/parent/page/title/text()' == stack_expr:
   self.page.append('title', self.chardata)
 elif '/parent/page/revision/id/text()' == stack_expr:
   self.page.append('revision_id', self.chardata)
 elif '/parent/page/revision/text/text()' == stack_expr:
   self.page.append('revision_text', self.chardata)
 else:
   pass

   def startElement(self, elemname, attrs):
 self.stack.append(elemname)
 self.check_stack()

   def endElement(self, elemname):
 if elemname == 'page' and self.page_handler:
   self.page_handler(self.page)
   self.page = None
 self.stack.pop()

   def characters(self, data):
 self.chardata = data
 self.stack.append('text()')
 self.check_stack()
 self.stack.pop()

testdoc = 
parent
 page
  titlePage number 1/title
  idp1/id
  revision
idr1/id
textrevision one/text
  /revision
 /page
 page
  titlePage number 2/title
  idp2/id
  revision
idr2/id
textrevision two/text
  /revision
 /page
/parent


def page_handler(new_page):
   print New page
   print title\t\t%s % new_page.title
   print revision_id\t%s % new_page.revision_id
   print revision_text\t%s % new_page.revision_text
   print

if __name__ == __main__:
   parser = xml.sax.make_parser()
   parser.setContentHandler(page_matcher(page_handler))
   parser.setFeature(xml.sax.handler.feature_namespaces, 0)
   parser.feed(testdoc)
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

HTH,

-- 
alan kennedy
--
email alan:  http://xhaus.com/contact/alan
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Newbie question: Sub-interpreters for CAD program

2005-08-29 Thread David MacQuigg
On Sat, 27 Aug 2005 16:56:03 -0500, Terry Hancock
[EMAIL PROTECTED] wrote:
On Saturday 27 August 2005 03:21 am, David MacQuigg wrote:

 There is a similar lack of interest in the academic community.  None
 of this is likely to lead to publications in scholarly journals.

I'm confused by what you meant by this.  Are you saying that academics
are afraid of using or creating open source CAD tools, or that they have
a lack of interest in tools development, because it won't generate papers
(directly anyway)?

It seems like a lack of interest in tools development, because there
are no new fundamental principles, sophisticated math, or anything
that could help directly and in the short term to get a publication.
There is probably also a perception, shared with engineers in
industry, that the complexity of these tools is inherent in the task.
It's OK for a full-time engineer to spend a few months learning the
intricacies of a poorly-designed scripting language that works with
just one tool, but not appropriate for students.

My hope is that we can get a few good projects to demonstrate the
utility of Python in doing sophisticated designs with simple tools.
Then we will have a foothold in the Universities.  Next will be small
companies that can't afford a CAD department with 10 engineers
dedicated to tool setup.

--
Dave

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


Re: Newbie question: Sub-interpreters for CAD program

2005-08-29 Thread David MacQuigg
On 27 Aug 2005 17:00:07 -0700, sonicSpammersGoToHellSmooth
[EMAIL PROTECTED] wrote:

Cool, I went to the UofA for my MS in ECE, 2000.  I did my theses under
Chuck Higgins. --
http://neuromorph.ece.arizona.edu/pubs/ma_schwager_msthesis.pdf

The tools we had were constantly underwhelming me, so I've been
thinking for years that a properly designed new toolset for students
should be marketable, etc.  I'll take a look at your site (although I
think I may have come across it before.)

A toolset for students is exactly what we need.  Whether that turns
into a marketable product is a question for later.  At this point, we
need a few people with a strong motivation to help students.  Sounds
like you might have what it takes.  Send me an email if you are
interested.

-- Dave

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


command history behavior in windows and linux

2005-08-29 Thread Leo
Does someone know if there is a setting in the python Unix world to
make the command history behave as it does in the Windows intepreter?
Specifically, I like the fact that the command history remembers which
of a sequence of commands is the one that I last issued. For example,
suppose that I typed the following lines into the interpreter:

import foo
for e in foo.container:
   print e

In Unix, I would have to tap up arrow 3 times for each line:

up up up gives me import foo. I press enter.
up up up gives me for I press enter.
up up up gives meprint I press enter.

In Windows, I get this behavior I like better:

up up up gives me import foo. I press enter.
down gives me for I press enter.
down gives meprint I press enter.

How do I get the second behavior to take place in all the platforms I
use? Also, the windows version remembers my commands across sections.
How do I enable that in the python version?

I tried editing the inputrc file that controls the readline library by
adding the following lines:

$if python
set history-preserve-point on
$endif

but this did not seem to work.

TIA,
Leo.

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


Re: using common lisp with python.

2005-08-29 Thread [EMAIL PROTECTED]
Your best bet is probably to look into your LISP environment's FFI
(Foreign Function Interface).  Most LISP environments have some way to
call C code directly.  Insofar as going back the other way... that I'm
a little more sketchy on.  Guile (the Scheme compiler from GNU) is a
strong contender, though.  It's not Common LISP, but it's a LISP with
copious documentation for how to call it from C.

I really can't see a reason to use Python as a glue layer.  I'd
recommend rewriting your LISP code in Python before I'd recommend using
Python to interface between Common LISP and C.

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


Re: using common lisp with python.

2005-08-29 Thread Robert Kern
[EMAIL PROTECTED] wrote:
 Your best bet is probably to look into your LISP environment's FFI
 (Foreign Function Interface).  Most LISP environments have some way to
 call C code directly.  Insofar as going back the other way... that I'm
 a little more sketchy on.  Guile (the Scheme compiler from GNU) is a
 strong contender, though.  It's not Common LISP, but it's a LISP with
 copious documentation for how to call it from C.

ECL might be a good choice for real Common Lisp (more or less).

http://ecls.sourceforge.net/

 I really can't see a reason to use Python as a glue layer.  I'd
 recommend rewriting your LISP code in Python before I'd recommend using
 Python to interface between Common LISP and C.

Agreed.

-- 
Robert Kern
[EMAIL PROTECTED]

In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die.
  -- Richard Harter

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


Re: Jargons of Info Tech industry

2005-08-29 Thread John Bokma
Alan Balmer [EMAIL PROTECTED] wrote:

 Why on earth was this cross-posted to comp.lang.c.? Followups set.

Your reply is even more meaningless and more noise compared to the 
crosspost. Why? You didn't add anything, you quote an entire message and 
you just tweaked the follow up to header in a bad way.

-- 
John   Small Perl scripts: http://johnbokma.com/perl/
   Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html

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


Re: Jargons of Info Tech industry

2005-08-29 Thread John Bokma
Alan Balmer [EMAIL PROTECTED] wrote:

 On Fri, 26 Aug 2005 16:47:10 GMT, Chris Head [EMAIL PROTECTED]
 wrote:
 
This point I agree with. There are some situations - 'net cafes included
- - where thick e-mail clients don't work. Even so, see below.
 
 I use Portable Thunderbird, on a USB memory stick. All I need is a USB
 port and an internet connection.

It's a brave internetcafe that allows such things. (I mean technically one 
can have a Portable Spam Device :-).

-- 
John   Small Perl scripts: http://johnbokma.com/perl/
   Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html

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


Re: python xml DOM? pulldom? SAX?

2005-08-29 Thread Fredrik Lundh
Alan Kennedy wrote:

 SAX is perfect for the job. See code below.

depends on your definition of perfect...

using a 20 MB version of jog's sample, and having replaced
the print statements with local variable assignments, I get the
following timings:

5 lines of cElementTree code: 7.2 seconds
60+ lines of xml.sax code: 63 seconds

(Python 2.4.1, Windows XP, Pentium 3 GHz)

/F 



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


Re: Cygwin font problems

2005-08-29 Thread Robin Becker
Steve Holden wrote:
 Is anyone aware of (a fix for) problems I'm having getting PIL 1.1.5 to 
 create bitmaps using TrueType and openType fonts? When I create an image 
 using the standard PIL fonts everything seems fine, but when I use 
 ImageFont.truetype(font-file, size) no text is drawn.
 
 setup.py reports from debug print statements that it's finding freetype21.
 
 The same code using (Fredrik's pre-built binary) on Windows runs 
 correctly and produces correct images.
 
 Cygwin runs Python 2.4.1, Windows runs 2.4. Any light on this mystery 
 gratefully received.
 
 regards
  Steve
Could PIL have been compiled without freetype support perhaps?

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


Re: python xml DOM? pulldom? SAX?

2005-08-29 Thread Alan Kennedy
[Alan Kennedy]
 SAX is perfect for the job. See code below.

[Fredrik Lundh]
  depends on your definition of perfect...

Obviously, perfect is the eye of the beholder ;-)

[Fredrik Lundh]
 using a 20 MB version of jog's sample, and having replaced
 the print statements with local variable assignments, I get the
 following timings:
 
 5 lines of cElementTree code: 7.2 seconds
 60+ lines of xml.sax code: 63 seconds
 
 (Python 2.4.1, Windows XP, Pentium 3 GHz)

Impressive!

At first, I thought your code sample was building a tree for the entire 
document, so I checked the API docs. It appeared to me that an event 
processing model *couldn't* obtain the text for the node when notified 
of the node: the text node is still in the future.

That's when I understood the nature of iterparse, which must generate an 
event *after* the node is complete, and it's subdocument reified. That's 
also when I understood the meaning of the elem.clear() call at the 
end. Only the required section of the tree is modelled in memory at any 
given time. Nice.

There are some minor inefficiencies in my pure python sax code, e.g. 
building the stack expression for every evaluation, but I left them in 
for didactic reasons. But even if every possible speed optimisation was 
added to my python code, I doubt it would be able to match your code.

I'm guessing that a lot of the reason why cElementTree performs best is 
because the model-building is primarily implemented in C: Both of our 
solutions run python code for every node in the tree, i.e. are O(N). But 
yours also avoids the overhead of having function-calls/stack-frames for 
every single node event, by processing all events inside a single function.

If the SAX algorithm were implemented in C (or Java) for that matter, I 
wonder if it might give comparable performance to the cElementTree code, 
primarily because the data structures it is building are simpler, 
compared to the tree-subsections being reified and discarded by 
cElementTree. But that's not of relevance, because we're looking for 
python solutions. (Aside: I can't wait to run my solution on a 
fully-optimising PyPy :-)

That's another nice thing I didn't know (c)ElementTree could do.

enlightened-ly'yrs,

-- 
alan kennedy
--
email alan:  http://xhaus.com/contact/alan
-- 
http://mail.python.org/mailman/listinfo/python-list


python and ajax

2005-08-29 Thread Steve Young
Hi, I was wondering if anybody knew of any good
tutorial/example of AJAX/xmlhttprequest in python.
Thanks.

-Steve




Start your day with Yahoo! - make it your home page 
http://www.yahoo.com/r/hs 
 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Exploring outlook contents

2005-08-29 Thread Beowulf TrollsHammer
Subir wrote:

 Hi,

   I am trying to build an application to explore the contents of an
 outlook .pst files. All the reference that I have seen uses the
 registry to do so. Does any one know any other way of doing this. Also,
 is anyone has any code which does something related to this, please let
 me know.

 -Subir


Check this out:

http://www.boddie.org.uk/python/COM.html

HTH

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


Re: python and ajax

2005-08-29 Thread Do Re Mi chel La Si Do
Hi !


Here :  http://wikipython.flibuste.net/moin.py/AJAX


@-salutations

Michel Claveau 


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


Re: python image thumbnail generator?

2005-08-29 Thread Paul Rubin
Fredrik Lundh [EMAIL PROTECTED] writes:
  You could do it with PIL, or run jpegtran in an external process.
  jpegtran may be easier.
 
 eh?  are you sure you know what jpegtran does?
 
 JPEGTRAN(1) 

Whoops, sorry, right, jpegtran is for rotating the images.  I meant:
use a pipeline like

djpeg -scale 1/4 | cjpeg

That's how I usually do it.  Main disadvantage is the scale factor has
to be 1/2, 1/4, 1/8, etc., not arbitrary amounts like 0.3456.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Robust statistics and optimmization from Python

2005-08-29 Thread araki
use R. it's pretty highend, and there is an interface for python.

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


Basic Server/Client socket pair not working

2005-08-29 Thread Michael Goettsche
Hi there,

I'm trying to write a simple server/client example. The client should be able 
to send text to the server and the server should distribute the text to all 
connected clients. However, it seems that only the first entered text is sent 
and received. When I then get prompted for input again and press return, 
nothing gets back to me. Any hints on what I have done would be very much 
appreciated!

Here's my code:

 SERVER ##
import socket
import select
 
mySocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
mySocket.bind(('', 1))
mySocket.listen(1)
 
clientlist = []
 
while True:
   connection, details = mySocket.accept()
   print 'We have opened a connection with', details
   clientlist.append(connection)
   readable = select.select(clientlist, [], [])
   msg = ''
   for i in readable[0]:
  while len(msg)  1024:
 chunk = i.recv(1024 - len(msg))
 msg = msg + chunk
 
   for i in clientlist:
  totalsent = 0
  while totalsent  1024:
 sent = i.send(msg)
 totalsent = totalsent + sent
 
## CLIENT 
import socket
import select
 
socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
socket.connect((127.0.0.1, 1))
 
while True:
text = raw_input(Du bist an der Reihe)
text = text + ((1024 - len(text)) * .)
totalsent = 0
while totalsent  len(text):
sent = socket.send(text)
totalsent = totalsent + sent
 
msg = ''
while len(msg)  1024:
chunk = socket.recv(1024 - len(msg))
msg = msg + chunk
 
print msg
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Virtual Slicing

2005-08-29 Thread Bryan Olson
Sybren Stuvel wrote:
  Bryan Olson enlightened us with:
 
 I recently wrote a module supporting value-shared slicing.
 
  Maybe I'm dumb, but could you explain this concept? Why would someone
  whant this?

My original motivation was reduce the amount of copying in some
tools that parse nested structures. All I really needed at the
time was a reference to a string, and the start and stop values.
Once I adopted Python's sequence interface, I thought I might as
well implement it consistently, generally, and completely.

So the first reason someone might want this is for efficiency,
in space and/or time.

The second reason is more abstract. Python's slice assignment is
a useful feature, but the slice selection must appear on the
right-hand-side of assignment. VSlice lets one instantiate the
updatable slice as an object, and pass it around.

I looked into supporting slice assignment between slices of
different sizes when possible, but the various options I came up
with all sucked.


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


Re: python image thumbnail generator?

2005-08-29 Thread Damjan
Chris Dewin wrote:

 Hi. I run a website for my band, and the other guys want an image gallery.
 
 I'm thinking it would be nice and easy, if we could just upload a jpg into
 a dir called gallery/. When the client clicks the gallery link, a
 cgi script could search the gallery/ dir, and create thumbnails of any
 jpeg images that don't already have a thumbnail associated with them. The
 script could then generate a page of clickable thumbnails.

Once I made an example mod_python handler, that resized images on the fly.
For example:
 http://server/folder/image.jpg - would give you the original image, served
directly by apache without any performance hit.

 http://server/folder/image.jpg?thumbnail  - would resize the picture (and
cache the result on disk) and return that, on a second request it would
return the cached image very fast by calling an apache.send_file function.

see
http://www.modpython.org/pipermail/mod_python/2004-September/016471.html

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


Re: global interpreter lock

2005-08-29 Thread Bryan Olson
Mike Meyer wrote:
  Bryan Olson writes:
  phil hunt wrote:
 
   What's important is *predictability*, e.g. which instruction will
   the computer execute next?
  
   If you only have one thread, you can tell by looking at the code
   what gets executed next. It's very simple.
 Not really. Trivially, an 'if' statement that depends upon input
 data is statically predictable. Use of async I/O means makes the
 programs execution dependent upon external timing.
 
 
  Yes, but that depenency is tied to a single point - the select
  call. The paths after that are statically predictable. This makes the
  code very managable.

Wow -- I could not disagree more. Returning back to some single
point for every possibly-blocking operation is painful to manage
even for simple GUIs, and humanly intractable for sophisticated
services.

Select is certainly useful, but it scales badly and isn't as
general as better tools.

  [...] I'm calling the tools available in most programming
  languages for dealing with it primitive.
 
  We need better tools.

Agreed, but if 'select' is someone's idea of the state of the
art, they have little clue as to the tools already available.
Bringing the tools to Python remains a bit of challenge, largely
because so many Pythoners are unaware.


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


Re: NooB Question

2005-08-29 Thread Jeff Schwab
APCass wrote:
 How do you execute a .py in Linux with KDE?  If I double click on my
 program it opens Kwrite, for editing.

Try inserting this as the first line of the file:

#!/usr/bin/env python
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Basic Server/Client socket pair not working

2005-08-29 Thread Nicolas Couture

Michael Goettsche wrote:
 Hi there,

 I'm trying to write a simple server/client example. The client should be able
 to send text to the server and the server should distribute the text to all
 connected clients. However, it seems that only the first entered text is sent
 and received. When I then get prompted for input again and press return,
 nothing gets back to me. Any hints on what I have done would be very much
 appreciated!

 Here's my code:

  SERVER ##
 import socket
 import select

 mySocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
 mySocket.bind(('', 1))
 mySocket.listen(1)

 clientlist = []

 while True:
connection, details = mySocket.accept()
print 'We have opened a connection with', details
clientlist.append(connection)
readable = select.select(clientlist, [], [])
msg = ''
for i in readable[0]:

for i in readable:

   while len(msg)  1024:
  chunk = i.recv(1024 - len(msg))
  msg = msg + chunk

for i in clientlist:
   totalsent = 0
   while totalsent  1024:
  sent = i.send(msg)
  totalsent = totalsent + sent

 ## CLIENT 
 import socket
 import select

 socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
 socket.connect((127.0.0.1, 1))

 while True:
 text = raw_input(Du bist an der Reihe)
 text = text + ((1024 - len(text)) * .)
 totalsent = 0
 while totalsent  len(text):
 sent = socket.send(text)
 totalsent = totalsent + sent

 msg = ''
 while len(msg)  1024:
 chunk = socket.recv(1024 - len(msg))
 msg = msg + chunk
  
 print msg

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


Re: reg email packages work

2005-08-29 Thread Steve Holden
praba kar wrote:
 Dear All,
 
I am working in web based email system project.
 Here I try to build email message
 from scratch. I used below code to build email
 message
 
msg =  email.MIMEBase('text','html')
msg['Return-Path'] = user+'@'+domain
msg['Date'] = formatdate(localtime=1)
msg['Subject'] =  subject
msg['From'] = from_name
msg['To'] = to
msg['Cc'] = cc
msg.set_payload(Body of the email messagge)
fh = os.popen('/bin/sendmail  %s'% (eachid),'w')
fh.write(msg.as_string())
fh.close()
 
 This code will build plain email message properly.
 But after building the message.  If a email user
 download this mail through out look express then
 this email message will display without any alignment.
  If a user type 3 paragraph message
 outlook express display as a single line.  What
 could be problem?.  Kindly let me know ASAP
 
It's obvious you aren't using that EXACT code, because it doesn't 
formulate a three-paragraph message. So the bit we really need to see is 
how you capture and formulate the argument to set_payload().

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/

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


Re: python xml DOM? pulldom? SAX?

2005-08-29 Thread William Park
jog [EMAIL PROTECTED] wrote:
 Hi,
 I want to get text out of some nodes of a huge xml file (1,5 GB). The
 architecture of the xml file is something like this
 parent
page
 titlebla/title
 id/id
 revision
   id/id
   textblablabla/text
 revision
/page
page
/page
 
 /parent
 I want to combine the text out of page:title and page:revision:text for
 every single page element. One by one I want to index these combined
 texts (so for each page one index)
 What is the most efficient API for that?: SAX ( I don?t thonk so) DOM
 or pulldom?
 Or should I just use Xpath somehow.
 I don`t want to do anything else with his xml file afterwards.
 I hope someone will understand me.
 Thank you very much
 Jog

I would use Expat interface from Python, Awk, or even Bash shell.  I'm
most familiar with shell interface to Expat, which would go something
like

start() # Usage: start tag att=value ...
{
case $1 in
page) unset title text ;;
esac
}
data()  # Usage: data text
{
case ${XML_TAG_STACK[0]}.${XML_TAG_STACK[1]}.${XML_TAG_STACK[2]} in
title.page.*) title=$1 ;;
text.revision.page) text=$1 ;;
esac
}
end()   # Usage: end tag
{
case $1 in
page) echo title=$title text=$text ;;
esac
}
expat -s start -d data -e end  file.xml

-- 
William Park [EMAIL PROTECTED], Toronto, Canada
ThinFlash: Linux thin-client on USB key (flash) drive
   http://home.eol.ca/~parkw/thinflash.html
BashDiff: Super Bash shell
  http://freshmeat.net/projects/bashdiff/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python and ajax

2005-08-29 Thread matt
Steve-

I recently ported version 1.3 of cpaint to python.  Soon after version
2.0 was released and I haven't really looked at it since.  The 1.3
stuff was really simple though if you understand cgi, then you just
implement a endpoint for your request to call.  The javascript side is
really the only thing new (might be a little learning if you having
done much js).

I think that more advanced ajax libraries like dojo or openrico are
probably better suited to more complicated ajax use.  Though they are
more focused on the js frontend stuff.

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


Re: Robust statistics and optimmization from Python

2005-08-29 Thread Tim Churches
[EMAIL PROTECTED] wrote:
 Robert Kern wrote:
 
 snip
 
If you find suitable
FORTRAN or C code that implements a particular robust algorithm, it
can probably wrapped for scipy relatively easily.
 
 
 An alternative would be to call R (a free statistical package) from
 Python, using something like the R/SPlus - Python Interface at
 http://www.omegahat.org/RSPython/ .

Unless you really want to call Python from R (as opposed to calling R
from Python), I strongly suggest that you use RPy (http://rpy.sf.net)
rather than RSPython. RPy is much easier to install and use and far less
buggy than RSPython.

 Many statistical algorithms,
 including those for robust statistics, have been implemented in R,
 usually by wrapping C or Fortran 77 code.

Yup, and if you really don't like the extra dependency or extra memory
requirements of R and RPy, it is often possible to port the R code back
to Python (or Numeric Python), with some effort.

Tim C

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


suggestion for Python graphing package, please

2005-08-29 Thread Stewart Midwinter
I need a graphing library that I can access from within a Tkinter application running on Windows.

It needs to be able to draw some *simple* 2D plots, and then output
them to a file (e.g. .PNG, .JPG) for inclusion in a HTML-formatted
e-mail to interested parties. 

Many of the packages that I've looked at a) either don't output to a
file, or b) are very old (3-5 years), or c) don't run on Windows.

I don't actually care if the library itself is written in Python or c++ or something else.
Any suggestions?

thanks,-- Stewart Midwinter[EMAIL PROTECTED][EMAIL PROTECTED]Skype:midtoadGoogleTalk:midtoadiChatAV:midtoad
MSN:midtoadYahoo:midtoadAIM:midtoad1
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: new line

2005-08-29 Thread Claudio Grondi
Kuljo [EMAIL PROTECTED] schrieb im Newsbeitrag
news:[EMAIL PROTECTED]
 Dear friends
 I'm so sorry to bore you with this trivial problem. Allthou: I have string
 having 0x0a as new line, but I should have \n instead.
 How should I solve it?
 I've tried
 text_new=tex_old.replace(str(0x0a), '\n')
 and other things, but none of them worked.
 Thanks in advance

text_new=tex_old.replace(chr(0x0a), '\r\n')
works for me.

Claudio
P.S. str(0x0a) == '10'


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


  1   2   >