understanding why there is no setup.py uninstall

2015-07-06 Thread c.buhtz
This question is not technical.
I know that there is no 'uninstall' Option in a setup.py.
I know this discussions and workarounds for that problem, too.


I want to understand the design concept behind it.

Why isn't there no uninstall routine implemented?

For me as a user and admin it feels quite dirty when installing
something with the setup.py but then not being able to remove it clean
like I would do it with packages of my system-package-manager (e.g. with
apt-get on a debianized system).
-- 
https://mail.python.org/mailman/listinfo/python-list


Writing a python editor for blind developers

2015-07-06 Thread germano carella

Hi to all,
I'm new of this list.
I'm Germano from Italy. I'm 39 and I'm a blind developer.
I'm writing a python editor accessible to screen readers, with 
autocompletion support.

So, when I write something, a context menu displays all option I can use.
To do this, I'm using inspect module and pkgutil, and parsing docstring 
of builtin functions 'cause inspect.getargspec doesn't work with builtins.
Now, when I instantiate a class, for example, I'd like to receive option 
on methods when I write name. ...

I tired to use code.InteractiveConsole running in background.
In this way, I can run source code every time I press enter and 
code.InteractiveConsole executes it in background.
The problem is when I'm writing a function: InteractiveConsole executes 
it, but doesn't update her locals since I finish to write the function; 
so I can't retrieve local variables.

There is an other way can you suggest me?
Thanks!
Germano
--
https://mail.python.org/mailman/listinfo/python-list


bottle app "crashes"

2015-07-06 Thread Martin S
Hi all,

Last summer I fumbled together a small appplication that calculates both LASK 
and Elo ratings for chess. I managed to "webify" it using Bottle. This works 
nicely on my laptop for testing.

However ... (you knew there would be a however right)

Once I log off (or my user session times out) my server where I've started the 
application with python3 LASKweb.py & the application dies within a  minute, 
resulting in clients getting 404 errors when accessing the page (a simple 
table that's processed by the application).

I've tried installting bottle deamon but I keep getting errors to the effect 
that it doesn't recognize bottledeamon.
Also I've tried to run as a wsgi application, but I seem to missunderstand 
what modifications I need to do the get it to run (I get server 
misconfiguration errors on the latter).

Do anyone have a pointer to an idiot proof instruction on how to deploy a 
simple bottle application to a live server.

/Martin S
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: understanding why there is no setup.py uninstall

2015-07-06 Thread Chris Angelico
On Sun, Jul 5, 2015 at 7:04 PM,   wrote:
> This question is not technical.
> I know that there is no 'uninstall' Option in a setup.py.
> I know this discussions and workarounds for that problem, too.
> 
>
> I want to understand the design concept behind it.
>
> Why isn't there no uninstall routine implemented?
>
> For me as a user and admin it feels quite dirty when installing
> something with the setup.py but then not being able to remove it clean
> like I would do it with packages of my system-package-manager (e.g. with
> apt-get on a debianized system).

If you want a package manager, don't use setup.py itself - use pip,
which does have an uninstallation feature. Alternatively, use a
virtual environment, which means installations happen there rather
than into the system directory - you can clean it up just by wiping
out one tree.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: understanding why there is no setup.py uninstall

2015-07-06 Thread Chris Warrick
On 5 July 2015 at 11:04,   wrote:
> This question is not technical.
> I know that there is no 'uninstall' Option in a setup.py.
> I know this discussions and workarounds for that problem, too.
> 
>
> I want to understand the design concept behind it.
>
> Why isn't there no uninstall routine implemented?
>
> For me as a user and admin it feels quite dirty when installing
> something with the setup.py but then not being able to remove it clean
> like I would do it with packages of my system-package-manager (e.g. with
> apt-get on a debianized system).
> --
> https://mail.python.org/mailman/listinfo/python-list

Don’t use setup.py, use pip. If you are working with a pypi package,
just use pip install foo. If you have a local package, you can point
pip to a tarball, or to an unpacked directory:

$ pip install foo-0.1.0.tar.gz
$ pip install /home/kwpolska/bar
$ cd baz; pip install .

pip has an uninstall option. (It should also work with packages
installed with plain setup.py.)

-- 
Chris Warrick 
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Bug in floating point multiplication

2015-07-06 Thread Jonas Wielicki
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA512



On 02.07.2015 19:29, Jason Swails wrote:
> // maths.h #include  #include 
> 
> int main() { double x; int i; x = 1-pow(0.5, 53);
> 
> for (i = 1; i < 100; i++) { if ((int)(i*x) == i) { 
> printf("%d\n", i); break; } }
> 
> return 0; }

Does not show the problem on either -m32 or normal on my Fedora 22,
64-bit with any of:

Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz (inside a qemu though, where
it shows "Intel Core Processor (Haswell)")
Intel(R) Core(TM) i5-2450M CPU @ 2.50GHz

Unfortunately, I fried my AMD Bulldozer last week, so I cannot check
there.

regards,
jonas
-BEGIN PGP SIGNATURE-
Version: GnuPG v2

iQIcBAEBCgAGBQJVmjunAAoJEMBiAyWXYliKzDwP+wcCn9AW7EdZ/gHEmw6vW9sL
MFUszpPQ3+HYPLuMn35tAy31GDozCBHze8AISHzL0oWCj6u1x7z4gxY0MKaAsRuh
Gp5R5W+KHpE0tYps65SHUFUxCvf5YSR4vao6PeUMsSNxdCZ5HVa6dPpdYe0wWho4
D+6HV5RT7LCKC4+u1iNrJL3ldBPCH73+0FY0IajC0/w3QDCOpQEUVRKDCQdARq3W
I4FYeU3I3jfUH7694gUgRDECYt16k53G3dU2J5r+ZXmFX6SUWxgL3McXdxpUpGZo
VnPGcvMeWEq1qRxkREphGtgaMz+NxX8im9jp9RZX3KD7uWSecEt4SrQJavLejRWg
vb0i+pe3Df64bT+1in4JxHV6UlEdULA+0/pP+S9OyYzydKDzPBWBuFe23WjsdDJi
sdRrUHCAyAr7sulfOiU92q+/ROgCW+sCD83TNFQdQ/kNsaXioYmW3Rc7jOoWPetN
Uqq6ezZqkfUmichqggZi5ogyDUyfLvfHoe3dpecun95ArTcsZXpVW8kddP3kYANv
3zldmQfTjCzDWc2EPCpRfs9gFn7AaWM9t4jiyIStTQoYId7mHcRbTmb2DwT/XsPY
Ulopha+6PhkGw0ejmbFYx2juvOZlSegTRhHnRe/+9QRtfpyqOFjHB92ai+g3H/g6
NSN8EA+7w3sc8/r31k7O
=7GrS
-END PGP SIGNATURE-
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: understanding why there is no setup.py uninstall

2015-07-06 Thread Mark Lawrence

On 05/07/2015 10:04, [email protected] wrote:

This question is not technical.
I know that there is no 'uninstall' Option in a setup.py.
I know this discussions and workarounds for that problem, too.


I want to understand the design concept behind it.


I haven't the faintest idea, sorry :(



Why isn't there no uninstall routine implemented?

For me as a user and admin it feels quite dirty when installing
something with the setup.py but then not being able to remove it clean
like I would do it with packages of my system-package-manager (e.g. with
apt-get on a debianized system).



pip (un)install xyz suits me fine on Windows, but then I'm a one stop shop.

--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: understanding why there is no setup.py uninstall

2015-07-06 Thread Ben Finney
 writes:

> I want to understand the design concept behind it.
> Why isn't there no uninstall routine implemented?

What form of answer are you looking for?

Will you be disappointed if the answer entails (as I fear it must)
“because no-one put in the sustained effort to make it work”?

If you merely want to know the sequence of events that led to the
situation, you'll need to go digging through the history of Distutils.

If, on the other hand, you are feeling wronged and want someone to take
responsibility and justify their actions:

> For me as a user and admin it feels quite dirty when installing
> something with the setup.py but then not being able to remove it clean
> like I would do it with packages of my system-package-manager (e.g.
> with apt-get on a debianized system).

… then I think you'll find it more productive to realise we *do* have a
better system now.

Part of the better system is that we have the Python Packaging Authority
http://pypa.io/> which didn't exist when Distutils was designed.
Read the documents there and I hope you'll be glad at the improvement!

More specifically, an important part of the better system is that we now
have Pip https://pypi.python.org/pypi/pip/>, which is the PyPA
recommended tool for end-users to install *and* uninstall Python packages.

Hopefully by the time you're done with that, you won't need anyone to
justify their actions to you any more :-)

-- 
 \  “I used to be an airline pilot. I got fired because I kept |
  `\   locking the keys in the plane. They caught me on an 80 foot |
_o__)stepladder with a coathanger.” —Steven Wright |
Ben Finney

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


RE: Writing a python editor for blind developers

2015-07-06 Thread Joseph Lee
Hi Germano and others,
First, sorry for this abrupt post without an intro (I'll write a more proper
intro next time) and a possible repeat message.
Second, as a blind developer and a regular contributor to a Python-based
screen reader, I can say that many of us (blind devs) use IDE's nor
Python-specific editors. For our Python tasks, we use a regular text editor
such as Notepad++, and some had success with Visual Studio Python plug-in
and/or Eclipse. Some people were looking at making IDLE itself accessible to
no avail (the way IDLE displays its output is such that it makes it hard for
screen readers to use their display parsing techniques to tell a programmer
what's on screen). This gets more interesting when blind Pythoneers (such as
myself) write GUI apps such as those using WXPython (NonVisual Desktop
Access, or NVDA, the Python-based screen reader is a WXPython app) and PyQT
(apps powered by QT 5 is accessible).
There exists a list like this for blind Pythoneers at:
http://www.freelists.org/list/pythonvis
For more info on NVDA, go to:
http://www.nvaccess.org
P.S. A very short intro: I'm Joseph, a blind Pythoneer and regular code and
translations contributor to NonVisual Desktop Access (NVDA) screen reader
project. I have studied computer science (no degree) and have been speaking
Python for about three years and spoke C++ prior to joining NVDA project in
2012. In NVDA project, I tend to work mostly on supporting new operating
systems, translations, braille display input/output and touchscreen support.
Cheers,
Josep

-Original Message-
From: Python-list
[mailto:[email protected]] On Behalf
Of germano carella
Sent: Sunday, July 5, 2015 2:56 AM
To: [email protected]
Subject: Writing a python editor for blind developers

Hi to all,
I'm new of this list.
I'm Germano from Italy. I'm 39 and I'm a blind developer.
I'm writing a python editor accessible to screen readers, with
autocompletion support.
So, when I write something, a context menu displays all option I can use.
To do this, I'm using inspect module and pkgutil, and parsing docstring of
builtin functions 'cause inspect.getargspec doesn't work with builtins.
Now, when I instantiate a class, for example, I'd like to receive option on
methods when I write name. ...
I tired to use code.InteractiveConsole running in background.
In this way, I can run source code every time I press enter and
code.InteractiveConsole executes it in background.
The problem is when I'm writing a function: InteractiveConsole executes it,
but doesn't update her locals since I finish to write the function; so I
can't retrieve local variables.
There is an other way can you suggest me?
Thanks!
Germano
--
https://mail.python.org/mailman/listinfo/python-list

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


Re: Writing a python editor for blind developers

2015-07-06 Thread Jacob Kruger

Germano, answering email at top of mail, since think that's the preferred
method for some of us.

I am also a 100% blind developer, and python is also one of my focus areas.

While don't think can really help with this part of development as of yet, I
would be more than willing to help with feedback, etc., and can also put you
in touch with various other blind developers who do also work with python,
etc.

For example, AFAIK, the primary blind programmers mailing list is
[email protected], and besides me, there are a few other python
developers on that list as well.

Stay well


Jacob Kruger
Blind Biker
Skype: BlindZA
"Roger Wilco wants to welcome you...to the space janitor's closet..."

- Original Message - 
From: "germano carella" 

To: 
Sent: Sunday, July 05, 2015 11:55 AM
Subject: Writing a python editor for blind developers



Hi to all,
I'm new of this list.
I'm Germano from Italy. I'm 39 and I'm a blind developer.
I'm writing a python editor accessible to screen readers, with 
autocompletion support.

So, when I write something, a context menu displays all option I can use.
To do this, I'm using inspect module and pkgutil, and parsing docstring of 
builtin functions 'cause inspect.getargspec doesn't work with builtins.
Now, when I instantiate a class, for example, I'd like to receive option 
on methods when I write name. ...

I tired to use code.InteractiveConsole running in background.
In this way, I can run source code every time I press enter and 
code.InteractiveConsole executes it in background.
The problem is when I'm writing a function: InteractiveConsole executes 
it, but doesn't update her locals since I finish to write the function; so 
I can't retrieve local variables.

There is an other way can you suggest me?
Thanks!
Germano
--
https://mail.python.org/mailman/listinfo/python-list



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


Re: requests.Session() how do you set 'replace' on the encoding?

2015-07-06 Thread Veek M
dieter wrote:

> Veek M  writes:
>> UnicodeEncodeError: 'gbk' codec can't encode character u'\xa0' in
>> position 8: illegal multibyte sequence
> 
> You give us very little context.

It's a longish chunk of code: basically, i'm trying to download using the 
'requests.Session' module and that should give me Unicode once it's told 
what encoding is being used 'gbk'.

def get_page(s, url):
print(url)
r = s.get(url, headers = {
  'User-Agent' : user_agent,
  'Keep-Alive' : '3600',
  'Connection' : 'keep-alive',
  })
s.encoding='gbk'
text = r.text
return text

# Open output file
fh=codecs.open('/tmp/out', 'wb')
fh.write(header)

# Download
s = requests.Session()


If 'text' is NOT proper unicode because the server introduced some junk, 
then when i do anchor.getparent() on my 'text' it'll traceback..
ergo the question, how do i set a replacement char within 'requests'

> In general: when you need control over encoding handling because
> deep in a framework an econding causes problems (as apparently in
> your case), you can usually first take the plain text,
> fix any encoding problems and only then pass the fixed text to
> your framework.
> 
>> I'm doing:
>> s = requests.Session()
>> to suck data in, so.. how do i 'replace' chars that fit gbk
> 
> It does not seem that the problem occurs inside the "requests" module.
> Thus, you have a chance to "intercept" the downloaded text
> and fix encoding problems.

Okay, so i should use the 'raw' method in requests and then clean up the 
raw-text and then convert that to unicode.. vs trying to do it using 
'requests'? The thing is 'codec's has a xmlcharrefreplace_errors(...) etc so 
i figured if output has clean up, input ought to have it :p

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


Re: lxml.xpath 'for/xpath' to get to a node and then xpath again within the loop?

2015-07-06 Thread Veek M
Saran Ahluwalia wrote:

> So what did you do to resolve this? Please provide your fix. This is an
> excellent case study for others.
it's provided, what part didn't you understand? Try googling relative-path, 
wth?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: lxml.xpath 'for/xpath' to get to a node and then xpath again within the loop?

2015-07-06 Thread Mark Lawrence

On 06/07/2015 10:40, Veek M wrote:

Saran Ahluwalia wrote:


So what did you do to resolve this? Please provide your fix. This is an
excellent case study for others.

it's provided, what part didn't you understand? Try googling relative-path,
wth?



If it's provided why have you snipped it this time around?  May I most 
humbly suggest that the next time you ask, please ensure that you tell 
us what you've googled for prior to putting your question.


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: (side-)effects and ...

2015-07-06 Thread Laura Creighton
>  And this is the intention of my post: Maybe there is such
>  a term, and I just missed to learn it so far? So,
>  do you know a term for the phenomenon that can be found
>  in Python but not in mathematics and consists in the state
>  of the world influencing the value of an expressions?

In the world of control logic, this sort of thing is needed a
whole lot.  One common way to go after this behaviour (the
temperature of the room determines whether the heater or the air
conditioner goes on, for instance) is to use Fuzzy Control Logic.
https://en.wikipedia.org/wiki/Fuzzy_control_system
https://en.wikipedia.org/wiki/Fuzzy_logic

Python has a bunch of packages for doing this, but I haven't ever used
them, so cannot comment on how good any of them are.

Laura

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


Re: (side-)effects and ...

2015-07-06 Thread Laura Creighton
In a message of 05 Jul 2015 20:29:11 +, Stefan Ram writes:
>  But why do we not have a common and well-known term for
>  the counterpart, that something does not modify the state
>  of the world, but that the state of the world does 
>  influence the value (behaviour) of a call such as
>  »datetime.datetime.now().time()«?

... to continue from the earlier post, I had a phone call and wrapped
it up too soon 

However, fuzzy logic is only one way to get such an effect.
You can get the same using Neural Nets and some sort of learning
algorithm.

https://en.wikipedia.org/wiki/Artificial_neural_network

Or you can try some sort of Genetic algorithm
see: https://en.wikipedia.org/wiki/Genetic_algorithm

These ways to go after the same problem

And we have Python packages for this, too.

The thing is that these things, aside from being suitable for a
whole lot of problems where you really want the outside environment
to influence the result of your code, don't have a lot in
common.  So, among practicioners of these arts -- mostly found
designing AI and control systems -- there doesn't seem to be a
pressing need for a general term that includes any of these.

And, at least in the area of control systems, there is a real problem
with the testing of such things.  They have this unfortunate habit of
producing results that were undreamed of by their creators, which
is not what you want in the control system for your high-speed train --
or especially if you are the insurance underwriters for that same train.
So there is rather more effort spent on going the other way -- writing
code that does the job but which is less and less dependent on outside
factors than in finding ways to include more outside factors in the
code we already have.

Laura


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


Re: Writing a python editor for blind developers

2015-07-06 Thread Oscar Benjamin
Hi Germano,

You may want to use the jedi package which you can find at this link:
https://pypi.python.org/pypi/jedi/

I'm not personally involved with the jedi package but I use it within my
own editor Vim and my understanding is that it should be useful for Python
autocompletion support in any IDE. It uses static analysis to infer the
types of variables e.g. an instance of a class so that it can complete the
methods for that class.

--
Oscar

On Mon, 6 Jul 2015 at 09:22 germano carella 
wrote:

> Hi to all,
> I'm new of this list.
> I'm Germano from Italy. I'm 39 and I'm a blind developer.
> I'm writing a python editor accessible to screen readers, with
> autocompletion support.
> So, when I write something, a context menu displays all option I can use.
> To do this, I'm using inspect module and pkgutil, and parsing docstring
> of builtin functions 'cause inspect.getargspec doesn't work with builtins.
> Now, when I instantiate a class, for example, I'd like to receive option
> on methods when I write name. ...
> I tired to use code.InteractiveConsole running in background.
> In this way, I can run source code every time I press enter and
> code.InteractiveConsole executes it in background.
> The problem is when I'm writing a function: InteractiveConsole executes
> it, but doesn't update her locals since I finish to write the function;
> so I can't retrieve local variables.
> There is an other way can you suggest me?
> Thanks!
> Germano
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Bug in floating point multiplication

2015-07-06 Thread Oscar Benjamin
On Sat, 4 Jul 2015 at 02:12 Jason Swails  wrote:

> On Fri, Jul 3, 2015 at 11:13 AM, Oscar Benjamin <
> [email protected]> wrote:
>
>> On 2 July 2015 at 18:29, Jason Swails  wrote:
>>
>> Where is the 32 bit one looks like:
>>
>> $ objdump -d a.out.32 | less
>> ...
>
>  804843e:  fildl  -0x14(%ebp)
>>  8048441:  fmull  -0x10(%ebp)
>>  8048444:  fnstcw -0x1a(%ebp)
>>  8048447:  movzwl -0x1a(%ebp),%eax
>>  804844b:  mov$0xc,%ah
>>  804844d:  mov%ax,-0x1c(%ebp)
>>  8048451:  fldcw  -0x1c(%ebp)
>>  8048454:  fistpl -0x20(%ebp)
>>  8048457:  fldcw  -0x1a(%ebp)
>>  804845a:  mov-0x20(%ebp),%eax
>>  804845d:  cmp-0x14(%ebp),%eax
>>  8048460:  jne8048477 
>>  8048462:  sub$0x8,%esp
>>  8048465:  pushl  -0x14(%ebp)
>>  8048468:  push   $0x8048520
>>  804846d:  call   80482f0 
>>  8048472:  add$0x10,%esp
>>  8048475:  jmp8048484 
>>  8048477:  addl   $0x1,-0x14(%ebp)
>>  804847b:  cmpl   $0xf423f,-0x14(%ebp)
>>  8048482:  jle804843e 
>> ...
>>
>> So the 64 bit one is using SSE instructions and the 32-bit one is
>> using x87. That could explain the difference you see at the C level
>> but I don't see it on this CPU (/proc/cpuinfo says Intel(R) Core(TM)
>> i5-3427U CPU @ 1.80GHz).
>>
>
> ​Hmm.  Well that could explain why you don't get the same results as me.
> My CPU is a
> AMD FX(tm)-6100 Six-Core Processor
> ​ (from /proc/cpuinfo).  My objdump looks the same as yours for the 64-bit
> version, but for 32-bit it looks like:
>

So if we have different generated machine instructions it suggests a
difference in the way it was compiled rather than in the hardware itself.
(Although it could be that the compilers were changed because the hardware
was inconsistent in this particular usage).


> However, I have no experience looking at raw assembler, so I can't discern
> what it is I'm even looking at (nor do I know what explicit SSE
> instructions look like in assembler).
>

The give away is that SSE instructions use the XMM registers so where you
see %xmm0 etc data is being loaded ready for SSE instructions. I'll
translate the important part of the 32 bit code below:

...
 804843a:   db 44 24 14 fildl  0x14(%esp)
​​


FILDL - F is for float and indicates that this is an x87 instruction. LD is
for load and indicates that we want to load from memory to the x87 register
stack. The I is for integer: we're loading from int format. I can't
remember what the L suffix means.

This instruction will load the integer from the memory stack at offset 0x14
from the stack pointer (esp) pushing it onto the x87 stack. Since the x87
stack uses 80-bit extended-real precision format internally this
instruction performs a format conversion. The conversion should be lossless
as 80-bit FP uses a 64 bit mantissa so it should be able to represent any
64-bit signed or unsigned integer (we're only using 32 bits in this
example).

​ 804843e:   dc 4c 24 18 fmull  0x18(%esp)

FMULL (x87 multiply) - This multiplies the top of the x87 stack (the number
we previously stored) by the 64 bit float at 0x18 stack offset. In context
that's the number 1-.5**53 which was presumably calculated earlier. The top
of the x87 stack is overwritten with the result. This calculation is
performed using 80-bit floating point with a 64 bit mantissa.

​ 8048442:   dd 5c 24 08 fstpl  0x8(%esp)

FSTPL (x87 store and pop) - Pop the top of the x87 stack pushing to the
memory stack. This is storing the result of the multiplication back to RAM
(0x8 from stack) as a 64 bit float. Since it was internally stored as an
80-bit float there is a format conversion here that can lose precision.
Rounding can occur according to the settings in the x87 control word.

​ 8048446:   f2 0f 2c 44 24 08   cvttsd2si 0x8(%esp),%eax

This converts the 64 bit float stored at 0x8 from stack to a signed int,
truncating if inexact, and stores the result in register eax. This
operation is guaranteed to truncate (rather than floor etc) if it needs to
round.

​ 804844c:   3b 44 24 14 cmp0x14(%esp),%eax

This compares the result of the above processing (now stored in eax) with
the int we started with (still at offset 0x14 from stack). The cmp
instruction sets flags ready for the jne instruction below.

​ 8048450:   75 16   jne8048468 

JNE (jump if not equal) - this is the branching instruction. If the
previously compared values are unequal we skip forward to 8048468 otherwise
we execute the instructions below which call printf and jmp (break) out of
the loop.

​ 8048452:   8b 44 24 14 mov0x14(%esp),%eax
​ 8048456:   89 44 24 04 mov%eax,0x4(%esp)
​ 804845a:   c7 04 24 10 85 04 08movl   $0x8048510,(%esp)
​ 8048461:   e8 8a fe ff ff  call   80482f0 
​ 8048466:   eb 0f   jmp8048477 

This is where the jne goes. We increment the int and jump (jle) back to the
top of the loop (unless the loo

Re: (side-)effects and ...

2015-07-06 Thread Tim Chase
On 2015-07-06 00:44, Robert Kern wrote:
>> I believe the term is "idempotent"
> 
> No, "idempotent" means that if it changes the state, then applying
> it twice or more has the same effect as applying it once.

Ah, thanks for the clarification.

-tkc



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


Best practices for writing jobs run through cron

2015-07-06 Thread webuser1200
I needed help/advice with a few things:

1. Is there a good example of a well written command line task that gets run 
routinely from the shell. Job would handle logging and be able to redirect 
stdout to a stdout file and stderr to a stderr file. 

2. I was going to setup a dict with all jobs and a unique identifier for each 
job. Then I would use the filesystem to capture output form each job. Jobs 
output would be redirected to _mmddhhmmss_start.stdout and 
_mmddhhmmss_end.stderr

3. Each script would know it's job id and would load the setup dict at start 
time and see if it still needs to be run or not. If not and it is still trying 
to run, and error would be sent. 

4. A web interface would look at the file system and generate a list of job 
runs and show errors etc.

5. A task would run end of the week which archive old runs of jobs by moving 
directories over to an archive folder. 

I'd like to lean towards simplicity...

Are there other examples that I should be looking at? Any thoughts on the above 
setup?

Regards,

WU
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Bug in floating point multiplication

2015-07-06 Thread Jason Swails
On Mon, Jul 6, 2015 at 11:44 AM, Oscar Benjamin 
wrote:

> On Sat, 4 Jul 2015 at 02:12 Jason Swails  wrote:
>
>> On Fri, Jul 3, 2015 at 11:13 AM, Oscar Benjamin <
>> [email protected]> wrote:
>>
>>> On 2 July 2015 at 18:29, Jason Swails  wrote:
>>>
>>> Where is the 32 bit one looks like:
>>>
>>> $ objdump -d a.out.32 | less
>>> ...
>>>
>>  804843e:  fildl  -0x14(%ebp)
>>>  8048441:  fmull  -0x10(%ebp)
>>>  8048444:  fnstcw -0x1a(%ebp)
>>>  8048447:  movzwl -0x1a(%ebp),%eax
>>>  804844b:  mov$0xc,%ah
>>>  804844d:  mov%ax,-0x1c(%ebp)
>>>  8048451:  fldcw  -0x1c(%ebp)
>>>  8048454:  fistpl -0x20(%ebp)
>>>  8048457:  fldcw  -0x1a(%ebp)
>>>  804845a:  mov-0x20(%ebp),%eax
>>>  804845d:  cmp-0x14(%ebp),%eax
>>>  8048460:  jne8048477 
>>>  8048462:  sub$0x8,%esp
>>>  8048465:  pushl  -0x14(%ebp)
>>>  8048468:  push   $0x8048520
>>>  804846d:  call   80482f0 
>>>  8048472:  add$0x10,%esp
>>>  8048475:  jmp8048484 
>>>  8048477:  addl   $0x1,-0x14(%ebp)
>>>  804847b:  cmpl   $0xf423f,-0x14(%ebp)
>>>  8048482:  jle804843e 
>>> ...
>>>
>>> So the 64 bit one is using SSE instructions and the 32-bit one is
>>> using x87. That could explain the difference you see at the C level
>>> but I don't see it on this CPU (/proc/cpuinfo says Intel(R) Core(TM)
>>> i5-3427U CPU @ 1.80GHz).
>>>
>>
>> ​Hmm.  Well that could explain why you don't get the same results as me.
>> My CPU is a
>> AMD FX(tm)-6100 Six-Core Processor
>> ​ (from /proc/cpuinfo).  My objdump looks the same as yours for the
>> 64-bit version, but for 32-bit it looks like:
>>
>
> So if we have different generated machine instructions it suggests a
> difference in the way it was compiled rather than in the hardware itself.
> (Although it could be that the compilers were changed because the hardware
> was inconsistent in this particular usage).
>

​I had assumed that the different compilations resulted from different
underlying hardware (i.e., the instructions used on the Intel chip were
either unavailable, or somehow deemed heuristically inferior on the AMD
chip).​

>
>
>> However, I have no experience looking at raw assembler, so I can't
>> discern what it is I'm even looking at (nor do I know what explicit SSE
>> instructions look like in assembler).
>>
>
> The give away is that SSE instructions use the XMM registers so where you
> see %xmm0 etc data is being loaded ready for SSE instructions. I'll
> translate the important part of the 32 bit code below:
>

​Oh of course.  I *have* seen/worked with code that uses routines from
xmmintrin.h, so I should've been able to piece the xmm together with the
SSE instructions.
​

> [
> ​snip]​
> This means that the x87 register will be storing a higher precision result
> in its 80 bit format. This result will have to be rounded by the FSTPL
> instruction.
>
> If you look at the assembly output I showed you'll see the instructions
> FNSTCW/FLDCW (x87 store/load control word) which are used to manipulate the
> control word to tell the FPU how to perform this kind of rounding. The fact
> that we don't see it in your compiled output could indicate a C compiler
> bug which could in turn explain the different behaviour people see from
> Python.
>
> To understand exactly why 2049 is the number where it fails consider that
> it is the smallest integer that requires 12 bits of mantissa in floating
> point format. The number 1-.5**53 has a mantissa that is 53 ones:
>
> >>> x = 1-.5**53
> >>> x.hex()
> '0x1.fp-1'
>
> When extended to 80 bit real-extended format with a 64 bit mantissa it
> will have 11 trailing zeros. So I think multiplication of x with any
> integer less than 2049 can be performed exactly by the FMULL instruction. I
> haven't fully considered what impact that would have but it seems
> reasonable that this is why 2049 is the first number that fails.
>

​Wow.  Great discussion and description -- I'm convinced.​

Thanks a lot,
Jason
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: (side-)effects and ...

2015-07-06 Thread Ethan Furman

On 07/05/2015 01:29 PM, Stefan Ram wrote:


   The function »datetime.datetime.now().time()« does not yield
   a value that is determined by the expression »time()«;
   instead its value can /differ/ between two calls even when the
   call »time()« does not differ. In mathematics, however, a
   call to a function that is given by a term such as »cos( 0 )«
   always has the /same/ value.


The input to time() is the result of datetime.datetime.now(); is it 
datetime.datetime.now() that is being influenced by the world.

--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list


Re: Best practices for writing jobs run through cron

2015-07-06 Thread Juan Gutierrez
Hi WU,

It sounds like you want to add a lot of helpful transparency into your task 
runner which is awesome, however, have you taken a look at Celery?

http://celery.readthedocs.org/en/latest/userguide/periodic-tasks.html

Celery also comes with a monitoring tool (Flower - 
http://celery.readthedocs.org/en/latest/userguide/monitoring.html?highlight=flower#flower-real-time-celery-web-monitor)

This may satisfy what you're looking for without having to write your own 
management and monitoring system.

Hope this helps!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Searching for a usable X509 implementation

2015-07-06 Thread Johannes Bauer
On 05.07.2015 07:33, Laura Creighton wrote:

> For an RSA key in PEM format you can do:
> from OpenSSL.crypto import _new_mem_buf, _lib, _bio_to_string
> 
> def dump_rsa_public_key(pkey):
> bio = _new_mem_buf()
> result = _lib.PEM_write_bio_RSAPublicKey(bio, 
> _lib.EVP_PKEY_get1_RSA(pkey._
> pkey))
> # if result == 0: ERROR!  Figure out what you want to do here ...
> return _bio_to_string(bio)

Oh, hacky :-)

> The original version of PyOpenSSL was written by Martin Sjögren, when
> he was working for me, and we had no need for such a thing at the time,
> since we just saved full certificates.  You are right that it is very
> odd that nobody else has needed them since then, and this probably
> should be added to PyOpenSSL.

Sadly my impression is that pyOpenSSL development is slow at best. I've
had an issue with it a while back and was missing some feature which
someone else had already suggested. It kindof was some back and forth in
their bugtracker and then all discussion died.

IIRC (and my memory may be wrong) it was about the ability to check
signatures of one certificate against a well-defined truststore
(especially against only one to identify parent certificates by crypto).
I was frustrated back then about the indecisiveness and wrote my own
wrapper around the functions I needed and was done with it.

Best regards,
Johannes

-- 
>> Wo hattest Du das Beben nochmal GENAU vorhergesagt?
> Zumindest nicht öffentlich!
Ah, der neueste und bis heute genialste Streich unsere großen
Kosmologen: Die Geheim-Vorhersage.
 - Karl Kaos über Rüdiger Thomas in dsa 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: bottle app "crashes"

2015-07-06 Thread mm0fmf via Python-list

On 05/07/2015 17:45, Martin S wrote:

Hi all,

Last summer I fumbled together a small appplication that calculates both LASK
and Elo ratings for chess. I managed to "webify" it using Bottle. This works
nicely on my laptop for testing.



[snip]



Do anyone have a pointer to an idiot proof instruction on how to deploy a
simple bottle application to a live server.

/Martin S



I use bottle as it comes to provide 2 apps that face straight onto the 
web. I have to say that I have only done half the job because I never 
got as far as daemonising them. I simply run them from a "screen" 
session. This is fine as they run on my own teeny-tiny Linux VM (256MB 
ram/5GB disk with 1 Xeon core).


I simply log in and type "screen python3 myapp.py" and remember to exit 
with ctrl-A D. One of them has been up for about 3 months now without issue.


That might not explain why you are seeing problems but could give you a 
solution that works whilst you fix the underlying issue. Or not in my case!


Andy

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


Re: bottle app "crashes"

2015-07-06 Thread m
W dniu 06.07.2015 o 21:28, mm0fmf pisze:
> On 05/07/2015 17:45, Martin S wrote:
>> > Hi all,
>> >
>> > Last summer I fumbled together a small appplication that calculates both 
>> > LASK
>> > and Elo ratings for chess. I managed to "webify" it using Bottle. This 
>> > works
>> > nicely on my laptop for testing.
>> >
> [snip]
> 
>> >
>> > Do anyone have a pointer to an idiot proof instruction on how to deploy a
>> > simple bottle application to a live server.
>> >
>> > /Martin S
>> >
> I use bottle as it comes to provide 2 apps that face straight onto the 
> web. I have to say that I have only done half the job because I never 
> got as far as daemonising them. I simply run them from a "screen" 
> session. This is fine as they run on my own teeny-tiny Linux VM (256MB 
> ram/5GB disk with 1 Xeon core).
> 
> I simply log in and type "screen python3 myapp.py" and remember to exit 
> with ctrl-A D. 

I would suggest using supervisor.

p. m.
-- 
https://mail.python.org/mailman/listinfo/python-list


Fast capture and 2D image stacking as 3D numpy array with Python and Raspberry Pi

2015-07-06 Thread Agustin Cruz
I'm working on a Python - Raspberry Pi project in which I need to take about 30 
images per second (no movie) and stack each 2D image to a 3D array using numpy 
array, without saving each 2D capture as a file (because is slow).

I found this Python code to take images as fast as possible, but i don't know 
how to stack all images fast to a 3D stack of images.

import io
import time
import picamera
#from PIL import Image

def outputs():
stream = io.BytesIO()
for i in range(40):
# This returns the stream for the camera to capture to
yield stream
# Once the capture is complete, the loop continues here
# (read up on generator functions in Python to understand
# the yield statement). Here you could do some processing
# on the image...
#stream.seek(0)
#img = Image.open(stream)
# Finally, reset the stream for the next capture
stream.seek(0)
stream.truncate()

with picamera.PiCamera() as camera:
camera.resolution = (640, 480)
camera.framerate = 80
time.sleep(2)
start = time.time()
camera.capture_sequence(outputs(), 'jpeg', use_video_port=True)
finish = time.time()
print('Captured 40 images at %.2ffps' % (40 / (finish - start)))

Does anyone of you know how to stack the 2D images taken in this code to a 3D 
numpy array using Python and the Raspberry Pi camera module? Without saving 
each 2D capture as a file

Best regards, Agustín
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Fast capture and 2D image stacking as 3D numpy array with Python and Raspberry Pi

2015-07-06 Thread Mark Lawrence

On 06/07/2015 22:31, Agustin Cruz wrote:

I'm working on a Python - Raspberry Pi project in which I need to take about 30 
images per second (no movie) and stack each 2D image to a 3D array using numpy 
array, without saving each 2D capture as a file (because is slow).

I found this Python code to take images as fast as possible, but i don't know 
how to stack all images fast to a 3D stack of images.

import io
import time
import picamera
#from PIL import Image

def outputs():
 stream = io.BytesIO()
 for i in range(40):
 # This returns the stream for the camera to capture to
 yield stream
 # Once the capture is complete, the loop continues here
 # (read up on generator functions in Python to understand
 # the yield statement). Here you could do some processing
 # on the image...
 #stream.seek(0)
 #img = Image.open(stream)
 # Finally, reset the stream for the next capture
 stream.seek(0)
 stream.truncate()

with picamera.PiCamera() as camera:
 camera.resolution = (640, 480)
 camera.framerate = 80
 time.sleep(2)
 start = time.time()
 camera.capture_sequence(outputs(), 'jpeg', use_video_port=True)
 finish = time.time()
 print('Captured 40 images at %.2ffps' % (40 / (finish - start)))

Does anyone of you know how to stack the 2D images taken in this code to a 3D 
numpy array using Python and the Raspberry Pi camera module? Without saving 
each 2D capture as a file

Best regards, Agustín



http://docs.scipy.org/doc/numpy/reference/generated/numpy.dstack.html is 
the first hit on google for "numpy 3d array stack".


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: Fast capture and 2D image stacking as 3D numpy array with Python and Raspberry Pi

2015-07-06 Thread Agustin Cruz
On Monday, July 6, 2015 at 6:00:42 PM UTC-4, Mark Lawrence wrote:
> On 06/07/2015 22:31, Agustin Cruz wrote:
> > I'm working on a Python - Raspberry Pi project in which I need to take 
> > about 30 images per second (no movie) and stack each 2D image to a 3D array 
> > using numpy array, without saving each 2D capture as a file (because is 
> > slow).
> >
> > I found this Python code to take images as fast as possible, but i don't 
> > know how to stack all images fast to a 3D stack of images.
> >
> > import io
> > import time
> > import picamera
> > #from PIL import Image
> >
> > def outputs():
> >  stream = io.BytesIO()
> >  for i in range(40):
> >  # This returns the stream for the camera to capture to
> >  yield stream
> >  # Once the capture is complete, the loop continues here
> >  # (read up on generator functions in Python to understand
> >  # the yield statement). Here you could do some processing
> >  # on the image...
> >  #stream.seek(0)
> >  #img = Image.open(stream)
> >  # Finally, reset the stream for the next capture
> >  stream.seek(0)
> >  stream.truncate()
> >
> > with picamera.PiCamera() as camera:
> >  camera.resolution = (640, 480)
> >  camera.framerate = 80
> >  time.sleep(2)
> >  start = time.time()
> >  camera.capture_sequence(outputs(), 'jpeg', use_video_port=True)
> >  finish = time.time()
> >  print('Captured 40 images at %.2ffps' % (40 / (finish - start)))
> >
> > Does anyone of you know how to stack the 2D images taken in this code to a 
> > 3D numpy array using Python and the Raspberry Pi camera module? Without 
> > saving each 2D capture as a file
> >
> > Best regards, Agustín
> >
> 
> http://docs.scipy.org/doc/numpy/reference/generated/numpy.dstack.html is 
> the first hit on google for "numpy 3d array stack".
> 
> -- 
> My fellow Pythonistas, ask not what our language can do for you, ask
> what you can do for our language.
> 
> Mark Lawrence

Hi Mark,
I know the dstack function can do the job, but i don't know how to implement it 
in this case.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Writing a python editor for blind developers

2015-07-06 Thread Terry Reedy

On 7/6/2015 4:42 AM, Joseph Lee wrote:

Some people were looking at making IDLE itself accessible to
no avail (the way IDLE displays its output is such that it makes it hard for
screen readers to use their display parsing techniques to tell a programmer
what's on screen).


Idle itself is not the issue.  It (currently) displays output (and gets 
input) by calling tkinter wrapper functions that interface to the 
cross-platform tcl/tk gui framework. I believe that just about 
everything written to tk can be read back by other functions.


If there is an accessibility module written in Python, I imagine that an 
alternate tkinter-based backend could be written. I imagine that the 
reader could then be incorporated into a tkinter app with an import and 
startup call.  I would be willing to help with the tkinter part of such 
a backend, and test with Idle.



--
Terry Jan Reedy

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


Trying to import numpy

2015-07-06 Thread ryguy7272
I'm trying to use numpy.  I get this error:
>>> import numpy as np

Traceback (most recent call last):
  File "", line 1, in 
import numpy as np
ImportError: No module named numpy



I followed the instructions here.
https://pip.pypa.io/en/latest/installing.html


In the c-prompt, I get this error.
C:\>python get-pip.py
python: can't open file 'get-pip.py': [Errno 2] No such file or directory


In python 2.7, I get this error.
>>> python get-pip.py
SyntaxError: invalid syntax


I would say 100% of my errors come from importing python modules.  If this 
every worked, I could do some real work.  Instead, I spend 100% of my time 
trying to make thing that don't work, work.  


I've already added ';C:\Python27' to the Path under Variable Name.  Of course, 
this makes no difference whatsoever.  Ugh.

Any thoughts?  Anyone?
Thanks.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: bottle app "crashes"

2015-07-06 Thread Jason Friedman
> Last summer I fumbled together a small appplication that calculates both LASK
> and Elo ratings for chess. I managed to "webify" it using Bottle. This works
> nicely on my laptop for testing.
>
> Once I log off (or my user session times out) my server where I've started the
> application with python3 LASKweb.py & the application dies within a  minute,
> resulting in clients getting 404 errors when accessing the page (a simple
> table that's processed by the application).

Similar to other answers here, I do not know why your application
stops serving, but I have had success using waitress
(https://pypi.python.org/pypi/waitress) with bottle
(http://bottlepy.org/docs/dev/deployment.html#switching-the-server-backend).
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Trying to import numpy

2015-07-06 Thread Michael Torrie
On 07/06/2015 09:17 PM, ryguy7272 wrote:
> I followed the instructions here.
> https://pip.pypa.io/en/latest/installing.html
> 
> 
> In the c-prompt, I get this error.
> C:\>python get-pip.py
> python: can't open file 'get-pip.py': [Errno 2] No such file or directory

Is get-pip.py located in c:\?  You have to specify the path to the
location where you saved get-pip.py:

C:\>python \path\to\get-pip.py

Where \path\to is the path of where ever you placed the downloaded file.
 You did download get-pip.py, right?  It's not clear from your post.

I can safely say that importing modules works very well for most people.
 I assume you mean that you have errors trying to download and install
third-party modules.  Hopefully we can get you over this hurdle.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Trying to import numpy

2015-07-06 Thread Chris Angelico
On Tue, Jul 7, 2015 at 1:17 PM, ryguy7272  wrote:
> I would say 100% of my errors come from importing python modules.  If this 
> every worked, I could do some real work.  Instead, I spend 100% of my time 
> trying to make thing that don't work, work.
>

I could equally say that 100% of your errors come from working on
Windows, and that if you were on a different OS, you could do some
real work. Or I could probably point out that 100% of your errors come
from using the internet, and that if you had a completely stand-alone
system, you could do some real work. You're blaming importing on
circumstantial evidence here, and that's not exactly fair.

Start by making sure you have Python 2.7.9 or better (and yes, 3.4
counts as "better"). It should come with pip already installed.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: requests.Session() how do you set 'replace' on the encoding?

2015-07-06 Thread dieter
Veek M  writes:

> dieter wrote:
>
>> Veek M  writes:
>>> UnicodeEncodeError: 'gbk' codec can't encode character u'\xa0' in
>>> position 8: illegal multibyte sequence
>> 
>> You give us very little context.
>
> It's a longish chunk of code: basically, i'm trying to download using the 
> 'requests.Session' module and that should give me Unicode once it's told 
> what encoding is being used 'gbk'.
>
> def get_page(s, url):
> print(url)
> r = s.get(url, headers = {
>   'User-Agent' : user_agent,
>   'Keep-Alive' : '3600',
>   'Connection' : 'keep-alive',
>   })
> s.encoding='gbk'

It looks strange that you can set "s.encoding" after you have
called "s.get" - but, as you apparently get an error related to
the "gbk" encoding, it seems to work.

> text = r.text
> return text
>
> # Open output file
> fh=codecs.open('/tmp/out', 'wb')
> fh.write(header)
>
> # Download
> s = requests.Session()
> 
>
> If 'text' is NOT proper unicode because the server introduced some junk, 
> then when i do anchor.getparent() on my 'text' it'll traceback..
> ergo the question, how do i set a replacement char within 'requests'

I see the following options for you:

  *  you look at the code (of "requests.Session"),
 determine where the "s.encoding" is taken care of and
 look around whether there it also support a replacement strategy.
 Then, you use this knowledge to set up your replacement.

  *  you avoid the "unicode" translating functionality of
 "requests.Session". If it does not immediately supports this,
 you can trick it using the "iso-8859-1" encoding (this maps
 bytes to the first 256 unicode codepoints in a one-to-one way)
 and then do the unicode handling in your own code -- with
 facilities you already know of (including replacement)

  *  you contact the website administrator and ask him why
 the delivered pages do not contain valid "gbk" content.

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


Why pay DICE When TheGongzuo.com is !! FREE !!

2015-07-06 Thread trentonwesley10
Greetings!
You been Invited as a Beta User for TheGongzuo.com ( Absolutely Extended Trial).
We bring to you TheGongzuo.com, Top notch highly talented IT (Information 
Technology / Software Industry) skilled Professional Candidates, where you can 
find more than a resume.

For a NO COST TRIAL all you have to do is:
*   Register & Post  only 1 Active Job.
*   Start interacting with more 100,000 IT professionals and 
Innovators/Ideators.

Before you get started , there are few things you should know,
1.   We are getting better  :- We will be updating our site with new 
material daily basis and we welcome your feedback on newly added material. 
Please send us your feedback by using Feedback option on the site or send us an 
email @ [email protected].
2.   We like Criticism   :-  As a fresh site, We are sure you can find lots 
to Criticize - remember , though we would prefer constructive criticism, so we 
can make site better. Please send us your valuable criticism by email @ 
[email protected].


 
Please make us a part of your distribution list,
We will start sending resumes to you.
If you do not wish to be a part of our mailing list just reply to us with 
unsubscribe from this list or else it will consider it as your consent to be 
part of our distribution list.


Thanks for trying TheGongzuo.com and please let us know , What you think !

Thanks,
TheGongzuo.com Team !

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


Re: Fast capture and 2D image stacking as 3D numpy array with Python and Raspberry Pi

2015-07-06 Thread Mark Lawrence

On 07/07/2015 00:16, Agustin Cruz wrote:

On Monday, July 6, 2015 at 6:00:42 PM UTC-4, Mark Lawrence wrote:

On 06/07/2015 22:31, Agustin Cruz wrote:

I'm working on a Python - Raspberry Pi project in which I need to take about 30 
images per second (no movie) and stack each 2D image to a 3D array using numpy 
array, without saving each 2D capture as a file (because is slow).

I found this Python code to take images as fast as possible, but i don't know 
how to stack all images fast to a 3D stack of images.

import io
import time
import picamera
#from PIL import Image

def outputs():
  stream = io.BytesIO()
  for i in range(40):
  # This returns the stream for the camera to capture to
  yield stream
  # Once the capture is complete, the loop continues here
  # (read up on generator functions in Python to understand
  # the yield statement). Here you could do some processing
  # on the image...
  #stream.seek(0)
  #img = Image.open(stream)
  # Finally, reset the stream for the next capture
  stream.seek(0)
  stream.truncate()

with picamera.PiCamera() as camera:
  camera.resolution = (640, 480)
  camera.framerate = 80
  time.sleep(2)
  start = time.time()
  camera.capture_sequence(outputs(), 'jpeg', use_video_port=True)
  finish = time.time()
  print('Captured 40 images at %.2ffps' % (40 / (finish - start)))

Does anyone of you know how to stack the 2D images taken in this code to a 3D 
numpy array using Python and the Raspberry Pi camera module? Without saving 
each 2D capture as a file

Best regards, Agustín



http://docs.scipy.org/doc/numpy/reference/generated/numpy.dstack.html is
the first hit on google for "numpy 3d array stack".

--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence


Hi Mark,
I know the dstack function can do the job, but i don't know how to implement it 
in this case.



Sadly I don't know how either, but if I can find the above link in 
seconds, I'm fairly certain that with a little searching you could find 
something.  Specific sites like nullege or koders might offer solutions.


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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