Re: Porn Addiction Solutions?

2008-10-08 Thread Aaron "Castironpi" Brady
On Oct 8, 2: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?

Do you want ideas for strategies for contending with it?  Do you want
to talk?  Do you want ideas for other places to find people to talk to?
--
http://mail.python.org/mailman/listinfo/python-list


Re: Porn Addiction Solutions?

2008-10-08 Thread Hackamore

[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?


Hi,

they didn't "hack" your account, you gave it to them.

if they're unauthorized charges (not you subscribed to expensive porn 
sites and now don't to pay, or you didn't bother to cancel your 
subscription) contest them

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


Re: re : do something in time interval

2008-10-08 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Hendrik
van Rooyen wrote:

> import time
> while True:
> end_time = time.time() + 5
> while time.time() < end_time:
> do_the_in_between_stuff()
> do_the_every_five_second_stuff()

Maybe I'm dense, but ... where do you stop the busy-waiting?
--
http://mail.python.org/mailman/listinfo/python-list


Re: Safe eval of insecure strings containing Python data structures?

2008-10-08 Thread James Mills
On Thu, Oct 9, 2008 at 2:26 PM, Warren DeLano <[EMAIL PROTECTED]> wrote:
> JSON rocks!  Thanks everyone.

Yes it does :)

> Ben wrote:
>
>>More generally, you should never execute (via eval, exec, or whatever)
>>*any* instruction from an untrusted path; especially not arbitrary
>>data from an input stream.

I second this.

> Wow, for the record,  I completely disagree with this point of view:
> Today's web apps wouldn't exist without safe forms of untrusted eval/exec
> (Javascript anyone?).  Such dogma is appropriate when dealing with the
> CPython VM, but not as a general principle.

It's far better to use Data Structures
rather than Programming Constructs
to represent and transmit your data.

> "Rocket fuel may be dangerous, but you ain't shooting the moon without it!"

Do we trust fuel from untrusted sources ?

cheers
James

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


RE: Safe eval of insecure strings containing Python data structures?

2008-10-08 Thread Warren DeLano
JSON rocks!  Thanks everyone.

Ben wrote:

>More generally, you should never execute (via eval, exec, or whatever)
>*any* instruction from an untrusted path; especially not arbitrary
>data from an input stream.

Wow, for the record,  I completely disagree with this point of view:  Today's 
web apps wouldn't exist without safe forms of untrusted eval/exec (Javascript 
anyone?).  Such dogma is appropriate when dealing with the CPython VM, but not 
as a general principle.

"Rocket fuel may be dangerous, but you ain't shooting the moon without it!"

Cheers,
Warren




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


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

2008-10-08 Thread Aaron "Castironpi" Brady
On Oct 8, 7:21 pm, greg <[EMAIL PROTECTED]> wrote:
> Terry Reedy wrote:
> > 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.
>
...
> [I]t can
> be inconvenient having a function that returns different
> types under different circumstances.
...

No.  It has precedent and there is no cost to convenience in pure
Python.

Perhaps you are passing the result straight to a C extension, and
parsing it straight to integer, but I can't attest to how common that
use case is.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Porn Addiction Solutions?

2008-10-08 Thread suntzu

[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?


try xnxx.com, at least you won't have to pay for anything or deal with 
malware.

--
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

greg wrote:

Terry Reedy wrote:

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.


I consider str.find to be an anomaly in two senses.

First, it is the only function/method I can think of that directly 
duplicates another function/method by replace raising an exception with 
returning an error indicator.  Some developers wanted to drop it from 
3.0, and I too wish it had been.  We get along fine without list.find 
and a whole slew of other such duplicates that one could think of.


Second, it is the only function/method I can think of that follows the 
Unix/C convention of using '-1' as an error/exception/no-can-do 
indicator.  When it is so used, it is not really an int, but an error 
indication represented as an int because there is no other choice.  In 
Python, there is another choice -- None -- which is used routinely, 
including its use as the default return when there is nothing else to 
return.



Although Guido has defended it on the grounds that it can
be inconvenient having a function that returns different
types under different circumstances. Also it discourages
making the mistake of treating the return value as a
boolean.


I consider this backwards.  Since -1 is a legal index in Python (unlike 
some other languages) as well as a legal int, returning -1 allows if not 
encourages the mistake of treating the fake return value as if it were a 
real value.  Returning None would completely prevent any use of the 
error indicator other than to test it, which is the only thing one 
should be able to do with it.  It should not be usable as an index or 
number in further calculations. I consider it a principle that error 
indicators that are returned rather than raised should be an 
illegal-to-use value if not a different type.


As for convenience, "if s.find(t) is None:" is as easily to write (and 
clearer to read) as "if s.find(t) == -1:".  As far as I can see, 
different return types are only an issue, if at all, if values of both 
types are to be used in further calculations.


Terry Jan Reedy


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


Re: Safe eval of insecure strings containing Python data structures?

2008-10-08 Thread Aaron "Castironpi" Brady
On Oct 8, 7:34 pm, "Warren DeLano" <[EMAIL PROTECTED]> wrote:
> I would like to parse arbitrary insecure text string containing nested
> Python data structures in eval-compatible form:  
>
...
> # But I know for certain that the above approach is NOT secure since
> object attributes can still be accessed...
>
> So is there an equally convenient yet secure alternative available for
> parsing strings containing Python data structure definitions?
>
> Thanks in advance for any pointers!
>
> Cheers,
> Warren

As mentioned, I don't know if everything has been tried or how secure
what attempts have been.  I haven't seen this one:

Python 2.6 (r26:66721, Oct  2 2008, 11:35:03) [MSC v.1500 32 bit
(Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> del __builtins__
>>> a= [ x for x in (1).__class__.__bases__[0].__subclasses__() if x.__name__==
'file' ][ 0 ]
>>> a

>>> a('abc.txt','w')
Traceback (most recent call last):
  File "", line 1, in 
IOError: file() constructor not accessible in restricted mode
>>> import os
Traceback (most recent call last):
  File "", line 1, in 
ImportError: __import__ not found

So, at least one of the newsgroup favorites is gone.  Take a shot
though!  Maybe a variant would be sufficient.  No warranty.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Porn Addiction Solutions?

2008-10-08 Thread mattmatical
On Wed, 8 Oct 2008 12:30:09 -0700 (PDT), [EMAIL PROTECTED] wrote:



>You can conquer this thing. Let us know how you make out.
>
>Regards,
>
>Mike

Now I finally know why this thing is called usenet.
Most useful post ever.


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


Re: MRO inconsistency: why?

2008-10-08 Thread Michele Simionato
On Oct 8, 9:09 pm, Ravi <[EMAIL PROTECTED]> wrote:
> Why the following code gives inconsistent method resolution order
> error:
> 

If you want to know all the nitty-gritty details about
the MRO (including the reason for the error you get)
you should read this:
http://www.python.org/download/releases/2.3/mro/

HTH,

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


inspect feature

2008-10-08 Thread Aaron "Castironpi" Brady
Hello,

The 'inspect' module has this method:

inspect.getargvalues(frame)

It takes a frame and returns the parameters used to call it, including
the locals as defined in the frame, as shown.

>>> def f( a, b, d= None, *c, **e ):
... import inspect
... return inspect.getargvalues( inspect.currentframe() )
...
>>> f( 0, 1, 'abc', 'def', ( 3, 2 ), h= 'ghi' )
(['a', 'b', 'd'], 'c', 'e', {'a': 0, 'c': ('def', (3, 2)), 'b': 1,
'e': {'h': 'g
hi'}, 'd': 'abc', 'inspect': })

However, if you wanted a decorator that examines the parameters to a
function, you're out of luck.  By the time you have a frame, you're
already in the function.

Perhaps it would not be as common as something like 'join' for
example, or even the rest of the functions in 'inspect', but do you
think something similar to 'getargvalues' that accepted a function and
an argument list, and returned a dictionary mapping parameters to
values, could be useful?

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


inspect bug

2008-10-08 Thread Aaron "Castironpi" Brady
Hi all,

Found this bug.  It's in 2.6, too bad.

Python 2.6 (r26:66721, Oct  2 2008, 11:35:03) [MSC v.1500 32 bit
(Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> import inspect
>>> type( inspect.getargvalues( inspect.currentframe() ) )


Docs say:

inspect.getargvalues(frame)
...
Changed in version 2.6: Returns a named tuple ArgInfo(args, varargs,
keywords, locals).

The code defines an ArgInfo type, but doesn't instantiate it in the
return, as shown here:

return args, varargs, varkw, frame.f_locals
--
http://mail.python.org/mailman/listinfo/python-list


Re: A question about funcation parameter and self defined object

2008-10-08 Thread Terry Reedy

Wei Guo wrote:

Hi Chris,
 
Thanks a lot for reply, you are right. I want to use this method as a 
static method as:
 
translation = staticmethod( translation )


static methods are mostly useless in Python.  Just put the definition of 
translation outside of any class.


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


Re: Array of dict or lists or ....?

2008-10-08 Thread Scott David Daniels

Pat wrote:
I can't figure out how to set up a Python data structure to read in data 
that looks something like this (albeit somewhat simplified and contrived):


States
   Counties
 Schools
   Classes
  Max Allowed Students
  Current enrolled Students

Nebraska, Wabash, Newville, Math, 20, 0
Nebraska, Wabash, Newville, Gym, 400, 0
Nebraska, Tingo,  Newfille, Gym, 400, 0
Ohio, Dinger, OldSchool, English, 10, 0

With each line I read in, I would create a hash entry and increment the 
number of enrolled students.



You might want something like this:

>>> import collections, functools
>>> int_dict = functools.partial(collections.defaultdict, int)
>>> curr = functools.partial(collections.defaultdict, int)
>>> # builds a dict-maker where t = curr(); t['name'] += 1  "works"
>>> for depth in range(4):
# add a layer with a default of the preceding "type"
curr = functools.partial(collections.defaultdict, curr)
>>> base = curr() # actually make one
>>> base['Nebraska']['Wabash']['Newville']['Math']['max'] = 20
>>> base['Nebraska']['Wabash']['Newville']['Math']['curr'] += 1
>>> base['Nebraska']['Wabash']['Newville']['Math']['curr']
  1
>>> base['Nebraska']['Wabash']['Newville']['English']['curr']
  0


--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list


Re: SMTPlib inside function, extra tab

2008-10-08 Thread Hunter
Thank you Tino.  I appreciate the help.

Duh!  Anything inside """ """ is preformatted text.  I have tabs
inside my preformatted text (without even thinking because it looks
more normal because of the indent).  I removed them and voila!

def send_mail(fromaddress,tolist,msgsubj,messagebody):
import smtplib
SERVER = "mymailserver.mydomain.com"
message = """\
From: %s
To: %s
Subject: %s
%s
""" % (fromaddress, ", ".join(tolist),msgsubj, messagebody)
print message
server = smtplib.SMTP(SERVER)
server.set_debuglevel(1)
server.sendmail(fromaddress, tolist, message)
server.quit()

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


Re: python for *nix system admins

2008-10-08 Thread Erik Southworth
On Sat, Sep 27, 2008 at 4:05 AM, Lars Stavholm <[EMAIL PROTECTED]> wrote:
> Hi All,
>
> I'm new to this list and hoping that this is not off-topic.
> If it is, please point me in the right direction.
>
> I seem to recollect a python module or library for *nix sysadmins,
> but I can't for the life of me find it again.
>
> The module (or library) somehow added unix command capabilities
> to the python language. It seemed like a lesser known, perhaps new,
> python library or module.
>
> Any input or ideas appreciated
> /Lars Stavholm
> --
> http://mail.python.org/mailman/listinfo/python-list
>

Here is a talk.really good.
http://specialkevin.com/?p=83
--
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 Gabriel Genellina
En Wed, 08 Oct 2008 15:24:39 -0300, Samuel A. Falvo II  
<[EMAIL PROTECTED]> escribió:

On Oct 7, 6:23 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote:


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.


But it *does* affect how subprocess handles the child process internally.


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.


Don't conclude too fast... I've tested a variant (using a Perl script as a  
replacement instead of a Java program), and it worked fine:



[EMAIL PROTECTED]:~$ cat foo.sh
#!/bin/sh
perl foo.pl&
echo End of foo.sh

[EMAIL PROTECTED]:~$ cat foo.pl
#!/usr/bin/perl

for ($i=5; $i>0; $i--) {
  print "$i seconds remaining...\n";
  sleep(1);
}
print "End of foo.pl\n";

[EMAIL PROTECTED]:~$ cat foo.py
#!/usr/bin/python2.5

import subprocess

command = "./foo.sh"

p = subprocess.Popen(command,
shell=True,
stdin=None,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
close_fds=True
)
print "py: before p.communicate"
output = p.communicate()[0]
print "py: after p.communicate"
print "py: returncode=",p.returncode
print "py: read",len(output),"bytes"
print "py: output=", repr(output)
print "py: End of foo.py"


[EMAIL PROTECTED]:~$ ./foo.py
py: before p.communicate
py: after p.communicate
py: returncode= 0
py: read 143 bytes
py: output= 'End of foo.sh\n5 seconds remaining...\n4 seconds  
remaining...\n3 seconds remaining...\n2 seconds remaining...\n1 seconds  
remaining...\nEnd of foo.pl\n'

py: End of foo.py
[EMAIL PROTECTED]:~$ uname -a
Linux debian 2.6.18-4-486 #1 Mon Mar 26 16:39:10 UTC 2007 i686 GNU/Linux
[EMAIL PROTECTED]:~$


This was tested both with python 2.4.4 and 2.5.2
I don't think it's a Python problem, but something related to java and how  
it handles stdin/stdout. Try with another program.



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


Several reasons - the child process might send enough text to stderr to  
fill its buffer, and if the parent process doesn't read from the other end  
of the pipe, the child blocks. That's why I suggested to use communicate  
instead of stdout.read() - it takes care of such cases.



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.


Can't you redirect to a file instead?
java foo.jar  >/tmp/foo.log 2>&1 &

--
Gabriel Genellina

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


wxPython binaries for Python 2.6

2008-10-08 Thread Robin Dunn

Hi All,

A set of wxPython binaries for Python 2.6 on Win32, Win64 and Mac OS X 
are now available at http://wxpython.org/download.php



What is wxPython?
-

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

wxPython is a cross-platform toolkit. This means that the same program
will usually run on multiple platforms without modifications.
Currently supported platforms are 32-bit and 64-bit Microsoft Windows,
most Linux or other Unix-like systems using GTK2, and Mac OS X 10.4+.
In most cases the native widgets are used on each platform to provide
a 100% native look and feel for the application.


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

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


Re: Safe eval of insecure strings containing Python data structures?

2008-10-08 Thread Ben Finney
"Warren DeLano" <[EMAIL PROTECTED]> writes:

> I would like to parse arbitrary insecure text string containing
> nested Python data structures in eval-compatible form:

It sounds like you want the ‘json’ library, new in Python 2.6
http://www.python.org/doc/current/library/json>. It's intended
for serialising and deserialising text streams for *data only* (not
executable code).

> # But I know for certain that the above approach is NOT secure since
> object attributes can still be accessed...

More generally, you should never execute (via eval, exec, or whatever)
*any* instruction from an untrusted path; especially not arbitrary
data from an input stream.

-- 
 \  “A hundred times every day I remind myself that […] I must |
  `\   exert myself in order to give in the same measure as I have |
_o__)received and am still receiving” —Albert Einstein |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list


Re: A question about funcation parameter and self defined object

2008-10-08 Thread Wei Guo
Hi Chris,

Thanks a lot for reply, you are right. I want to use this method as a static
method as:

translation = staticmethod( translation )

I think that here the built in function pass None. So we can not pass any
self defined object for static method?

Best regards,

Wei

On Wed, Oct 8, 2008 at 5:50 PM, Chris Rebert <[EMAIL PROTECTED]> wrote:

> On Wed, Oct 8, 2008 at 4:36 PM, Wei Guo <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > I defined a class called vec3 which contains x, y, z and in another
> > function, I tried to call a function which takes a vec3 as a parameter,
> but
> > it seems that parameter is passed as a generic object and I can not
> access x
> > , y, z in my vec3. Could anyone help me with that?
>
> Being dynamically typed, Python has no notion of variables having
> types, so the object isn't being "passed as a generic object", you're
> getting what really is a "generic object" value of type NoneType,
> which means the value of traV is indeed None, not vec3().
>
> >
> > class vec3:
> > def __init__(self, x_ = 0.0, y_ = 0.0, z_ = 0.0):
> > self.x = x_
> > self.y = y_
> > self.z = z_
> > class mat4:
> >  def translation( traV = vec3() ):
> >   tranM.rowLst[index][0] = traV.x
> > AttributeError: 'NoneType' object has no attribute 'x'
>
> This code is perfectly fine. See below.
>
> >
> > Could anyone help me how to turn the traV as type of vec3() instead of
> > NoneType object?
>
> That's not what's happening. It's not like traV is being cast to
> NoneType thus making x inaccessible, as that's not even possible to
> express in Python.
> What's happening is something is calling translation() with None as an
> argument, and of course None (the value the caller provided for traV)
> has no attribute 'x', hence the error. So, check the full exception
> traceback and see who's calling translation() and how the argument
> being passed to it got to be None.
>
> Cheers,
> Chris
> --
> Follow the path of the Iguana...
> http://rebertia.com
>
> >
> > Thanks a lot,
> >
> > Wei
> > --
> > http://mail.python.org/mailman/listinfo/python-list
> >
> >
>
--
http://mail.python.org/mailman/listinfo/python-list


Re: Safe eval of insecure strings containing Python data structures?

2008-10-08 Thread George Sakkis
On Oct 8, 8:34 pm, "Warren DeLano" <[EMAIL PROTECTED]> wrote:

> I would like to parse arbitrary insecure text string containing nested
> Python data structures in eval-compatible form:  
>
> # For example, given a "config.txt" such as:
>
> {
>   'my_atom' : 1.20,
>   'my_dict' : { 2:50 , 'hi':'mom'},
>   'my_list' : [ (1,2,3), [4.5,6.9], 'foo', 0 ]
>
> }
>
> # I would like to do something like this:
>
> empty_space = {'__builtins__' : {}}
>
> try:
>     config = eval(open("config.txt").read(), empty_space, empty_space)
> except:
>     config = {}
>
> print config
>
> # But I know for certain that the above approach is NOT secure since
> object attributes can still be accessed...
>
> So is there an equally convenient yet secure alternative available for
> parsing strings containing Python data structure definitions?
>
> Thanks in advance for any pointers!

This topic comes up every other month or so in this list, so if you
had taken a minute to search for "python safe eval" or a variation
thereof in your favorite search engine, you'd get more than enough
pointers.

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


Re: Porn Addiction Solutions?

2008-10-08 Thread George Sakkis
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?

Yes, get some professional help instead of trolling random groups with
a different email account once a year or so [1].

[1]
http://groups.google.com/group/comp.lang.python/tree/browse_frm/thread/787cc101ed764687/842a8031dbeca8ec?rnum=1&q=porn+addiction&_done=%2Fgroup%2Fcomp.lang.python%2Fbrowse_frm%2Fthread%2F787cc101ed764687%2F9a366c6fa44c0b3d%3Flnk%3Dgst%26q%3Dporn%2Baddiction%26#doc_842a8031dbeca8ec
--
http://mail.python.org/mailman/listinfo/python-list


google urls - Free

2008-10-08 Thread kirbytailorml
http://news.meta.ua/redirect.php?url=vids247.cn/zoo-tube-247-com
http://news.meta.ua/redirect.php?url=vids247.cn/zootube247-com
http://news.meta.ua/redirect.php?url=vids247.cn/www-zootube247
http://news.meta.ua/redirect.php?url=vids247.cn/zooskool
http://news.meta.ua/redirect.php?url=vids247.cn/animalssex
http://news.meta.ua/redirect.php?url=vids247.cn/girls-fucking-animals
http://news.meta.ua/redirect.php?url=vids247.cn/girls-fucking-dogs
http://news.meta.ua/redirect.php?url=vids247.cn/women-fucking-dogs
http://news.meta.ua/redirect.php?url=vids247.cn/girls-fucking-horses
http://news.meta.ua/redirect.php?url=vids247.cn/dogfuck
http://news.meta.ua/redirect.php?url=vids247.cn/sextube-com
http://news.meta.ua/redirect.php?url=vids247.cn/tila-tequila-nude
http://news.meta.ua/redirect.php?url=vids247.cn/miley-cyrus-nude
http://news.meta.ua/redirect.php?url=vids247.cn/miley-cyrus-naked
http://news.meta.ua/redirect.php?url=vids247.cn/brenda-song-nude
http://news.meta.ua/redirect.php?url=vids247.cn/robbs-celebrity-oops
http://news.meta.ua/redirect.php?url=vids247.cn/john-cena-naked
http://news.meta.ua/redirect.php?url=vids247.cn/miley-cyrus-upskirt
http://news.meta.ua/redirect.php?url=vids247.cn/emma-watson-upskirt
http://news.meta.ua/redirect.php?url=vids247.cn/keezmovies
http://news.meta.ua/redirect.php?url=vids247.cn/sunporno
http://news.meta.ua/redirect.php?url=vids247.cn/qporno
http://news.meta.ua/redirect.php?url=vids247.cn/dreammovies
http://news.meta.ua/redirect.php?url=vids247.cn/xxxtube
http://news.meta.ua/redirect.php?url=vids247.cn/xxxstash
--
http://mail.python.org/mailman/listinfo/python-list


google urls - Free

2008-10-08 Thread wbdismalgoldstein
http://news.meta.ua/redirect.php?url=vids247.cn/zoo tube 365 com
http://news.meta.ua/redirect.php?url=vids247.cn/zootube365 com
http://news.meta.ua/redirect.php?url=vids247.cn/www zootube365
http://news.meta.ua/redirect.php?url=vids247.cn/zooskool
http://news.meta.ua/redirect.php?url=vids247.cn/animalssex
http://news.meta.ua/redirect.php?url=vids247.cn/girls fucking animals
http://news.meta.ua/redirect.php?url=vids247.cn/girls fucking dogs
http://news.meta.ua/redirect.php?url=vids247.cn/women fucking dogs
http://news.meta.ua/redirect.php?url=vids247.cn/girls fucking horses
http://news.meta.ua/redirect.php?url=vids247.cn/dogfuck
http://news.meta.ua/redirect.php?url=vids247.cn/sextube com
http://news.meta.ua/redirect.php?url=vids247.cn/tila tequila nude
http://news.meta.ua/redirect.php?url=vids247.cn/miley cyrus nude
http://news.meta.ua/redirect.php?url=vids247.cn/miley cyrus naked
http://news.meta.ua/redirect.php?url=vids247.cn/brenda song nude
http://news.meta.ua/redirect.php?url=vids247.cn/robbs celebrity oops
http://news.meta.ua/redirect.php?url=vids247.cn/john cena naked
http://news.meta.ua/redirect.php?url=vids247.cn/miley cyrus upskirt
http://news.meta.ua/redirect.php?url=vids247.cn/emma watson upskirt
http://news.meta.ua/redirect.php?url=vids247.cn/keezmovies
http://news.meta.ua/redirect.php?url=vids247.cn/sunporno
http://news.meta.ua/redirect.php?url=vids247.cn/qporno
http://news.meta.ua/redirect.php?url=vids247.cn/dreammovies
http://news.meta.ua/redirect.php?url=vids247.cn/xxxtube
http://news.meta.ua/redirect.php?url=vids247.cn/xxxstash
--
http://mail.python.org/mailman/listinfo/python-list


xtube - Free

2008-10-08 Thread wbdismalgoldstein
xtube
.
.
.
***CLICK HERE
http://vids247.cn/xtube
*
.
.
.
.
.
.
.
.
.
.
.
.
xtube
--
http://mail.python.org/mailman/listinfo/python-list


Google Advanced Urls - Free

2008-10-08 Thread wbdismalgoldstein
Hello
--
http://mail.python.org/mailman/listinfo/python-list


Re: Safe eval of insecure strings containing Python data structures?

2008-10-08 Thread Chris Rebert
On Wed, Oct 8, 2008 at 5:34 PM, Warren DeLano <[EMAIL PROTECTED]> wrote:
>
> I would like to parse arbitrary insecure text string containing nested
> Python data structures in eval-compatible form:
>
> # For example, given a "config.txt" such as:
>
> {
>  'my_atom' : 1.20,
>  'my_dict' : { 2:50 , 'hi':'mom'},
>  'my_list' : [ (1,2,3), [4.5,6.9], 'foo', 0 ]
> }
>
> # I would like to do something like this:
>
> empty_space = {'__builtins__' : {}}
>
> try:
>config = eval(open("config.txt").read(), empty_space, empty_space)
> except:
>config = {}
>
> print config
>
> # But I know for certain that the above approach is NOT secure since
> object attributes can still be accessed...
>
> So is there an equally convenient yet secure alternative available for
> parsing strings containing Python data structure definitions?

Assuming the data structures are sufficiently basic, i.e. no class
instanciations, you can just use the json (AKA simplejson) library to
deserialize the data in the string. Python and JSON conveniently
happen to share the same syntax for literals (except for booleans
IIRC).
Also, if this is your program's config file, you might consider
changing it to INI-format and using ConfigParser
(http://www.python.org/doc/2.5.2/lib/module-ConfigParser.html)
instead.

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

>
> Thanks in advance for any pointers!
>
> Cheers,
> Warren
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list


Re: A question about funcation parameter and self defined object

2008-10-08 Thread Chris Rebert
On Wed, Oct 8, 2008 at 4:36 PM, Wei Guo <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I defined a class called vec3 which contains x, y, z and in another
> function, I tried to call a function which takes a vec3 as a parameter, but
> it seems that parameter is passed as a generic object and I can not access x
> , y, z in my vec3. Could anyone help me with that?

Being dynamically typed, Python has no notion of variables having
types, so the object isn't being "passed as a generic object", you're
getting what really is a "generic object" value of type NoneType,
which means the value of traV is indeed None, not vec3().

>
> class vec3:
> def __init__(self, x_ = 0.0, y_ = 0.0, z_ = 0.0):
> self.x = x_
> self.y = y_
> self.z = z_
> class mat4:
>  def translation( traV = vec3() ):
>   tranM.rowLst[index][0] = traV.x
> AttributeError: 'NoneType' object has no attribute 'x'

This code is perfectly fine. See below.

>
> Could anyone help me how to turn the traV as type of vec3() instead of
> NoneType object?

That's not what's happening. It's not like traV is being cast to
NoneType thus making x inaccessible, as that's not even possible to
express in Python.
What's happening is something is calling translation() with None as an
argument, and of course None (the value the caller provided for traV)
has no attribute 'x', hence the error. So, check the full exception
traceback and see who's calling translation() and how the argument
being passed to it got to be None.

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

>
> Thanks a lot,
>
> Wei
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>
--
http://mail.python.org/mailman/listinfo/python-list


Safe eval of insecure strings containing Python data structures?

2008-10-08 Thread Warren DeLano

I would like to parse arbitrary insecure text string containing nested
Python data structures in eval-compatible form:  

# For example, given a "config.txt" such as:

{ 
  'my_atom' : 1.20,
  'my_dict' : { 2:50 , 'hi':'mom'},
  'my_list' : [ (1,2,3), [4.5,6.9], 'foo', 0 ]
}

# I would like to do something like this:

empty_space = {'__builtins__' : {}}

try:
config = eval(open("config.txt").read(), empty_space, empty_space)
except:
config = {} 

print config

# But I know for certain that the above approach is NOT secure since
object attributes can still be accessed...

So is there an equally convenient yet secure alternative available for
parsing strings containing Python data structure definitions?

Thanks in advance for any pointers!

Cheers,
Warren


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


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

2008-10-08 Thread greg

Terry Reedy wrote:

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.


Although Guido has defended it on the grounds that it can
be inconvenient having a function that returns different
types under different circumstances. Also it discourages
making the mistake of treating the return value as a
boolean.

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


Re: distributing apps without the Python source?

2008-10-08 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Joe Strout
wrote:

> We have a client who's paranoid about distributing the Python source
> to his commercial app.

"Commercial" is not synonymous with "closed source". If he wanted to keep
the source closed, Python was a poor choice. You could redo it in C or C++,
and charge the client appropriately* for all the extra time and effort etc.

*i.e. lots

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


Re: If an OS was to be written in Python, how'w it look?

2008-10-08 Thread Greg Ewing

James Mills wrote:


I've just checked out the darcs repository and converted
it to Mercurial. I'm going to have a bit of a play wiht it...

Anyone interested in this ?


I'll be interested to hear of any developments.
--
http://mail.python.org/mailman/listinfo/python-list


Re: split a list based on a predicate

2008-10-08 Thread bearophileHUGS
Rajanikanth Jammalamadaka:
> Is there a functional way to do this?
> I have an array [0,1,2,3,0,1,2,2,3] and I want the first chunk of
> non-decreasing values from this array (eg: In this case I want
> [0,1,2,3])

In Python sometimes the best way to write the code isn't functional,
this is readable code:

s = [3,1,2,3,0,1,2,2,3,3,2]

it = iter(s)
prec = it.next() #fix this if it can be empty
groups = [[prec]]
for x in it:
if x < prec:
groups.append([])
groups[-1].append(x)
prec = x
print groups

Output:
[[3], [1, 2, 3], [0, 1, 2, 2, 3, 3], [2]]

If you want more fancy code you may use something like this:

class Infinite:
def __cmp__(self, other):
return 0 if isinstance(other, Infinite) else 1
infinite = Infinite()

it = iter(s)
prec = infinite
groups = []
for x in it:
if x < prec:
groups.append([])
groups[-1].append(x)
prec = x
print groups

If you really want functional code you may try to use groupby().

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


Re: split a list based on a predicate

2008-10-08 Thread Tim Chase

Is there a functional way to do this?

I have an array [0,1,2,3,0,1,2,2,3] and I want the first chunk of
non-decreasing values from this array (eg: In this case I want
[0,1,2,3])



Sounds like a use for a generator wrapper:

  def monotonic(iterator):
i = iter(iterator)
prev = i.next()
yield prev
while True:
  this = i.next()
  if prev <= this:
yield this
prev = this
  else:
break

  >>> lst1 = [0,1,2,3,0,1,2,2,3]
  >>> lst2 = [0,1,2,3,3,0,1,2,2,3]
  >>> print list(monotonic(lst1))
  [0,1,2,3]
  >>> print list(monotonic(lst2))
  [0,1,2,3,3]

Adjust the "<=" to "<" depending on your needs (my "lst2" 
condition probes that edge)


-tkc



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


A question about funcation parameter and self defined object

2008-10-08 Thread Wei Guo
Hi,

I defined a class called vec3 which contains x, y, z and in another
function, I tried to call a function which takes a vec3 as a parameter, but
it seems that parameter is passed as a generic object and I can not access x
, y, z in my vec3. Could anyone help me with that?

 class vec3:
def __init__(self, x_ = 0.0, y_ = 0.0, z_ = 0.0):
self.x = x_
self.y = y_
self.z = z_
class mat4:
 def translation( traV = vec3() ):
  tranM.rowLst[index][0] = traV.x
AttributeError: 'NoneType' object has no attribute 'x'

Could anyone help me how to turn the traV as type of vec3() instead of
NoneType object?

Thanks a lot,

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


split a list based on a predicate

2008-10-08 Thread Rajanikanth Jammalamadaka
Hi!

Is there a functional way to do this?

I have an array [0,1,2,3,0,1,2,2,3] and I want the first chunk of
non-decreasing values from this array (eg: In this case I want
[0,1,2,3])

Thanks,

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


Re: ssh problem using paramiko?

2008-10-08 Thread Steve Holden
Diez B. Roggisch wrote:
> 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.
> 
No, you really don't want to use SSHv1. Amtelnet won't do, it's an SSH
*server* the OP needs, I understand. Why not openssh.org?

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


Re: utf-8 read/write file

2008-10-08 Thread Kent Johnson
On Oct 8, 5:55 pm, gigs <[EMAIL PROTECTED]> wrote:
> 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
> >> (©,Ð,®,È,Æ).
>
> UnicodeDecodeError: 'utf8' codec can't decode byte 0x9e in position 0:
> unexpected code byte

Are you sure you have UTF-8 data? I guess your file is encoded in
CP1250 or CP1252; in both of these charsets 0x9e represents LATIN
SMALL LETTER Z WITH CARON.

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


Re: ssh problem using paramiko?

2008-10-08 Thread Steve Holden
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.openssh.org/ would be my first port of call.

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


Re: utf-8 read/write file

2008-10-08 Thread Aleksandar Radulovic
Hi,

What is the encoding of the file1 you're reading from? I just ran
tests on my machine (OS X)
with both python2.5 and 2.6 and was able to read from a file containing:
"život je lep"

The file is UTF-8 encoded.

>>> data = open("test.txt").read()
>>> data
'\xc5\xbeivot je lep.'
>>> f = open("test2.txt", "wb")
>>> f.write(data)
>>> f.close()

mac-alex:~ alex$ file test.txt
test.txt: UTF-8 Unicode text, with no line terminators
mac-alex:~ alex$ file test2.txt
test2.txt: UTF-8 Unicode text, with no line terminators
mac-alex:~ alex$

Files test.txt and test2.txt are identical.

Regards,
alex.


2008/10/8 gigs <[EMAIL PROTECTED]>:
> 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
>



-- 
a lex 13 x
--
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


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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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


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: 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


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
> 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: 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: 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 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 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: 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


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: 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


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: 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


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: 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


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: 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: 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 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


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: 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 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: 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 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


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 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 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: 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: 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: 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: 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


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: 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


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: 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


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: 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


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


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: 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


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: 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: 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: 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


  1   2   >