Re: Losing curses decorations.

2008-10-08 Thread Peter Otten
Joe Keen wrote:

> I'm working on a small curses application that opens an external
> editor occasionally; in the current case I'm testing its running vi.
> Once I exit vi and return to the curses application I lose the
> background color, window frames, and any text I had on the screen
> before I opened vi.  I can still see the program functioning though as
> it is still responding to key strokes and still updating small
> portions of the screen.  I'm obviously doing something wrong but so
> far I haven't been able to figure out what from the documentation.
> 
> I've boiled the problem I'm seeing down to a relatively small program:

Does redrawing

> def vitest():
> os.system('vi /tmp/foo_bar_baz');
  screen.redrawwin()
  screen.refresh()
> return 1

help?

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


Re: Problem while reading an outlook in box using python.

2008-10-08 Thread Tim Golden

[EMAIL PROTECTED] wrote:

Hello,
   I was getting an error in Cocreate instance while trying to
access "Outlook" using python script. The python script looks like:

from win32com.client import Dispatch
session = Dispatch("MAPI.session")
session.Logon('OUTLOOK')  # MAPI profile name
inbox = session.Inbox

  When I tried to execute the script I got the error:

IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx,
pythoncom.IID_IDispatch)
com_error: (-2147221005, 'Invalid class string', None, None)

  Can any one guide me in obtaining a solution
for  this.



Do you have Outlook installed with the CDO components?
(I think it became an option unchecked by default
at some point).

If not, then you won't have the MAPI.Session class
registered. 


As a double-check, look in the registry for:

HKEY_CLASSES_ROOT\MAPI.Session

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


Re: urllib equivalent for HTTP requests

2008-10-08 Thread Diez B. Roggisch

K schrieb:

Hello everyone,

I understand that urllib and urllib2 serve as really simple page
request libraries. I was wondering if there is a library out there
that can get the HTTP requests for a given page.

Example:
URL: http://www.google.com/test.html

Something like: urllib.urlopen('http://www.google.com/
test.html').files()

Lists HTTP Requests attached to that URL:
=> http://www.google.com/test.html
=> http://www.google.com/css/google.css
=> http://www.google.com/js/js.css



There are no "Requests attached" to an url. There is a HTML-document 
behind it, that might contain further external references.



The other fun part is the inclusion of JS within 

ANN: Solu 0.1 - Office Resource Finder

2008-10-08 Thread Heikki Toivonen
Solu is a simple web application meant for making it easy to find
colleagues, meeting rooms and other resources in an office. Great when
you are new in a company and don't know where everyone and everything is
located in! In other words, Solu is the "cubicle finder". And if you
have ever configured a printer for a computer and being frustrated with
the printer dialog that only showed the IP address but not where the
printer was located, Solu can help! It has a self service model without
any authentication or permission checks, where anyone can find and
update any resource's information.

Besides the easy installation, all you need to set up an instance is
your office map or office floorplan or blueprints stored as an image file.

This is the first public release.

Solu Project Homepage: http://www.heikkitoivonen.net/solu/

Enjoy!

-- 
  Heikki Toivonen - http://www.heikkitoivonen.net
--
http://mail.python.org/mailman/listinfo/python-list


Re: ssh problem using paramiko?

2008-10-08 Thread sa6113

I couldn't find any good source for download Openssh on the net?
Would you please introduce a URL for download that?


Steve Holden-5 wrote:
> 
> sa6113 wrote:
>> I use this code :
>> 
>> 
>> import paramiko
>> import socket
>> 
>> hostname = "192.168.1.4"
>> username = "test"
>> port = 22
>> password = ''123456"
>> 
>> # now connect
>> try:
>> sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
>> sock.connect((hostname, port))
>> except Exception, e:
>> print 'Connect failed: ' + str(e)
>> traceback.print_exc()
>> sys.exit(1)
>> 
>> --
>> and I got this error :
>> sock.connect((hostname, port))
>> File "", line 1 , in  connect
>> error:(10061 ,'Connection refused')
>> ---
>> what is the problem?
>> I have a computer with this Ip and username , password in my network.
>> Do I have to install ssh or somthing else in that computer(server) or run
>> any script?
>> 
>> 
> Yes, 192.168.1.4 should have an ssh daemon (normally sshd) running and
> listening on port 22. It's fairly easy software to install.
> 
> regards
>  Steve
> -- 
> Steve Holden+1 571 484 6266   +1 800 494 3119
> Holden Web LLC  http://www.holdenweb.com/
> 
> --
> http://mail.python.org/mailman/listinfo/python-list
> 
> 

-- 
View this message in context: 
http://www.nabble.com/ssh-problem-using-paramiko--tp19857268p19875248.html
Sent from the Python - python-list mailing list archive at Nabble.com.

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


Re: Problem while reading an outlook in box using python.

2008-10-08 Thread Tim Golden

[EMAIL PROTECTED] wrote:

May I know how to check whether my Outlook is installed with CDO
components?

There is no entry in my Registry Database with the name MAPI.Session.



Well, that pretty much *is* the check. Get hold of your Office
install disk and do a reinstall and look out for suboptions
of Outlook saying things like "CDO" or "Collaboration Data
Objects". Tick the box and click [Install].

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


Re: Reading from stdin

2008-10-08 Thread Almar Klein
>
> I guess the phrasing "hidden read-ahead buffer" implies that buffering
> cannot be turned off (or at least it is not intended to even if it's
> somehow possible).
>

I think it can be done, but you would have to use a different approach on
linux than on windows. Linux requires fcntl (I dont know what this is) and
windows would require the win32api stuff.

Look here for an example where this is done for a subprocess:
http://code.activestate.com/recipes/440554/

cheers,
  Almar
--
http://mail.python.org/mailman/listinfo/python-list


adding text in properties of ms-word

2008-10-08 Thread gita ziabari
I wanna add text in properties of ms-word. Could anyone help me please?

Thanks,

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


Upgrading an instance to a subclass

2008-10-08 Thread Antoon Pardon
I have a subclass of socket.

class Mysocket (socket):
   ...

But when I use the python library it will of course
just return an instance of socket, like the SocketServer
module.

So now I was wondering if it is somehow possible to
turn this instance into a Mysocket instance, either
by somehow changing the original instance or producing
a new instance that represents the same connection.

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


Python/Django hosting on "normal" hosting plans

2008-10-08 Thread david . lyon

Hi All,

I have chosen to use a Django app for a customer site and wish to put  
it up on the net.


Before I waste all day trying it myself (and probably getting it  
wrong) I thought I would ask the experts here.


My questions are:

 - can most everyday vanilla linux web hosts run a django site ?

 - can most everyday vanilla linux web hosts run python web scripts?

Thanks

David

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


Socket With QoS

2008-10-08 Thread Hartman Mario Andres


Hi, this my first message on this list.
My problem is that I need to create a socket with QoS.
I can create a normal socket and transmit data; but now, I need to 
ensure the transfer rate.

If anyone can help me,  be grateful.
Greetings


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


Re: ssh problem using paramiko?

2008-10-08 Thread Diez B. Roggisch
sa6113 wrote:

> 
> I couldn't find any good source for download Openssh on the net?
> Would you please introduce a URL for download that?

http://www.vapor.com/amtelnet/

it supports only SSHv1, but I guess that's ok.

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


Re: how to get the thighest bit position in big integers?

2008-10-08 Thread Mark Dickinson
On Oct 7, 5:19 pm, [EMAIL PROTECTED] wrote:
> but I want to make clear that I think that (0).numbits()==-1
> is the natural solution. At least for all square-and-multiply-like
> algorithms needed in [...]

Can you clarify this?  Why is -1 the natural solution? I
can see a case for 0, for -infinity (whatever that means),
or for raising an exception, but I can't see why -1 would
be at all useful or natural.

Here's a straightforward (mildly inefficient)
implementation of the left-to-right square-and-multiply algorithm
for powering.  It works just fine with nbits(0) == 0.

def nbits(n):
return 0 if n == 0 else len(bin(abs(n)))-2

def LtoRpow(a, n):
acc = 1
for i in reversed(xrange(nbits(n))):
acc *= acc
if n & (1

Re: several version of eggs

2008-10-08 Thread Sed
On Oct 7, 5:14 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:
> Sed wrote:
> >> you need to easy_install with -m/--multi-version. All of your packages.
> > Unfortunately, this is not even working :(
>
> It is.

I see !!! thanks !!!

the fact is that if you have only one egg of sqlachemy module (for
example) which was not installed with easy_install -m, then you get
stuck !

I was having 3 eggs for sqlalchemy:- 2 of them with -m
   - 1 of them without -m  (that was
the mistake).

thanks again.

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


Re: Upgrading an instance to a subclass

2008-10-08 Thread Orestis Markou
I would suggest rather than inheriting from socket, encapsulate over it:

class MySocket(object):
   def __init__(self, socket):
  self.socket = socket

Then you don't have to worry about patching instances...

On Wed, Oct 8, 2008 at 12:54 PM, Antoon Pardon <[EMAIL PROTECTED]> wrote:
> I have a subclass of socket.
>
> class Mysocket (socket):
>   ...
>
> But when I use the python library it will of course
> just return an instance of socket, like the SocketServer
> module.
>
> So now I was wondering if it is somehow possible to
> turn this instance into a Mysocket instance, either
> by somehow changing the original instance or producing
> a new instance that represents the same connection.
>
> --
> Antoon Pardon
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
[EMAIL PROTECTED]
http://orestis.gr
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python pre-release announcements

2008-10-08 Thread Ben Finney
[EMAIL PROTECTED] writes:

> Ben> Is there an appropriate email destination for such patches?
> 
> You might try [EMAIL PROTECTED]

Thank you.

-- 
 \ “I put contact lenses in my dog's eyes. They had little |
  `\   pictures of cats on them. Then I took one out and he ran around |
_o__)  in circles.” —Steven Wright |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list


Re: Reading from stdin

2008-10-08 Thread Luis Zarrabeitia
On Tuesday 07 October 2008 11:27:19 pm George Sakkis wrote:
> """
> In order to make a for loop the most efficient way of looping over the
> lines of a file (a very common operation), the next() method uses a
> hidden read-ahead buffer. As a consequence of using a read-ahead
> buffer, combining next() with other file methods (like readline())
> does not work right.
> """
>
> I guess the phrasing "hidden read-ahead buffer" implies that buffering
> cannot be turned off (or at least it is not intended to even if it's
> somehow possible).

Hmm. I wonder how those optimizations look like. Apparently, readline() cannot 
read from that read-ahead buffer, and that by itself sounds bad. Currently, 
if you loop a few times with next, you cannot use readline afterwards until 
you seek() to an absolute position.

Actually, I think I may be replying to myself here. I imagine that 'next' will 
read a block instead of a character, and look for lines in there, and as the 
underlying OS likely blocks until the whole block is read, 'next' cannot 
avoid it. That doesn't explain, though, why readline() can't use next's 
buffer, why next doesn't have a sensible timeout for interactive sessions 
(unless the OS doesn't support it), and why the readahead cannot be turned 
off.

I think I'll have to stick for now with the iter(function,sentinel) solution.

And I may try to find next()'s implementation... I guess I'll be downloading 
python's source when my bandwidth allows it (or find it on a browseable 
repository)

On a related note, help(file.read) shows:

=
read(...)
read([size]) -> read at most size bytes, returned as a string.

If the size argument is negative or omitted, read until EOF is reached.
Notice that when in non-blocking mode, less data than what was requested
may be returned, even if no size parameter was given.
=

But it doesn't say how to put the file object in non-blocking mode. (I was 
trying to put the file object in non-blocking mode to test next()'s 
behavior). ??Ideas?

-- 
Luis Zarrabeitia (aka Kyrie)
Fac. de Matemática y Computación, UH.
http://profesores.matcom.uh.cu/~kyrie
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python/Django hosting on "normal" hosting plans

2008-10-08 Thread Tim Chase

My questions are:

  - can most everyday vanilla linux web hosts run a django site ?

  - can most everyday vanilla linux web hosts run python web scripts?


Depends on your definition of "most everyday vanilla linux web 
hosts".  :)


The bottom-of-the-barrel hosts will often (but not always) offer 
Python CGI.  Django "can" run in a CGI (google for "django 
cgi"[0]), but it's an unpleasant experience because the entire 
Django framework gets reloaded for *every* request. 
Doable/tolerable for a private development/family page, but it 
will likely flounder under the slightest load.


This is like strapping a jet engine (Django) on a bicycle (CGI). 
 [1]  Doable, but more for the macho-factor of "I got it 
working" rather than the practical aspects.


Your lowest-end hosting services won't offer mod_python or WSGI 
(either Apache with mod_wsgi, or others like lighttpd with a wsgi 
interface) though WSGI is becoming more popular.  There are still 
some shared-hosting solutions that facilitate using Django[2] 
pretty well.  They're not super-cheap, but they're affordable. 
The canonical catalog of Django-friendly & Django-capable hosting 
services can be found at [3].  If you're just starting out with 
Django, it might help to pay a bit more for one of the click-n-go 
hosts, while others you'll have to do some of the heavy lifting 
(installing Django, as well as possibly other components, 
assembling your wsgi startup script, etc) yourself.


Hope this helps,

-tkc


[0]
http://www.google.com/search?q=django%20cgi

[1]
http://www.youtube.com/watch?v=SFv1Yu-KxZ8

[2]
http://groups.google.com/group/django-users/browse_thread/thread/cfaf8c04f3dfb56e/

[3]
http://code.djangoproject.com/wiki/DjangoFriendlyWebHosts











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


Re: Python pre-release announcements

2008-10-08 Thread skip

Ben> Is there an appropriate email destination for such patches?

You might try [EMAIL PROTECTED]

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


Re: how to start thread by group?

2008-10-08 Thread bieffe62
On 7 Ott, 06:37, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote:
> En Mon, 06 Oct 2008 11:24:51 -0300, <[EMAIL PROTECTED]> escribió:
>
> > On 6 Ott, 15:24, oyster <[EMAIL PROTECTED]> wrote:
> >> my code is not right, can sb give me a hand? thanx
>
> >> for example, I have 1000 urls to be downloaded, but only 5 thread at  
> >> one time
> > I would restructure my code with someting like this ( WARNING: the
> > following code is
> > ABSOLUTELY UNTESTED and shall be considered only as pseudo-code to
> > express my idea of
> > the algorithm (which, also, could be wrong:-) ):
>
> Your code creates one thread per url (but never more than MAX_THREADS  
> alive at the same time). Usually it's more efficient to create all the  
> MAX_THREADS at once, and continuously feed them with tasks to be done. A  
> Queue object is the way to synchronize them; from the documentation:
>
> 
>  from Queue import Queue
>  from threading import Thread
>
> num_worker_threads = 3
> list_of_urls = ["http://foo.com";, "http://bar.com";,
>                  "http://baz.com";, "http://spam.com";,
>                  "http://egg.com";,
>                 ]
>
> def do_work(url):
>      from time import sleep
>      from random import randrange
>      from threading import currentThread
>      print "%s downloading %s" % (currentThread().getName(), url)
>      sleep(randrange(5))
>      print "%s done" % currentThread().getName()
>
> # from this point on, copied almost verbatim from the Queue example
> # at the end ofhttp://docs.python.org/library/queue.html
>
> def worker():
>      while True:
>          item = q.get()
>          do_work(item)
>          q.task_done()
>
> q = Queue()
> for i in range(num_worker_threads):
>       t = Thread(target=worker)
>       t.setDaemon(True)
>       t.start()
>
> for item in list_of_urls:
>      q.put(item)
>
> q.join()       # block until all tasks are done
> print "Finished"
> 
>
> --
> Gabriel Genellina


Agreed.
I was trying to do what the OP was trying to do, but in a way that
works.
But keeping the thread alive and feeding them the URL is a better
design, definitly.
And no, I don't think its 'premature optimization': it is just
cleaner.

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


Re: Problem while reading an outlook in box using python.

2008-10-08 Thread venutaurus539
May I know how to check whether my Outlook is installed with CDO
components?

There is no entry in my Registry Database with the name MAPI.Session.

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


Re: Problem while reading an outlook in box using python.

2008-10-08 Thread venutaurus539
On Oct 8, 2:54 pm, Tim Golden <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> > May I know how to check whether my Outlook is installed with CDO
> > components?
>
> > There is no entry in my Registry Database with the name MAPI.Session.
>
> Well, that pretty much *is* the check. Get hold of your Office
> install disk and do a reinstall and look out for suboptions
> of Outlook saying things like "CDO" or "Collaboration Data
> Objects". Tick the box and click [Install].
>
> TJG


Thanks Tim, it worked.!!!
--
http://mail.python.org/mailman/listinfo/python-list


Re: Losing curses decorations.

2008-10-08 Thread Joe Keen
On Oct 8, 1:16 am, Peter Otten <[EMAIL PROTECTED]> wrote:
> Joe Keen wrote:
> > I'm working on a small curses application that opens an external
> > editor occasionally; in the current case I'm testing its running vi.
> > Once I exit vi and return to the curses application I lose the
> > background color, window frames, and any text I had on the screen
> > before I opened vi.  I can still see the program functioning though as
> > it is still responding to key strokes and still updating small
> > portions of the screen.  I'm obviously doing something wrong but so
> > far I haven't been able to figure out what from the documentation.
>
> > I've boiled the problem I'm seeing down to a relatively small program:
>
> Does redrawing
>
> > def vitest():
> > os.system('vi /tmp/foo_bar_baz');
>
>   screen.redrawwin()
>   screen.refresh()
>
> > return 1
>
> help?
>
> Peter

It helps a little bit.  Using that the line I modified with
screen.addstr(1,1,"Got: "+key) now has the proper background color and
the window decorations on the far ends.  Only that line does though.
My understanding is that curses is going to try and redraw as little
as possible.  Is there a function to force a full redraw?  Or is that
redrawwin function supposed to be doing that?
--
http://mail.python.org/mailman/listinfo/python-list


How to calculate two time?

2008-10-08 Thread lookon
I have two string like "2007-03-27T08:54:43+08:00 "
how do I get the hours between these two time(string format)?
--
http://mail.python.org/mailman/listinfo/python-list


Re: Reading from stdin

2008-10-08 Thread Jean-Paul Calderone

On Wed, 8 Oct 2008 09:28:55 -0400, Luis Zarrabeitia <[EMAIL PROTECTED]> wrote:

On Tuesday 07 October 2008 11:27:19 pm George Sakkis wrote:

"""
In order to make a for loop the most efficient way of looping over the
lines of a file (a very common operation), the next() method uses a
hidden read-ahead buffer. As a consequence of using a read-ahead
buffer, combining next() with other file methods (like readline())
does not work right.
"""

I guess the phrasing "hidden read-ahead buffer" implies that buffering
cannot be turned off (or at least it is not intended to even if it's
somehow possible).


Hmm. I wonder how those optimizations look like. Apparently, readline() cannot
read from that read-ahead buffer, and that by itself sounds bad. Currently,
if you loop a few times with next, you cannot use readline afterwards until
you seek() to an absolute position.

Actually, I think I may be replying to myself here. I imagine that 'next' will
read a block instead of a character, and look for lines in there, and as the
underlying OS likely blocks until the whole block is read, 'next' cannot
avoid it. That doesn't explain, though, why readline() can't use next's
buffer, why next doesn't have a sensible timeout for interactive sessions
(unless the OS doesn't support it), and why the readahead cannot be turned
off.

I think I'll have to stick for now with the iter(function,sentinel) solution.

And I may try to find next()'s implementation... I guess I'll be downloading
python's source when my bandwidth allows it (or find it on a browseable
repository)

On a related note, help(file.read) shows:

=
read(...)
   read([size]) -> read at most size bytes, returned as a string.

   If the size argument is negative or omitted, read until EOF is reached.
   Notice that when in non-blocking mode, less data than what was requested
   may be returned, even if no size parameter was given.
=

But it doesn't say how to put the file object in non-blocking mode. (I was
trying to put the file object in non-blocking mode to test next()'s
behavior). ??Ideas?



Take a look at 
http://twistedmatrix.com/trac/browser/trunk/twisted/internet/fdesc.py

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


Re: How to calculate two time?

2008-10-08 Thread skip

lookon> I have two string like "2007-03-27T08:54:43+08:00 " how do I get
lookon> the hours between these two time(string format)?

Look in PyPI for dateutil, then:

>>> import dateutil.parser
>>> t1 = dateutil.parser.parse("2007-03-27T08:54:43+08:00")
>>> t1
datetime.datetime(2007, 3, 27, 8, 54, 43, tzinfo=tzoffset(None, 28800))
>>> t2 = dateutil.parser.parse("2007-03-29T10:00:00+02:00") >>> t2
datetime.datetime(2007, 3, 29, 10, 0, tzinfo=tzoffset(None, 7200))
>>> t2 - t1
datetime.timedelta(2, 25517)

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


Re: How to calculate two time?

2008-10-08 Thread Jean-Paul Calderone

On Wed, 8 Oct 2008 06:49:10 -0700 (PDT), lookon <[EMAIL PROTECTED]> wrote:

I have two string like "2007-03-27T08:54:43+08:00 "
how do I get the hours between these two time(string format)?


That's ISO 8601 datetime format.  You might use epsilon.extime:

   >>> from epsilon.extime import Time
   >>> Time.fromISO8601TimeAndDate("2008-10-08T14:05:16.029246+00:00") - 
Time.fromISO8601TimeAndDate("2007-03-27T08:54:43+08:00")
   datetime.timedelta(561, 47433, 29246)

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


Accessing the message of Outlook inbox

2008-10-08 Thread venutaurus539
Hi all,
How can I access the body of a mail in Outlook Inbox? I tried
various options like message.Body or message.Mesg etc. but didn't
work. I could get the subject of the mail using message.Subject
though.

Any help is appreciated.

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


Re: Race condition when generating .pyc files

2008-10-08 Thread [EMAIL PROTECTED]
I think this is my best option for now - I'm going to give it a shot.
Thanks.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Race condition when generating .pyc files

2008-10-08 Thread [EMAIL PROTECTED]
Ugggh, I'm not using the exact same version everywhere.  Of course,
the mystery to me is that this just started failing recently,
everything has been fine until
last week.
Anyway, thanks for the info.

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


PIL problem

2008-10-08 Thread bfrederi
I am having a problem using PIL. I am trying to crop and image to a
square, starting from the center of the image, but when I try to crop
the image, it won't crop. Here are the relevant code snippets:

### Function I am testing ###
def create_square_image(file_name):
""" Creates a thumbnail sized image and turns it into a square """
image = Image.open(open(file_name))

size_tuple = image.size
width = size_tuple[0]
height = size_tuple[1]

square_length = 75

x1 = (width / 2) - (square_length / 2)
x2 = x1 + square_length
y1 = (height / 2) - (square_length / 2)
y2 = y1 + square_length

image.crop((x1,y1,x2,y2))
image.save(file_name, "JPEG")


### In my tests.py ###
def testCreateSquareImage(self):
""" Test to turn image into a square """
self.convert_file = '/home/bfrederi/square-dissertation.jpg'
tkl_converter.create_square_image(self.convert_file)
image = Image.open(self.convert_file)
if image.size[0] == 75 and image.size[1] == 75:
self.assert_(True)
else:
self.fail("Width: %s Height: %s" % (image.size[0],
image.size[1]))

### Test result ###
FAIL: Test to turn image into a square
--
Traceback (most recent call last):
  File "tests.py", line 462, in testCreateSquareImage
self.fail("Width: %s Height: %s" % (image.size[0], image.size[1]))
AssertionError: Width: 75 Height: 97

--

The image is unchanged. Anyone have any idea what I'm doing wrong?
I've tried opening the file, and outputting to a different file
(instead of overwriting the file), but the new file always comes out
the same as the original.
--
http://mail.python.org/mailman/listinfo/python-list


distributing apps without the Python source?

2008-10-08 Thread Joe Strout
We have a client who's paranoid about distributing the Python source  
to his commercial app.  Is there some way I can distribute and use  
just the .pyc files, so as to not give away the source?


Thanks,
- Joe



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


Re: ABCs -> infix syntax for isinstance() ?

2008-10-08 Thread Boris Borcic

Bruno Desthuilliers wrote:

[EMAIL PROTECTED] a écrit :

...

A intriguing wider proposition would be to transpose Ruby's notion of
"Open Classes" to Python built-in metaclasses (or just to type
itself ?).


No, thanks. Even the Ruby guys start to think making evrything open may 
not be such a good idea after all.


Wasn't an all-or-nothing proposition; a good objection is spelled out in PEP 
3119 (ABCs) :




...but there are some good reasons to keep the built-in types immutable (for 
one, they are shared between all Python interpreters running in the same address 
space, as is used by mod_python)




Cheers, BB

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


Re: distributing apps without the Python source?

2008-10-08 Thread Marc 'BlackJack' Rintsch
On Wed, 08 Oct 2008 09:18:47 -0600, Joe Strout wrote:

> We have a client who's paranoid about distributing the Python source to
> his commercial app.  Is there some way I can distribute and use just the
> .pyc files, so as to not give away the source?

Yes.  Just use the *.pyc files.

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


config errors

2008-10-08 Thread Kathleen Krause-Thompson
Hello,

After having setup my dev environment for Plone 3.0, I've been receiving
these errors when using apt-get:

Errors were encountered while processing:
 python-setuptools
 python-paste
 python-pastedeploy
 python-pastescript

Is there something that needs to be configured?

Thanks in advance.

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


Re: PIL problem

2008-10-08 Thread Marc 'BlackJack' Rintsch
On Wed, 08 Oct 2008 08:10:02 -0700, bfrederi wrote:

> I am having a problem using PIL. I am trying to crop and image to a
> square, starting from the center of the image, but when I try to crop
> the image, it won't crop. Here are the relevant code snippets:
> 
> ### Function I am testing ###
> def create_square_image(file_name):
> """ Creates a thumbnail sized image and turns it into a square """
> image = Image.open(open(file_name))
> 
> size_tuple = image.size
> width = size_tuple[0]
> height = size_tuple[1]
> 
> square_length = 75
> 
> x1 = (width / 2) - (square_length / 2) x2 = x1 + square_length
> y1 = (height / 2) - (square_length / 2) y2 = y1 + square_length
> 
> image.crop((x1,y1,x2,y2))

This doesn't change `image` but creates and returns a new cropped image 
which you simply ignore.

> image.save(file_name, "JPEG")

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


Re: PIL problem

2008-10-08 Thread bfrederi
On Oct 8, 10:30 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
> On Wed, 08 Oct 2008 08:10:02 -0700, bfrederi wrote:
> > I am having a problem using PIL. I am trying to crop and image to a
> > square, starting from the center of the image, but when I try to crop
> > the image, it won't crop. Here are the relevant code snippets:
>
> > ### Function I am testing ###
> > def create_square_image(file_name):
> >     """ Creates a thumbnail sized image and turns it into a square """
> >     image = Image.open(open(file_name))
>
> >     size_tuple = image.size
> >     width = size_tuple[0]
> >     height = size_tuple[1]
>
> >     square_length = 75
>
> >     x1 = (width / 2) - (square_length / 2) x2 = x1 + square_length
> >     y1 = (height / 2) - (square_length / 2) y2 = y1 + square_length
>
> >     image.crop((x1,y1,x2,y2))
>
> This doesn't change `image` but creates and returns a new cropped image
> which you simply ignore.
>
> >     image.save(file_name, "JPEG")
>
> Ciao,
>         Marc 'BlackJack' Rintsch

How do I output it to an actual file then? Or overwrite the existing
file?
--
http://mail.python.org/mailman/listinfo/python-list


Quality control in open source development

2008-10-08 Thread Dave
With the open source licenses that allow redistribution of modified
code, how do you keep someone unaffiliated with the Python community
from creating his or her own version of python, and declaring it to be
Python 2.6, or maybe Python 2.7 without any approval of anyone at the
PSF? Maybe their code is terrible, and not even compatible with the
rest of Python! How can the PSF, for example, maintain the quality and
coheren of new code contributed to be part of Python, or derivative
works that claim to be some future version of Python? If licensees can
redisribute as they like, isn't this a huge problem? Is this dealt
with be restricting use of the Python trademarks?  Just curious..

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


Re: Quality control in open source development

2008-10-08 Thread Chris Mellon
On Wed, Oct 8, 2008 at 10:43 AM, Dave <[EMAIL PROTECTED]> wrote:
> With the open source licenses that allow redistribution of modified
> code, how do you keep someone unaffiliated with the Python community
> from creating his or her own version of python, and declaring it to be
> Python 2.6, or maybe Python 2.7 without any approval of anyone at the
> PSF? Maybe their code is terrible, and not even compatible with the
> rest of Python!

In some projects, there's trademarks on the project name (for example,
Linus owns the Linux trademark), so you can mitigate confusion that
way. I don't know if the PSF owns the Python trademarks or not.

You can't stop them from forking and releasing their own code, even if
it's really bad. That's freedom for you.

> How can the PSF, for example, maintain the quality and
> coheren of new code contributed to be part of Python, or derivative
> works that claim to be some future version of Python? If licensees can
> redisribute as they like, isn't this a huge problem?

I think it's pretty self-evident that it's not a huge problem, don't
you? Do you see lots of low quality python forks cluttering up the
internet?

> Is this dealt
> with be restricting use of the Python trademarks?  Just curious..
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list


Re: Accessing the message of Outlook inbox

2008-10-08 Thread Mike Driscoll
On Oct 8, 9:24 am, [EMAIL PROTECTED] wrote:
> Hi all,
>         How can I access the body of a mail in Outlook Inbox? I tried
> various options like message.Body or message.Mesg etc. but didn't
> work. I could get the subject of the mail using message.Subject
> though.
>
> Any help is appreciated.
>
> Thanks in advance,
> Venu

Can you connect via POP3? If so, the email module should be able to
get it. Otherwise, you'll probably have to use the PyWin32 package's
win32com module.

Google is your friend. The following links should give you a general
idea of how to access Outlook with Python:

http://cephas.net/blog/2004/09/17/sending-your-outlook-calendar-using-python/
http://www.boddie.org.uk/python/COM.html
http://www.goldb.org/goldblog/CommentView,guid,dcd1d9cd-eb1b-4590-a14b-1480bdf1db69.aspx
http://mail.python.org/pipermail/python-win32/2007-November/006446.html

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


Re: PIL problem

2008-10-08 Thread bfrederi
On Oct 8, 10:39 am, bfrederi <[EMAIL PROTECTED]> wrote:
> On Oct 8, 10:30 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Wed, 08 Oct 2008 08:10:02 -0700, bfrederi wrote:
> > > I am having a problem using PIL. I am trying to crop and image to a
> > > square, starting from the center of the image, but when I try to crop
> > > the image, it won't crop. Here are the relevant code snippets:
>
> > > ### Function I am testing ###
> > > def create_square_image(file_name):
> > >     """ Creates a thumbnail sized image and turns it into a square """
> > >     image = Image.open(open(file_name))
>
> > >     size_tuple = image.size
> > >     width = size_tuple[0]
> > >     height = size_tuple[1]
>
> > >     square_length = 75
>
> > >     x1 = (width / 2) - (square_length / 2) x2 = x1 + square_length
> > >     y1 = (height / 2) - (square_length / 2) y2 = y1 + square_length
>
> > >     image.crop((x1,y1,x2,y2))
>
> > This doesn't change `image` but creates and returns a new cropped image
> > which you simply ignore.
>
> > >     image.save(file_name, "JPEG")
>
> > Ciao,
> >         Marc 'BlackJack' Rintsch
>
> How do I output it to an actual file then? Or overwrite the existing
> file?

Nevermind, I gotcha. I needed to do this:

def create_square_image(file_name):
""" Creates a thumbnail sized image and turns it into a square """
image = Image.open(open(file_name))

size_tuple = image.size
width = size_tuple[0]
height = size_tuple[1]

square_length = 75

x1 = (width / 2) - (square_length / 2)
x2 = x1 + square_length
y1 = (height / 2) - (square_length / 2)
y2 = y1 + square_length

new_image = image.crop((x1,y1,x2,y2))
try:
new_image.save(file_name, "JPEG")
except IOError:
print "Cannot create square image for", file_name

I needed to output the cropped image by getting the cropped image in
"new_image" and outputting the new file. I see what you were saying.
--
http://mail.python.org/mailman/listinfo/python-list


Re: PIL problem

2008-10-08 Thread bfrederi
On Oct 8, 10:39 am, bfrederi <[EMAIL PROTECTED]> wrote:
> On Oct 8, 10:30 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Wed, 08 Oct 2008 08:10:02 -0700, bfrederi wrote:
> > > I am having a problem using PIL. I am trying to crop and image to a
> > > square, starting from the center of the image, but when I try to crop
> > > the image, it won't crop. Here are the relevant code snippets:
>
> > > ### Function I am testing ###
> > > def create_square_image(file_name):
> > >     """ Creates a thumbnail sized image and turns it into a square """
> > >     image = Image.open(open(file_name))
>
> > >     size_tuple = image.size
> > >     width = size_tuple[0]
> > >     height = size_tuple[1]
>
> > >     square_length = 75
>
> > >     x1 = (width / 2) - (square_length / 2) x2 = x1 + square_length
> > >     y1 = (height / 2) - (square_length / 2) y2 = y1 + square_length
>
> > >     image.crop((x1,y1,x2,y2))
>
> > This doesn't change `image` but creates and returns a new cropped image
> > which you simply ignore.
>
> > >     image.save(file_name, "JPEG")
>
> > Ciao,
> >         Marc 'BlackJack' Rintsch
>
> How do I output it to an actual file then? Or overwrite the existing
> file?

Nevermind, I gotcha. I needed to do this:

def create_square_image(file_name):
""" Creates a thumbnail sized image and turns it into a square """
image = Image.open(open(file_name))

size_tuple = image.size
width = size_tuple[0]
height = size_tuple[1]

square_length = 75

x1 = (width / 2) - (square_length / 2)
x2 = x1 + square_length
y1 = (height / 2) - (square_length / 2)
y2 = y1 + square_length

new_image = image.crop((x1,y1,x2,y2))
try:
new_image.save(file_name, "JPEG")
except IOError:
print "Cannot create square image for", file_name

I needed to output the cropped image by getting the cropped image in
"new_image" and outputting the new file. I see what you were saying.
--
http://mail.python.org/mailman/listinfo/python-list


Re: PIL problem

2008-10-08 Thread Peter Otten
bfrederi wrote:

>> > image.crop((x1,y1,x2,y2))
>>
>> This doesn't change `image` but creates and returns a new cropped image
>> which you simply ignore.
>>
>> > image.save(file_name, "JPEG")
>>
>> Ciao,
>> Marc 'BlackJack' Rintsch
> 
> How do I output it to an actual file then? Or overwrite the existing
> file?

cropped_image = image.crop(...)
cropped_image.save(...)

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


Re: distributing apps without the Python source?

2008-10-08 Thread skip

Marc> On Wed, 08 Oct 2008 09:18:47 -0600, Joe Strout wrote:
>> We have a client who's paranoid about distributing the Python source
>> to his commercial app.  Is there some way I can distribute and use
>> just the .pyc files, so as to not give away the source?

Marc> Yes.  Just use the *.pyc files.

Though of course there is decompyle to consider, assuming Joe's client is
truly paranoid.

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


Re: Quality control in open source development

2008-10-08 Thread Peter Otten
Dave wrote:

> With the open source licenses that allow redistribution of modified
> code, how do you keep someone unaffiliated with the Python community
> from creating his or her own version of python, and declaring it to be
> Python 2.6, or maybe Python 2.7 without any approval of anyone at the
> PSF? Maybe their code is terrible, and not even compatible with the
> rest of Python! How can the PSF, for example, maintain the quality and
> coheren of new code contributed to be part of Python, or derivative
> works that claim to be some future version of Python? If licensees can
> redisribute as they like, isn't this a huge problem? Is this dealt
> with be restricting use of the Python trademarks?  Just curious..

The hit men from the PSU will take care of that. But I'm not supposed to
talk ab 

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


Re: PIL problem

2008-10-08 Thread J Kenneth King
bfrederi <[EMAIL PROTECTED]> writes:

> I am having a problem using PIL. I am trying to crop and image to a
> square, starting from the center of the image, but when I try to crop
> the image, it won't crop. Here are the relevant code snippets:
>
> ### Function I am testing ###
> def create_square_image(file_name):
> """ Creates a thumbnail sized image and turns it into a square """
> image = Image.open(open(file_name))
>
> size_tuple = image.size
> width = size_tuple[0]
> height = size_tuple[1]
>
> square_length = 75
>
> x1 = (width / 2) - (square_length / 2)
> x2 = x1 + square_length
> y1 = (height / 2) - (square_length / 2)
> y2 = y1 + square_length
>
> image.crop((x1,y1,x2,y2))
> image.save(file_name, "JPEG")

def create_square_image(filename, size=75):
file = open(filename, 'rb')
image = Image.open(file)
w, h = image.size

x1 = (w / 2) - (size / 2)
x2 = x1 + size
y1 = (h / 2) - (size / 2)
y2 = y1 + size

thumb = image.crop((x1,y1,x2,y2))
thumb.save("thumb_" + filename, "JPEG")

...

of course PIL has a thumbnail method that does this type of stuff.
--
http://mail.python.org/mailman/listinfo/python-list


Job Posting

2008-10-08 Thread Capuano, Rebecca
HI,

Would you be able to post this on your site? I don't know if you post jobs. 
Thanks!

Our client in Princeton, NJ is looking for a Python Developer to join its team.

Description
A small to medium Python project needs a motivated developer to work with the 
team lead.  The position entails designing, implementing, and  testing a 
flexible schema definition and data cataloging front end for an image and 
metadata management system.  The project may include  building a distributed 
image repository system as well as the cataloging tool.  The entire project 
will eventually be released as  open source software.

6-month+ project.

Requirements

3+ years of Python experience preferably in a professional capacity.
Familiarity with JQuery, PIL, SQLAlchemy, PyProcessing, Pylons, Django.
Knowledge of functional programming is a plus.
Knowledge of image processing is a plus.
Excellent verbal and written communication skills.

You will be required to write some python code as part of  the interview proces

To apply please contact:
Rebecca Capuano
Sr. Recruiter
Information Technology and Engineering
TECHNISOURCE
100 Wood Ave. South, Suite 208, Iselin, New Jersey 08830
Direct 732.635.0700 x 227 | fax 800.258.9775
[EMAIL PROTECTED] | 
www.technisource.com

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


Re: Quality control in open source development

2008-10-08 Thread Christian Heimes

Dave wrote:

If licensees can
redisribute as they like, isn't this a huge problem? Is this dealt
with be restricting use of the Python trademarks?  Just curious..


From http://www.python.org/psf/summary/
---
The PSF also holds and protects the trademarks behind the Python 
programming language. This includes the "Python" name, when used in the 
domain of programming languages, and also the Python logos. "Python" is 
a registered trademark in the US, while the logos have not yet been 
registered.

---

Christian

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


Re: how to get the thighest bit position in big integers?

2008-10-08 Thread MRAB
On Oct 8, 9:56 am, Mark Dickinson <[EMAIL PROTECTED]> wrote:
> On Oct 7, 5:19 pm, [EMAIL PROTECTED] wrote:
>
> > but I want to make clear that I think that (0).numbits()==-1
> > is the natural solution. At least for all square-and-multiply-like
> > algorithms needed in [...]
>
> Can you clarify this?  Why is -1 the natural solution? I
> can see a case for 0, for -infinity (whatever that means),
> or for raising an exception, but I can't see why -1 would
> be at all useful or natural.
>
[snip]
Compare it with, say, str.find, which returns the position if found
(>=0) or -1 if not found.

int.numbits should return the position of the highest set bit (>=0) or
-1 if none found.

On the other hand, if you compare it wirh str.index then int.numbits
should raise ValueError if none found.

Actually, the name "numbits" suggests that it returns the number of
bits, so (1).numbits() should return 1 and (0).numbits() should return
0. If it's called "highbit" then it suggests that it returns the
position of the highest (set) bit, so (1).highbit() should return 0
and (0).highbit() should return -1 (or raise an exception).
--
http://mail.python.org/mailman/listinfo/python-list


utf-8 read/write file

2008-10-08 Thread Bruno

Hi!

I have big .txt file which i want to read, process and write to another .txt 
file.
I have done script for that, but im having problem with croatian characters 
(Š,Đ,Ž,Č,Ć).

How can I read/write from/to file in utf-8 encoding?
I read file with fileinput.input.

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


Re: Accessing the message of Outlook inbox

2008-10-08 Thread venutaurus539
On Oct 8, 8:53 pm, Mike Driscoll <[EMAIL PROTECTED]> wrote:
> On Oct 8, 9:24 am, [EMAIL PROTECTED] wrote:
>
> > Hi all,
> >         How can I access the body of a mail in Outlook Inbox? I tried
> > various options like message.Body or message.Mesg etc. but didn't
> > work. I could get the subject of the mail using message.Subject
> > though.
>
> > Any help is appreciated.
>
> > Thanks in advance,
> > Venu
>
> Can you connect via POP3? If so, the email module should be able to
> get it. Otherwise, you'll probably have to use the PyWin32 package's
> win32com module.
>
> Google is your friend. The following links should give you a general
> idea of how to access Outlook with Python:
>
> http://cephas.net/blog/2004/09/17/sending-your-outlook-calendar-using...http://www.boddie.org.uk/python/COM.htmlhttp://www.goldb.org/goldblog/CommentView,guid,dcd1d9cd-eb1b-4590-a14...http://mail.python.org/pipermail/python-win32/2007-November/006446.html
>
> Mike

Thanks Mike for your suggestion.. I am using PyWin32 package's Win32
module... I did go through those mails,, and am able to access the
Outlook inbox as they have mentioned.. but am not getting the exact
function with which I can refer the mails content ( Message of the
Body)... :-(

THank you,,
Venu.
--
http://mail.python.org/mailman/listinfo/python-list


Apache log munging

2008-10-08 Thread Joe Python
I have a written a generator for an apache log which returns two types of
information,
hostname and the filename requested.

The 'log' generator can be 'consumed' like this:

for r in log:
  print r['host'], r['filename']

I want to find the top '100' hosts (sorted in descending order of total
requests) like follows:

host  filename1  filename2 filename3 Total

hostA   6  9 45 110
hostC   4 4343  98
hostB   344 45  83

and so on.
Is there a fast way to this without scanning the log file many times?
Thanks in advance.
- Jo
--
http://mail.python.org/mailman/listinfo/python-list


Re: how to get the thighest bit position in big integers?

2008-10-08 Thread Terry Reedy

MRAB wrote:

On Oct 8, 9:56 am, Mark Dickinson <[EMAIL PROTECTED]> wrote:

On Oct 7, 5:19 pm, [EMAIL PROTECTED] wrote:


but I want to make clear that I think that (0).numbits()==-1
is the natural solution. At least for all square-and-multiply-like
algorithms needed in [...]

Can you clarify this?  Why is -1 the natural solution? I
can see a case for 0, for -infinity (whatever that means),
or for raising an exception, but I can't see why -1 would
be at all useful or natural.


[snip]
Compare it with, say, str.find, which returns the position if found
(>=0) or -1 if not found.


str.find is an historical anomaly that should not be copied.  It 
was(is?) a wrapper for C's string find function.  C routinely uses -1 to 
mean None for functions statically typed to return ints.  The Python 
version logically should return None and usually does for other functions.


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


Python syntax question

2008-10-08 Thread Daniel
I hope this question is OK for this list.  I've downloaded Rpyc and
placed it in my site packages dir.  On some machines it works fine, on
others not so much.

Here is one error I get when I try to import it:

>>> import Rpyc
Traceback (most recent call last):
  File "", line 1, in 
  File "C:\Python25\lib\site-packages\Rpyc\__init__.py", line 7, in

from Rpyc.Lib import rpyc_excepthook
  File "C:\Python25\lib\site-packages\Rpyc\Lib.py", line 65
print("=== Remote traceback ===", file=stderr)
  ^
SyntaxError: invalid syntax

The little carrot points to the equal sign ('=') in 'file=stderr'

What's the syntax problem?

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


Re: distributing apps without the Python source?

2008-10-08 Thread Marc 'BlackJack' Rintsch
On Wed, 08 Oct 2008 10:59:44 -0500, skip wrote:

> Marc> On Wed, 08 Oct 2008 09:18:47 -0600, Joe Strout wrote:
> >> We have a client who's paranoid about distributing the Python
> >> source to his commercial app.  Is there some way I can distribute
> >> and use just the .pyc files, so as to not give away the source?
> 
> Marc> Yes.  Just use the *.pyc files.
> 
> Though of course there is decompyle to consider, assuming Joe's client
> is truly paranoid.

Simply don't tell the client.  All he has to know is that it's basically 
the same as Java *.class files.  Most paranoid clients are fine with 
that.  Unless you tell them there are decompilers for *.class files.  :-)

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


Re: Python syntax question

2008-10-08 Thread Marc 'BlackJack' Rintsch
On Wed, 08 Oct 2008 11:02:49 -0700, Daniel wrote:

> Here is one error I get when I try to import it:
> 
 import Rpyc
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "C:\Python25\lib\site-packages\Rpyc\__init__.py", line 7, in
> 
> from Rpyc.Lib import rpyc_excepthook
>   File "C:\Python25\lib\site-packages\Rpyc\Lib.py", line 65
> print("=== Remote traceback ===", file=stderr)
>   ^
> SyntaxError: invalid syntax
> 
> The little carrot points to the equal sign ('=') in 'file=stderr'
> 
> What's the syntax problem?

That's Python 3.0 syntax where ``print`` is not a keyword anymore but a 
function.  Won't work with Python 2.5.

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


Re: Apache log munging

2008-10-08 Thread Joe Riopel
On Wed, Oct 8, 2008 at 1:55 PM, Joe Python <[EMAIL PROTECTED]> wrote:
> I want to find the top '100' hosts (sorted in descending order of total
> requests) like follows:
> Is there a fast way to this without scanning the log file many times?

As you encounter a new "host" add it to a dict (or another type of
collection), and if encountered again, use that "host" as the key to
retrieve the dict entry and increment it's request count. You should
only have to read the file once.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Upgrading an instance to a subclass

2008-10-08 Thread Terry Reedy

Antoon Pardon wrote:

I have a subclass of socket.

class Mysocket (socket):
   ...

But when I use the python library it will of course
just return an instance of socket, like the SocketServer
module.

So now I was wondering if it is somehow possible to
turn this instance into a Mysocket instance, either
by somehow changing the original instance


Instances of Python-coded classes can usually have __class__ changed. 
But not for builtin, C-coded classes, which I assume


> or producing

a new instance that represents the same connection.


Given that socket appears to be immutable, I believe Mysocket would need 
a __new__ method that called socket.__new__.  But I have never worked 
with __new__ functions.


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


Re: Quality control in open source development

2008-10-08 Thread Samuel A. Falvo II
On Oct 8, 8:43 am, Dave <[EMAIL PROTECTED]> wrote:
> With the open source licenses that allow redistribution of modified
> code, how do you keep someone unaffiliated with the Python community
> from creating his or her own version of python, and declaring it to be
> Python 2.6, or maybe Python 2.7 without any approval of anyone at the
> PSF? Maybe their code is terrible, and not even compatible with the
> rest of Python! How can the PSF, for example, maintain the quality and
> coheren of new code contributed to be part of Python, or derivative
> works that claim to be some future version of Python? If licensees can
> redisribute as they like, isn't this a huge problem? Is this dealt
> with be restricting use of the Python trademarks?  Just curious..

Most trademark violations have occurred, to the best of my
recollection, by commercial entities trying to usurp the popularity of
an open-source endeavor for their own commercial gain.  It is very
rare that another in the open-source community will commandeer the
good name of another project for his own purposes.

This gives strong credence to the idea that the highly participatory
nature of the open-source community serves as a strong, self-enforcing
deterrent to negative acts of this nature.

As far as quality assurance itself goes, independent, third-party unit
test suites are easily engineered.  Parties who do manage to succeed
in releasing their own "Python 2.7" can do so only by either making
their product compatible with this third-party verification suite, or
by not doing so.  This leads to two situations:

(1) If compatible, then the name "Python 2.7" may well be accepted by
the community, even if only in an allegorical sense (e.g., "If PSF
released Python 2.7, this product is how I envision it'd be like.").
Alternatively, people will recognize the product as being Python-
compatible, but otherwise an independent line of development -- e.g.,
a fork.  The PSF can then release under a new set of version numbers
(where everyone understands that 2.7 is an independent fork not
endorsed by PSF), persue negotiations (ultimately terminating in legal
action) to arrive at an acceptable product name, etc.  If the PSF were
feeling particularly benevolent, they could even accept some ideas
from the 2.7 release into their own branch of development.

(2) If incompatible, the product will gather a reputation of
inferiority rapidly, and those clearly interested in Python will
neither want nor have anything to do with this misbranded malfeasance.

Again, independent verification is an example of the participatory
nature of the community at large, and is a prime example of how
concerned citizens can act collectively in their own interest,
independently, to help ensure the quality of a socially-accepted
product.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Using subprocess module to launch a shell shell script that itself forks a process

2008-10-08 Thread Samuel A. Falvo II
On Oct 7, 6:23 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote:
> Is your shell script doing something else, apart from invoking the java  
> process?

Obviously, yes.  The script is some 150 lines long.  But the hang-up
occurs because of the forked Java process, not the other lines.

> If not, you could just invoke java directly from Python. Also,  
> you set stdin=PIPE - is your java process expecting some input? you're not  
> writing anything to stdin.

It does not expect input from stdin.  However, this does not affect
any OTHER scripts or commands I run.

Let's remember to look at the objective facts: for shell scripts that
launch child processes of their own, Python hangs.  For all other
types of commands, it works 100% as expected.

> Anyway, it's better to use the communicate method instead (it uses select  
> to read from both stdout and stderr):

That doesn't help me.

> See  http://docs.python.org/library/subprocess.html#subprocess.Popen.commu...

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


Re: Quality control in open source development

2008-10-08 Thread Terry Reedy

Dave wrote:

With the open source licenses that allow redistribution of modified
code, how do you keep someone unaffiliated with the Python community
from creating his or her own version of python, and declaring it to be
Python 2.6, or maybe Python 2.7 without any approval of anyone at the
PSF? Maybe their code is terrible, and not even compatible with the
rest of Python! How can the PSF, for example, maintain the quality and
coheren of new code contributed to be part of Python, or derivative
works that claim to be some future version of Python? If licensees can
redisribute as they like, isn't this a huge problem? Is this dealt
with be restricting use of the Python trademarks?  Just curious..


The Python license says:
"In the event Licensee prepares a derivative work that is based on or 
incorporates Python 3.0c1 or any part thereof, and wants to make the 
derivative work available to others as provided herein, then Licensee 
hereby agrees to include in any such work a brief summary of the changes 
made to Python 3.0c1."


Other licenses specify that derivatives use a different name or even 
distribute changes as a patch for the unchanged original.


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


Re: Using subprocess module to launch a shell shell script that itself forks a process

2008-10-08 Thread Samuel A. Falvo II
On Oct 8, 11:31 am, "Samuel A. Falvo II" <[EMAIL PROTECTED]> wrote:
> I removed the stdin=PIPE argument, and this works.  Many thanks for
> bringing this to my attention.

OK, I am confused.  After observing a bug where the code works "every
other time", like clockwork, I've used strace to figure out what is
going on.  In the times when "it works," it's only the shell script
complaining that it's already running.

So, I'm right back to square one.  Even _without_ setting stdin=PIPE,
it fails to unblock.  I'm left utterly bewildered.

The only thing I can think of is that the JVM's stdout is tied to the
shell script's stdout, because that's the only way it can remain open
upon the termination of the child process.  I suppose, at this point,
the next place to look is in shell script syntax to find out how to
detach the JVM from the script's process group.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Using subprocess module to launch a shell shell script that itself forks a process

2008-10-08 Thread Sean DiZazzo
On Oct 8, 11:24 am, "Samuel A. Falvo II" <[EMAIL PROTECTED]> wrote:
> On Oct 7, 6:23 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote:
>
> > Is your shell script doing something else, apart from invoking the java  
> > process?
>
> Obviously, yes.  The script is some 150 lines long.  But the hang-up
> occurs because of the forked Java process, not the other lines.
>
> > If not, you could just invoke java directly from Python. Also,  
> > you set stdin=PIPE - is your java process expecting some input? you're not  
> > writing anything to stdin.
>
> It does not expect input from stdin.  However, this does not affect
> any OTHER scripts or commands I run.
>
> Let's remember to look at the objective facts: for shell scripts that
> launch child processes of their own, Python hangs.  For all other
> types of commands, it works 100% as expected.
>
> > Anyway, it's better to use the communicate method instead (it uses select  
> > to read from both stdout and stderr):
>
> That doesn't help me.
>
> > See  
> > http://docs.python.org/library/subprocess.html#subprocess.Popen.commu...
>
> I have.

You should be nicer to Gabriel.  He is a guru.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Quality control in open source development

2008-10-08 Thread Tim Chase

I think it's pretty self-evident that it's not a huge problem, don't
you? Do you see lots of low quality python forks cluttering up the
internet?


hardly any...the best python fork I found:

http://www.woopit.com/albums/Australian-snakes/GreenPythonSnake.jpg

though they look more like tweezers than a fork...



-tkc



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


Re: Using subprocess module to launch a shell shell script that itself forks a process

2008-10-08 Thread Samuel A. Falvo II
On Oct 8, 11:24 am, "Samuel A. Falvo II" <[EMAIL PROTECTED]> wrote:
> It does not expect input from stdin.  However, this does not affect
> any OTHER scripts or commands I run.

OK, so, I'm very confused as to why this would matter.

I removed the stdin=PIPE argument, and this works.  Many thanks for
bringing this to my attention.

But, my question now is, WHY is this an issue?  If the launched
process doesn't read from its stdin, why would it block?  Hence my
question here:

> Let's remember to look at the objective facts: for shell scripts that
> launch child processes of their own, Python hangs.  For all other
> types of commands, it works 100% as expected.

Meaning, if I launched the Java process directly, it works fine.  If I
launch it from the shell script WITHOUT background execution, it works
fine.  But when I launch it WITH background execution (e.g., with the
& suffix), then it blocks.

Any ideas, so I can write this into my log for future reference?

Thanks.

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


MRO inconsistency: why?

2008-10-08 Thread Ravi
Why the following code gives inconsistent method resolution order
error:

class X(object):
x = 4
def f(self):
print 'f in X'
print dir(X)
X.g(self)
def g(self):
print 'g in X'

class Y(object, X):
def g(self):
print 'g in Y'

o = Y()
o.f()

While this code doesn't:

class X(object):
x = 4
def f(self):
print 'f in X'
print dir(X)
X.g(self)
def g(self):
print 'g in X'

class Y(X, object):
def g(self):
print 'g in Y'

o = Y()
o.f()
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python syntax question

2008-10-08 Thread Daniel
On Oct 8, 12:07 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
> On Wed, 08 Oct 2008 11:02:49 -0700, Daniel wrote:
> > Here is one error I get when I try to import it:
>
>  import Rpyc
> > Traceback (most recent call last):
> >   File "", line 1, in 
> >   File "C:\Python25\lib\site-packages\Rpyc\__init__.py", line 7, in
> > 
> >     from Rpyc.Lib import rpyc_excepthook
> >   File "C:\Python25\lib\site-packages\Rpyc\Lib.py", line 65
> >     print("=== Remote traceback ===", file=stderr)
> >                                                   ^
> > SyntaxError: invalid syntax
>
> > The little carrot points to the equal sign ('=') in 'file=stderr'
>
> > What's the syntax problem?
>
> That's Python 3.0 syntax where ``print`` is not a keyword anymore but a
> function.  Won't work with Python 2.5.
>
> Ciao,
>         Marc 'BlackJack' Rintsch

Thanks!  With that I was able to find a solution.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Accessing the message of Outlook inbox

2008-10-08 Thread Mike Driscoll
On Oct 8, 12:50 pm, [EMAIL PROTECTED] wrote:
> On Oct 8, 8:53 pm, Mike Driscoll <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Oct 8, 9:24 am, [EMAIL PROTECTED] wrote:
>
> > > Hi all,
> > >         How can I access the body of a mail in Outlook Inbox? I tried
> > > various options like message.Body or message.Mesg etc. but didn't
> > > work. I could get the subject of the mail using message.Subject
> > > though.
>
> > > Any help is appreciated.
>
> > > Thanks in advance,
> > > Venu
>
> > Can you connect via POP3? If so, the email module should be able to
> > get it. Otherwise, you'll probably have to use the PyWin32 package's
> > win32com module.
>
> > Google is your friend. The following links should give you a general
> > idea of how to access Outlook with Python:
>
> >http://cephas.net/blog/2004/09/17/sending-your-outlook-calendar-using...
>
> > Mike
>
> Thanks Mike for your suggestion.. I am using PyWin32 package's Win32
> module... I did go through those mails,, and am able to access the
> Outlook inbox as they have mentioned.. but am not getting the exact
> function with which I can refer the mails content ( Message of the
> Body)... :-(
>
> THank you,,
> Venu.

Our organization no longer uses Outlook, so I don't have a good way to
test any more. I recommend re-posting to the pywin32 group here:
http://mail.python.org/mailman/listinfo/python-win32

They'll be able to give you pointers and there's plenty of helpful
people there.

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


RE: Python syntax question

2008-10-08 Thread Blubaugh, David A.
Sir,

I was just wondering that the module that you are utilizing (Rpyc) is a remote 
process call module for python?  Is this what you are developing with at this 
time? 

Thanks,


David Blubaugh

 

-Original Message-
From: Daniel [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, October 08, 2008 3:11 PM
To: python-list@python.org
Subject: Re: Python syntax question

On Oct 8, 12:07 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
> On Wed, 08 Oct 2008 11:02:49 -0700, Daniel wrote:
> > Here is one error I get when I try to import it:
>
>  import Rpyc
> > Traceback (most recent call last):
> >   File "", line 1, in 
> >   File "C:\Python25\lib\site-packages\Rpyc\__init__.py", line 7, in 
> > 
> >     from Rpyc.Lib import rpyc_excepthook
> >   File "C:\Python25\lib\site-packages\Rpyc\Lib.py", line 65
> >     print("=== Remote traceback ===", file=stderr)
> >                                                   ^
> > SyntaxError: invalid syntax
>
> > The little carrot points to the equal sign ('=') in 'file=stderr'
>
> > What's the syntax problem?
>
> That's Python 3.0 syntax where ``print`` is not a keyword anymore but 
> a function.  Won't work with Python 2.5.
>
> Ciao,
>         Marc 'BlackJack' Rintsch

Thanks!  With that I was able to find a solution.


This e-mail transmission contains information that is confidential and may be 
privileged. It is intended only for the addressee(s) named above. If you 
receive 
this e-mail in error, please do not read, copy or disseminate it in any manner. 
If you are not the intended recipient, any disclosure, copying, distribution or 
use of the contents of this information is prohibited. Please reply to the 
message immediately by informing the sender that the message was misdirected. 
After replying, please erase it from your computer system. Your assistance in 
correcting this error is appreciated.

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


Re: MRO inconsistency: why?

2008-10-08 Thread Christian Heimes

Ravi wrote:

Why the following code gives inconsistent method resolution order
error:

[...]

Your problem can be reduced to:

>>> class A(object):
... pass
...
>>> A.__mro__
(, )
>>> class B(object, A):
... pass
...
Traceback (most recent call last):
  File "", line 1, in 
TypeError: Error when calling the metaclass bases
Cannot create a consistent method resolution
order (MRO) for bases object, A
>>> class C(A, object):
... pass
...
>>> C.__mro__
(, , )

The class B would require a MRO of (, 'object'>, , ) which isn't allowed in 
Python.


Christian

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


Re: Porn Addiction Solutions?

2008-10-08 Thread mikejanse
On Oct 8, 3:07 pm, [EMAIL PROTECTED] wrote:
> Help, I'm addicted to porn. I've been spending a lot of time
> downloading hardcore porn and masturbating to it. It's ruining my
> life. I just found out that one of these sites somehow hacked my card
> and rang up $5K in charges which they won't even refund me. Even with
> that I haven't stopped my habit and it's only getting worse. How can I
> end this addiction?
>
> Any suggestions?

You need to install a porn filter on your computer. Don't ever surf
unprotected. A good filter program is Optenet PC which you can get at
optenetpc.com.

Be sure to change the password to something you won't remember so that
you won't be tempted to circumvent the filter.

You have made the first step by recognizing excessive pornography use
is a problem in your life. Now you need to change your habits. Use the
filter as a first line of defense to block access to this material
from your computer. Then look at how you can alter the factors that
lead to this behavior.

See these tips:

"Change routines and environments that lead to pornography usage.
Avoid high risk situations."

"Learn new ways of coping with strong feelings like anxiety,
loneliness, anger, depression, and boredom."

"Identify activities that can help you relax, enjoy yourself, and feel
refreshed."

From:

http://www.utdallas.edu/counseling/selfhelp/porn-addiction.html

You can conquer this thing. Let us know how you make out.

Regards,

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


config errors

2008-10-08 Thread Kathleen Krause-Thompson
I've recently setup an environment on Unbuntu for Plone 3.0 that includes
Python 2.4. I get the errors below when doing various things with apt-get
like 'install python'. Is there some configuration that needs to be done as
the message suggests? Thanks in advance.

dpkg: error processing python-setuptools (--configure):
 subprocess post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of python-paste:
 python-paste depends on python-setuptools (>= 0.6b3-1); however:
  Package python-setuptools is not configured yet.
dpkg: error processing python-paste (--configure):inst
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python-pastedeploy:
 python-pastedeploy depends on python-setuptools (>= 0.6b3-1); however:
  Package python-setuptools is not configured yet.
dpkg: error processing python-pastedeploy (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python-pastescript:
 python-pastescript depends on python-paste (>= 1.6-1); however:
  Package python-paste is not configured yet.
 python-pastescript depends on python-pastedeploy (>= 1.3.1-2); however:
  Package python-pastedeploy is not configured yet.
 python-pastescript depends on python-setuptools (>= 0.6b3-1); however:
  Package python-setuptools is not configured yet.
dpkg: error processing python-pastescript (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 python-setuptools
 python-paste
 python-pastedeploy
 python-pastescript

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


Re: MRO inconsistency: why?

2008-10-08 Thread Terry Reedy

Ravi wrote:
Why the following code gives inconsistent method resolution order 
error:


class X(object): x = 4 def f(self): print 'f in X' print dir(X) 
X.g(self) def g(self): print 'g in X'


class Y(object, X): def g(self): print 'g in Y'

o = Y() o.f()


Calculating a linear MRO from a non-tree inheritance graph is a fairly
arcane subject.  Here, I believe, are the two rule relevant here:
1. Direct superclass must remain in the same order as in the class header.
2. A class cannot appear before any of its subclasses.
Violation of these rules can lead to unexpected anomalies.

(object, X) violates rule 2.
(X, object) violates rule 1.
There are no other possible orders.

The only reason to add object to the header first would be if you want Y 
to only inherit new methods defined in X but not object methods 
redefined in X.  To do that, define a class Z that at least copies from 
object those redefined methods and "class Y(Z,X)" should work.



While this code doesn't:

class X(object): x = 4 def f(self): print 'f in X' print dir(X) 
X.g(self) def g(self): print 'g in X'


class Y(X, object): def g(self): print 'g in Y'

o = Y() o.f()


(X, object) satifies both rules.  That said, putting object in the class 
Y header is redundant since object would follow X in the MRO anyway!


Terry Jan Reedy

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


Re: Apache log munging

2008-10-08 Thread Joe Python
I am currently using the following technic to get the info above:

all = defaultdict(int)
hosts = defaultdict(int)
filename = defaultdict(int)

for r in log:
   all[r['host'],r['file']] += 1
   hosts[r['host']] += 1
   filename[r['file']] = 1


for host in sorted(hosts,key=hosts.get, reverse=True):
for file in filename:
  print host, all[host,file]
print hosts[host]
I was looking for a better option instead of building 'three' collections
to improve performance.

- Jo

On Wed, Oct 8, 2008 at 2:15 PM, Joe Riopel <[EMAIL PROTECTED]> wrote:

> On Wed, Oct 8, 2008 at 1:55 PM, Joe Python <[EMAIL PROTECTED]> wrote:
> > I want to find the top '100' hosts (sorted in descending order of total
> > requests) like follows:
> > Is there a fast way to this without scanning the log file many times?
>
> As you encounter a new "host" add it to a dict (or another type of
> collection), and if encountered again, use that "host" as the key to
> retrieve the dict entry and increment it's request count. You should
> only have to read the file once.
>
--
http://mail.python.org/mailman/listinfo/python-list


Re: Job Posting

2008-10-08 Thread Chris Rebert
On Wed, Oct 8, 2008 at 9:20 AM, Capuano, Rebecca
<[EMAIL PROTECTED]> wrote:
> HI,
>
> Would you be able to post this on your site? I don't know if you post jobs.
> Thanks!

This is a general-interest mailinglist about the Python programming
language, not a way of directly contacting just the Python.org admins.
Based on the Community --> Jobs page from the python.org website, you
can find instructions on submitting a job posting on
http://www.python.org/community/jobs/howto/

Cheers,
Chris
-- 
Follow the path of the Iguana...
http://rebertia.com

>
> Our client in Princeton, NJ is looking for a Python Developer to join its
> team.
>
> Description
> A small to medium Python project needs a motivated developer to work with
> the team lead.  The position entails designing, implementing, and  testing a
> flexible schema definition and data cataloging front end for an image and
> metadata management system.  The project may include  building a distributed
> image repository system as well as the cataloging tool.  The entire project
> will eventually be released as  open source software.
>
> 6-month+ project.
>
> Requirements
>
> 3+ years of Python experience preferably in a professional capacity.
> Familiarity with JQuery, PIL, SQLAlchemy, PyProcessing, Pylons, Django.
> Knowledge of functional programming is a plus.
> Knowledge of image processing is a plus.
> Excellent verbal and written communication skills.
>
> You will be required to write some python code as part of  the interview
> proces
>
> To apply please contact:
> Rebecca Capuano
> Sr. Recruiter
> Information Technology and Engineering
> TECHNISOURCE
> 100 Wood Ave. South, Suite 208, Iselin, New Jersey 08830
> Direct 732.635.0700 x 227 | fax 800.258.9775
> [EMAIL PROTECTED] | www.technisource.com
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>
--
http://mail.python.org/mailman/listinfo/python-list


no unbound methods in py3k

2008-10-08 Thread Thomas Heller
I'm currently using code like this to create unbound methods
from functions and stick them into classes:

   method = new.instancemethod(raw_func, None, cls)
   setattr(cls, name, method)

Ok, python 2.6, run with the -3 flag, gives a warning that the new
module is going away in python 3.0, so the equivalent code is:

   method = types.MethodType(raw_func, None, cls)
   setattr(cls, name, method)

However, this code will not work in Python 3.0 because there are
no unbound methods any longer.  The only way that I found so far
is this code:

   method = lambda self, *args: raw_func(self, *args)
   setattr(cls, name, method)

or the equivalent:

   def method(self, *args):
   return raw_func(self, *args)
   setattr(cls, name, method)

but this is very ugly, imo.  Is there another way?
The raw_func instances that I have are not descriptors (they
do not implement a __get__() method...)

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


Re: Quality control in open source development

2008-10-08 Thread Matimus
On Oct 8, 8:43 am, Dave <[EMAIL PROTECTED]> wrote:
> With the open source licenses that allow redistribution of modified
> code, how do you keep someone unaffiliated with the Python community
> from creating his or her own version of python, and declaring it to be
> Python 2.6, or maybe Python 2.7 without any approval of anyone at the
> PSF?

How are they going to "declare" that their version is Python 2.x? What
forum would they use. Current users of python most likely look to
comp.lang.python or python.org for their python update news. New users
of python are likely to use google or another search engine, and
probably land at python.org. Is it possible for me to take Python's
source code, make some changes, and post it somewhere as Python 2.7?
Yes. Will anybody notice? Not likely. Others have made some pretty
sound arguments around trademarks and such, but I'm going to simply
argue that Python as a community has its own inertia, and it simply
isn't a practical to be concerned about a dubious fork. It simply
wouldn't take off.

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


RE: Porn Addiction Solutions?

2008-10-08 Thread Support Desk
I got a solution, cutt it off, and then Kill yourself.

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, October 08, 2008 2:30 PM
To: python-list@python.org
Subject: Re: Porn Addiction Solutions?

On Oct 8, 3:07 pm, [EMAIL PROTECTED] wrote:
> Help, I'm addicted to porn. I've been spending a lot of time
> downloading hardcore porn and masturbating to it. It's ruining my
> life. I just found out that one of these sites somehow hacked my card
> and rang up $5K in charges which they won't even refund me. Even with
> that I haven't stopped my habit and it's only getting worse. How can I
> end this addiction?
>
> Any suggestions?

You need to install a porn filter on your computer. Don't ever surf
unprotected. A good filter program is Optenet PC which you can get at
optenetpc.com.

Be sure to change the password to something you won't remember so that
you won't be tempted to circumvent the filter.

You have made the first step by recognizing excessive pornography use
is a problem in your life. Now you need to change your habits. Use the
filter as a first line of defense to block access to this material
from your computer. Then look at how you can alter the factors that
lead to this behavior.

See these tips:

"Change routines and environments that lead to pornography usage.
Avoid high risk situations."

"Learn new ways of coping with strong feelings like anxiety,
loneliness, anger, depression, and boredom."

"Identify activities that can help you relax, enjoy yourself, and feel
refreshed."

From:

http://www.utdallas.edu/counseling/selfhelp/porn-addiction.html

You can conquer this thing. Let us know how you make out.

Regards,

Mike


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


Re: no unbound methods in py3k

2008-10-08 Thread Christian Heimes

Thomas Heller wrote:

but this is very ugly, imo.  Is there another way?
The raw_func instances that I have are not descriptors (they
do not implement a __get__() method...)


I've written PyInstanceMethod_Type for this use case. It's not (yet) 
available for Python code. Barry hasn't decided whether he should expose 
the type so late in the release cycle or not. See 
http://bugs.python.org/issue3787 and 
http://docs.python.org/dev/3.0/c-api/method.html?highlight=pyinstancemethod#PyInstanceMethod_Type


Christian

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


Re: Porn Addiction Solutions?

2008-10-08 Thread Dotan Cohen
2008/10/8 Support Desk <[EMAIL PROTECTED]>:
> I got a solution, cutt it off, and then Kill yourself.
>

Cut what off? The OP is female.

-- 
Dotan Cohen

http://what-is-what.com
http://gibberish.co.il
א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת

ä-ö-ü-ß-Ä-Ö-Ü
--
http://mail.python.org/mailman/listinfo/python-list


Re: no unbound methods in py3k

2008-10-08 Thread Bruno Desthuilliers

Thomas Heller a écrit :

I'm currently using code like this to create unbound methods
from functions and stick them into classes:

   method = new.instancemethod(raw_func, None, cls)
   setattr(cls, name, method)


setattr(cls, name, func) would work better - given that either 
isinstance(raw_func, function) or raw_func.__get__ is implemented the 
right way.


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


Re: Compiler, ast and forwards/backwards compatibility

2008-10-08 Thread Martin v. Löwis
> The documentation for the ast module states that it "helps to find out
> programmatically what the current grammar looks like". I can't find
> any reference (even when reading the code) on how you should go about
> this, other than checking the sys.version number and reading up on the
> changes.

Not sure what "this" is, but if you mean what you quoted - what does
that have to do with version numbers?

To find out what the grammar looks like, just inspect the classes in
the _ast module, e.g.

py> _ast.For._fields
('target', 'iter', 'body', 'orelse')
py> _ast.For._attributes
['lineno', 'col_offset']

In any case, you shouldn't look at sys.version, but at _ast.__version__

To see the source code version of that, look at Python/Parser.asdl.

> My understanding is that there is no way to write, say, an ast visitor
> that runs under Python 3.0 that targets 2.4 because the ast has
> changed, and there's no way to indicate that you want to parse another
> version.

I wouldn't say that. The writer might not be trivial, but should be
fairly simple. It can't be 1:1, because, as you say, the AST has
changed.

> I guess that Python 2.6 can target Python 2.3-6, and with specific
> compiler flags it can also target 3.0, so it seems that the correct
> thing to do is to use that.

Depends on what you want to do. To transform source code so that
people can still read and understand it, the _ast module might be
inappropriate, as it drops all comments.

For code-rewriting applications, look at lib2to3 instead.

> Am I correct? Am I seriously confused? Please help!

I think you are a little confused.

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


Re: distributing apps without the Python source?

2008-10-08 Thread Bruno Desthuilliers

Marc 'BlackJack' Rintsch a écrit :

On Wed, 08 Oct 2008 10:59:44 -0500, skip wrote:


Marc> On Wed, 08 Oct 2008 09:18:47 -0600, Joe Strout wrote:
>> We have a client who's paranoid about distributing the Python
>> source to his commercial app.  Is there some way I can distribute
>> and use just the .pyc files, so as to not give away the source?

Marc> Yes.  Just use the *.pyc files.

Though of course there is decompyle to consider, assuming Joe's client
is truly paranoid.


Simply don't tell the client.  All he has to know is that it's basically 
the same as Java *.class files.  Most paranoid clients are fine with 
that.  Unless you tell them there are decompilers for *.class files.  :-)



FWIW, even native binary code can be 'disassembled' and hacked.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Compiler, ast and forwards/backwards compatibility

2008-10-08 Thread Martin v. Löwis
> My confusion starts with the fact that I'm not sure if all Python 2.4
> code is going to be syntactically valid 2.6 code.

That's not so much a matter of confusion, but of careful research.

I *think* all code that is syntactically correct in 2.4 is also
syntactically correct in 2.6 - but only because

  raise "Hello"

is still syntactically correct in 2.6 - it's a TypeError, not a
SyntaxError. The other case would be assignment to None, but that
was banned in 2.4 already.

> I guess 2.3 is valid
> 2.4 is valid 2.5

I think not so: assignment to None got disallowed, syntactically
(can't test 2.3, at the moment).

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


Inefficient summing

2008-10-08 Thread beginner
Hi All,

I have a list of records like below:

rec=[{"F1":1, "F2":2}, {"F1":3, "F2":4} ]

Now I want to write code to find out the ratio of the sums of the two
fields.

One thing I can do is:

sum(r["F1"] for r in rec)/sum(r["F2"] for r in rec)

But this is slow because I have to iterate through the list twice.
Also, in the case where rec is an iterator, it does not work.

I can also do this:

sum1, sum2= reduce(lambda x, y: (x[0]+y[0], x[1]+y[1]), ((r["F1"],
r["F2"]) for r in rec))
sum1/sum2

This loops through the list only once, and is probably more efficient,
but it is less readable.

I can of course use an old-fashioned loop. This is more readable, but
also more verbose.

What is the best way, I wonder?


-a new python programmer
--
http://mail.python.org/mailman/listinfo/python-list


RE: Porn Addiction Solutions?

2008-10-08 Thread Support Desk
Oh in that case she can email me, I got lots of porn.

-Original Message-
From: Dotan Cohen [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, October 08, 2008 3:15 PM
To: Support Desk
Cc: [EMAIL PROTECTED]; python-list@python.org
Subject: Re: Porn Addiction Solutions?

2008/10/8 Support Desk <[EMAIL PROTECTED]>:
> I got a solution, cutt it off, and then Kill yourself.
>

Cut what off? The OP is female.

-- 
Dotan Cohen

http://what-is-what.com
http://gibberish.co.il
א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת

ä-ö-ü-ß-Ä-Ö-Ü

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


RE: Porn Addiction Solutions?

2008-10-08 Thread Michael . Coll-Barth
 

> From: Dotan Cohen
> 
> 2008/10/8 Support Desk <[EMAIL PROTECTED]>:
> > I got a solution, cutt it off, and then Kill yourself.
> >
> 
> Cut what off? The OP is female.

Are you sure about that?  :)















The information contained in this message and any attachment may be
proprietary, confidential, and privileged or subject to the work
product doctrine and thus protected from disclosure.  If the reader
of this message is not the intended recipient, or an employee or
agent responsible for delivering this message to the intended
recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly prohibited.
If you have received this communication in error, please notify me
immediately by replying to this message and deleting it and all
copies and backups thereof.  Thank you.


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


Re: Inefficient summing

2008-10-08 Thread Bruno Desthuilliers

beginner a écrit :

Hi All,

I have a list of records like below:

rec=[{"F1":1, "F2":2}, {"F1":3, "F2":4} ]

Now I want to write code to find out the ratio of the sums of the two
fields.

One thing I can do is:

sum(r["F1"] for r in rec)/sum(r["F2"] for r in rec)

But this is slow because I have to iterate through the list twice.
Also, in the case where rec is an iterator, it does not work.

I can also do this:

sum1, sum2= reduce(lambda x, y: (x[0]+y[0], x[1]+y[1]), ((r["F1"],
r["F2"]) for r in rec))
sum1/sum2

This loops through the list only once, and is probably more efficient,
but it is less readable.

I can of course use an old-fashioned loop. This is more readable, but
also more verbose.

What is the best way, I wonder?


The best way is the one that give you the correct answer while being 
fast enough - for a definition of 'fast enough' that is highly 
project-specific - and still readable - for a definition of 'readable' 
that may be somehow subjective, but clearly favours a plain for loop 
over your 'I can also do this' snippet.


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


Re: Inefficient summing

2008-10-08 Thread Chris Rebert
I personally would probably do:

from collections import defaultdict

label2sum = defaultdict(lambda: 0)
for r in rec:
for key, value in r.iteritems():
label2sum[key] += value

ratio = label2sum["F1"] / label2sum["F2"]

This iterates through each 'r' only once, and (imho) is pretty
readable provided you know how defaultdicts work. Not everything has
to unnecessarily be made a one-liner. Coding is about readability
first, optimization second. And optimized code should not be
abbreviated, which would make it even harder to understand.

I probably would have gone with your second solution if performance
was no object.

Cheers,
Chris
-- 
Follow the path of the Iguana...
http://rebertia.com

On Wed, Oct 8, 2008 at 1:23 PM, beginner <[EMAIL PROTECTED]> wrote:
> Hi All,
>
> I have a list of records like below:
>
> rec=[{"F1":1, "F2":2}, {"F1":3, "F2":4} ]
>
> Now I want to write code to find out the ratio of the sums of the two
> fields.
>
> One thing I can do is:
>
> sum(r["F1"] for r in rec)/sum(r["F2"] for r in rec)
>
> But this is slow because I have to iterate through the list twice.
> Also, in the case where rec is an iterator, it does not work.
>
> I can also do this:
>
> sum1, sum2= reduce(lambda x, y: (x[0]+y[0], x[1]+y[1]), ((r["F1"],
> r["F2"]) for r in rec))
> sum1/sum2
>
> This loops through the list only once, and is probably more efficient,
> but it is less readable.
>
> I can of course use an old-fashioned loop. This is more readable, but
> also more verbose.
>
> What is the best way, I wonder?
>
>
> -a new python programmer
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list


Re: Porn Addiction Solutions?

2008-10-08 Thread [EMAIL PROTECTED]
On Oct 8, 12:07 pm, [EMAIL PROTECTED] wrote:
> Help, I'm addicted to porn. I've been spending a lot of time
> downloading hardcore porn and masturbating to it. It's ruining my
> life. I just found out that one of these sites somehow hacked my card
> and rang up $5K in charges which they won't even refund me. Even with
> that I haven't stopped my habit and it's only getting worse. How can I
> end this addiction?
>
> Any suggestions?

Thats is quite simple!
You need to call your credit card company and cancel the charge.



--
Your IP and location uncovered:
http://www.infobyip.com

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


Re: Porn Addiction Solutions?

2008-10-08 Thread Dotan Cohen
2008/10/8  <[EMAIL PROTECTED]>:
>> > I got a solution, cutt it off, and then Kill yourself.
>> >
>>
>> Cut what off? The OP is female.
>
> Are you sure about that?  :)
>

On the internet, nobody knows you're a dog.

-- 
Dotan Cohen

http://what-is-what.com
http://gibberish.co.il
א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת

ä-ö-ü-ß-Ä-Ö-Ü
--
http://mail.python.org/mailman/listinfo/python-list


Re: Inefficient summing

2008-10-08 Thread bearophileHUGS
beginner:
> I can of course use an old-fashioned loop. This is more readable, but
> also more verbose.
> What is the best way, I wonder?

In such situation the old loop seems the best solution. Short code is
good only when it doesn't make the code too much slow/difficult to
understand. Keeping the code quite readable is very important. So I
think a simple solution is the best in this situation. The following
code can be understood quickly:

records = [{"F1": 1, "F2": 2}, {"F1": 3, "F2": 4}]

f1sum, f2sum = 0, 0
for rec in records:
f1sum += rec["F1"]
f2sum += rec["F2"]
ratio = f1sum / float(f2sum)
print ratio

Output:
0.6667

Note that I allowed myself to use this line of code:
f1sum, f2sum = 0, 0
because the two values on the right are equal, so you don't need one
bit of brain to understand where each value goes :-)

You can of course generalize the code in various ways, for example:

keys = ["F1", "F2"]
totals = [0] * len(keys)

for rec in records:
for i, key in enumerate(keys):
totals[i] += rec[key]

ratio = totals[0] / float(totals[1])
print ratio

But that already smells of over-engineering. Generally it's better to
use the simpler solution that works in all your cases at a speed that
is acceptable for you (my variant of the KISS principle).

Bye,
bearophile
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python pre-release announcements

2008-10-08 Thread Benjamin
On Oct 8, 12:42 am, Ben Finney <[EMAIL PROTECTED]>
wrote:
> "Martin v. Löwis" <[EMAIL PROTECTED]> writes:
>
> > > Is there some policy document or release management guide that could
> > > be updated for release teams to follow on this without needing to have
> > > this discussion every time?
>
> > It's in PEP 101.
>
> Thank you.
>
> > If it matters to you, please submit a patch to that document (which
> > is in subversion)
>
> Can do.
>
> > to bugs.python.org.
>
> Requires registration and management of yet another online identity
> :-(

And yet one that will never let you down. :)

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


Re: utf-8 read/write file

2008-10-08 Thread Benjamin
On Oct 8, 12:49 pm, Bruno <[EMAIL PROTECTED]> wrote:
> Hi!
>
> I have big .txt file which i want to read, process and write to another .txt 
> file.
> I have done script for that, but im having problem with croatian characters
> (Š,Đ,Ž,Č,Ć).

Can you show us what you have so far?

> How can I read/write from/to file in utf-8 encoding?

import codecs
data = codecs.open("my-utf8-file.txt").read()

> I read file with fileinput.input.
>
> thanks

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


Re: Quality control in open source development

2008-10-08 Thread Martin v. Löwis
Matimus wrote:
> Others have made some pretty
> sound arguments around trademarks and such, but I'm going to simply
> argue that Python as a community has its own inertia, and it simply
> isn't a practical to be concerned about a dubious fork. It simply
> wouldn't take off.

I think this is indeed the strongest argument. If it isn't on
python.org, it won't be Python 2.7 (and people won't mistake it for that).

The PSF encourages alternative implementations of Python
(whether as forks from the current code base, or by starting from
scratch), and there are indeed several such implementations available
(Jython, Stackless Python, IronPython, PyPy). Formally, people need to
designate their implementation with some additional attribute, as
done in this list, or even in "mere" repackaging (ActivePython,
Enthought Python Distribution).

As a matter of fact, all these people not only come up with specific
names because they are required to do so, but also because they are
proud of their specific product, and they *want* people to recognize
that this is different (in various ways) from "core" Python (which
they sometimes call CPython, just to make it clear that this is actually
but another implementation of the Python language).

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


Re: distributing apps without the Python source?

2008-10-08 Thread Almar Klein
You could encrypt the sensitive pieces of source code. I'm not an expert in
that field, but I know Matlab allows
encryption of source code files.

Almar

2008/10/8 Bruno Desthuilliers <[EMAIL PROTECTED]>

> Marc 'BlackJack' Rintsch a écrit :
>
>> On Wed, 08 Oct 2008 10:59:44 -0500, skip wrote:
>>
>>  Marc> On Wed, 08 Oct 2008 09:18:47 -0600, Joe Strout wrote:
>>>>> We have a client who's paranoid about distributing the Python
>>>>> source to his commercial app.  Is there some way I can distribute
>>>>> and use just the .pyc files, so as to not give away the source?
>>>
>>>Marc> Yes.  Just use the *.pyc files.
>>>
>>> Though of course there is decompyle to consider, assuming Joe's client
>>> is truly paranoid.
>>>
>>
>> Simply don't tell the client.  All he has to know is that it's basically
>> the same as Java *.class files.  Most paranoid clients are fine with that.
>>  Unless you tell them there are decompilers for *.class files.  :-)
>>
>>  FWIW, even native binary code can be 'disassembled' and hacked.
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list


Re: distributing apps without the Python source?

2008-10-08 Thread James Mills
On Thu, Oct 9, 2008 at 4:19 AM, Bruno Desthuilliers
<[EMAIL PROTECTED]> wrote:
> Marc 'BlackJack' Rintsch a écrit :
>>
>> On Wed, 08 Oct 2008 10:59:44 -0500, skip wrote:
>>> Though of course there is decompyle to consider, assuming Joe's client
>>> is truly paranoid.
>>
>> Simply don't tell the client.  All he has to know is that it's basically
>> the same as Java *.class files.  Most paranoid clients are fine with that.
>>  Unless you tell them there are decompilers for *.class files.  :-)
>>
> FWIW, even native binary code can be 'disassembled' and hacked.

I must point out though that if your client
is paranoid for intellectual property reasons
(ie: protecting his assets), then you should
be aware that even if you can decompile
a Python compiled module (or a compiled
java class), it's generally pretty useless in this
form to any would-be-thief.

Decompiling/Disassembling never gets you
the original source code back.

cheers
James

-- 
--
-- "Problems are solved by method"
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python syntax question

2008-10-08 Thread Diez B. Roggisch

Blubaugh, David A. schrieb:

Sir,

I was just wondering that the module that you are utilizing (Rpyc) is a remote process call module for python?  Is this what you are developing with at this time? 


Are you internetically challenged?

http://www.google.de/search?q=rpyc&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:de-DE:official&client=firefox-a

*First* hit. And the google excerpt says

"""
RPyC is a transparent, symmetrical python library for 
distributed-computing. Pronounced "are-pie-see", it began as an RPC 
library (hence the name), ...

"""


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


Re: utf-8 read/write file

2008-10-08 Thread gigs

Benjamin wrote:

On Oct 8, 12:49 pm, Bruno <[EMAIL PROTECTED]> wrote:

Hi!

I have big .txt file which i want to read, process and write to another .txt 
file.
I have done script for that, but im having problem with croatian characters
(Š,Đ,Ž,Č,Ć).


Can you show us what you have so far?


How can I read/write from/to file in utf-8 encoding?


import codecs
data = codecs.open("my-utf8-file.txt").read()


I read file with fileinput.input.

thanks


I have tried with codecs, but when i use encoding="utf-8" i get this error on 
word : život


Traceback (most recent call last):
  File "C:\Users\Administrator\Desktop\getcontent.py", line 43, in 
encoding="utf-8").readlines()
  File "C:\Python25\Lib\codecs.py", line 626, in readlines
return self.reader.readlines(sizehint)
  File "C:\Python25\Lib\codecs.py", line 535, in readlines
data = self.read()
  File "C:\Python25\Lib\codecs.py", line 424, in read
newchars, decodedbytes = self.decode(data, self.errors)
UnicodeDecodeError: 'utf8' codec can't decode byte 0x9e in position 0: 
unexpected code byte



i just need to read from file1.txt, process (its simple text processing) some 
words and write them to file2.txt without loss of croatian characters. (šđžčć)

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


Re: distributing apps without the Python source?

2008-10-08 Thread Paul Boddie
On 8 Okt, 23:50, "James Mills" <[EMAIL PROTECTED]> wrote:
>
> I must point out though that if your client
> is paranoid for intellectual property reasons
> (ie: protecting his assets), then you should
> be aware that even if you can decompile
> a Python compiled module (or a compiled
> java class), it's generally pretty useless in this
> form to any would-be-thief.

I beg to differ on the usefulness of the decompiled code: Python
bytecode is pretty high-level stuff, and it doesn't leave that much to
the imagination. It may not give you nice source code, but if you want
answers to questions on how some mechanism in the code works,
decompyle does a reasonable job.

> Decompiling/Disassembling never gets you
> the original source code back.

True, but that's not always what you want, anyway. Some more opinions
on the subject can be found here:

http://wiki.python.org/moin/HowDoYouProtectSource

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


  1   2   >