Hi Folks,
I was arguing with a guy who was sure that incrementing a variable i with "i +=
1" is faster than "i = i + 1". I couldn't tell if he was right or wrong so I
did a little benchmark with the very useful timeit module.
Here are the results on my little Linux Eeepc Netbook (using Python 3.
Well I agree with you about string concatenation, but here I'm talking about
integers incrementation...
--
http://mail.python.org/mailman/listinfo/python-list
Thanks for these explanations. So 2% speed difference just between "B..." and
"I..." entries in a huge alphabetically-ordered switch case? Wow. Maybe there
is some material for speed enhancement here...
--
http://mail.python.org/mailman/listinfo/python-list
Well 2% more time after 1 million iterations so you're right I won't consider
it.
--
http://mail.python.org/mailman/listinfo/python-list
Actually 6% between float themselves is just as not-understandable.
--
http://mail.python.org/mailman/listinfo/python-list
> With 64 bit 3.2.2 on my Win 7 Pentium, the difference was 4% and with
> floats (0.0 and 1.0), 6%
For floats it is understandable. But for integers, seriously, 4% is a lot. I
would never have thought an interpreter would have differences like this in
syntax for something as fundamental as add
I did the test several times with floats on my machine and the difference is
not as big as for integers:
==> "i = i + 1.0" is 0.732% faster than "i += 1.0".
It seems normal as the float addition is supposed to be slower than integer
addition, thus the syntaxic difference is comparatively less
Hi there,
What is the simplest way to check that you are at the beginning or at the end
of an iterable? I'm using enumerate with Python 3.2 (see below) but I'm
wondering if there would be a better way.
l = ['a', 'b', 'a', 'c']
for pos, i in enumerate(l):
if pos == 0:
print("head =
I totally understand the performance issue that an hypothetical "istail" would
bring, even if I think it would just be the programmer's responsibility not to
use it when it's not certain that an end can be detected.
But I don't see why *adding* something like "ishead" would be so bad (at worse
Yes of course the use of a boolean variable is obvious but I'm mixing python
code with html using Mako templates. In Mako for code readability reasons I try
to stick to simple "for" and "if" constructions, and I try to avoid variables
declarations inside the html, that's all. Thanks anyway.
--
add__(6)
^
SyntaxError: invalid syntax
while
>>> a=5
>>> a.__add__(6)
11
Very well. I learned something today.
Thanks
Laurent
--
http://mail.python.org/mailman/listinfo/python-list
I need that MyApp_AppEvents class knows the
thread object to call a thread function when the event occurs(for
example I need to toggle a flag)
I've got no idea how to do that!
Anyone has encoutered the problem?
I've tryied to use getevents but with no result...
Help!
Best regards,
Laurent
Falc wrote:
> Hi there...
>
> I have been looking at learning Python, so far it looks like an
> absolutely grat language. I am having trouble finding some free
> resources to learn Python from. I am on windows and the only experience
> I have with programming is with PHP.
>
> I have been trying t
hello,
I follow somes projects that have a pythonic way to make web site.
there's thats projects :
http://www.cherrypy.org/
and
http://subway.python-hosting.com/
subway aim to be like ruby on rails frameworks , simple and fast
developpment. It uses cherrypy and other project like :
*
nd produce some files : python.zip (for
python higher 2.3) and python.dll and other dll for application that
needs some dynamic python's extension.
regards,
Laurent
--
http://mail.python.org/mailman/listinfo/python-list
Yes, I was just hoping for something already included that I wouldn't know (i'm
new to Python).
--
http://mail.python.org/mailman/listinfo/python-list
Interesting. I will check that yield functionality out. Thanks.
--
http://mail.python.org/mailman/listinfo/python-list
> I don't think this question is meaningful. There are basically two
> fundamental types of iterables, sequences and iterators.
>
> Sequences have random access and a length, so if the "start" and "end" of
> the sequence is important to you, just use indexing:
>
> beginning = sequence[0]
> end =
Neat. But I can see some "print(x)" and some "print x". What is the Python
version?
--
http://mail.python.org/mailman/listinfo/python-list
[troll]
For a serious web based MMO you'd rather stick to low level and forget about
bloated Object Relational Mapping java-like layered kind of frameworks that are
made for Rapid Applications Development, not for efficiency.
[/troll]
"Eve Online", a well known MMORPG was developped with stackle
Well PyPy is just an implementation of Python among many others (but limited to
version 2.7). It is not a web server. If you want to make PyPy interact with a
web server (such as nginx) you have to use a special protocol such as WSGI or
Fast-CGI. For best performances you can for instance use uW
+1 for PostgreSQL. It's faster than MySQL for years now, and is much more
seriously featured.
If you don't need ACID properties (transactions stuff) you should also give
Document-based databases like MongoDB a try. It changed my code life.
--
http://mail.python.org/mailman/listinfo/python-list
Include from __future__ import division on the top of your file
from __future__ import division
1/2
0.5
Wohaw. This means that this behavior is going to be default in a
foreseeable future ?
Thanks
Laurent
--
http://mail.python.org/mailman/listinfo/python-list
Le 28/10/2011 10:43, ll.snark a écrit :
On 27 oct, 17:06, Laurent Claessens wrote:
> J'aimerais donc pouvoir indiquer dans fonca, que la variable lst est
> celle définie dans fonc1.
> Je ne veux pas d'une variable locale à fonca, ni une variable globale
> à tout m
Hi. I couldn't find a way to overwrite a property declared using a decorator in
a parent class. I can only do this if I use the "classic" property() method
along with a getter function. Here's an example:
#!/usr/bin/python3
class Polite:
def __init__(self):
self._greeting = "He
Yes using a separate class variable would transfer the problem to the class
level. But adding 10 class variables if I have 10 properties would be ugly.
Maybe I should reformulate the subject of this thread to "is there some python
magic to pass parameters to decorator-declared properties ?"
--
Hey yes it's working that way. But I don't like it very much either. If as OKB
said the whole point is that outside functions can't detect a property then I'm
going to stick with the non-decorator way. Thanks anyway.
--
http://mail.python.org/mailman/listinfo/python-list
I do not understand why he is talking me about 'str', no str given!!!
I have this:
-
def to_float(elt):
if type(elt) is list:
return map(to_float, elt)
else:
return float(elt)
def Denombrement(A,b,c,type):
.
.
.
A = to_float(A)
b
Hi,
here is the context:
I'm coding a openGL API I will need for a project for my school.
This API is quite simple:
an ooglScene describe all needed to make an openGL, and inherits from a
list. So an ooglScene is fundamentaly a list of ooglObjects (which is
organised as a Composite Pattern).
oo
Here are my codes:
it doesn't use threading...!
#
# test_pyoogl.py
#
#!/usr/bin/env python
from pyoogl import *
import unittest
class test(unittest.TestCase):
def testWind
That is exactly what I do not want!!
this is not transparent, I'm sure it is possible to make what I want:
Scene = ooglScene()
Scene.run()
scene.append(ooglPoint())
--
http://mail.python.org/mailman/listinfo/python-list
This is not a fantasm...
Why this can not work??
in a thread a loop (the glut main loop) called by Scene.run()
and in a second something else, e.g. function A
A want to add an object in the Scene, the it call
Scene.append(anObject)
and in his next step, the glutmainloop will see that there is a
threading.Thread(target = Scene.run).start() WORKS !!!
great thx ;)
now this should be better if the thread can ben declared inside the
class!
--
http://mail.python.org/mailman/listinfo/python-list
Youpe!
That work as I want
Thx everybody ;)
The problem was that I launched the glut main loop into a thread, and
then it was separated from his initialisations functions
I put it into another method and launch that method into a thread...!
That work!
--
http
> each error. (Before "integrated" development environments)
This is a + for compiled environments that you effectively cannot have with
Python, non-syntaxic errors found at runtime.
A+
Laurent.
--
Laurent POINTAL - laurent.poin...@laposte.net
--
http://mail.python.org/mailman/listinfo/python-list
ould appreciate it ever so much, Dave:)
Note: if you develop such a tool, make it a "Web Out Of Browser" module.
http://weboob.org/
--
Laurent POINTAL - laurent.poin...@laposte.net
--
http://mail.python.org/mailman/listinfo/python-list
>
> plus you could add some error-handling code.
To have a shell / python script interaction for cwd management, you can take
a look at autojump
https://github.com/joelthelion/autojump/wiki
Its a Python script + different shells glue.
A+
Laurent.
--
Laurent POINTAL - laurent
Hi,
I'm impletting a tool in Python.
I'd like this tool to behave like a standard unix tool, as grep for exemple.
I chose to use the argparse module to parse the command line and I think I'm
getting into several limitations of this module.
> First Question.
How can I configure the the ArgumentPa
Le Jul 27, 2012 à 4:43 PM, Oscar Benjamin a écrit :
>
>
> On 27 July 2012 15:26, Benoist Laurent wrote:
> Hi,
>
> I'm impletting a tool in Python.
> I'd like this tool to behave like a standard unix tool, as grep for exemple.
> I chose to use the argparse mo
Yes basically looks like you get it.
I have to further test it but my first impression is that it's correct.
So actually the point was to use nargs="?".
Thank you very much.
Ben
Le Jul 27, 2012 à 5:44 PM, Peter Otten a écrit :
> Benoist Laurent wrote:
>
>> I
2
bar.txt:42
$ cat foo.txt | grep 42
42
$ grep -c 42 foo.txt
1
Cheers,
Ben
Le Jul 27, 2012 à 7:08 PM, Benoist Laurent a écrit :
>
>
> Yes basically looks like you get it.
> I have to further test it but my first impression is that it's correct.
>
> So actually t
else:
for fname in args.fname:
with(open(fname, "rt")) as f:
content = f.read()
# do somet
Benoist
Le Jul 31, 2012 à 11:55 AM, Oscar Benjamin a écrit :
>
> On Jul 31, 2012 10:32 AM, "Benoist Laurent" wrote:
&
d choice: '10' (choose from 'foo',
'bar')
Any solution?
Cheers,
Ben
Le Jul 31, 2012 à 12:37 PM, Benoist Laurent a écrit :
> Really sorry about that.
>
> So, for the community, below is the full code for a tool that behaves like a
> Unix standard tool
Le Jul 31, 2012 à 1:45 PM, Oscar Benjamin a écrit :
>
>
> On 31 July 2012 12:03, Benoist Laurent wrote:
> Finally.
>
> The code I proposed doesn't work in this case: if you add any positional
> argument to one of the subparsers, then the parsing doesn't work
rks that way.
I'll do this way.
Thank a lot.
Ben
Le Jul 31, 2012 à 3:04 PM, Oscar Benjamin a écrit :
>
>
> On 31 July 2012 13:51, Benoist Laurent wrote:
>
> Le Jul 31, 2012 à 1:45 PM, Oscar Benjamin a écrit :
>
>>
>>
>> On 31 July 2012 12:03, Benoist L
photo on top of
his name and room number).
http://www.reportlab.com/software/opensource/
Once created the pdf, you must find a solution to send it to the printer...
>
> Thanks in advance,
>
> Martha
A+
Laurent.
--
http://mail.python.org/mailman/listinfo/python-list
t were called by os.system() ?
My aim is of course to write an ultimate log file containing the status
of the program when KeyboardInterupt was raised. (if not, the unix
command "kill" does the job ;) )
Thanks for any help
have a good day
Laurent
--
http://mail.python.org/mailman/listinfo/python-list
2.6+, I'd recommend
converting from os.system() to subprocess.Popen(). .Popen() objects now
have .terminate() and .kill() methods.
Ok, I'll try that Popen. Indeed I think that my threads are stuck
waiting os.system to complete.
Thanks
Laurent
--
http://mail.python.org/mailman/listi
kages.
Thanks.
This is not 100% an answer to the question, but you should read that :
http://www.python.org/dev/peps/pep-0008/
This explain you WhatCaseToChoose for_naming youVariables.
Laurent
--
http://mail.python.org/mailman/listinfo/python-list
This is not 100% an answer to the question, but you should read that :
http://www.python.org/dev/peps/pep-0008/
The OP mentions PEP 8 in the bit of his message that you *don't* quote.
Well... I've to sleep. Sorry :(
Laurent
--
http://mail.python.org/mailman/listinfo/python-list
te(x)
sys.stdout=MyStdOut()
... well ... a part of the fact that it is much longer ?
Laurent Claessens
--
http://mail.python.org/mailman/listinfo/python-list
for information.|
--
sage: from scipy import stats
sage: X=stats.poisson.rvs
sage: X(4)
5
sage: X(4)
2
sage: X(4)
3
Hope it helps
Laurent
--
http://mail.python.org/mailman/listinfo/python-list
ot;.format(b['name'],b['job'])
In the case in which b is an object having "job" and "name" attribute,
the dynamic string will write
"$b.name$ works as $b.job$"
instead of
"{0}.name works as {0}.job".format(b)
Laurent
--
http://mail.python.org/mailman/listinfo/python-list
ata)
if dataput.sent(timeout=1.0):
print "Data has been sent."
else:
print "Data hasn't been sent within one second."
--
Laurent POINTAL - laurent.poin...@laposte.net
3 allée des Orangers - 91940 Les Ulis - France
Tél. 01 69 29 06 59
--
http://mail.python.org/mailman/listinfo/python-list
title,qstack):
> if choice[0] == None:
> print ("No entries made")
> break
>
>
> print("CHOICE IS: ",choice). CHOICE IS:
> ('', 'ksals', '', '',
Hello,
I started a first translation of my document originally in french. Could
some fluent english people read it and indicate errors or bad english
expressions.
http://perso.limsi.fr/pointal/python:memento
Thanks.
A+
Laurent.
--
Laurent POINTAL - laurent.poin...@laposte.net
--
http
Paul Rubin wrote:
> Laurent Pointal writes:
>> I started a first translation of my document originally in french. Could
>> some fluent english people read it and indicate errors or bad english
>> expressions.
>>
>> http://perso.limsi.fr/pointal/python:memento
Paul Rubin wrote:
> Laurent Pointal writes:
>>> There are a few other things like that, and I'll try to look more
>>> carefully tonight, I can't spend more time on it right now.
>> I updated the document into 1.0.5a (and fix some other errors).
>
> A f
Ulrich Eckhardt wrote:
> Am 05.06.2012 19:32, schrieb Laurent Pointal:
>> I started a first translation of my document originally in french. Could
>> some fluent english people read it and indicate errors or bad english
>> expressions.
>
> Just one note up front: Lan
should think about add stderr to the class MyPrint
If you know French, I strongly recommend "Comprendre les erreurs
unicode" by Victor Stinner :
http://dl.afpy.org/pycon-fr-09/Comprendre_les_erreurs_unicode.pdf
Have a nice day
Laurent
--
http://mail.python.org/mailman/listinfo/python-list
should think about add stderr to the class MyPrint
If you know French, I strongly recommend "Comprendre les erreurs
unicode" by Victor Stinner :
http://dl.afpy.org/pycon-fr-09/Comprendre_les_erreurs_unicode.pdf
Have a nice day
Laurent
--
http://mail.python.org/mailman/listinfo/python-list
should think about add stderr to the class MyPrint
If you know French, I strongly recommend "Comprendre les erreurs
unicode" by Victor Stinner :
http://dl.afpy.org/pycon-fr-09/Comprendre_les_erreurs_unicode.pdf
Have a nice day
Laurent
--
http://mail.python.org/mailman/listinfo/python-list
rst convert to '/some/path/and/file'
and then hash ?
By the way it remains some problems with
/some/another/../path/and/file
which should also be the same.
Laurent
--
http://mail.python.org/mailman/listinfo/python-list
uote " in a string, you put in
between single quote '.
(and vice versa)
So here you have the string
'"'
which is "
then
+x
(add x)
then
+'"'
Try also
>>> print "'"
'
>>> print "'"
"
Laurent
--
http://mail.python.org/mailman/listinfo/python-list
Le 19/06/2011 17:19, Chris Angelico a écrit :
On Mon, Jun 20, 2011 at 12:42 AM, Laurent Claessens wrote:
Hello
I've a list of tasks to perform. Each of them is a threading.Thread.
Basically I have :
while task_list :
task = task_list[0]
task.run()
task_list.remove
Le 19/06/2011 18:03, Chris Angelico a écrit :
On Mon, Jun 20, 2011 at 1:39 AM, Laurent Claessens wrote:
My problem is that when FileToCopyTask raises an error, the program does not
stop.
In fact when the error is Disk Full, I want to stop the whole program
because I know that the next task
e.
Thanks all
Laurent
--
http://mail.python.org/mailman/listinfo/python-list
to be included in a loop, but I
can make them raise personnal exceptions.
How can I do ?
Thanks
Laurent
--
http://mail.python.org/mailman/listinfo/python-list
I read the library documentation. I think that if I get a trick to kill
a thread, then I'm done.
Is there a way ?
Laurent
Le 19/06/2011 17:39, Laurent Claessens a écrit :
Le 19/06/2011 17:19, Chris Angelico a écrit :
On Mon, Jun 20, 2011 at 12:42 AM, Laurent Claessens
Le 23/06/2011 11:48, mahantesh varavattekar a écrit :
Hi,
i am new to python please help to let me know the syntax for python
3.2. with examples.
and how can i use these things for ranges
http://lmgtfy.com/?q=python+syntax+range+example
Laurent
--
http://mail.python.org/mailman/listinfo
ist:
if is_prime(n):
new_list.append(n)
SECOND POSSIBILITY :
new_list=[ n for n in old_list if is_prime(n) ]
There is a primiality test in Sage which is basically a module over
python (www.sagemath.org).
Have a good WE
Laurent
--
http://mail.python.org/mailman/listinfo/python-list
.
Laurent
--
http://mail.python.org/mailman/listinfo/python-list
I made Python my language of choice because of its readability and simpleness,
and not because of its speed. But it's always good to know what is the fastest
sometimes when you don't want to write a module in C. So I was just wondering
if there was a difference. There is, of a few percent. Anywa
k (most recent call last):
File "", line 1, in
UnicodeEncodeError: 'utf-8' codec can't encode character '\udce8' in
position 3: surrogates not allowed
Thanks,
Laurent
--
http://mail.python.org/mailman/listinfo/python-list
ogateescape parameter and which should not.. I guess I could
reencode them all and it wouldn't cause any problems?
Laurent
On Mon, 28 Feb 2011 02:12:20 +, MRAB wrote:
On 28/02/2011 01:31, Laurent Duchesne wrote:
Hi,
I'm using python 3.2 and got the following err
if a is a number and append something else in that case.
Depending what you want, you can even do
s.replace("1","ONE").replace("2","TWO").replace("3","FIVE")
This is however far from being random ;)
Have good tests
Laurent
--
http://mail.python.org/mailman/listinfo/python-list
you have to do is to read about basic python. Search for python
tutorial on the net.
Then try the following exercices :
Exercises
1
print the first 1000 intergers
2
print the sine of 1 ... 1000
3
print the intergers x between 1 and 1000 such that cos(x) is between 0
and 0.5
Have a good afternoon
Laurent
--
http://mail.python.org/mailman/listinfo/python-list
you have to do is to read about basic python. Search for python
tutorial on the net.
Then try the following exercices :
Exercises
1
print the first 1000 intergers
2
print the sine of 1 ... 1000
3
print the intergers x between 1 and 1000 such that cos(x) is between 0
and 0.5
Have a good afternoon
Laurent
--
http://mail.python.org/mailman/listinfo/python-list
inted text.
Laurent
--
http://mail.python.org/mailman/listinfo/python-list
And I'm willing to bet that there are plenty of
scripts out there that use "dec" as a name for Decimal objects.
You won. I owe you a beer ;)
Laurent
--
http://mail.python.org/mailman/listinfo/python-list
shell :
sage: p=plot(x**2,-1,1)
sage: p.get_minmax_data()
{'xmin': -1.0, 'ymin': 1.2545281288559271e-05, 'ymax': 1.0, 'xmax': 1.0}
Hope it helps
Laurent
[1] www.sagemath.org
--
http://mail.python.org/mailman/listinfo/python-list
r way.
Laurent
--
http://mail.python.org/mailman/listinfo/python-list
On Apr 16, 5:20 am, Alec Taylor wrote:
> Good Afternoon,
>
> I'm looking for an IDE which offers syntax-highlighting,
> code-completion, tabs, an embedded interpreter and which is portable
> (for running from USB on Windows).
>
> Here's a mockup of the app I'm looking for:http://i52.tinypic.com/2u
1. time. One backup takes between 10 minutes and one hour. I don't
really care.
2. space. Since my backup is a copy (and copy of copies), my backup
directory takes ~150Go
while my home is about 25 Go.
Hope it answer your question.
Have a nice day
Laurent
--
http://mail.python.org/mailman/listinfo/python-list
e no
value". I spent a while to figure out the problem :)
Conclusion: the boolean value of an object is to be used with care in
order to tests if an optional parameter is given or not (when default
value is None).
Have a good noon
Laurent
--
http://mail.python.org/mailman/listinfo/python-list
object being None.
It was my conclusion too ;)
Laurent
--
http://mail.python.org/mailman/listinfo/python-list
object being None.
It was my conclusion too ;)
Laurent
--
http://mail.python.org/mailman/listinfo/python-list
Yes, I want to extract the data that is contained in an image file.
Greets
Maybe ask to imagemagick's or matplotlib. They should know if it is
possible at all.
Good luck.
Laurent
--
http://mail.python.org/mailman/listinfo/python-list
Yes, I want to extract the data that is contained in an image file.
Greets
Maybe ask to imagemagick's or matplotlib. They should know if it is
possible at all.
Good luck.
Laurent
--
http://mail.python.org/mailman/listinfo/python-list
Yes, I want to extract the data that is contained in an image file.
Greets
Maybe ask to imagemagick's or matplotlib. They should know if it is
possible at all.
Good luck.
Laurent
--
http://mail.python.org/mailman/listinfo/python-list
Yes, I want to extract the data that is contained in an image file.
Greets
Maybe ask to imagemagick's or matplotlib. They should know if it is
possible at all.
Good luck.
Laurent
--
http://mail.python.org/mailman/listinfo/python-list
Yes, I want to extract the data that is contained in an image file.
Greets
Basti
> Yes, I want to extract the data that is contained in an image file.
> Greets
Maybe ask to imagemagick's or matplotlib. They should know if it is
possible at all.
Good luck.
Lauren
don’t know matlab
>might provide some tools .. just guessing ) then its easy i think to
pick (X,Y) as time and value ?
You made me think that in addition to ask to imagemagick's and
matplotlib, one can also as to Sage[1]
In order of pythonicity :
- matplotlib
- sage
- imagemagick
ve an example of an object that has no name ? I've missed
something ...
Laurent
--
http://mail.python.org/mailman/listinfo/python-list
Le 30/05/2011 11:02, Terry Reedy a écrit :
On 5/30/2011 3:38 AM, Laurent wrote:
Cool. I was thinking that "5" was the name, but
>>> 5.__add__(6)
File "", line 1
5.__add__(6)
Try 5 .__add__(6)
What is the rationale behind the fact to add a space betwe
What is the rationale behind the fact to add a space between "5" and
".__add__" ?
Why does it work ?
It's a hint for the tokenizer.
I didn't know the tokenizer. Now I understand.
Thanks
Laurent
--
http://mail.python.org/mailman/listinfo/python-list
What is the rationale behind the fact to add a space between "5" and
".__add__" ?
Why does it work ?
It's a hint for the tokenizer.
I didn't know the tokenizer. Now I understand.
Thanks
Laurent
--
http://mail.python.org/mailman/listinfo/python-list
Hello,
The Python 3 Sheet Cheat (Mémento Bases Python 3) has been
translated into german by StR Martin Putzlocher. Thanks to him.
It can be downloaded on the same page as english and french
versions: https://perso.limsi.fr/pointal/python:memento
A+
L.Pointal.
--
https://mail.python.org/mailman
Hi,
I updated the cheat sheet on the aesthetic side. Parts bloc and their
title are now more easily identified with colors (but its nice with B&W
printing too).
French and german versions have also been updated.
See https://perso.limsi.fr/pointal/python:memento
A+
L.Pointal.
--
https://mail.p
Brython (http://www.brython.info/)
(ok, its translated into JavaScript for execution in the web browser… maybe
somedays it will be asmsjs)
A+
Laurent.
--
https://mail.python.org/mailman/listinfo/python-list
1 - 100 of 406 matches
Mail list logo