Hello all
I've a program that launches a lot of threads and each of them
launches a os.system("my_command").
My program also keeps a list of the launched threads, so I can make
"for" loops on the threads.
My aim is to kill everything with ctrl-C (KeyboardInterrupt).
Of course I tr
Le 31/01/2012 17:04, Dennis Lee Bieber a écrit :
Of course, if that thread is stuck waiting for a call to os.system()
to complete, then it can not do anything...
os.system() is a rather limited, restrictive, call -- best used for
quick one-of operations. If running Python 2.
Here is my question: I would like to start an in-house library of small
modules to import, for things like error handling/logging. That's easy
enough, but is there a recommended way of naming such modules? I am
concerned about avoiding name clashes with standard modules and site
packages.
Thank
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
Il 20/03/2012 12:21, Ben Finney ha scritto:
"prince.pangeni" writes:
I am doing a simulation project using Python. In my project, I want
to use some short of distribution to generate requests to a server.
I guess scipy is also available in plain python (didn't check), but the
following
Seems you miss understood my notion of dynamic string.
Dynamic strings are expressions in disguise: the things
in between $...$ are plain old expressions (with optional
formatting specifications). They are evaluated
as if they were outside the dynamic string. We put them
in there to to kill two
Le 09/06/2011 04:18, Sérgio Monteiro Basto a écrit :
> hi,
> cat test.py
> #!/usr/bin/env python
> #-*- coding: utf-8 -*-
> u = u'moçambique'
> print u.encode("utf-8")
> print u
>
> chmod +x test.py
> ../test.py
> moçambique
> moçambique
The following tries to encode before to print. If you pass
Le 09/06/2011 04:18, Sérgio Monteiro Basto a écrit :
> hi,
> cat test.py
> #!/usr/bin/env python
> #-*- coding: utf-8 -*-
> u = u'moçambique'
> print u.encode("utf-8")
> print u
>
> chmod +x test.py
> ../test.py
> moçambique
> moçambique
The following tries to encode before to print. If you pass
Le 09/06/2011 04:18, Sérgio Monteiro Basto a écrit :
> hi,
> cat test.py
> #!/usr/bin/env python
> #-*- coding: utf-8 -*-
> u = u'moçambique'
> print u.encode("utf-8")
> print u
>
> chmod +x test.py
> ../test.py
> moçambique
> moçambique
The following tries to encode before to print. If you pass
So, I suppose I shall have to let go of my dreams of
--> Path('/some/path/and/file') == '\\some\\path\\and\\file'
and settle for
--> Path('...') == Path('...')
but I don't have to like it. :(
Why not define the hash method to first convert to '/some/path/and/file'
and then hash ?
By
Le 19/06/2011 15:41, candide a écrit :
With Python 2.7 :
>>> x="foo"
>>> print '"'+x+'"'
"foo"
>>>
What is this curious syntax on line 2 ? Where is it documented ?
When you want to have an explicit double quote " in a string, you put in
between single quote '.
(and vice versa)
So
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
Popping task off the end of the list is more efficient:
while task_list:
task_list.pop().start()
That's cool. In my case it's better to do
task_list.pop(0).start
in order to pop the first element.
or if the list is static
No, my list is dynamic and is feeded by an other thread (whi
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(task)
Now I want, in some circumstance to raise errors that make the loop stop.
In order IOError to make stop the loop
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/pytho
You might try writing the boolean function is_prime(n) for almost any n.
There was a recent discussion on this topic.
Since the guy is "new in programming", I complete the answer, just in
case. Using the function is_prime(n),
FIRST POSSIBILITY :
new_list=[]
for n in old_list:
if is_pr
But if the function itself runs for longer than 10 seconds, there
will be a major problem, as the sleep apparently takes the argument as
unsigned, and a negative number is a very big sleep!
Launch each call in a separate thread. If the calls are independent,
this could be a solution.
Le 15/03/2011 09:10, yqyq22 a écrit :
Hi all,
I would like to put an alphanumeric string like this one
EE472A86441AF2E629DE360 in a list, then iterate inside the entire
string lenght and change each digit with a random digit.
Do u have some suggestion? thanks a lot
This can be a way to begin :
string = "EE472B"
t = []
for x in string[:]:
print t.append("A") #i don't want to append A, the final
result is EAEA4A7A2ABA
As it, it prints "None" 6 times. Then t is ['A','A','A','A','A']
What you have to do is to read about basic python. Search for python
tutorial on the net.
string = "EE472B"
t = []
for x in string[:]:
print t.append("A") #i don't want to append A, the final
result is EAEA4A7A2ABA
As it, it prints "None" 6 times. Then t is ['A','A','A','A','A']
What you have to do is to read about basic python. Search for python
tutorial on the net.
file_list = []
for root, _, filenames in os.walk(root_path):
for filename in filenames:
file_list.append(os.path.join(root, filename))
What does the notation "_" stands for ? Is it a sort of /dev/null ?
I know that in the terminal it represents the last printed text.
Laurent
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
One of us thought it could be set and dictionaries not always yielding
the same results. I, however, would think that given the exact same
operations, a set/dictionary would always yield the same results. Am I
correct? Or could different runs of the same program yield different
results due to, s
Le 08/04/2011 14:47, Gilles Ganault a écrit :
Hello,
Before I go ahead and learn how to write this, I was wondering if
someone knew of some source code I could use to download and rename a
bunch of files, ie. the equivalent of wget's -O switch?
I would provide a two-column list where co
Le 11/05/2011 01:57, James Mills a écrit :
> On Wed, May 11, 2011 at 9:00 AM, Dan Stromberg
wrote:
>>
>> What are your favorite backup programs written, in whole or in part, in
>> Python?
My favorite one is the one I wrote myself for myself ;)
The point I like :
1. the backup is a simple co
In this case, the interpretation of an arbitrary object as a boolean
is peculiar for python. An empty list is a real, existing object, and
the supposition that [] be false is counter-intuitive. It can be
learnt, and the shorthand may be powerful when it is, but it will
confuse many readers.
On
I believe you are grossly oversimplifying whatever code you had. Using
the definition of f from above:
theta = math.pi/4
f(math.cos(2*theta))
6.12303176911e-17
Yes: its oversimplifued. The angle come from a normal vector of a curve
and so on In particular, I was using Sage; the compu
I believe you are grossly oversimplifying whatever code you had. Using
the definition of f from above:
theta = math.pi/4
f(math.cos(2*theta))
6.12303176911e-17
Yes: its oversimplifued. The angle come from a normal vector of a curve
and so on In particular, I was using Sage; the compu
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.
Laurent
--
http://mail.python.o
I guess it requires some kind of image processing , where you can move around
image pixel
by pixel and somehow figure out what color is present in that pixel .
If there isn’t much noise in the image you should sharp contrast and would
be able to differentiate between two colors ? if yes ( I don
Le 29/05/2011 23:42, Ben Finney a écrit :
Peter Pearson writes:
Python works in terms of objects having names, and one
object can have many names.
Or no names. So it's less accurate (though better than talking of
“variables”) to speak of Python objects “having names”.
Could you give an e
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 between "5" and
".__add__" ?
Why does
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
Le 29/09/2011 18:27, John Gordon a écrit :
In Subhabrata
Banerjee writes:
(i) I have a file of lists. Now, the first digit starts with a number
or index, like,
[001, "Obama", "USA", "President"]
[002 "Major", "UK", "PM"]
[003 "Singh", "INDIA", "PM"]
What about creating a dictiona
Hello
Is it possible to count the number of time a function is called ?
Of course, if I've access to the source code, it's easy.
I tried the following :
def foo():
print "foo !"
class wraper(object):
def __init__(self,fun):
globals()[fun]=self.replacement
def replac
The keys of globals() are the _names_. You're giving it the function
itself.
Ow, ok. I didn't caught it. I understand now.
> A decorator would be better.
Yes. I keep the solution with
foo=Wraper(foo)
Thanks a lot all !
Laurent
--
http://mail.python.org/mailman/listinfo/python-list
Hi all
This is well known :
>>> 1/2
0
This is because the division is an "integer division".
My question is : how can I evaluate 1/2 to 0.5 ? Is there some non
integer division operator ?
Up to now I workarounded writing float(1)/2. Is there an other way ?
My Zen of python says :
There sho
Wohaw. This means that this behavior is going to be default in a
foreseeable future ?
It's the default in 3.x. I can't imagine it ever being the default in 2.x.
2.7 is now in "bug-fix only" mode, so no new features, and there won't be a
2.8, so true division will never be the default in
You should get in touch with the Sage developers. In the Sage FAQ they
say that "until SciPy is ported to run with Python 3.x and Cython
supports Python 3.x, Sage will continue to use Python 2.x."
``scipy.weave``."
So according to the Sage FAQ there is no reason why Sage shouldn't
support Pyt
Woops. This was aimed to the french speaking python's usenet. Sorry.
Laurent
Le 28/10/2011 11:29, Laurent a écrit :
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 es
Le 07/11/2011 18:12, JoeM a écrit :
Howdy,
If I have a few lists like
a=[1,2,3,4,5]
b=["one", "two", "three", "four", "five"]
c=["cat", "dog", "parrot", "clam", "ferret"]
what is the most pythonic method of removing the first element from
all of the lists?
Do you want to remove the first ite
Le 07/11/2011 19:01, JoeM a écrit :
Thanks guys, I was just looking for a one line solution instead of a
for loop if possible. Why do you consider
[x.remove(x[0]) for x in [a,b,c]]
cheating? It seems compact and elegant enough for me.
I have the feeling that it does not do what I expect it do
Le 24/11/2011 13:31, Rudra Banerjee a écrit :
Dear friends,
I am a newbie in python and basically i use python for postprocessing
like plotting, data manipulation etc.
Based on ease of programming on python I am wondering if I can consider
it for the main development as well. My jobs (written on
for x in y
However, what does "for" and "in" mean in this context?
It means basically the same as in Englsish
Does the following links answer the question ?
http://www.ibiblio.org/g2swap/byteofpython/read/for-loop.html
http://dsnra.jpl.nasa.gov/software/Python/diveintopython.pdf (page 58)
H
Le 11/01/2012 12:19, mike a écrit :
Hi,
We are running are running Python program on Redhat 5.5.
When executing our program we get the following error ( see below).
Any ideas what this is due to?
On my computer hashlib has "md5" :
Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56)
[GCC 4.4.
Hi all.
I just put online a first version of two tools that combine LaTeX and
python.
The first one, phystricks[1], is a python module intended to generate
pstricks code. The main features are
* you don't have to know pstricks (but you need to have some basics in
python)
* you have python instead
54 matches
Mail list logo