Re: [Solved] SIP installation and usage on windows

2010-04-12 Thread omnia neo
On Apr 9, 7:41 pm, Gabriel Genellina  wrote:
> omnia neo  gmail.com> writes:
>
>
>
>
>
> > On Apr 9, 10:42 am, omnia neo  wrote:
> > > On Apr 9, 10:30 am, Stefan Behnel  wrote:
>
> > > > omnia neo, 09.04.2010 07:01:
>
> > > > > import siptest
>
> > > > > I get following error :
> > > > > import error : no module named siptest
>
> > > > Is the directory where your siptest.dll lies in your PYTHONPATH
> (sys.path)?
> > > well I added PYTHONPATH =  in my environment variables
> > > (windows XP).
>
> > well I just tried this too.
> > I added the path using sys.path on the fly in my python script as
> > follows:
>
> > ###
> > import sys
> > sys.path.append("")
> > print sys.path
> > import siptest
> > ###
>
> > again same error:
> > ImportError: No module named siptest.
>
> Make sure the extension module must is called siptest.pyd, not 
> siptest.dllhttp://docs.python.org/extending/windows.html
> (I'd expect SIP to take care of this)
>
> --
> Gabriel Genellina- Hide quoted text -
>
> - Show quoted text -

SIP tool installation steps are as follows:
•   Download latest SIP from: 
http://www.riverbankcomputing.co.uk/software/sip/download
and unzip to any location.
•   Make sure python is in PATH of environment variables -> PATH = %PATH
%;C:\python26
•   Go to cmd promt -> go to the SIP location (location of download) ->
run :/python configure.py
•   It will take all the default setting for configuration, the default
directories will be in c:\python26 (change if required)
•   Go to Start -> programs -> MS visual studios -> visuals studio tools-
> command prompt. Go to SIP folder (location of download)
•   \> nmake -> this will run makefile and build sip.exe and sip.pyd
•   \> nmake  install -> this will copy: sip.exe, sip.pyd,sip.h,
sipconfig.py, sipdistutils.py in C:\python26 
•   Go to the folder where the manually written .sip file is present in
command prompt and run the following:
sip -e -j 1 -c . xyz.sip

Steps to create an extension module:
1.  Create a “.sip” specification file for the C/C++ library
a.  Follow the syntax definitions as given in
http://www.riverbankcomputing.co.uk/static/Docs/sip4/specification_files.html#syntax-definition
b.  Appropriately add the C/C++ classes, functions, methods and
structures in the specification file.
2.  Run the SIP tool utility on the specification file to create the
intermediate C/C++ code.
3.  Copy and edit the simple build script as shown in
http://www.riverbankcomputing.co.uk/static/Docs/sip4/using.html#a-simple-c-example
4.  Run the build script to create the makefile, the CModule, the .sbf
files
5.  Run Visual Studios nmake utility on the makefile to create the .pyd
file which is the final module which can be imported from python.


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


Re: Extracting an undefined number of items from a list

2010-04-12 Thread Patrick Maupin
On Apr 12, 9:26 pm, Steven D'Aprano
 wrote:

> # The obfuscated, fragile way
> map( itemgetter(0), sorted(
>      zip(db, range(1, len(db)+1)), key=lambda t: t[1] if t[1] in i else -1
>      )[-len(i):] )

I have to hand it to you that this might, in fact, be "the"
obfuscated, fragile way, but I gotta tell you that I'm certain there
exist other ways that are considerably less obfuscated and
considerably less fragile that I, personally would still consider to
be obfuscated and fragile...

The only thing you get points off for is the lack of a multiply or
divide by 10.  The original data set is just crying out for such a
thing, and, while it might not do all that much for the obfuscation,
it would certainly help with the fragility. ;-)

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


Re: Extracting an undefined number of items from a list

2010-04-12 Thread Steven D'Aprano
On Mon, 12 Apr 2010 13:05:30 -0700, vsoler wrote:

> Hi everyone,
> 
> say that 'db' is a list of values
> say 'i' is a list of indexes
> I'd like to get a list where each item is i-th element of db.
> 
> For example:
> 
> db=[10,20,30,40,50,60,70,80,90]  #undefined length 
> i=[3,5,7]  #undefined length then 
> result=[30,50,70]  # resulting list
> 
> how can I do this?


Others have given a simple solution using list comprehensions. Here's 
another few ways.


# The beginner's way
result = []
for index in i: # "i" is a bad name for a list of indexes
x = db[index - 1]  # shift from one-based counts to zero-based
result.append(x)


# The advanced functional way
from operator import itemgetter
indexes = map(lambda n: n-1, i)  # adjust for one-based counts
result = itemgetter(*indexes)(db)



# The obfuscated, fragile way
map( itemgetter(0), sorted(
 zip(db, range(1, len(db)+1)), key=lambda t: t[1] if t[1] in i else -1
 )[-len(i):] )



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


It's a fact not lost on the opportunity to see yourself

2010-04-12 Thread a m
http://www.google.com/url?sa=D&q=http://osamah2000.jeeran.com/daauageralmuslmeen1.htm&usg=AFQjCNGQhhGz-1TGv9Y7gE8zKwHHustJCg
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What license/copyright text to include and where to include it when selling a commercial Python based application?

2010-04-12 Thread Robert Kern

On 2010-04-12 17:02 PM, Malcolm Greene wrote:

Looking for advice on what Python license and copyright text to
include and where to include it when selling a commercial
(Windows based) Python based application.


The requirement is fairly broad; there are a number of things you could do to 
satisfy the requirement. Largely, it's up to you as long as the full license 
text is accessible somewhere. I will provide personal, entirely unofficial 
recommendations below, though.



By license text and copyrights I am refering to the text on this
page:

PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
http://www.python.org/download/releases/2.6.5/license/

By "where to include it" I mean:

1. What Python license text/copyright text should I place in our
printed user manual?


The whole license and history text, parts A and B.


2. What Python license text/copyright text should I include in
our online documentation?


The whole thing.


3. What Python license text/copyright text should I include in
product's license text file?


Have a licenses\ directory with a LICENSE_Python.txt containing the whole 
license text. Have other LICENSE_.txt files for any other third-party 
libraries you use, like the GUI toolkit.



4. What Python license text/copyright text should I include in
application's splash screen and about dialog boxes?


Link to the part of the online documentation that lists the third-party software 
that you use.


--
Robert Kern

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

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


What license/copyright text to include and where to include it when selling a commercial Python based application?

2010-04-12 Thread Malcolm Greene
Looking for advice on what Python license and copyright text to
include and where to include it when selling a commercial
(Windows based) Python based application.

By license text and copyrights I am refering to the text on this
page:

PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
http://www.python.org/download/releases/2.6.5/license/

By "where to include it" I mean:

1. What Python license text/copyright text should I place in our
printed user manual?

2. What Python license text/copyright text should I include in
our online documentation?

3. What Python license text/copyright text should I include in
product's license text file?

4. What Python license text/copyright text should I include in
application's splash screen and about dialog boxes?

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


Re: Startup problems with Python 3.1.2 and PythonPath under XP

2010-04-12 Thread Martin v. Loewis
tkp...@hotmail.com wrote:
> I fixed the problem by creating a file call MyPath.pth that has only
> one line
> H:/Python
> 
> and placing it in the C:\Python31\Lib\site-packages directory. So as a
> practical matter, my problem is solved. That said, I'm still puzzled
> by why Python 3.1 acts up when I set the environment variable
> PYTHONPATH. It certainly caused no problem with the 2.X series.

Most likely, H:\Python contains a module with a name that conflicts with
the standard library. Starting IDLE tries to import that module - but
not from the standard library, but your own version. That module then
(of course) fails to work correctly. By putting in a pth file, h:\python
is *appended* to sys.path, not prepended.

However, the real fix is not to use module names that conflict with the
standard library.

Run idle.py in a cmd.exe shell window to find out what the true cause of
the problem is.

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


Re: Destructor being called twice?

2010-04-12 Thread Duncan Booth
Longpoke  wrote:

> So either this test case is wrong to assume the destructor can only be
> called once, or there is a bug in Python?

Or perhaps more likely you misunderstand what is happening here. Maybe 
there are two separate instances of A()?

If I remember correctly gtk wraps C objects in Python wrappers when they 
are accessed from Python code. A python wrapper isn't created until it is 
needed and it is destroyed as soon as it is no longer needed.

Since don't save a Python reference to your A() instance when you create 
it I'd expect the original wrapper is destroyed and the another one created 
later when needed. The test does hang on to the gobj reference so there's 
only going to be a single wrapper.
-- 
http://mail.python.org/mailman/listinfo/python-list


Download Visual Studio Express 2008 now

2010-04-12 Thread Martin v. Loewis
Microsoft has just released Visual Studio 2010, along with its free (of
charge) Express edition. Following a tradition, they are likely to
withdraw support and availability for VS 2008 Express some time in the
future.

Python 2.6, 2.7, and 3.1 are all built with that release (i.e. 2008).
Because of another long tradition, Python extension modules must be
built with the same compiler version (more specifically, CRT version) as
Python itself. So to build extension modules for any of these releases,
you need to have a copy of VS 2008 or VS 2008 Express.

If you are planning to build Python extension modules in the next five
years, I recommend that you obtain a copy of VS Express, just in case
Microsoft removes it from their servers. As mentioned, it's free of
charge. When downloading it for later use, it's probably best to get the
offline ISO image release, available from

http://www.microsoft.com/express/Downloads/#2008-All

Disclaimer: I'm not connected with Microsoft or its release process. Any
claim on future actions that Microsoft may take is purely hypothetical.

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


Re: 2.7 beta 1

2010-04-12 Thread Mensanator
On Apr 12, 11:39 am, Terry Reedy  wrote:
> On 4/12/2010 1:57 AM, Mensanator wrote:
>
> > Likewise, I usually don't shut down
> > when I leave work, so I can't allow orphaned processes to accumulate
> > eating up CPU and memory.
>
> So don't.

I don't. I'm complaining about the need to do that.

>
> Orphaned processes only accumulate when you use Restart Shell to abandon
> a process stuck in an infinite loop.

Surely, you don't expect me to beleive that Python
has solved the halting problem and knows when its
in an infinite loop? No, Restart Shell is used whenever
the process is going to take longer than one is willing
to wait.

> I personally very seldom do that.
> Otherwise, the old process dies in a few seconds and the number of
> pythonw processes drops back down from 3 to the normal 2.

You've never written a program that takes more than a
few seconds to execute? Wow.

>
> As I already said, either roboot or use TaskManager to kill such
> zombies.

Do we need to add something to the documentation to explain
this? Something along the lines of:

"Python simply doesn't work properly. You must keep constant
vigilance on the TaskKanager to watch for orphaned processes,
otherwise they will consume all your CPU cycles and eat up your
memory."?

Maybe put it in large red letters under the caption
"WARNING!"?

> When I had a unix desktop machine, I routinely used the command
> line equivalents ps (process status) and kill to do the same thing.

No wonder you don't see the problem! You think it's normal!

>
> Terry Jan Reedy

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


Re: Destructor being called twice?

2010-04-12 Thread Benjamin Peterson
Longpoke  gmail.com> writes:
> So either this test case is wrong to assume the destructor can only be
> called once, or there is a bug in Python?

Destructors can be called more than once in CPython, but other implementations
have proper finalization behavior.




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


Re: Extracting an undefined number of items from a list

2010-04-12 Thread vsoler
On 12 abr, 22:11, Patrick Maupin  wrote:
> On Apr 12, 3:05 pm, vsoler  wrote:
>
> > Hi everyone,
>
> > say that 'db' is a list of values
> > say 'i' is a list of indexes
> > I'd like to get a list where each item is i-th element of db.
>
> > For example:
>
> > db=[10,20,30,40,50,60,70,80,90]      #undefined length
> > i=[3,5,7]                                         #undefined length
> > then result=[30,50,70]                     # resulting list
>
> > how can I do this?
>
> With a list comprehension:
>
> >>> db=[10,20,30,40,50,60,70,80,90]
> >>> i=[3,5,7]
> >>> [db[x-1] for x in i]
>
> [30, 50, 70]
>
> Regards,
> Pat

Thank you Patrick,

Your quick answer only tells me how much I still have to learn.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Extracting an undefined number of items from a list

2010-04-12 Thread Chris Rebert
On Mon, Apr 12, 2010 at 1:05 PM, vsoler  wrote:
> Hi everyone,
>
> say that 'db' is a list of values
> say 'i' is a list of indexes
> I'd like to get a list where each item is i-th element of db.
>
> For example:
>
> db=[10,20,30,40,50,60,70,80,90]      #undefined length
> i=[3,5,7]                                         #undefined length
> then result=[30,50,70]                     # resulting list
>
> how can I do this?

result = [db[k-1] for k in i] # your indices seem to be 1-based

See "List comprehensions":
http://docs.python.org/tutorial/datastructures.html#list-comprehensions

Cheers,
Chris
--
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Extracting an undefined number of items from a list

2010-04-12 Thread Patrick Maupin
On Apr 12, 3:05 pm, vsoler  wrote:
> Hi everyone,
>
> say that 'db' is a list of values
> say 'i' is a list of indexes
> I'd like to get a list where each item is i-th element of db.
>
> For example:
>
> db=[10,20,30,40,50,60,70,80,90]      #undefined length
> i=[3,5,7]                                         #undefined length
> then result=[30,50,70]                     # resulting list
>
> how can I do this?

With a list comprehension:

>>> db=[10,20,30,40,50,60,70,80,90]
>>> i=[3,5,7]
>>> [db[x-1] for x in i]
[30, 50, 70]

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


Extracting an undefined number of items from a list

2010-04-12 Thread vsoler
Hi everyone,

say that 'db' is a list of values
say 'i' is a list of indexes
I'd like to get a list where each item is i-th element of db.

For example:

db=[10,20,30,40,50,60,70,80,90]  #undefined length
i=[3,5,7] #undefined length
then result=[30,50,70] # resulting list

how can I do this?

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


Re: 2.7 beta 1

2010-04-12 Thread Mensanator
On Apr 12, 3:51 am, alex23  wrote:
> Mensanator  wrote:
> > You think the right thing to do is just quietly work
> > around the problem and sit back and laugh knowing sooner
> > or later someone else will get burned by it?
>
> Haven't we covered argument from fallacy enough in this group by now?
>
> Reporting the bug was exactly the right thing to do. Loudly
> pronouncing the impending demise of 3.x because of it was not. Coming
> up with exaggerated parodies of arguments that no one here is actually
> making is even worse.
>
> > Why do you guys think I'm talking about the language? I'm talking
> > about a particular implementation.
>
> Probably because _you_ made no such restriction with your blanket
> statement of "3.x won't be adopted by developers until it's fixed". If
> only "under Windows", "probably" and "IDLE" had been injected into it,
> I don't think there would have been a word of disagreement.

Ok. If more people are aware of the issue now, then the hyperbole
has served it's purpose.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Startup problems with Python 3.1.2 and PythonPath under XP

2010-04-12 Thread tkp...@hotmail.com
I fixed the problem by creating a file call MyPath.pth that has only
one line
H:/Python

and placing it in the C:\Python31\Lib\site-packages directory. So as a
practical matter, my problem is solved. That said, I'm still puzzled
by why Python 3.1 acts up when I set the environment variable
PYTHONPATH. It certainly caused no problem with the 2.X series.

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


Destructor being called twice?

2010-04-12 Thread Longpoke
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi,

Is it normal for the destructor to be called more than once? This code
caused it to happen:

import gtk

class A(gtk.Window):
def __init__(self):
gtk.Window.__init__(self)
self.connect("delete-event", lambda w,e: gtk.main_quit())
def __del__(self):
print 'bye', self

if __name__ == '__main__':
A().show()
print 'enter main'
gtk.main()
print 'quitting'

$ python test.py 
bye 
enter main
bye 
quitting
$ python --version
Python 2.6.4

FYI, gtk.Window is a new-style class. There is another thread about
this claiming this is a bug, but the author only mentions it happening
with old-style classes:

http://mail.python.org/pipermail/python-dev/2006-August/068358.html

I don't suspect this is a bug in pygtk, as a grep for __del__ yields
nothing through pygtk's and pygobject's sources (pygobject is a heavy
dependency of pygtk).

Furthermore, pygtk has a test case to ensure __del__ is called after
GC (pygtk-2.16.0/tests/test_gdk.py), and pygobject has one that asserts
__del__ is only called once (pygobject-2.18.0/tests/test_subtype.py).

A snippet from pygobject-2.18.0/tests/test_subtype.py:
def testSimpleDecref(self):
class CallInDel:
def __init__(self, callback):
self.callback = callback

def __del__(self):
if callable(self.callback):
self.callback()
disposed_calls = []
def on_dispose():
disposed_calls.append(None)
gobj = gobject.GObject()
gobj.set_data('tmp', CallInDel(on_dispose))
del gobj
assert len(disposed_calls) == 1 # < !!

So either this test case is wrong to assume the destructor can only be
called once, or there is a bug in Python?
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.14 (GNU/Linux)

iEYEARECAAYFAkvDbt0ACgkQ3PGpByoQpZEQBQCbB1pzcOBHWrB4RUqFLaEbKt1E
9a4AoKENPAwQ99g8Y/DJwJqDSQFPGZQ2
=/CUN
-END PGP SIGNATURE-
-- 
http://mail.python.org/mailman/listinfo/python-list


mechanize.browser() click or submit related problem

2010-04-12 Thread ken
Hello All.
im making some website login function with mechanize.browser() module.
but problem is i can't send submit or click submit button with
mechanize click() function, it not working.
how can i submit button or click() function make it work?
i can make it work mechanize.Request and mechanize.urlopen() 's POST
function,but
this time i want to make it work mechanize.browser() which emulate web
browser.
please help me!
thanks in advance


# -*- coding: utf-8 -*-
import sys,os
import mechanize, urllib
import cookielib
from BeautifulSoup import BeautifulSoup,BeautifulStoneSoup,Tag
import datetime, time
import re,sys,os,mechanize,urllib,threading,time, socket
br = mechanize.Browser()
# Cookie Jar
cj = cookielib.LWPCookieJar()
br.set_cookiejar(cj)

# Browser options
br.set_handle_equiv(True)
br.set_handle_gzip(True)
br.set_handle_redirect(True)
br.set_handle_referer(True)
br.set_handle_robots(False)

# Follows refresh 0 but not hangs on refresh > 0
br.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(),
max_time=1)

# Want debugging messages?
br.set_debug_http(True)
br.set_debug_redirects(True)
br.set_debug_responses(True)

br.addheaders = [('User-agent', 'Mozilla/4.0 (compatible; MSIE 7.0b;
Windows NT 5.1)')]

br.clear_history()

br.open('http://xo.nate.com/login.jsp')
html = br.response().read()
#print html
 #Show the available forms
for f in br.forms():
print f

# Select the first (index zero) form
#br.select_form(nr=1)
br.select_form(name='f_login')
# Let's search
br.form['ID']= 'prudy'
#br.form['user_password']=['on']
br.form['PASSWD']= 'sotkfkd'
print br.geturl()
br.submit()
html = br.response().read()
print html
-- 
http://mail.python.org/mailman/listinfo/python-list


Startup problems with Python 3.1.2 and PythonPath under XP

2010-04-12 Thread tkp...@hotmail.com
I run Python under Windows XP SP3, and for the longest time, I have
installed it on my C: drive under C:\PythonXX (XX = 20, 21., 26),
and maintained all my Python files on our network in a directory
called H:\Python that I point to by creating an environment variable
called PYTHONPATH. I recently installed 3.1.2 under C:\Python31, and
now IDLE crashes every single time Python 3.1 starts up. If I remove
PYTHONPATH, it starts up without a problem. The mystery deepens -
Python 2.6 starts without a hiccup with or without PYTHONPATH! What
could the issue be? Is there any other way to have H:\Python appended
to sys.path when I start Python 3.1?

Thank you in advance for your help and advice

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


Re: rich comparison fscks up reference count?

2010-04-12 Thread Gerhard Häring
On Apr 12, 4:27 pm, Gerhard Häring 
wrote:
> Maybe somebody can enlighten me here. I can't figure out why doing a
> rich comparison on my object decreases the total reference count by 1. [...]

Doh! It turned out the strange effect was due to my particular build
process.
My Python 2.6/3.1 are built using our own SCons-based build and the
corresponding Makefile that distutils then uses didn't have the same
DEFINEs.

So, the Python was built with Py_REF_DEBUG, but Py_REF_DEBUG was not
defined
when I built my extension module. Which fscked up the *total*
reference
counting  (sys.gettotalrefcount()).

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


Re: Reading in a file

2010-04-12 Thread Chris Rebert
On Mon, Apr 12, 2010 at 11:31 AM, Maggie  wrote:
> hello,
>
> i have a basic script i need to implement. i need below code to read
> in a file and perform operation is it designed to do:
>
> #!/usr/bin/python
>
> import sys
>
> feed = sys.stdin.readlines()

This sounds like homework, so here are some clues:
sys.stdin is a file object.
open('/path/to/file.here', 'r') creates a new readable file object
representing the file at the given path.

You should be able to figure it out from there.

Cheers,
Chris
--
s/aaa/bbb/
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Reading in a file

2010-04-12 Thread Maggie
hello,

i have a basic script i need to implement. i need below code to read
in a file and perform operation is it designed to do:

#!/usr/bin/python

import sys

feed = sys.stdin.readlines()

for temp in feed:
  line = temp.split()
  if len(line) == 3:
 if (line[0] == "xmax" or line[0] == "xmin"):
   time = line[2]
   print str(line[0]) + " " + str(line[1]) + " " +
str(float(time)*2/3)
 else:
   print temp
  else:
 print temp

i appreciate your help in advance..
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: raise exception with fake filename and linenumber

2010-04-12 Thread Gabriel Genellina

En Fri, 09 Apr 2010 23:19:48 -0300, kwatch  escribió:


On 4月8日, 午後12:52, "Gabriel Genellina"  wrote:


The built-in SyntaxError exception does what you want. Constructor  
parameters are undocumented, but they're as follows:


raise SyntaxError("A descriptive error message", (filename,  
linenum, colnum, source_line))


colnum is used to place the ^ symbol (10 in this fake example). Output:

Traceback (most recent call last):
   File "1.py", line 9, in 
 foo()
   File "1.py", line 7, in foo
 raise SyntaxError("A descriptive error message", (filename,  
linenum, colnum, "this is line 123 in example.file"))

   File "example.file", line 123
 this is line 123 in example.file
  ^
SyntaxError: A descriptive error message



By the way, is it hard to specify any other exception class instead of
SyntaxError?
The SyntaxError class is a good solution in my case, but if possible,
I want to know
more general solution to specify filename and linenum for exception.


You can always store any info you want in the exception object, just write  
__str__ accordingly.
The advantage of SyntaxError is that it is special-cased in the  
interpreter itself as to add some spaces and the ^ character.
The disadvantages are already pointed out by Dennis Lee Bieber and aren't  
minor.


--
Gabriel Genellina

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


Re: How to read file during module import?

2010-04-12 Thread Gabriel Genellina

En Fri, 09 Apr 2010 19:16:14 -0300, Jeremy  escribió:

On Apr 9, 4:02 pm, "Gabriel Genellina"  wrote:
En Fri, 09 Apr 2010 18:04:59 -0300, Jeremy   
escribió:


> A related question: Can I parse the data once and keep it somewhere
> instead of reading the supporting file every time?  I tried pickling
> but that wouldn't work because I have custom classes.  (Either that or
> I just don't know how to pickle—this is a highly probable event.)

What kind of "custom classes"?


My custom classes are not very fancy.  They basically are dictionaries
and lists organizing the data in the supporting file.  I was actually
surprised they didn't pickle because the classes were so simple.


# pickle some_object
with open(filename, "wb") as f:
   pickle.dump(some_object, f, -1)


When I did this I got the following error:

PicklingError: Can't pickle : it's not found
as __main__.element

Am I just being dumb?


No, but maybe you're redefining 'element':

py> from pickle import dumps
py> class Foo(object):
...   pass
...
py> x = Foo()
py> class Foo(object):
...   pass
...
py> dumps(x)
Traceback (most recent call last):
...
pickle.PicklingError: Can't pickle : it's not the  
same obj

ect as __main__.Foo

Using reload() may lead to this error too. Basically, the class says: "I  
am 'DonQuijote', from module 'LaMancha'". But nobody at LaMancha knows  
DonQuijote, or they say DonQuijote is a different person.


--
Gabriel Genellina

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


Re: gps coordinate identification

2010-04-12 Thread Luis Quesada

Luis Quesada wrote:

Dear all,
Given a gps coordinate, I would like to find out the country the 
coordinate belongs to. I wonder whether there is a python library that 
offers this capability...

(In case somebody here is looking for the same thing)
Somebody in sci.geo.satellite-nav suggested using geopy:
http://code.google.com/p/geopy/wiki/ReverseGeocoding
Indeed, it is exactly what I was looking for.
Cheers,
Luis
--
http://mail.python.org/mailman/listinfo/python-list


Re: How to read file during module import?

2010-04-12 Thread Gabriel Genellina

En Sun, 11 Apr 2010 19:43:03 -0300, HigStar  escribió:


I have had trouble with the __file__ attribute in the past, when using
py2exe (i.e. on the windows platform) and using the bundle feature
(which zips all files).
Using os.path.realpath( __file__ ) resolves to something like .../
library.zip/packageName/fileName
Then when trying to perform an open on a file, say .../library.zip/
packageName/supportingPackageName, the file can not be found.


Use pkgutil.get_data then:
http://docs.python.org/library/pkgutil.html#pkgutil.get_data

--
Gabriel Genellina

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


Re: Sometimes the python shell cannot recognize the presence of an attribute.

2010-04-12 Thread Simon Brunning
2010/4/12 Ricardo Aráoz :
> Because .

... Guido says so: http://www.python.org/dev/peps/pep-0008/

-- 
Cheers,
Simon B.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Sometimes the python shell cannot recognize the presence of an attribute.

2010-04-12 Thread Ricardo Aráoz
Aahz wrote:
> In article ,
> Justin Park   wrote:
>   
>> The real problem is this.  When I started working on the package,
>> somehow all of indentations were made by space-bars instead of using
>> tabs.  But when I am implementing my own on top of it, I still use tabs
>> to make indentations.
>> 
>
> Stop using TAB.  Allowing TAB was a mistake.  Spaces are the One True
> Way when formatting Python code.
>   
Because .



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


Re: python and enigma2

2010-04-12 Thread luca72
On 12 Apr, 19:10, luca72  wrote:
> Hello i have a dvb decoder with enigma2 inside, The enigma2 plugin can
> be made with python.
> In my plugin i have to use pyserial, but in the decoder the python2.5
> reply in this way:
> r...@bm750:/var/pyserial-2.5-rc2# python setup.py install
> Traceback (most recent call last):
>   File "setup.py", line 8, in 
>     from distutils.core import setup
> ImportError: No module named distutils.core
>
> How i can install distutils?
>
> Thanks
>
> Luca

Sorry i try to install setuptolls i get this :
r...@bm750:/var# sh setuptools-0.6c11-py2.5.egg
exec: 8: python2.5: not found

I see anly the python executable andno other folder can you hel me

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


python and enigma2

2010-04-12 Thread luca72
Hello i have a dvb decoder with enigma2 inside, The enigma2 plugin can
be made with python.
In my plugin i have to use pyserial, but in the decoder the python2.5
reply in this way:
r...@bm750:/var/pyserial-2.5-rc2# python setup.py install
Traceback (most recent call last):
  File "setup.py", line 8, in 
from distutils.core import setup
ImportError: No module named distutils.core

How i can install distutils?

Thanks

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


Pickle

2010-04-12 Thread gerardob

I have a problem using Pickle inside a class object.

The following code works:

m2 = markov_model.MarkovModel()
m2 =  pickle.load(open("prueba", 'rb'))
print m2.n

However, if I create the following method inside markov_model.MarkovModel:

def load_model_from_file(self, name):
try:
file = open(name, 'rb')
self = pickle.load(file)
file.close()
except pickle.PicklingError:
print "PicklingError"

and then run:

m2 = markov_model.MarkovModel()
m2.load_model_from_file("prueba")
print m2.n

it says that 'MarkovModel' object has no attribute 'n'. If the printing of
'n' i put it inside (at the end) of the method load_model_from_file as
'print self.n' it works.

How can i solve this?
Thanks

-- 
View this message in context: 
http://old.nabble.com/Pickle-tp28219159p28219159.html
Sent from the Python - python-list mailing list archive at Nabble.com.

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


Re: 2.7 beta 1

2010-04-12 Thread Terry Reedy

On 4/12/2010 1:57 AM, Mensanator wrote:

Likewise, I usually don't shut down
when I leave work, so I can't allow orphaned processes to accumulate
eating up CPU and memory.


So don't.

Orphaned processes only accumulate when you use Restart Shell to abandon 
a process stuck in an infinite loop. I personally very seldom do that. 
Otherwise, the old process dies in a few seconds and the number of 
pythonw processes drops back down from 3 to the normal 2.



As I already said, either roboot or use TaskManager to kill such 
zombies. When I had a unix desktop machine, I routinely used the command 
line equivalents ps (process status) and kill to do the same thing.


Terry Jan Reedy

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


Re: Sometimes the python shell cannot recognize the presence of an attribute.

2010-04-12 Thread Aahz
In article ,
Justin Park   wrote:
>
>The real problem is this.  When I started working on the package,
>somehow all of indentations were made by space-bars instead of using
>tabs.  But when I am implementing my own on top of it, I still use tabs
>to make indentations.

Stop using TAB.  Allowing TAB was a mistake.  Spaces are the One True
Way when formatting Python code.
-- 
Aahz (a...@pythoncraft.com)   <*> http://www.pythoncraft.com/

"It is easier to optimize correct code than to correct optimized code."
--Bill Harlan
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Replacing Periods with Backspaces

2010-04-12 Thread Booter
All,

Thanks for all the help I finally got it.  I ended up not having to
get rid of the periods.

Thanks again!

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


ANN: Pyrex 0.9.9

2010-04-12 Thread Gregory Ewing

Pyrex 0.9.9 is now available:

  http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/

Highlights of this release:

* Some facilities for interfacing with C++ code have been
  added.

* Changes have been made to the semantics of exception
  catching to improve efficiency.

* Preparation is being made for making 'not None' the
  default for extension type parameters to Python functions.

A more detailed discussion of these changes can be found
in the release notes here:


http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/version/Doc/Release_Notes_0.9.9.html


What is Pyrex?
--

Pyrex is a language for writing Python extension modules.
It lets you freely mix operations on Python and C data, with
all Python reference counting and error checking handled
automatically.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Tempering Client Expectations (OT)

2010-04-12 Thread Mark Lawrence

[Big snip]

Heh, my wife and I joke that in those "can this marriage be saved" 
newspaper columns, every answer boils down to "communication is key".  
Keep the customer tightly in the loop with regular communication -- 
frequent feedback regarding progress, costs, and whether your shared 
understanding coincides helps prevent developers from wandering off for 
6months only to come back with 6mo of costs for a project that doesn't 
meet the client's expectations.  The customer may cut you off if 
progress is too slow or costly, but the earlier that happens, the less 
pain for both parties.


-tkc



You've obviously never worked on a UK MOD contract.  By definition,
everything has to be delivered at least five years late and millions if not
billions overspent.  Still, it's only taxpayers money.

Going OT a fair way, for those who don't know, I quote from an MOD QA 
guy that I spoke to.


Her Majesty's Government never buys anything that has faults in it


Hence when a Chinook flew into a mountainside killing umpteen highly 
skilled people, it was put down to being pilot error, despite the fact 
that it was completely against regulations to blame the pilot when there 
was no evidence to back it up, plus the minor little detail that the 
engine control system FADEC was already suspect.


The UK magazine Computer Weekly fought a long and hard battle to protect 
the pilots name.  They might as well have hit their heads against a 
brick wall.  Democracy, please don't make me laugh.


Oh, and see this http://www.computerweekly.com/Articles/2010/01/14/239954/
faulty-safety-critical-software-changed-after-fatal-mull.htm

Kindest regards.

Mark Lawrence.

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


Re: Python Pickle

2010-04-12 Thread Bruno Desthuilliers

gerardob a écrit :

I have a problem using Pickle inside a class object.

The following code works:

m2 = markov_model.MarkovModel()
m2 =  pickle.load(open("prueba", 'rb'))


Given the second line, the first is totally useless.


print m2.n

However, if I create the following method inside markov_model.MarkovModel: 


def load_model_from_file(self, name):
try:
file = open(name, 'rb') 
self = pickle.load(file)


This doesn't work - or, more exactly, this doesn't work the way you 
expect it to work !-)


Remember that there's nothing magical with 'self' - it's just a local 
name in a function. Rebinding it within the function's body only affects 
the function's local namespace.


What you want is to make load_model_from_file a classmethod and make it 
return the unpickled object instead.




file.close()
	except pickle.PicklingError: 
		print "PicklingError"


Useless exception handling - you lose all the relevant informations.


and then run:

m2 = markov_model.MarkovModel()
m2.load_model_from_file("prueba")
print m2.n

it says that 'MarkovModel' object has no attribute 'n'. If the printing of
'n' i put it inside (at the end) of the method load_model_from_file as
'print self.n' it works.


Indeed - at this stage, the *local* 'self' name has been rebound to the 
unpickled object.


Also and fwiw, if you expect a MarkovModel instance to have a 'n' 
attribute, you should bind it (at least to a sensible default value) in 
the class __init__ method.



How can i solve this?


cf above.

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


Python Pickle

2010-04-12 Thread gerardob

I have a problem using Pickle inside a class object.

The following code works:

m2 = markov_model.MarkovModel()
m2 =  pickle.load(open("prueba", 'rb'))
print m2.n

However, if I create the following method inside markov_model.MarkovModel: 

def load_model_from_file(self, name):
try:
file = open(name, 'rb') 
self = pickle.load(file)
file.close()
except pickle.PicklingError: 
print "PicklingError"

and then run:

m2 = markov_model.MarkovModel()
m2.load_model_from_file("prueba")
print m2.n

it says that 'MarkovModel' object has no attribute 'n'. If the printing of
'n' i put it inside (at the end) of the method load_model_from_file as
'print self.n' it works.

How can i solve this?
Thanks.





-- 
View this message in context: 
http://old.nabble.com/Python-Pickle-tp28219135p28219135.html
Sent from the Python - python-list mailing list archive at Nabble.com.

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


Re: Tempering Client Expectations (OT)

2010-04-12 Thread Victor Subervi
On Mon, Apr 12, 2010 at 10:29 AM, Tim Chase
wrote:

> your own inaccurate assumptions and answer those, please.
>>
>
>
> Heh, my wife and I joke that in those "can this marriage be saved"
> newspaper columns, every answer boils down to "communication is key".  Keep
> the customer tightly in the loop with regular communication -- frequent
> feedback regarding progress, costs, and whether your shared understanding
> coincides helps prevent developers from wandering off for 6months only to
> come back with 6mo of costs for a project that doesn't meet the client's
> expectations.  The customer may cut you off if progress is too slow or
> costly, but the earlier that happens, the less pain for both parties.
>

Yeah, that's pretty much where I'm seeing it, too. Parameterize customer
expectations as much as practicable up front so it's less painful down the
road.
Thanks,
beno

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


Re: rich comparison fscks up reference count?

2010-04-12 Thread Gerhard Häring
Can be run like this:

ghaer...@ws124~/src/gh/test$ python3 setup.py build_ext --inplace
running build_ext
building 'foo' extension
gcc -fno-strict-aliasing -g -fwrapv -O0 -Wall -Wstrict-prototypes -
arch i386 -m32 -I/opt/jetstream/include/python3.1 -c foo.c -o build/
temp.macosx-10.4-i386-3.1-pydebug/foo.o
foo.c: In function ‘PyInit_foo’:
foo.c:109: warning: return makes pointer from integer without a cast
gcc -bundle -undefined dynamic_lookup -arch i386 -m32 build/
temp.macosx-10.4-i386-3.1-pydebug/foo.o -o /Users/ghaering/src/gh/test/
foo.so
[50367 refs]
ghaer...@ws124~/src/gh/test$ python3 setup.py test
running test
total refcount  65304
total refcount  65305
total refcount  65304
total refcount  65303
total refcount  65302
total refcount  65301
total refcount  65300
total refcount  65299
total refcount  65298
total refcount  65297
[45322 refs]
ghaer...@ws124~/src/gh/test$
-- 
http://mail.python.org/mailman/listinfo/python-list


rich comparison fscks up reference count?

2010-04-12 Thread Gerhard Häring
Maybe somebody can enlighten me here. I can't figure out why doing a
rich comparison on my object decreases the total reference count by 1.
Linked is the minimal test case with a C exension that compiles  under
both Python 2.6 and 3.1. No external dependencies, except a DEBUG
build of Python to see the effect (Py_REF_DEBUG defined).

http://cdn.ghaering.de/foo.c
http://cdn.ghaering.de/setup.py

Builtin types like list, dict, etc. don't seem to have the same
effect.

I've also run the test a few thousand times; then the total refcount
is like -5, but Python does not crash. Also if I print all objects
and their respective refcounts using the gc module, none of them seems
to have a negative refcount, but the total refcount is still way
negative. How could that be?

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


Re: Tempering Client Expectations (OT)

2010-04-12 Thread Tim Chase

On 04/12/2010 06:37 AM, Victor Subervi wrote:

On Sat, Apr 10, 2010 at 3:14 PM, Tim Chase wrote:

1) Preeminently, address second-order ignorance.

[elided kvetch]

"second-order ignorance" is a technical term (not intended so 
much as a slur) for "not knowing what you don't know".  If you 
google the phrase, you'll get several articles/papers on the 
topic (I think I first learned about the hierarchy in an issue of 
Dr. Dobbs or CACM/Queue magazine).  The brief summary is:


0th order ignorance (0OI):  I provably know the material

1st order ignorance (1OI):  I know that I don't know something 
(for me, e.g. sports...I know my sports-knowledge is nigh 
non-existent).  For you, it might be the inner workings of HTTP 
or SQL transactions.  You now know that you don't know it, but 
you could go read up and learn the topics and their best-practices.


2nd order ignorance (2OI):  I don't know what I don't know...if 
you don't know what you need to learn in order to develop a web 
application (so my email's "learn HTTP, HTML, ..." comment moves 
you from 2OI to 1OI because now you have a list of things to learn).


3rd order ignorance (3OI):  I don't know how to find out what I 
don't know (in your case, you've asked the mailing list, just as 
you could ask any respectable web-developer, so you know how to 
find out what you don't know and thus aren't 3OI)


4th order ignorance (4OI):  commonly described as "not knowing 
about the various orders of ignorance" :)



Pay attention to my question, don't make up your own based on
your own inaccurate assumptions and answer those, please.


The topic was setting accurate estimates and tempering client 
expectations (TCE).  If you don't have a foundation regarding 
what you do/don't know, you can't set accurate estimates, so TCE 
consists of "I need to learn what technologies are involved in 
doing this, and then learn those technologies".  Once you've 
moved from 2nd to 1st order ignorance, your TCE shifts to "I know 
that technologies X, Y, and Z are involved, but I only know X and 
will have to learn Y & Z before I can produce a satisfactory 
result".  If I were a client, I'd want to know the level/depth of 
my vendor/supplier's expertise.  So perfectly relevant to the thread.



4) Don't be afraid to reuse existing technologies:  could installing
osCommerce on a $3/month web-server and tweaking the PHP code have sufficed
for what you need?  Could you have used Django+Satchmo to get yourself up
and running with proven code, tweaking what you need?  I remember you
dismissing the suggestion to use existing web-frameworks.


Bringing that up again, are you? I was all but done with the shopping cart
when you suggested I re-invent the wheel based on another technology. Yeah,
sure, throw out 10,000 lines of the 12,000 line program so I can rebuild on
a new technology. Brilliant, that. Thanks for the suggestion. Now, can we
get back to my question?



If you're throwing out 10k lines of code that has only seen one 
core developer and hasn't been tested in the real world against 
real hackers satisfying real customers; and you're replacing it 
with a proven-in-the-real-world framework that has been worked on 
by multiple professional developers, then yes, that's exactly 
what I'm suggesting.  It hurts to throw away that much work, and 
I've had to do just that (in my case, printing from PocketPC 
devices, having written my own printer-drivers for mobile 
printers).  There's an personal attachment to code you've spent 
hours upon hours writing.  But unless that effort nets you big 
wins over merely tweaking a proven solution, your hurting your 
customer(s).



6) As for "Tempering Client Expectations" (the subject line
of this OT post),


Ah, so you *did* recognize what *my* question was! Good!


If you're just realizing that by the time you get to item #6, I'm 
glad to see you read my entire email before getting testy. 



True. I ended up taking a bath on it, and I believe that was
merited since it was my first client project. Now, I'm dealing
with scope-creep and trying to work my way out of it, and
looking ahead at how to avoid complications like this in the
future.


Heh, my wife and I joke that in those "can this marriage be 
saved" newspaper columns, every answer boils down to 
"communication is key".  Keep the customer tightly in the loop 
with regular communication -- frequent feedback regarding 
progress, costs, and whether your shared understanding coincides 
helps prevent developers from wandering off for 6months only to 
come back with 6mo of costs for a project that doesn't meet the 
client's expectations.  The customer may cut you off if progress 
is too slow or costly, but the earlier that happens, the less 
pain for both parties.


-tkc






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


"BOLLYWOOD GIRLS" "HOLLYWOOD GIRLS" "LOLLYWOOD GIRLS" "INDIAN GIRLS" "PAKISTANI GIRLS" "KARACHI GIRLS" "LAHORE GIRLS" "ISLAMABAD GIRLS" "MUSLIM GIRLS" "TURKISH GIRLS" "BLACK GIRLS" "PRETTY GIRLS" ON

2010-04-12 Thread Naeem
"BOLLYWOOD GIRLS" "HOLLYWOOD GIRLS" "LOLLYWOOD GIRLS" "INDIAN GIRLS"
"PAKISTANI GIRLS" "KARACHI GIRLS" "LAHORE GIRLS" "ISLAMABAD GIRLS"
"MUSLIM GIRLS" "TURKISH GIRLS" "BLACK GIRLS" "PRETTY GIRLS" ON
www.epakistanigirls.blogspot.com   "BOLLYWOOD GIRLS"
"HOLLYWOOD GIRLS" "LOLLYWOOD GIRLS" "INDIAN GIRLS" "PAKISTANI GIRLS"
"KARACHI GIRLS" "LAHORE GIRLS" "ISLAMABAD GIRLS" "MUSLIM GIRLS"
"TURKISH GIRLS" "BLACK GIRLS" "PRETTY GIRLS" ON  
www.epakistanigirls.blogspot.com
"BOLLYWOOD GIRLS" "HOLLYWOOD GIRLS" "LOLLYWOOD GIRLS" "INDIAN GIRLS"
"PAKISTANI GIRLS" "KARACHI GIRLS" "LAHORE GIRLS" "ISLAMABAD GIRLS"
"MUSLIM GIRLS" "TURKISH GIRLS" "BLACK GIRLS" "PRETTY GIRLS" ON
www.epakistanigirls.blogspot.com   "BOLLYWOOD GIRLS"
"HOLLYWOOD GIRLS" "LOLLYWOOD GIRLS" "INDIAN GIRLS" "PAKISTANI GIRLS"
"KARACHI GIRLS" "LAHORE GIRLS" "ISLAMABAD GIRLS" "MUSLIM GIRLS"
"TURKISH GIRLS" "BLACK GIRLS" "PRETTY GIRLS" ON  
www.epakistanigirls.blogspot.com
"BOLLYWOOD GIRLS" "HOLLYWOOD GIRLS" "LOLLYWOOD GIRLS" "INDIAN GIRLS"
"PAKISTANI GIRLS" "KARACHI GIRLS" "LAHORE GIRLS" "ISLAMABAD GIRLS"
"MUSLIM GIRLS" "TURKISH GIRLS" "BLACK GIRLS" "PRETTY GIRLS" ON
www.epakistanigirls.blogspot.com   "BOLLYWOOD GIRLS"
"HOLLYWOOD GIRLS" "LOLLYWOOD GIRLS" "INDIAN GIRLS" "PAKISTANI GIRLS"
"KARACHI GIRLS" "LAHORE GIRLS" "ISLAMABAD GIRLS" "MUSLIM GIRLS"
"TURKISH GIRLS" "BLACK GIRLS" "PRETTY GIRLS" ON  
www.epakistanigirls.blogspot.com
"BOLLYWOOD GIRLS" "HOLLYWOOD GIRLS" "LOLLYWOOD GIRLS" "INDIAN GIRLS"
"PAKISTANI GIRLS" "KARACHI GIRLS" "LAHORE GIRLS" "ISLAMABAD GIRLS"
"MUSLIM GIRLS" "TURKISH GIRLS" "BLACK GIRLS" "PRETTY GIRLS" ON
www.epakistanigirls.blogspot.com   "BOLLYWOOD GIRLS"
"HOLLYWOOD GIRLS" "LOLLYWOOD GIRLS" "INDIAN GIRLS" "PAKISTANI GIRLS"
"KARACHI GIRLS" "LAHORE GIRLS" "ISLAMABAD GIRLS" "MUSLIM GIRLS"
"TURKISH GIRLS" "BLACK GIRLS" "PRETTY GIRLS" ON  
www.epakistanigirls.blogspot.com
"BOLLYWOOD GIRLS" "HOLLYWOOD GIRLS" "LOLLYWOOD GIRLS" "INDIAN GIRLS"
"PAKISTANI GIRLS" "KARACHI GIRLS" "LAHORE GIRLS" "ISLAMABAD GIRLS"
"MUSLIM GIRLS" "TURKISH GIRLS" "BLACK GIRLS" "PRETTY GIRLS" ON
www.epakistanigirls.blogspot.com   "BOLLYWOOD GIRLS"
"HOLLYWOOD GIRLS" "LOLLYWOOD GIRLS" "INDIAN GIRLS" "PAKISTANI GIRLS"
"KARACHI GIRLS" "LAHORE GIRLS" "ISLAMABAD GIRLS" "MUSLIM GIRLS"
"TURKISH GIRLS" "BLACK GIRLS" "PRETTY GIRLS" ON  
www.epakistanigirls.blogspot.com
"BOLLYWOOD GIRLS" "HOLLYWOOD GIRLS" "LOLLYWOOD GIRLS" "INDIAN GIRLS"
"PAKISTANI GIRLS" "KARACHI GIRLS" "LAHORE GIRLS" "ISLAMABAD GIRLS"
"MUSLIM GIRLS" "TURKISH GIRLS" "BLACK GIRLS" "PRETTY GIRLS" ON
www.epakistanigirls.blogspot.com   "BOLLYWOOD GIRLS"
"HOLLYWOOD GIRLS" "LOLLYWOOD GIRLS" "INDIAN GIRLS" "PAKISTANI GIRLS"
"KARACHI GIRLS" "LAHORE GIRLS" "ISLAMABAD GIRLS" "MUSLIM GIRLS"
"TURKISH GIRLS" "BLACK GIRLS" "PRETTY GIRLS" ON  
www.epakistanigirls.blogspot.com
"BOLLYWOOD GIRLS" "HOLLYWOOD GIRLS" "LOLLYWOOD GIRLS" "INDIAN GIRLS"
"PAKISTANI GIRLS" "KARACHI GIRLS" "LAHORE GIRLS" "ISLAMABAD GIRLS"
"MUSLIM GIRLS" "TURKISH GIRLS" "BLACK GIRLS" "PRETTY GIRLS" ON
www.epakistanigirls.blogspot.com   "BOLLYWOOD GIRLS"
"HOLLYWOOD GIRLS" "LOLLYWOOD GIRLS" "INDIAN GIRLS" "PAKISTANI GIRLS"
"KARACHI GIRLS" "LAHORE GIRLS" "ISLAMABAD GIRLS" "MUSLIM GIRLS"
"TURKISH GIRLS" "BLACK GIRLS" "PRETTY GIRLS" ON  
www.epakistanigirls.blogspot.com
"BOLLYWOOD GIRLS" "HOLLYWOOD GIRLS" "LOLLYWOOD GIRLS" "INDIAN GIRLS"
"PAKISTANI GIRLS" "KARACHI GIRLS" "LAHORE GIRLS" "ISLAMABAD GIRLS"
"MUSLIM GIRLS" "TURKISH GIRLS" "BLACK GIRLS" "PRETTY GIRLS" ON
www.epakistanigirls.blogspot.com   "BOLLYWOOD GIRLS"
"HOLLYWOOD GIRLS" "LOLLYWOOD GIRLS" "INDIAN GIRLS" "PAKISTANI GIRLS"
"KARACHI GIRLS" "LAHORE GIRLS" "ISLAMABAD GIRLS" "MUSLIM GIRLS"
"TURKISH GIRLS" "BLACK GIRLS" "PRETTY GIRLS" ON  
www.epakistanigirls.blogspot.com
"BOLLYWOOD GIRLS" "HOLLYWOOD GIRLS" "LOLLYWOOD GIRLS" "INDIAN GIRLS"
"PAKISTANI GIRLS" "KARACHI GIRLS" "LAHORE GIRLS" "ISLAMABAD GIRLS"
"MUSLIM GIRLS" "TURKISH GIRLS" "BLACK GIRLS" "PRETTY GIRLS" ON
www.epakistanigirls.blogspot.com   "BOLLYWOOD GIRLS"
"HOLLYWOOD GIRLS" "LOLLYWOOD GIRLS" "INDIAN GIRLS" "PAKISTANI GIRLS"
"KARACHI GIRLS" "LAHORE GIRLS" "ISLAMABAD GIRLS" "MUSLIM GIRLS"
"TURKISH GIRLS" "BLACK GIRLS" "PRETTY GIRLS" ON  
www.epakistanigirls.blogspot.com
"BOLLYWOOD GIRLS" "HOLLYWOOD GIRLS" "LOLLYWOOD GIRLS" "INDIAN GIRLS"
"PAKISTANI GIRLS" "KARACHI GIRLS" "LAHORE GIRLS" "ISLAMABAD GIRLS"
"MUSLIM GIRLS" "TURKISH GIRLS" "BLACK GIRLS" "PRETTY GIRLS" ON
www.epakistanigirls.blogspot.com   "BOLLYWOOD GIRLS"
"HOLLYWOOD GIRLS" "LOLLYWOOD GIRLS" "INDIAN GIRLS" "PAKISTANI GIRLS"
"KARACHI GIRLS" "LAHORE GIRLS" "ISLAMABAD GIRLS" "MUSLIM GIRLS"
"TURKISH GIRLS" "BLACK GIRLS" "PRETTY GIRLS" ON  
www.epakistanigirls.blogspot.com
"BOLLYWOOD GIRLS" "HOLLYWOOD GIRLS" "LOLLYWOOD GIRLS" "INDIAN GIRLS"
"PAKISTANI GIRLS" "KARACHI GIRLS" "LAHORE GIRLS" "ISLAMABAD GIRLS"
"MUSLIM GIRLS" "TURKISH GIRLS" "BLACK GIRLS" "PRETTY GIRLS" ON

Re: 2.7 beta 1

2010-04-12 Thread Mark Lawrence

Mensanator wrote:

On Apr 10, 11:51�pm, alex23  wrote:

Mensanator  wrote:

3.x won't be adopted by WINDOWS developers WHO USE IDLE until it's fixed.

I think you left your hyperbole level too high so I turned it down for
you. I don't know of _anyone_ who uses IDLE to run production code,
nor do I follow how one errant IDE shows that Python 3.x as a language
is broken.


Planning to buy a Toyota?


No, on the grounds that I have an Enterprise Probike, which being chain 
driven is vastly superior to any gas guzzling petrol or diesel driven 
vehicle.  Ok, it's slower, but it gets me there in the end.


Mark Lawrence

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


Re: tools for network adminstrator

2010-04-12 Thread Kushal Kumaran
On Mon, Apr 12, 2010 at 5:56 PM, prakash jp  wrote:
> Hi all,
>
> Can any one mention a list of python based tools (existant / could be
> developed) which network administrators might need.
>

Not sure if you might like, but there's an O'Reilly book titled
"Python for Unix and Linux System Administration".

-- 
regards,
kushal
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Refresh Problem

2010-04-12 Thread Victor Subervi
On Mon, Apr 12, 2010 at 9:03 AM, Victor Subervi wrote:

> On Sun, Apr 11, 2010 at 4:29 PM, Tim Chase 
> wrote:
>
>> On 04/11/2010 02:53 PM, MRAB wrote:
>>
>>> Victor Subervi wrote:
>>>
 Hi;
 I send variables to a script. The script adds appropriate lines into a
 database of an order to my shopping cart. When I refresh the screen, as
 no doubt some customers will do, it re-ads those orders. Now, I can
 delete them, but that's not the point. I don't want it to re-ad the
 orders. How do I skirt this problem?

  When you click on the Submit button on the form it should post the
>>> data,
>>> ie use method="post", not method="get". If refreshing causes it to
>>> re-submit, then you're using the wrong method. This is basic stuff.
>>>
>>
>> And if you do POST your data (which you should if you're attempting to
>> change state on the server), you should use a post/redirect/get pattern[1].
>>  This will prevent the browser from giving the "you've already submitted
>> this data; do you want to resubmit it?" message that most should give you if
>> you refresh a POST'ed page.
>>
>> And therein demonstrates the need to know HTTP as mentioned in my previous
>> reply to you (VS, not MRAB).
>>
>
> Man, I just forget this stuff. Dunno why. Yeah, just set a var in the URL
> of the post. Right. Sorry. Thanks.
> beno
>
> Correction. I was not familiar with Post/Redirect/Get. Thanks, Tim
beno
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Python-Dev] [RELEASED] 2.7 beta 1

2010-04-12 Thread anatoly techtonik
On Sun, Apr 11, 2010 at 1:13 AM, average  wrote:
>
> There are so many features taken from 3.0 that I fear that it will
> postpone its adoption interminably (it is, in practice, treated as
> "beta" software itself).  By making it doctrine that it won't be
> official until the next "major" Python release, it will encourage
> those who are able, to just make the jump to 3.0, while those who
> cannot will have the subtle pressure to make the shift, however
> gradual.

> Additionally, it will give the community further incentive
> to make Python3 all that it was intended to be.  Personally, the
> timing of v3 prevented me from fully participating in that effort,
> and, not ignoring the work of those who did contribute, I think many
> of us feel that it has not reached its potential.

The same problem. For me it was possible to participate in standard
library development only after Python Alphas with Windows binaries
were released. I could test both new features and old bugs. Having a
requirement that every developer should be able to compile binaries
has an adverse effect on the quality of standard library.

The absence of public Roadmap also makes it hard to judge the
aforementioned "desired potential".
It could be possible to compile a public list like
http://dungeonhack.sourceforge.net/Roadmap

I am afraid of two things with forthcoming Python releases.
1. feature creeping
2. feature missing
And an overview of Python development in the form of release timer and
roadmap will remove the remnants of fear and uncertainty and surely
attract new people for sprints.

Regardless of said above it is great to feel the hard work behind the
scenes that makes new releases popping up. Thanks.
-- 
anatoly t.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Refresh Problem

2010-04-12 Thread Victor Subervi
On Sun, Apr 11, 2010 at 4:29 PM, Tim Chase wrote:

> On 04/11/2010 02:53 PM, MRAB wrote:
>
>> Victor Subervi wrote:
>>
>>> Hi;
>>> I send variables to a script. The script adds appropriate lines into a
>>> database of an order to my shopping cart. When I refresh the screen, as
>>> no doubt some customers will do, it re-ads those orders. Now, I can
>>> delete them, but that's not the point. I don't want it to re-ad the
>>> orders. How do I skirt this problem?
>>>
>>>  When you click on the Submit button on the form it should post the data,
>> ie use method="post", not method="get". If refreshing causes it to
>> re-submit, then you're using the wrong method. This is basic stuff.
>>
>
> And if you do POST your data (which you should if you're attempting to
> change state on the server), you should use a post/redirect/get pattern[1].
>  This will prevent the browser from giving the "you've already submitted
> this data; do you want to resubmit it?" message that most should give you if
> you refresh a POST'ed page.
>
> And therein demonstrates the need to know HTTP as mentioned in my previous
> reply to you (VS, not MRAB).
>

Man, I just forget this stuff. Dunno why. Yeah, just set a var in the URL of
the post. Right. Sorry. Thanks.
beno
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Write web apps in Python?

2010-04-12 Thread Stefan Behnel

Gilles Ganault, 12.04.2010 11:57:

I'd like to make sure I understand what the options are to write web
applications in Python:

- à la PHP, using Apache's mod_python

- using eg. Lighttpd and configuring it to load the Python interpreter
every time a Python script is called (www.jakehilton.com/?q=node/54)

- long-running process, by compiling the Python script as a
stand-alone program that will then wait for queries on a port and
being called by the web server through eg. the WSGI


Those are "deployment" options, not "write" (== design/implementation) 
options. If you stick to a WSGI compatible framework, you are free to 
deploy your application any way you like or need, depending on the specific 
context or environment.




As for writing apps, I can either built it from scratch, or use
frameworks like Pylons, TurboGears, or Django.


Amongst tons of other options, as already pointed out.

Stefan

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


Re: Write web apps in Python?

2010-04-12 Thread Luis M . González
On 12 abr, 06:57, Gilles Ganault  wrote:
> Hello
>
> I'd like to make sure I understand what the options are to write web
> applications in Python:
>
> - à la PHP, using Apache's mod_python
>
> - using eg. Lighttpd and configuring it to load the Python interpreter
> every time a Python script is called (www.jakehilton.com/?q=node/54)
>
> - long-running process, by compiling the Python script as a
> stand-alone program that will then wait for queries on a port and
> being called by the web server through eg. the WSGI
>
> As for writing apps, I can either built it from scratch, or use
> frameworks like Pylons, TurboGears, or Django.
>
> Is this correct?
>
> Thank you.

You should first investigate the different python web frameworks,
choose one and then use the deployment options supported by your
choice. These frameworks support several ways to deploy your apps,
such as those you mentioned.

If you want an easy way to get started for free, check the Google App
Engine.
It's the google infraestructure to host web apps (written in python or
Java), and it's free as long as you don't surpass the limited quotas
on bandwith and data used (which are quite generous). You don't need
to set up anything. All you need is a google account to get started.

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


tools for network adminstrator

2010-04-12 Thread prakash jp
Hi all,

Can any one mention a list of *python based tools* (existant / could be
developed) which network administrators might need.

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


Re: Python and Regular Expressions

2010-04-12 Thread Neil Cerutti
On 2010-04-11, Steven D'Aprano
 wrote:
> On Sat, 10 Apr 2010 10:11:07 -0700, Patrick Maupin wrote:
>> On Apr 10, 11:35??am, Neil Cerutti  wrote:
>>> On 2010-04-10, Patrick Maupin  wrote:
>>> > as Pyparsing". ??Which is all well and good, except then the OP will
>>> > download pyparsing, take a look, realize that it uses regexps under
>>> > the hood, and possibly be very confused.
>>>
>>> I don't agree with that. If a person is trying to ski using pieces of
>>> wood that they carved themselves, I don't expect them to be surprised
>>> that the skis they buy are made out of similar materials.
>> 
>> But, in this case, the guy ASKED how to make the skis in his woodworking
>> shop, and was told not to be silly -- you don't use wood to make skis --
>> and then directed to go buy some skis that are, in fact, made out of
>> wood.
>
> As entertaining as this is, the analogy is rubbish.

You should have seen the car engine analogy I thought up at
first. ;)

> Skis are far too simple to use as an analogy for a parser (he
> says, having never seen skis up close in his life *wink*).
> Have you looked at PyParsing's source code? Regexes are only a
> small part of the parser, and not analogous to the wood of
> skis.

I was mainly trying to get accross my incredulity that somebody
should be surprised a parsing package uses regexes under the
good. But for the record, a set of downhill skis comes with a
really fancy interface layer:

URL:http://images03.olx.com/ui/1/85/66/13147966_1.jpg

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


Re: Tempering Client Expectations (OT)

2010-04-12 Thread Victor Subervi
On Sat, Apr 10, 2010 at 3:14 PM, Tim Chase wrote:

> 1) Preeminently, address second-order ignorance.


Tim, throughout this post, you're way out of line. The s/w I have already
built for this client works just fine. It's not a matter or not having the
tools or not knowing how to use them. Pay attention to my question, don't
make up your own based on your own inaccurate assumptions and answer those,
please. Stick to the topic.

4) Don't be afraid to reuse existing technologies:  could installing
osCommerce on a $3/month web-server and tweaking the PHP code have sufficed
for what you need?  Could you have used Django+Satchmo to get yourself up
and running with proven code, tweaking what you need?  I remember you
dismissing the suggestion to use existing web-frameworks.


Bringing that up again, are you? I was all but done with the shopping cart
when you suggested I re-invent the wheel based on another technology. Yeah,
sure, throw out 10,000 lines of the 12,000 line program so I can rebuild on
a new technology. Brilliant, that. Thanks for the suggestion. Now, can we
get back to my question?


>
> 5) Regarding scope-creep,


Yeah, that's where we should have been all along, Tim.



> it's a problem most developers & analysts face, but there are several
> mitigating methods you can use.  Experience from past projects helps gauge
> time for future projects and only your own experience will suffice.  If you
> don't have any past projects (personal deployments or school projects)
> you're not yet remotely ready to give estimates.  Even after you've done
> multiple projects, estimation is still as much an art as a science.
>

Obviously.

>
> Also, get the client to sign off on basic features in very small bite-sized
> increments, addressing highest-priority needs first. If at any time the
> client sees a failure to progress at the rate they expect, they can pull the
> plug losing far less of their investment keeping the most important features
> developed thus-far.  Part of a developer/analyst's job is to get a good idea
> of a project's scope.  Examining all edge cases, looking for
> infrequently-used processes, probing exceptions, building a mental-model
> that corresponds to the client's mental-model...
>

Now you're talking.

>
> 6) As for "Tempering Client Expectations" (the subject line of this OT
> post),


Ah, so you *did* recognize what *my* question was! Good!


> it seems the biggest gap involved not communicating to your client/friend
> "I'm using your project as a learning experience for multiple complicated
> technologies and I have minimal idea what is involved so there's no possible
> way I could give you an accurate estimate of scope or cost"
>

True. I ended up taking a bath on it, and I believe that was merited since
it was my first client project. Now, I'm dealing with scope-creep and trying
to work my way out of it, and looking ahead at how to avoid complications
like this in the future.
Thanks,
beno

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


Re: Question about LLVM

2010-04-12 Thread Stefan Behnel

Hannes, 12.04.2010 12:56:

I heard that its possible to use LLVM to speed up Python.

Can anybody explain to me, how that works?


http://code.google.com/p/unladen-swallow/

Stefan

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


Re: Write web apps in Python?

2010-04-12 Thread Gilles Ganault
On Mon, 12 Apr 2010 12:13:17 +0200, Daniel Fetchinson
 wrote:
>For additional info have a look at http://wiki.python.org/moin/WebProgramming

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


Question about LLVM

2010-04-12 Thread Hannes

Hi Pythoneers,

I heard that its possible to use LLVM to speed up Python.

Can anybody explain to me, how that works?


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


Re: About Python execution speed

2010-04-12 Thread Leonardo Giordani
Thank you Chris and Stefan, this was the answer I was looking for.

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


Re: Classes as namespaces?

2010-04-12 Thread Bruno Desthuilliers

Aahz a écrit :

In article , kj   wrote:

What's the word on using "classes as namespaces"?  E.g.

class _cfg(object):
   spam = 1
   jambon = 3 
   huevos = 2


breakfast = (_cfg.spam, _cfg.jambon, _cfg.huevos)


There is one gotcha associated with using classes as namespaces: you have
to be careful to avoid instantiating them.  That goes triple if you
modify the class attributes, because modifying an attribute in an
instance does *not* propagate the change to the class.


This can be "solved" (using only classmethods and overriding 
__setattr__), but then it begins to be a bit OOTP for a mostly simple 
usecase.

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


Re: About Python execution speed

2010-04-12 Thread Stefan Behnel

Leonardo Giordani, 12.04.2010 11:51:

I'm facing a strange issue in Python execution speed. I'm running the
following test script:

-8<-

dim = 1000
iteration = 10

list1 = []
list2 =  []

for i in range(dim):
 list1.append(float(i))
 list2.append(float(i) * 0.264)


What about this:

list1 = list(map(float, xrange(dim)))
list2 = [f * 0.264 for f in list2]



for k in range(iteration):
 for j in range(dim):
 ris = 0
 ris = ris + list1[j] + list2[j]


What result do you expect for 'ris' after the last two lines?



-8<-

which runs in about 80 seconds on my local hardware (mean of multiple
execution)
If I move the whole code into a function and call this latter the execution
time drops to about 45 seconds.

What is the reason of this improvement?


Local variables in a function can be accessed much faster than globally 
defined names (which require a dictionary lookup). This is a good thing 
because the access to local variables tends to be much more performance 
critical than that to globals.


Stefan

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


Re: About Python execution speed

2010-04-12 Thread Chris Rebert
On Mon, Apr 12, 2010 at 2:51 AM, Leonardo Giordani
 wrote:

> which runs in about 80 seconds on my local hardware (mean of multiple
> execution)
> If I move the whole code into a function and call this latter the execution
> time drops to about 45 seconds.
>
> What is the reason of this improvement?

The top-level module namespace (i.e. global scope) is implemented
using a dictionary (i.e. hash table).
Names in local function scope instead use precalculated offsets into an array.
The latter is faster than the former, hence the speed difference.

Cheers,
Chris
--
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Write web apps in Python?

2010-04-12 Thread Daniel Fetchinson
> I'd like to make sure I understand what the options are to write web
> applications in Python:
>
> - à la PHP, using Apache's mod_python
>
> - using eg. Lighttpd and configuring it to load the Python interpreter
> every time a Python script is called (www.jakehilton.com/?q=node/54)
>
> - long-running process, by compiling the Python script as a
> stand-alone program that will then wait for queries on a port and
> being called by the web server through eg. the WSGI
>
> As for writing apps, I can either built it from scratch, or use
> frameworks like Pylons, TurboGears, or Django.
>
> Is this correct?

Basically, yes.

For additional info have a look at http://wiki.python.org/moin/WebProgramming

Cheers,
Daniel



-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Buy Samsung Corby TXT B3210 Mobile

2010-04-12 Thread mohanti.si...@yahoo.in
Samsung Corby TXT is a GSM phone. Samsung Corby TXT, a SmartPhone
mobile comes with a great list of features.

 Samsung Corby TXT B3210 is a mobile with a user memory of 38 MB and
MicroSD support up to 8 GB of external memory. This simple statement
of specifications is sufficient for mobile buffs to gauge the power of
Samsung Corby TXT B3210.

The Samsung Corby TxT is approximately priced at Rs 7,000 in India.

Samsung Corby Txt Specification
• Network: GSM, Band 850/900/1800/1900
• Dimension: 59×110x12.9
• Display: TFT LCD 2.2 inch
• Battery: 800mAh
• Talk Time: up to 10 hrs
• Standby: up to 316H
• Camera: 2MP, 2x digital zoom
• Video player
• Video recording
• Video messaging
• Video streaming
• Music Player
• MP3 Ringtones
• 3D sound technology • Music Recognition
• FM Radio
• Bluetooth
• WAP
• USB
• PC Sync Application
• User Memory: 38 MB
• SMS Memory: 500
• Phone Book Entries upto 1000
• External Memory: Upto MicroSD(Upto 8GB)
• Speakerphone
For more information: http://www.khojle.in/classifieds/mobile/
-- 
http://mail.python.org/mailman/listinfo/python-list


Buy Samsung Corby TXT B3210 Mobile

2010-04-12 Thread mohanti.si...@yahoo.in
Samsung Corby TXT is a GSM phone. Samsung Corby TXT, a SmartPhone
mobile comes with a great list of features.

 Samsung Corby TXT B3210 is a mobile with a user memory of 38 MB and
MicroSD support up to 8 GB of external memory. This simple statement
of specifications is sufficient for mobile buffs to gauge the power of
Samsung Corby TXT B3210.

The Samsung Corby TxT is approximately priced at Rs 7,000 in India.

Samsung Corby Txt Specification
• Network: GSM, Band 850/900/1800/1900
• Dimension: 59×110x12.9
• Display: TFT LCD 2.2 inch
• Battery: 800mAh
• Talk Time: up to 10 hrs
• Standby: up to 316H
• Camera: 2MP, 2x digital zoom
• Video player
• Video recording
• Video messaging
• Video streaming
• Music Player
• MP3 Ringtones
• 3D sound technology • Music Recognition
• FM Radio
• Bluetooth
• WAP
• USB
• PC Sync Application
• User Memory: 38 MB
• SMS Memory: 500
• Phone Book Entries upto 1000
• External Memory: Upto MicroSD(Upto 8GB)
• Speakerphone
For more information: http://www.khojle.in/classifieds/mobile/
-- 
http://mail.python.org/mailman/listinfo/python-list


Write web apps in Python?

2010-04-12 Thread Gilles Ganault
Hello

I'd like to make sure I understand what the options are to write web
applications in Python:

- à la PHP, using Apache's mod_python

- using eg. Lighttpd and configuring it to load the Python interpreter
every time a Python script is called (www.jakehilton.com/?q=node/54)

- long-running process, by compiling the Python script as a
stand-alone program that will then wait for queries on a port and
being called by the web server through eg. the WSGI

As for writing apps, I can either built it from scratch, or use
frameworks like Pylons, TurboGears, or Django.

Is this correct?

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


About Python execution speed

2010-04-12 Thread Leonardo Giordani
Hi all,

I'm facing a strange issue in Python execution speed. I'm running the
following test script:

-8<-

dim = 1000
iteration = 10

list1 = []
list2 =  []

for i in range(dim):
list1.append(float(i))
list2.append(float(i) * 0.264)

for k in range(iteration):
for j in range(dim):
ris = 0
ris = ris + list1[j] + list2[j]

-8<-

which runs in about 80 seconds on my local hardware (mean of multiple
execution)
If I move the whole code into a function and call this latter the execution
time drops to about 45 seconds.

What is the reason of this improvement?

Thank you very much in advance.

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


Re: 2.7 beta 1

2010-04-12 Thread alex23
Mensanator  wrote:
> You think the right thing to do is just quietly work
> around the problem and sit back and laugh knowing sooner
> or later someone else will get burned by it?

Haven't we covered argument from fallacy enough in this group by now?

Reporting the bug was exactly the right thing to do. Loudly
pronouncing the impending demise of 3.x because of it was not. Coming
up with exaggerated parodies of arguments that no one here is actually
making is even worse.

> Why do you guys think I'm talking about the language? I'm talking
> about a particular implementation.

Probably because _you_ made no such restriction with your blanket
statement of "3.x won't be adopted by developers until it's fixed". If
only "under Windows", "probably" and "IDLE" had been injected into it,
I don't think there would have been a word of disagreement.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A 'foolproof' way to query inheritance tree? numbers.Real in 2.6)

2010-04-12 Thread Steven D'Aprano
On Sun, 11 Apr 2010 21:47:59 -0700, Chris Rebert wrote:

> On Sun, Apr 11, 2010 at 10:46 AM,  
> wrote:
>> Generally, if I want to know the inheritance tree of a class, I either
>> use inspect.getmro or __bases__
>>
>> However, after reading about the new numbers module / class tower in
>> Python 2.6/3.0, I realized that both of these will fail to show that
>> the 'float' type actually inherits from numbers.Real:
> 
> Well, as your introspection shows, it doesn't *actually* inherit from
> numbers.Real.
> However, it does "implement" the numbers.Real Abstract Base Class (ABC)
> and this is reported via the results of issubclass(). Basically,
> `issubclass(x, y)` is no longer more-or-less just sugar for `y in
> x.__mro__` due to changes that have been made to accommodate ABCs.


So this is a "Consenting Adults" inheritance? If I say that MyNumber 
class inherits from numbers.Real, I'm responsible for making sure that 
MyNumber has all the appropriate methods defined by numbers.Real because 
it won't actually inherit any of them.

Given a class C, is there some way to find out what classes
issubclass(C, X) will return true for? Obviously you can get a partial 
list, by walking the MRO, but is there a list somewhere of which ABCs 
consider C a subclass?

Presumably the general answer is No, because any class X could happen to 
have a __subclasscheck__ method that returns True when called with C.



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