Re: Frameworks

2009-10-19 Thread Javier Santana
juno
http://github.com/breily/juno

it's very easy, uses sqlalchemy as ORM and jinja2 (others can be used
if you want) for templates.

On Mon, Oct 19, 2009 at 10:24 AM, Bruno Desthuilliers
 wrote:
> flebber a écrit :
>>
>> Hi
>>
>> I have been searching through the vast array of python frameworks
>> http://wiki.python.org/moin/WebFrameworks and its quite astounding the
>> choice available.
>>
>> I am looking at using a web framework for my personal project which
>> isn't actually aimed at developing a website as such. However I deduce
>> that rather than creating a gui application and screen input for data,
>> I can use a web browser for this and have a great array of tools to
>> format input screens and output display formats.
>
> Yeps - but remember that a web app will have a couple limitations /
> drawbacks, specially wrt/ handling complex UI.
>
>> Since I will be retreiving information from several websites (usually
>> csv files) formatting them and submitting them to a database and
>> creating queries and printouts based on them most frameworks seem to
>> handle this basically with ease and for any complex queries most
>> support SqlAlchemy.
>>
>> Is it simply a case of just picking one and starting and I would find
>> it hard to be dissapointed or is there a few special considerations to
>> make, though I am unsure what they are?
>
> Given your "specs", forget about monstruosities like Zope, Twisted etc, that
> will mostly get in the way. You have simple needs, use a simple tool !-)
>
>> Most obvious ones I am considering are Django (Of course),
>
> A pretty good framework, but you'll loose some of it's nice features if you
> ever want to use an alternate DB layer or templating system. OTHO, most
> other more "flexible" frameworks just don't offer this level of integration,
> so it's may not be such a big deal.
>
> Note that Django's ORM, while already pretty good and constently improving,
> is not as powerful as SLQAlchemy (now nothing prevents you from going down
> to raw SQL for the more complex queries - and this might be better anyway,
> since complex queries usually requires to be very fine tuned and tend to not
> be really portable). The Forms API OTHO is a real winner IMHO.
>
>> Pylons
>> includes SqlAlchemy, Sql Object and templating and I here turbogears
>> plans to sit on top of this platform.
>
> I admit I fail to see what TG brings except for more indirection levels.
>
>> Zope I am considering but I am a
>> little confused by this.
>
> Friendly advice (based on years of working experience): don't waste your
> time with Zope.
>
>> The are heaps of others but not sure how to
>> narrow the selection criteria.
>>
>> How/Why woul you split Django and Pylons let alone the others?
>
> Django : very strong integration, excellent documentation and support, huge
> community, really easy to get started with. And possibly a bit more mature
> and stable...
>
> Pylons : more loosely coupled (imply: less integration), based on "standard"
> components - which is both a blessing and a curse, specially wrt/
> documentation -, requires a good knowledge of Python and the HTTP protocol
> to get started with. Very powerful and flexible but this comes with a
> price...
>
> Now both are written by talented programmers, and both are pretty good
> tools. I guess it's more a matter of personal preferences and/or external
> constraints (PHB etc...) than anything else.
>
> A couple other "lightweight" candidates you migh want to consider are
> werkzeug and web.py:
>
> http://werkzeug.pocoo.org/
> http://webpy.org/
>
>> Database likely to be MySQl
>
> Mmmm If your application is "write-heavy", PostgreSQL might be a better
> choice. Anyway, both Django's ORM and SQLAlchemy work fine with MySQL
> AFAICT.
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Frameworks

2009-10-19 Thread Bruno Desthuilliers

flebber a écrit :

Hi

I have been searching through the vast array of python frameworks
http://wiki.python.org/moin/WebFrameworks and its quite astounding the
choice available.

I am looking at using a web framework for my personal project which
isn't actually aimed at developing a website as such. However I deduce
that rather than creating a gui application and screen input for data,
I can use a web browser for this and have a great array of tools to
format input screens and output display formats.


Yeps - but remember that a web app will have a couple limitations / 
drawbacks, specially wrt/ handling complex UI.



Since I will be retreiving information from several websites (usually
csv files) formatting them and submitting them to a database and
creating queries and printouts based on them most frameworks seem to
handle this basically with ease and for any complex queries most
support SqlAlchemy.

Is it simply a case of just picking one and starting and I would find
it hard to be dissapointed or is there a few special considerations to
make, though I am unsure what they are?


Given your "specs", forget about monstruosities like Zope, Twisted etc, 
that will mostly get in the way. You have simple needs, use a simple 
tool !-)



Most obvious ones I am considering are Django (Of course),


A pretty good framework, but you'll loose some of it's nice features if 
you ever want to use an alternate DB layer or templating system. OTHO, 
most other more "flexible" frameworks just don't offer this level of 
integration, so it's may not be such a big deal.


Note that Django's ORM, while already pretty good and constently 
improving, is not as powerful as SLQAlchemy (now nothing prevents you 
from going down to raw SQL for the more complex queries - and this might 
be better anyway, since complex queries usually requires to be very fine 
tuned and tend to not be really portable). The Forms API OTHO is a real 
winner IMHO.



Pylons
includes SqlAlchemy, Sql Object and templating and I here turbogears
plans to sit on top of this platform.


I admit I fail to see what TG brings except for more indirection levels.


Zope I am considering but I am a
little confused by this.


Friendly advice (based on years of working experience): don't waste your 
time with Zope.



The are heaps of others but not sure how to
narrow the selection criteria.

How/Why woul you split Django and Pylons let alone the others?


Django : very strong integration, excellent documentation and support, 
huge community, really easy to get started with. And possibly a bit more 
mature and stable...


Pylons : more loosely coupled (imply: less integration), based on 
"standard" components - which is both a blessing and a curse, specially 
wrt/ documentation -, requires a good knowledge of Python and the HTTP 
protocol to get started with. Very powerful and flexible but this comes 
with a price...


Now both are written by talented programmers, and both are pretty good 
tools. I guess it's more a matter of personal preferences and/or 
external constraints (PHB etc...) than anything else.


A couple other "lightweight" candidates you migh want to consider are 
werkzeug and web.py:


http://werkzeug.pocoo.org/
http://webpy.org/


Database likely to be MySQl


Mmmm If your application is "write-heavy", PostgreSQL might be a 
better choice. Anyway, both Django's ORM and SQLAlchemy work fine with 
MySQL AFAICT.

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


Re: Reverse Iteration Through Integers

2009-10-19 Thread Bearophile
Paul Rubin:

> If you want to peel off digits from an int one by one without string
> conversions, it's easiest to do that in reverse order:
>
>   n = 961
>   digits = []
>   while n > 0:
>     n,d = divmod(n, 10)
>     digits.append(d)
>
> Look up the docs for "divmod" for an explanation of that handy function.
> Now the above gives you a reversed list of digits--what to do with it
> is an exercise for you ;-).  Note that if n=0 then you get the empty list.

I think that with Psyco it's better to avoid divmod().

It's very positive to teach novices to always use tests every time
they write a function, because it makes their programs less buggy and
often allows them to solve the whole programming problem sooner:


def reverse(n):
"""
Reverse the digits of integer n, ignoring trailing zeros.

>>> reverse(12590)
9521
>>> reverse("abc")
Traceback (most recent call last):
  ...
TypeError: unsupported operand type(s) for divmod(): 'str' and
'int'
>>> [reverse(x) for x in (0, 1, -1, 2, -2L, 100L, -100)]
[0, 1, -1, 2, -2L, 1L, -1]
>>> [reverse(x) for x in (125, 1250, 123456789)]
[521, 521, 987654321]
>>> [reverse(x) for x in (0.0, 1.0, -5.3, 125.0, 1.23456e20)]
[0, 1.0, -5.2998, 521.0, 654321.0]
>>> str(reverse(169883903200298309284038223098439430943092816286
** 123))[:35]
'65852401624276201339740994895755844'
"""
# code removed ...

if __name__ == "__main__":
import doctest
doctest.testmod()
print "Doctests done"


Using tests (and a bit later to use a versioning system) is among the
things that have to be taught as soon as possible :-)

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


Re: print()

2009-10-19 Thread Dave Angel

Gabriel Genellina wrote:



but the new str.format() originally suggested by Dave Angel is better:

s = "{0:03.02f}% done".format(100.0-100.0*(size/tot))

(BTW, why 03.02f? The output will always have at least 4 chars, so 03 
doesn't mean anything... Maybe you want {0:06.2f} (three places before 
the decimal point, two after it, filled with 0's on the left)?)


I deliberately gave an example where every specifier was a different 
digit, so I could easily describe what each part did.  It was intended 
to be understood, not copied.


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


Re: Memory deallocation

2009-10-19 Thread Steven D'Aprano
On Mon, 19 Oct 2009 00:30:30 -0700, dheeraj wrote:

> Hi, a program of mine is being terminated by the OS as it uses too much
> memory. I guess this is due to static memory allocation
> 
> I've also tried to use "del" but in vain. Is there any other function
> that performs the above operation and frees the allocated memory??


Python uses a ref-counting garbage collector which automatically frees 
memory when the number of references to each object falls to zero. This 
is automatic and fast, but it is defeated if you store objects in cycles 
(e.g. x refers to y, and y refers to x) or if you put everything in 
globals which never go out of scope.

In addition Python has a separate garbage collect which can detect, and 
break, many cycles. Perhaps you can use the gc module to debug your 
problem?

I would expect in general that Python will fail with a MemoryError 
exception before the operating system terminates the process for using 
too much memory. What are you doing in your program? What version of 
Python are you using and what OS? You need to give more information for 
us to be more helpful.



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


Re: (from stdlib-sig) ctypes or struct from an h file

2009-10-19 Thread Yuvgoog Greenle
Ok I see your point that C is ambiguous concerning compiler
implementation. I think #pragma pack should work out the padding issue
but I'm not sure if the floating point issue is solvable.

I don't have an idea for solving that one...

On Sun, Oct 18, 2009 at 11:14 PM, Erik Max Francis  wrote:
> Yuvgoog Greenle wrote:
>>
>> I'd like to clarify the use case.
>>
>> Lets say you're writing a client and a server, one is in python and
>> the other is C. If these 2 programs need to pass binary information
>> between them (lets say over a socket) there are 2 options, it could be
>> nice if you could only write the struct once (either in python or in
>> C) without any Cython or C extension (for portability and ease of
>> development's sake).
>
> It's not as simple as that.  You have to know the binary format layouts
> (say, for floating point numbers) and struct padding that's used (since it
> can be inserted arbitrarily) on the C side of things, not to mention you
> have to arrange the whole the to be put into consistent (network) byte
> order.  Both sides have to take care of this, since if the server and client
> are running on different architectures, there's no guarantees any of these
> things will be the same.
>
> --
> Erik Max Francis && m...@alcyone.com && http://www.alcyone.com/max/
>  San Jose, CA, USA && 37 18 N 121 57 W && AIM/Y!M/Skype erikmaxfrancis
>  Diplomacy and defense are not substitutes for one another. Either
>   alone would fail. -- John F. Kennedy, 1917-1963
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


smtplib send mail dns resolve problem

2009-10-19 Thread 星星
hello everyone,
 I am using smtplib to send email, and i meet such a problem:

my email smtp server hostname can be parsed to 5 ips, for example:
**
 my email smtp server hostname:  email-my.local.com
 ips through dns parse:
1.1.1.1
1.1.1.12
1.1.13.1
1.1.1.14
1.1.1.15
**

but when i send mail using smtplib, i was always using one ip, no
dns re-resolve happened, (for example: only use 1.1.1.12). I checked
smtplib src code, but i can't find anything strange;

here is my smtplib send mail client code:
 

for i in range(1000):
server = smtplib.SMTP(host)
try:
 server.sendmail(fromaddr, toaddr, msg)
except Exception, e:
 logger.warning('sendmail exception')
else:
 pass
finally:
 server.quit()
time.sleep(0.3)
 


Can anyone give some tips? Thank you!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The rap against "while True:" loops

2009-10-19 Thread Steven D'Aprano
On Mon, 19 Oct 2009 08:51:44 +0200, Hendrik van Rooyen wrote:

> The point I was trying to make
> subliminally, was that there is a relative cost of double lookup for all
> cases versus exceptions for some cases. - Depending on the frequency of
> "some", I would expect a breakeven point.

There is, at least according to my (long distant and only barely 
remembered) tests.

Setting up a try...except is very cheap, about as cheap as a pass 
statement. That is:

d = {1: None}
try:
x = d[1]
except KeyError:
print "This can't happen"


is approximately as costly as:

d = {1: None}
pass
x = d[1]

under Python 2.5. However, catching an exception is more expensive, 
approximately ten times more so. Doing a lookup twice falls somewhere 
between the two, closer to the cheap side than the expensive.

So according to my rough estimates, it is faster to use the try...except 
form so long as the number of KeyErrors is less than about one in six, 
give or take. If KeyError is more common than that, it's cheaper to do a 
test first, say with d.has_key(). Using the `in` operator is likely to be 
faster than has_key(), which will shift the break-even point.

(The above numbers are from memory and should be taken with a large pinch 
of salt. Even if they are accurate for me, they will likely be different 
on other machines, and will depend on the actual keys in the dict. In 
other words, your mileage may vary.)



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


Re: restriction on sum: intentional bug?

2009-10-19 Thread ryles
On Oct 16, 6:53 pm, ryles  wrote:
> Then you probably haven't read through these discussions:
>
> sum and 
> strings:http://mail.python.org/pipermail/python-list/2006-August/subject.html
> summing a bunch of 
> numbers:http://mail.python.org/pipermail/python-dev/2003-April/subj

You meant:

sum and strings:
http://mail.python.org/pipermail/python-list/2006-August/subject.html

summing a bunch of numbers:
http://mail.python.org/pipermail/python-dev/2003-April/subject.html
-- 
http://mail.python.org/mailman/listinfo/python-list


CALL FOR PAPERS: TOOLS EUROPE 2010

2009-10-19 Thread Lorenzo Bettini

==
 CALL FOR PAPERS
  (Deadline: January 22, 2010)

 TOOLS EUROPE 2010
   48th International Conference
Objects, Models, Components, Patterns
Co-located with
   *** International Conference on Model Transformation (ICMT 2010) ***
*** International Conference on Software Composition (SC 2010) ***
 *** International Conference on Tests and Proofs (TAP 2010) ***
  Málaga - Spain, 28 June - 02 July 2010
   http://malaga2010.lcc.uma.es/
==

TOOLS EUROPE is devoted to the combination of technologies that have
emerged as a result of object technology becoming "mainstream". Like its
predecessors, TOOLS EUROPE combines an emphasis on quality with a strong
practical focus.

Started in 1989, TOOLS conferences, held in Europe, the USA, Australia,
China and Eastern Europe, have played a major role in the development of
object technology; many of seminal concepts were first presented at
TOOLS. After an interruption of four years, the conference was revived
in 2007 to reflect the maturing of the field and the new challenges
ahead and has become a yearly event.

Contributions are solicited on all aspects of object technology and
related fields, in particular model-based development, component-based
development, and patterns (design, analysis and other applications);
more generally, any contribution addressing topics in advanced software
technology fall within the scope of TOOLS. Reflecting the practical
emphasis of TOOLS, contributions showcasing applications along with a
sound conceptual contribution are particularly welcome. Topics include:

* Object technology, including programming techniques, languages, tools
* Testing of object-oriented systems
* Patterns, pattern languages, tool support for patterns
* Distributed and concurrent object systems
* Real-time object-oriented programming and design
* Experience reports, including efforts at standardisation
* Applications to safety- and security-related software
* Component-based programming, modelling, tools
* Aspects and aspect-oriented programming and modelling
* Frameworks for component-based development
* Trusted and reliable components
* Model-driven development and Model-Driven Architecture
* Domain specific languages and language design
* Tools and frameworks for supporting model-driven development
* Language implementation techniques, compilers, run-time systems
* Practical applications of program verification and analysis
* Open source solutions & Reproduction studies

All contributions will be subject to a rigorous selection process by the
international Program Committee, with a stress on originality,
practicality and overall quality. The proceedings will be published in
Springer LNBIP. For detailed submission information see the conference
page.

Important Dates:

Papers submission deadline: January 22, 2010
Acceptance notification: March 24, 2010
Camera-ready final copy: April 5, 2010
Conference: June 28 -- July 02, 2010

Conference Chair: Bertrand Meyer, ETH Zürich and Eiffel Software
Program Chair: Jan Vitek, Purdue University
Publicity Chair: Osmar Santos, University of York

Program Committee:

Uwe Assman, University of Dresden, Germany
Elisa Baniassad, Chinese University of Hong Kong, Hong Kong
Alexandre Bergel, University of Chile, Chile
Lorenzo Bettini, University of Torino, Italy
Judith Bishop, University of Pretoria, South Africa
William Cook, University of Texas Austin, USA
Sophia Drossopolou, Imperial College London, UK
Catherine Dubois, ENSIIE, France
Stéphane Ducasse, INRIA Lille, France
Manuel Fahndrich, Microsoft Research, USA
Harald Gall, University of Zurich, Switzerland
Benoit Garbinato, University of Lausanne, Switzerland
Angelo Gargantini, University of Bergamo, Italy
Jeff Gray, University of Alabama Birmingham, USA
Kathryn Gray, University of Cambridge, UK
Thomas Gschwind, IBM Research, Switzerland
Matthias Hauswith, University of  Lugano, Switzerland
Nigel Horspool, University of Victoria, Canada
Tomas Kalibera, Charles University, Czech Republic
Gerti Kappel, Vienna University of Technology, Austria
Doug Lea, State University of New York Oswego, USA
Shane Markstrum, Brucknell University, USA
Peter Müller, ETH Zurich, Switzerland
Oscar Nierstrasz, University of Bern, Switzerland
James Noble, Victoria University of Wellington, New Zealand
Nate Nystrom, University of Texas Arlington, USA
Manuel Oriol, University of York, UK
Jonathan Ostroff, York University, Canada
Richard Paige, University of York, UK
Shaz Qadeer, Microsoft Research, USA
Awais Rashid, Lancaster University, UK
Vivek Sarkar, Rice University, USA
Doug Schmidt, Vanderbilt University, USA
Manuel Serrano, INRIA Sophia Antipolis, France
Peter Thiemann, University of Freib

Re: weekdays in range

2009-10-19 Thread Jive Dadson
I'm using weekdays as a proxy for days when the US stock market is open. 
 (I'll miss holidays.)  The application is pricing CALL and PUT 
options.  Speed is not a problem.  The number of days will typically be 
between 1 and 254.

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


weekdays in range

2009-10-19 Thread Jive Dadson

(Sorry if this shows up twice.)

Can someone think of an easy way to calculate the number of weekdays 
between two calendar dates (in Python)?


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


Memory deallocation

2009-10-19 Thread dheeraj
Hi, a program of mine is being terminated by the OS as it uses too
much memory. I guess this is due to static memory allocation

I've also tried to use "del" but in vain. Is there any other function
that performs the above operation and frees the allocated memory??

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


<    1   2