Re: [Python-ideas] string.format() default variable assignment

2013-03-03 Thread Steven D'Aprano
On Sun, 03 Mar 2013 03:21:37 +, Steven D'Aprano wrote:

> On Sat, 02 Mar 2013 21:11:04 -0500, David Robinow wrote:

>>  Do you consider it rude that you choose to use a newsreader, thus
>> inconveniencing those of us who use the mailing list, as God intended.
> 
> How the flying fuck does my choice of where and how *I* read this forum
> inconvenience YOU?

Hmmm. While I stand by the general sentiments, I think I flew off the 
handle there. In retrospect, I wish I had said that in a less aggressive 
manner.

David, please consider this an apology for the bellicose response to your 
rhetorical question.


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


Re: [Python-ideas] string.format() default variable assignment

2013-03-03 Thread Steven D'Aprano
On Sat, 02 Mar 2013 23:00:13 -0500, Devin Jeanpierre wrote:

> On Sat, Mar 2, 2013 at 10:21 PM, Steven D'Aprano
>  wrote:
>> How the flying fuck does my choice of where and how *I* read this forum
>> inconvenience YOU?
>>
>> Talk about an overactive sense of entitlement. The world does not
>> revolve around you and I do not arrange my day to suit your
>> preferences.
> 
> I don't agree with what he said, but I think what he was getting at is
> that it's inconvenient to be polite to you according to the standards
> you have set.

Whether I read these messages via Usenet or email or a web-based archive 
or by having a trained monkey forward the message to me in Morse code 
makes *absolutely no difference* to the sender. All he need do is send to 
the same list *he* reads the messages from, using whatever protocol he 
chooses to use.

The very idea that my choice to read this in Pan newsreader rather than 
some email client somehow inconveniences David Robinow is stupid.

Furthermore, he's picked out the *least* important part of my original 
email to respond to. Even if I read this via email rather than news, 
people emailing me directly rather than via the list may bypass any email 
filters I may have set up. The use of news rather than email is merely 
*equivalent* to a filter, where posts to this forum go into my news 
reader instead of my email inbox.

And then there are people who go on No Mail and read responses via a web 
archive, including the dreaded Google Groups. Or rather than receiving 
individual messages, they go on digest mail. By emailing them directly, 
you dis-empower them, taking away their choice of how they read messages 
on that mailing list.

I'm sorry, but *your response is not that important* that you get to 
thoughtlessly take away my choice of where and how I read messages. 
(That's generic "you", not specifically you, Devin). That's a sign of 
unreasonable sense of entitlement, conscious or not, and lack of 
consideration for others.

I'm not being unreasonable here. Not withstanding the occasional person, 
like Roy Smith, who considers it a good thing[1], if you reply directly 
to the sender, in a small way you are taking away the sender's freedom of 
choice. And that is rude.





[1] Perhaps Roy hasn't experienced really high volume threads, with 
hundreds of messages a day, and getting two copies of every email in any 
thread you replied to. I have.


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


Python in web development

2013-03-03 Thread Sarbjit singh
Hello All,

I have been using Python as a scripting language for my office tasks. Now I 
have been thinking of using (and learning as well) for web development. For my 
tasks, I need to perform some tasks and report on the web. Now I have no 
experience of web development with Python. So, I want to conform first whether 
Python is best for web development. Python is my personal choice for my 
automation works and I want to extend it for web development.

REQUIREMENT:
I need to develop a html form which would take user input and perform some 
operations (generate intermediate files) and report result on web.

>> Some guys in my organization are using Perl for this purpose and thus I 
>> could get the setup for free.But I want to learn and use Python as 
>> substitute for Perl. (PHP could also be an option. I have worked on PHP once 
>> for handling the form data.)

So my questions are:-

1. Can I use Python (I want to use personally :)) over PHP/Perl?

2. If Yes, I want to know the modules that I should learn for achieving my 
requirement. I searched internet and found Python provides CGI, Django etc.

I don't much about Django/CGI, please suggest which module I should learn and 
use.

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


Re: Is it correct this way to inherit from a list?

2013-03-03 Thread Colin J. Williams

On 02/03/2013 9:30 PM, gialloporpora wrote:

Risposta al messaggio di Rick Johnson :


What are you trying to achieve exactly?



I would like to implement a class (vector) to works with vectors, for
example using scalar multiplication:
a*v = [a*v1, a*vn]
and a dual class for dual vector (the only method that I'll change is
the __str__ method to print it as colun.
Sandro

Numpy facilitates this sort of thing more efficiently than using a List.

Colin W.

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


Re: Python in web development

2013-03-03 Thread becky_lewis
1) Python is absolutely fine for web development. It's just as good, if not 
better than PHP or Perl for this sort of work (that's my opinion anyway).

2) I've used Django quite extensively and it can certainly handle your 
requirements. You might want to have a look at Flask (http://flask.pocoo.org/) 
as it's not quite as heavy as Django so would possibly suit your needs a little 
better.


On Sunday, March 3, 2013 2:18:00 PM UTC, Sarbjit singh wrote:
> Hello All,
> 
> 
> 
> I have been using Python as a scripting language for my office tasks. Now I 
> have been thinking of using (and learning as well) for web development. For 
> my tasks, I need to perform some tasks and report on the web. Now I have no 
> experience of web development with Python. So, I want to conform first 
> whether Python is best for web development. Python is my personal choice for 
> my automation works and I want to extend it for web development.
> 
> 
> 
> REQUIREMENT:
> 
> I need to develop a html form which would take user input and perform some 
> operations (generate intermediate files) and report result on web.
> 
> 
> 
> >> Some guys in my organization are using Perl for this purpose and thus I 
> >> could get the setup for free.But I want to learn and use Python as 
> >> substitute for Perl. (PHP could also be an option. I have worked on PHP 
> >> once for handling the form data.)
> 
> 
> 
> So my questions are:-
> 
> 
> 
> 1. Can I use Python (I want to use personally :)) over PHP/Perl?
> 
> 
> 
> 2. If Yes, I want to know the modules that I should learn for achieving my 
> requirement. I searched internet and found Python provides CGI, Django etc.
> 
> 
> 
> I don't much about Django/CGI, please suggest which module I should learn and 
> use.
> 
> 
> 
> Thanks
> 
> Sarbjit

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


Re: Python in web development

2013-03-03 Thread Michael Torrie
On 03/03/2013 07:18 AM, Sarbjit singh wrote:
> 1. Can I use Python (I want to use personally :)) over PHP/Perl?

Yes of course.

> 2. If Yes, I want to know the modules that I should learn for
> achieving my requirement. I searched internet and found Python
> provides CGI, Django etc.
> 
> I don't much about Django/CGI, please suggest which module I should
> learn and use.

There are literally dozens of frameworks you can use.  You could use
straight CGI if you wanted, but I recommend a framework with a decent
templating engine for HTML code generation.

Anyway, a list--not exhaustive--of frameworks can be found here:

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

Django is one of the most popular.  Web2Py is another.  Though they
might seem overkill, it's well worth it to use them and learn them.
They both have good documentation.  So start there at their individual
sites.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to install development package on linux?

2013-03-03 Thread Michael Torrie
On 03/02/2013 11:39 PM, Sarbjit singh wrote:
> Yes, I configured the makefile for mod_wsgi as without any error :
>  ./configure --prefix=/opt/lampp/ --with-apxs=/opt/lampp/bin/apxs 
> --with-python=/opt/lampp/python/bin/python2.7 
> --with-mutex-dir=/opt/lampp/var/run/wsgi

This is not quite right.  the --with-python option should point to the
python install path, not the python binary itself.  It probably should be:

--with-python=/opt/lampp/python

Presuming that's what you used as a prefix when you built and installed
python 2.7.

When installing from source code, there's no such thing as a
"development package."  Tarballs nominally install binaries, libraries,
and header files, which is the equivalent of a Red Hat rpm plus the
devel rpm.  In other words when you did a "make install" everything you
need to compile against python 2.7 is installed to the prefix you used.


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


IV ECCOMAS Thematic Conference VipIMAGE 2013: CALL FOR CONTRIBUTIONS

2013-03-03 Thread tava...@fe.up.pt
Dear Colleague,

We are pleased to invite you to the International Conference VipIMAGE 2013 - IV 
ECCOMAS THEMATIC CONFERENCE ON COMPUTATIONAL VISION AND MEDICAL IMAGE 
PROCESSING (www.fe.up.pt/~vipimage) to be held October 14-16, 2013, in Melia 
Madeira Mare Hotel, Madeira Island, Funchal, Portugal.


Possible Topics (not limited to)

• Signal and Image Processing 
• Computational Vision 
• Medical Imaging 
• Physics of Medical Imaging 
• Tracking and Analysis of Movement 
• Simulation and Modeling
• Image Acquisition 
• Industrial Applications 
• Shape Reconstruction 
• Objects Segmentation, Matching, Simulation 
• Data Interpolation, Registration, Acquisition and Compression 
• 3D Vision 
• Virtual Reality 
• Visual Inspection 
• Software Development for Image Processing and Analysis 
• Computer Aided Diagnosis, Surgery, Therapy, and Treatment 
• Computational Bioimaging and Visualization 
• Telemedicine Systems and their Applications

Invited Lecturers

• Daniel Rueckert - Imperial College London, UK
• Dimitris N. Metaxas - Rutgers University, USA
• Durval C. Costa - Champalimaud Foundation, Portugal
• James S Duncan - Yale School of Medicine, USA
• Milan Sonka - The University of Iowa, USA
• Richard Bowden - University of Surrey, UK

Thematic Sessions

Proposals to organize Thematic Session under the auspicious of VipIMAGE 2013 
are welcome.
The organizers of the selected thematic sessions will be included in the 
conference scientific committee and will have a reduced registration fee. 
Additionally, they will be responsible for the dissemination of their thematic 
session, may invite expertise researchers to have invited keynotes during their 
session and will participate in the review process of the submitted 
contributions.
Proposals for Thematic Sessions should be submitted by email to the conference 
co-chairs (tava...@fe.up.pt, rna...@fe.up.pt) until March 1, 2013.

Confirmed thematic session: “Imaging of Biological Flows: trends and challenges”

Publications

Proceedings: The proceedings book will be published by the Taylor & Francis 
Group (www.balkema.nl/instructions.asp) and indexed by Thomson Reuters 
Conference Proceedings Citation Index, IET Inspect and Elsevier Scopus.
Springer Book: A book with 20 invited works from the ones presented in the 
conference will be published by Springer under the book series “Lecture Notes 
in Computational Vision and Biomechanics” (www.springer.com/series/8910).
Journal Publication: A dedicated special issue of the Taylor & Francis 
International Journal “Computer Methods in Biomechanics and Biomedical 
Engineering: Imaging & Visualization” (www.tandfonline.com/tciv) will be 
published with extended versions of the best works presented in the conference.

Important dates

• Deadline for Thematic Session Proposals: March 1, 2013
• Deadline for Extended Abstracts: April 15, 2013
• Authors Notification: May 1, 2013
• Deadline for Lectures and Papers: July 1, 2013


We are looking forward to see you in Funchal next October.

Kind regards,

João Manuel R. S. Tavares
Renato Natal Jorge
(conference co-chairs)

PS. For further details please have a look in the conference website at: 
www.fe.up.pt/~vipimage, or the facebook page at: 
www.facebook.com/pages/Vipimage/237980719665456

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


Re: Python in web development

2013-03-03 Thread Michael Herman
If Python is your personal choice, then it's the *best* for you. If
you are literally just going to be processing an HTML form, then CGI
is your best bet. However, if you think this functionally will grow,
then it's worth learning a web framework.

I would go with a micro framework. bottle.py is a perfect starting
point. I am a huge Flask fan, but it's a little higher level. I have
tutorials here for Flask -
http://www.youtube.com/playlist?list=PLLjmbh6XPGK5pM1QJ8I1ccdGiCTHa1IC8

Also, check out realpythonfortheweb.com for more tutorials.

Good luck! :)

On Sun, Mar 3, 2013 at 6:18 AM, Sarbjit singh  wrote:
>
> Hello All,
>
> I have been using Python as a scripting language for my office tasks. Now
> I have been thinking of using (and learning as well) for web development.
> For my tasks, I need to perform some tasks and report on the web. Now I have
> no experience of web development with Python. So, I want to conform first
> whether Python is best for web development. Python is my personal choice for
> my automation works and I want to extend it for web development.
>
> REQUIREMENT:
> I need to develop a html form which would take user input and perform some
> operations (generate intermediate files) and report result on web.
>
> >> Some guys in my organization are using Perl for this purpose and thus I
> >> could get the setup for free.But I want to learn and use Python as
> >> substitute for Perl. (PHP could also be an option. I have worked on PHP 
> >> once
> >> for handling the form data.)
>
> So my questions are:-
>
> 1. Can I use Python (I want to use personally :)) over PHP/Perl?
>
> 2. If Yes, I want to know the modules that I should learn for achieving my
> requirement. I searched internet and found Python provides CGI, Django etc.
>
> I don't much about Django/CGI, please suggest which module I should learn
> and use.
>
> Thanks
> Sarbjit
> --
> http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list


استفتاء هل ستشارك فى الانتخابات البرلمانيه القادمه مجلس النواب

2013-03-03 Thread 23alagmy
استفتاء هل ستشارك فى الانتخابات البرلمانيه القادمه مجلس النواب

https://www.facebook.com/permalink.php?story_fbid=542812542426361&id=299719160065550

facebook

https://www.facebook.com/sharer/sharer.php?u=http%3A%2F%2Fnatigtas7ab.blogspot.com%2F2013%2F03%2Fblog-post_7369.html%23.UTOIFr8OJp8.facebook

twitter

https://twitter.com/intent/tweet?text=%D8%A7%D8%B3%D8%AA%D9%81%D8%AA%D8%A7%D8%A1+%D9%87%D9%84+%D8%B3%D8%AA%D8%B4%D8%A7%D8%B1%D9%83+%D9%81%D9%89+%D8%A7%D9%84%D8%A7%D9%86%D8%AA%D8%AE%D8%A7%D8%A8%D8%A7%D8%AA+%D8%A7%D9%84%D8%A8%D8%B1%D9%84%D9%85%D8%A7%D9%86%D9%8A%D9%87+%D8%A7%D9%84%D9%82%D8%A7%D8%AF%D9%85%D9%87+%D9%85%D8%AC%D9%84%D8%B3+%D8%A7%D9%84%D9%86%D9%88%D8%A7%D8%A8+~+%D9%86%D8%AA%D8%A7%D8%A6%D8%AC+%D8%A7%D9%84%D8%A5%D9%85%D8%AA%D8%AD%D8%A7%D9%86%D8%A7%D8%AA+%D9%84%D9%84%D8%B4%D9%87%D8%A7%D8%AF%D8%A7%D8%AA+%D9%88%D8%A7%D9%84%D8%AC%D8%A7%D9%85%D8%B9%D8%A7%D8%AA&url=http%3A%2F%2Fnatigtas7ab.blogspot.com%2F2013%2F03%2Fblog-post_7369.html%23.UTOIGTZk_ew.twitter&related=
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: i need help

2013-03-03 Thread Kwpolska
On Sun, Mar 3, 2013 at 7:46 AM, Michael Torrie  wrote:
> On 02/21/2013 03:18 AM, leonardo wrote:
>> thanks, problem solved
>
> Apparently not.  The shift key on your keyboard still seems to be
> non-functional. ;)
> --
> http://mail.python.org/mailman/listinfo/python-list

It is!  How else could he type those two question marks and 10 double-quotes?

-- 
Kwpolska  | GPG KEY: 5EAAEA16
stop html mail| always bottom-post
http://asciiribbon.org| http://caliburn.nl/topposting.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Question about Tashaphyne package in python

2013-03-03 Thread MRAB

On 2013-03-03 03:06, yomnasala...@gmail.com wrote:

I have a Python code that take an Arabic word and get the root and also remove diacritics, but i I have a problem with the output. For 
example  : when the input is "العربيه" the output is:"عرب" which is right answer but when the input is "كاتب" 
the output is:"ب", and when the input is "يخاف" the output is " خف".

This is my code:

# -*- coding=utf-8 -*-

import re
from arabic_const import *
import Tashaphyne
from Tashaphyne import *
import enum
from enum import Enum
search_type=Enum('unvoc_word','voc_word','root_word')

HARAKAT_pat = re.compile(ur"[" + u"".join([FATHATAN, DAMMATAN, KASRATAN, FATHA, DAMMA, 
KASRA, SUKUN, SHADDA]) + u"]")
HAMZAT_pat = re.compile(ur"[" + u"".join([WAW_HAMZA, YEH_HAMZA]) + u"]");
ALEFAT_pat = re.compile(ur"[" + u"".join([ALEF_MADDA, ALEF_HAMZA_ABOVE, ALEF_HAMZA_BELOW, 
HAMZA_ABOVE, HAMZA_BELOW]) + u"]");
LAMALEFAT_pat = re.compile(ur"[" + u"".join([LAM_ALEF, LAM_ALEF_HAMZA_ABOVE, 
LAM_ALEF_HAMZA_BELOW, LAM_ALEF_MADDA_ABOVE]) + u"]");


[snip]
When you're using Unicode with re in Python 2, you should include the
re.UNICODE flag. For example:

HARAKAT_pat = re.compile(ur"[" + u"".join([FATHATAN, DAMMATAN, KASRATAN, 
FATHA, DAMMA, KASRA, SUKUN, SHADDA]) + u"]", flags=re.UNICODE)


or:

HARAKAT_pat = re.compile(ur"(?u)[" + u"".join([FATHATAN, DAMMATAN, 
KASRATAN, FATHA, DAMMA, KASRA, SUKUN, SHADDA]) + u"]")


I don't know whether that will make a difference in this case because I
don't know Tashaphyne or Arabic.

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


Re: Python in web development

2013-03-03 Thread Roy Smith
In article ,
 Sarbjit singh  wrote:

> Hello All,
> 
> I have been using Python as a scripting language for my office tasks. Now I 
> have been thinking of using (and learning as well) for web development. For 
> my tasks, I need to perform some tasks and report on the web. Now I have no 
> experience of web development with Python. So, I want to conform first 
> whether Python is best for web development. Python is my personal choice for 
> my automation works and I want to extend it for web development.
> 
> REQUIREMENT:
> I need to develop a html form which would take user input and perform some 
> operations (generate intermediate files) and report result on web.

It's got a bit of a steep learning curve, but django might be what 
you're looking for.  I would start with the tutorial:

https://docs.djangoproject.com/en/1.5/intro/tutorial01/

and eventually work your way to class-based views and forms:

https://docs.djangoproject.com/en/1.5/topics/class-based-views/generic-ed
iting/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is it correct this way to inherit from a list?

2013-03-03 Thread Jason Swails
On Sun, Mar 3, 2013 at 9:21 AM, Colin J. Williams  wrote:

> On 02/03/2013 9:30 PM, gialloporpora wrote:
>
>> Risposta al messaggio di Rick Johnson :
>>
>>  What are you trying to achieve exactly?
>>>
>>
>>
>> I would like to implement a class (vector) to works with vectors, for
>> example using scalar multiplication:
>> a*v = [a*v1, a*vn]
>> and a dual class for dual vector (the only method that I'll change is
>> the __str__ method to print it as colun.
>> Sandro
>>
> Numpy facilitates this sort of thing more efficiently than using a List.
>

As a couple people have already pointed out, numpy is the way to go for
most scientific applications.  You have also been given good advice
regarding 'properly' inheriting from 'list' by calling the list.__init__
function.

The only thing I'll add here is that you can inherit from array.array
instead of list if you want a 'truly' numeric-vector without introducing
numpy as a dependency.  The advantage array.array has over list in this
instance is that it is type-restrictive for member data (it has to be
pre-declared and throws TypeError if you try to pass it a bad variable
type).

You can then proceed to override the __add__, __sub__, __mul__, and __div__
methods (and the in-place versions of these operators) to mimic vector
operations.  (By default, __add__ appends the rhs to the lhs and returns a
copy of that for array.array and list).

You can avoid all this work, however, and just use numpy.ndarray instead ;).

Good luck,
Jason
-- 
http://mail.python.org/mailman/listinfo/python-list


How to prevent tests from running against production?

2013-03-03 Thread Roy Smith
Our deploy/configuration system includes credentials for connecting to a 
database.  We have one production database, and a variety of clones of 
that in our test and development environments.

We've got a large body of tests, written with a combination of unittest 
and nose.  Many of our tests do things which shouldn't be done against 
the production database.  I'd like to set things up so anytime any test 
code gets run, a check is made to see which database you're connected to 
and if you're connect to production, the test refuses to run.

It's easy to write a check like that in setup(), but that only gets 
called if you remember to write a setup() method (or inherit from 
something that does).  I'm looking for something that runs completely 
automatically.  I don't want somebody to be able to write something 
which causes damage that nose can discover and run when you're connected 
to the wrong database.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pygame mouse cursor load/unload

2013-03-03 Thread Alex Gardner
On Saturday, March 2, 2013 7:56:31 PM UTC-6, Alex Gardner wrote:
> I am in the process of making a pong game in python using the pygame library. 
>  My current problem is that when I move the mouse, it turns off as soon as 
> the mouse stops moving.  The way I am doing this is by making the default 
> cursor invisible and using .png files as replacements for the cursor.  
> Perhaps my code would best explain my problem.  I will take help in any way 
> that I can.  Here are the links that contain my code:
> 
> 
> 
> Main class:  http://pastebin.com/HSQzX6h2
> 
> Main file (where the problem lies):  http://pastebin.com/67p97RsJ
> 
> 
> 
> If the links yield nothing, please let me know (agardner...@gmail.com)

I have a new problem :(.  I want to restrict the paddle to a certain plane.  I 
have it working but when the paddle reaches the limit it locks up.  I have no 
idea how I can redraw it back in the plane.  I am using the code that Ian 
provided (thank you so much).  I was thinking of making an else to redraw the 
paddle using the same code, but part of me thinks that it would be rather 
sloppy.

if (0,0) <= paddle_pos <= (300,300):
 paddle_pos = pygame.mouse.get_pos() 
 screen.blit(beeper, paddle_pos)
 pygame.display.update()
 clock.tick(50)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pygame mouse cursor load/unload

2013-03-03 Thread Alex Gardner
On Saturday, March 2, 2013 7:56:31 PM UTC-6, Alex Gardner wrote:
> I am in the process of making a pong game in python using the pygame library. 
>  My current problem is that when I move the mouse, it turns off as soon as 
> the mouse stops moving.  The way I am doing this is by making the default 
> cursor invisible and using .png files as replacements for the cursor.  
> Perhaps my code would best explain my problem.  I will take help in any way 
> that I can.  Here are the links that contain my code:
> 
> 
> 
> Main class:  http://pastebin.com/HSQzX6h2
> 
> Main file (where the problem lies):  http://pastebin.com/67p97RsJ
> 
> 
> 
> If the links yield nothing, please let me know (agardner...@gmail.com)

I have a new problem that I'm dealing with.  I want to restrict the paddle to a 
certain plane.  When the paddle reaches the boundary, it locks up.  I am using 
the code that Ian provided earlier (thank you so much).  Here is what I have so 
far:

if (0,0) <= paddle_pos <= (300,300):
 paddle_pos = pygame.mouse.get_pos() 
 screen.blit(beeper, paddle_pos)
 pygame.display.update()
 clock.tick(50)

I tried making an else statement and copying Ian's code in it, but I don't 
think that it would work.  I have tried to fix this myself; this is my second 
GUI program that I have ever made please forgive me if I seem needy. 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Dealing with exceptions

2013-03-03 Thread Nobody
On Sat, 02 Mar 2013 18:52:19 +0100, Kwpolska wrote:

> Also, you can do `except:` for a catch-all, but it is discouraged unless
> you have REALLY good reasons to do this.  And, most of the time, you
> don’t.

Most of the time you probably want to catch either Exception (which
excludes GeneratorExit, KeyboardInterrupt and SystemExit) or StandardError
(which excludes the above pluse warnings and StopIteration).

Only in specific circumstances can you reasonably go finer than that,
partly due to the set of exceptions a method may throw seldom being
documented, and partly due to duck typing; a parameter which is intended
to be a file object could realistically be any object which supports the
appropriate methods (e.g. .read()), and there's no guarantee that those
methods will have the same set of possible exceptions as a real file
object.

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


Re: Speeding up Python's exit

2013-03-03 Thread Ross Ridge
Antoine Pitrou   wrote:
>Now please read my message again. The OS buffers are *not* flushed according
>to POSIX.

POSIX says open *streams* might not be flushed.  POSIX streams are C
FILE * streams and generally aren't regarded as being part of the OS.

When you call os._exit() in a Python program any unwritten data still
in Python's own file buffers will be lost.  Any unwritten data still
in the C library's FILE * buffers will be lost.  Any data successfuly
written through a POSIX file descriptor (eg. using the write() function)
will not be lost becasue os._exit() was used.

Note that this doesn't mean that OS buffers will flushed when os._exit()
is called.  Data that hasn't yet been physically written to disk, hasn't
be successfully transmitted over the network, or otherwise hasn't been
fully comitted could still be lost.  However, exiting Python normally
doesn't change this.  Only the Python process's own internal buffers are
flushed, the OS doesn't change its handling of its buffers.  If you want
written data to be fully committed before exiting you need to use other
OS services that guarantee this.

Ross Ridge

-- 
 l/  //   Ross Ridge -- The Great HTMU
[oo][oo]  rri...@csclub.uwaterloo.ca
-()-/()/  http://www.csclub.uwaterloo.ca/~rridge/ 
 db  //   
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Twisted or Tornado?

2013-03-03 Thread Jake Angulo
All,

Thanks for your reply - I thought I would share the outcome of my choice:

I have chosen to use twisted.   The API is very decent to learn, though the
clincher is theres huge community / docs, and many projects used on
production.

I was able to make a working project prototype in hours!
Thanks to the large twisted library.

Our project is an ipad multiplayer game, and we didnt want to use existing
servers because we want to do things exactly as we wish.

Rgds,

Jake

On Fri, Mar 1, 2013 at 8:55 PM, Andriy Kornatskyy <
andriy.kornats...@live.com> wrote:

>
> The following benchmarks are related to:
>
> a) python web frameworks
> http://mindref.blogspot.com/2012/09/python-fastest-web-framework.html
> http://mindref.blogspot.com/2012/10/python-web-routing-benchmark.html
> http://mindref.blogspot.com/2012/10/python-web-reverse-urls-benchmark.html
> http://mindref.blogspot.com/2012/10/python-web-caching-benchmark.html
>
> b) template engines
> http://mindref.blogspot.com/2012/10/python-templates-benchmark.html
> http://mindref.blogspot.com/2012/07/python-fastest-template.html
>
> With source code:
> https://bitbucket.org/akorn/helloworld
>
> Thanks.
>
> Andriy Kornatskyy
>
>
> 
> > Date: Fri, 1 Mar 2013 09:25:43 +
> > Subject: Re: Twisted or Tornado?
> > From: sven...@gmail.com
> > To: jake.ang...@gmail.com
> > CC: python-list@python.org
> >
> > Although these articles are a _little_ old they are probably useful to
> > help you decide which solution is most suitable for you in terms of
> > performance
> >
> > http://nichol.as/benchmark-of-python-web-servers
> > http://nichol.as/asynchronous-servers-in-python
> >
> > I would also be interested if any one on this list has any idea if the
> > results above would be any different these days or whether the
> > benchmarks are still fairly representative.
> >
> >
> > On 1 March 2013 00:28, Jake Angulo
> > mailto:jake.ang...@gmail.com>> wrote:
> > I have to say it first: I am not trolling :P
> >
> > Im working on a server project (with IOS client) and would like to
> > create a custom, lean and mean server - real Quick!
> >
> > My requirements for this framework in descending order:
> > 1) Easy to use API
> > 2) Widely available documentation / Examples / Community contributions
> > 3) Feature-wise - kinda most that you commonly need is there
> >
> > Your opinions will be valuable, if possible cite examples or URL
> > references, Pls!
> >
> > I prefer opinion from those who have programmed real projects in it -
> > not just read some blog or Slashdot :P
> > --
> > http://mail.python.org/mailman/listinfo/python-list
> >
> >
> >
> > --
> > ./Sven
> >
> > -- http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pygame mouse cursor load/unload

2013-03-03 Thread Ian Kelly
On Sun, Mar 3, 2013 at 3:09 PM, Alex Gardner  wrote:
> if (0,0) <= paddle_pos <= (300,300):

This doesn't do what you think it does.  Tuples are compared
lexicographically, not element-wise.  So (250, 350) < (300, 300), but
(350, 250) > (300, 300).

>  paddle_pos = pygame.mouse.get_pos()
>  screen.blit(beeper, paddle_pos)
>  pygame.display.update()
>  clock.tick(50)

You're updating paddle_pos inside the if block.  Once paddle_pos falls
outside that range, the if block won't trigger, and paddle_pos will no
longer be updated, so it will never fall inside that range again.

pygame has a Rect class for rectangle logic that can solve both of
these problems for you.  Given:

paddle_rect = beeper.get_rect()
bounds_rect = pygame.Rect(0, 0, 300, 300)

your position update code then becomes:

paddle_rect.center = pygame.mouse.get_pos()
paddle_rect.clamp_ip(bounds_rect)

Note that paddle_rect can replace paddle_pos entirely.  The code:

screen.blit(beeper, paddle_pos)

simply becomes:

screen.blit(beeper, paddle_rect)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Do you feel bad because of the Python docs?

2013-03-03 Thread Jake Angulo
The OP speaks for himself alone.

Python - for such a very young language, and with the documentation and
community blogs available at this point - I cannot ask for more.

And who needs docs when the python syntax is as good as writing plain
english sentence?


On Fri, Mar 1, 2013 at 9:06 PM, Jean-Michel Pichavant <
jeanmic...@sequans.com> wrote:

> [snip hostile replies]
>
> It's somehow funny to read such posts on a thread about someone
> complaining about the community python being hostile.
> I think we should really try to resist the urge of answering trolls
> because no matter how many times we slap them, they'll stay trolls and
> probably get even bigger.
>
> Instead, we take revenge by helping someone asking us to do his homework
> and show the world how merciful the python community is.
>
> JM
>
>
> -- IMPORTANT NOTICE:
>
> The contents of this email and any attachments are confidential and may
> also be privileged. If you are not the intended recipient, please notify
> the sender immediately and do not disclose the contents to any other
> person, use it for any purpose, or store or copy the information in any
> medium. Thank you.
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Twisted or Tornado?

2013-03-03 Thread Michael Torrie
On 03/03/2013 04:35 PM, Jake Angulo wrote:
> All,
> 
> Thanks for your reply - I thought I would share the outcome of my choice:
> 
> I have chosen to use twisted.   The API is very decent to learn, though the
> clincher is theres huge community / docs, and many projects used on
> production.
> 
> I was able to make a working project prototype in hours!
> Thanks to the large twisted library.

Sweet!  Thanks for letting us know the outcome.  I think that's one of
the most rewarding things about working with Python (and it's many
libraries, frameworks, and projects).  It's so fast to get a prototype
up and running.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to prevent tests from running against production?

2013-03-03 Thread Ross Ridge
Roy Smith   wrote:
>Our deploy/configuration system includes credentials for connecting to a 
>database.  We have one production database, and a variety of clones of 
>that in our test and development environments.

Having your tests use credentials that don't work in the production
environment would seem to be the obvious solution.

Ross Ridge

-- 
 l/  //   Ross Ridge -- The Great HTMU
[oo][oo]  rri...@csclub.uwaterloo.ca
-()-/()/  http://www.csclub.uwaterloo.ca/~rridge/ 
 db  //   
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to prevent tests from running against production?

2013-03-03 Thread Steven D'Aprano
On Sun, 03 Mar 2013 16:56:16 -0500, Roy Smith wrote:

> Our deploy/configuration system includes credentials for connecting to a
> database.  We have one production database, and a variety of clones of
> that in our test and development environments.
> 
> We've got a large body of tests, written with a combination of unittest
> and nose.  Many of our tests do things which shouldn't be done against
> the production database.  I'd like to set things up so anytime any test
> code gets run, a check is made to see which database you're connected to
> and if you're connect to production, the test refuses to run.

Test code is just code, so in general you can't guarantee to idiot-proof 
your tests. Anyone can write a function, called by one of the tests, 
which connects directly to the production database and does whatever they 
want. But I assume you're not worried about malice.

One solution: create a single module, used by all tests, that handles 
connection to the database. Simply don't have your connection module 
connect to the database you don't want it to connect to. Since all tests 
go through that module for connections, you can enforce whatever access 
rules you like.

For added security, you should ensure that the production database does 
not accept the same credentials as the test databases.

Another solution: instead of calling unittest.TestCase directly, write 
your own subclass, then have all your tests use that:

class MyTestCase(unittest.TestCase):
def __init__(self, *args, **kwargs):
if DATABASE == 'Production':
import webbrowser
webbrowser.open("http://i.imgur.com/y7Hm9.jpg";, new=1)
raise RuntimeError("don't use production database")
super(MyTestCase, self).__init__(*args, **kwargs)


For added paranoia (and/or debugging fun), consider monkey-patching 
unittest and/or nose.



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