Re: question: script to input data into a webpage and then retrieve the result?

2006-10-22 Thread Christoph Haas
On Sunday 22 October 2006 08:06, mxywp wrote:
> Could someone help me with this or share an example script with me?
>
> Here is what I want to accomplish:
> (1) input 3 values into 3 boxes on a web page
> (2) there is an authentication code each time you access this page and I
> have to write this code into the fourth box on the same page (3) click
> "submit" button
> (4) this web page will turn into a page with a table having a value
> calculated from my inputs (5) extract this value into a local file
> (6) repeat the above for 12000 times.
>
> I would really appreciate it if someone can tell me how to do it using
> python script. I am new to python web programming.

Dark side way:
 http://www.idyll.org/~t/www-tools/twill.html

 Christoph

P.S.: One posting is usually sufficient to get a reply.
-- 
http://mail.python.org/mailman/listinfo/python-list


A very nice free browser to try...

2006-10-22 Thread bj_private
Hi Guys,

There's a very nice browser that is called Smart Bro. I think this
browser is the best browser in the market. It has:

1. Very nice and clean interface.
2. Tabbed browsing.
3. History Cleaner.
4. Popup killer.
5. Form filler.
6. RSS reader.
7. Flash filter.

And best of all it's free. I think you should try it.

You can download it from here http://www.smartbro.com

Best regards, 
John

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


Re: A Comparison Of Dynamic and Static Languiges

2006-10-22 Thread Steve Holden
sturlamolden wrote:
> Gerrit Holl wrote:
> 
> 
>>This newsgroup is mirrored by a mailing-list, so many people use their real
>>address. The solution to spam is spamfiltering (spambayes), not hiding ones
>>address on the internet.
> 
> 
> The answer to spam here in Norway is incredibly simple. It seems that
> all spam originates in the US or South Korea. The following filter can
> thus be applied:
> 
> 1. Create a white-list of all valid contacts in the US.
> (There is no need to create a white list for Korea, as it will be empty
> anyway.)
> 
> 2. Do a reverse nslookup of the sender on zz.countries.nerd.dk. If the
> return value is 127.0.3.72 or 127.0.1.154, and the sender is not in the
> whitelist, flag the mail as spam.
> 
> 3. Accept all other mail.
> 
> Do you think spambayes can beat this filter?
> 
Since network 127 is reserved in its entirety for loopback (local 
process) use, it would seem that any DNS name that maps to an address in 
that space with the single exception of "localhost" should be treated as 
a spammer.

If you only receive spam from the USA and Korea then consider yourself 
lucky. Your "solution" is simplistic beyond belief. Are you *sure* you 
know in advance all potential senders from the USA? I'm (currently) in 
the UK, but sending via a .com domain that operated through a server in 
the USA. Where am I "from".

I suspect your posting may have been a troll.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Skype: holdenweb   http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

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


Re: Fwd: Re: How to upgrade python from 2.4.3 to 2.4.4 ?

2006-10-22 Thread Steve Holden
Martin v. Löwis wrote:
> Kenneth Long schrieb:
> 
>>> Okay if one builds such from sources... but us poor
>>>Windows flunkies
>>>without a build environment have to wait for some
>>>kindly soul to build
>>>the installer compatible with the new Python
>>>version.
>>>
>>
>>especially since I havent got MS visual studio...
>>and mingw is not supported... :-(
> 
> 
> Why do you say that? mingw might just work fine
> (depending on particular details of the extension
> module in question).
> 
At the moment SourceForge is only listing one (UK) mirror for mingw, and 
that seems to be down. I'm guessing something is broken, since I know it 
used to be much more widely available.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Skype: holdenweb   http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

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


a question about MS Windows Clipboard to decrease cpu usage.

2006-10-22 Thread [EMAIL PROTECTED]
hello, I want to record the content of windows'clipboad,
after search c.l.p. I got some practical answer such as
http://groups.google.com/group/comp.lang.python/browse_thread/thread/57318b87e33e79b0/a7c5d5fcbd4eb58a
I have create my small script, it can get clipboard preliminary. but
now i had a trouble,
I use win32gui.PumpWaitingMessages() in while True: so the script use
9x% cpu. what should i do?
the code was post below.

##
import win32ui, win32clipboard, win32con, win32api, win32gui
def paste():
win32clipboard.OpenClipboard(0)
data = win32clipboard.GetClipboardData()
win32clipboard.CloseClipboard()
return data
class ClipRecord(object):
def __init__(self):
self.hPrev = 0
self.first   = True
self.win = win32ui.CreateFrame()
self.win.CreateWindow(None,'',win32con.WS_OVERLAPPEDWINDOW)

self.win.HookMessage(self.OnDrawClipboard,win32con.WM_DRAWCLIPBOARD)

self.win.HookMessage(self.OnChangeCBChain,win32con.WM_CHANGECBCHAIN)
self.win.HookMessage(self.OnDestroy,win32con.WM_DESTROY)
try:

self.hPrev=win32clipboard.SetClipboardViewer(self.win.GetSafeHwnd())
except win32api.error, err:
if win32api.GetLastError () == 0:
# information that there is no other window in chain
pass
else:
raise
while True:
win32gui.PumpWaitingMessages()
def OnChangeCBChain(self, *args):
msg, wParam, lParam = args[-1][1:4]
if self.hPrev == wParam:
   # repair the chain
   self.hPrev = lParam
if self.hPrev:
   # pass the message to the next window in chain
   win32api.SendMessage (self.hPrev, msg, wParam, lParam)
def OnDrawClipboard(self, *args):
msg, wParam, lParam = args[-1][1:4]
if self.first:
   self.first = False
else:
   print "clipboard content changed"
   print paste()
if self.hPrev:
   # pass the message to the next window in chain
   win32api.SendMessage (self.hPrev, msg, wParam, lParam)
def OnDestroy(self):
if self.hPrev:
win32clipboard.ChangeClipboardChain(self.win.GetSafeHwnd(),
self.hPrev)
else:
win32clipboard.ChangeClipboardChain(self.win.GetSafeHwnd(),
0)
if __name__ == "__main__":
cr = ClipRecord()

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


Re: How to upgrade python from 2.4.3 to 2.4.4 ?

2006-10-22 Thread Tony Meyer
> At the moment SourceForge is only listing one (UK) mirror for  
> mingw, and
> that seems to be down. I'm guessing something is broken, since I  
> know it
> used to be much more widely available.

Only one mirror (Kent) is available for any project.  It's been like  
this for nearly a day now, although the site status still hasn't  
changed from "online".  There are about 50 open tickets open about it  
(one would think that people that are able to find the sf.net tickets  
would be able to check for duplicates first...).

=Tony.Meyer

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


Re: A Comparison Of Dynamic and Static Languiges

2006-10-22 Thread Fredrik Lundh
Steve Holden wrote:

> Since network 127 is reserved in its entirety for loopback (local 
> process) use, it would seem that any DNS name that maps to an address in 
> that space with the single exception of "localhost" should be treated as 
> a spammer.

countries.nerd.dk is a DNS blackhole system that can be used to filter 
on originating country.  like most other DNSBL systems, it uses loopback 
addresses to return status codes (in this case, country codes).



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


Re: Attempting to parse free-form ANSI text.

2006-10-22 Thread Frederic Rentsch
Michael B. Trausch wrote:
> Alright... I am attempting to find a way to parse ANSI text from a
> telnet application.  However, I am experiencing a bit of trouble.
>
> What I want to do is have all ANSI sequences _removed_ from the output,
> save for those that manage color codes or text presentation (in short,
> the ones that are ESC[#m (with additional #s separated by ; characters).
>  The ones that are left, the ones that are the color codes, I want to
> act on, and remove from the text stream, and display the text.
>
> I am using wxPython's TextCtrl as output, so when I "get" an ANSI color
> control sequence, I want to basically turn it into a call to wxWidgets'
> TextCtrl.SetDefaultStyle method for the control, adding the appropriate
> color/brightness/italic/bold/etc. settings to the TextCtrl until the
> next ANSI code comes in to alter it.
>
> It would *seem* easy, but I cannot seem to wrap my mind around the idea.
>  :-/
>
> I have a source tarball up at http://fd0man.theunixplace.com/Tmud.tar
> which contains the code in question.  In short, the information is
> coming in over a TCP/IP socket that is traditionally connected to with a
> telnet client, so things can be broken mid-line (or even mid-control
> sequence).  If anyone has any ideas as to what I am doing, expecting, or
> assuming that is wrong, I would be delighted to hear it.  The code that
> is not behaving as I would expect it to is in src/AnsiTextCtrl.py, but I
> have included the entire project as it stands for completeness.
>
> Any help would be appreciated!  Thanks!
>
>   -- Mike
>   
*I have no experience with reading from TCP/IP. But looking at your 
program with a candid mind I'd say that it is written to process a chunk 
of data in memory. If, as you say, the chunks you get from TCP/IP may 
start and end anywhere and, presumably you pass each chunk through 
AppendText, then you have a synchronization problem, as each call resets 
your escape flag, even if the new chunk starts in the middle of an 
escape sequence. Perhaps you should cut off incomplete escapes at the 
end and prepend them to the next chunk.

And:

if(len(buffer) > 0):   
wx.TextCtrl.AppendText(self, buffer)  <<< Are you sure text goes 
into the same place as the controls?
   
if(len(AnsiBuffer) > 0):
wx.TextCtrl.AppendText(self, AnsiBuffer)  <<< You say you want to 
strip the control sequences


Frederic

*

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


Re: How to upgrade python from 2.4.3 to 2.4.4 ?

2006-10-22 Thread Steve Holden
Tony Meyer wrote:
>> At the moment SourceForge is only listing one (UK) mirror for  mingw, and
>> that seems to be down. I'm guessing something is broken, since I  know it
>> used to be much more widely available.
> 
> 
> Only one mirror (Kent) is available for any project.  It's been like  
> this for nearly a day now, although the site status still hasn't  
> changed from "online".  There are about 50 open tickets open about it  
> (one would think that people that are able to find the sf.net tickets  
> would be able to check for duplicates first...).
> 
I see. Well, now you know why the PSF has continued to migrate away from 
SourceForge. They are, at best, victims of their own success.

I found that a wget will, eventually, access the required files, albeit 
after several retries - I'd be pretty annoyed about this state of 
affairs if I were running the mirror at UKC.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Skype: holdenweb   http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A Comparison Of Dynamic and Static Languiges

2006-10-22 Thread Steve Holden
Fredrik Lundh wrote:
> Steve Holden wrote:
> 
> 
>>Since network 127 is reserved in its entirety for loopback (local 
>>process) use, it would seem that any DNS name that maps to an address in 
>>that space with the single exception of "localhost" should be treated as 
>>a spammer.
> 
> 
> countries.nerd.dk is a DNS blackhole system that can be used to filter 
> on originating country.  like most other DNSBL systems, it uses loopback 
> addresses to return status codes (in this case, country codes).
> 
(!)

Light goes on. Thanks.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Skype: holdenweb   http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

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


Re: Tkinter--does anyone use it for sophisticated GUI development?

2006-10-22 Thread bearophileHUGS
Peter Decker:
> Now that I've discovered Dabo, which wraps wxPython, hiding the C++
> ugliness under a very Pythonic API, I have the best of both worlds. I
> get to code naturally, and the results look great.

With some cleaning and improving, I think wax
(http://zephyrfalcon.org/labs/wax.html ) can become good too.

Bye,
bearophile

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


Re: A very nice free browser to try...

2006-10-22 Thread Ben Finney
[EMAIL PROTECTED] writes:

> There's a very nice browser

Please don't spam about products unrelated to Python here.

-- 
 \   "A celebrity is one who is known by many people he is glad he |
  `\   doesn't know."  -- Henry L. Mencken |
_o__)  |
Ben Finney

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


Re: ANN compiler2 : Produce bytecode from Python 2.5 Abstract Syntax Trees

2006-10-22 Thread Georg Brandl
Michael Spencer wrote:
> Announcing: compiler2
> -
> 
> For all you bytecode enthusiasts:  'compiler2' is an alternative to the 
> standard 
> library 'compiler' package, with several advantages.

Is this a rewrite from scratch, or an improved stdlib compiler package?

In the latter case, maybe you can contribute some patches to the core.

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


Re: Tkinter--does anyone use it for sophisticated GUI development?

2006-10-22 Thread Wektor

sturlamolden wrote:
> > Its also a pity that no one didnt do something based on OpenGL with
> > python (or maybe im wrong) it could be cool and really cross-platform.
>
> You are wrong. There are PyOpenGL and there is cross-platform GUI and
> game development platforms that use it (PyGTK, wxPython, PyGame). There
> are also PyOgre, which are more pythonic than using OpenGL directly.

I ment in the GUI context , a widget-based api where you can put
buttons, labels etc. on a form.
Not an advanced 3D stuff which is useless for such application.
Something like :
http://www.cs.unc.edu/~rademach/glui/
http://glow.sourceforge.net/
and sdl based
http://www.paragui.org/

but none have Python support (or again maybe im wrong)

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


Re: help with my first use of a class

2006-10-22 Thread bruno de chez modulix en face

Fulvio a écrit :

> ***
> Your mail has been scanned by InterScan MSS.
> ***
>
>
> On Saturday 21 October 2006 02:01, James Stroud wrote:
> > I think the trick is to identify when a class would make more sense than
> > a collection of subroutines
>
> I do believe that's a bit of forecasting, in sense to determine whether a
> piece of code may have a future.
> Usually in hobbistic term I think we can
> bear with copy&pasting pieces of code across programs rather than go for a
> class(es) module.

OO and reuse are two orthogonal concerns. You don't need OO to reuse
code, and OO is not so much about code reuse - even if it can improve
reusability - than about how to best structure your code.

To illustrate James' POV, if you end up with half a dozen functions
working on a same well-defined data structure,  then it might be time
to 'integrate' these functions and the data structure into a class.
Some other hints are when you have a small set of functions depending
on a common set of globals, or when you find yourself adding to your
functions signature too much additional params that are only meant to
be passed to other functions that themselves will pass them etc...

Copy-paste reuse should IMHO be limited to very trivial helper
functions that are not worth the pain of dependencies management...

My 2 cents

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


Re: question: script to input data into a webpage and then retrieve the result?

2006-10-22 Thread [EMAIL PROTECTED]
Christoph Haas 写道:

> On Sunday 22 October 2006 08:06, mxywp wrote:
> > Could someone help me with this or share an example script with me?
> >
> > Here is what I want to accomplish:
> > (1) input 3 values into 3 boxes on a web page
> > (2) there is an authentication code each time you access this page and I
> > have to write this code into the fourth box on the same page (3) click
> > "submit" button
> > (4) this web page will turn into a page with a table having a value
> > calculated from my inputs (5) extract this value into a local file
> > (6) repeat the above for 12000 times.
> >
> > I would really appreciate it if someone can tell me how to do it using
> > python script. I am new to python web programming.
>
> Dark side way:
>  http://www.idyll.org/~t/www-tools/twill.html
>

The main task is to constitute a correct URL.
e.g. the requested page is www.somepage.com,
first input form'id is input1, and respectively.

The request URL should be
'www.somepage.com?input1=value1&input2=value2',
post it and you'll get the response page .

Just do:

import urllib

value1=getValue1()
.
.
.

url='www.somepage.com?input1='+str(value1)+'&input2='+str(value2)
resp=urlopen(url)
parseResp(resp)

Problem: if the authentication code is an image, how to deal with it?

:)Sorry for my poor english.

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

Py 2.5: Bug in sgmllib

2006-10-22 Thread Michael Butscher
Hi,

if I execute the following two lines in Python 2.5 (to feed in a 
*unicode* string):

import sgmllib
sgmllib.SGMLParser().feed(u'')



I get the exception:

Traceback (most recent call last):
  File "", line 1, in 
sgmllib.SGMLParser().feed(u'')
  File "C:\Programme\Python25\Lib\sgmllib.py", line 99, in feed
self.goahead(0)
  File "C:\Programme\Python25\Lib\sgmllib.py", line 133, in goahead
k = self.parse_starttag(i)
  File "C:\Programme\Python25\Lib\sgmllib.py", line 285, in 
parse_starttag
self._convert_ref, attrvalue)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xdf in position 0: 
ordinal not in range(128)



The reason is that the character reference ß is converted to 
*byte* string "\xdf" by SGMLParser.convert_codepoint. Adding this byte 
string to the remaining unicode string fails.


Workaround (not thoroughly tested): Override convert_codepoint in a 
derived class with:

def convert_codepoint(self, codepoint):
return unichr(codepoint)



Is this a bug or is SGMLParser not meant to be used for unicode strings 
(it should be documented then)?



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


Re: Py 2.5: Bug in sgmllib

2006-10-22 Thread Fredrik Lundh
Michael Butscher wrote:


> if I execute the following two lines in Python 2.5 (to feed in a 
> *unicode* string):
> 
> import sgmllib
> sgmllib.SGMLParser().feed(u'')

source documents are encoded byte streams, not decoded Unicode 
sequences.  I suggest reading up on how Python's Unicode string
type is, and what a Unicode string represents.  it's not the same
thing as a byte string.



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


Python and CMS

2006-10-22 Thread Echo
I am going to start working on a church website. And since I like
python, I decided to use WSGI. However, I later found out about all
the different CMS's in php. So I wondered if there where any in
python.

Sadly, I only found Plone, skeletonz, and PyLucid (If there is any
more, please let me know). Of those three, only PyLucid supports WSGI
and it didn't look very nice to me.
Both Plone and skeletonz looked very nice. However, they can't be
hosted on a regular web host(at least to my knowledge) since they run
as the web server themselves. So hosting would cost more, at least 2-3
times more from what I've seen.

So I'm thinking of making a python CMS based on WSGI. I'm now trying
to figure out a few things like the best way to store the content and
how to manage/use plugins. For storing the content, the only ways I
know of are as files or in a database. But I'm not sure what would be
better. And as for how to do plugings, I plan on looking at Plone and
skeletonz.

As for working with WSGI, I have found
Colubrid(http://wsgiarea.pocoo.org/colubrid/) and
Paste(http://pythonpaste.org/). I was wondering if anyone knew of any
other libraries that make working with WSGI easier. Also, I wondering
if anyone would like to share their experiences of working with those.


ps. I know that this is a big and complicated project. But no matter
how far I get, it will be fun because its Python:)

-- 
"Now that I am a Christian I do not have moods in which the whole
thing looks very improbable: but when I was an atheist I had moods in
which Christianity looked terribly probable."
  -C. S. Lewis

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


Re: The fastest search

2006-10-22 Thread Fulvio
***
Your mail has been scanned by InterScan MSS.
***


On Saturday 21 October 2006 19:09, Steven D'Aprano wrote:

> So for searches that succeed, dicts are much faster than lists.

Very precious advice. Thank you, indeed. The lesson was good :-)

I'd only like to know if "List.index(vars)" has the same performance than
 "vars in List" or even it's the same thing.
But, so far I still have my own question about that the search goes on the 
key's name rather then its paired value. In fact, in my actual case the value 
doesn't make any use.
However the search goes on a few hundred email ID, the difference is less than 
a jiffy :-)

F


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


Re: Debugging

2006-10-22 Thread Fulvio
***
Your mail has been scanned by InterScan MSS.
***


On Saturday 21 October 2006 19:40, Gregor Horvath wrote:

> Small snippets of code are developed in the interpreter and when they
> are working assembled in the editor. If something goes wrong a print on
> the suspect place or the traceback is all I need. (of course this is
> matter of taste)

I also using this techinque, but I found myself to do a lot of rewriting on 
the code, as long as probing several points on the program.
The pdb.py is much of what I need. Running the program can stop in critical 
points and see if all comes as expected. It won't need to remove 
several "print" from the code.
Obvious, it's referred for programs which aren't time critical.

F

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


How to print a file in binary mode

2006-10-22 Thread Lucas
I need print a file in binary mode .

f = f.open('python.jpg','rb')
bytes = f.read()
f.close()

print(bytes)

I can't get any binary code.

how to do it?

Thank you very much!

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


Re: Py 2.5: Bug in sgmllib

2006-10-22 Thread Martin v. Löwis
Michael Butscher schrieb:
> Is this a bug or is SGMLParser not meant to be used for unicode strings 
> (it should be documented then)?

In a sense, SGML itself is not meant to be used for Unicode. In SGML,
the document character set is subject to the SGML application. So what
specific character a character reference refers to is also subject to
the SGML application.

This entire issue is already documented; see the discussion of
convert_charref and convert_codepoint in

http://docs.python.org/lib/module-sgmllib.html

Regards,
Martin
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to print a file in binary mode

2006-10-22 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Lucas wrote:

> I need print a file in binary mode .
> 
> f = f.open('python.jpg','rb')
> bytes = f.read()
> f.close()
> 
> print(bytes)
> 
> I can't get any binary code.

What do you mean by "binary code"?  If you use ``print repr(bytes)``
everything outside ASCII will be printed as escape sequence.

But why do you want to "print" JPEG images anyway?

Ciao,
Marc 'BlackJack' Rintsch

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


Re: Tkinter--does anyone use it for sophisticated GUI development?

2006-10-22 Thread Neil Cerutti
On 2006-10-22, Wektor <[EMAIL PROTECTED]> wrote:
> I ment in the GUI context , a widget-based api where you can put
> buttons, labels etc. on a form.
> Not an advanced 3D stuff which is useless for such application.
> Something like :
> and sdl based
> http://www.paragui.org/
>
> but none have Python support (or again maybe im wrong)

PyGame for SDL, I think.

-- 
Neil Cerutti

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


Re: Tkinter--does anyone use it for sophisticated GUI development?

2006-10-22 Thread Peter Decker
On 22 Oct 2006 02:40:17 -0700, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:

> With some cleaning and improving, I think wax
> (http://zephyrfalcon.org/labs/wax.html ) can become good too.

I looked at Wax, but the author doesn't seem to be too involved with
it. It looks like a cool idea that he developed far enough to make it
work, and then got bored with it. I mean hell, there isn't even a
workable grid class that does anything differently than the wxPython
grid does!

Dabo's implementation is already llight years ahead of Wax, despite
entering the game much later. When you've worked with lots of open
source projects, you can tell which are actively being developed and
which are dead or comatose; you can tell which have a growing
community and which are stagnant; you can tell which are worth
investing your time into learning and/or contributing to, and which
are dead-ends. Wax feels like a real dead-end to me.

-- 

# p.d.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Screen capture on Linux

2006-10-22 Thread Theerasak Photha
On 10/21/06, Grant Edwards <[EMAIL PROTECTED]> wrote:
> On 2006-10-21, Sai Krishna M <[EMAIL PROTECTED]> wrote:
> > On 10/21/06, Paolo Pantaleo <[EMAIL PROTECTED]> wrote:
> >> Hi,
> >>
> >> I need to capture a screen snapshot in Linux. PIL has a module
>
> ImageMagick has a command-line program named "import" that you
> might be able to use.

import -window root something.png

You can also try ksnapshot, gnome-panel-screenshor, shutterbug if you
have the FOX toolkit installed, or---ULCH---xwd as a last resort.

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


Re: How to print a file in binary mode

2006-10-22 Thread Lucas
thanks for your answer.

I known how to do it.
read() return a string. so
1) bytes = read(1) #read the file by bit.
2) chrString  = ord(bytes) #convert the string to ASCII.
3) print numberToBinary(chrString) #convert the ASCII to Binary using
my function.
4) Loop

I do it because I want to encrypt a string into a picture using RSA
algorithm.
so I first convert the string to binary,and then saving the binary into
picture

finally, print the picture by binary!

It is my coursework and studying PYTHON passingly : )

Marc 'BlackJack' Rintsch wrote:
> In <[EMAIL PROTECTED]>, Lucas wrote:
>
> > I need print a file in binary mode .
> >
> > f = f.open('python.jpg','rb')
> > bytes = f.read()
> > f.close()
> >
> > print(bytes)
> >
> > I can't get any binary code.
>
> What do you mean by "binary code"?  If you use ``print repr(bytes)``
> everything outside ASCII will be printed as escape sequence.
>
> But why do you want to "print" JPEG images anyway?
> 
> Ciao,
>   Marc 'BlackJack' Rintsch

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


Re: How to print a file in binary mode

2006-10-22 Thread Felipe Almeida Lessa
22 Oct 2006 06:33:50 -0700, Lucas <[EMAIL PROTECTED]>:
I known how to do it.read() return a string. so1) bytes = read(1) #read the file by bit.2) chrString  = ord(bytes) #convert the string to ASCII.3) print numberToBinary(chrString) #convert the ASCII to Binary using
my function.4) Loop[numberToBinary(ord(x)) for x in f.read()]    ?-- Felipe.
-- 
http://mail.python.org/mailman/listinfo/python-list

implementation of "in" that returns the object.

2006-10-22 Thread Jorge Vargas
Hi

I need to check if an object is in a list AND keep a reference to the
object I have done it this way but is there a better one?

>>> def inplusplus(value,listObj):
... for i in listObj:
... if i is value:
... return value
... return False
...
>>> l = [1,2,3,4]
>>> print inplusplus(2,l)
2
>>> print inplusplus(9,l)
False
>>> print inplusplus(1,l)
1
>>> l.append(0)
>>> print inplusplus(0,l)
0
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tkinter--does anyone use it for sophisticated GUI development?

2006-10-22 Thread sturlamolden

Wektor wrote:

> I ment in the GUI context , a widget-based api where you can put
> buttons, labels etc. on a form.

You mean GTK?

GTK 2.8 uses an abstraction layer for drawing widgets called "Cairo".
Cairo can use OpenGL or Quartz as backends (still experimental). Thus,
you can get a hardware-accelerated GUI from PyGTK if you are willing to
use an experimental backend in Cairo. 


http://cairographics.org/

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


Re: How to print a file in binary mode

2006-10-22 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Lucas wrote:

> thanks for your answer.
> 
> I known how to do it.
> read() return a string. so
> 1) bytes = read(1) #read the file by bit.

This reads a byte, not a bit.

> 2) chrString  = ord(bytes) #convert the string to ASCII.

Converts the byte into an integer with value of the byte.  This has
nothing to do with ASCII.

> 3) print numberToBinary(chrString) #convert the ASCII to Binary using
> my function.

You mean a binary representation i.e. a string that contains just 0s and
1s?

> 4) Loop

This is quite inefficient.  If the file is not too big it's better to load
it into memory completely.  And if you need the byte value of every single
byte you should read the file into an `array.array()` of type 'B'.

Ciao,
Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: implementation of "in" that returns the object.

2006-10-22 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Jorge Vargas
wrote:

> I need to check if an object is in a list AND keep a reference to the
> object I have done it this way but is there a better one?

But you already *have* a reference to that object!?

 def inplusplus(value,listObj):
> ... for i in listObj:
> ... if i is value:
> ... return value
> ... return False
> ...

def my_in(value, sequence):
if value in sequence:
return value
else:
return False

Ciao,
Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to print a file in binary mode

2006-10-22 Thread Fredrik Lundh
Lucas wrote:

> I do it because I want to encrypt a string into a picture using RSA
> algorithm.

what does "into" mean?  are you supposed to encrypt the binary data 
representing the JPEG image, or embed a message into the actual image?

 > so I first convert the string to binary,and then saving the binary
 > into picture

you seem to have a rather fuzzy understanding of the words "string" and 
"binary" here.  if you read from a file that's opened in binary mode, 
you get an 8-bit string that contains the binary data.  there's no need 
for any conversion here; just use the data you got from "read".

 > finally, print the picture by binary!

do you mean "save the picture to a binary file", or something else?



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


Re: implementation of "in" that returns the object.

2006-10-22 Thread Fredrik Lundh
Marc 'BlackJack' Rintsch wrote:

> def inplusplus(value,listObj):
>> ... for i in listObj:
>> ... if i is value:
>> ... return value
>> ... return False
>> ...
> 
> def my_in(value, sequence):
> if value in sequence:
> return value
> else:
> return False

however,

 >>> a = [1.0, 2, 3]

 >>> my_in(1, a)
1
 >>> my_in(2.0, a)
2.0
 >>> my_in(3L, a)
3L

so it all depends on what the OP means by "is in".



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


PSF Infrastructure has chosen Roundup as the issue tracker for Python development [repost]

2006-10-22 Thread [EMAIL PROTECTED]
[my initial post through python-list never seemed to reach c.l.py;
reposting]

At the beginning of the month the PSF Infrastructure committee
announced that we had reached the decision that JIRA was our
recommendation for the next issue tracker for Python development.
Realizing, though, that it was a tough call between JIRA and Roundup we
said that we would be willing to switch our recommendation to Roundup
if enough volunteers stepped forward to help administer the tracker,
thus negating Atlassian's offer of free managed hosting.

Well, the community stepped up to the challenge and we got plenty of
volunteers!  In fact, the call for volunteers has led to an offer for
professional hosting for Roundup from Upfront Systems.  The committee
is currently evaluating that offer and will hopefully have a decision
made soon.  Once a decision has been made we will contact the
volunteers as to whom we have selected to help administer the
installation (regardless of who hosts the tracker).  The administrators
and python-dev can then begin working towards deciding what we want
from the tracker and its configuration.

Once again, thanks to the volunteers for stepping forward to make this
happen!

-Brett Cannon
PSF Infrastructure committee chairman

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


Why I cannot Exit python shell ??

2006-10-22 Thread Jia Lu
Hi all.

  After using python shell (IDLE) for a while, I typed commands below
to exit . But error ocurred.

>>> raise SystemExit

Traceback (most recent call last):
  File "", line 1, in 
raise SystemExit
SystemExit
>>> sys.exit(0)

Traceback (most recent call last):
  File "", line 1, in 
sys.exit(0)
SystemExit: 0
>>> dir()
['__builtins__', '__doc__', '__name__', 'os', 'sys', 'time']

Why??

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


Re: Why I cannot Exit python shell ??

2006-10-22 Thread Fredrik Lundh
Jia Lu wrote:

>   After using python shell (IDLE) for a while, I typed commands below
> to exit . But error ocurred.
> 
 raise SystemExit
> 
> Traceback (most recent call last):
>   File "", line 1, in 
> raise SystemExit
> SystemExit
 sys.exit(0)
> 
> Traceback (most recent call last):
>   File "", line 1, in 
> sys.exit(0)
> SystemExit: 0
 dir()
> ['__builtins__', '__doc__', '__name__', 'os', 'sys', 'time']
> 
> Why??

because IDLE catches all exceptions, including SystemExit.  to quit 
IDLE, just type "quit()", or close the window.



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


Re: Screen capture on Linux

2006-10-22 Thread [EMAIL PROTECTED]
Paolo Pantaleo wrote:
> Hi,
>
> I need to capture a screen snapshot in Linux. PIL has a module
> IageGrab, but in the free version it only works under Windows. Is
> there any package to capture the screen on Linux?

xwd comes with the X server.  man xwd

Most useful is "xwd -root" or similar.  You may want "sleep 5; xwd
-root" to give you some time to set things up as needed, or map it to a
window manager keybinding.

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


Re: How to print a file in binary mode

2006-10-22 Thread Lucas
well,  if I just open the file in binary mode, and write a string,e.g
'660', how do i read the result? I means I need print the binary in
screen.

do these?

fileWrite = open('a.jpg',''ab')
fileWrite.write('660')
fileWrite.close()

fileRead = open('a.jpg','rb')
b = fileRead.read()
fileRead.close()
print b

???

Thanks again

Fredrik Lundh wrote:
> Lucas wrote:
>
> > I do it because I want to encrypt a string into a picture using RSA
> > algorithm.
>
> what does "into" mean?  are you supposed to encrypt the binary data
> representing the JPEG image, or embed a message into the actual image?
>
>  > so I first convert the string to binary,and then saving the binary
>  > into picture
>
> you seem to have a rather fuzzy understanding of the words "string" and
> "binary" here.  if you read from a file that's opened in binary mode,
> you get an 8-bit string that contains the binary data.  there's no need
> for any conversion here; just use the data you got from "read".
>
>  > finally, print the picture by binary!
>
> do you mean "save the picture to a binary file", or something else?
> 
> 

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


Re: Screen capture on Linux

2006-10-22 Thread Theerasak Photha
On 22 Oct 2006 09:06:53 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Paolo Pantaleo wrote:
> > Hi,
> >
> > I need to capture a screen snapshot in Linux. PIL has a module
> > IageGrab, but in the free version it only works under Windows. Is
> > there any package to capture the screen on Linux?
>
> xwd comes with the X server.  man xwd
>
> Most useful is "xwd -root" or similar.  You may want "sleep 5; xwd
> -root" to give you some time to set things up as needed, or map it to a
> window manager keybinding.

The problem with that is that xwd format is a non-standard format, and
*uncompressed* on top of that. If he wants to distribute the image to
friends, or whatever, he'll have to convert it to something like png
anyway. If he's using Linux, he probably doesn't need to use xwd
anyway and might as well save himself the effort (and HD space) now.

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


Re: How to print a file in binary mode

2006-10-22 Thread Fredrik Lundh
Lucas wrote:

> well,  if I just open the file in binary mode, and write a string,e.g
> '660', how do i read the result? I means I need print the binary in
> screen.

I'm afraid that the more you write, the less sense you make.

> do these?
> 
> fileWrite = open('a.jpg','ab')
> fileWrite.write('660')
> fileWrite.close()
> 
> fileRead = open('a.jpg','rb')
> b = fileRead.read()
> fileRead.close()
> print b

that prints three bytes, "6", "6", and "0":

 >>> fileWrite = open('a.jpg','ab')
 >>> fileWrite.write('660')
 >>> fileWrite.close()

 >>> fileRead = open('a.jpg','rb')
 >>> b = fileRead.read()
 >>> fileRead.close()
 >>> print b
660

what do you want it to print ?



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


Re: implementation of "in" that returns the object.

2006-10-22 Thread Paul McGuire
"Jorge Vargas" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Hi
>
> I need to check if an object is in a list AND keep a reference to the
> object I have done it this way but is there a better one?
>
 def inplusplus(value,listObj):
> ... for i in listObj:
> ... if i is value:
> ... return value
> ... return False
> ...
 l = [1,2,3,4]
 print inplusplus(2,l)
> 2
 print inplusplus(9,l)
> False
 print inplusplus(1,l)
> 1
 l.append(0)
 print inplusplus(0,l)
> 0

Just a couple of quick comments:
1. "if i is value" will check for identity, not equality.  Your example with 
small integers relies on a nonportable CPython implementation of using 
cached objects.  Check out this behavior:

>>> def inplusplus(value,listObj):
...   for i in listObj:
... if i is value:
...   return value
...   return False
...
>>> a = 5
>>> lst = [ 1,3,5,7 ]
>>> inplusplus(5,lst)
5
>>> inplusplus(a,lst)
5
>>> lst.append( 123456789 )
>>> inplusplus( 123456789,lst)
False

Instead of this loopy "is" test, just use "in":

>>> def inplusplus(value,listObj):
...   if value in listObj: return value
...   return False
...
>>> inplusplus( 123456789,lst)
123456789


2.  What happens if "False" is in the list?  How would you know?

-- Paul


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


Re: How to print a file in binary mode

2006-10-22 Thread Lucas
I am sorry my english is not good!

strList = ['1010010100','11101000100']

fileWrite = open('a.jpg','ab')
for item in strList:
   fileWrite.write(item)
fileWrite.close()
# I don't know whether or not I succeed

fileRead = open('a.jpg','rb')
b = fileRead.read()
fileRead.close()
print b
#it is wrong
# How can I display a.jpg's binary code?

Lucas wrote:
> well,  if I just open the file in binary mode, and write a string,e.g
> '660', how do i read the result? I means I need print the binary in
> screen.
>
> do these?
>
> fileWrite = open('a.jpg',''ab')
> fileWrite.write('660')
> fileWrite.close()
>
> fileRead = open('a.jpg','rb')
> b = fileRead.read()
> fileRead.close()
> print b
>
> ???
>
> Thanks again
>
> Fredrik Lundh wrote:
> > Lucas wrote:
> >
> > > I do it because I want to encrypt a string into a picture using RSA
> > > algorithm.
> >
> > what does "into" mean?  are you supposed to encrypt the binary data
> > representing the JPEG image, or embed a message into the actual image?
> >
> >  > so I first convert the string to binary,and then saving the binary
> >  > into picture
> >
> > you seem to have a rather fuzzy understanding of the words "string" and
> > "binary" here.  if you read from a file that's opened in binary mode,
> > you get an 8-bit string that contains the binary data.  there's no need
> > for any conversion here; just use the data you got from "read".
> >
> >  > finally, print the picture by binary!
> >
> > do you mean "save the picture to a binary file", or something else?
> > 
> > 

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


Re: PSF Infrastructure has chosen Roundup as the issue tracker for Python development

2006-10-22 Thread Kay Schluehr
Anna Ravenscroft wrote:

> Interestingly enough, the quote of the day from Google on this email was:
>
> Never doubt that a small group of thoughtful, committed citizens can
> change the world; indeed, it's the only thing that ever has.
> Margaret Mead

Commitment. Some individuals do the actual changes but others have to
commit to make these changes effective. I've no indication in human
history that groups are innovative or that they produce anything
compelling new. Sometimes they support ventilation or being busy with
"conservative innovation" or other oxymoronic activities. They serve a
critical function but are most of the time uncritical to themselves and
critical to everything and everyone else who is not using their own
code(s). Identifying the enemy is still the prime function of the
political and politics is all about groups. In this simple social
scheme the "hero" indicates the border. The hero acts outside of the
order of the group/society but the society uses the hero to indicate
its own interior in some kind of hegelian twist: the hero is the
otherness defining the self. The hero is the radical other supporting
the groups identify. At best the hero becomes the prince/souvereign of
the group and the group identifies itself as its knights. So the whole
truth about "changing the world" might be just slightly more complex.

Never thought having a small philosophical conversion with Margaret
Mead beyond time and space. So many thanks to great Google and its
devotees. 

Kay

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


[ANN] Movable IDLE 0.1.0

2006-10-22 Thread Fuzzyman
There is now an experimental version of **Movable IDLE** available,
this is an off-shoot of the `Movable Python
`_ project.

**Movable IDLE**, version 0.1.0 can be downloaded (free) from :

`Movable IDLE Download
`_

(Same place as the trial version of Movable Python.)

**Movable IDLE** is a portable distribution of IDLE, the Python IDE,
for Windows.

The homepage of Movable IDLE is :

   http://voidspace.org.uk/python/movpy/movableidle.html

This can be run without installing, and at only fifteen megabytes
uncompressed it can be run from a USB stick or memory card.

It comes with the full Python standard library, and should be capable
of running almost any program that can be run with IDLE. Hopefully this
will be useful for educational and experimental purposes.


Limitations


**Movable IDLE** does not have all the clever trickery that **Movable
Python** does. This means that the `win32
`_ extensions, or any program
that uses ``imp.find_module`` are unlikely to work. It also won't work
with programs that have another event loop, like other GUI toolkits.

If you need these features, try `Movable Python`_.

On the other hand, if you do find bugs or restrictions, post them to
the `Movable Python Mailing List
`_ and it may be possible to fix
them. This is the right place to post feedback and suggestions as well.


License
==

**Movable IDLE** is copyright *Michael Foord*, 2006. It is free, but
not Open Source.

You are free to copy and distribute **Movable IDLE**, but not to charge
for it. It may not be included in any distribution which charges
directly or indirectly, without express permission.

The following sections of the `Movable Python License
`_ also apply :

* *Disclaimer*
* *Limitations*
* *Restricted Uses*

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


Current stackdepth outside PyEval_EvalFrameEx

2006-10-22 Thread Fabiano Sidler
Hi folks!

I'm trying to implement a python function that returns the current stack
depth of its frame. Unfortunately, I don't see any possibility to get this
value outside of PyEval_EvalFrameEx. Inside of it, I'd use the STACK_LEVEL
macro. How do I do it?

Greetings,
Fips
-- 
http://mail.python.org/mailman/listinfo/python-list


Socket module bug on OpenVMS

2006-10-22 Thread Irmen de Jong
Hi,

Recently I was bitten by an apparent bug in the BSD socket layer
on Open VMS. Specifically, it appears that VMS defines MSG_WAITALL
in socket.h but does not implement it (it is not in the documentation).
And I use the socket.MSG_WAITALL flag on my recv() calls... and
then they crash on OpenVMS.

I don't have access to an OpenVMS machine myself so could someone
else that has (or has more knowledge of it) shed some light on it?



This also raises the question to what extent Python itself should
work around platform specific "peculiarities", such as this one.
There's another problem with socket code on Windows and VMS systems,
where you get strange exceptions when using a "too big" recv() buffer.

Things like this force me into writing all sorts of error checking
code or platform specific functions, to work around these bugs.
Just for what was supposed to be a simple socket recv() and a
simple socket send()...

In my opinion Python's socket module itself could implement these
workarounds. That would make user code a lot cleaner and less
error prone, and more portable. What do other people think?


Regards
--Irmen de Jong
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Socket module bug on OpenVMS

2006-10-22 Thread Jean-Paul Calderone
On Sun, 22 Oct 2006 19:00:22 +0200, Irmen de Jong <[EMAIL PROTECTED]> wrote:
>Hi,
>
>Recently I was bitten by an apparent bug in the BSD socket layer
>on Open VMS. Specifically, it appears that VMS defines MSG_WAITALL
>in socket.h but does not implement it (it is not in the documentation).
>And I use the socket.MSG_WAITALL flag on my recv() calls... and
>then they crash on OpenVMS.
>
>I don't have access to an OpenVMS machine myself so could someone
>else that has (or has more knowledge of it) shed some light on it?
>
>
>
>This also raises the question to what extent Python itself should
>work around platform specific "peculiarities", such as this one.
>There's another problem with socket code on Windows and VMS systems,
>where you get strange exceptions when using a "too big" recv() buffer.
>
>Things like this force me into writing all sorts of error checking
>code or platform specific functions, to work around these bugs.
>Just for what was supposed to be a simple socket recv() and a
>simple socket send()...
>
>In my opinion Python's socket module itself could implement these
>workarounds. That would make user code a lot cleaner and less
>error prone, and more portable. What do other people think?
>

I think everyone can agree that Python shouldn't crash.  It sounds like
the MSG_WAITALL check could be made somewhat more paranoid to detect the
behavior exhibited by OpenVMS.  Of course, in practice, this is weighed
against developer time and relevative popularity of various platforms.
How many people are using Python on OpenVMS?

Whether Python should propagate other kinds of errors from the underlying
platform is a harder question though.  At the lowest level interface, it
seems to me that it _should_ propagate them.  If there is a general way to
handle them, then a higher layer can be built on top of that lowest level
which does so.  Applications which are not interested in dealing with these
errors can use the higher-level interface (and it probably even makes sense
to recommend the high-level interface for most applications).  Python doesn't
always do a good job of keeping the high and low levels separate though, and
this seems like an area in which Python could stand some improvement.

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


Re: pylint: What's wrong with the builtin map()

2006-10-22 Thread Tuomas
Georg Brandl wrote:
> Some people think that all occurences of map() must be replaced
> by list comprehensions. The designer of pylint seems to be
> one of those.

So it seems, but why? Formally spoken we ase "using variable 'x' before 
assigment" in the comprehension too.

#!/usr/bin/python
"""test pydev_0.9.3/../pylint"""
__revision__ = "test_mod 0.2 by TV 06/10/22"

lst = ['aaa', ' bbb', '\tccc\n']
# lst = (lambda x: x.strip(), lst) # revision 0.1
lst = [x.strip() for x in lst]

result = """revision 0.1:
No config file found, using default configuration
* Module test_mod
W:  6: Used builtin function 'map'
E:  6: Using variable 'x' before assigment
...

revision 0.2:
...
Your code has been rated at 10.00/10 (previous run: -10.00/10)
"""
-- 
http://mail.python.org/mailman/listinfo/python-list


Altering the way exceptions print themselves

2006-10-22 Thread Irmen de Jong
Hello,

I want to alter the way exceptions print themselves.
More specifically, I'd like to extend the __str__ method of
the exception's class so that it is printed in a different way.

I used to replace the __str__ method on the exception object's
class by a custom method, but that breaks my code on Python 2.5
because of the following error I'm getting:

TypeError: can't set attributes of built-in/extension type 
'exceptions.TypeError'

Well, ok. So I tried to improve my code and not alter the class,
but only the exception object. I came up with this:



def __excStr__(self):
 return "[[[EXCEPTION! "+self.originalStr()+"]]"


... some code that raises an exception 'ex' 

import new
newStr = new.instancemethod( __excStr__, ex, ex.__class__)
ex.__str__=newStr


On Python 2.4 the above code works as I expect, however on Python 2.5
it doesn't seem to have any effect... What am I doing wrong?

Or is there perhaps a different way to do what I want?


Thanks!
--Irmen de Jong


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


Re: Socket module bug on OpenVMS

2006-10-22 Thread Irmen de Jong
Jean-Paul Calderone wrote:
> I think everyone can agree that Python shouldn't crash.

Well, it doesn't really crash in a bad way, in my example:
it doesn't work because it simply raises a socket exception all the time.

> Whether Python should propagate other kinds of errors from the underlying
> platform is a harder question though.  At the lowest level interface, it
> seems to me that it _should_ propagate them.  If there is a general way to
> handle them, then a higher layer can be built on top of that lowest level
> which does so.

We already have a low-level "_socket" module (builtin) and a higher level
"socket" module (implemented in python in the std lib)...
I could imagine that the "socket" module would offer methods that can deal
with platform bugs such as the two I mentioned in my original posting.

I have never used _socket directly by the way (and don't think anyone
else ever did?)


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


Re: Socket module bug on OpenVMS

2006-10-22 Thread Jean-Paul Calderone
On Sun, 22 Oct 2006 19:58:44 +0200, Irmen de Jong <[EMAIL PROTECTED]> wrote:
>Jean-Paul Calderone wrote:
>> I think everyone can agree that Python shouldn't crash.
>
>Well, it doesn't really crash in a bad way, in my example:
>it doesn't work because it simply raises a socket exception all the time.

Okay.  I assumed you meant the interpreter died with a SIGSEGV or something
similar.  If the call simply raises an exception, then I'm not sure I see
a real problem here.

>
>> Whether Python should propagate other kinds of errors from the underlying
>> platform is a harder question though.  At the lowest level interface, it
>> seems to me that it _should_ propagate them.  If there is a general way to
>> handle them, then a higher layer can be built on top of that lowest level
>> which does so.
>
>We already have a low-level "_socket" module (builtin) and a higher level
>"socket" module (implemented in python in the std lib)...
>I could imagine that the "socket" module would offer methods that can deal
>with platform bugs such as the two I mentioned in my original posting.
>
>I have never used _socket directly by the way (and don't think anyone
>else ever did?)

The _ prefix indicates the module is private: you aren't *supposed* to use
_socket.  This may help internal factoring, but it's not useful for anyone
writing code that's not part of the standard library.  For the separation
I'm talking about to be useful, all layers need to be made available to
developers of third-party libraries.

What'd be really nice is a direct wrapper around recv(2), send(2), etc,
with a simple socket-object layer on top of that, with timeouts or error
handling layered on top of that.

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


Re: pylint: What's wrong with the builtin map()

2006-10-22 Thread Georg Brandl
Tuomas wrote:
> #!/usr/bin/python
> """test pydev_0.9.3/../pylint"""
> __revision__ = "test_mod 0.1 by TV 06/10/22"
> 
> lst = ['aaa', ' bbb', '\tccc\n']
> lst = map(lambda x: x.strip(), lst)
> 
> result = """
> No config file found, using default configuration
> * Module test_mod
> W:  6: Used builtin function 'map'
> E:  6: Using variable 'x' before assigment

Some people think that all occurences of map() must be replaced
by list comprehensions. The designer of pylint seems to be
one of those.

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


Re: Socket module bug on OpenVMS

2006-10-22 Thread Jean-François Piéronne
> Hi,
> 
> Recently I was bitten by an apparent bug in the BSD socket layer
> on Open VMS. Specifically, it appears that VMS defines MSG_WAITALL
> in socket.h but does not implement it (it is not in the documentation).
> And I use the socket.MSG_WAITALL flag on my recv() calls... and
> then they crash on OpenVMS.
>
Which Python version, OpenVMS version, IP stack and stack version?

If you think this is a Python on OpenVMS problem, send me a small
reproduced anf I will take a look.

If you think it's a OpenVMS problem and if you can provide a simple
reproducer and have a support contract I suggest you call HP, but I
suspect that if it's not documented the reply would be not (yet?) supported.



> I don't have access to an OpenVMS machine myself so could someone
> else that has (or has more knowledge of it) shed some light on it?
> 
>

It appear that the only place, in the Python source code, where
MSG_WAITALL is used is in socketmodule.c:
#ifdef  MSG_WAITALL
PyModule_AddIntConstant(m, "MSG_WAITALL", MSG_WAITALL);
#endif

May be a workaround is to not use MSG_WAITALL (currently) on OpenVMS and
in next version I will not defined MSG_WAITALL in the socket module on
OpenVMS.

If you need an access to an OpenVMS let me know.

> 
> This also raises the question to what extent Python itself should
> work around platform specific "peculiarities", such as this one.
> There's another problem with socket code on Windows and VMS systems,
> where you get strange exceptions when using a "too big" recv() buffer.
> 

Old Python version on OpenVMS have bugs in the socket module which have
been fixed in newer version. Be sure to check using the latest kit.

> Things like this force me into writing all sorts of error checking
> code or platform specific functions, to work around these bugs.
> Just for what was supposed to be a simple socket recv() and a
> simple socket send()...
> 
> In my opinion Python's socket module itself could implement these
> workarounds. That would make user code a lot cleaner and less
> error prone, and more portable. What do other people think?
> 
> 
> Regards
> --Irmen de Jong

Jean-Francois Pieronne
-- 
http://mail.python.org/mailman/listinfo/python-list


pylint: What's wrong with the builtin map()

2006-10-22 Thread Tuomas
#!/usr/bin/python
"""test pydev_0.9.3/../pylint"""
__revision__ = "test_mod 0.1 by TV 06/10/22"

lst = ['aaa', ' bbb', '\tccc\n']
lst = map(lambda x: x.strip(), lst)

result = """
No config file found, using default configuration
* Module test_mod
W:  6: Used builtin function 'map'
E:  6: Using variable 'x' before assigment
...
"""
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ElementSOAP tutorial / HTTPClient

2006-10-22 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote:

> 2) how should I have constructed my searches when attempting to resolve
> this issue such that I wouldn't have had to post this question?

maybe reading the highlighted "Note" at the top of each page in that 
article series could have helped?

 "Note: A distribution kit containing the source code for this
 article is available from the effbot.org downloads site (look
 for elementsoap)."



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


Re: How to print a file in binary mode

2006-10-22 Thread Fredrik Lundh
Lucas wrote:

> # How can I display a.jpg's binary code?

looks like you're confusing binary numbers with binary files:

http://en.wikipedia.org/wiki/Binary_numeral_system
http://en.wikipedia.org/wiki/Binary_file

you don't really need the former to encrypt the contents of the file; 
algorithms tend to work just fine no matter what number system you use 
to represent the input and output data.



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


Re: PSF Infrastructure has chosen Roundup as the issue tracker for Python development

2006-10-22 Thread Ron Adam
Kay Schluehr wrote:
> Anna Ravenscroft wrote:
> 
>> Interestingly enough, the quote of the day from Google on this email was:
>>
>> Never doubt that a small group of thoughtful, committed citizens can
>> change the world; indeed, it's the only thing that ever has.
>> Margaret Mead
> 
> Commitment. Some individuals do the actual changes but others have to
> commit to make these changes effective. I've no indication in human
> history that groups are innovative or that they produce anything
> compelling new. Sometimes they support ventilation or being busy with
> "conservative innovation" or other oxymoronic activities. They serve a
> critical function but are most of the time uncritical to themselves and
> critical to everything and everyone else who is not using their own
> code(s). Identifying the enemy is still the prime function of the
> political and politics is all about groups. In this simple social
> scheme the "hero" indicates the border. The hero acts outside of the
> order of the group/society but the society uses the hero to indicate
> its own interior in some kind of hegelian twist: the hero is the
> otherness defining the self. The hero is the radical other supporting
> the groups identify. At best the hero becomes the prince/souvereign of
> the group and the group identifies itself as its knights. So the whole
> truth about "changing the world" might be just slightly more complex.

Committees often do fit this description.

Of course, this is a subject that is very dependent on viewpoints.

The world changes.  Sometimes those changes are the result of certain events 
where groups of people were present.  Sometimes individuals in the group had a 
significant effect on the outcome of those events.  Sometimes the individuals 
were committed to a common purpose.  Sometimes they were aided by sharing 
information and effort to achieve that purpose.  Sometimes the outcome was one 
that is very unlikely or impossible for a single individual to have produced.

It is this last point that is important.

Sometimes groups are formed with the desire of reproducing this last point.

Sometimes they succeed.


There is also the view point of informal groups of individuals working 
separately but having a significant combined effect.  This is probably the more 
common situation.

But not as common as the viewpoint you've stated above unfortunately.

Cheers,
   Ron



> Never thought having a small philosophical conversion with Margaret
> Mead beyond time and space. So many thanks to great Google and its
> devotees. 
> 
> Kay

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


Problems trying to override __str__ on path class

2006-10-22 Thread Mike Krell
I'm running into problems trying to override __str__ on the path class 
from Jason Orendorff's path module 
(http://www.jorendorff.com/articles/python/path/src/path.py).

My first attempt to do this was as follows:

'''
class NormPath(path):
def __str__(self):
return 'overridden __str__: ' + path.__str__(self.normpath())
'''

The problem is that the override is not invoked unless str() is called 
explictly, as indicated by the test program and its output below:

'''
from normpath import NormPath
np = NormPath('c:/mbk/test')
print 'np: "%s"' % np
print 'str(np): "%s"' % str(np)
print np / 'appendtest'


np: "c:/mbk/test"
str(np): "overridden __str__: c:\mbk\test"
c:/mbk/test\appendtest
'''

I suspect that the problem has to do with the base class of the path 
class being unicode because it works when I create dummy classes derived 
off of object.

My next attempt was to try delegation as follows:

'''
class NormPath(object):
def __init__(self, *a, **k):
self._path = path(*a, **k)

def __str__(self):
return 'overridden __str__: ' + str(self._path.normpath())

def __getattr__(self, attr):
print 'delegating %s...' % attr
return getattr(self._path, attr)
'''

In this case the test program blows up with a TypeError when trying to 
invoke the / operator:

'''
np: "overridden __str__: c:\mbk\test"
str(np): "overridden __str__: c:\mbk\test"
-
exceptions.TypeError Traceback (most 
recent call last)

e:\projects\Python\vc\nptest.py
  1 from normpath import NormPath
  2 np=NormPath('c:/mbk/test')
  3 print 'np: "%s"' % np
  4 print 'str(np): "%s"' % str(np)
> 5 print np / 'appendtest'

TypeError: unsupported operand type(s) for /: 'NormPath' and 'str'
WARNING: Failure executing file: 
'''

Can someone explain these failures to me?  Also, assuming I don't want to 
modify path.py itself, is there any way to do what I'm trying to 
accomplish?  BTW, I'm running 2.4.2 under Windows.

Thanks in advance,
   Mike
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pylint: What's wrong with the builtin map()

2006-10-22 Thread Fredrik Lundh
Tuomas wrote:

 > lst = map(lambda x: x.strip(), lst)

list comprehensions are more efficient than map/lambda combinations;
the above is better written as:

lst = [x.strip() for x in lst]

in general, map() works best when the callable is an existing function 
(especially if it's a built-in).  not sure if pylist is smart enough to 
tell the difference, though.



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


Re: pylint: What's wrong with the builtin map()

2006-10-22 Thread Georg Brandl
Tuomas wrote:
> Georg Brandl wrote:
>> Some people think that all occurences of map() must be replaced
>> by list comprehensions. The designer of pylint seems to be
>> one of those.
> 
> So it seems, but why?

See Fredrik's post. There's no error in the expression with map(),
it's just less effective than a LC, but only if used with a
lambda.

> Formally spoken we ase "using variable 'x' before 
> assigment" in the comprehension too.

That's another issue. I'd suggest a bug in pylint. (You probably
have a variable called "x" later in the file.

My version of pylint (0.12.1) doesn't show this "error".

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


Re: Problems trying to override __str__ on path class

2006-10-22 Thread Peter Otten
Mike Krell wrote:

> I'm running into problems trying to override __str__ on the path class
> from Jason Orendorff's path module
> (http://www.jorendorff.com/articles/python/path/src/path.py).
> 
> My first attempt to do this was as follows:
> 
> '''
> class NormPath(path):
> def __str__(self):
> return 'overridden __str__: ' + path.__str__(self.normpath())
> '''
> 
> The problem is that the override is not invoked unless str() is called
> explictly, as indicated by the test program and its output below:
> 
> '''
> from normpath import NormPath
> np = NormPath('c:/mbk/test')
> print 'np: "%s"' % np
> print 'str(np): "%s"' % str(np)
> print np / 'appendtest'
> 
> 
> np: "c:/mbk/test"
> str(np): "overridden __str__: c:\mbk\test"
> c:/mbk/test\appendtest
> '''

With

from path import path

class NormPath(path):
def __str__(self):
return 'overridden __str__: ' + path.__str__(self.normpath())

np = NormPath('c:/mbk/test')
print 'np: "%s"' % np
print 'str(np): "%s"' % str(np)
print np / 'appendtest'

I get

np: "overridden __str__: c:/mbk/test"
str(np): "overridden __str__: c:/mbk/test"
overridden __str__: overridden __str__: c:/mbk/test/appendtest

Are you using the latest version of the path module? Older versions implied
a Path() call in the __div__() operator which would explain at least the
output you get for

print np / 'appendtest'

Peter



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


Re: Socket module bug on OpenVMS

2006-10-22 Thread Irmen de Jong
Jean-François Piéronne wrote:

> Which Python version, OpenVMS version, IP stack and stack version?

OpenVMS 7.3-2, Python 2.3.5, no idea about IP stack version.

> If you think this is a Python on OpenVMS problem, send me a small
> reproduced anf I will take a look.

I don't have any small case lying around (I can't reproduce it myself
because I lack access to an openVMS machine) but I think you should
be able to reproduce it by slightly altering one of the socket examples
that comes with Python. Just add the MSG_WAITALL to the recv() call:

something = sock.recv(somesize, socket.MSG_WAITALL)

and you should see it crash with a socket exception.

Mail me offline if you still need running example code (that I think
would expose the problem).

> If you think it's a OpenVMS problem and if you can provide a simple
> reproducer and have a support contract I suggest you call HP, but I
> suspect that if it's not documented the reply would be not (yet?) supported.

I don't have anything to do with HP... the person that reported the
problem to me has, however. He's already aware of the problem.

> May be a workaround is to not use MSG_WAITALL (currently) on OpenVMS and
> in next version I will not defined MSG_WAITALL in the socket module on
> OpenVMS.

How can I detect that I'm running on OpenVMS?


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


Re: print dos format file into unix format

2006-10-22 Thread Simon Forman
[EMAIL PROTECTED] wrote:
> Suppose I have a dos format text file. The following python code will
> print ^M at the end. I'm wondering how to print it in unix format.
>
> fh = open(options.filename)
> for line in fh.readlines()
>   print line,
>
> Thanks,
> Peng

Python ships with two utility scripts, crlf.py and lfcr.py, that
"Replace CRLF with LF in argument files" and "Replace LF with CRLF in
argument files", respectively.

Look in examples/Tools/scripts of your python dist.

Even if you don't want to use the scripts, you can read them for
insight.

Peace,
~Simon

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


Re: Socket module bug on OpenVMS

2006-10-22 Thread Jean-François Piéronne
Irmen de Jong a écrit :
> Jean-François Piéronne wrote:
> 
>> Which Python version, OpenVMS version, IP stack and stack version?
> 
> OpenVMS 7.3-2, Python 2.3.5, no idea about IP stack version.
> 
Thanks, may be upgrade to Python 2.5 will solve the problem.

>> If you think this is a Python on OpenVMS problem, send me a small
>> reproduced anf I will take a look.
> 
> I don't have any small case lying around (I can't reproduce it myself
> because I lack access to an openVMS machine) but I think you should
> be able to reproduce it by slightly altering one of the socket examples
> that comes with Python. Just add the MSG_WAITALL to the recv() call:
> 
> something = sock.recv(somesize, socket.MSG_WAITALL)
> 
> and you should see it crash with a socket exception.
> 
Ok, I will try.

> Mail me offline if you still need running example code (that I think
> would expose the problem).
> 

Ok

>> If you think it's a OpenVMS problem and if you can provide a simple
>> reproducer and have a support contract I suggest you call HP, but I
>> suspect that if it's not documented the reply would be not (yet?)
>> supported.
> 
> I don't have anything to do with HP... the person that reported the
> problem to me has, however. He's already aware of the problem.
> 

You or the other person can also try to use

http://forums1.itrc.hp.com/service/forums/familyhome.do?familyId=288


>> May be a workaround is to not use MSG_WAITALL (currently) on OpenVMS and
>> in next version I will not defined MSG_WAITALL in the socket module on
>> OpenVMS.
> 
> How can I detect that I'm running on OpenVMS?
> 
>
for example

import sys
print sys.platform
'OpenVMS'


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


ElementSOAP tutorial / HTTPClient

2006-10-22 Thread mirandacascade
Operating system: Windows XP Home
Version of Python: 2.4

While looking through the tutorial on ElementSOAP at the following
link:

http://effbot.org/zone/element-soap.htm

I observed sample code that included:

from HTTPClient import HTTPClient

When I get into Pythonwin and attempt the import statement above:

>>> from HTTPClient import HTTPClient
Traceback (most recent call last):
  File "", line 1, in ?
ImportError: No module named HTTPClient

In addition:
1) a case-insensitive search for any files with 'HTTPClient' where the
search begins in the c:\python24\ and includes all sub-folders results
in a: "Search is complete. There are not results to dsiplay." message
2) a search of this Google group for HTTPClient didn't result in any
links that appeared to point me to where I could find a package that
includes HTTPClient
3) a search in the python.org home page for HTTPClient didn't result in
any links that appeared to point me to where I could find a package
that includes HTTPClient

I noticed that there is a file httplib.py in which the docstring begins
"HTTP/1.1 client library", but I couldn't figure out whether what was
in httplib.py replaced HTTPClient.py, and if so, how.

So, my questions are:
1) is there a package available which, when installed, will allow the

from HTTPClient import HTTPClient

statement to execute without ImportError?

2) how should I have constructed my searches when attempting to resolve
this issue such that I wouldn't have had to post this question?

Thank you.

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


Re: Python and CMS

2006-10-22 Thread johnzenger
For a free out of the box solution, look at MoinMoin.  It is wiki
software, but nothing stops you from turning off user signups, locking
down the whole site, and just using it as a CMS.  It's very easy to set
up, can run as a CGI, and requires no database backend.

Echo wrote:
> I am going to start working on a church website. And since I like
> python, I decided to use WSGI. However, I later found out about all
> the different CMS's in php. So I wondered if there where any in
> python.
>
> Sadly, I only found Plone, skeletonz, and PyLucid (If there is any
> more, please let me know). Of those three, only PyLucid supports WSGI
> and it didn't look very nice to me.
> Both Plone and skeletonz looked very nice. However, they can't be
> hosted on a regular web host(at least to my knowledge) since they run
> as the web server themselves. So hosting would cost more, at least 2-3
> times more from what I've seen.
>
> So I'm thinking of making a python CMS based on WSGI. I'm now trying
> to figure out a few things like the best way to store the content and
> how to manage/use plugins. For storing the content, the only ways I
> know of are as files or in a database. But I'm not sure what would be
> better. And as for how to do plugings, I plan on looking at Plone and
> skeletonz.
>
> As for working with WSGI, I have found
> Colubrid(http://wsgiarea.pocoo.org/colubrid/) and
> Paste(http://pythonpaste.org/). I was wondering if anyone knew of any
> other libraries that make working with WSGI easier. Also, I wondering
> if anyone would like to share their experiences of working with those.
>
>
> ps. I know that this is a big and complicated project. But no matter
> how far I get, it will be fun because its Python:)
>
> --
> "Now that I am a Christian I do not have moods in which the whole
> thing looks very improbable: but when I was an atheist I had moods in
> which Christianity looked terribly probable."
>   -C. S. Lewis
> 
> -Echo

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


Re: Altering the way exceptions print themselves

2006-10-22 Thread Peter Otten
Irmen de Jong wrote:

> I want to alter the way exceptions print themselves.
> More specifically, I'd like to extend the __str__ method of
> the exception's class so that it is printed in a different way.
> 
> I used to replace the __str__ method on the exception object's
> class by a custom method, but that breaks my code on Python 2.5
> because of the following error I'm getting:
> 
> TypeError: can't set attributes of built-in/extension type
> 'exceptions.TypeError'
> 
> Well, ok. So I tried to improve my code and not alter the class,
> but only the exception object. I came up with this:
> 
> 
> 
> def __excStr__(self):
>  return "[[[EXCEPTION! "+self.originalStr()+"]]"
> 
> 
> ... some code that raises an exception 'ex' 
> 
> import new
> newStr = new.instancemethod( __excStr__, ex, ex.__class__)
> ex.__str__=newStr
> 
> 
> On Python 2.4 the above code works as I expect, however on Python 2.5
> it doesn't seem to have any effect... What am I doing wrong?

Nothing. That's just a chain of bad luck. As exceptions have become newstyle
classes __xxx__() special methods aren't looked up in the instance anymore.
 
> Or is there perhaps a different way to do what I want?

Does it suffice to set the excepthook? If so, you might want something less
hackish than

class wrap_exc(object):
def __init__(self, exception):
self.__exception = exception
def __getattr__(self, name):
return getattr(self.__exception, name)
def __str__(self):
return "yadda"

def eh(etype, exception, tb):
eh_orig(etype, wrap_exc(exception), tb)

eh_orig = sys.excepthook

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


Scrolling On IDLE

2006-10-22 Thread Julio Ng
Hello,

I am using the IDLE (v1.2) for Mac OS X, and realized that scrolling  
with the mouse doesn't work. Do I need to configure anything to  
enable that feature?

Thanks,

Julio

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


Re: Python and CMS

2006-10-22 Thread Kjell Magne Fauske
I recommend taking a look at Django [1]. It is not a CMS right out of
the box, but writing one using the Django framework is not that
difficult.

[1] http://www.djangoproject.com/

- Kjell Magne Fauske

Echo wrote:
> I am going to start working on a church website. And since I like
> python, I decided to use WSGI. However, I later found out about all
> the different CMS's in php. So I wondered if there where any in
> python.
>
> Sadly, I only found Plone, skeletonz, and PyLucid (If there is any
> more, please let me know). Of those three, only PyLucid supports WSGI
> and it didn't look very nice to me.
> Both Plone and skeletonz looked very nice. However, they can't be
> hosted on a regular web host(at least to my knowledge) since they run
> as the web server themselves. So hosting would cost more, at least 2-3
> times more from what I've seen.
>
> So I'm thinking of making a python CMS based on WSGI. I'm now trying
> to figure out a few things like the best way to store the content and
> how to manage/use plugins. For storing the content, the only ways I
> know of are as files or in a database. But I'm not sure what would be
> better. And as for how to do plugings, I plan on looking at Plone and
> skeletonz.
>
> As for working with WSGI, I have found
> Colubrid(http://wsgiarea.pocoo.org/colubrid/) and
> Paste(http://pythonpaste.org/). I was wondering if anyone knew of any
> other libraries that make working with WSGI easier. Also, I wondering
> if anyone would like to share their experiences of working with those.
>
>
> ps. I know that this is a big and complicated project. But no matter
> how far I get, it will be fun because its Python:)
>
> --
> "Now that I am a Christian I do not have moods in which the whole
> thing looks very improbable: but when I was an atheist I had moods in
> which Christianity looked terribly probable."
>   -C. S. Lewis
> 
> -Echo

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


Re: Python and CMS

2006-10-22 Thread Duncan Booth
Echo <[EMAIL PROTECTED]> wrote:

> Sadly, I only found Plone, skeletonz, and PyLucid (If there is any
> more, please let me know). Of those three, only PyLucid supports WSGI
> and it didn't look very nice to me.
> Both Plone and skeletonz looked very nice. However, they can't be
> hosted on a regular web host(at least to my knowledge) since they run
> as the web server themselves. So hosting would cost more, at least 2-3
> times more from what I've seen.
> 
Just because something like Plone can run as a web server doesn't mean that 
you expose that web server to the outside world, nor do you have to run it 
as a webserver at all. Normally you run Plone behind another web server 
such as Apache.

You can get Plone on shared hosting from various places. I use webfaction 
(www.webfaction.com).
-- 
http://mail.python.org/mailman/listinfo/python-list


sending vim text through Python filter

2006-10-22 Thread BartlebyScrivener
Hello,

I'm sure this is my fault or some Windows snafu. But using gvim 7.0 on
Windows XP, I can't seem to get gvim to successfully filter text
through a Python script. I also use NoteTab and have no problems
running text from NoteTab through the same Python script.

Any vimmers help with this?

I'm sending standard text with the vim command :%!sort.py

The Python script (sort.py) is:

from sys import stdin
input = stdin.read().split('\n')
input.sort()
print '\n'.join(input)

I get:

Traceback (most recent call last):
  File "d:\python\sort.py", line 2, in ?
input = stdin.read().split('\n')
IOError: [Errno 9] Bad file descriptor

Thanks,

rd

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


Re: Python and CMS

2006-10-22 Thread Bruno Desthuilliers
Echo a écrit :
(snip)
> As for working with WSGI, I have found
> Colubrid(http://wsgiarea.pocoo.org/colubrid/) and
> Paste(http://pythonpaste.org/). I was wondering if anyone knew of any
> other libraries that make working with WSGI easier. 

Pylons (www.pylonshq.com). It's a rail-like framework based on Paste.

(snip)
> ps. I know that this is a big and complicated project. 

Really ? Why so ?

Writing a configurable, extensible, general purpose can be a "big and 
complicated project". But writing a "taylor-made", specific one is not 
that difficult.

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


Re: Tkinter--does anyone use it for sophisticated GUI development?

2006-10-22 Thread alex23
Peter Decker wrote:
> When you've worked with lots of open
> source projects, you can tell which are actively being developed and
> which are dead or comatose; you can tell which have a growing
> community and which are stagnant; you can tell which are worth
> investing your time into learning and/or contributing to, and which
> are dead-ends. Wax feels like a real dead-end to me.

Can you also tell when you're wrong?

I checked out Wax last week for the first time; I hit a snag and got an
answer from the lead developer within a day, along with a pointer to
the latest dev version.

But don't let communication get in the way of that six sense you've got
going there :)

- alex23

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


Re: Is x.f() <==>MyClass.f(x) a kind of algebraic structure?

2006-10-22 Thread Simon Forman
steve wrote:
> I thought that when read Guido van Rossum' Python tutorial.What can we
> think that?

What?

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


Re: Socket module bug on OpenVMS

2006-10-22 Thread Irmen de Jong
Jean-Paul Calderone wrote:
> On Sun, 22 Oct 2006 19:58:44 +0200, Irmen de Jong 
> <[EMAIL PROTECTED]> wrote:
>> Jean-Paul Calderone wrote:
>>> I think everyone can agree that Python shouldn't crash.
>>
>> Well, it doesn't really crash in a bad way, in my example:
>> it doesn't work because it simply raises a socket exception all the time.
> 
> Okay.  I assumed you meant the interpreter died with a SIGSEGV or something
> similar.  If the call simply raises an exception, then I'm not sure I see
> a real problem here.

Hmm.. it is not supposed to raise the exception (the code is valid but
just breaks on windows or VMS). On the other hand, the underlying platform
goes bad and what else could Python do? (at this point)



> What'd be really nice is a direct wrapper around recv(2), send(2), etc,
> with a simple socket-object layer on top of that, with timeouts or error
> handling layered on top of that.

I agree, that would be nice indeed.

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


Re: Customize the effect of enumerate()?

2006-10-22 Thread Simon Forman
Dustan wrote:
> Can I make enumerate(myObject) act differently?
>
> class A(object):
>   def __getitem__(self, item):
>   if item > 0:
>   return self.sequence[item-1]
>   elif item < 0:
>   return self.sequence[item]
>   elif item == 0:
>   raise IndexError, "Index 0 is not valid."
>   else:
>   raise IndexError, "Invalid Index."
>   def __iter__(self): return iter(self.sequence)

That final else clause is a little funny...What kind of indices are
you expecting that will be neither less than zero, greater than zero,
or equal to zero?

> Why the funny behavior, you ask? For my class A, it doesn't make sense
> to number everything the standard programming way. Of course, if
> someone uses enumerate, it's going to number the items the same way as
> ever. Is there any way to modify that behavior, any special function to
> set? There doesn't appear to be, according to the docs, but it never
> hurts to make sure.

You can write your own enumerate function and then bind that to the
name 'enumerate'.

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


Re: pylint: What's wrong with the builtin map()

2006-10-22 Thread Robert Kern
Tuomas wrote:
> #!/usr/bin/python
> """test pydev_0.9.3/../pylint"""
> __revision__ = "test_mod 0.1 by TV 06/10/22"
> 
> lst = ['aaa', ' bbb', '\tccc\n']
> lst = map(lambda x: x.strip(), lst)
> 
> result = """
> No config file found, using default configuration
> * Module test_mod
> W:  6: Used builtin function 'map'
> E:  6: Using variable 'x' before assigment
> ...
> """

In addition to what the others said, note that pylint is entirely configurable. 
If you don't want to be bothered with warnings about map() which you are going 
to ignore, a simple modification to the pylint configuration file will prevent 
it from doing that check.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco

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


multythreading app memory consumption

2006-10-22 Thread Roman Petrichev
Hi folks.
I've just faced with very nasty memory consumption problem.
I have a multythreaded app with 150 threads which use the only and the 
same function - through urllib2 it just gets the web page's html code 
and assigns it to local variable. On the next turn the variable is 
overritten with another page's code. At every moment the summary of 
values of the variables containig code is not more than 15Mb (I've just 
invented a tricky way to measure this). But during the first 30 minutes 
all the system memory (512Mb) is consumed and 'MemoryError's is arising.
Why is it so and how can I limit the memory consumption in borders, say, 
400Mb? Maybe there is a memory leak there?
Thnx

The test app code:


Q = Queue.Queue()
for i in rez: #rez length - 5000
 Q.put(i)


def checker():
 while True:
 try:
 url = Q.get()
 except Queue.Empty:
 break
 try:
 opener = urllib2.urlopen(url)
 data = opener.read()
 opener.close()
 except:
 sys.stderr.write('ERROR: %s\n' % traceback.format_exc())
 try:
 opener.close()
 except:
 pass
 continue
 print len(data)


for i in xrange(150):
 new_thread = threading.Thread(target=checker)
 new_thread.start()
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PSF Infrastructure has chosen Roundup as the issue tracker for Python development [repost]

2006-10-22 Thread Ben Finney
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes:

> [my initial post through python-list never seemed to reach c.l.py;
> reposting]

It did reach us, but in an ugly mass of text with no paragraph
breaks. This one is more readable, thanks.

> Well, the community stepped up to the challenge and we got plenty of
> volunteers!  In fact, the call for volunteers has led to an offer for
> professional hosting for Roundup from Upfront Systems.  The committee
> is currently evaluating that offer and will hopefully have a decision
> made soon.

Great news! I really hope the developers of free-software Python can
use free-software tools for managing the process.

-- 
 \  "He that would make his own liberty secure must guard even his |
  `\  enemy from oppression."  -- Thomas Paine |
_o__)  |
Ben Finney

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


Re: Attempting to parse free-form ANSI text.

2006-10-22 Thread Paul McGuire
"Michael B. Trausch" <"mike$#at^&nospam!%trauschus"> wrote in message 
news:[EMAIL PROTECTED]
> Alright... I am attempting to find a way to parse ANSI text from a
> telnet application.  However, I am experiencing a bit of trouble.
>
> What I want to do is have all ANSI sequences _removed_ from the output,
> save for those that manage color codes or text presentation (in short,
> the ones that are ESC[#m (with additional #s separated by ; characters).
> The ones that are left, the ones that are the color codes, I want to
> act on, and remove from the text stream, and display the text.
>
Here is a pyparsing-based scanner/converter, along with some test code at 
the end.  It takes care of partial escape sequences, and strips any 
sequences of the form
"[##;##;...", unless the trailing alpha is 'm'.
The pyparsing project wiki is at http://pyparsing.wikispaces.com.

-- Paul

from pyparsing import *

ESC = chr(27)
escIntro = Literal(ESC + '[').suppress()
integer = Word(nums)

colorCode = Combine(escIntro +
Optional(delimitedList(integer,delim=';')) +
Suppress('m')).setResultsName("colorCode")

# define search pattern that will match non-color ANSI command
# codes - these will just get dropped on the floor
otherAnsiCode = Suppress( Combine(escIntro +
Optional(delimitedList(integer,delim=';')) +
oneOf(list(alphas)) ) )

partialAnsiCode = Combine(Literal(ESC) +
Optional('[') +
Optional(delimitedList(integer,delim=';') + 
Optional(';')) +
StringEnd()).setResultsName("partialCode")
ansiSearchPattern = colorCode | otherAnsiCode | partialAnsiCode


# preserve tabs in incoming text
ansiSearchPattern.parseWithTabs()

def processInputString(inputString):
lastEnd = 0
for t,start,end in ansiSearchPattern.scanString( inputString ):
# pass inputString[lastEnd:start] to wxTextControl - font styles 
were set in parse action
print inputString[lastEnd:start]

# process color codes, if any:
if t.getName() == "colorCode":
if t:
print "" % t.asList()
else:
print ""
elif t.getName() == "partialCode":
print "" % t
# return partial code, to be prepended to the next string
# sent to processInputString
return t[0]
else:
# other kind of ANSI code found, do nothing
pass

lastEnd = end

# # pass inputString[lastEnd:] to wxTextControl - this is the last bit
# of the input string after the last escape sequence
print inputString[lastEnd:]


test = """\
This is a test string containing some ANSI sequences.
Sequence 1: ~[10;12m
Sequence 2: ~[3;4h
Sequence 3: ~[4;5m
Sequence 4; ~[m
Sequence 5; ~[24HNo more escape sequences.
~[7""".replace('~',chr(27))

leftOver = processInputString(test)


Prints:
This is a test string containing some ANSI sequences.
Sequence 1:


Sequence 2:

Sequence 3:


Sequence 4;


Sequence 5;
No more escape sequences.




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


Re: Tkinter--does anyone use it for sophisticated GUI development?

2006-10-22 Thread Peter Decker
On 22 Oct 2006 17:26:55 -0700, alex23 <[EMAIL PROTECTED]> wrote:

> Can you also tell when you're wrong?
>
> I checked out Wax last week for the first time; I hit a snag and got an
> answer from the lead developer within a day, along with a pointer to
> the latest dev version.
>
> But don't let communication get in the way of that six sense you've got
> going there :)

I've been following Wax for over two years. You can count the number
of new features that have been added to it in that time on one hand.
Hans is a great guy and has written some great stuff, but Wax is but a
small side project of his. I'm sure he'll support it excellently, but
I don't think I would hold my breath waiting for him to him to release
a grid that does, say, 1/10th of what the Dabo grid can do.

-- 

# p.d.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Customize the effect of enumerate()?

2006-10-22 Thread Steve Holden
Simon Forman wrote:
> Dustan wrote:
> 
>>Can I make enumerate(myObject) act differently?
>>
>>class A(object):
>>  def __getitem__(self, item):
>>  if item > 0:
>>  return self.sequence[item-1]
>>  elif item < 0:
>>  return self.sequence[item]
>>  elif item == 0:
>>  raise IndexError, "Index 0 is not valid."
>>  else:
>>  raise IndexError, "Invalid Index."
>>  def __iter__(self): return iter(self.sequence)
> 
> 
> That final else clause is a little funny...What kind of indices are
> you expecting that will be neither less than zero, greater than zero,
> or equal to zero?
> 
Good defensive programming albeit of a somewhat extreme nature. Should 
one of the tests be removed at a later date the else clause will trap 
occurrences of the no-longer handled case.

> 
>>Why the funny behavior, you ask? For my class A, it doesn't make sense
>>to number everything the standard programming way. Of course, if
>>someone uses enumerate, it's going to number the items the same way as
>>ever. Is there any way to modify that behavior, any special function to
>>set? There doesn't appear to be, according to the docs, but it never
>>hurts to make sure.
> 
> 
> You can write your own enumerate function and then bind that to the
> name 'enumerate'.
> 
Yes, but if you do you had better make sure that it gives the standard 
behavior for normal uses.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Skype: holdenweb   http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

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


Arrays? (Or lists if you prefer)

2006-10-22 Thread [EMAIL PROTECTED]
Pythonic lists are everything I want in a one dimensional array . . .
but I'm trying to do a text adventure and simplify the proces by
creating a grid as opposed to a tedious list of rooms this room
connects to.

So I want to know a good way to do a SIMPLE two dimensional array.
Python's lists are a little confusing when it comes to how to do this.
I realized that I could do

list = [ [0] * N ] * N

but I don't know if it would work because I'm a newbie and only
understand arrays if they're in grid-like form. And I haven't ben thru
linear algebra yet, due to my school giving me a few set backs I'm
allready having to take geometry and allgebra II which are meant to be
taken one after another at my school, so any suggestions  or hints in
that direction won't be helpful.

So:
Way to do SIMPLE array, either internally or externally, with Python,
please.

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


Re: Arrays? (Or lists if you prefer)

2006-10-22 Thread Paul Rubin
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes:
> Way to do SIMPLE array, either internally or externally, with Python,

Maybe you want to use a dictionary:

   a = {}
   a[(3,5)] = 2
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Arrays? (Or lists if you prefer)

2006-10-22 Thread Neil Cerutti
On 2006-10-23, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Pythonic lists are everything I want in a one dimensional array
> . . .  but I'm trying to do a text adventure and simplify the
> proces by creating a grid as opposed to a tedious list of rooms
> this room connects to.

Not to chase you out of comp.lang.python, but take a stroll by
rec.arts.int-fiction for pointers to a selection of domain
specific programming languages and virtual machines for writing
text adventures.

> So I want to know a good way to do a SIMPLE two dimensional
> array.  Python's lists are a little confusing when it comes to
> how to do this.  I realized that I could do
>
> list = [ [0] * N ] * N

You're right to be suspicious of that construct.

>>> a = [[0] * 2] * 2
>>> a
[[0, 0], [0, 0]]
>>> a[0][1] = "Oops."
>>> a
[[0, 'Oops.'], [0, 'Oops.']]

The problem is that Python lists hold references, not objects,
combined with the behavior of the multiplication operator on
lists.

> but I don't know if it would work because I'm a newbie and only
> understand arrays if they're in grid-like form. And I haven't
> ben thru linear algebra yet, due to my school giving me a few
> set backs I'm allready having to take geometry and allgebra II
> which are meant to be taken one after another at my school, so
> any suggestions  or hints in that direction won't be helpful.
>
> So:
> Way to do SIMPLE array, either internally or externally, with
> Python, please.

The problem wasn't with the construct, but in the way it was
constructed. Just build it up bit by bit, or build it all at once
using range() and then fill it in afterwards.

>>> b =[range(2), range(2)]
>>> b
[0, 1], [0, 1]]
>>> b[0][1] = "OK."
>>> b
[0, 'OK.'], [0, 1]]

A flexible way to do it instead might be to make your data
attributes of objects, instead. It won't be as fast as decoding 
multi-dimensional arrays, but it'll be easier to work with.

Then again, there's Inform, TADS, HUGO, the Z-machine, Glk and
Adrift to consider. ;-)

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


Re: Arrays? (Or lists if you prefer)

2006-10-22 Thread Paul McGuire
<[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Pythonic lists are everything I want in a one dimensional array . . .
> but I'm trying to do a text adventure and simplify the proces by
> creating a grid as opposed to a tedious list of rooms this room
> connects to.
>

> Way to do SIMPLE array, either internally or externally, with Python,
> please.
>

As an example of using pyparsing, I chose a simple text adventure 
application, and had to create a 2-D grid of rooms.  The presentation 
materials are online at http://www.python.org/pycon/2006/papers/4/, and the 
source code is included with the examples that ship with pyparsing 


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


Re: Problems trying to override __str__ on path class

2006-10-22 Thread Mike Krell
Peter Otten <[EMAIL PROTECTED]> wrote in
news:[EMAIL PROTECTED]: 
 
> I get
> 
> np: "overridden __str__: c:/mbk/test"
> str(np): "overridden __str__: c:/mbk/test"
> overridden __str__: overridden __str__: c:/mbk/test/appendtest

Hmmm.  I guess you're not running under windows, since normpath() 
converts / to \ on windows.  I wonder if that's part of the problem.

 
> Are you using the latest version of the path module?

My path.py says it's 2.1, which is the latest according to the site.

 Older versions
> implied a Path() call in the __div__() operator which would explain at
> least the output you get for
> 
> print np / 'appendtest'

You've lost me here.  What do you mean about "implied a Path() call"?  
Here is the definition of __div__ from path.py:

'''
# The / operator joins paths.
def __div__(self, rel):
""" fp.__div__(rel) == fp / rel == fp.joinpath(rel)

Join two path components, adding a separator character if
needed.
"""
return self.__class__(os.path.join(self, rel))
'''

I still don't understand the TypeError in the delegation case.

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


comp.lang.python, comp.sys.ibm.pc.games.rpg, comp.arch.embedded, comp.programming, comp.text.txt

2006-10-22 Thread vilebuzz
I sell on ebay alot and I'm starting to search online to find other
options to sell computers.  What I mainly do is buy used desktops and
upgrade them w/ better/newer parts for resale.  But do to ebays
overwhelming fees racking up every month I've started to look else
where.  I have since found a site called usfreeads that I have an
account w/ thats working fairly well for me as a seller (
http://www.usfreeads.com/_electronics/?affid=18156 ) , it works similar
to ebay but as classifieds rather than auctions, so you can negotiate
with sellers on prices which helps you to get more contacts, but I'm
trying to find out where everyone else is buying/selling at other than
ebay,  any recomendations?

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


Re: comp.lang.python, comp.sys.ibm.pc.games.rpg, comp.arch.embedded, comp.programming, comp.text.txt

2006-10-22 Thread Paul Rubin
[EMAIL PROTECTED] writes:
> trying to find out where everyone else is buying/selling at other than
> ebay,  any recomendations?

Yes, one thing for sure, those of us with sense don't buy from
spammers like yourself.
-- 
http://mail.python.org/mailman/listinfo/python-list


question about xmlrpc server: returning a list of lists to a Java client?

2006-10-22 Thread fortepianissimo
I have a simple xmlrpc server/client written in Python, and the client
throws a list of lists to the server and gets back a list of lists.
This runs without a problem.

I then wrote a simple Java xmlrpc client and it calls the python
server. But I can't figure out what type to cast the result (of type
Object) to. The Java xmlrpc call is basically this:


Object result = client.execute("MyFunction", params);


And I tried to replace that line with

 Vector result = (Vector) client.execute("MyFunction", params);

and

ArrayList result = (ArrayList) client.execute("MyFunction", params);

and both gave me  java.lang.ClassCastException.

I'm really not a Java expert - anyone can give a hint or two?

(NOTE the java client/python server works well when the returning
result is of type string - so this rules out some other possible
problems)

Thanks a lot!

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


sigmaplot key

2006-10-22 Thread Jac
key for sigmaplot 10 please
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Python and CMS

2006-10-22 Thread johnf
Echo wrote:

> I am going to start working on a church website. And since I like
> python, I decided to use WSGI. However, I later found out about all
> the different CMS's in php. So I wondered if there where any in
> python.
> 
> Sadly, I only found Plone, skeletonz, and PyLucid (If there is any
> more, please let me know). Of those three, only PyLucid supports WSGI
> and it didn't look very nice to me.
> Both Plone and skeletonz looked very nice. However, they can't be
> hosted on a regular web host(at least to my knowledge) since they run
> as the web server themselves. So hosting would cost more, at least 2-3
> times more from what I've seen.
> 
> So I'm thinking of making a python CMS based on WSGI. I'm now trying
> to figure out a few things like the best way to store the content and
> how to manage/use plugins. For storing the content, the only ways I
> know of are as files or in a database. But I'm not sure what would be
> better. And as for how to do plugings, I plan on looking at Plone and
> skeletonz.
> 
> As for working with WSGI, I have found
> Colubrid(http://wsgiarea.pocoo.org/colubrid/) and
> Paste(http://pythonpaste.org/). I was wondering if anyone knew of any
> other libraries that make working with WSGI easier. Also, I wondering
> if anyone would like to share their experiences of working with those.
> 
> 
> ps. I know that this is a big and complicated project. But no matter
> how far I get, it will be fun because its Python:)
> 
Turbogears???
John
-- 
http://mail.python.org/mailman/listinfo/python-list


ANN: wxPython 2.7.1.2 release

2006-10-22 Thread Robin Dunn
Announcing
--

The 2.7.1.2 release of wxPython is now available for download at
http://wxpython.org/download.php.  This release is a quick-turnaround
bugfix release designed to solve some problems found in the 2.7.1.1
release. Source and binaries are available for both Python 2.4 and 2.5
for Windows and Mac, as well some pacakges for varous Linux
distributions.  A summary of changes is listed below and also at
http://wxpython.org/recentchanges.php.


What is wxPython?
-

wxPython is a GUI toolkit for the Python programming language. It
allows Python programmers to create programs with a robust, highly
functional graphical user interface, simply and easily. It is
implemented as a Python extension module that wraps the GUI components
of the popular wxWidgets cross platform library, which is written in
C++.

wxPython is a cross-platform toolkit. This means that the same program
will usually run on multiple platforms without modifications.
Currently supported platforms are 32-bit Microsoft Windows, most Linux
or other Unix-like systems using GTK2, and Mac OS X 10.3+, in most
cases the native widgets are used on each platform.


Changes in 2.7.1.2
--

Fixed a bug in the MaskedEdit controls caused by conflicting IsEmpty
methods.

Patch #1579280: Some mimetype optimizations on unix-like systems.

wxMac: Several wx.webkit.WebKitCtrl enhancements/fixes, including:

 - new methods for increasing/decreasing text size, getting
   selection, getting/setting scroll position, printing, enabling
   editing, and running JavaScripts on the page.

 - added new event (wx.webkit.WebKitBeforeLoadEvent) for catching, and
   possibly vetoing, load events before they occur.

 - wx.webkit.WebKitCtrl now fires mouse events for certain events
   that it was eating before. This improves wxSplitterWindow
   resizing behavior.

 - refactoring of the sizing logic to move the Cocoa view.  Tested
   with splitter windows, panels, notebooks and all position
   correctly with this.

Some improvements to the drawing code in CustomTreeCtrl.

Fixed refcount leak in wx.Window.GetChildren.


-- 
Robin Dunn
Software Craftsman
http://wxPython.org  Java give you jitters?  Relax with wxPython!

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


Re: Socket module bug on OpenVMS

2006-10-22 Thread Fredrik Lundh
Irmen de Jong wrote:

> This also raises the question to what extent Python itself should
> work around platform specific "peculiarities", such as this one.
> There's another problem with socket code on Windows and VMS systems,
> where you get strange exceptions when using a "too big" recv() buffer.

what's a "strange exception" and a "too big" buffer?

> Things like this force me into writing all sorts of error checking
> code or platform specific functions, to work around these bugs.
> Just for what was supposed to be a simple socket recv() and a
> simple socket send()...

if you want buffering, use makefile().  relying on platform-specific 
behaviour isn't a good way to write portable code.



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


Re: Arrays? (Or lists if you prefer)

2006-10-22 Thread Andrea Griffini
Neil Cerutti wrote:

> >>> b =[range(2), range(2)]

I often happened to use

   b = [[0] * N for i in xrange(N)]

an approach that can also scale up in dimensions;
for example for a cubic NxNxN matrix:

   b = [[[0] * N for i in xrange(N)]
for j in xrange(N)]

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


Re: question about xmlrpc server: returning a list of lists to a Java client?

2006-10-22 Thread fortepianissimo

fortepianissimo wrote:
> I have a simple xmlrpc server/client written in Python, and the client
> throws a list of lists to the server and gets back a list of lists.
> This runs without a problem.
>
> I then wrote a simple Java xmlrpc client and it calls the python
> server. But I can't figure out what type to cast the result (of type
> Object) to. The Java xmlrpc call is basically this:
>
>
> Object result = client.execute("MyFunction", params);
>
>
> And I tried to replace that line with
>
>  Vector result = (Vector) client.execute("MyFunction", params);
>
> and
>
> ArrayList result = (ArrayList) client.execute("MyFunction", params);
>
> and both gave me  java.lang.ClassCastException.
>
> I'm really not a Java expert - anyone can give a hint or two?
>
> (NOTE the java client/python server works well when the returning
> result is of type string - so this rules out some other possible
> problems)
>
> Thanks a lot!

Ok I'll answer to myself: found this message

http://mail-archives.apache.org/mod_mbox/ws-xmlrpc-user/200603.mbox/[EMAIL 
PROTECTED]

Basically it's introduced by a bug in Apache XMLRPC 3.0a1
implementation.

Anyone knows any update on this please do post up (the message was
dated in March 2006) - appreciate it!

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


Re: Arrays? (Or lists if you prefer)

2006-10-22 Thread [EMAIL PROTECTED]
Niel Cerutti wrote:
>Just build it up bit by bit, or build it all at once
>using range() and then fill it in afterwards.

>>>> b =[range(2), range(2)]
>>>> b
>[0, 1], [0, 1]]
>>>> b[0][1] = "OK."
>>>> b
>[0, 'OK.'], [0, 1]]

Interesting. Could I do . . . let's say

b = [range(range(3)]

for a three-dimensional array?


Paul McGuire wrote:
> As an example of using pyparsing, I chose a simple text adventure
> application, and had to create a 2-D grid of rooms.  The presentation
> materials are online at http://www.python.org/pycon/2006/papers/4/, and the
> source code is included with the examples that ship with pyparsing

I read your entire thing, but how much stuck is a testimate to how much
I have yet to learn. Also, I didn't see the source code or downoad or
anything there. Where is it again?

Thanks for the responces.

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


Re: Arrays? (Or lists if you prefer)

2006-10-22 Thread [EMAIL PROTECTED]

Andrea Griffini wrote:
> Neil Cerutti wrote:
>
> > >>> b =[range(2), range(2)]
>
> I often happened to use
>
>b = [[0] * N for i in xrange(N)]
>
> an approach that can also scale up in dimensions;
> for example for a cubic NxNxN matrix:
>
>b = [[[0] * N for i in xrange(N)]
> for j in xrange(N)]
> 
> Andrea

What's the difference between xrange and range?

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


  1   2   >