Re: A problem while using urllib

2005-10-13 Thread Johnny Lee

Steve Holden 写道:
> Good catch, John, I suspect this is a possibility so I've added the
> following note:
>
> """The Windows 2.4.1 build doesn't show this error, but the Cygwin 2.4.1
> build does still have uncollectable objects after a urllib2.urlopen(),
> so there may be a platform dependency here. No 2.4.2 on Cygwin yet, so
> nothing conclusive as lsof isn't available."""
>
> regards
>   Steve
> --
> Steve Holden   +44 150 684 7255  +1 800 494 3119
> Holden Web LLC www.holdenweb.com
> PyCon TX 2006  www.python.org/pycon/

Maybe it's really a problem of platform dependency. Take a look at this
brief example, (not using urllib, but just want to show the platform
dependency of python):

Here is the snapshot from dos:
---
D:\>python
ActivePython 2.4.1 Build 247 (ActiveState Corp.) based on
Python 2.4.1 (#65, Jun 20 2005, 17:01:55) [MSC v.1310 32 bit (Intel)]
on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> f = open("t", "r")
>>> f.tell()
0L
>>> f.readline()
'http://cn.realestate.yahoo.com\n'
>>> f.tell()
28L

--

Here is the a snapshot from cygwin:
---
Johnny [EMAIL PROTECTED] /cygdrive/d
$ python
Python 2.4.1 (#1, May 27 2005, 18:02:40)
[GCC 3.3.3 (cygwin special)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> f = open("t", "r")
>>> f.tell()
0L
>>> f.readline()
'http://cn.realestate.yahoo.com\n'
>>> f.tell()
31L



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

Help with cPickle for deserializing datetime.datetime instances

2005-10-13 Thread Mingus Tsai
Hello- please help with unpickling problem:

I am using Python version 2.3.4 with IDLE version 1.0.3 on a Windows 
XPhome system.

My problem is with using cPickle to deserialize my pickled arrays of 
datetime.datetime instances.  The following is the code I have written:

import cPickle, datetime
import Numeric

#the file below contains a serialized dict with arrays of datetime 
#objects.  When these three statements run, the IDLE crashes!

input1 = open('tsm2_outa','r')
time1 = cPickle.load(input1)
input1.close()

#the file below contains serialized dict with arrays of built-in objects
#it unpickles without any problem, when I omit the above unpickling 
#operation.

input2 = open('tsm2_outb','rb')
data1 = cPickle.load(input2)
input2.close()

My guess is that I need to somehow tell the pickle.load command that it 
is loading datetime instances, but I have no idea how to do this.  Any 
help would be much appreciated.

Thanks,
Ming
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ImportError: No module named dbm

2005-10-13 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote:

> firstly i couldnt find the DBM module for python 2.3.5, trustix system and
> i386 hardware platform.
> so i downloaded gnu dbm for python 2.3.5 and i568( precisly,
> python-gdbm-2.3.5-4tr.i586), simply assuming it could just work.
>
> but trying to install gives me the following error,
>
> error: failed dependencies:
> python = 2.3.5 is needed by python-gdbm-2.3.5-4tr
>
> I am preety sure its python 2.3.5 tht is installed.

did you install 2.3.5 yourself, or via RPM (or whatever trustix is using) ?

if you built it yourself, the RPM database will not know about it; on the
other hand, all you need to do to fix that is to look for a gdbm package
for trustix, install it, and rebuild Python.

if this isn't enough to get you unstuck, it might be a good idea to check
with some trustix support forum.





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


Re: Setdefault bypasses __setitem__

2005-10-13 Thread Fredrik Lundh
Diez B. Roggisch wrote:

> I rarely find things in python strange or named incorrectly, but this is
> IMHO such a case - setdefault led me to think that using it would set a
> default value to return for _future_ lookups of non-existant keys. That
> semantics is known in e.g. ruby or java.
>
> I think a better name would be getdefault, or even get_setdefault - in
> oppposition to the get(key, d) form.
>
> But now that this became clear to me... I guess I can live with the name :)

as long as you pronounce it correctly (see my earlier post).





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


Re: Python's garbage collection was Re: Python reliability

2005-10-13 Thread Paul Rubin
[EMAIL PROTECTED] writes:
> Folks, most common GC schemes have been tried as experiments over
> the years.  None have succeeeded, for various reasons.  I think one
> of the main reasons is that Python has to "play nice" with external
> libraries, many of which weren't written with GC beyond malloc and
> free in mind.

Most GC'd language implementations I've seen actually have friendlier
FFI's (foreign function interfaces) than Python does.  I find it very
easy to make errors with the reference counts in what little Python C
extension hacking I've done.  Maybe one gets better at it with
experience.

> Tagged integers: 
> http://mail.python.org/pipermail/python-dev/2004-July/046139.html

That actually says there was a speedup from tagged ints with no
obvious counterbalancing cost.  However, it looks like there's no
traditional GC, it stays with the same reference counts for heap objects.

> Boehm GC:
> http://mail.python.org/pipermail/python-dev/2005-January/051370.html

This mentions use of Python idioms like txt = open(filename).read()
expecting the file handle to get freed immediately.  I think there's
been some language extensions ("with" statement) discussed to replace
that idiom.  Note that the idiom is already not so safe in Jython.

The Boehm GC doesn't seem like the right choice for an interpreter
being built from scratch anyway, but who knows.  Maybe I'm being
premature but I'm already thinking of CPython as a legacy
implementation and PyPy as the more likely testbed for stuff like
this.  I sorta wanted to go to the current sprint but oh well.

> http://wiki.python.org/moin/CodingProjectIdeas/PythonGarbageCollected

This correctly describes difficulties of using a copying GC in
CPython.  Note that the Boehm GC is mark-and-sweep.  As Alex mentions,
that usually means there's a pause every so often while the GC scans
the entire heap, touching all data both live and dead (maybe the Boehm
GC got around this somehow).

I haven't been keeping up with this stuff in recent years so I have a
worse concern.  I don't know whether it's founded or not.  Basically
in the past decade or so, memory has gotten 100x larger and cpu's have
gotten 100x faster, but memory is less than 10x faster once you're out
of the cpu cache.  The mark phase of mark/sweep tends to have a very
random access pattern (at least for Lisp).  In the old days that
wasn't so bad, since a random memory access took maybe a couple of cpu
cycles, but today it takes hundreds of cycles.  So for applications
that use a lot of memory, simple mark/sweep may be a much worse dog
than it was in the Vax era, even if you don't mind the pauses.

> Miscellaneous:
>   http://mail.python.org/pipermail/python-dev/2002-June/026032.html

That looks potentially kind of neat, though it's not obvious what it does.

>   http://mail.python.org/pipermail/python-dev/2003-November/040299.html

I'll try to read that sometime out of general interest.  I'm too
sleepy right now.

> And lest anyone here think they were the first to suggest getting rid of
> reference counting in Python:
> 
> http://www.python.org/search/hypermail/python-1993/0554.html

I think the language suggestions in that message are sound in
principle, if not quite the right thing in every detail.  Lisp went
through about the same evolution in the 60's or 70's (before my time).

With PyPy, it looks like Python implementation methodology is getting
a lot more advanced, so hopefully some big performance gains are
possible, and the language will likely evolve to help things along.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: UI toolkits for Python

2005-10-13 Thread Fredrik Lundh
> > However, Tkinter not most people's favorite, because the widgets look
> > crude, they don't resemble the native widgets of any popular platform,
> > and the widget set is somewhat limited.

(given that the web interface is the new black, that's not much of
an argument.  tkinter with the right stylesheet can look anyway you
want)

Mark Roseman wrote:

> People should probably be more aware of work that has been going on with
> Tk recently (after a fairly long hiatus) in terms of greatly improving
> its appearance, adding theming, and more.  It's worth checking out, and
> of course, if there's a way to help get some of these changes into
> Tkinter, the Tk folks would I'm sure be helpful.

maybe this should be reposted to tkinter-discuss ?

fwiw, I still use Tkinter for all UI:s I build, but these days, 80-90%
of the visible widgets are based on this module:

http://effbot.org/zone/wck.htm

sometimes combined with:

http://effbot.org/zone/draw-agg.htm





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


Re: Adding a __filename__ predefined attribute to 2.5?

2005-10-13 Thread Fredrik Lundh
Rune Strand wrote:

> I've read a lot of your comments the last years. Your friendliness
> always strikes me.

terseness != unfriendlyness





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


Problem processing Chinese

2005-10-13 Thread Anthony Liu
I believe that topic related to Chinese processing was
discussed before.  I could not dig out the info I want
from the mail list archive.

My Python script reads some Chinese text and then
split a line delimited by white spaces.  I got lists
like

['\xbc\xc7\xd5\xdf', '\xd0\xbb\xbd\xf0\xbb\xa2',
'\xa1\xa2']

I had 

#-*- coding: gbk -*-

on top of the script.

My Windows 2000 system's default language is Chinese
(GB2312) and  displays Chinese perfectly.

I don't know how to configure python or what else I
need to properly process such two-byte-character text.

Thanks.







__ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: UI toolkits for Python

2005-10-13 Thread gsteff
Er, meant to say  "In addition GTK itself is in the top tier of free
software projects"

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


Re: UI toolkits for Python

2005-10-13 Thread gsteff
I've used wxpython and pygtk, and have a strong preference for pygtk.
wxpython has some advantages: it has better OSX support (widgets look
native, and it doesn't require the installation of the Fink x server),
and better win32 support (a few gtk widgets, such as menus, don't look
quite native on gtk, and multithreading with pygtk on win32 is
problematic).  But pygtk has better documentation, a MUCH cleaner api,
integration with the Glade GUI designer (wxpython has wxglade, but its
not in the same league), and a richer widget set.  In addition, top
itself is in the top tier of free software projects; wxwidgets is not
as mature, and its development is not as active.

So, if you're trying to choose between those two, go with wxpython if
you need OSX support, or have specific issues with pygtk's win32
support.  In all other cases, I'd reccomend pygtk.

Greg

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


Re: Hidden string formatting bug

2005-10-13 Thread Steve Holden
Tim Peters wrote:
> [Echo]
> 
>>I have been trying to figure out the problem with this string formatting:
> 
> 
> [monstrous statement snipped]
> 
> 
>>when it executes, I get this error: "inv argument required".
> 
> 
> That shoud be "int", not "inv".
> 
> 
>>I have checked and rechecked both the string and the tuple. I cant figure
>>out what the problem is.  After playing around with it, i found out if change
>>the last line to: "%s,%i) %(... I get a different error. The error is "not all
>>arguments converted during string formatting".
>>
>>So I am baffled and confused as of why this wont work. Is anyone able to
>>shed some light on my hidden bug?
> 
> 
> Yup, it's precedence.  Here's the same thing:
> 
> sql = "%s" + \
>   "%i" % ("abc", 2)
> 
> Run that and you get "int argument required".  Change the last %i to
> %s and you get "not all arguments converted during string formatting".
>  Both error messages are accurate.
> 
> That's because % binds tighter than "+".  As a 1-liner, and inserting
> redundant parentheses to make the precedence obvious, my simplified
> example is
> 
> sql = "%s" + ("%i" % ("abc", 2))
> 
> What you intended _requires_ inserting more parentheses to force the
> intended order (if you're going to stick to this confusing coding
> style):
> 
> sql = ("%s" + "%i") % ("abc", 2)
> 
> Better is to not use "+" on string literals, and not use backslash
> continuation either; try this instead:
> 
> sql_format = ('string1'
> 'string2'
> 'string3'
> ...
> 'last string')
> 
> Build the format in a separate statement to reduce the chance of
> errors (for example, your original mistake would have been impossible
> to make this way).  Use parens instead of backslashes.  Don't use "+"
> to catenate string literals:  the Python compiler automatically
> catenates adjacent string literals for you, and at compile-time (so
> it's even more efficient than using '"+").

Further to Tim's erudite language advice, I should point out the 
oft-repeated advice that you are leaving yourself wide open to SQL 
injection exploits here, and you should definitely consider using 
parameterised queries, which have been discussed here so often (and too 
recently for me to repeat) that you should easily be able to find them 
with Google.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006  www.python.org/pycon/

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


Re: String code required please

2005-10-13 Thread da_hmea98
[EMAIL PROTECTED] wrote:
> Does someone have the Python code to pull just the filename and
> extension from the end of an absolute path please.
>
> Thanks in advance ...

# Here you go...
import os.path

# Example path
p1 = "C:\\WINDOWS\\system32\\DirectX\\Dinput\\mse.ini"

# This will return: 'mse.ini'
os.path.basename(p1)

"""
You can read more about manipulating file paths by reading the Python
documentation under "6.2 os.path -- Common pathname manipulations".

DA
"""

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


Re: String code required please

2005-10-13 Thread SPE - Stani's Python Editor
import os
fileName = os.path.basename(absolute)
base, ext  = os.path.splitext(fileName)

Stani

http://pythonide.stani.be

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


Re: wxPython & Cygwin

2005-10-13 Thread Steve Holden
Diez B. Roggisch wrote:
> Gilles DRIDI wrote:
> 
>>Does someone has installed wxPython on the Cygwin platform, environment ?
> 
> 
> Why? Use windows python, wxPython for it - and put it in your path to 
> use it inside cygwin.
> 
Don't think that'll work for an extension module.

> But maybe you _can_ compile it yourself - I didn't try, though.
> 
> Diez

Probably a daunting task.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006  www.python.org/pycon/

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


Re: Python's garbage collection was Re: Python reliability

2005-10-13 Thread Paul Rubin
Steve Holden <[EMAIL PROTECTED]> writes:
>  >>And this presumes an architecture which byte-addresses and only
>  >> uses "aligned" addresses.
> 
> He was talking about the arachiteecture, for Pete's sake, not a compiler.

Yeah, I noticed that, I could have been pedantic about it but chose to
just describe how these language implementations work in the real
world with zero exceptions that I know of.  I guess I should have
spelled it out.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python interpreter

2005-10-13 Thread Neal Norwitz
g.franzkowiak wrote:
> Hi everybody,
>
> my interest is for the internals of the Python interpreter.
>
> I've used up to now FORTH for something and this indirect interpreter is
>  very smart.
> --- ASM ---
>
> Where can I find informations like this for Python ?

Depends on what you want.  If you want to see the disassembled bytes
similar to what I cut out, see the dis module.  (e.g.,
dis.dis(foo_func))

If you want to know how the byte codes are created, it's mostly in
Python/compile.c.  If you want to know how the byte codes are executed,
it's mostly in Python/ceval.c.

All base Python objects implemented in C are under Objects/.  All
standard modules implemented in C are under Modules/.

Get the source and build it.  It's quite readable.

n

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


Re: FORM data in cgi

2005-10-13 Thread Steve Holden
Mike Meyer wrote:
> "jponiato" <[EMAIL PROTECTED]> writes:
> 
> 
>>Greetings.
>>An HTML form submits it's data to a python cgi script on my server. This 
>>script accepts this POST data, and uses urllib.urlopen() to call a different 
>>cgi script (on an external server), passing this same data. I'm using 
>>cgi.FieldStorage() to create a mapping of the FORM data, then using 
>>urllib.urlencode() to turn it back into form data for urlopen().
>>Question - is there a more efficient way to do this?
> 
> 
> Yes. But the question you should be asking is "Is there an easier way
> to do it that's worth doing?"
> 
> Unless you're passing around files, or really huge forms, the amount
> of time you spend doing decoding and encodinng the form data will be
> pretty trivial. Unless you're really pressed for cycles, why bother
> fixing it? And if you're really pressed for cycles, you should start
> by instrumenting things to make sure that you're optimizing something
> that will do you some good.
> 
> Anyway, the general idea is to skip cgi.FieldStorage, and parse the
> request yourself. You'll have to deal with the headers. But you can
> just grab the post data with a read(). I'm not sure you can use urllib
> to send pre-encoded POST data; you'll have to check that yourself. If
> not, you'll have to do the HTTP request processing by yourself. That's
> not hard, though.
> 
> http://mail.python.org/mailman/listinfo/python-list


Re: Yes, this is a python question, and a serious one at that (moving to Win XP)

2005-10-13 Thread Christian Stapfer
"John J. Lee" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Kenneth McDonald <[EMAIL PROTECTED]> writes:
> [...]
>> absolutely preventing me from making the switch. Number one is the
>> lack of a decent command line and command-line environment, and I'm
>> wondering (hoping) if perhaps someone has written a "Python shell"-- 
>> something that will look like a regular shell, let users type in
>> commands, maybe have some of the nice features of bash etc. like tab
>> completion, etc, and will then execute an underlying python script
>> when the command is entered. I'm not thinking of IDLE, but something
>> that is really aimed more at being a system terminal, not a Python-
>> specific terminal.
> [...]
>
> cmd.exe can be made bearable.  I just got a new machine, so I'll have
> to do this myself in the next few days...
>
> 0. Make a shortcut to cmd.exe, stick it somewhere get-at-able,
>   eg. quick launch toolbar

0.0. ... and add an item to your SendTo folder that allows
you to have Windows Explorer open a terminal window with its
current directory set to the currently displayed folder
(= "Open terminal here").

Regards,
Christian


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


Re: Python's garbage collection was Re: Python reliability

2005-10-13 Thread Steve Holden
Paul Rubin wrote:
> "Diez B. Roggisch" <[EMAIL PROTECTED]> writes:
> 
>>>Yes, that would describe just about every cpu for the past 30 years
>>>that's a plausible Python target.
>>
>>No. The later 68K (>68020) could address on odd adresses. And AFAIK
>>all x86 can because of their 8080 stemming.
> 
> 
> Yes, "could" but not "does" in terms of what any reasonable actual
> compiler implmementations do.  You get a huge performance hit for
> using unaligned data.  The one exception is you could conceivably have
> character strings starting at odd addresses but it's no big deal to
> start them all on 4-byte (or even 2-byte) boundaries.

You made your original assertion in response to Diez saying

 >>And this presumes an architecture which byte-addresses and only
 >> uses "aligned" addresses.

He was talking about the arachiteecture, for Pete's sake, not a compiler.

I personally find it irritating that you continue to try and justify 
your assertions even when you are plainly on shaky ground, which tends 
to make the threads you are involved in endless. Sorry for the ad 
hominem remarks, which I normally try and avoid, but this (ab)uses 
newsgroup bandwidth unnecessarily.

Unwillingness to admit any mistake can be rather unattractive. Can't 
you, just once, say "I was wrong"? Or are you perchance related to 
President Bush? Better still, just let these small things go without 
further comment.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006  www.python.org/pycon/

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


Re: A problem while using urllib

2005-10-13 Thread Steve Holden
John J. Lee wrote:
> Steve Holden <[EMAIL PROTECTED]> writes:
> [...]
> 
>>   File "/usr/lib/python2.4/urllib2.py", line 996, in do_open
>> raise URLError(err)
>>urllib2.URLError: 
>>
>>Looking at that part of the course of urrllib2 we see:
>>
>> headers["Connection"] = "close"
>> try:
>> h.request(req.get_method(), req.get_selector(), req.data, 
>>headers)
>> r = h.getresponse()
>> except socket.error, err: # XXX what error?
>> raise URLError(err)
>>
>>So my conclusion is that there's something in the Cygwin socket module 
>>that causes problems not seen under other platforms.
>>
>>I couldn't find any obviously-related error in the Python bug tracker, 
>>and I have copied this message to the Cygwin list in case someone there 
>>knows what the problem is.
> 
> [...]
> 
> I don't *think* this is related, but just in case:
> 
> http://python.org/sf/1208304
> 
Good catch, John, I suspect this is a possibility so I've added the 
following note:

"""The Windows 2.4.1 build doesn't show this error, but the Cygwin 2.4.1 
build does still have uncollectable objects after a urllib2.urlopen(), 
so there may be a platform dependency here. No 2.4.2 on Cygwin yet, so 
nothing conclusive as lsof isn't available."""

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006  www.python.org/pycon/

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


String code required please

2005-10-13 Thread dapgy
Does someone have the Python code to pull just the filename and
extension from the end of an absolute path please.

Thanks in advance ...

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


Re: setuptools, ez_setup over http proxy

2005-10-13 Thread ray223

yoda wrote:
> I've recently configured my network such that I use squid as a http
> proxy.  I'd now like to be able to use setuptools and ez_setup via this
> proxy.  Is this possible? If so, how do I do it?
>
> The most that the setuptools documentation says is
> (http://peak.telecommunity.com/DevCenter/setuptools):
>
> "If you are behind an NTLM-based firewall that prevents Python
> programs from accessing the net directly, you may wish to first install
> and use the APS proxy server, which lets you get past such firewalls in
> the same way that your web browser(s) do."
>
> ps. I'm not sure that this is the right forum for this question.  If it
> isn't feel free to point me to the right place.

Hi,

This is really an urllib2 question ...

setup an environment variable "HTTP_PROXY" that points to your proxy
server, of the form:

user:[EMAIL PROTECTED]:port

urllib2 doco will probably have more details

Ray Smith

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


Re: CSV module and Mac excel format problem

2005-10-13 Thread David Pratt
Many thanks Andrew for this excellent piece of knowledge :-). 4 
characters of code and everything is great!

Regards,
David

On Friday, October 14, 2005, at 12:11 AM, Andrew McNamara wrote:

>> Hi. I have had good success with CSV module but recently came across
>> problem with reading excel from Mac Office.  The trouble is with line
>> endings.  Instead of \r\n you have just \r and the file as a whole
>> appears as a single line. CSV coughs and provides this exception:
>>
>> _csv.Error: newline inside string
>>
>> Saving as Windows (text) in Mac Office solves this but I don't
>> necessarily want to force users to save this way just to avoid
>> modifying my code. There is a lineterminator in the package.  Adding
>> parameter lineterminator='\r' did not correct the problem.
>
> Open the file in universal-newline mode - for example:
>
> sample = open(filename, 'rU')
>
> "lineterminator" is only used for output - we use the supplied iterator
> (and whatever conventions it imposes) for input.
>
> -- 
> Andrew McNamara, Senior Developer, Object Craft
> http://www.object-craft.com.au/
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: setuptools, ez_setup over http proxy

2005-10-13 Thread Phillip J. Eby
yoda wrote:
> I've recently configured my network such that I use squid as a http
> proxy.  I'd now like to be able to use setuptools and ez_setup via this
> proxy.  Is this possible? If so, how do I do it?

The key thing is just that Python's urllib module needs to be able to
retrieve web pages and download files.  Try pulling up your Python
interpreter and retrieving a page with urllib.  If it works, you're
good to go, and no need to bother with anything else.

If it doesn't work, try Jay's suggestions for setting environment
variables, or consult the urllib doc and/or code for more details on
how urllib finds out what proxy to use.

> The most that the setuptools documentation says is
> (http://peak.telecommunity.com/DevCenter/setuptools):
>
> "If you are behind an NTLM-based firewall that prevents Python
> programs from accessing the net directly, you may wish to first install
> and use the APS proxy server, which lets you get past such firewalls in
> the same way that your web browser(s) do."

Yeah, I mention this because by far the most common cause of problems
for Windows users is that they're behind one of those infernal
NTLM-based firewalls and thus can't use urllib unaided.


> ps. I'm not sure that this is the right forum for this question.  If it
> isn't feel free to point me to the right place.

The distutils-sig mailing list is the best place to ensure you get an
answer relatively quickly, since I don't subscribe to this list, just
skim it from time to time.

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


Re: setuptools, ez_setup over http proxy

2005-10-13 Thread Phillip J. Eby
yoda wrote:
> I've recently configured my network such that I use squid as a http
> proxy.  I'd now like to be able to use setuptools and ez_setup via this
> proxy.  Is this possible? If so, how do I do it?

The key thing is just that Python's urllib module needs to be able to
retrieve web pages and download files.  Try pulling up your Python
interpreter and retrieving a page with urllib.  If it works, you're
good to go, and no need to bother with anything else.

If it doesn't work, try Jay's suggestions for setting environment
variables, or consult the urllib doc and/or code for more details on
how urllib finds out what proxy to use.

> The most that the setuptools documentation says is
> (http://peak.telecommunity.com/DevCenter/setuptools):
>
> "If you are behind an NTLM-based firewall that prevents Python
> programs from accessing the net directly, you may wish to first install
> and use the APS proxy server, which lets you get past such firewalls in
> the same way that your web browser(s) do."

Yeah, I mention this because by far the most common cause of problems
for Windows users is that they're behind one of those infernal
NTLM-based firewalls and thus can't use urllib unaided.


> ps. I'm not sure that this is the right forum for this question.  If it
> isn't feel free to point me to the right place.

The distutils-sig mailing list is the best place to ensure you get an
answer relatively quickly, since I don't subscribe to this list, just
skim it from time to time.

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


Re: CSV module and Mac excel format problem

2005-10-13 Thread Andrew McNamara
>Hi. I have had good success with CSV module but recently came across 
>problem with reading excel from Mac Office.  The trouble is with line 
>endings.  Instead of \r\n you have just \r and the file as a whole 
>appears as a single line. CSV coughs and provides this exception:
>
>_csv.Error: newline inside string
>
>Saving as Windows (text) in Mac Office solves this but I don't 
>necessarily want to force users to save this way just to avoid 
>modifying my code. There is a lineterminator in the package.  Adding 
>parameter lineterminator='\r' did not correct the problem.

Open the file in universal-newline mode - for example:

sample = open(filename, 'rU')

"lineterminator" is only used for output - we use the supplied iterator
(and whatever conventions it imposes) for input. 

-- 
Andrew McNamara, Senior Developer, Object Craft
http://www.object-craft.com.au/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: setuptools, ez_setup over http proxy

2005-10-13 Thread Jay Parlar
> I've recently configured my network such that I use squid as a http
> proxy.  I'd now like to be able to use setuptools and ez_setup via this
> proxy.  Is this possible? If so, how do I do it?

It should work if you sent the environment variable (in your shell) 
'http_proxy' to the address of your proxy. Python's urllib will then be 
able to pull it, and everything should magically work.

Something like:

export http_proxy='http://some_squid_server'



> "If you are behind an NTLM-based firewall that prevents Python
> programs from accessing the net directly, you may wish to first install
> and use the APS proxy server, which lets you get past such firewalls in
> the same way that your web browser(s) do.

As far as I know, this is only a problem if you're using a particular 
proxy server from Microsoft.


> ps. I'm not sure that this is the right forum for this question.  If it
> isn't feel free to point me to the right place.

The distutils list would be the more appropriate place for setuptools 
questions in general.

Jay P.

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


CSV module and Mac excel format problem

2005-10-13 Thread David Pratt
Hi. I have had good success with CSV module but recently came across 
problem with reading excel from Mac Office.  The trouble is with line 
endings.  Instead of \r\n you have just \r and the file as a whole 
appears as a single line. CSV coughs and provides this exception:

_csv.Error: newline inside string

Saving as Windows (text) in Mac Office solves this but I don't 
necessarily want to force users to save this way just to avoid 
modifying my code. There is a lineterminator in the package.  Adding 
parameter lineterminator='\r' did not correct the problem.

The way I am reading tab delimited to dictionary:

lines = sample.readlines()
headers = csv.reader(lines, delimiter='\t').next()
rows = csv.DictReader(lines, headers, delimiter='\t')
for row in rows:
print row

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


Re: Bad magic no. in python zipfile

2005-10-13 Thread [EMAIL PROTECTED]
okay, I've figured out the problem - the zip file was being mangled by
a file transfer.  I was fetching a remote python-generated zip file in
8k chunks, and then writing those chunks to a file.  At first I was
using an array to store the data in, and had the 'bad magic number'
problem.  This may have been due to writing the chunks out to a local
file as strings, which would definitely have corrupted the file; I also
noticed that the local copy was several kb larger, probably due to the
line endings being added.  When I took care to write the file as a
binary file, all was well. case closed.

BTW, regarding using zipfile under Python 1.5.2... I found zipfile.py
in Python 1.6, but it wouldn't run.  You need to build Python 1.5 with
the binascii.c and zlibmodule.c from Python 1.6, since a CRC32 method
has been added to those modules.  This was more trouble than it was
worth, in the end. 

S

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


Re: Hidden string formatting bug

2005-10-13 Thread Tim Peters
[Echo]
> I have been trying to figure out the problem with this string formatting:

[monstrous statement snipped]

> when it executes, I get this error: "inv argument required".

That shoud be "int", not "inv".

> I have checked and rechecked both the string and the tuple. I cant figure
> out what the problem is.  After playing around with it, i found out if change
> the last line to: "%s,%i) %(... I get a different error. The error is "not all
> arguments converted during string formatting".
>
> So I am baffled and confused as of why this wont work. Is anyone able to
> shed some light on my hidden bug?

Yup, it's precedence.  Here's the same thing:

sql = "%s" + \
  "%i" % ("abc", 2)

Run that and you get "int argument required".  Change the last %i to
%s and you get "not all arguments converted during string formatting".
 Both error messages are accurate.

That's because % binds tighter than "+".  As a 1-liner, and inserting
redundant parentheses to make the precedence obvious, my simplified
example is

sql = "%s" + ("%i" % ("abc", 2))

What you intended _requires_ inserting more parentheses to force the
intended order (if you're going to stick to this confusing coding
style):

sql = ("%s" + "%i") % ("abc", 2)

Better is to not use "+" on string literals, and not use backslash
continuation either; try this instead:

sql_format = ('string1'
'string2'
'string3'
...
'last string')

Build the format in a separate statement to reduce the chance of
errors (for example, your original mistake would have been impossible
to make this way).  Use parens instead of backslashes.  Don't use "+"
to catenate string literals:  the Python compiler automatically
catenates adjacent string literals for you, and at compile-time (so
it's even more efficient than using '"+").
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 1-liner to iterate over infinite sequence of integers?

2005-10-13 Thread Peter Hansen
Erik Max Francis wrote:
> The negative integers are being descriminated against!  I demand justice!
> 
> def integers():
> yield 0
> x = 1
> while True:
> yield x
> yield -x
> x += 1
> 
> ... which is also not a bad demonstration of how the integers are 
> countably infinite.

For some reason I was unable to avoid seeing that one can save a yield 
there (not that they're a scarce resource, mind you):

def integers():
   x = 0
   while True:
 yield -x
 x += 1
 yield x

I know that shouldn't win any readability awards...

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


Re: [Info] PEP 308 accepted - new conditional expressions

2005-10-13 Thread Chris Smith
> "Duncan" == Duncan Booth <[EMAIL PROTECTED]> writes:

Duncan> Chris Smith wrote:
>> What I really want to do is take four lines of conditional, and
>> put them into one, as well as blow off dealing with a 'filler'
>> variable:
>> 
>> return "the answer is " + "yes" if X==0 else "no"
>> 
>> 
>> Or whatever the final release syntax is.

Duncan> The syntax is fine, but the semantics might not be what
Duncan> you expected. If I understand it correctly you need:

Duncan> return "the answer is " + ("yes" if X==0 else "no")

Duncan> Guido's pronouncement said:

>> In general, 'if' and 'else' bind less tight than everything
>> except lambda.
I say, with the utmost arrogance, that I won't neglect the parens more
than, say, 50 times. ;)
-Chris
-- 
http://mail.python.org/mailman/listinfo/python-list


setuptools, ez_setup over http proxy

2005-10-13 Thread yoda
I've recently configured my network such that I use squid as a http
proxy.  I'd now like to be able to use setuptools and ez_setup via this
proxy.  Is this possible? If so, how do I do it?

The most that the setuptools documentation says is
(http://peak.telecommunity.com/DevCenter/setuptools):

"If you are behind an NTLM-based firewall that prevents Python
programs from accessing the net directly, you may wish to first install
and use the APS proxy server, which lets you get past such firewalls in
the same way that your web browser(s) do."

ps. I'm not sure that this is the right forum for this question.  If it
isn't feel free to point me to the right place.

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


Re: matching elements of numeric arrays

2005-10-13 Thread daniel . neilson
Thanks a lot. It was this equal.outer idea that I was missing.

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


Hidden string formatting bug

2005-10-13 Thread Echo
Hello,
I have been trying to figure out the problem with this string formatting:

sql = 'INSERT INTO tc_themes (name,user_made,hour12,time_loc,background_color_r,' + \
   
'background_color_g,background_color_b,clock_color_r,clock_color_g,' + \
   
'clock_color_b,clock_background_color_r,clock_background_color_g,' + \
   
'clock_background_color_b,clock_points_color_r,clock_points_color_g,' +
\
   
'clock_points_color_b,clock_hour_color_r,clock_hour_color_g,' + \
   
'clock_hour_color_b,clock_min_color_r,clock_min_color_g,' + \
   
'clock_min_color_b,clock_sec_color_r,clock_sec_color_g,' + \
   
'clock_sec_color_b,clock_font_facename,clock_font_size,' + \
   
'clock_font_style,clock_font_underlined,clock_font_weight,' + \
   
'clock_font_color_r,clock_font_color_g,clock_font_color_b,' + \
   
'time_font_facename,time_font_size,time_font_style,' + \
   
'time_font_underlined,time_font_weight,time_font_color_r,' + \
   
'time_font_color_g,time_font_color_b) VALUES (' + \
    "%s,%i,%i,%s,%i," + \
    "%i,%i,%i,%i," + \
    "%i,%i,%i," + \
    "%i,%i,%i," + \
    "%i,%i,%i," + \
    "%i,%i,%i," + \
    "%i,%i,%i," + \
    "%i,%s,%i," + \
    "%i,%i,%i," + \
    "%i,%i,%i," + \
    "%s,%i,%i," + \
    "%i,%i,%i," + \
   
"%i,%i)" % ("'Simple Clock'", 0, 1, "'Top'", 200, 200, 200, 100, 100,
100, 255, 255, 255, 100, 100, 100, 0, 0, 0, 0, 0, 0, 255, 0, 0,
"'Arial'", 18, 90, 0, 90, 0, 0, 0, "'Arial'", 32, 90, 0, 90, 0, 0, 0)

when it executes, I get this error: "inv argument required". I have
checked and rechecked both the string and the tuple. I cant figure out
what the problem is.
After playing around with it, i found out if change the last line to:
"%s,%i) %(... I get a different error. The error is "not all arguments
converted during string formatting".

So I am baffled and confused as of why this wont work. Is anyone able to shed some light on my hidden bug?
Using: Python 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit (Intel)]
-- -Echo
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: win32api.FindFiles Win2003, problem with Short Name

2005-10-13 Thread Neil Hodgson
Frank Borell:

> I'm having a problem retrieving the ShortName from a file that was
> written by a MAC and only from a Windows 2003 server.
> 
> I realize the file has a space after it, but I can retrieve the short
> name from Windows XP and 2000;

Does your Windows 2003 machine have short file name support turned 
off? The NtfsDisable8dot3NameCreation registry option is popular with 
some administrators.

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


Re: Setdefault bypasses __setitem__

2005-10-13 Thread Diez B. Roggisch
Duncan Booth wrote:
> Diez B. Roggisch wrote:
> 
> 
>>So if setdefault
>>was implemented as
>>
>>def setdefault(self, v):
>> self["SOME_DEFAULT_KEY_NAME"] = v
> 
> 
> if setdefault was implemented that way then all current uses of setdefault 
> would throw an exception.
> 
> setdefault takes *three* parameters: self, key, value. Once you include the 
> key parameter your entire argument implodes.

Yup. It does implode, leaving me thunderstruck because of my dumbness.

I rarely find things in python strange or named incorrectly, but this is 
IMHO such a case - setdefault led me to think that using it would set a 
default value to return for _future_ lookups of non-existant keys. That 
semantics is known in e.g. ruby or java.

I think a better name would be getdefault, or even get_setdefault - in 
oppposition to the get(key, d) form.

But now that this became clear to me... I guess I can live with the name :)

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


Re: Jargons of Info Tech industry

2005-10-13 Thread Mike Meyer
Brendan Guild <[EMAIL PROTECTED]> writes:
>> 2. flipping to a sender pays system so that the Internet does not
>> subsidise spam.
>
> This is very promising. Our ISPs should put limits on how much email we 
> can send. The limits should be rather insane, nothing that any 
> nonspammer would ever come close to, but low enough to stop spam dead. 
> If we want to send more than that, we'd better be charged extra.
>
> We could make each mail server responsible for the spam that it sends 
> out. It seems that currently mail servers are swamped and spending big 
> money on handling the vast loads of spam that gets pumped into them 
> from other mail servers, so I'm sure they wouldn't mind having a rule 
> like: Refuse to allow email to be transported from any server that 
> spews more than 50% spam. Servers could be audited occasionally to 
> check if they are spammers.

Except that lots of spam doesn't *go* through the ISPs server. It's
running on some Windows zombie, and delivering mail directly to the
recipients server. It'll only go through the ownee's mail server if
the ISP blocks outbound SMTP connections.

> I don't know exactly how spammers send spam, but a rule like that would 
> sure stop ISPs from allowing any one person to send a thousand emails a 
> day.

And that would work if spammers needed an ISPs permissions to send
email. But they don't.

 http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: FORM data in cgi

2005-10-13 Thread Mike Meyer
"jponiato" <[EMAIL PROTECTED]> writes:

> Greetings.
> An HTML form submits it's data to a python cgi script on my server. This 
> script accepts this POST data, and uses urllib.urlopen() to call a different 
> cgi script (on an external server), passing this same data. I'm using 
> cgi.FieldStorage() to create a mapping of the FORM data, then using 
> urllib.urlencode() to turn it back into form data for urlopen().
> Question - is there a more efficient way to do this?

Yes. But the question you should be asking is "Is there an easier way
to do it that's worth doing?"

Unless you're passing around files, or really huge forms, the amount
of time you spend doing decoding and encodinng the form data will be
pretty trivial. Unless you're really pressed for cycles, why bother
fixing it? And if you're really pressed for cycles, you should start
by instrumenting things to make sure that you're optimizing something
that will do you some good.

Anyway, the general idea is to skip cgi.FieldStorage, and parse the
request yourself. You'll have to deal with the headers. But you can
just grab the post data with a read(). I'm not sure you can use urllib
to send pre-encoded POST data; you'll have to check that yourself. If
not, you'll have to do the HTTP request processing by yourself. That's
not hard, though.

  http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: wxPython & Cygwin

2005-10-13 Thread Diez B. Roggisch
Gilles DRIDI wrote:
> Does someone has installed wxPython on the Cygwin platform, environment ?

Why? Use windows python, wxPython for it - and put it in your path to 
use it inside cygwin.

But maybe you _can_ compile it yourself - I didn't try, though.

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


Re: Yes, this is a python question, and a serious one at that (moving to Win XP)

2005-10-13 Thread Trent Mick
[John J. Lee wrote]
> 4. There's a registry key for tab completion somewhere...

Search for "CompletionChar" and change it to 9.

http://www.microsoft.com/resources/documentation/Windows/2000/server/reskit/en-us/Default.asp?url=/resources/documentation/Windows/2000/server/reskit/en-us/regentry/34995.asp


Cheers,
Trent

-- 
Trent Mick
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Well written open source Python apps

2005-10-13 Thread Peter Hansen
Ben wrote:
> Could anyone suggest an open source project that has particularly well
> written Python?  I am especially looking for code that people would
> describe as "very Python-ic".  (Not trying to start any kind of war -
> just wanted some good examples of a well written Python app to read.)

I'm sorry I can't speak on its "pythonicity" (my memory sucks), but I 
did find Roger Binns' BitPim program (http://bitpim.sourceforge.net/) to 
be an excellent source of ideas (steal steal steal) for wxPython code, 
and I do remember it struck me as being exceptionally well commented and 
well structured.  I suspect it's pretty Pythonic, too, since Roger seems 
pretty brilliant from where I sit. :-)

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


Re: UI toolkits for Python

2005-10-13 Thread John J. Lee
Kenneth McDonald <[EMAIL PROTECTED]> writes:
[...]
> both doing fairly well in general. I'm already aware of the licensing  
> issues surrounding qt (fwiw, I think their license fee for commercial  
> use is eminently reasonable), so aside from that, I was wondering if  
[...]

Qt 4 is available as GPL even on Windows.


John

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


Re: Jargons of Info Tech industry

2005-10-13 Thread Scott Ellsworth
In article <[EMAIL PROTECTED]>,
 Paul Rubin  wrote:

> Roedy Green <[EMAIL PROTECTED]> writes:
> > Next Mr. Phish had to present his passport etc when he got his Thawte
> > ID.  Now Interpol has a much better handle on putting him in jail.
> > He can't repudiate his phishing attempt.
> 
> Any underage drinker in a college town can tell you a hundred ways to
> get sufficient fake ID to get around that.

Most such jurisdictions get very excited, though, if that underage 
drinker kills someone while driving drunk.  Ofttimes, that gets _real_ 
police attention, rather than occasional bouncer investigation.

Make each recieved spam be worth a buck to the reciever, and the 
spammers/phishers/etc will be facing felony charges.  I suspect much of 
the spamming would stop.

Some, of course, would continue.  Pyramid schemes still get proposed, 
but their scope is much smaller.

Scott

-- 
Scott Ellsworth
[EMAIL PROTECTED]
Java and database consulting for the life sciences
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Yes, this is a python question, and a serious one at that (moving to Win XP)

2005-10-13 Thread John J. Lee
Kenneth McDonald <[EMAIL PROTECTED]> writes:
[...]
> absolutely preventing me from making the switch. Number one is the  
> lack of a decent command line and command-line environment, and I'm  
> wondering (hoping) if perhaps someone has written a "Python shell"-- 
> something that will look like a regular shell, let users type in  
> commands, maybe have some of the nice features of bash etc. like tab  
> completion, etc, and will then execute an underlying python script  
> when the command is entered. I'm not thinking of IDLE, but something  
> that is really aimed more at being a system terminal, not a Python- 
> specific terminal.
[...]

cmd.exe can be made bearable.  I just got a new machine, so I'll have
to do this myself in the next few days...

0. Make a shortcut to cmd.exe, stick it somewhere get-at-able,
   eg. quick launch toolbar

1. Somewhere under the menu reachable from the little icon in the
   top-left corner you can set the default directory when cmd is
   launched, plus there's some way to set up env vars (eg. PYTHONPATH)

2. Fiddle with buffers to make them sensible sizes (that menu again).

3. Adjust colours to taste (menu again).

4. There's a registry key for tab completion somewhere...

5. Make sure .py is associated with the Python you want


Also see IPython, which does do shell-ish things as well as python-ish
things.



John

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


Re: matching elements of numeric arrays

2005-10-13 Thread Robert Kern
[EMAIL PROTECTED] wrote:
> I have two one-dimensional Numeric arrays, and I need to know the
> indices in the second array of elements from the first.
> 
> so if i had:
> 
> a=array([2,4,6])
> b=array([2,3,4,5,6])
> 
> i want a function match that does this:
> 
> 
match(a,b)
> 
> array([0,2,4])
> 
> i have something that works, but it involves converting things to lists
> and using 'in', and it is rather slow. if someone could point me to a
> better solution, i would appreciate it.

If b is sorted, then you can use Numeric.searchsorted(b, a).

Otherwise:

In [28]: import Numeric as N

In [29]: a = N.array([2,4,6])

In [30]: b = N.array([2,3,4,5,6])

In [31]: match = N.equal.outer(a, b)

In [32]: idx = N.compress(N.sum(match), N.arange(len(b)))

In [33]: idx
Out[33]: array([0, 2, 4])


-- 
Robert Kern
[EMAIL PROTECTED]

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

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


Re: 1-liner to iterate over infinite sequence of integers?

2005-10-13 Thread Paul Rubin
Steven D'Aprano <[EMAIL PROTECTED]> writes:
> Others have given answers involving xrange() and itertools.count(), but I
> thought I'd just mention that in my opinion, what you have written is
> pretty elegant and concise and best of all, doesn't have the same problems
> xrange() and itertools.count() have when then hit maxint. Not everything
> needs to be a one-liner or a mysterious blackbox.

When you say "problems" with xrange or itertools.count hitting maxint,
the correct word is "bugs".  The right thing to do with library bugs
is fix them, not clutter up your application code to circumvent them.
xrange, at least, raises an error if you give it too large an
argument, but what itertools.count does is just plain dangerous.

I just opened SF bug 1326277 about itertools.count.
-- 
http://mail.python.org/mailman/listinfo/python-list


win32api.FindFiles Win2003, problem with Short Name

2005-10-13 Thread Frank Borell
I'm having a problem retrieving the ShortName from a file that was
written by a MAC and only from a Windows 2003 server.

I realize the file has a space after it, but I can retrieve the short
name from Windows XP and 2000;

>>>print win32api.FindFiles(process_source_dir + "*")

Excluding the results from "." and "..", it returns:
(32, , ,
, 0, 44118, 2974, 0, '10^2f16
Hardcover a ', '10^2F167.5AC') - All OK!!

When using the same command on Win2003, it returns:
, , 0,
44118, 2974, 0, '10^2f16 Hardcover a ', '')

The versions of Python / Win32 are the same on all servers.
Does anyone have any ideas?

Frank

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


Re: A problem while using urllib

2005-10-13 Thread John J. Lee
Steve Holden <[EMAIL PROTECTED]> writes:
[...]
>File "/usr/lib/python2.4/urllib2.py", line 996, in do_open
>  raise URLError(err)
> urllib2.URLError: 
> 
> Looking at that part of the course of urrllib2 we see:
> 
>  headers["Connection"] = "close"
>  try:
>  h.request(req.get_method(), req.get_selector(), req.data, 
> headers)
>  r = h.getresponse()
>  except socket.error, err: # XXX what error?
>  raise URLError(err)
> 
> So my conclusion is that there's something in the Cygwin socket module 
> that causes problems not seen under other platforms.
> 
> I couldn't find any obviously-related error in the Python bug tracker, 
> and I have copied this message to the Cygwin list in case someone there 
> knows what the problem is.
[...]

I don't *think* this is related, but just in case:

http://python.org/sf/1208304


John

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


Re: Send password over TCP connection

2005-10-13 Thread Paul Rubin
"dcrespo" <[EMAIL PROTECTED]> writes:
> Important data like diplomatic traffic. Must be accessible from all
> Clients inmediatly a client publish his data.  Its an online system.

OK, if it's actual diplomatic traffic you need to work with your
government about criteria.  If you're in the US, you'd get help from
the NSA.  This sounds more like business data.  It's pretty normal to
rely on your VPN.  That will probably be more secure than some
home-cooked protocol.  If it's highly sensitive then you should use
secure terminals (not PC's), hardware crypto tokens at the endpoints,
and so forth.  Please do read Ross Anderson's book, it sounds like you
really might need it.

Can I ask what country you are in?  Also, how is the data supposed to
get handled at the endpoints?  Is it something like text messages that
get displayed on a screen for someone to read?  Or something like
database updates?  Something like a cash dispenser network where the
leaf clients only make online queries (and maybe dispense cash) but
don't really store much data?

There are a lot of industry standards for different applications like
this.  You should follow one if you possibly can, even if you think
your own method is better.  There are two problems you have to
consider.  The first is how to make the system secure.  For that, you
should assume at this point that the people who designed the standards
knew what they were doing.  The second is what you'll tell the jury if
something goes wrong despite your best efforts.  For that, the best
thing you can tell them is "I followed the standard written by the
industry experts that represents the best knowledge in the field", and
almost the worst thing is "I thought I was smarter than the experts so
I used my own home-cooked method".  So in both areas, following
standards is the best policy.

> > Why do you want to do that?  All of them get compromised if the
> > one password is compromised.
> 
> How is it that all of them get compromised?

It sounded like you're using the same password on all the clients.
If not, then that helps.

> > so why do you need this password stuff at all?
> I don't want to permit anyone to run RPC functions. It's my desire.

I don't understand how the password stuff is related to RPC.  You
shouldn't have RPC ports open on the server.  
-- 
http://mail.python.org/mailman/listinfo/python-list


Profiling results

2005-10-13 Thread Dave
Hello All,

I'm trying to profile a Python program using gprof,
but I don't understand some of the results, especially
what some of the functions do. For example, _moncount,
mcount, _PyEval_EvalFrame  take too much
time. What are they for? Any ideas?

Thank you for your help! 





__ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 1-liner to iterate over infinite sequence of integers?

2005-10-13 Thread Erik Max Francis
Fredrik Lundh wrote:

> Neal Becker wrote:
> 
>> I can do this with a generator:
>>
>> def integers():
>> x = 1
>> while (True):
>> yield x
>> x += 1
>>
>> for i in integers():
>>
>> Is there a more elegant/concise way?
> 
> depends on your definition of "integers":
> 
> xrange(sys.maxint) # 0-based
> xrange(1, sys.maxint) # 1-based

The negative integers are being descriminated against!  I demand justice!

def integers():
yield 0
x = 1
while True:
yield x
yield -x
x += 1

... which is also not a bad demonstration of how the integers are 
countably infinite.

-- 
Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/
San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
   War can only be abolished through war, and in order to get rid of the
   gun it is necessary to take up the gun. -- Mao Zedong, 1898-1976
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python interpreter

2005-10-13 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, g.franzkowiak wrote:

> my interest is for the internals of the Python interpreter.
> 
> I've used up to now FORTH for something and this indirect interpreter is
>  very smart.
> --- ASM ---
> 
> NEXT:   LODSW   ; WA  <- [IP]
> ; IP  <- IP+2
> MOV T,WA; T   <- WA1 (CFA)
> JMP [T] ; JMP [CFA]
> 
> --- C -
> 
> for (;;)
>   {
>   w = *ip++;
>   (**w) ();
>}
> 
> -
> 
> Where can I find informations like this for Python ?

I don't really grok the assembler code.  The C code seems to assume that
there is an infinitive number of function pointers stored at `*ip`!?

The Python equivalent might be ::

  for w in ip:
w()

if `ip` is a (finite) sequence of functions or callables in general.

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


Re: 1-liner to iterate over infinite sequence of integers?

2005-10-13 Thread Steven D'Aprano
On Thu, 13 Oct 2005 13:31:13 -0400, Neal Becker wrote:

> I can do this with a generator:
> 
> def integers():
> x = 1
> while (True):
> yield x
> x += 1
> 
> for i in integers(): 
> 
> Is there a more elegant/concise way?

Others have given answers involving xrange() and itertools.count(), but I
thought I'd just mention that in my opinion, what you have written is
pretty elegant and concise and best of all, doesn't have the same problems
xrange() and itertools.count() have when then hit maxint. Not everything
needs to be a one-liner or a mysterious blackbox.

You could even modify your function to take start and step arguments:

def integers(start=1, step=1):
x = start
while True:
yield x
x += step

for odd in integers(step=2):
print odd

for even in integers(0, 2):
print even

etc.


-- 
Steven.

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


Re: UI toolkits for Python

2005-10-13 Thread Kenneth McDonald
This improved appearance has been a nice thing to see, but looks were never really the reason I decided to leave Tkinter. It's much more the fundamental issues of Tk, plus the fact that Tkinter was never really "completed" (not a comment on the original author--there's only so much one person can do) that has made me decide to leave Tk behind.As an example of the worst Tk issues (at least for what I was doing):1) Marks screw up when they come to occupy the position. For example, let's say { symbolizes a text mark with right gravity, and } a text mark with left gravity. Remember that marks all have names, so they can all be referred to uniquely. Now construct some text like this: {here} is {some}  marked {text}. Delete all the text. The marks still exist. Now, try to recreate the original text by inserting the appropriate words at the appropriate marks. It won't work for two reasons, the worst of which is that marks that come to occupy the same index in the text can actually change their relative order.2) There are no abstract references; everything is referred to by its string name. This causes serious problems with name clashes and code abstraction. Tkinter hides some of this, but not enough.3) Window nesting is completely determined by window naming, which only compounds the problem mentioned in (2).I don't really mean to diss Tk, I just get so frustrated when I think of what it could have been...Thanks,KenOn 13-Oct-05, at 4:02 PM, Mark Roseman wrote:People should probably be more aware of work that has been going on with  Tk recently (after a fairly long hiatus) in terms of greatly improving  its appearance, adding theming, and more.  It's worth checking out, and  of course, if there's a way to help get some of these changes into  Tkinter, the Tk folks would I'm sure be helpful.   Here's a portion of a note that Jeff Hobbs posted to the Ruby group  recently, on a similar topic:  -- 
http://mail.python.org/mailman/listinfo/python-list

Re: matching elements of numeric arrays

2005-10-13 Thread Claudio Grondi
<[EMAIL PROTECTED]> wrote in
news:[EMAIL PROTECTED]
> I have two one-dimensional Numeric arrays, and I need to know the
> indices in the second array of elements from the first.
>
> so if i had:
>
> a=array([2,4,6])
> b=array([2,3,4,5,6])
>
> i want a function match that does this:
>
> >>> match(a,b)
> array([0,2,4])
>
> i have something that works, but it involves converting things to lists
> and using 'in', and it is rather slow. if someone could point me to a
> better solution, i would appreciate it.

I have no idea about Numeric array module, so I will use
the built-in Python one for it (how about the speed if
compared to Numeric arrays?):

from array import array
a = array('I', [2,4,6])
b = array('I', [2,3,4,5,6])

def match(a,b):
  retVal = array('I')
  for item in a:
retVal.append(b.index(item))
  return retVal

print a
print b
print str(match(a,b))

Outputs:

array('I', [2L, 4L, 6L])
array('I', [2L, 3L, 4L, 5L, 6L])
array('I', [0L, 2L, 4L])

Claudio


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


Re: Send password over TCP connection

2005-10-13 Thread dcrespo
> Well, I mean, what kind of data is it?  Sports chat?  Personal 
> correspondence?  Financial info like credit card numbers?  Medical records?  
> Military/diplomatic traffic?  I'm asking how severe the security requirements 
> are.

Important data like diplomatic traffic. Must be accessible from all
Clients inmediatly a client publish his data. Its an online system.

> Why do you want to do that?  All of them get compromised if the one password 
> is compromised.

How is it that all of them get compromised?

> What do you mean by "password"?  If it's not something a user has to remember 
> and type in, then I hope you mean a long random string rather than a 
> password.  I sort of remember your mentioning this though.

With 'password' I meant simply a string to log in.

> so why do you need this password stuff at all?

I don't want to permit anyone to run RPC functions. It's my desire.

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


Re: Python's garbage collection was Re: Python reliability

2005-10-13 Thread Paul Rubin
"Diez B. Roggisch" <[EMAIL PROTECTED]> writes:
> > Yes, that would describe just about every cpu for the past 30 years
> > that's a plausible Python target.
> 
> No. The later 68K (>68020) could address on odd adresses. And AFAIK
> all x86 can because of their 8080 stemming.

Yes, "could" but not "does" in terms of what any reasonable actual
compiler implmementations do.  You get a huge performance hit for
using unaligned data.  The one exception is you could conceivably have
character strings starting at odd addresses but it's no big deal to
start them all on 4-byte (or even 2-byte) boundaries.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python's garbage collection was Re: Python reliability

2005-10-13 Thread Diez B. Roggisch
> Yes, that would describe just about every cpu for the past 30 years
> that's a plausible Python target.

No. The later 68K (>68020) could address on odd adresses. And AFAIK all 
x86 can because of their 8080 stemming.

Don't confuse this with 16Bit aligned addressing - _that_ is the minimum 
for years, and of course doing something like

move.l #1, d0   // move 4 byte ad immediate address 1 into data register 0

is a nightmare on runtime - but working, nontehless.

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


Re: Send password over TCP connection

2005-10-13 Thread Paul Rubin
"dcrespo" <[EMAIL PROTECTED]> writes:
> > Can you say what your application is?  That will help figure out
> > how far you need to go to protect these passwords, and what
> > alternatives might be possible.
> 
> Sure, no problem (see this on fixed text):

Well, I mean, what kind of data is it?  Sports chat?  Personal
correspondence?  Financial info like credit card numbers?  Medical
records?  Military/diplomatic traffic?  I'm asking how severe the
security requirements are.

> All ClientServers log in supplying only one hashed password. It is
> hashedly stored in MasterServer.

Why do you want to do that?  All of them get compromised if the one
password is compromised.  What do you mean by "password"?  If it's not
something a user has to remember and type in, then I hope you mean a
long random string rather than a password.  I sort of remember your
mentioning this though.

> All this is sustented over a VPN.

If the VPN is any good, it should authenticate all the peers in some
reasonable way, so why do you need this password stuff at all?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Send password over TCP connection

2005-10-13 Thread dcrespo
> Can you say what your application is?  That will help figure out how far you 
> need to go to protect these passwords, and what alternatives might be 
> possible.

Sure, no problem (see this on fixed text):


 ___ MasterServer ___
/// ||   | \\\
ClientServer ClientServer ClientServer
  //\\ //\\//  \\
   Client  Client   Client  Client   Client  Client

// = XML-RPC connection
/  = Pure TCP connection

Clients, connects to MasterServer through ClientServer using XML-RPC
ClientServer interacts with MasterServer using 2 modes: XMLRPC and pure
TCP.

Pure TCP connection is used for athenticating ClientServer. When a
ClientServer is authenticated,
the ClientServers can connect to MasterServer for running RPC functions
requested by its Clients.

All ClientServers log in supplying only one hashed password. It is
hashedly stored in MasterServer.

The way I elected to log in is:
-Generate an MD5 string from a Random Alpha_Numeric string on
ClientServer side
-Generate another MD5 string from a Random Alpha_Numeric string on
MasterServer side
-Send each string from one host to the other.
-Apply a Hash algorithm using both MD5 in conjunction with the
password that each one knows.
-Then, the ClientServer sends its resulting hashed string to
MasterServer
-MasterServer then compares its own resulting hashed string with
the one received from ClientServer

ClientServer logs in if:
- IP's ClientServer is not a Blocked IP by MasterServer
- IP's ClientServer is in an Allowed IP Range
- hashed strings match

All this is sustented over a VPN.

Suggestions are welcomed

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


Re: Jargons of Info Tech industry

2005-10-13 Thread Paul Rubin
[EMAIL PROTECTED] (Gordon Burditt) writes:
> I'm not sure that you can disable Javascript from reading cookies
> from other sites while allowing Javascript to read cookies from the
> site it came from on all browsers.

Javascript is not supposed to be able to read cross-site cookies.
It's bad but it's not THAT bad.  There was an MSIE bug that allowed
reading other sites' cookies but it was correctly considered a
horrendous security breach and it was fixed quickly after discovery.
It caused a big fire drill where I was working at the time of the
incident.  We had to write a special ActiveX control to protect our
cookie info until the browser patch went out.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Jargons of Info Tech industry

2005-10-13 Thread Gordon Burditt
>> Does the language allow Javascript to open a new window?  Does the
>> language allow Javascript to trigger a function when a window is
>> closed?  I believe the answer to both questions is YES.  Then it
>> is possible to have a page that pops up two windows whenever you
>> close one.
>
>This was a problem, but modern browsers implement Javascript in such a 
>way that it requires permission from the user before it will open a new 
>window.

An infinite loop of asking permission is *ALSO* a denial-of-service
attack.  And I don't believe that the limitation applies in all
circumstances.  This seems to be a feature of the *language*, not
only the implementation.

>> If it can reveal my email address to any web site, it's a bug.  If
>> it can access or alter my personal files or address book, it's a
>> bug.  If it can generate hits on web sites other than that specified
>> in the HTML, it's a bug.  If it can open sockets, it's a bug.
>> If it can look at or set cookies stored on my system, it's a bug.
>> If it can look at or alter the list of previously visited URLs, it's
>> a bug.
>
>All of those things seem like major problems except the bit about 
>cookies. What possible harm can reading and setting cookies do? I had 

Javascript may be able to set cookies even if they are turned off
by the normal mechanism of setting cookies.  Even if that isn't the
case, cookies are supposed to be domain-specific and a cookie from
site A (which might have a session ID for an active login session, or
login credentials for site A) should not be sent to site B.  Javascript
can apparently make its own URLs and send anything it gets its hands
on to any site it wants to.

The existence of a cookie from site A shouldn't be revealed at all
to site B (or to Javascript from site B), regardless of what it
contains.

>always thought they were carefully and successfully designed to be 
>harmless. That's not personal information in your cookies. That 

Some websites *DO* put personal information in cookies.  They don't
all just use randomized session identifiers.  Some of them store
login credentials for a site (not just a currently active session,
but permanent login credentials.  That might not be "personal" the
same way a SSN or credit card number is, but you could still do
damage with it).  A lot of the popularity of Javascript comes from
the ability to steal information from the client computer that
normal HTML does not give access to (e.g.  screen/window size, email
address, IP address as seen by the client (because of NAT and
proxies, might not be the same IP as seen by the server), MAC
address, browsing history, Windows serial number, Pentium CPU serial
number, etc.)

>information is set by websites for the sole purpose of being read by 
>websites. 

*BY THE WEBSITES THAT SET THEM*, not by all websites.  The "domain"
parameter for setting cookies has been in there since the beginning
of the standard for cookies.

If a marketer wants a piece of information, then I don't want him
to have it, even if it's something like "I visited  and
then went to " even if there's no identification of who "I"
is.

>Plus, I'm pretty sure that browsers have always allowed us to 
>disable cookies.

I'm not sure that you can disable Javascript from reading cookies
from other sites while allowing Javascript to read cookies from the
site it came from on all browsers.

Gordon L. Burditt
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python adodb

2005-10-13 Thread gt182
Thank you everyone for your posts. Listed below is the correct code,
solution reached. And to include the username and password you can
simply inter it behind Persist Security devieded off with semicolons.







con = win32com.client.Dispatch(r'ADODB.Connection')
DSN = r'Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\test.mdb;Mode=ReadWrite;Persist Security Info=False'
con.Open(DSN)

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


Re: UI toolkits for Python

2005-10-13 Thread Grant Edwards
On 2005-10-13, Paul Rubin <> wrote:

> The answer to each of those questions points to Tkinter.  It comes
> with Python by default (the least installation hassles of any
> toolkit), is pretty reliable, has a reasonably Pythonic interface, and
> I don't understand the question about external libraries.
>
> However, Tkinter not most people's favorite, because the widgets look
> crude, they don't resemble the native widgets of any popular platform,
> and the widget set is somewhat limited.

Aside from the look & feel issue with Tk, the other objection
sometimes heard is that Tk is integrated into Python by
including Tcl as well (as opposed to doing an actual Tk binding
the way some other languages have done).  It's an eminently
practical approach, but it sure makes you feel dirty.

-- 
Grant Edwards   grante Yow!  Hey!! Let's watch
  at   the' ELEVATOR go UP and
   visi.comDOWN at th' HILTON HOTEL!!
-- 
http://mail.python.org/mailman/listinfo/python-list


matching elements of numeric arrays

2005-10-13 Thread daniel . neilson
I have two one-dimensional Numeric arrays, and I need to know the
indices in the second array of elements from the first.

so if i had:

a=array([2,4,6])
b=array([2,3,4,5,6])

i want a function match that does this:

>>> match(a,b)
array([0,2,4])

i have something that works, but it involves converting things to lists
and using 'in', and it is rather slow. if someone could point me to a
better solution, i would appreciate it.

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


ANNOUNCE: Python interface for making telephone calls using Voicent Gateway

2005-10-13 Thread andrew
The Voicent Python Simple Interface class contains the following
functions.

callText
callAudio
callStatus
callRemove
callTillConfirm

These functions are used to invoke telephone calls from your Python
program. For example, callText is used to call a specified number and
automatically play your text message using text-to-speech engine.

In order for this class to work, you'll need to have Voicent Gateway
installed somewhere in your network. This class simply sends HTTP
request for telephone calls to the gateway. Voicent has a free edition
for the gateway. You can download it from http://www.voicent.com

More information can be found at:
http://www.voicent.com/devnet/docs/pyapi.htm

Thank you and have fun

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


Nufox examples hosted :-)

2005-10-13 Thread Salvatore
Hello,

I've been kindly authorized to host Nufox examples for free on :
http://bsd.miki.eu.org:9090/

Regards

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


Nufox hosted.

2005-10-13 Thread Salvatore
Hello,

I've been kindly authorized to host Nufox examples for free on :
http://bsd.miki.eu.org:9090/

Regards

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


Re: Yes, this is a python question, and a serious one at that (moving to Win XP)

2005-10-13 Thread Claudio Grondi
What I can point you to is not Python, but embedding it in Python
is a question of executing one line of Python code triggering its
execution.
I think you will be fascinated by its features and ease of use and
how well it is suited to fit into your needs:
  http://www.autoitscript.com/autoit3/index.php
With it you will start to see, that forcing to obey to Windows way
of doing things has not only bad sides.

Is there something similar for another OSs-es (especially Linux)?

Claudio

"Kenneth McDonald" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
news:[EMAIL PROTECTED]
> For unfortunate reasons, I'm considering switching back to Win XP
> (from OS X) as my "main" system. Windows has so many annoyances that
> I can only compare it to driving in the Bay Area at rush hour (OS X
> is like driving in Portland at rush hour--not as bad, but getting
> there), but there are really only a couple of things that are really,
> absolutely preventing me from making the switch. Number one is the
> lack of a decent command line and command-line environment, and I'm
> wondering (hoping) if perhaps someone has written a "Python shell"-- 
> something that will look like a regular shell, let users type in
> commands, maybe have some of the nice features of bash etc. like tab
> completion, etc, and will then execute an underlying python script
> when the command is entered. I'm not thinking of IDLE, but something
> that is really aimed more at being a system terminal, not a Python-
> specific terminal.
>
> Yes, I know that Cygwin is out there, but last I looked, they still
> went through the Win command-line window, which imposes a lot of
> restrictions.
>
> More generally, has anyone written any python programs to administer
> various Win settings for which one must otherwise delve deep into
> mazes of twisty little dialogs, all alike? Or to help out with other
> annoyances? I know there are a lot of general utilities, but if
> they're in Python, I can also use them as a starting base for my own
> needs.
>
> Finally, a significant incentive in doing this is that I could avoid
> a lot of installation hassle, since virtually everything has at least
> a decent installation package for Win. (I'd hoped this would happen
> for OS X, but it never has). Can anyone think of important python-
> related packages (release level, not cutting edge alphas) for which
> this might not be the case?
>
> Many thanks,
> Ken


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


Re: UI toolkits for Python

2005-10-13 Thread Mark Roseman
 Paul Rubin  wrote:
> However, Tkinter not most people's favorite, because the widgets look
> crude, they don't resemble the native widgets of any popular platform,
> and the widget set is somewhat limited.


People should probably be more aware of work that has been going on with 
Tk recently (after a fairly long hiatus) in terms of greatly improving 
its appearance, adding theming, and more.  It's worth checking out, and 
of course, if there's a way to help get some of these changes into 
Tkinter, the Tk folks would I'm sure be helpful. 

Here's a portion of a note that Jeff Hobbs posted to the Ruby group 
recently, on a similar topic:


> From: Jeff Hobbs <[EMAIL PROTECTED]>
> Subject: Re: The definitive GUI for Ruby
> Date: Wed, 05 Oct 2005 11:02:46 -0700
> Newsgroups: comp.lang.ruby
> Message-ID: <[EMAIL PROTECTED]>
>
> Eustaquio Rangel de Oliveira J wrote:
> > Tk is still too ugly for make programmers that are
> > migrating. :-)
>
> Tk is only ugly if that's the way you like it.  You have a
> full set of themed widgets available now that give you
> native look and feel, with all the same dynamic control and
> general ease of use that Tk has always provided.  All this
> on Aqua, Win32 and X11 (even Windows/CE).  Some screenshots
> of Tk apps that try not to be ugly:
>
> The Perl Dev Kit and Tcl Dev Kit UIs:
> http://aspn.activestate.com/ASPN/docs/PDK/6.0/PerlApp_gui.html#perlapp_gui_configuring_perlapp_build_parameters
> http://aspn.activestate.com/ASPN/docs/Tcl_Dev_Kit/3.2/TclVFSE.html
>
> Tk on Win/CE (I know that the Perl/Tcl::Tk use this too):
> http://wiki.tcl.tk/8442
>
> Coccinella:
> http://hem.fyristorg.com/matben/
> http://hem.fyristorg.com/matben/examples/index.html
>
> An installer builder:
> http://installbase.sourceforge.net/screenshots.shtml
>
> An example of improving a Tk app by "going native":
> http://wiki.tcl.tk/14522
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Info] PEP 308 accepted - new conditional expressions

2005-10-13 Thread Dave Hansen
On Thu, 13 Oct 2005 21:49:15 +0200, Piet van Oostrum <[EMAIL PROTECTED]>
wrote:

>> [EMAIL PROTECTED] (Dave Hansen) (DH) wrote:
>
>>DH> So lose the "if."
>
>>DH>R = C then A else B
>
>>DH> I don't think python uses the question mark for anything.  Throw that
>>DH> in, if it makes parsing easier:
>
>>DH>R = C ? then A else B
>
>We have already had this discussion several times. I don't think it is
>going to add anything new to it. Besides after the BDFL has decided it is
>useless. 

Oh, agreed, most assuredly (except that "we" didn't include "me," not
that that would have made any difference, but I missed most of the
discussion).  I was merely responding to your assertion that using "if
C then A else B" could cause parsing problems.

I'm not convinced python even needs a ternary operator.  I just wish
the syntax chosen by the BDFL made more sense.  Even if I don't use
it, I'll likely have to read it...

Regards,

   -=Dave
-- 
Change is inevitable, progress is not.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: extract PDF pages

2005-10-13 Thread Larry Bates
I've used ReportLab's PageCatcher.  It isn't free, but
I've gladly paid for the functionality it gives me.

Larry Bates

http://www.reportlab.com/pagecatcher_index.html


David Isaac wrote:
> While pdftk is awesome
> http://www.accesspdf.com/pdftk/
> I am looking for a Python solution.
> Just for PDF page extraction.
> Any hope?
> 
> Thanks,
> Alan Isaac
> 
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Send password over TCP connection

2005-10-13 Thread Paul Rubin
"dcrespo" <[EMAIL PROTECTED]> writes:
> Ok, I understand... What about the MD5? Is it good enough to use when
> saving a hashed password on the database?
> 
> For example:
> user_input = raw_input("Type your password: ")
> password = md5.md5(user_input).hexdigest()
> SavePasswordInDatabase(user,password)

The usual way to do it is something more like:

   import os,binascii
   salt = binascii.b2a_base64(os.urandom(6))[:6]
   user_input = raw_input("Type your password: ")
   password = md5.md5(salt + user_input).hexdigest()
   SavePasswordInDatabase(user,salt,password)

The random salt slows down offline dictionary attacks against the
database.  Say you have 1000 accounts on your system and the attacker
needs just one password to log in and mess with stuff.  With your
scheme, he hashes each word in a large dictionary (say a million
words), sorts on the hash values, sorts your hashed password list on
its hash values, then compares the two sorted lists and if there's
even one match, you're cooked.  Each hash he computes can be compared
against all your accounts in parallel.  The salt means he has to do
them one by one, slowing him down by a factor of 1000.  However,
computers are now fast enough that dictionary attacks against every
single password are a serious threat.

If you have a way of storing a secret key K, then rather than using
unkeyed md5(whatever), use hmac(K, whatever).  But revealing K
effectively turns the hmac into an unkeyed hash.

Can you say what your application is?  That will help figure out how
far you need to go to protect these passwords, and what alternatives
might be possible.  

I highly recommend the book "Security Engineering" by Ross Anderson
for a good cultural introduction to what you're getting into when you
program this stuff.  It's a fun book to read, too.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: UI toolkits for Python

2005-10-13 Thread Michael Ekstrand
On Thursday 13 October 2005 15:17, Kenneth McDonald wrote:
> 1) Which plays best with Python? Ideally, it would already have some
> higher-level python libraries to hide the grotty stuff that is almost
> never needed when actually implementing apps.

wxPython plays reasonably well.

I've just started playing with PyGTK+glade, and am highly impressed with 
that.

> 4) Ease of installation/use on OS X?

Ease of installation and use, wxPython is good. General OS X goodness, 
wxPython has been exhibiting highly weird behavior. Plus some useful 
widgets don't work well (if at all) on Mac.

wxWidgets also feels very old-Windows-ish. For example, it's built 
around having 1 toolbar for a window; for my application, that's not 
going to work so well, and I'm also having issues with some things 
related to dynamically creating toolbars and changing the toolbar.

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


Re: Send password over TCP connection

2005-10-13 Thread Michael Ströder
dcrespo wrote:
> 
> Ok, I understand it. What about the MD5? Is it good enough to use when
> saving a hashed password on the database?
> 
> For example:
> user_input = raw_input("Type your password: ")
> password = md5.md5(user_input).hexdigest()
> SavePasswordInDatabase(user,password)

It would be better to use salted SHA-1.

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


Re: Well written open source Python apps

2005-10-13 Thread Micah Elliott
On Oct 13, Grig Gheorghiu wrote:
> This is really synchronicity in action! I started to think yesterday
> about putting together a project that measures the 'goodness' of Python
> packages in the PyPI Cheese Shop repository. I call it the "Cheesecake"
> project. I took the liberty of citing Micah's post in a blog entry that
> I just posted:
> 

Grig, I think you're onto something here; good idea.  I have no
experience with CPANTS, and I'm not sure how many of my ideals could be
checked programmatically.  But if your Cheesecake tool comes into
fruition, here are some things that I would personally find useful:

* A command-line version that I could easily run on my projects.

* An output that gives more than just an index/score; maybe a bunch of
  stats/indicators like pylint.  I.e., it would be say "pypkglint" or
  "pydistchecker", a higher level lint that operates on packages instead
  of just source files.

* Some checks that might be useful

   - Module and package naming conventions. (PEP-8 describes
 module-naming, but I see this broken more often than followed in
 practice.  And it is silent on package names, but the tutorial uses
 capitalized names.)  Some consistency here would be nice.

   - Existence of standard files.  ESR goes into detail on this in his
 "Art of UNIX Programming" book (pp 452).

   - Existence of standard directories (those I mentioned before).

   - Output of checkee "--help" should satisfy some standards.  I presently
 check my own tools by running "help2man" which forces me to setup
 optparse to follow a strict format.  I have some active RFEs on
 optik (optparse) to address this.

   - Use of distutils.  Maybe just a check for setup.py ?

   - Consistency of module length.  Not sure about this one, but you
 might lower the score if some package modules are 10 lines while
 others are 10KLOC.

   - Number of modules per package.  Maybe 4..20 is a good amount?

   - Extra points for existence of something like "api.html", which
 indicates that epydoc/pydoc generated API info.

   - Extra points for .svn/CVS/RCS directories indicating that version
 control is in place.  Maybe even glarking of version numbers where
 high numbers indicate that code is checked in frequently.

   - Use of ReST in documentation, or even in docstrings.

   - Count of unit tests.  Do module names map to test_ in
 test directory?  How many testXXX functions exist?

   - A summary calculation of pylint/pychecker scores for each module.

   - Point deduction (or fail!) if any .doc/.xls, etc. files included in
 distribution.

   - Extra points for use of modules that indicate extra usability was
 incorporated, such as: gettext (multi-language), optparse (clean
 UI), configparser (fine control), etc.

* A PEP describing the conventions (though some will argue that PEPs
  should be enforcable by the compiler, so maybe just a "Cheesecake
  Convention" document).

* And of course anything that CPANTS offers :-)

I'm sure people here have more ideas for quality indicators...

-- 
Micah Elliott
<[EMAIL PROTECTED]>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: UI toolkits for Python

2005-10-13 Thread Kenneth McDonald
Thanks for reminding me of Gtk. OK, add that to the list.

The Web Browser interface is good for simple things, and will get better
with CSS2's adoption, but they still don't have a good way for important
things like interactive styled text, key bindings, etc. Good for  
simple things
(for which I use them), not for more complex stuff.

As for Tkinter, well, sigh, I have to go into a semi-rant, semi- 
eulogy right now.

Tk was, IMHO, the hands-down award winner for UI toolkit farthest  
ahead of
its time. I used it for years and years and years.

Tcl, on the other had, wasn't the _worst_ scripting language of all  
time, but it
was sure down in the bottom ten percent. How John Ousterhout could  
come up
with Tk on one hand and the other at the same Tcl boggles my mind.

Unfortunately, while Tkinter did provide in theory full access to Tk,  
it was in
practice never finished. I wrote quite a bit of code to try to add a  
true pythonic
interface to Tk via Tkinter (I'm happy to give it away if anyone  
wants--some of
it is actually in pretty good shape). But it's a big job, and it  
became clear to me
that Tk is going the way of the dinosaurs, so I abandoned it.

Ddevelopment on the advanced features of Tk--what really made it worth
using--has languished. Both marks and tags in the Text widget have been
fundamentally broken forever (not buggy, I mean broken in the sense that
their semantics destroys a great deal of their real potential), and I  
don't see
they'll ever be fixed. Same thing with tags in the Canvas widget.  
Plus the
lack of well-thought-out new widgets, and various other sins of omission
and comission, and I decided that Tkinter was clearly in the last of  
its days.

That said, if I was one of the founders of Google, Tk would be one of  
the
projects I'd hire a lot of people to get on to and actually realize  
its potential.
But I don't even buy lottery tickets :-)

Now I'm just waiting until one of the other kits becomes mature enough
(if ever) to start using it. So this is a query about that :-)
On 13-Oct-05, at 3:21 PM, Paul Rubin wrote:

> Kenneth McDonald <[EMAIL PROTECTED]> writes:
>
>> 1) Which plays best with Python? Ideally, it would already have some
>> higher-level python libraries to hide the grotty stuff that is almost
>> never needed when actually implementing apps.
>>
>> 2) Reliability of each?
>>
>> 3) Useful external libraries for each?
>>
>> 4) Ease of installation/use on OS X?
>>
>
> The answer to each of those questions points to Tkinter.  It comes
> with Python by default (the least installation hassles of any
> toolkit), is pretty reliable, has a reasonably Pythonic interface, and
> I don't understand the question about external libraries.
>
> However, Tkinter not most people's favorite, because the widgets look
> crude, they don't resemble the native widgets of any popular platform,
> and the widget set is somewhat limited.
>
> That suggests you're not asking the right questions.
>
> I use Tkinter because the Python gui's I've built so far have been for
> straightforward functionality purposes without being fancy.  However,
> if I were doing something for wide distribution and wanted it to look
> sharp, at this point I think I'd go for PyGtk despite the preference
> of many for wxpython.
>
> Finally, don't overlook the possibility of embedding a basic web
> server in your app, and having the user communicate with it through a
> web browser.  That turns HTML into your gui, which is very easy to
> program.  It also lets you easily handle remote clients, multiple
> concurrent clients, etc, and gives users a familiar and intuitive
> interface.
> -- 
> http://mail.python.org/mailman/listinfo/python-list
>

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


Re: Jargons of Info Tech industry

2005-10-13 Thread Paul Rubin
Brendan Guild <[EMAIL PROTECTED]> writes:
> This was a problem, but modern browsers implement Javascript in such a 
> way that it requires permission from the user before it will open a new 
> window.

Not really true, it's easy to defeat that, and also generally the
pop-up blocker only blocks window.open on load events.  JS can usually
still open windows when you mouse over something.

> All of those things seem like major problems except the bit about 
> cookies. What possible harm can reading and setting cookies do? I had 
> always thought they were carefully and successfully designed to be 
> harmless. That's not personal information in your cookies. That 
> information is set by websites for the sole purpose of being read by 
> websites.

If you have a cookie from site ABC on your system, that shows you
visited site ABC sometime in the past.  That is personal information
all by itself, that shouldn't be revealed (including to site ABC)
without your permission.  And that doesn't even begin to address web
bugs.

If the JS from site ABC can also read cookies set by unrelated site
XYZ, that's an absolute disaster.  It can steal login credentials and
anything else.  MSIE actually had a bug of that type a few years ago.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Yes, this is a python question, and a serious one at that (moving to Win XP)

2005-10-13 Thread Jeremy Jones
Kenneth McDonald wrote:

>For unfortunate reasons, I'm considering switching back to Win XP  
>(from OS X) as my "main" system. Windows has so many annoyances that  
>I can only compare it to driving in the Bay Area at rush hour (OS X  
>is like driving in Portland at rush hour--not as bad, but getting  
>there), but there are really only a couple of things that are really,  
>absolutely preventing me from making the switch. Number one is the  
>lack of a decent command line and command-line environment, and I'm  
>wondering (hoping) if perhaps someone has written a "Python shell"-- 
>something that will look like a regular shell, let users type in  
>commands, maybe have some of the nice features of bash etc. like tab  
>completion, etc, and will then execute an underlying python script  
>when the command is entered. I'm not thinking of IDLE, but something  
>that is really aimed more at being a system terminal, not a Python- 
>specific terminal.
>  
>
ipython -p pysh

IPython rocks as a Python shell.  I use zsh mostly, but IPython's pysh 
looks pretty good.  I hate to help you get back on Windows, though :-)


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


Re: Send password over TCP connection

2005-10-13 Thread dcrespo
> Do you know how any other system manages to do this?  Linux, for example 
> assuming  properly configured system)?  The passwords aren't stored: hashes 
> of the passwords are stored (with additional things thrown in to prevent 
> certain kinds of attacks even if someone nabs the password (/etc/shadow) 
> file).  If you store the password or even encrypt it (i.e. something that can 
> be reversed if someone knows the key), it's a risk.

Ok, I understand it. What about the MD5? Is it good enough to use when
saving a hashed password on the database?

For example:
user_input = raw_input("Type your password: ")
password = md5.md5(user_input).hexdigest()
SavePasswordInDatabase(user,password)

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


Re: Send password over TCP connection

2005-10-13 Thread dcrespo
Ok, I understand... What about the MD5? Is it good enough to use when
saving a hashed password on the database?

For example:
user_input = raw_input("Type your password: ")
password = md5.md5(user_input).hexdigest()
SavePasswordInDatabase(user,password)

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


Yes, this is a python question, and a serious one at that (moving to Win XP)

2005-10-13 Thread Kenneth McDonald
For unfortunate reasons, I'm considering switching back to Win XP  
(from OS X) as my "main" system. Windows has so many annoyances that  
I can only compare it to driving in the Bay Area at rush hour (OS X  
is like driving in Portland at rush hour--not as bad, but getting  
there), but there are really only a couple of things that are really,  
absolutely preventing me from making the switch. Number one is the  
lack of a decent command line and command-line environment, and I'm  
wondering (hoping) if perhaps someone has written a "Python shell"-- 
something that will look like a regular shell, let users type in  
commands, maybe have some of the nice features of bash etc. like tab  
completion, etc, and will then execute an underlying python script  
when the command is entered. I'm not thinking of IDLE, but something  
that is really aimed more at being a system terminal, not a Python- 
specific terminal.

Yes, I know that Cygwin is out there, but last I looked, they still  
went through the Win command-line window, which imposes a lot of  
restrictions.

More generally, has anyone written any python programs to administer  
various Win settings for which one must otherwise delve deep into  
mazes of twisty little dialogs, all alike? Or to help out with other  
annoyances? I know there are a lot of general utilities, but if  
they're in Python, I can also use them as a starting base for my own  
needs.

Finally, a significant incentive in doing this is that I could avoid  
a lot of installation hassle, since virtually everything has at least  
a decent installation package for Win. (I'd hoped this would happen  
for OS X, but it never has). Can anyone think of important python- 
related packages (release level, not cutting edge alphas) for which  
this might not be the case?

Many thanks,
Ken
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: UI toolkits for Python

2005-10-13 Thread Paul Rubin
Kenneth McDonald <[EMAIL PROTECTED]> writes:
> 1) Which plays best with Python? Ideally, it would already have some
> higher-level python libraries to hide the grotty stuff that is almost
> never needed when actually implementing apps.
> 
> 2) Reliability of each?
> 
> 3) Useful external libraries for each?
> 
> 4) Ease of installation/use on OS X?

The answer to each of those questions points to Tkinter.  It comes
with Python by default (the least installation hassles of any
toolkit), is pretty reliable, has a reasonably Pythonic interface, and
I don't understand the question about external libraries.

However, Tkinter not most people's favorite, because the widgets look
crude, they don't resemble the native widgets of any popular platform,
and the widget set is somewhat limited.

That suggests you're not asking the right questions.

I use Tkinter because the Python gui's I've built so far have been for
straightforward functionality purposes without being fancy.  However,
if I were doing something for wide distribution and wanted it to look
sharp, at this point I think I'd go for PyGtk despite the preference
of many for wxpython.  

Finally, don't overlook the possibility of embedding a basic web
server in your app, and having the user communicate with it through a
web browser.  That turns HTML into your gui, which is very easy to
program.  It also lets you easily handle remote clients, multiple
concurrent clients, etc, and gives users a familiar and intuitive
interface.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Jargons of Info Tech industry

2005-10-13 Thread Brendan Guild
Gordon Burditt wrote in
news:[EMAIL PROTECTED]: 

> Does the language allow Javascript to open a new window?  Does the
> language allow Javascript to trigger a function when a window is
> closed?  I believe the answer to both questions is YES.  Then it
> is possible to have a page that pops up two windows whenever you
> close one.

This was a problem, but modern browsers implement Javascript in such a 
way that it requires permission from the user before it will open a new 
window.

> If it can reveal my email address to any web site, it's a bug.  If
> it can access or alter my personal files or address book, it's a
> bug.  If it can generate hits on web sites other than that specified
> in the HTML, it's a bug.  If it can open sockets, it's a bug.
> If it can look at or set cookies stored on my system, it's a bug.
> If it can look at or alter the list of previously visited URLs, it's
> a bug.

All of those things seem like major problems except the bit about 
cookies. What possible harm can reading and setting cookies do? I had 
always thought they were carefully and successfully designed to be 
harmless. That's not personal information in your cookies. That 
information is set by websites for the sole purpose of being read by 
websites. Plus, I'm pretty sure that browsers have always allowed us to 
disable cookies.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Jargons of Info Tech industry

2005-10-13 Thread Terry Hancock
On Wednesday 12 October 2005 04:37 pm, Roedy Green wrote:
> It is a bit like termites. If we don't do something drastic to deal
> with spam, the ruddy things will eventually make the entire Internet
> unusable.
> 
> the three keys to me are:
> 
> 1. flipping to a digital id based email system so that the sender of
> any piece of mail can be legally identified and prosecuted.
> If every piece of anonymous email disappeared that would go a long way
> to clearing up spam.  Let those sending ransom notes, death threats
> and  hate mail use snail mail.  As a second best, correspondents are
> identified by permission/identity/encryption keys given to them by
> their recipients.

Well, that certainly won't accomplish much -- not without a world
government, anyway. Much (maybe most) of the spam I receive is
international (from Russia, Japan, Southeast Asia, the Middle East,
Africa, even the Phillipines).  Most of it is also already illegal,
so new legislation will certainly make no difference.

The only thing you buy with an authentication system is that you
can filter out the problems at the ISP or on the uploading side,
thus saving a lot of bandwidth. But it would have to be very widely
accepted to actually reduce spamming.

Now, of course, spammers are also hitting web forms and blogs and
other protocols besides e-mail.

> 2. flipping to a sender pays system so that the Internet does not
> subsidise spam.

Then I won't be posting on the Python list anymore, I can assure you.
This would chill a lot of the purposes for which email is ideal.

> 3. Mail is not transported without prior permission.  The receiver can
> turn that permission on and off any time he chooses.  This is
> basically an automated version of what Zaep does where the sender is
> not consciously aware of the permission-getting step.

Well, this is already happening at the level of my mail client. I
gather you have something more centralized in mind?

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

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


UI toolkits for Python

2005-10-13 Thread Kenneth McDonald
Is there any emerging consensus on the "best" UI for toolkit.  Tk  
never quite made it but from what I can see, both qt and wxWin are  
both doing fairly well in general. I'm already aware of the licensing  
issues surrounding qt (fwiw, I think their license fee for commercial  
use is eminently reasonable), so aside from that, I was wondering if  
there was any feedback readers could provide on the following:

1) Which plays best with Python? Ideally, it would already have some  
higher-level python libraries to hide the grotty stuff that is almost  
never needed when actually implementing apps.

2) Reliability of each?

3) Useful external libraries for each?

4) Ease of installation/use on OS X?

Something with a genuinely useful text widget would be nice, but I  
know that's too much to expect...ah, TkText widget, where are you  
when I need you.


Thanks,
Ken
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Jargons of Info Tech industry

2005-10-13 Thread Brendan Guild
Roedy Green wrote in news:[EMAIL PROTECTED]:

> On Tue, 11 Oct 2005 11:45:03 -0400, Mike Meyer <[EMAIL PROTECTED]> wrote
> or quoted :
> 
>>Jeff Poskanzer, now *he* has a spam problem. He gets a few million
>>spams a day: http://www.acme.com/mail_filtering/ >.
> 
> It is a bit like termites. If we don't do something drastic to deal
> with spam, the ruddy things will eventually make the entire Internet
> unusable.
> 
> the three keys to me are:
> 
> 1. flipping to a digital id based email system so that the sender of
> any piece of mail can be legally identified and prosecuted.
> If every piece of anonymous email disappeared that would go a long
> way to clearing up spam.  Let those sending ransom notes, death
> threats and  hate mail use snail mail.  As a second best,
> correspondents are identified by permission/identity/encryption keys
> given to them by their recipients.

The first part seems rather expensive and I'm not sure it would help. 
Is spam illegal? I don't see how it can be. I mean, those messages are 
annoying, but not that annoying. I get unsolicited email that I 
actually want often enough to want to avoid gumming it up in legal 
issues.

The second part seems like it would be annoying for the recipients and 
would make just sending ordinary email more complicated.

> 2. flipping to a sender pays system so that the Internet does not
> subsidise spam.

This is very promising. Our ISPs should put limits on how much email we 
can send. The limits should be rather insane, nothing that any 
nonspammer would ever come close to, but low enough to stop spam dead. 
If we want to send more than that, we'd better be charged extra.

We could make each mail server responsible for the spam that it sends 
out. It seems that currently mail servers are swamped and spending big 
money on handling the vast loads of spam that gets pumped into them 
from other mail servers, so I'm sure they wouldn't mind having a rule 
like: Refuse to allow email to be transported from any server that 
spews more than 50% spam. Servers could be audited occasionally to 
check if they are spammers.

I don't know exactly how spammers send spam, but a rule like that would 
sure stop ISPs from allowing any one person to send a thousand emails a 
day.

In fact, if 99% of the email sent is spam, then we can safely assume 
that the proper email traffic is 1/100th of what it is now. We just 
have to close the valves a little. Mail servers could have an upper 
limit on how much they will transfer each day to force restrictions 
throughout the system and finally to the individual emailer. I'd rather 
have my mail server give me an error message saying that I've sent too 
much email every once in a while than have the entire Internet clogged 
with spam.

[snipped third key]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Info] PEP 308 accepted - new conditional expressions

2005-10-13 Thread Piet van Oostrum
> [EMAIL PROTECTED] (Dave Hansen) (DH) wrote:

>DH> So lose the "if."

>DH>R = C then A else B

>DH> I don't think python uses the question mark for anything.  Throw that
>DH> in, if it makes parsing easier:

>DH>R = C ? then A else B

We have already had this discussion several times. I don't think it is
going to add anything new to it. Besides after the BDFL has decided it is
useless. 
-- 
Piet van Oostrum <[EMAIL PROTECTED]>
URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4]
Private email: [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


[ANN] XPN 0.5.5 released

2005-10-13 Thread Nemesis
XPN (X Python Newsreader) is a multi-platform newsreader with Unicode
support. It is written with Python+GTK. It has features like
scoring/actions, X-Face and Face decoding, muting of quoted text,
newsrc import/export, find article and search in the body, spoiler
char/rot13, random taglines and configurable attribution lines.

You can find it on:

http://xpn.altervista.org/index-en.html

or

http://sf.net/projects/xpn


Changes in this release:

*  improved support for outgoing/draft articles, now is possible to
   re-edit queued articles.
*  added a simple SSL connection support (no certificates checks)
*  added multipart article support (no binary attachments support)
*  added German translation (thanks to Rene Fischer)
*  fixed a bug that caused crashes with strange Date fields
*  fixed a bug in newsrc importing, now is alse possible to import
   not standard newsrc files like the Xnews ones.
*  fixed a bug in the newsrc system that caused a crash with groups
   containings lots of articles
*  a lot of little bug-fixes and little enhancements

XPN is translated in Italian French and German, if you'd like to
translate it
in your language and you are familiar with gettext and po-files
editing please contact me ([EMAIL PROTECTED]).
-- 
This is not a beer belly. It's a fuel tank for a sex machine.
 
 |\ |   |HomePage   : http://nem01.altervista.org
 | \|emesis |XPN (my nr): http://xpn.altervista.org


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


Re: extract PDF pages

2005-10-13 Thread Andreas Lobinger
Aloha,

David Isaac wrote:
> I am looking for a Python solution.
> Just for PDF page extraction.
> Any hope?

With python, there's always hope.
http://sourceforge.net/projects/pdfplayground

In the CVS (sorry no distribution at the time) you'll find
an example page-extract.
http://cvs.sourceforge.net/viewcvs.py/pdfplayground/ppg/Exp/page-extract.py?rev=1.1&view=markup

pdfplayground is limited at the moment to PDF <= 1.4.
If you want to do more with .pdfs you'll probably need at least
a basic understanding of the PDF specification. pdfplayground
is focused at low-level .pdf (by implementation resources...).

Thomas Lotze is also preparing a pdf reader/writer project:
http://svn.thomas-lotze.de/PDFSpec/

So is David Boddie:
http://www.boddie.org.uk/david/Projects/Python/pdftools

Wishing a happy day
LOBI
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: installer for amd64 build of python?

2005-10-13 Thread Trent Mick
[Brett Hoerner wrote]
> Thanks, looking at their site I can't find a Platform SDK for XP... am
> I looking for the Windows 2003 Server SDK...?  Seems counter-intuitive

Yes, I believe that is the one I am using. MS seems to aim for minimal
intuitive-factor with Platform SDK version naming.

Trent

-- 
Trent Mick
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [PIL]: Question On Changing Colour

2005-10-13 Thread Andrea Gavana
I have tried your solution, Terry:

> new_hue   # your 'basic color', just the hue part
> rgb_base  # color from the basic button image
> rgb_new   # the new color you want to replace rgb_base with
>
> rgb_new = hsv_to_rgb( (new_hue,) + rgb_to_hsv(rgb_base)[1:])


thanks a lot for your suggestion! However, either I did not understand it
correctly or I am doing something stupid in my code. Here is a small
example:

from colorsys import *

# that is the old colour --> GREY
rgb_old = (0.7, 0.7, 0.7)

# Transform the new colour in HSV
hsv_old = rgb_to_hsv(rgb_old[0], rgb_old[1], rgb_old[2])

# this is the new colour --> BLUE
rgb_new = (0.0, 0.0, 1.0)

# Transform the new colour in HSV
hsv_new = rgb_to_hsv(rgb_new[0], rgb_new[1], rgb_new[2])

# I take only the Hue part of the new colour
new_hue = hsv_new[0]

# Get the new colour
rgb_new = hsv_to_rgb(new_hue, hsv_old[1], hsv_old[2])

print rgb_old
print rgb_new
print rgb_old == rgb_new


This prints:

(0.69996, 0.69996, 0.69996)
(0.69996, 0.69996, 0.69996)
True

So, no matter what colour I choose as a "new" colour, the Hue part of the
new colour doesn't change in RGB. In other words, leaving the old value for
"Saturation" and "Value" makes the presence of the "Hue" part useless. But
why in the world does this happen? If a colour is defined by 3 values,
changes in every single value should change the colour too...
Ah, thanks God for the existence of RGB ;-)

Thanks a lot for every suggestion.

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.virgilio.it/infinity77


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


Re: Adding a __filename__ predefined attribute to 2.5?

2005-10-13 Thread Rune Strand
I've read a lot of your comments the last years. Your friendliness
always strikes me.

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


Re: ImportError: No module named dbm

2005-10-13 Thread mhardas
Hi, thanks for the reply.
firstly i couldnt find the DBM module for python 2.3.5, trustix system and
i386 hardware platform.
so i downloaded gnu dbm for python 2.3.5 and i568( precisly,
python-gdbm-2.3.5-4tr.i586), simply assuming it could just work.

but trying to install gives me the following error,

error: failed dependencies:
python = 2.3.5 is needed by python-gdbm-2.3.5-4tr

I am preety sure its python 2.3.5 tht is installed.

Can you shed some light or give some pointers.

Thanks again, appreciate it.

Manas.



> [EMAIL PROTECTED] wrote:
>
>> Can you tell me how do I go about getting the dbm module and install
>> it.??
>
> http://www.google.com/search?q=trustix+python+dbm
>
> 
>
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>


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


Re: Jargons of Info Tech industry

2005-10-13 Thread Gordon Burditt
>Hello? I don't think that should make any difference. I should be able
>to visit absolutely any website on the Internet without any danger to my
>computer or the data stored on it. Any browser which allows otherwise
>has a bug. 

Then Javascript *as a language* is a bug.

>Javascript is not inherently a virus vector. Flawed

A virus vector is not the only security problem.  Leaking
information to the web site is also a problem.

>implementations might be; the language itself is not. 

Does the language allow Javascript to open a new window?  Does the
language allow Javascript to trigger a function when a window is
closed?  I believe the answer to both questions is YES.  Then it
is possible to have a page that pops up two windows whenever you
close one.  This isn't theoretical:  I've seen someone demonstrate
this with certain nasty porn sites.  The only way to recover was
to kill off the browser and restart it.  (Clicking HOME apparently
fired off a cascade of closed windows which then opened more, running
the browser out of virtual memory.) Because of this, he lost work
in progress with another web site.  (Apparently he accidentally
clicked on a banner ad which lead to this booby-trapped site.)

>Similarly for
>anything else. In reality, with a properly-configured, good quality
>operating system (probably a UNIX-type system), one ought to be able to
>run full native code without any danger to one's computer or data
>(think: under the NOBODY account on Linux).

If it can reveal my email address to any web site, it's a bug.  If
it can access or alter my personal files or address book, it's a
bug.  If it can generate hits on web sites other than that specified
in the HTML, it's a bug.  If it can open sockets, it's a bug.
If it can look at or set cookies stored on my system, it's a bug.
If it can look at or alter the list of previously visited URLs, it's
a bug.

>> Browsers don't read unsolicited web sites.  Email readers do, however,
>> read unsolicited email, and email from downright hostile correspondents.  
>> And I consider "web bugs" and similar tracking methods to be a danger
>> for something that's supposed to be ONLY "formatted text".

Gordon L. Burditt
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Well written open source Python apps

2005-10-13 Thread John J. Lee
"Ben" <[EMAIL PROTECTED]> writes:

> Could anyone suggest an open source project that has particularly well
> written Python?  I am especially looking for code that people would
> describe as "very Python-ic".  (Not trying to start any kind of war -
> just wanted some good examples of a well written Python app to read.)
[...]

At the time I looked at it I thought this was nice, though that was
some time ago (it was still 'sketch' then) so I wonder if I'd still
have the same opinion if I looked now (due to me changing my view of
"good code", not the skencil source code changing!):

http://www.nongnu.org/skencil/


John

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


Re: installer for amd64 build of python?

2005-10-13 Thread Steve Holden
Brett Hoerner wrote:
> Trent Mick wrote:
> 
>>Yes. The MS Platform SDK is free and includes a compiler that can target
>>x86, ia64 and x64 (the latter is what MS -- and Sun -- are calling
>>AMD64).
> 
> 
> Thanks, looking at their site I can't find a Platform SDK for XP... am
> I looking for the Windows 2003 Server SDK...?  Seems counter-intuitive
> if so, but it does mention you can build 32 and 64-bit apps with it, I
> just assumed they would be uh, for Windows Server.
> 
> Thanks again,
> Brett
> 
I used the instructions at

   http://www.vrplumber.com/programming/mstoolkit/

to install the MS Toolkit, but I haven't tried compiling 64-bit code 
myself, not having any 64-bit hardware.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006  www.python.org/pycon/

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


Re: Well written open source Python apps

2005-10-13 Thread Grig Gheorghiu
This is really synchronicity in action! I started to think yesterday
about putting together a project that measures the 'goodness' of Python
packages in the PyPI Cheese Shop repository. I call it the "Cheesecake"
project. I took the liberty of citing Micah's post in a blog entry that
I just posted:


Comments/suggestions welcome!

Grig

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


Re: 1-liner to iterate over infinite sequence of integers?

2005-10-13 Thread Paul Rubin
"Fredrik Lundh" <[EMAIL PROTECTED]> writes:
> itertools.count() # 0-based
> itertools.count(1) # 1-based
> 
> gives you an iterator that generates all Python integers (the behaviour
> when it exceeds sys.maxint doesn't seem to be defined, but 2.4 wraps
> around to -(sys.maxint+1))

Ugh, I'd say that's a bad bug.  It should be cleaned up to promote to
long (int/long unification you know) and documented to do that.  
-- 
http://mail.python.org/mailman/listinfo/python-list


  1   2   3   >