Re: Exception handling for socket.error in Python 3.5/RStudio

2016-02-05 Thread Bernardo Sulzbach

On 02/05/2016 07:26 PM, shaunak.bang...@gmail.com wrote:


from _ssl import RAND_status, RAND_egd, RAND_add
ImportError: cannot import name 'RAND_egd'



I believe I've already seen this issue myself. It has to do with 
LibreSSL not having RAND_egd for some reason I can't recall.


This seems to be the related ticket https://bugs.python.org/issue21356

On 02/05/2016 07:26 PM, shaunak.bang...@gmail.com wrote:
> I am new to coding and this code has been borrowed from an online
> source but I can see same code working on mac+Rstudio+python combo.

Are you sure that the Python you talk about is 3.5?
--
https://mail.python.org/mailman/listinfo/python-list


Re: realtime output and csv files

2016-02-05 Thread Joel Goldstick
On Fri, Feb 5, 2016 at 4:13 PM, Bernardo Sulzbach  wrote:

> On 02/05/2016 07:09 PM, lucan wrote:
>
>>
>> What do you mean? What is "datas"? What do you mean by "correct"?
>>>
>>
>> "datas" I mean the values for example temperature = 20.4 (so they are
>> floating point)
>>
>> Index time temp
>> 1 10:24 20.4
>> 2 10:25 20.6
>> ...
>>
>> I wonder if this is correct "my way" to write a csv file:
>>
>> file.write('\n'+str(index))
>> f.write(str(index)+','+str(now.hour)+':'+str(now.minute)+','+str(temp))
>>
>
You might want to do this:

f.write("%d, %2d:%2d, %.1f" % (index, now.hour, now.minute, temp))

In my test:

>>> print("%d, %2d:%2d, %.1f" % (1,10,24,20.4))
1, 10:24, 20.4

This uses the original python formatting method.  There is a newer one as
well

>
>> Or if there is a better way to do that.
>>
>>
> If you got your newlines and headers (if the other program requires it)
> right, this should be all you need.
> --
> https://mail.python.org/mailman/listinfo/python-list
>



-- 
Joel Goldstick
http://joelgoldstick.com/stats/birthdays
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: realtime output and csv files

2016-02-05 Thread Bernardo Sulzbach

On 02/05/2016 07:43 PM, Joel Goldstick wrote:

print("%d, %2d:%2d, %.1f" % (1,10,24,20.4))

1, 10:24, 20.4


Let us be more careful there. Although CSV has no formal specification 
(according to the IETF), *those spaces are not good*.


It is **very unlikely** that they will cause issues, but 1,10:24,20.4 is 
*safer* and - to my eyes - better CSV.


I wouldn't be surprised if a parser treated a value as text only because 
it has spaces on it.


For OP, if you are going for this, I - personally - suggest sticking to 
"%d,%2d:%2d,%.1f".

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


Re: Exception handling for socket.error in Python 3.5/RStudio

2016-02-05 Thread shaunak . bangale
On Friday, February 5, 2016 at 12:58:37 PM UTC-7, shaunak...@gmail.com wrote:
> I am running this python script on R-studio. I have Python 3.5 installed on 
> my system.
> 
> count = 10
> while (count > 0):
> try :
> # read line from file:
> print(file.readline())
> # parse
> parse_json(file.readline())
> count = count - 1
> except socket.error as e
> print('Connection fail', e)
> print(traceback.format_exc())
> 
> # wait for user input to end
> # input("\n Press Enter to exit...");
> # close the SSLSocket, will also close the underlying socket
> ssl_sock.close()
> The error I am getting is here:
> 
> line 53 except socket.error as e ^ SyntaxError: invalid syntax
> 
> I tried changing socket.error to ConnectionRefusedError. and still got the 
> same error.
> 
> Please tell me if the problem is with Rstudio, Python version or the syntax.
> 
> TIA
> -Shaunak

It is 3.5. I am looking at the link.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue26297] Move constant folding to AST level

2016-02-05 Thread STINNER Victor

STINNER Victor added the comment:

> we need to move some optimizations from bytecode level to AST level

You may be aware that there is a long list of similar (old) issues proposing 
something similar:
https://www.python.org/dev/peps/pep-0511/#usage-1-ast-optimizer

My PEP 511 tries to propose a generic API to support all proposed optimizations.

--

I didn't try yet to do something like importlib to compile an AST optimizer 
written in Python into a frozen module and then use it in Python. It would 
allow to implement an AST optimizer in pure Python to ease its maintenance 
*and* have it builtin into CPython, rather than having to play with AST in C 
(less fun).

My plan for the PEP 511 is more to start to experiment multiple AST optimizers 
and bytecode optimizers outside CPython, wait until the code becomes more 
stable, and later discuss if one optimizer deserves to become part of Python 
stdlib.

"Writing an optimizer or a preprocessor is out of the scope of this PEP."

--

But maybe you would prefer to have a single and simple AST optimizer builtin 
Python without new additional API?

I don't want to block your effort on experimentation :-) I just see a nice 
opportunity to sell you the PEP 511 ;-)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26287] Core dump in f-string with formatting errors

2016-02-05 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 9095a5787a82 by Eric V. Smith in branch 'default':
Fix issue 26287: While handling FORMAT_VALUE opcode, the top of stack was being 
corrupted if an error occurred in PyObject_Format().
https://hg.python.org/cpython/rev/9095a5787a82

--
nosy: +python-dev

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24683] Type confusion in json encoding

2016-02-05 Thread paul

paul added the comment:

Sorry, I wasn't clear enough. This POC is a proof that the original bug can be 
used for EIP control. I just checked and it works as advertised on 2.7 
revision: https://hg.python.org/cpython/rev/2d39777f3477 - it's a parent of 
https://hg.python.org/cpython/rev/0a1266ef1b5d containing the patch for this 
issue. I added this file, because I submitted a bug on hackerone claiming EIP 
control.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Daemon strategy

2016-02-05 Thread Ian Kelly
On Fri, Feb 5, 2016 at 4:10 PM, Ben Finney  wrote:
> Sorry to learn that. The PyPI metadata for ‘python-daemon’
>  explicitly declares
> the supported OS limited to “Operating System :: POSIX”, which MS
> Windows is not compatible with.

Depends on the version: https://en.wikipedia.org/wiki/Windows_Services_for_UNIX

Unfortunately that's no longer available for modern Windows. But it's
not the only option either:
https://en.wikipedia.org/wiki/POSIX#POSIX_for_Windows

> If ‘pip’ does not honour that field and inform you of the
> incompatibility, you may want to report a bug to the ‘pip’ developers.

Linux and FreeBSD are also not POSIX-certified, even though they
mostly comply. Should pip warn about those also?
-- 
https://mail.python.org/mailman/listinfo/python-list


snmpset

2016-02-05 Thread Matt
How do I do the equivalent of this in Python?

snmpset -v 2c -c $community $ip .1.3.1.1.4.1.1.1.1.1.1.1.0 s test

and

snmpset -v 2c -c $community $ip .1.3.1.1.4.1.1.1.1.1.1.1.0 i 123

and

snmpbulkget -v2c -c $community -m ALL $ip .1.3.1.1.4.1.1.1.1.1.1.1.1

and

snmpget -v2c -c $community -m ALL $ip .1.3.1.1.4.1.1.1.1.1.1.1.2
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue21955] ceval.c: implement fast path for integers with a single digit

2016-02-05 Thread Yury Selivanov

Yury Selivanov added the comment:

As to weather we want this patch committed or not, here's a 
mini-macro-something benchmark:


$ ./python.exe -m timeit -s "x=2" "x + 10 + x * 20  + x* 10 + 20 -x"
1000 loops, best of 3: 0.115 usec per loop

$ python3.5 -m timeit -s "x=2" "x + 10 + x * 20  + x* 10 + 20 -x"
1000 loops, best of 3: 0.141 usec per loop


$ ./python.exe -m timeit -s "x=2" "x*2.2 + 2 + x*2.5 + 1.0 - x / 2.0 + 
(x+0.1)/(x-0.1)*2 + (x+10)*(x-30)"
100 loops, best of 3: 0.308 usec per loop

$ python3.5 -m timeit -s "x=2" "x*2.2 + 2 + x*2.5 + 1.0 - x / 2.0 + 
(x+0.1)/(x-0.1)*2 + (x+10)*(x-30)"
100 loops, best of 3: 0.652 usec per loop


Still, longs are faster 30-50%, FP are faster 100%.  I think it's a very good 
result.  Please don't block this patch.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: [issue21955] ceval.c: implement fast path for integers with a single digit

2016-02-05 Thread M.-A. Lemburg
On 05.02.2016 16:14, STINNER Victor wrote:
> 
> Please don't. I would like to have time to benchmark all these patches (there 
> are now 9 patches attached to the issue :-)) and I would like to hear 
> Serhiy's feedback on your latest patches.

Regardless of the performance, the fastint5.patch looks like the
least invasive approach to me. It also doesn't incur as much
maintenance overhead as the others do.

I'd only rename the macro MAYBE_DISPATCH_FAST_NUM_OP to
TRY_FAST_NUMOP_DISPATCH :-)

BTW: I do wonder why this approach is as fast as the others. Have
compilers grown smart enough to realize that the number slot
functions will not change and can thus be inlined ?

-- 
Marc-Andre Lemburg
eGenix.com

___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: _siftup and _siftdown implementation

2016-02-05 Thread srinivas devaki
On Fri, Feb 5, 2016 at 8:12 PM, Sven R. Kunze  wrote:
> On 05.02.2016 02:26, srinivas devaki wrote:
> What do you think about our use-case?
>
Oh, the logic is sound, every element that we have inserted has to be popped,
We are spending some *extra* time in rearranging the elements only to be
sure that we won't be spending more than this *extra* time when doing other
operations, and our use-case isn't much different either, If by rearranging the
elements in the heap(*subheap*) gets optimal for other operations like
popping the
root element(heap[0]) then obviously it is optimal for popping other elements
(children of heap[0]).


PS: @sven But don't yet merge the pull request, I could be wrong.
as the heapq module already says that the variance is very small,
let me write some tests(on more than 10**3 elements) and then get back here.
-- 
Regards
Srinivas Devaki
Junior (3rd yr) student at Indian School of Mines,(IIT Dhanbad)
Computer Science and Engineering Department
ph: +91 9491 383 249
telegram_id: @eightnoteight
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: snmpset

2016-02-05 Thread Zachary Ware
On Fri, Feb 5, 2016 at 9:16 AM, Matt  wrote:
> How do I do the equivalent of this in Python?
>
> snmpset -v 2c -c $community $ip .1.3.1.1.4.1.1.1.1.1.1.1.0 s test
>
> and
>
> snmpset -v 2c -c $community $ip .1.3.1.1.4.1.1.1.1.1.1.1.0 i 123
>
> and
>
> snmpbulkget -v2c -c $community -m ALL $ip .1.3.1.1.4.1.1.1.1.1.1.1.1
>
> and
>
> snmpget -v2c -c $community -m ALL $ip .1.3.1.1.4.1.1.1.1.1.1.1.2

I have had success with pysnmp (http://pysnmp.sourceforge.net/).  It
is far from a shining example of a Pythonic API and I don't envy you
if you should need to subclass something to change its behavior, but
it is effective.

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


Re: _siftup and _siftdown implementation

2016-02-05 Thread Sven R. Kunze

Hi srinivas,

I wrote this simple benchmark to measure comparisons:

import random

from xheapimport RemovalHeap


class X(object):
c =0 def __init__(self, x):
self.x = x
def __lt__(self, other):
X.c +=1 return self.x < other.x

n =10 for jjin range(5):
items = [X(i)for iin range(n)]
random.shuffle(items)
heap = RemovalHeap(items)

random.shuffle(items)
for i  in items:
heap.remove(i)

print(X.c)
X.c =0


old version:
430457
430810
430657
429971
430583

your pull request version:
426414
426045
425437
425528
425522


Can we do better here?

Best,
Sven
--
https://mail.python.org/mailman/listinfo/python-list


[issue21955] ceval.c: implement fast path for integers with a single digit

2016-02-05 Thread STINNER Victor

STINNER Victor added the comment:

My analysis of benchmarks.

Even using CPU isolation to run benchmarks, the results look unreliable for 
very short benchmarks like 3 ** 2.0: I don't think that fastint_alt can make 
the operation 16% slower since it doesn't touch this code, no?

Well... as expected, speedup is quite *small*: the largest difference is on "3 
* 2" ran 100 times: 18% faster with fastint_alt. We are talking about 1.82 us 
=> 1.49 us: delta of 330 ns. I expect a much larger difference is you compile a 
function to machine code using Cython or a JIT like Numba and PyPy. Remember 
that we are running *micro*-benchmarks, so we should not push overkill 
optimizations except if the speedup is really impressive.

It's quite obvious from the tables than fastint_alt.patch only optimize int 
(float is not optimized). If we choose to optimize float too, 
fastintfloat_alt.patch and fastint5.patch look to have the *same* speed.

I don't see any overhead on Decimal + Decimal with any patch: good.

--

Between fastintfloat_alt.patch and fastint5.patch, I prefer 
fastintfloat_alt.patch which is much easier to read, so probably much easier to 
debug. I hate huge macro when I have to debug code in gdb :-( I also like very 
much the idea of *reusing* existing functions, rather than duplicating code.

Even if Antoine doesn't seem interested by optimizations on float, I think that 
it's ok to add a few lines for this type, fastintfloat_alt.patch is not so 
complex. What do *you* think?

Why not optimizing a**b? It's a common operation, especially 2**k, no?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21955] ceval.c: implement fast path for integers with a single digit

2016-02-05 Thread Yury Selivanov

Yury Selivanov added the comment:

Anyways, if it's about macro vs non-macro, I can inline the macro by hand 
(which I think is an inferior approach here).  But I'd like the final code to 
use my approach of using slots directly, instead of modifying 
longobject/floatobject to export lots of *internal* stuff.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: _siftup and _siftdown implementation

2016-02-05 Thread Sven R. Kunze

again for the list:
###


import random

from xheap import RemovalHeap


class X(object):
c = 0
def __init__(self, x):
self.x = x
def __lt__(self, other):
X.c += 1
return self.x < other.x

n = 10

for jj in range(5):
items = [X(i) for i in range(n)]
random.shuffle(items)
heap = RemovalHeap(items)

random.shuffle(items)
for i in items:
heap.remove(i)

print(X.c)
X.c = 0


(note to myself: never copy PyCharm formatting strings to this list).

On 05.02.2016 17:27, Sven R. Kunze wrote:

Hi srinivas,

I wrote this simple benchmark to measure comparisons:

import random

from xheapimport RemovalHeap


class X(object):
c =0 def __init__(self, x):
self.x = x
def __lt__(self, other):
X.c +=1 return self.x < other.x

n =10 for jjin range(5):
items = [X(i)for iin range(n)]
random.shuffle(items)
heap = RemovalHeap(items)

random.shuffle(items)
for i  in items:
heap.remove(i)

print(X.c)
X.c =0


old version:
430457
430810
430657
429971
430583

your pull request version:
426414
426045
425437
425528
425522


Can we do better here?

Best,
Sven


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


Re: _siftup and _siftdown implementation

2016-02-05 Thread Bernardo Sulzbach

On 02/05/2016 12:55 PM, Sven R. Kunze wrote:

On 05.02.2016 15:48, Bernardo Sulzbach wrote:

On 02/05/2016 12:42 PM, Sven R. Kunze wrote:


PS: I do competitive programming, I use these modules every couple of
days
when compared to other modules. so didn't give much thought when
posting to
the mailing list. sorry for that.


Competitive programming? That sounds interesting. :)



I wonder why you *can* use this amount of already done stuff in
competitive programming. When I was into that you could use what the
standard library of the language gave you and nothing else.


AFAICT, heapq is part of the standard lib. :)



Yes. I thought he was talking about XHEAP. However, rereading makes it 
look like he meant heapq indeed.

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


[issue21955] ceval.c: implement fast path for integers with a single digit

2016-02-05 Thread Yury Selivanov

Yury Selivanov added the comment:

Unless there are any objections, I'll commit fastint5.patch in a day or two.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21955] ceval.c: implement fast path for integers with a single digit

2016-02-05 Thread Yury Selivanov

Yury Selivanov added the comment:

>> Unless there are any objections, I'll commit fastint5.patch in a day or two.

> Please don't. I would like to have time to benchmark all these patches (there 
> are now 9 patches attached to the issue :-)) and I would like to hear 
> Serhiy's feedback on your latest patches.

Sure, I'd very appreciate a review of fastint5.

I can save you sometime on benchmarking -- it's really about fastint_alt vs 
fastint5.  The latter optimizes ALL ops on longs AND floats.  The former only 
optimizes some ops on longs.  So please be sure you're comparing oranges to 
oranges ;)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21955] ceval.c: implement fast path for integers with a single digit

2016-02-05 Thread STINNER Victor

STINNER Victor added the comment:

bench_long2.py: my updated microbenchmark to test many types and more 
operations.

compare.txt: compare Python original, fastint_alt.patch, fastintfloat_alt.patch 
and fastint5.patch. "(*)" marks the minimum of the line, percents are relative 
to the minimum (if larger than +/-5%).

compare_to.txt: similar to compare.txt, but percents are relative to the 
original Python.

--
Added file: http://bugs.python.org/file41821/bench_long2.py

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19217] Calling assertEquals for moderately long list takes too long

2016-02-05 Thread Chris AtLee

Chris AtLee added the comment:

Switching this to unified_diff allows the test case to finish nearly instantly.

The downside is that the output is changed in the case of a difference found:

FF
==
FAIL: test_compare (__main__.SCSE)
--
Traceback (most recent call last):
  File "test_case.py", line 14, in test_compare
self.assertEqual(arr1, arr2)
AssertionError: Lists differ: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,[29953 
chars]1, 1] != [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,[29953 chars]2, 2]

First differing element 0:
1
2

Diff is 100034 characters long. Set self.maxDiff to None to see it.

==
FAIL: test_compare_2 (__main__.SCSE)
--
Traceback (most recent call last):
  File "test_case.py", line 24, in test_compare_2
self.assertEqual(arr1, arr2)
AssertionError: Lists differ: [1, 1[29932 chars] 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] != [1, 1[29932 chars] 1, 1, 1, 1, 1, 1, 1, 1, 
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]

First differing element :
1
2

--- 
+++ 
@@ -9997,4 +9997,4 @@
  1,
  1,
  1,
- 1]
+ 2]

--
Ran 2 tests in 0.098s

FAILED (failures=2)


--
nosy: +Chris AtLee

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21955] ceval.c: implement fast path for integers with a single digit

2016-02-05 Thread Yury Selivanov

Yury Selivanov added the comment:

> Regardless of the performance, the fastint5.patch looks like the
least invasive approach to me. It also doesn't incur as much
maintenance overhead as the others do.

Thanks.  It's a result of an enlightenment that can only come
after running benchmarks all day :)

> I'd only rename the macro MAYBE_DISPATCH_FAST_NUM_OP to
TRY_FAST_NUMOP_DISPATCH :-)

Yeah, your name is better.

> BTW: I do wonder why this approach is as fast as the others. Have
compilers grown smart enough to realize that the number slot
functions will not change and can thus be inlined ?

Looks like so, I'm very impressed myself.  I'd expect fastint3 (which just 
inlines a lot of logic directly in ceval.c) to be the fastest one.  But it 
seems that compiler does an excellent job here.

Victor, BTW, if you want to test fastint3 vs fastint5, don't forget to apply 
the patch from issue #26288 over fastint5 (fixes slow performance of 
PyLong_AsDouble)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21955] ceval.c: implement fast path for integers with a single digit

2016-02-05 Thread Yury Selivanov

Yury Selivanov added the comment:

> Between fastintfloat_alt.patch and fastint5.patch, I prefer 
> fastintfloat_alt.patch which is much easier to read, so probably much easier 
> to debug. I hate huge macro when I have to debug code in gdb :-( I also like 
> very much the idea of *reusing* existing functions, rather than duplicating 
> code.

I disagree.

fastintfloat_alt exports a lot of functions from longobject/floatobject, 
something that I really don't like.  Lots of repetitive code in ceval.c also 
make it harder to make sure everything is correct.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19217] Calling assertEquals for moderately long list takes too long

2016-02-05 Thread Chris AtLee

Changes by Chris AtLee :


Added file: http://bugs.python.org/file41824/cpython-issue19217.diff

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26280] ceval: Optimize [] operation similarly to CPython 2.7

2016-02-05 Thread Zach Byrne

Zach Byrne added the comment:

I'm attaching output from a selection of the benchmarks, I'm counting 
non-builtins and slices, but for everything, not just lists and tuples.

Quick observation: math workloads seem list heavy, text workloads seem dict 
heavy, and tuples are usually somewhere in the middle.

--
Added file: http://bugs.python.org/file41826/subscr_stats.txt

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21955] ceval.c: implement fast path for integers with a single digit

2016-02-05 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

My patches were just samples. I'm glad that Yury incorporated the main idea and 
that this helps. If apply any patch I would prefer fastint5.patch. But I don't 
quite understand why it adds any gain. Is this just due to overhead of calling 
PyNumber_Add? Then we should test with other compilers and with the LTO option. 
fastint5.patch adds an overhead for type checks and increases the size of ceval 
loop. What is outweigh this overhead?

As for tests, it would be more honest to test data that results out of small 
ints range (-5..256).

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: _siftup and _siftdown implementation

2016-02-05 Thread Bernardo Sulzbach

On 02/05/2016 12:42 PM, Sven R. Kunze wrote:


PS: I do competitive programming, I use these modules every couple of
days
when compared to other modules. so didn't give much thought when
posting to
the mailing list. sorry for that.


Competitive programming? That sounds interesting. :)



I wonder why you *can* use this amount of already done stuff in 
competitive programming. When I was into that you could use what the 
standard library of the language gave you and nothing else.

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


Re: _siftup and _siftdown implementation

2016-02-05 Thread Sven R. Kunze

On 05.02.2016 15:48, Bernardo Sulzbach wrote:

On 02/05/2016 12:42 PM, Sven R. Kunze wrote:


PS: I do competitive programming, I use these modules every couple of
days
when compared to other modules. so didn't give much thought when
posting to
the mailing list. sorry for that.


Competitive programming? That sounds interesting. :)



I wonder why you *can* use this amount of already done stuff in 
competitive programming. When I was into that you could use what the 
standard library of the language gave you and nothing else.


AFAICT, heapq is part of the standard lib. :)

Best,
Sven
--
https://mail.python.org/mailman/listinfo/python-list


[issue23551] IDLE to provide menu link to PIP gui.

2016-02-05 Thread Upendra Kumar

Upendra Kumar added the comment:

I trying to write the Tk application for the pip package manager. It is in very 
initial stage, with none of the functionalities implemented yet. I have 
attached the current state of code written by me. I have also included the 
wrapper provided by Terri for pip command line. 

Please can someone review my current code , if I am on correct path? If there 
are some objections to my coding style and the structure of program, please do 
tell me.

--
Added file: http://bugs.python.org/file41825/tem_pip_v2.py

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26287] Core dump in f-string with formatting errors due to refcount bug

2016-02-05 Thread Eric V. Smith

Eric V. Smith added the comment:

The problem has to do with refcounting when an error occurs. Adjusting the 
title accordingly.

I'm not sure yet if the problem is in PyObject_Format(), or in handling errors 
in the eval loop when processing FORMAT_VALUE opcodes. I'm slowly tracking it 
down. It doesn't happen with format(), so I suspect it's in FORMAT_VALUE.

Here's an example showing the error with a large, non-cached int. You need to 
call it twice to trigger the refcount problem.

>>> f'{1000:j}'
Traceback (most recent call last):
  File "", line 1, in 
ValueError: Unknown format code 'j' for object of type 'int'
>>> f'{1000:j}'
Fatal Python error: Objects/tupleobject.c:233 object at 0x7f904006b360 has 
negative ref count -2604246222170760230

Current thread 0x7f9041278700 (most recent call first):
Aborted (core dumped)

--
title: Core dump in f-string with lambda and format specification -> Core dump 
in f-string with formatting errors due to refcount bug

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21955] ceval.c: implement fast path for integers with a single digit

2016-02-05 Thread STINNER Victor

STINNER Victor added the comment:

> Unless there are any objections, I'll commit fastint5.patch in a day or two.

Please don't. I would like to have time to benchmark all these patches (there 
are now 9 patches attached to the issue :-)) and I would like to hear Serhiy's 
feedback on your latest patches.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24683] Type confusion in json encoding

2016-02-05 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

The same result on 2.7 branch:

$ ./python ../cpython/eip.py 
Traceback (most recent call last):
  File "../cpython/eip.py", line 21, in 
e = j.make_encoder(markers, None, enc, 4, "ks", "is", False, True, True)
TypeError: make_encoder() argument 1 must be dict or None, not str

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Daemon strategy

2016-02-05 Thread Ben Finney
paul.hermeneu...@gmail.com writes:

> It appears that python-deamon would be exactly what I need. Alas,
> appears not to run on Windows. If I am wrong about that, please tell
> me.

You're correct that ‘python-daemon’ uses Unix facilities to create a
well-behaved Unix daemon process.

Since MS Windows lacks those facilities, ‘python-daemon’ can't use them.

> To what tools should I turn?

If what you need – the support to create a Unix daemon process – is
available only on Unix by definition, it seems you'll need to deploy to
Unix.

> I am not eager to produce a "service" on Windows unless it cannot be
> avoided.

Agreed :-)

-- 
 \ “Wrinkles should merely indicate where smiles have been.” —Mark |
  `\Twain, _Following the Equator_ |
_o__)  |
Ben Finney

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


[issue22107] tempfile module misinterprets access denied error on Windows

2016-02-05 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
status: closed -> open

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26296] colorys rgb_to_hls algorithm error

2016-02-05 Thread Shashank Agarwal

Shashank Agarwal added the comment:

I would like to work on this..

--
nosy: +The_Knight

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21955] ceval.c: implement fast path for integers with a single digit

2016-02-05 Thread Yury Selivanov

Yury Selivanov added the comment:

Thanks, Serhiy,

> But I don't quite understand why it adds any gain. 

Perhaps, and this is just a guess - the fast path does only couple of eq tests 
& one call for the actual op.  If it's long+long then long_add will be called 
directly.

PyNumber_Add has more overhead on:
- at least one extra call
- a few extra checks to guard against NotImplemented
- abstract.c/binary_op1 has a few more checks/slot lookups

So it look that there's just much less instructions to be executed.  If this 
guess is correct, then an LTO build without fast paths will still be somewhat 
slower.

> Is this just due to overhead of calling PyNumber_Add? Then we should test 
> with other compilers and with the LTO option.

I actually tried to compile CPython with LTO -- but couldn't.  Almost all of C 
extension modules failed to link.  Do we compile official binaries with LTO?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: snmpset

2016-02-05 Thread Zachary Ware
On Fri, Feb 5, 2016 at 11:14 AM, Joel Goldstick
 wrote:
> On Fri, Feb 5, 2016 at 12:12 PM, Joel Goldstick 
> wrote:
>> That page 404s for me.
>>
>
> Pardon me, looks like sourceforge is down

Ah, I guess caching fooled me when I rechecked.

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


[issue26298] Split ceval.c into small files

2016-02-05 Thread STINNER Victor

New submission from STINNER Victor:

Attached patch splits the huge "switch (opcode)" of ceval.c into smaller 
ceval_xxx.h files. New files:

   93 Python/ceval_stack.h
  142 Python/ceval_condjump.h
  155 Python/ceval_misc.h
  162 Python/ceval_fast.h
  180 Python/ceval_module.h
  238 Python/ceval_ctx.h
  249 Python/ceval_func.h
  262 Python/ceval_iter.h
  268 Python/ceval_build.h
  384 Python/ceval_number.h

Maybe we can put more files per .h file, maybe less. I don't really care.

It will allow to keep the code readable even with new optimizations like the 
issue #21955.

What do you think?

--
files: split_ceval.patch
keywords: patch
messages: 259682
nosy: haypo, pitrou, serhiy.storchaka, yselivanov
priority: normal
severity: normal
status: open
title: Split ceval.c into small files
versions: Python 3.6
Added file: http://bugs.python.org/file41827/split_ceval.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26298] Split ceval.c into small files

2016-02-05 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

I don't think this will make the code more readable. Rather less readable, 
since macros are defined in different file than used.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: snmpset

2016-02-05 Thread Joel Goldstick
On Fri, Feb 5, 2016 at 11:10 AM, Zachary Ware  wrote:

> On Fri, Feb 5, 2016 at 9:16 AM, Matt  wrote:
> > How do I do the equivalent of this in Python?
> >
> > snmpset -v 2c -c $community $ip .1.3.1.1.4.1.1.1.1.1.1.1.0 s test
> >
> > and
> >
> > snmpset -v 2c -c $community $ip .1.3.1.1.4.1.1.1.1.1.1.1.0 i 123
> >
> > and
> >
> > snmpbulkget -v2c -c $community -m ALL $ip .1.3.1.1.4.1.1.1.1.1.1.1.1
> >
> > and
> >
> > snmpget -v2c -c $community -m ALL $ip .1.3.1.1.4.1.1.1.1.1.1.1.2
>
> I have had success with pysnmp (http://pysnmp.sourceforge.net/).  It
> is far from a shining example of a Pythonic API and I don't envy you
> if you should need to subclass something to change its behavior, but
> it is effective.
>
> --
> Zach
> --
> https://mail.python.org/mailman/listinfo/python-list
>

That page 404s for me

-- 
Joel Goldstick
http://joelgoldstick.com/stats/birthdays
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: snmpset

2016-02-05 Thread Grant Edwards
On 2016-02-05, Joel Goldstick  wrote:

>> I have had success with pysnmp (http://pysnmp.sourceforge.net/).
>
> That page 404s for me

Looks like sourceforge is suffering an outage of some kind.

-- 
Grant Edwards   grant.b.edwardsYow! The FALAFEL SANDWICH
  at   lands on my HEAD and I
  gmail.combecome a VEGETARIAN ...
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: sharepoint python

2016-02-05 Thread Joel Goldstick
On Fri, Feb 5, 2016 at 12:31 PM, Joel Goldstick 
wrote:

>
>
> On Fri, Feb 5, 2016 at 9:35 AM,  wrote:
>
>> Hi Folks,
>>
>> Is there a python package available to check-in files from Unix to
>> sharepoint?
>> I hope current sharepoint package is used to read from sharepoint server.
>>
>> Thanks,
>> Ramesh
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>>
>
> Does this help?  https://pypi.python.org/pypi/sharepoint/0.3.2
>

or this:

http://stackoverflow.com/questions/23696705/how-to-upload-a-file-to-sharepoint-site-using-python-script


>
>
> --
> Joel Goldstick
> http://joelgoldstick.com/stats/birthdays
>



-- 
Joel Goldstick
http://joelgoldstick.com/stats/birthdays
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Daemon strategy

2016-02-05 Thread Nathan Hilterbrand



On 02/05/2016 01:39 PM, paul.hermeneu...@gmail.com wrote:

It appears that python-deamon would be exactly what I need. Alas,
appears not to run on Windows. If I am wrong about that, please tell
me.

To what tools should I turn?

I am not eager to produce a "service" on Windows unless it cannot be avoided.


I am not 100% sure exactly what you want to do, but you might take a 
look at using 'pythonw.exe' instead of 'python.exe'


YMMV

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


Re: snmpset

2016-02-05 Thread Zachary Ware
On Fri, Feb 5, 2016 at 11:12 AM, Joel Goldstick
 wrote:
> On Fri, Feb 5, 2016 at 11:10 AM, Zachary Ware > wrote:
>> I have had success with pysnmp (http://pysnmp.sourceforge.net/).  It
>
> That page 404s for me

Hmm, it works for me (just tried again).  Even Gmail's automatic
linkification didn't kill it.

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


Re: snmpset

2016-02-05 Thread Johannes Findeisen
On Fri, 5 Feb 2016 12:12:58 -0500
Joel Goldstick wrote:

> On Fri, Feb 5, 2016 at 11:10 AM, Zachary Ware  > wrote:  
> 
> > On Fri, Feb 5, 2016 at 9:16 AM, Matt  wrote:  
> > > How do I do the equivalent of this in Python?
> > >
> > > snmpset -v 2c -c $community $ip .1.3.1.1.4.1.1.1.1.1.1.1.0 s test
> > >
> > > and
> > >
> > > snmpset -v 2c -c $community $ip .1.3.1.1.4.1.1.1.1.1.1.1.0 i 123
> > >
> > > and
> > >
> > > snmpbulkget -v2c -c $community -m ALL $ip .1.3.1.1.4.1.1.1.1.1.1.1.1
> > >
> > > and
> > >
> > > snmpget -v2c -c $community -m ALL $ip .1.3.1.1.4.1.1.1.1.1.1.1.2  
> >
> > I have had success with pysnmp (http://pysnmp.sourceforge.net/).  It
> > is far from a shining example of a Pythonic API and I don't envy you
> > if you should need to subclass something to change its behavior, but
> > it is effective.
> >
> > --
> > Zach
> > --
> > https://mail.python.org/mailman/listinfo/python-list
> >  
> 
> That page 404s for me

SourceForge seems to have problems at all... The Homepage is down too.

Johannes

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


[issue26297] Move constant folding to AST level

2016-02-05 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

For using more efficient bytecode (either specialized 8-bit opcodes or 16-bit 
opcodes) we need to move some optimizations from bytecode level to AST level, 
since LOAD_CONST variants could have variable size. Now with the Constant node 
this should be easy.

--
components: Interpreter Core
messages: 259680
nosy: abarnert, benjamin.peterson, brett.cannon, georg.brandl, haypo, ncoghlan, 
serhiy.storchaka, yselivanov
priority: normal
severity: normal
stage: needs patch
status: open
title: Move constant folding to AST level
type: enhancement
versions: Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24683] Type confusion in json encoding

2016-02-05 Thread paul

paul added the comment:

Can you try on 2.7 branch?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Daemon strategy

2016-02-05 Thread Ray Cote
We’ve recently stopped building Windows services (Python or any other type)
and started using the NSSM service manager.
Takes a normal Windows application and runs it as a service.
The NSSM service manager provides great command-line support for
installing, configuring, and controlling Windows services.
Has greatly reduced our development time and test time since we no longer
need to test both app and service executables.



Downside is that it is a separate tool to install.
Upside is that it has features such as :
  - run-once at startup.
  - auto-restart failed services
  - setting service dependences (don’t start until another service is up
and running)
  - set processor dependencies

—Ray


On Fri, Feb 5, 2016 at 1:39 PM,  wrote:

> It appears that python-deamon would be exactly what I need. Alas,
> appears not to run on Windows. If I am wrong about that, please tell
> me.
>
> To what tools should I turn?
>
> I am not eager to produce a "service" on Windows unless it cannot be
> avoided.
> --
> https://mail.python.org/mailman/listinfo/python-list
>



-- 
Raymond Cote, President
voice: +1.603.924.6079 email: rgac...@appropriatesolutions.com skype:
ray.cote
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue26299] wsgiref.util FileWrapper raises ValueError: I/O operation on closed file.

2016-02-05 Thread Samwyse

New submission from Samwyse:

While developing, I am using wsgiref.simple_server.  Using to serve static 
content isn't working.  The attached program demonstrates the issue.  Run it 
and connect to http://127.0.0.1:8000/.  You will see three buttons.  Clicking 
on 'wsgi.filewrapper' causes the FileWrapper class found in wsgiref.util to be 
used, while clicking on 'PEP 0333' uses code suggested in PEP 0333 
(https://www.python.org/dev/peps/pep-0333/#id36).  Both of these fail.  
Clicking on 'slurp' causes the entire file to loaded and returned in a list.  
This works.

When an application returns an instance of environ['wsgi.file_wrapper'], or 
creates it's own iterator, an error is raised during the initial read of the 
file.  Reading the entire file and returning a single-element list (the 'slurp' 
technique) works, but is impractical for larger files.

I've tested this with both Python 2.7.9 and 3.4.3 under Windows 7 (my laptop) 
and 3.4.3 under Alpine Linux (a Docker instance).

--
components: Library (Lib)
files: wsgitest.py
messages: 259685
nosy: samwyse
priority: normal
severity: normal
status: open
title: wsgiref.util FileWrapper raises ValueError: I/O operation on closed file.
versions: Python 2.7, Python 3.4
Added file: http://bugs.python.org/file41828/wsgitest.py

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24683] Type confusion in json encoding

2016-02-05 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

I can't reproduce your example paul.

$ ./python eip.py 
Traceback (most recent call last):
  File "eip.py", line 21, in 
e = j.make_encoder(markers, None, enc, 4, "ks", "is", False, True, True)
TypeError: make_encoder() argument 1 must be dict or None, not array.array

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: snmpset

2016-02-05 Thread Joel Goldstick
On Fri, Feb 5, 2016 at 12:12 PM, Joel Goldstick 
wrote:

>
>
> On Fri, Feb 5, 2016 at 11:10 AM, Zachary Ware <
> zachary.ware+pyl...@gmail.com> wrote:
>
>> On Fri, Feb 5, 2016 at 9:16 AM, Matt  wrote:
>> > How do I do the equivalent of this in Python?
>> >
>> > snmpset -v 2c -c $community $ip .1.3.1.1.4.1.1.1.1.1.1.1.0 s test
>> >
>> > and
>> >
>> > snmpset -v 2c -c $community $ip .1.3.1.1.4.1.1.1.1.1.1.1.0 i 123
>> >
>> > and
>> >
>> > snmpbulkget -v2c -c $community -m ALL $ip .1.3.1.1.4.1.1.1.1.1.1.1.1
>> >
>> > and
>> >
>> > snmpget -v2c -c $community -m ALL $ip .1.3.1.1.4.1.1.1.1.1.1.1.2
>>
>> I have had success with pysnmp (http://pysnmp.sourceforge.net/).  It
>> is far from a shining example of a Pythonic API and I don't envy you
>> if you should need to subclass something to change its behavior, but
>> it is effective.
>>
>> --
>> Zach
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>>
>
> That page 404s for me.
>

Pardon me, looks like sourceforge is down

>
>
> --
> Joel Goldstick
> http://joelgoldstick.com/stats/birthdays
>



-- 
Joel Goldstick
http://joelgoldstick.com/stats/birthdays
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: snmpset

2016-02-05 Thread Bernardo Sulzbach

On 02/05/2016 03:18 PM, Grant Edwards wrote:

On 2016-02-05, Joel Goldstick  wrote:


I have had success with pysnmp (http://pysnmp.sourceforge.net/).


That page 404s for me


Looks like sourceforge is suffering an outage of some kind.



Agree, it does not work for me right now.
--
https://mail.python.org/mailman/listinfo/python-list


Re: sharepoint python

2016-02-05 Thread Joel Goldstick
On Fri, Feb 5, 2016 at 9:35 AM,  wrote:

> Hi Folks,
>
> Is there a python package available to check-in files from Unix to
> sharepoint?
> I hope current sharepoint package is used to read from sharepoint server.
>
> Thanks,
> Ramesh
> --
> https://mail.python.org/mailman/listinfo/python-list
>

Does this help?  https://pypi.python.org/pypi/sharepoint/0.3.2

-- 
Joel Goldstick
http://joelgoldstick.com/stats/birthdays
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: _siftup and _siftdown implementation

2016-02-05 Thread srinivas devaki
wow, that's great.
you read a comment in the code, and you test it, to only find that it
is indeed true,
sounds ok, but feels great. :)

Just experimenting a bit, I swaped the lines _siftdown and _siftup and something
strange happened the number of comparisions in both the versions remained same.
I'm attaching the files.

do you have any idea why this happened?

On Fri, Feb 5, 2016 at 9:57 PM, Sven R. Kunze  wrote:
>
> Can we do better here?
>
I don't know, I have to read TAOP knuth article.

-- 
Regards
Srinivas Devaki
Junior (3rd yr) student at Indian School of Mines,(IIT Dhanbad)
Computer Science and Engineering Department
ph: +91 9491 383 249
telegram_id: @eightnoteight
-- 
https://mail.python.org/mailman/listinfo/python-list


Daemon strategy

2016-02-05 Thread paul . hermeneutic
It appears that python-deamon would be exactly what I need. Alas,
appears not to run on Windows. If I am wrong about that, please tell
me.

To what tools should I turn?

I am not eager to produce a "service" on Windows unless it cannot be avoided.
-- 
https://mail.python.org/mailman/listinfo/python-list


Question about official API

2016-02-05 Thread Frank Millman

Hi all

What is the rule for knowing if something is part of the official API?

I have a queue.Queue(), I want to call q.join(), but I do not want it to 
block.


Looking at dir(q), I find an attribute 'unfinished_tasks'. It is an integer, 
and it looks like the counter referred to in the documentation for 
'task_done()'. I tried it out, and it does exactly what I want.


However, it is not mentioned in the documentation.

How do I know if it is safe to rely on this?

Thanks

Frank Millman


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


[issue21328] Resize doesn't change reported length on create_string_buffer()

2016-02-05 Thread Tamás Bence Gedai

Tamás Bence Gedai added the comment:

Thanks for the remarks, I think the issue can be closed as well.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



RE: Question about official API

2016-02-05 Thread Lutz Horn
Hi,

> What is the rule for knowing if something is part of the official API?

Look into https://docs.python.org/3/library/

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


Re: Question about official API

2016-02-05 Thread Ben Finney
"Frank Millman"  writes:

> What is the rule for knowing if something is part of the official API?

Part of what official API?

Different libraries will have different rules about what is the official
API. Some may not have official rules.

For Python standard library modules, the official API is in the user
documentation for each module.

> However, it is not mentioned in the [standard library] documentation.

Then it's not part of the official API (or the documentation has a bug
which needs to be reported).

-- 
 \   “The long-term solution to mountains of waste is not more |
  `\  landfill sites but fewer shopping centres.” —Clive Hamilton, |
_o__)_Affluenza_, 2005 |
Ben Finney

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


[issue1927] raw_input behavior incorrect if readline not enabled

2016-02-05 Thread Martin Panter

Changes by Martin Panter :


--
Removed message: http://bugs.python.org/msg259637

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Reply to whom?

2016-02-05 Thread Mark Lawrence

On 04/02/2016 03:23, Bernardo Sulzbach wrote:

I see. I've bad experiences with Thunderbird in the past, but I will
try a desktop client again.



I've been using Thunderbird on Windows for years and never had a 
problem.  I read all Python mailing list, blogs, or whatever via gmane, 
it's a piece of cake.


--
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


[issue21328] Resize doesn't change reported length on create_string_buffer()

2016-02-05 Thread Dustin Oprea

Dustin Oprea added the comment:

I'm closing it. The ticket has been open two-years and no one else seemed to be 
interested in this issue until now, which leads me to believe that it's a 
PEBCAK/understanding issue. The rationale for why it's irrelevant seems sound. 
Thanks for digging through the code, Tamás. Thank you for your comments, Martin 
and Eryk.

--
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21955] ceval.c: implement fast path for integers with a single digit

2016-02-05 Thread STINNER Victor

Changes by STINNER Victor :


Added file: http://bugs.python.org/file41823/compare_to.txt

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21955] ceval.c: implement fast path for integers with a single digit

2016-02-05 Thread STINNER Victor

Changes by STINNER Victor :


Added file: http://bugs.python.org/file41822/compare.txt

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Exception handling for socket.error in Python 3.5/RStudio

2016-02-05 Thread Nathan Hilterbrand
On Feb 5, 2016 15:01,  wrote:
>
> I am running this python script on R-studio. I have Python 3.5 installed
on my system.
>
> count = 10
> while (count > 0):
> try :
> # read line from file:
> print(file.readline())
> # parse
> parse_json(file.readline())
> count = count - 1
> except socket.error as e
> print('Connection fail', e)
> print(traceback.format_exc())
>
> # wait for user input to end
> # input("\n Press Enter to exit...");
> # close the SSLSocket, will also close the underlying socket
> ssl_sock.close()
> The error I am getting is here:
>
> line 53 except socket.error as e ^ SyntaxError: invalid syntax
>
> I tried changing socket.error to ConnectionRefusedError. and still got
the same error.
>
> Please tell me if the problem is with Rstudio, Python version or the
syntax.
>
> TIA
> -Shaunak
> --
> https://mail.python.org/mailman/listinfo/python-list

Looks like you are missing a colon after 'as e'... as e:  might do
the trick

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


Re: Exception handling for socket.error in Python 3.5/RStudio

2016-02-05 Thread shaunak . bangale
On Friday, February 5, 2016 at 1:09:35 PM UTC-7, Martin A. Brown wrote:
> >except socket.error as e
> 
> >line 53 except socket.error as e ^ SyntaxError: invalid syntax
> >
> >I tried changing socket.error to ConnectionRefusedError. and still 
> >got the same error.
> 
> >Please tell me if the problem is with Rstudio, Python version or 
> >the syntax.
> 
> Syntax.
> 
> Your code has, unfortunately, suffered a colonectomy.
> 
> When you transplant a colon, it is more likely to function properly 
> again.  For example:
> 
>except socket.error as e:
> 
> Good luck,
> 
> -Martin
> 
> -- 
> Martin A. Brown
> http://linux-ip.net/

I was first running with a colon only. Later tried with a comma. But it didn't 
work. I got the same error.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue26292] Raw I/O writelines() broken

2016-02-05 Thread Martin Panter

Martin Panter added the comment:

For BufferedIOBase, the documentation says write() will not return a short 
number of bytes, so I don’t see how writelines() is a problem there. For 
TextIOBase, the documentation is not so clear 
, 
but I understand the standard library implementations do not do short writes.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Exception handling for socket.error in Python 3.5/RStudio

2016-02-05 Thread Bernardo Sulzbach

On 02/05/2016 07:01 PM, Chris Angelico wrote:

On Sat, Feb 6, 2016 at 6:58 AM,   wrote:

I am running this python script on R-studio. I have Python 3.5 installed on my 
system.



Let's just try a quick smoke test. Run this script:

import sys
print(sys.version)
input("Press Enter to exit...")

That'll tell you a few things about how your system is set up. Most
notably, if it doesn't say you're using Python 3.5, there's a problem.

ChrisA



Is there? If he just got the minor version wrong it wouldn't be a 
problem. Unless RStudio requires 3.**5** for some reason.

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


Re: realtime output and csv files

2016-02-05 Thread Joel Goldstick
On Fri, Feb 5, 2016 at 4:51 PM, Bernardo Sulzbach  wrote:

> On 02/05/2016 07:43 PM, Joel Goldstick wrote:
>
>> print("%d, %2d:%2d, %.1f" % (1,10,24,20.4))
>
 1, 10:24, 20.4
>>
>
> Let us be more careful there. Although CSV has no formal specification
> (according to the IETF), *those spaces are not good*.
>
> It is **very unlikely** that they will cause issues, but 1,10:24,20.4 is
> *safer* and - to my eyes - better CSV.
>
> I wouldn't be surprised if a parser treated a value as text only because
> it has spaces on it.
>
> For OP, if you are going for this, I - personally - suggest sticking to
> "%d,%2d:%2d,%.1f".


Good point!

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



-- 
Joel Goldstick
http://joelgoldstick.com/stats/birthdays
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue21955] ceval.c: implement fast path for integers with a single digit

2016-02-05 Thread STINNER Victor

STINNER Victor added the comment:

Serhiy Storchaka: "My patches were just samples. I'm glad that Yury 
incorporated the main idea and that this helps."

Oh, if even Serhiy prefers Yury's patches, I should read them again :-)

--

I read fastint5.patch one more time and I finally understood the following 
macros:

+#define NB_SLOT(slot) offsetof(PyNumberMethods, slot)
+#define NB_BINOP(nb_methods, slot) \
+(*(binaryfunc*)(& ((char*)nb_methods)[NB_SLOT(slot)]))
+#define PY_LONG_CALL_BINOP(slot, left, right) \
+(NB_BINOP(PyLong_Type.tp_as_number, slot))(left, right)
+#define PY_FLOAT_CALL_BINOP(slot, left, right) \
+(NB_BINOP(PyFloat_Type.tp_as_number, slot))(left, right)

In short, a+b calls long_add(a, b) with that. At the first read, I understood 
that it casted objects to C long or C double (don't ask me why).


I see a difference between fastint5.patch and fastintfloat_alt.patch: 
fastint5.patch resolves the address of long_add() at runtime, whereas 
fastintfloat_alt.patch gets a direct pointer to _PyLong_Add() at the 
compilation. I expected a sublte speedup, but I'm unable to see it on 
benchmarks (again, both patches have the same speed).

The float path is simpler in fastint5.patch because it uses the same code if 
right is float or long, but it adds more checks for the slow-path. No patch 
looks to have a real impact on the slow-path. Is it worth to change the second 
if to PyFloat_CheckExact() and then check type of right in the if body to avoid 
other checks on the slow-path?

(C checks look very cheap, so I think that I already replied to my own question 
:-))

--

fastint5.patch optimizes a+b, a-b, a*b, a/b and a//b. Why not other operators? 
List of operators from my constant folding optimzation in fatoptimizer:

* int, float: a+b, a-b, a*b, a/b, +x, -x, ~x, a//b, a%b, a**b
* int only: a<>b, a, a|b, a^b

If we optimize a//b, I suggest to also optimize a%b to be consistent. For 
integers, a**b, a<>b would make sense too. Coming from the C language, 
I would prefer a<>b than a*2**k or a//2**k, since I expect better 
performance.

For float, -x and +x may be common, but less a+b, a-b, a*b, a/b.

Well, what I'm trying to say: if choose fastintfloat_alt.patch design, we will 
have to expose like a lot of new C functions in headers, and duplicate a lot of 
code.

To support more than 4 operators, we need a macro.

If we use a macro, it's cheap (in term of code maintenance) to use it for most 
or even all operators.

--

> But I don't quite understand why it adds any gain. Is this just due to 
> overhead of calling PyNumber_Add?

Hum, that's a good question.


> Then we should test with other compilers and with the LTO option.

There are projects (I don't recall the number number) but I would prefer to 
handle LTO separatly. Python supports platforms and compilers which don't 
implement LTO.


> fastint5.patch adds an overhead for type checks and increases the size of 
> ceval loop. What is outweigh this overhead?

I stopped to guess the speedup just by reading the code or a patch. I only 
trust benchmarks :-)

Advice: don't trust yourself! only trust benchmarks.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26297] Move constant folding to AST level

2016-02-05 Thread STINNER Victor

STINNER Victor added the comment:

Yury Selivanov added the comment:
> In fact I'm -1 on using any kind of flag to trigger optimizations on or off.  
> Those flags will only drive confusion.  If the optimizations are any good, 
> people will simply start using the flag all the time.

Yeah, Guido calls this a missed optimization opportunity.

My only concern is:

> ast.Constant for tuples and frozensets has a limitation: it doesn't store the 
> location of items (line number, column offset).

Is it a problem in practice? I didn't have time to investigate this.

Since the PEP 511 is still under discussion, I prefer to focus on the
PEP itself than this specific implementation detail ;-)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Exception handling for socket.error in Python 3.5/RStudio

2016-02-05 Thread Chris Angelico
On Sat, Feb 6, 2016 at 8:08 AM, Bernardo Sulzbach
 wrote:
> On 02/05/2016 07:01 PM, Chris Angelico wrote:
>>
>> On Sat, Feb 6, 2016 at 6:58 AM,   wrote:
>>>
>>> I am running this python script on R-studio. I have Python 3.5 installed
>>> on my system.
>>>
>>
>> Let's just try a quick smoke test. Run this script:
>>
>> import sys
>> print(sys.version)
>> input("Press Enter to exit...")
>>
>> That'll tell you a few things about how your system is set up. Most
>> notably, if it doesn't say you're using Python 3.5, there's a problem.
>>
>> ChrisA
>>
>
> Is there? If he just got the minor version wrong it wouldn't be a problem.
> Unless RStudio requires 3.**5** for some reason.

Stuff might work, but if you think you're using 3.5 and you're
actually running under 3.4, there's a high probability that you have
two Python installations and it's picking the wrong one. That, in
turn, means problems with package installations and such, so it's a
reasonable smoke test to try. (It's unlikely there'll be two different
3.5s installed.) And, of course, if it shows up that it's running
under *2*.5, well, that would explain a lot :)

Anyway, it is indeed what's expected - smoke test passed.

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


[issue26297] Move constant folding to AST level

2016-02-05 Thread STINNER Victor

STINNER Victor added the comment:

*If* the PEP 511 is accepted, it will be super easy to start with an
implementation in pure Python.

But I think that we should benchmark the overhead of the Python API of
PEP 511, because we need to convert all AST internal objects to Python
objects, run the AST optimizer, and then again convert Python objects
to internal AST objects.

For a long running process, the time to compile a .py file doesn't
matter. For a short script, it matters. At least, we need to compile
the script itself.

By the way, would it be insane to *not* optimize the script when
running "python script.py"?

> Now with the Constant node this should be easy.

ast.Constant is *not* emited by the compiler to not break backward
compatibility. I *know* that there is no stable API on AST, but I
noticed some issues when working on my AST project. For example, pip
doesn't work because an internal library uses AST and the code doesn't
handle ast.Constant (it's probably super easy to fix it).

I'm open to change the compiler to emit ast.Constant directly, but
maybe only in "optimized mode" (ex: python -O?). ast.Constant for
tuples and frozensets has a limitation: it doesn't store the location
of items (line number, column offset).

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26300] "unpacked" bytecode

2016-02-05 Thread Andrew Barnert

New submission from Andrew Barnert:

Currently, the compiler starts with a list of arrays of instructions, packs 
them to 1/3/6-bytes-apiece bytecodes, fixes up all the jumps, and then calls 
PyCode_Optimize on the result. This makes the peephole optimizer much more 
complicated. Assuming PEP 511 is accepted, it will also make plug-in bytecode 
optimizers much more complicated (and probably wasteful--they'll each be 
repeating the same work to re-do the fixups).

The simplest alternative (as suggested by Serhiy on -ideas) is to expose an 
"unpacked" bytecode to the optimizer (in the code parameter and return value 
and lnotab_obj in-out parameter for PyCode_Optimize, and similarly for PEP 511) 
where each instruction takes a fixed 4 bytes. This is much easier to process. 
After the optimizer returns, the compiler packs opcodes into the usual 
1/3/6-byte format, removing NOPs, retargeting jumps, and adjusting the lnotab 
as it goes. (Note that it already pretty much has code to do all of this except 
the NOP removal; it's just doing it before the optimizer instead of after.)

Negatives:

 * Arguments can now only go up to 2**23 instead of 2**31. I don't think that's 
a problem (has anyone ever created a code object with 4 million instructions?).

 * A bit more work for the compiler; we'd need to test to make sure there's no 
measurable performance impact.

We could also expose this functionality through C API PyCode_Pack/Unpack and 
Python dis.pack_code/unpack_code functions (and also make the dis module know 
how to parse unpacked code), which would allow import hooks, post-processing 
decorators, etc. to be simplified as well. This would remove some, but not all, 
of the need for things like byteplay. I think this may be worth doing, but I'm 
not sure until I see how complicated it is.

We could even allow code objects with unpacked bytecode to be executed, but I 
think that's unnecessary complexity. Nobody should want to do that 
intentionally, and if an optimizer lets such code escape by accident, a 
SystemError is fine.

MRAB implied an alternative: exposing some slightly-higher-level label-based 
format. That would be even nicer to work with. But it's also more complicated 
for the compiler and for the API, and I think it's already easy enough to 
handle jumps with fixed-width instructions.

--
components: Interpreter Core
messages: 259693
nosy: abarnert, benjamin.peterson, georg.brandl, haypo, pitrou, 
serhiy.storchaka, yselivanov
priority: normal
severity: normal
status: open
title: "unpacked" bytecode
type: enhancement

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26297] Move constant folding to AST level

2016-02-05 Thread Yury Selivanov

Yury Selivanov added the comment:

> ast.Constant is *not* emited by the compiler to not break backward
compatibility. I *know* that there is no stable API on AST, but I
noticed some issues when working on my AST project. For example, pip
doesn't work because an internal library uses AST and the code doesn't
handle ast.Constant (it's probably super easy to fix it).

Yeah, it's probably very easy to fix.  And if pip stops working on 3.6-alpha it 
will be fixed.  We don't give any guarantees on AST backwards compatibility.  
In fact, we even tell that the AST might change in every release in the docs 
"The abstract syntax itself might change with each Python release".


> I'm open to change the compiler to emit ast.Constant directly, but
maybe only in "optimized mode" (ex: python -O?). 

I'm -1 on using -O flag since some people would prefer to have optimizations 
*and* have their assert statements.

In fact I'm -1 on using any kind of flag to trigger optimizations on or off.  
Those flags will only drive confusion.  If the optimizations are any good, 
people will simply start using the flag all the time.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Exception handling for socket.error in Python 3.5/RStudio

2016-02-05 Thread shaunak . bangale
On Friday, February 5, 2016 at 12:58:37 PM UTC-7, shaunak...@gmail.com wrote:
> I am running this python script on R-studio. I have Python 3.5 installed on 
> my system.
> 
> count = 10
> while (count > 0):
> try :
> # read line from file:
> print(file.readline())
> # parse
> parse_json(file.readline())
> count = count - 1
> except socket.error as e
> print('Connection fail', e)
> print(traceback.format_exc())
> 
> # wait for user input to end
> # input("\n Press Enter to exit...");
> # close the SSLSocket, will also close the underlying socket
> ssl_sock.close()
> The error I am getting is here:
> 
> line 53 except socket.error as e ^ SyntaxError: invalid syntax
> 
> I tried changing socket.error to ConnectionRefusedError. and still got the 
> same error.
> 
> Please tell me if the problem is with Rstudio, Python version or the syntax.
> 
> TIA
> -Shaunak


Chris,

That sounds legitimate.
But I never installed second 3.X version and deleted previous 2.X version and 
using only 3.5 now. What will be the next test according to you?

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


[issue26287] Core dump in f-string with formatting errors due to refcount bug

2016-02-05 Thread Eric V. Smith

Eric V. Smith added the comment:

Yes, that's my thinking as well. I'll have a patch soon-ish.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26287] Core dump in f-string with formatting errors

2016-02-05 Thread Eric V. Smith

Eric V. Smith added the comment:

Now I think it's not a refcount problem.

I'm going to switch to POP/PUSH instead of TOP/SET_TOP. I believe the problem 
is that I'm not adjusting the top of stack if there's an error.

--
title: Core dump in f-string with formatting errors due to refcount bug -> Core 
dump in f-string with formatting errors

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Daemon strategy

2016-02-05 Thread Ben Finney
paul.hermeneu...@gmail.com writes:

> On Fri, Feb 5, 2016 at 11:52 AM, Ben Finney  
> wrote:
> > Since MS Windows lacks those facilities, ‘python-daemon’ can't use
> > them.
>
> As you might imagine, I am not always able to specify which OS is
> deployed. That does not mean that I am not responsible for getting the
> work done. Perhaps you will tell me that what I want is not a daemon.

I'm telling you none of those. What I'm telling you is MS Windows does
not support what is needed to make a Unix daemon.

You may need to re-visit the requirements and negotiate something
different — a different deployment platform, or something which MS
Windows can do which is less than a proper Unix daemon.

> BTW, I thought that pip would know that python-daemon would not run on
> my machine, but it had no complaints installing it. That gave me
> unmerited hope.

Sorry to learn that. The PyPI metadata for ‘python-daemon’
 explicitly declares
the supported OS limited to “Operating System :: POSIX”, which MS
Windows is not compatible with.

If ‘pip’ does not honour that field and inform you of the
incompatibility, you may want to report a bug to the ‘pip’ developers.

-- 
 \   “My business is to teach my aspirations to conform themselves |
  `\  to fact, not to try and make facts harmonise with my |
_o__)   aspirations.“ —Thomas Henry Huxley, 1860-09-23 |
Ben Finney

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


[issue26287] Core dump in f-string with formatting errors

2016-02-05 Thread Eric V. Smith

Eric V. Smith added the comment:

Thanks for the report and the debugging help.

--
resolution:  -> fixed
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: realtime output and csv files

2016-02-05 Thread lucan



What do you mean? What is "datas"? What do you mean by "correct"?


"datas" I mean the values for example temperature = 20.4 (so they are 
floating point)


Index time temp
1 10:24 20.4
2 10:25 20.6
...

I wonder if this is correct "my way" to write a csv file:

file.write('\n'+str(index)) 
f.write(str(index)+','+str(now.hour)+':'+str(now.minute)+','+str(temp))


Or if there is a better way to do that.


CSVs is essentially text separated by commas, so you likely do not need
any library to write it "Just separating with ','" should work if you
are formatting them correctly.


ok.

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


Re: Daemon strategy

2016-02-05 Thread paul . hermeneutic
On Fri, Feb 5, 2016 at 11:52 AM, Ben Finney  wrote:
> paul.hermeneu...@gmail.com writes:
>
>> It appears that python-deamon would be exactly what I need. Alas,
>> appears not to run on Windows. If I am wrong about that, please tell
>> me.
>
> You're correct that ‘python-daemon’ uses Unix facilities to create a
> well-behaved Unix daemon process.
>
> Since MS Windows lacks those facilities, ‘python-daemon’ can't use them.

As you might imagine, I am not always able to specify which OS is
deployed. That does not mean that I am not responsible for getting the
work done. Perhaps you will tell me that what I want is not a daemon.

BTW, I thought that pip would know that python-daemon would not run on
my machine, but it had no complaints installing it. That gave me
unmerited hope.

I want to create a program that will run a list of command lines. Some
of the tasks might take 42 milliseconds, but others might take 4.2
hours. I need to be able to:

- list the tasks currently being run
- kill a task that is currently being run
- list the tasks that are not yet run
- delete a task not yet run from the list
- add tasks to the list

The goal is to load the machine up to a specified percentage of
CPU/memory/io bandwidth. I want to keep the machine loaded up to 90%
of capacity. It is important to monitor more than just CPU utilization
because the machine may already be over-committed on memory while CPU
utilization is low. Adding more processes in such an environment just
makes the system go slower.

I realize that high-end schedulers like IBM/Tivoli, CA7, and BMC might
do things like that. Those are not usually within budget.

Is a daemon what I need? Any other suggestions?
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue26298] Split ceval.c into small files

2016-02-05 Thread Brett Cannon

Brett Cannon added the comment:

I have a similar worry as Serhiy as I don't know where to find something like 
GET_AWAITABLE with that organization.

--
nosy: +brett.cannon

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



realtime output and csv files

2016-02-05 Thread lucan

I'm new of python adn I'm using it only to complete some experiments.
I'm reading a series of data from various sensors and in the meantime 
I'm writing datas on a file. I would like to print output in realtime 
(or refresh it when I need) but the problem is that I'm writing on a 
file every x seconds (my timestep).
Anyway from the moment that datas are scientific value is it correct to 
write on a file using str(temp) and separating with ","?

I need a csv file to read it with some data analysis softwares.


...
now = datetime.datetime.now()
dayexperiment = str(now.day)+str(now.month)+str(now.year)

myfilename ="myData"+dayexperiment+".dat"

index = 0
count = 1

timestep = 10


with open(myfilename,'w') as f:
f.write('#Index Time Value')
while True:
reading = ...
...
temp=...

print 'Temp{0:0.3F}*C'.format(temp)

now = datetime.datetime.now()
file.write('\n'+str(index))

f.write(str(index)+','+str(now.hour)+':'+str(now.minute)+', '+str(temp))

index +=1
time.sleep(timestep)





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


Re: Exception handling for socket.error in Python 3.5/RStudio

2016-02-05 Thread shaunak . bangale
On Friday, February 5, 2016 at 1:08:11 PM UTC-7, Nathan Hilterbrand wrote:
> On Feb 5, 2016 15:01,  wrote:
> >
> > I am running this python script on R-studio. I have Python 3.5 installed
> on my system.
> >
> > count = 10
> > while (count > 0):
> > try :
> > # read line from file:
> > print(file.readline())
> > # parse
> > parse_json(file.readline())
> > count = count - 1
> > except socket.error as e
> > print('Connection fail', e)
> > print(traceback.format_exc())
> >
> > # wait for user input to end
> > # input("\n Press Enter to exit...");
> > # close the SSLSocket, will also close the underlying socket
> > ssl_sock.close()
> > The error I am getting is here:
> >
> > line 53 except socket.error as e ^ SyntaxError: invalid syntax
> >
> > I tried changing socket.error to ConnectionRefusedError. and still got
> the same error.
> >
> > Please tell me if the problem is with Rstudio, Python version or the
> syntax.
> >
> > TIA
> > -Shaunak
> > --
> > https://mail.python.org/mailman/listinfo/python-list
> 
> Looks like you are missing a colon after 'as e'... as e:  might do
> the trick
> 
> Nathan

Hi Nathan,

Tried colon and a comma as well. Both did not work.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Exception handling for socket.error in Python 3.5/RStudio

2016-02-05 Thread Chris Angelico
On Sat, Feb 6, 2016 at 6:58 AM,   wrote:
> I am running this python script on R-studio. I have Python 3.5 installed on 
> my system.
>

Let's just try a quick smoke test. Run this script:

import sys
print(sys.version)
input("Press Enter to exit...")

That'll tell you a few things about how your system is set up. Most
notably, if it doesn't say you're using Python 3.5, there's a problem.

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


Exception handling for socket.error in Python 3.5/RStudio

2016-02-05 Thread shaunak . bangale
I am running this python script on R-studio. I have Python 3.5 installed on my 
system.

count = 10
while (count > 0):
try :
# read line from file:
print(file.readline())
# parse
parse_json(file.readline())
count = count - 1
except socket.error as e
print('Connection fail', e)
print(traceback.format_exc())

# wait for user input to end
# input("\n Press Enter to exit...");
# close the SSLSocket, will also close the underlying socket
ssl_sock.close()
The error I am getting is here:

line 53 except socket.error as e ^ SyntaxError: invalid syntax

I tried changing socket.error to ConnectionRefusedError. and still got the same 
error.

Please tell me if the problem is with Rstudio, Python version or the syntax.

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


Re: Exception handling for socket.error in Python 3.5/RStudio

2016-02-05 Thread Martin A. Brown

Hi there,

>Thanks for the detailed reply. I edited, saved and opened the file 
>again. Still I am getting exactly the same error.
>
>Putting bigger chunk of code and the error again:

[snipped; thanks for the larger chunk]

>Error:
>except socket.error as e:
> ^
>SyntaxError: invalid syntax

I ran your code.  I see this:

  $ python3 shaunak.bangale.py 
  Connecting...
  Connection succeeded
  Traceback (most recent call last):
File "shaunak.bangale.py", line 23, in 
  ssl_sock.write(bytes(initiation_command, 'UTF-8'))
  NameError: name 'initiation_command' is not defined

Strictly speaking, I don't think you are having a Python problem.

  * Are you absolutely certain you are (or your IDE is) executing 
the same code you are writing?

  * How would you be able to tell?  Close your IDE.  Run the code on 
the command-line.

  * How much time have you taken to work out what the interpreter is 
telling you?

Good luck,

-Martin

-- 
Martin A. Brown
http://linux-ip.net/

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


[issue25228] Regression in cookie parsing with brackets and quotes

2016-02-05 Thread Guido van Rossum

Changes by Guido van Rossum :


--
nosy:  -gvanrossum

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22107] tempfile module misinterprets access denied error on Windows

2016-02-05 Thread Mark Lawrence

Changes by Mark Lawrence :


--
nosy:  -BreamoreBoy

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: realtime output and csv files

2016-02-05 Thread Bernardo Sulzbach

On 02/05/2016 05:49 PM, lucan wrote:

Anyway from the moment that datas are scientific value is it correct to
write on a file using str(temp) and separating with ","?
I need a csv file to read it with some data analysis softwares.



What do you mean? What is "datas"? What do you mean by "correct"?

CSVs is essentially text separated by commas, so you likely do not need 
any library to write it "Just separating with ','" should work if you 
are formatting them correctly.

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


Re: Exception handling for socket.error in Python 3.5/RStudio

2016-02-05 Thread Martin A. Brown

>except socket.error as e

>line 53 except socket.error as e ^ SyntaxError: invalid syntax
>
>I tried changing socket.error to ConnectionRefusedError. and still 
>got the same error.

>Please tell me if the problem is with Rstudio, Python version or 
>the syntax.

Syntax.

Your code has, unfortunately, suffered a colonectomy.

When you transplant a colon, it is more likely to function properly 
again.  For example:

   except socket.error as e:

Good luck,

-Martin

-- 
Martin A. Brown
http://linux-ip.net/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Exception handling for socket.error in Python 3.5/RStudio

2016-02-05 Thread shaunak . bangale
On Friday, February 5, 2016 at 1:11:19 PM UTC-7, shaunak...@gmail.com wrote:
> On Friday, February 5, 2016 at 1:08:11 PM UTC-7, Nathan Hilterbrand wrote:
> > On Feb 5, 2016 15:01,  wrote:
> > >
> > > I am running this python script on R-studio. I have Python 3.5 installed
> > on my system.
> > >
> > > count = 10
> > > while (count > 0):
> > > try :
> > > # read line from file:
> > > print(file.readline())
> > > # parse
> > > parse_json(file.readline())
> > > count = count - 1
> > > except socket.error as e
> > > print('Connection fail', e)
> > > print(traceback.format_exc())
> > >
> > > # wait for user input to end
> > > # input("\n Press Enter to exit...");
> > > # close the SSLSocket, will also close the underlying socket
> > > ssl_sock.close()
> > > The error I am getting is here:
> > >
> > > line 53 except socket.error as e ^ SyntaxError: invalid syntax
> > >
> > > I tried changing socket.error to ConnectionRefusedError. and still got
> > the same error.
> > >
> > > Please tell me if the problem is with Rstudio, Python version or the
> > syntax.
> > >
> > > TIA
> > > -Shaunak
> > > --
> > > https://mail.python.org/mailman/listinfo/python-list
> > 
> > Looks like you are missing a colon after 'as e'... as e:  might do
> > the trick
> > 
> > Nathan
> 
> Hi Nathan,
> 
> Tried colon and a comma as well. Both did not work.

Of course I am new to Python. I am wondering if it has to do anything with the 
indentation. Putting my most recent code here, again:

try :
# read line from file:
print(file.readline())
# parse
parse_json(file.readline())
count = count - 1
except socket.error as e:
print('Connection fail', e)
print(traceback.format_exc())
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue26287] Core dump in f-string with formatting errors due to refcount bug

2016-02-05 Thread Martin Panter

Martin Panter added the comment:

I have zero experience with with ceval.c but I have a theory after looking over 
revision 1ddeb2e175df. I suspect “value” is a borrowed reference from TOP(), 
but at  
and  you 
are calling DECREF on it without calling SET_TOP() if there is an error.

I suspected FORMAT_VALUE, because the crash doesn’t happen when you call 
format() directly.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Exception handling for socket.error in Python 3.5/RStudio

2016-02-05 Thread Martin A. Brown

Hi there Shaunak,

I saw your few replies to my (and Nathan's) quick identification of 
syntax error.  More comments follow, here.

>I am running this python script on R-studio. I have Python 3.5 installed on my 
>system.
>
>count = 10
>while (count > 0):
>try :
># read line from file:
>print(file.readline())
># parse
>parse_json(file.readline())
>count = count - 1
>except socket.error as e
>print('Connection fail', e)
>print(traceback.format_exc())
>
># wait for user input to end
># input("\n Press Enter to exit...");
># close the SSLSocket, will also close the underlying socket
>ssl_sock.close()
>
>The error I am getting is here:
>
>line 53 except socket.error as e ^ SyntaxError: invalid syntax
>
>I tried changing socket.error to ConnectionRefusedError. and still got the 
>same error.

We were assuming that line 53 in your file is the part you pasted 
above.  That clearly shows a syntax error (the missing colon).

If, after fixing that error, you are still seeing errors, then the 
probable explanations are:

  * you are not executing the same file you are editing

  * there is a separate syntax error elsewhere in the file (you sent
us only a fragment)

Additional points:

  * While the word 'file' is not reserved in Python 3.x, it is in 
Python 2.x, so, just be careful when working with older Python 
versions.  You could always change your variable name, but you 
do not need to.

  * When you catch the error in the above, you print the traceback 
information, but your loop will continue.  Is that what you 
desired?

I might suggest saving your work carefully and make sure that you 
are running the same code that you are working on.  Then, if you 
are still experiencing syntax errors, study the lines that the 
interpreter is complaining about.  And, of course, send the list an 
email.

Best of luck,

-Martin

-- 
Martin A. Brown
http://linux-ip.net/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: realtime output and csv files

2016-02-05 Thread Bernardo Sulzbach

On 02/05/2016 07:09 PM, lucan wrote:



What do you mean? What is "datas"? What do you mean by "correct"?


"datas" I mean the values for example temperature = 20.4 (so they are
floating point)

Index time temp
1 10:24 20.4
2 10:25 20.6
...

I wonder if this is correct "my way" to write a csv file:

file.write('\n'+str(index))
f.write(str(index)+','+str(now.hour)+':'+str(now.minute)+','+str(temp))

Or if there is a better way to do that.



If you got your newlines and headers (if the other program requires it) 
right, this should be all you need.

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


[issue26248] Improve scandir DirEntry docs, especially re symlinks and caching

2016-02-05 Thread Guido van Rossum

Guido van Rossum added the comment:

Thanks very much for all that added information!

--
resolution:  -> fixed
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Exception handling for socket.error in Python 3.5/RStudio

2016-02-05 Thread shaunak . bangale
On Friday, February 5, 2016 at 2:09:11 PM UTC-7, Bernardo Sulzbach wrote:
> On 02/05/2016 07:01 PM, Chris Angelico wrote:
> > On Sat, Feb 6, 2016 at 6:58 AM,   wrote:
> >> I am running this python script on R-studio. I have Python 3.5 installed 
> >> on my system.
> >>
> >
> > Let's just try a quick smoke test. Run this script:
> >
> > import sys
> > print(sys.version)
> > input("Press Enter to exit...")
> >
> > That'll tell you a few things about how your system is set up. Most
> > notably, if it doesn't say you're using Python 3.5, there's a problem.
> >
> > ChrisA
> >
> 
> Is there? If he just got the minor version wrong it wouldn't be a 
> problem. Unless RStudio requires 3.**5** for some reason.

Hi Chris,
Output:

3.5.0 (v3.5.0:374f501f4567, Sep 13 2015, 02:16:59) [MSC v.1900 32 bit (Intel)]

Hi Martin,

I do have the initiation command defined. Just that I am not allowed to make 
the username, pwd public.

I am absolutely sure I am running the same code. Now opened the same file with 
Python 3.5 shell and I get following error:

   from _ssl import RAND_status, RAND_egd, RAND_add
ImportError: cannot import name 'RAND_egd'

I am new to coding and this code has been borrowed from an online source but I 
can see same code working on mac+Rstudio+python combo.

Salute your patience.

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


[issue26293] Embedded zipfile fields dependent on absolute position

2016-02-05 Thread spoo

spoo added the comment:

I'm not familiar with iOS development, but I'd hazard a guess that "some zip 
library implementations" means a (the official?) iOS zip library.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



  1   2   >