Eventlet 0.14 released

2014-07-03 Thread Sergey Shepelev
Eventlet is a concurrent networking library for Python that allows you to 
change how you run your code, not how you write it. 

http://pypi.python.org/pypi/eventlet/0.15.0

This release features websocket13 support, improved PyPy compatibility and 
wheel package. Thanks to all contributors!

Huge part is work-in-progress Python3 support, already included in this 
release. Please try it with your projects, report issues here 
https://github.com/eventlet/eventlet/issues/new
hopefully, next release will officially support Python3!

News:
* Python3 compatibility -- **not ready yet**; Thanks to Astrum Kuo, Davanum 
Srinivas, Jakub Stasiak, Victor Sergeyev
* coros: remove Actor which was deprecated in 2010-01
* saranwrap: remove saranwrap which was deprecated in 2010-02
* PyPy compatibility fixes; Thanks to Dmitriy Kruglyak, Jakub Stasiak
* green.profile: accumulate results between runs; Thanks to Zhang Hua
* greenthread: add .unlink() method; Thanks to Astrum Kuo
* packaging: Generate universal wheels; Thanks to Jakub Stasiak
* queue: Make join not wait if there are no unfinished tasks; Thanks to Jakub 
Stasiak
* tpool: proxy __enter__, __exit__ fixes Bitbucket-158; Thanks to Eric Urban
* websockets: Add websockets13 support; handle lack of Upgrade header; Thanks 
to Edward George
* wsgi: capitalize_response_headers option

Our website: http://eventlet.net/
Direct package download links:
https://pypi.python.org/packages/source/e/eventlet/eventlet-0.15.0.tar.gz
https://pypi.python.org/packages/2.7/e/eventlet/eventlet-0.15.0-py2.py3-none-any.whl#md5=72403b5b4623e4802baf976f55b11a36
-- 
https://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations/


Re: how can i get the source code of goagent.exe?

2014-07-03 Thread Shiyao Ma
Ask on the goagent googlecode?


exe is fow win, dig out more on the linux version. I bet it should be
delivered with py source in that version.


Regards.

2014-07-03 10:20 GMT+08:00 liuerfire Wang liuerf...@gmail.com:
 Hi 水静流深
 the source code is on https://github.com/goagent/goagent

 Hi Terry,
 GoAgent, a tool to help cross the GFW, is written by Python not Go. So this
 may be not off-topic. :P


 On Thu, Jul 3, 2014 at 6:40 AM, 水静流深 1248283...@qq.com wrote:

 There is a open source project-goagent,when you download it and extract
 it,
 code.google.com/p/goagent/downloads‍

  in the local diretory, a file named goagent.exe in it.

 how can i get the source code of goagent.exe ,not the binary form ,the
 text form.




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




 --
 Best regards.
 /**
 google+: +liuerfire twitter: @liuerfire
 蛋疼不蛋疼的都可以试着点一下~^_^~
 ***/


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




-- 

吾輩は猫である。ホームーページはhttp://introo.me。
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: 1-0.95

2014-07-03 Thread Marko Rauhamaa
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info:

 On Wed, 02 Jul 2014 23:00:15 +0300, Marko Rauhamaa wrote:
 Steven D'Aprano steve+comp.lang.pyt...@pearwood.info:
 Rational(2).sqrt() * Rational(2).sqrt() == Rational(2)
False
 Square root of 2 is not a rational number.
 Nobody said it was. 

 Your comment can be read as implying it. You stated:

 [quote]
 Even arbitrary-precision RATIONALS [emphasis added] would 
 suffer from the same problem 
 [end quote]

 and then showed an invented example where you squared a NON-RATIONAL.

While √2 is irrational, the hypothetical Rational(2).sqrt() probably
would be another arbitrary-precision Rational number and thus,
necessarily an approximation.

That's completely analogous to Decimal(1) / Decimal(3) being an
approximation.

And the point: when dealing with real numbers on a computer, there's no
way to avoid approximations. If an aspiring programmer is dismayed at
the imprecision of 0.1, that probably wouldn't be the right moment to
talk about Decimal().

 By the way, there's no need to use an invented example. Here is an
 actual example:

 py import math
 py from fractions import Fraction
 py math.sqrt(Fraction(2))**2
 2.0004

Sure, although you were invoking arbitrary-precision rational numbers,
which Fraction() is not.

 I'm sorry Marko, have you not being paying attention? Have you ever
 done any numeric programming?

Your style is consistent and impeccable.

 Floating-point is *hard*, not perfect.

It can be both. The point is, regular floating point numbers will likely
the optimal choice for your numeric calculation needs. They are compact,
fast and readily supported by hardware and numeric software. Switching to
Decimal might give you a false sense of security.


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


Re: general module auditing

2014-07-03 Thread Mark Lawrence

On 03/07/2014 02:17, Rita wrote:


On Wed, Jul 2, 2014 at 2:46 PM, Irmen de Jong irmen.nos...@xs4all.nl
mailto:irmen.nos...@xs4all.nl wrote:

On 2-7-2014 4:04, Rita wrote:
  yes, this helps. But I want to know who uses the module, serpent.
So, when
  I upgrade it or remove it they won't be affected adversely.

(Please don't top-post, it makes the discussion harder to follow.)

  On Tue, Jul 1, 2014 at 2:16 PM, Irmen de Jong
irmen.nos...@xs4all.nl mailto:irmen.nos...@xs4all.nl
  wrote:
 
  On 1-7-2014 12:38, Rita wrote:
  i work in a group of developers (15 or so)  who are located
globally. I
  would like to know what modules everyone is uses if I ever have to
  upgrade
  my python. Is there mechanism which will let me see who is
using what?
 
  ie,
 
  tom,matplotlib
  bob, pylab
  nancy, numpy
  nancy, matplotlib
 
  etc...
 
 
 
  Well, if your group is all using Pip (and perhaps even
virtualenv), you
  could use pip
  list. In my case:
 
  $ pip list

[...]


Why would the fact that you upgrade or remove a package, affect
another developer in
your group? Are you all using the same machine to develop on, with
one Python installation?

I think you'll have to tell us some more details about the way you
work together before
we can give a meaningful answer to your question.

Irmen

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

we have a shared mount point which has our python install. we have 3
servers on one part of the campus  and 2 in another part.

I want to find out what packages our user base is using thats the final
goal. I can figure out who is using python by writing a wrapper but not
what module.

--
--- Get your facts first, then you can distort them as you please.--



You can check every users's program for import statements but do you 
really need to, why not check what's in the site-packages folder for 
your python install?


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


Mark Lawrence

---
This email is free from viruses and malware because avast! Antivirus protection 
is active.
http://www.avast.com


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


Re: Image Upload with FalconFramework

2014-07-03 Thread Mark Lawrence

On 03/07/2014 04:54, Peter Romfeld wrote:

Hi,

I am stuck at a simple image upload function, in django i just used:

for feature phones:
file = request.body

iOS with Form:
class ImageForm(forms.Form):
 image = forms.FileField()


What is forms?  image is defined at the class level, not the instance 
level, did you actually mean that?



form = ImageForm(request.POST, request.FILES)
file = request.FILES['image'].read()


file has been overwritten.



with falcon i tried but not working;
req.stream.read()


req is undefined here.



Cheers,
Peter



So please give us your OS and Python versions, the exact code that 
you've tried to run, how you've tried to run it, what you expected to 
happen and what actually happened including the complete traceback if any.


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


Mark Lawrence

---
This email is free from viruses and malware because avast! Antivirus protection 
is active.
http://www.avast.com


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


Re: TypeError expected in an augmented assignment

2014-07-03 Thread candide

   seq = [1,2]
 
   seq.extend((3,4))


OK, this feature is referenced in the Python Library reference here : 

https://docs.python.org/3.2/library/stdtypes.html#typesseq-mutable

not thoroughly referenced but, anyway, referenced.





 
   seq+= {5, 6}  # the order of extending is not determined
 
   seq
 
 [1, 2, 3, 4, 5, 6]
 
  

Good and interesting observation. But I can't find out where this feature is 
referenced in the Language/Library Reference. Because, as my first post 
explains, augmented assignment performs the binary operation associated to the 
augmented assignment, cf. 

https://docs.python.org/3.2/reference/simple_stmts.html#augmented-assignment-statements

so seq+= {5, 6} performs seq + {5, 6}, the later raising a TypeError.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Success with subprocess communicate on Windows?

2014-07-03 Thread Wolfgang Maier

On 07/03/2014 06:09 AM, Terry Reedy wrote:


Yes, but what puzzled me is that running
subprocess.check_output(r'pyflakes c:\programs\python34\lib')
in the regular interpreter *does* produce output instead of the error
message. My guess is that it fills up the pipe, so that check_output
starts reading the pipe long before pyflakes exits with status 1.

Hmm. I tried it again, and I see some but not all of the output I got at
the command line *and* I see the exit status message. So the subprocess
must get some of the output but then stop when it sees the exit status.
  Thanks.



For a partial explanation try this:

from the command line (again my path is slightly different):

pyflakes C:\Python34\lib  stdout.txt

this will still give you a few lines of output and these should be the 
same ones you're seeing from the python interpreter when you're doing:


subprocess.check_output(r'pyflakes C:\Python34\lib')

== pyflakes sends these lines to stderr instead of stdout !!

confirmation:

subprocess.check_output(r'pyflakes C:\Python34\lib', stderr=subprocess.PIPE)

and the output is gone.

So the remaining questions are:
- why on earth is pyflakes sending these lines (and only these) to stderr ?

- what is happening to the stderr output when run in IDLE ? I guess it 
is caught and suppressed somewhere, but to add to your observations the 
check_output call doesn't hang on IDLE, but finishes eventually with no 
output other than the traceback.


Best wishes,
Wolfgang

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


Re: TypeError expected in an augmented assignment

2014-07-03 Thread Chris Angelico
On Thu, Jul 3, 2014 at 5:51 PM, candide c.cand...@laposte.net wrote:
 Good and interesting observation. But I can't find out where this feature is 
 referenced in the Language/Library Reference. Because, as my first post 
 explains, augmented assignment performs the binary operation associated to 
 the augmented assignment, cf.

 https://docs.python.org/3.2/reference/simple_stmts.html#augmented-assignment-statements

 so seq+= {5, 6} performs seq + {5, 6}, the later raising a TypeError.

From that link:


An augmented assignment expression like x += 1 can be rewritten as x =
x + 1 to achieve a similar, but not exactly equal effect. In the
augmented version, x is only evaluated once. Also, when possible, the
actual operation is performed in-place, meaning that rather than
creating a new object and assigning that to the target, the old object
is modified instead.


The significance here is that the augmented assignment may not
necessarily be at all comparable to the non-augmented version, but
ought to have *approximately* the same *intention*. There are plenty
of situations where the two will differ, eg when there are multiple
references to the same object:

 a = b = [1,2]
 a += [3]
 a,b
([1, 2, 3], [1, 2, 3])
 a = a + [4]
 a,b
([1, 2, 3, 4], [1, 2, 3])

In its simplest form, x += 1 - x = x + 1, but there are plenty of
ways to distinguish them.

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


OT: speeds (physical, not computing) [was Re: 1-0.95]

2014-07-03 Thread Steven D'Aprano
On Wed, 02 Jul 2014 21:06:52 -0700, Rustom Mody wrote:

 On Thursday, July 3, 2014 7:49:30 AM UTC+5:30, Steven D'Aprano wrote:
 On Wed, 02 Jul 2014 23:00:15 +0300, Marko Rauhamaa wrote:
 
  On the other hand, floating-point numbers are perfect whenever you
  deal with science and measurement.
 
 /head-desk
 
 wink
 
 Just as there are even some esteemed members of this list who think that
 c - a is a meaningful operation
   where
 c is speed of light
 a is speed of an automobile
 
 
 /wink


You seem to be having some sort of nervous tic.

Subtracting two numbers a and c *is* a meaningful operation, even if they 
are speeds, and even in special relativity.

Consider an observer O in an inertial frame of reference. A car x is 
driving towards the observer at v metres per second, while a photon p 
travels away from the observer at c m/s:


x -- v  O p -- c


According to the observer, the difference in speeds between x and p is 
just (c - v), the same as in classic mechanics. The technical term for it 
is closing speed (or opening speed as the case may be) as seen by O.

Note that this is *not* the difference in speeds as observed by x, but I 
never said it was.


You don't have to believe me. You can believe the Physics FAQs, 
maintained by John Baez:

http://math.ucr.edu/home/baez/physics/Relativity/SR/velocity.html


The important part is the paragraph titled How can that be right? and 
ending In this sense velocities add according to ordinary vector 
addition.

As I wanted to confirm my understanding of the situation:

https://groups.google.com/forum/#!topic/sci.physics/BqT0p_7tHYg




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


Re: Success with subprocess communicate on Windows?

2014-07-03 Thread Wolfgang Maier

On 07/03/2014 10:03 AM, Wolfgang Maier wrote:

On 07/03/2014 06:09 AM, Terry Reedy wrote:

- what is happening to the stderr output when run in IDLE ? I guess it
is caught and suppressed somewhere, but to add to your observations the
check_output call doesn't hang on IDLE, but finishes eventually with no
output other than the traceback.


stderr output not being displayed in IDLE is mentioned in 
http://bugs.python.org/issue13582 .


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


Re: general module auditing

2014-07-03 Thread Rita
On Thu, Jul 3, 2014 at 2:54 AM, Mark Lawrence breamore...@yahoo.co.uk
wrote:

 On 03/07/2014 02:17, Rita wrote:


 On Wed, Jul 2, 2014 at 2:46 PM, Irmen de Jong irmen.nos...@xs4all.nl
 mailto:irmen.nos...@xs4all.nl wrote:

 On 2-7-2014 4:04, Rita wrote:
   yes, this helps. But I want to know who uses the module, serpent.
 So, when
   I upgrade it or remove it they won't be affected adversely.

 (Please don't top-post, it makes the discussion harder to follow.)

   On Tue, Jul 1, 2014 at 2:16 PM, Irmen de Jong
 irmen.nos...@xs4all.nl mailto:irmen.nos...@xs4all.nl

   wrote:
  
   On 1-7-2014 12:38, Rita wrote:
   i work in a group of developers (15 or so)  who are located
 globally. I
   would like to know what modules everyone is uses if I ever have
 to
   upgrade
   my python. Is there mechanism which will let me see who is
 using what?
  
   ie,
  
   tom,matplotlib
   bob, pylab
   nancy, numpy
   nancy, matplotlib
  
   etc...
  
  
  
   Well, if your group is all using Pip (and perhaps even
 virtualenv), you
   could use pip
   list. In my case:
  
   $ pip list

 [...]


 Why would the fact that you upgrade or remove a package, affect
 another developer in
 your group? Are you all using the same machine to develop on, with
 one Python installation?

 I think you'll have to tell us some more details about the way you
 work together before
 we can give a meaningful answer to your question.

 Irmen

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

 we have a shared mount point which has our python install. we have 3
 servers on one part of the campus  and 2 in another part.

 I want to find out what packages our user base is using thats the final
 goal. I can figure out who is using python by writing a wrapper but not
 what module.

 --
 --- Get your facts first, then you can distort them as you please.--


 You can check every users's program for import statements but do you
 really need to, why not check what's in the site-packages folder for your
 python install?

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

 Mark Lawrence

 ---
 This email is free from viruses and malware because avast! Antivirus
 protection is active.
 http://www.avast.com


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



how can i get frequency of the module usage? thats the end goal.

-- 
--- Get your facts first, then you can distort them as you please.--
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: TypeError expected in an augmented assignment

2014-07-03 Thread candide


 From that link:
 
 
 
 
 
 An augmented assignment expression like x += 1 can be rewritten as x =
 
 x + 1 to achieve a similar, but not exactly equal effect. In the
 
 augmented version, x is only evaluated once. Also, when possible, the
 
 actual operation is performed in-place, meaning that rather than
 
 creating a new object and assigning that to the target, the old object
 
 is modified instead.
 
 
 
 
 
 The significance here is that the augmented assignment may not
 
 necessarily be at all comparable to the non-augmented version, but
 
 ought to have *approximately* the same *intention*. 


This is not my reading. 




 
 of situations where the two will differ, eg when there are multiple
 
 references to the same object:
 
 
 
  a = b = [1,2]
 
  a += [3]
 
  a,b
 
 ([1, 2, 3], [1, 2, 3])
 
  a = a + [4]
 
  a,b
 
 ([1, 2, 3, 4], [1, 2, 3])
 
 

OK but this behavior is in conformance with the Reference Manual (cf. your 
quote above : when possible, the actual operation is performed in-place). 
This is not my point because the doc explictly claims that an augmented 
assignment [...] performs the binary operation specific to the type of 
assignment on the two operands.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: 1-0.95

2014-07-03 Thread Steven D'Aprano
On Thu, 03 Jul 2014 09:51:35 +0300, Marko Rauhamaa wrote:

 Steven D'Aprano steve+comp.lang.pyt...@pearwood.info:
[...]
 By the way, there's no need to use an invented example. Here is an
 actual example:

 py import math
 py from fractions import Fraction
 py math.sqrt(Fraction(2))**2
 2.0004
 
 Sure, although you were invoking arbitrary-precision rational numbers,
 which Fraction() is not.

In what way is Fraction not an arbitrary precision rational number? It's 
a rational number, and it can store numbers to any arbitrary precision 
you like (up to the limit of RAM) in any base you like. 

How about the smallest non-zero number representable in base 17 to 13004 
significant figures? I can represent that as a Fraction with no 
difficulty at all:

py x = 1/(Fraction(17)**13004)
py str(x)[:20] + ... + str(x)[-5:]
'1/572497511269282241...23521'


And it is calculated *exactly*.


Now, I admit that I have misgivings about using the term precision when 
it comes to discussing rational numbers, since the idea of significant 
figures doesn't really work very well with fraction notation. It's not 
clear to me how many significant figures x above should be described as 
having. The number of digits in its decimal expansion perhaps? But you 
started using the term, not me, so I'm just following your lead.

If you don't think Fraction counts as arbitrary precision rational 
number, what do you think does?



[...]
 Floating-point is *hard*, not perfect.
 
 It can be both. 

Perfect requires that it be flawless. It certainly is not flawless. As 
I have repeatedly stated, there are mathematical properties which 
floating point numbers do not obey. Given that they are supposed to model 
real numbers, the fact that they do not obey the mathematical laws 
applicable to real numbers is a pretty big flaw.


 The point is, regular floating point numbers will likely
 the optimal choice for your numeric calculation needs. They are compact,
 fast and readily supported by hardware and numeric software. Switching
 to Decimal might give you a false sense of security.

Ah, now this is a much more reasonable thing to say. Why didn't you say 
so in the first place? :-)




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


threading.Condition.wait() is not catching SIGTERM

2014-07-03 Thread Sangeeth Saravanaraj
Hi All, 

I have the following code which when executed waits to be interrupted by 
SIGINT, SIGTERM or SIGQUIT. When an object is initialized, it creates a 
threading.Condition() and acquires() it! The program then registers the signal 
handlers where notify() and release() is called when the above mentioned 
signals are received. After registering the signal handlers, it calls wait() on 
the condition variable and block.

When I tried to stop the program with Ctrl-C, its did not respond. IOW, the 
_signal_handler() method did not get called.  

# start

from signal import signal, SIGINT, SIGTERM, SIGQUIT
from threading import Condition

class A:
def __init__(self):
self._termination_signal = Condition()
self._termination_signal.acquire(blocking=0)

def _signal_handler(self, signum, frame):
print Received terminate request - signal = {0}.format(signum)
del frame
self._termination_signal.notify()
self._termination_signal.release()
return

def register_and_wait(self):
signal(SIGINT, self._signal_handler)
signal(SIGTERM, self._signal_handler)
signal(SIGQUIT, self._signal_handler)
print Waiting to be interrupted!
self._termination_signal.wait()  # control blocks here!
print Notified!!

def main():
a = A()
a.register_and_wait()

if __name__ == __main__:
main()

# end

What am I doing wrong?! 

Thank you,

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


Re: threading.Condition.wait() is not catching SIGTERM

2014-07-03 Thread Roy Smith
In article mailman.11450.1404382552.18130.python-l...@python.org,
 Sangeeth Saravanaraj sangeeth.saravana...@gmail.com wrote:

 Hi All, 
 
 I have the following code which when executed waits to be interrupted by 
 SIGINT, SIGTERM or SIGQUIT.

We need more information.  What version of Python are you using?  And, 
what operating system is this running on?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: threading.Condition.wait() is not catching SIGTERM

2014-07-03 Thread Sangeeth Saravanaraj

On 03-Jul-2014, at 3:49 pm, Roy Smith r...@panix.com wrote:

 In article mailman.11450.1404382552.18130.python-l...@python.org,
 Sangeeth Saravanaraj sangeeth.saravana...@gmail.com wrote:
 
 Hi All, 
 
 I have the following code which when executed waits to be interrupted by 
 SIGINT, SIGTERM or SIGQUIT.
 
 We need more information.  What version of Python are you using?  And, 
 what operating system is this running on?

I am using Python 2.7.7 and running this code on MacOS Darwin Kernel 13.2.0

But does the behavior of threading.Condition.wait() depends on operating 
system?! 

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

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


Re: threading.Condition.wait() is not catching SIGTERM

2014-07-03 Thread Chris Angelico
On Thu, Jul 3, 2014 at 8:27 PM, Sangeeth Saravanaraj
sangeeth.saravana...@gmail.com wrote:
 But does the behavior of threading.Condition.wait() depends on operating 
 system?!

The behaviour of signals certainly does - there's a huge difference
between Windows and POSIX, and there are lesser differences between
Linux and Mac OS, and so on. It's just safest to say exactly what
platform, in case it matters.

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


Re: 1-0.95

2014-07-03 Thread Marko Rauhamaa
Steven D'Aprano st...@pearwood.info:

 If you don't think Fraction counts as arbitrary precision rational 
 number, what do you think does?

I was assuming you were referring to an idealized datatype.

Fraction() doesn't have a square root method. Let's make one:

   def newton(x, n):
   guess = Fraction(1)
   for i in range(n):
   guess = (guess + x / guess) / 2
   return guess

newton(Fraction(2), 3)
   Fraction(577, 408)
newton(Fraction(2), 8)
   Fraction(489266466344238819545868088398566945584921822586685371455477\
   00898547222910968507268117381704646657,
   345963636159190997653185453890148615173898600719883426481871047662465\
   65694525469768325292176831232)
newton(Fraction(2), 18)

   ... keeps going and going and going ...

Point being, if you have trouble with floats, you will likely have it
with Decimal(), Fraction(), super-duper Rational(), Algebraic(),
Expressible(), you name it. You'll just have to develop an understanding
of numeric computation.

BTW, the same thing applies to integers, also. While Python has
abstracted out many of the 2's-complement arithmetic details, the bits
shine through.

 The point is, regular floating point numbers will likely the optimal
 choice for your numeric calculation needs. They are compact, fast and
 readily supported by hardware and numeric software. Switching to
 Decimal might give you a false sense of security.

 Ah, now this is a much more reasonable thing to say. Why didn't you
 say so in the first place? :-)

That's all I've been saying all along.


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


Re: general module auditing

2014-07-03 Thread Mark Lawrence

On 03/07/2014 10:27, Rita wrote:




On Thu, Jul 3, 2014 at 2:54 AM, Mark Lawrence breamore...@yahoo.co.uk
mailto:breamore...@yahoo.co.uk wrote:

On 03/07/2014 02:17, Rita wrote:


On Wed, Jul 2, 2014 at 2:46 PM, Irmen de Jong
irmen.nos...@xs4all.nl mailto:irmen.nos...@xs4all.nl
mailto:irmen.nos...@xs4all.nl
mailto:irmen.nos...@xs4all.nl__ wrote:

 On 2-7-2014 4:04, Rita wrote:
   yes, this helps. But I want to know who uses the module,
serpent.
 So, when
   I upgrade it or remove it they won't be affected adversely.

 (Please don't top-post, it makes the discussion harder to
follow.)

   On Tue, Jul 1, 2014 at 2:16 PM, Irmen de Jong
 irmen.nos...@xs4all.nl mailto:irmen.nos...@xs4all.nl
mailto:irmen.nos...@xs4all.nl mailto:irmen.nos...@xs4all.nl__

   wrote:
  
   On 1-7-2014 12:38, Rita wrote:
   i work in a group of developers (15 or so)  who are
located
 globally. I
   would like to know what modules everyone is uses if I
ever have to
   upgrade
   my python. Is there mechanism which will let me see who is
 using what?
  
   ie,
  
   tom,matplotlib
   bob, pylab
   nancy, numpy
   nancy, matplotlib
  
   etc...
  
  
  
   Well, if your group is all using Pip (and perhaps even
 virtualenv), you
   could use pip
   list. In my case:
  
   $ pip list

 [...]


 Why would the fact that you upgrade or remove a package, affect
 another developer in
 your group? Are you all using the same machine to develop
on, with
 one Python installation?

 I think you'll have to tell us some more details about the
way you
 work together before
 we can give a meaningful answer to your question.

 Irmen

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

we have a shared mount point which has our python install. we have 3
servers on one part of the campus  and 2 in another part.

I want to find out what packages our user base is using thats
the final
goal. I can figure out who is using python by writing a wrapper
but not
what module.

--
--- Get your facts first, then you can distort them as you please.--


You can check every users's program for import statements but do you
really need to, why not check what's in the site-packages folder for
your python install?

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

Mark Lawrence

how can i get frequency of the module usage? thats the end goal.

--
--- Get your facts first, then you can distort them as you please.--




Count the number of imports or count the times a given program gets run 
for the number of imports depending on what you mean.


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


Mark Lawrence

---
This email is free from viruses and malware because avast! Antivirus protection 
is active.
http://www.avast.com


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


Re: TypeError expected in an augmented assignment

2014-07-03 Thread Mark Lawrence

On 03/07/2014 10:35, candide wrote:




From that link:





An augmented assignment expression like x += 1 can be rewritten as x =

x + 1 to achieve a similar, but not exactly equal effect. In the

augmented version, x is only evaluated once. Also, when possible, the

actual operation is performed in-place, meaning that rather than

creating a new object and assigning that to the target, the old object

is modified instead.





The significance here is that the augmented assignment may not

necessarily be at all comparable to the non-augmented version, but

ought to have *approximately* the same *intention*.



This is not my reading.






of situations where the two will differ, eg when there are multiple

references to the same object:




a = b = [1,2]



a += [3]



a,b


([1, 2, 3], [1, 2, 3])


a = a + [4]



a,b


([1, 2, 3, 4], [1, 2, 3])




OK but this behavior is in conformance with the Reference Manual (cf. your quote above : when 
possible, the actual operation is performed in-place). This is not my point because the doc 
explictly claims that an augmented assignment [...] performs the binary operation specific to 
the type of assignment on the two operands.



To get the wording changed to satisfy yourself, either raise an issue on 
the bug tracker at bugs.python.org and attach a patch file, or send an 
email with suggested wording to d...@python.org.


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


Mark Lawrence

---
This email is free from viruses and malware because avast! Antivirus protection 
is active.
http://www.avast.com


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


Re: OOP with MyTime

2014-07-03 Thread kjakupak
On Wednesday, July 2, 2014 4:02:00 PM UTC-4, MRAB wrote:
 
 
 If you want 'between' to be an instance method of the MyTime class, it
 
 needs 'self' as well as the 2 arguments 't1' and 't2'.
 
 
 
 You can then compare the hours, minutes and seconds of self against
 
 those of t1 and t2:
 
 
 
  def between(self, t1, t2):
 
  return (t1.hours, t1.minutes, t1.seconds) = (self.hours, 
 
 self.minutes, self.seconds) and (self.hours, self.minutes, self.seconds) 
 
 = (t2.hours, t2.minutes, t2.seconds)
 
 
 
 That could be shortened further using chained comparisons.
 
 
 
 Note that the code assumes that the times t1 and t2 are ordered, i.e.
 
 that time t1 is not later/greater than time t2.

So I've now gotten this:
class MyTime:

def __init__(self, hrs=0, mins=0, secs=0):
self.hours = hrs
self.minutes = mins
self.seconds = secs

if self.seconds = 60:
self.minutes += self.seconds // 60
self.seconds = self.seconds % 60

if self.minutes = 60:
self.hours += self.minutes // 60
self.minutes = self.minutes % 60

if self.hours = 24:
self.hours = self.hours % 24

def get_sec(self):
return (self.hours * 60 + self.minutes) * 60 + self.seconds

def __str__(self):
return {:02d}:{:02d}:{:02d}.\
   format(self.hours, self.minutes, self.seconds)

def between(self, t1, t2):
return (t1.hours, t1.minutes, t1.seconds) = (self.hours, self.minutes, 
self.seconds) and (self.hours, self.minutes, self.seconds) = (t2.hours, 
t2.minutes, t2.seconds)


t1 = MyTime(9, 59, 59)
print(t1 =, t1)

t2 = MyTime(10, 0, 1)
print(t2 =, t2)

t3 = MyTime(10, 0, 0)
print(t3 =, t3)

print(between(t2, t3, t1) =, between(t2, t3, t1))
print(between(t1, t3, t2) =, between(t1, t3, t2))
print(between(t3, t1, t2) =, between(t3, t1, t2))
print(between(t1, t2, t3) =, between(t1, t2, t3))

Am I on the right track or? Not sure where to go from here
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: OOP with MyTime

2014-07-03 Thread Chris Angelico
On Thu, Jul 3, 2014 at 10:51 PM,  kjaku...@gmail.com wrote:
 So I've now gotten this:
 class MyTime:
 def between(self, t1, t2):
 return (t1.hours, t1.minutes, t1.seconds) = (self.hours, 
 self.minutes, self.seconds) and (self.hours, self.minutes, self.seconds) = 
 (t2.hours, t2.minutes, t2.seconds)
 print(between(t2, t3, t1) =, between(t2, t3, t1))

And what happens when you run this code? A NameError, I would expect.
Do you understand how to define and call methods?

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


Re: OOP with MyTime

2014-07-03 Thread kjakupak
On Thursday, July 3, 2014 9:01:09 AM UTC-4, Chris Angelico wrote:
 
 
 
 And what happens when you run this code? A NameError, I would expect.
 
 Do you understand how to define and call methods?
 
 
 
 ChrisA

Altered the code. But yes a nameerror came up

class MyTime:

def __init__(self, hrs=0, mins=0, secs=0):
self.hours = hrs
self.minutes = mins
self.seconds = secs

if self.seconds = 60:
self.minutes += self.seconds // 60
self.seconds = self.seconds % 60

if self.minutes = 60:
self.hours += self.minutes // 60
self.minutes = self.minutes % 60

if self.hours = 24:
self.hours = self.hours % 24

def get_sec(self):
return (self.hours * 60 + self.minutes) * 60 + self.seconds

def __str__(self):
return {:02d}:{:02d}:{:02d}.\
   format(self.hours, self.minutes, self.seconds)

def between(self, t1, t2):
return (t1.get_sec() = (self.get_sec()) and (self.get_sec()) = 
(t2.get_sec())

s = MyTime()
t1 = s(9, 59, 59)
print(t1 =, t1)

t2 = s(10, 0, 1)
print(t2 =, t2)

t3 = s(10, 0, 0)
print(t3 =, t3)

print(between(t2, t3, t1) =, s.between(t2, t3, t1))
print(between(t1, t3, t2) =, s.between(t1, t3, t2))
print(between(t3, t1, t2) =, s.between(t3, t1, t2))
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: OOP with MyTime

2014-07-03 Thread MRAB

On 2014-07-03 13:51, kjaku...@gmail.com wrote:

On Wednesday, July 2, 2014 4:02:00 PM UTC-4, MRAB wrote:



If you want 'between' to be an instance method of the MyTime class, it

needs 'self' as well as the 2 arguments 't1' and 't2'.



You can then compare the hours, minutes and seconds of self against

those of t1 and t2:



 def between(self, t1, t2):

 return (t1.hours, t1.minutes, t1.seconds) = (self.hours,

self.minutes, self.seconds) and (self.hours, self.minutes, self.seconds)

= (t2.hours, t2.minutes, t2.seconds)



That could be shortened further using chained comparisons.



Note that the code assumes that the times t1 and t2 are ordered, i.e.

that time t1 is not later/greater than time t2.


So I've now gotten this:
class MyTime:

 def __init__(self, hrs=0, mins=0, secs=0):
 self.hours = hrs
 self.minutes = mins
 self.seconds = secs

 if self.seconds = 60:
 self.minutes += self.seconds // 60
 self.seconds = self.seconds % 60

 if self.minutes = 60:
 self.hours += self.minutes // 60
 self.minutes = self.minutes % 60

 if self.hours = 24:
 self.hours = self.hours % 24

 def get_sec(self):
 return (self.hours * 60 + self.minutes) * 60 + self.seconds

 def __str__(self):
 return {:02d}:{:02d}:{:02d}.\
format(self.hours, self.minutes, self.seconds)

 def between(self, t1, t2):
 return (t1.hours, t1.minutes, t1.seconds) = (self.hours, self.minutes, 
self.seconds) and (self.hours, self.minutes, self.seconds) = (t2.hours, 
t2.minutes, t2.seconds)


t1 = MyTime(9, 59, 59)
print(t1 =, t1)

t2 = MyTime(10, 0, 1)
print(t2 =, t2)

t3 = MyTime(10, 0, 0)
print(t3 =, t3)

print(between(t2, t3, t1) =, between(t2, t3, t1))
print(between(t1, t3, t2) =, between(t1, t3, t2))
print(between(t3, t1, t2) =, between(t3, t1, t2))
print(between(t1, t2, t3) =, between(t1, t2, t3))

Am I on the right track or? Not sure where to go from here


You need to decide whether you want 'between' to be a method of the
MyTime class or a separate function.

In the above code it's defined as a method, so you can say:

t2.between(t3, t1)

which means is t2 between t3 and t1?.

That would return False because t3 is greater than t1, but:

t2.between(t1, t3)

would return True.

(I _did_ say that it assumes that the times are ordered.)

BTW, gmail is messing up your messages. This will tell you how to fix
it:

https://wiki.python.org/moin/GoogleGroupsPython

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


Re: OOP with MyTime

2014-07-03 Thread Chris Angelico
On Thu, Jul 3, 2014 at 11:08 PM,  kjaku...@gmail.com wrote:
 Altered the code. But yes a nameerror came up

When that sort of thing happens, you have three basic approaches to
solving the problem.

1) Read the traceback, look at the line of code it points to, and see
if you can figure out what it means.
2) Post here with the full traceback so we have a chance of being able
to help you
3) Play 20 questions with us, while making the gathering of
information as hard as pulling teeth.

Suggestion: The third option is the least effective. :)

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


Re: OOP with MyTime

2014-07-03 Thread kjakupak
On Thursday, July 3, 2014 9:11:49 AM UTC-4, MRAB wrote:
 On 2014-07-03 13:51, kjaku...@gmail.com wrote:
 
  On Wednesday, July 2, 2014 4:02:00 PM UTC-4, MRAB wrote:
 
  
 
 
 
  If you want 'between' to be an instance method of the MyTime class, it
 
 
 
  needs 'self' as well as the 2 arguments 't1' and 't2'.
 
 
 
 
 
 
 
  You can then compare the hours, minutes and seconds of self against
 
 
 
  those of t1 and t2:
 
 
 
 
 
 
 
   def between(self, t1, t2):
 
 
 
   return (t1.hours, t1.minutes, t1.seconds) = (self.hours,
 
 
 
  self.minutes, self.seconds) and (self.hours, self.minutes, self.seconds)
 
 
 
  = (t2.hours, t2.minutes, t2.seconds)
 
 
 
 
 
 
 
  That could be shortened further using chained comparisons.
 
 
 
 
 
 
 
  Note that the code assumes that the times t1 and t2 are ordered, i.e.
 
 
 
  that time t1 is not later/greater than time t2.
 
 
 
  So I've now gotten this:
 
  class MyTime:
 
 
 
   def __init__(self, hrs=0, mins=0, secs=0):
 
   self.hours = hrs
 
   self.minutes = mins
 
   self.seconds = secs
 
 
 
   if self.seconds = 60:
 
   self.minutes += self.seconds // 60
 
   self.seconds = self.seconds % 60
 
 
 
   if self.minutes = 60:
 
   self.hours += self.minutes // 60
 
   self.minutes = self.minutes % 60
 
 
 
   if self.hours = 24:
 
   self.hours = self.hours % 24
 
 
 
   def get_sec(self):
 
   return (self.hours * 60 + self.minutes) * 60 + self.seconds
 
 
 
   def __str__(self):
 
   return {:02d}:{:02d}:{:02d}.\
 
  format(self.hours, self.minutes, self.seconds)
 
 
 
   def between(self, t1, t2):
 
   return (t1.hours, t1.minutes, t1.seconds) = (self.hours, 
  self.minutes, self.seconds) and (self.hours, self.minutes, self.seconds) = 
  (t2.hours, t2.minutes, t2.seconds)
 
 
 
 
 
  t1 = MyTime(9, 59, 59)
 
  print(t1 =, t1)
 
 
 
  t2 = MyTime(10, 0, 1)
 
  print(t2 =, t2)
 
 
 
  t3 = MyTime(10, 0, 0)
 
  print(t3 =, t3)
 
 
 
  print(between(t2, t3, t1) =, between(t2, t3, t1))
 
  print(between(t1, t3, t2) =, between(t1, t3, t2))
 
  print(between(t3, t1, t2) =, between(t3, t1, t2))
 
  print(between(t1, t2, t3) =, between(t1, t2, t3))
 
 
 
  Am I on the right track or? Not sure where to go from here
 
 
 
 You need to decide whether you want 'between' to be a method of the
 
 MyTime class or a separate function.
 
 
 
 In the above code it's defined as a method, so you can say:
 
 
 
  t2.between(t3, t1)
 
 
 
 which means is t2 between t3 and t1?.
 
 
 
 That would return False because t3 is greater than t1, but:
 
 
 
  t2.between(t1, t3)
 
 
 
 would return True.
 
 
 
 (I _did_ say that it assumes that the times are ordered.)
 
 
 
 BTW, gmail is messing up your messages. This will tell you how to fix
 
 it:
 
 
 
 https://wiki.python.org/moin/GoogleGroupsPython

I keep getting an invalid syntax on the t1 = (9, 59, 59) line, not sure why?

t1 = (9, 59, 59)
print(t1 =, t1)

t2 = (10, 0, 1)
print(t2 =, t2)

t3 = (10, 0, 0)
print(t3 =, t3)

print(between(t2, t3, t1) =, t2.between(t3, t1))
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: OOP with MyTime

2014-07-03 Thread Chris Angelico
On Fri, Jul 4, 2014 at 1:21 AM,  kjaku...@gmail.com wrote:
 I keep getting an invalid syntax on the t1 = (9, 59, 59) line, not sure why?

 t1 = (9, 59, 59)

Two points. Firstly, as I said before, posting the entire exception
helps us enormously. Secondly, with most computerized parsers, the
file is processed top-down, left-to-right, so it's possible for a
syntax error to be discovered a bit after where it actually happens -
but not before. So when you get parsing errors, check the immediately
preceding line; sometimes it's there. Since you haven't shown us that
line, we have no idea what's happening. Showing us the code below the
highlighted error line is of no value; showing us the code before that
line is helpful.

Also: Please don't use Google Groups, or if you must, please clean up
its messes.

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


Re: OOP with MyTime

2014-07-03 Thread Mark Lawrence

On 03/07/2014 16:21, kjaku...@gmail.com wrote:

On Thursday, July 3, 2014 9:11:49 AM UTC-4, MRAB wrote:


I'm pleased to see that you have answers.  In return would you please 
use the mailing list 
https://mail.python.org/mailman/listinfo/python-list or read and action 
this https://wiki.python.org/moin/GoogleGroupsPython to prevent us 
seeing double line spacing and single line paragraphs, thanks.


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


Mark Lawrence

---
This email is free from viruses and malware because avast! Antivirus protection 
is active.
http://www.avast.com


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


PEP8 and 4 spaces

2014-07-03 Thread Tobiah

Coworker takes PEP8 as gospel and uses 4 spaces
to indent.  I prefer tabs.  Boss want's us to
unify.  The sole thing you get with spaces as
far as I can tell, is that someone loading the
code into Notepad will still see a 4 character
indent.  That may be true, but that same person
is going to have a difficult time editing the
code.

Anyway, I gave up the 80 char line length long
ago, having little feeling for some dolt on
a Weiss terminal that for some reason needs to
edit my code.  I feel rather the same about the
spaces and tabs, given that most people seem to
be using editors these days that are configurable
to show tabs a four characters.

Any evidence out there that this part of PEP8 is becoming
more optional or even obsolete, as I've heard others
say about the 80 char line length?

Just need ammo for when the hammer of code
unification comes down.

Thanks,

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


Re: PEP8 and 4 spaces

2014-07-03 Thread Chris Angelico
On Fri, Jul 4, 2014 at 3:31 AM, Tobiah tshep...@rcsreg.com wrote:
 Coworker takes PEP8 as gospel and uses 4 spaces
 to indent.  I prefer tabs.  Boss want's us to
 unify.

1) PEP 8 is meant to be guidelines, *not* a set of hard-and-fast rules.
2) Tabs let different people display the indents at different widths.
You want it to look like four spaces? No problem. You think it looks
better at eight? Fine, set your display to eight. Easy.
3) Perhaps most importantly: You don't have to unify. Let your source
control system do the work for you. In git, that's the smudge/clean
filters and gitattributes; I don't know the mechanics in hg, but I'm
sure it'll exist; in other systems, you might have to rig something
up, or dig through the docs. But you should be able to settle on one
thing in source control and let everyone check out files in whatever
way they like.

Personally, I like, use, and recommend, tabs - but the next best thing
to tabs is a consistent number of spaces (preferably four). But if you
can't make your tools handle the difference, you're going to be
putting unnecessary strains on the humans. Let the humans work with
whatever they prefer.

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


Re: PEP8 and 4 spaces

2014-07-03 Thread Roy Smith
In article mailman.11462.1404408676.18130.python-l...@python.org,
 Tobiah tshep...@rcsreg.com wrote:

 Coworker takes PEP8 as gospel and uses 4 spaces
 to indent.  I prefer tabs.
 [...]
 Just need ammo for when the hammer of code
 unification comes down.

There are so many battles to fight that are worth fighting.  This isn't 
one of them.  Just go with pep-8 and move on to solving real problems.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PEP8 and 4 spaces

2014-07-03 Thread Peter Otten
Tobiah wrote:

 Coworker takes PEP8 as gospel and uses 4 spaces
 to indent.  I prefer tabs.  Boss want's us to
 unify.  The sole thing you get with spaces as
 far as I can tell, is that someone loading the
 code into Notepad will still see a 4 character
 indent.  That may be true, but that same person
 is going to have a difficult time editing the
 code.
 
 Anyway, I gave up the 80 char line length long
 ago, having little feeling for some dolt on
 a Weiss terminal that for some reason needs to
 edit my code.  I feel rather the same about the
 spaces and tabs, given that most people seem to
 be using editors these days that are configurable
 to show tabs a four characters.
 
 Any evidence out there that this part of PEP8 is becoming
 more optional or even obsolete, as I've heard others
 say about the 80 char line length?
 
 Just need ammo for when the hammer of code
 unification comes down.

Indentation: more important than what convention is chosen is that a
convention is chosen. Relax and follow your collegue's example.

As to the line length: how do you manage to exceed the 80-char limit? Deep
nesting, long variable names, complex expressions? All of these often make
it worthwhile refactoring the code even with a lot of horizonal space left
blank on the monitor.

Also: you can probably come up with five aspects that affect the quality of 
your company's code more than the above superficial points and that are hard 
to fix. So pick your fights and attack the most relevant issue.

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


Re: PEP8 and 4 spaces

2014-07-03 Thread Toby Shepard

On 07/03/2014 10:46 AM, Tim Chase wrote:

Any evidence out there that this part of PEP8 is becoming
more optional or even obsolete, as I've heard others
say about the 80 char line length?

Just need ammo for when the hammer of code
unification comes down.


I'm not sure you'll get a whole lot of PEP8 is optional or
obsolete, though some may protest the 80-char suggestion.

While I prefer tabs for similar reasons you present (I can set them
to display at whatever width is comfortable), I have Vim configured
to expand tabs into spaces so that my code conforms to standards.

If you're really picky about it, just create hooks in your VCS (you
ARE using revision control, right?) that turn
$STANDARD_NUMBER_OF_SPACES into a tabs at checkout, and then revert
tabs back to that number of spaces pre-commit.  For git, this SO
post covers it:

http://stackoverflow.com/questions/2316677/can-git-automatically-switch-between-spaces-and-tabs



Very interesting.  Yes, we're using Git.  Thanks for the suggestion.

Tobiah

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


Re: PEP8 and 4 spaces

2014-07-03 Thread Paul Sokolovsky
Hello,

On Fri, 4 Jul 2014 03:38:27 +1000
Chris Angelico ros...@gmail.com wrote:

 On Fri, Jul 4, 2014 at 3:31 AM, Tobiah tshep...@rcsreg.com wrote:
  Coworker takes PEP8 as gospel and uses 4 spaces
  to indent.  I prefer tabs.  Boss want's us to
  unify.
 
 1) PEP 8 is meant to be guidelines, *not* a set of hard-and-fast
 rules. 
 2) Tabs let different people display the indents at different
 widths. 

That's exactly the problem with tabs - whatever you think your code
looks like with tabs, other people will see quite different picture.

Also, most people are not interested in doing mumbo-jumbo with tabs
settings, and have them set to standard 8-char tabs. So, any python
code which uses only tabs for indentation automatically violates
4-space convention (and mixing tabs and spaces is nowadays prohibited
in Python).

Summing up: if you care about other human beings, use spaces. If you
don't care about other human beings, you may use tabs, but other human
beings surely will take how you treat them into account ;-).


-- 
Best regards,
 Paul  mailto:pmis...@gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PEP8 and 4 spaces

2014-07-03 Thread Grant Edwards
On 2014-07-03, Tobiah tshep...@rcsreg.com wrote:

 Coworker takes PEP8 as gospel and uses 4 spaces to indent.  I prefer
 tabs.  Boss want's us to unify.  The sole thing you get with spaces
 as far as I can tell, is that someone loading the code into Notepad
 will still see a 4 character indent.

Or any editor at all.

 That may be true, but that same person is going to have a difficult
 time editing the code.

That's true with Notepad, but with dozens of other programming
editors, code indented with spaces will read and edit prefectly.
Not so for tab-indented code.

 Anyway, I gave up the 80 char line length long ago, having little
 feeling for some dolt

Same to you.

 on a Weiss terminal that for some reason needs to edit my code.  I
 feel rather the same about the spaces and tabs, given that most
 people seem to be using editors these days that are configurable to
 show tabs a four characters.

 Any evidence out there that this part of PEP8 is becoming more
 optional or even obsolete, as I've heard others say about the 80 char
 line length?

 Just need ammo for when the hammer of code unification comes down.

Just do the right thing and configure your editor to indent with
spaces.

-- 
Grant Edwards   grant.b.edwardsYow! Am I SHOPLIFTING?
  at   
  gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PEP8 and 4 spaces

2014-07-03 Thread Tim Chase
 Any evidence out there that this part of PEP8 is becoming
 more optional or even obsolete, as I've heard others
 say about the 80 char line length?
 
 Just need ammo for when the hammer of code
 unification comes down.

I'm not sure you'll get a whole lot of PEP8 is optional or
obsolete, though some may protest the 80-char suggestion.

While I prefer tabs for similar reasons you present (I can set them
to display at whatever width is comfortable), I have Vim configured
to expand tabs into spaces so that my code conforms to standards.

If you're really picky about it, just create hooks in your VCS (you
ARE using revision control, right?) that turn
$STANDARD_NUMBER_OF_SPACES into a tabs at checkout, and then revert
tabs back to that number of spaces pre-commit.  For git, this SO
post covers it:

http://stackoverflow.com/questions/2316677/can-git-automatically-switch-between-spaces-and-tabs

-tkc



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


Re: PEP8 and 4 spaces

2014-07-03 Thread Tim Chase
On 2014-07-03 19:02, Grant Edwards wrote:
  That may be true, but that same person is going to have a
  difficult time editing the code.  
 
 That's true with Notepad, but with dozens of other programming
 editors, code indented with spaces will read and edit prefectly.
 Not so for tab-indented code.

A broken editor isn't the world's best argument.  If I used an editor
that changed my line-endings, randomly altered arbitrary characters,
or tried to compress multiple spaces into one, I'd complain that the
editor was broken.  If a file has tab characters and my editor
doesn't let me properly deal with tab characters, then THE EDITOR IS
BROKEN.

That said, even though I'm -0 on use 4 spaces rather than tabs, I
conform to the standard to reduce interop headache even if I'd rather
use tabs.

-tkc



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


Re: threading.Condition.wait() is not catching SIGTERM

2014-07-03 Thread Ned Deily
In article 17f05a1b-44c8-4f25-afe9-5dbcffb99...@gmail.com,
 I have the following code which when executed waits to be interrupted by 
 SIGINT, SIGTERM or SIGQUIT. When an object is initialized, it creates a 
 threading.Condition() and acquires() it! The program then registers the 
 signal handlers where notify() and release() is called when the above 
 mentioned signals are received. After registering the signal handlers, it 
 calls wait() on the condition variable and block.
 
 When I tried to stop the program with Ctrl-C, its did not respond. IOW, the 
 _signal_handler() method did not get called.  

I'm not sure what you are trying to do but your test case seems flawed.  
threading.Condition is designed to be used with multiple threads but 
your test doesn't actually use threads.  If you run your test with a 
reasonably current Python 3 (after changing print to print()), you can 
see that it fails (and why it fails) when interrupting with Ctrl-C:

Waiting to be interrupted!
^CReceived terminate request - signal = 2
Traceback (most recent call last):
  File b.py, line 30, in module
main()
  File b.py, line 27, in main
a.register_and_wait()
  File b.py, line 22, in register_and_wait
self._termination_signal.wait()  # control blocks here!
  File 
/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/threadin
g.py, line 289, in wait
waiter.acquire()
  File b.py, line 13, in _signal_handler
self._termination_signal.notify()
  File 
/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/threadin
g.py, line 339, in notify
raise RuntimeError(cannot notify on un-acquired lock)
RuntimeError: cannot notify on un-acquired lock

After a quick glance, I'm not sure why Python 2.7 is behaving 
differently, e.g. not raising an error, since both versions of 
Condition.notify have the same test so the difference is elsewhere.  
Feel free to open an issue for not catching the error in 2.7 but you 
should rethink what you are trying to do here.

-- 
 Ned Deily,
 n...@acm.org

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


Re: PEP8 and 4 spaces

2014-07-03 Thread Toby Shepard

On 07/03/2014 12:44 PM, Simon Ward wrote:



On 3 July 2014 18:31:04 BST, Tobiah tshep...@rcsreg.com wrote:

Coworker takes PEP8 as gospel and uses 4 spaces to indent.  I
prefer tabs.  Boss want's us to unify.


This isn't worth arguing about.


How point of view changes things.




Anyway, I gave up the 80 char line length long ago, having little
feeling for some dolt on a Weiss terminal that for some reason
needs to edit my code.


Putting the code factoring considerations aside, because others have
already mentioned them and I'm sure others will, there are some other
practical reasons for limiting line width:


All that is fine, and makes great sense.  I generally write short lines.
I know the tricks for splitting otherwise long lines into multiple readable
lines.  I'm not advocating that we use semicolons and always go past 80
characters.  I'm just saying that once in a while it makes sense to me
to do it, and I don't lose sleep when it happens.
 

I feel rather the same about the spaces and tabs, given that most
people seem to be using editors these days that are configurable to
show tabs a four characters.


Conversely, those same editors can probably automatically indent and
unindent a configurable amount of spaces. If you don't use such an
editor, and you really can't tolerate the different style, you can
use another tool to reindent your code.


It works both ways.  I'm using Vim, and it will handle the spaces
and give a tab-like experience - not quite as good, but good enough
to live with.  Either of us could give in.  The boss likes tabs,
as I do.  The coworker really only has PEP8 to point to.  There is
really nothing good about the space way, other than as I said, Notepad
users will see four space indents.  Most other users can configure the tabstop
as they like *if* tabs are being used.  The Notepad users will get by just fine.

It could fall either way.  I was just trying to nudge it toward mine.

Tobiah

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


Re: threading.Condition.wait() is not catching SIGTERM

2014-07-03 Thread Roy Smith
In article mailman.11469.1404418450.18130.python-l...@python.org,
 Ned Deily n...@acm.org wrote:

 In article 17f05a1b-44c8-4f25-afe9-5dbcffb99...@gmail.com,
  I have the following code which when executed waits to be interrupted by 
  SIGINT, SIGTERM or SIGQUIT. When an object is initialized, it creates a 
  threading.Condition() and acquires() it! The program then registers the 
  signal handlers where notify() and release() is called when the above 
  mentioned signals are received. After registering the signal handlers, it 
  calls wait() on the condition variable and block.
  
  When I tried to stop the program with Ctrl-C, its did not respond. IOW, the 
  _signal_handler() method did not get called.  
 
 I'm not sure what you are trying to do but your test case seems flawed.  
 threading.Condition is designed to be used with multiple threads but 
 your test doesn't actually use threads.  If you run your test with a 
 reasonably current Python 3 (after changing print to print()), you can 
 see that it fails (and why it fails) when interrupting with Ctrl-C:
 
 Waiting to be interrupted!
 ^CReceived terminate request - signal = 2
 Traceback (most recent call last):
   File b.py, line 30, in module
 main()
   File b.py, line 27, in main 
 a.register_and_wait()
   File b.py, line 22, in register_and_wait
 self._termination_signal.wait()  # control blocks here!
   File 
 /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/threadin
 g.py, line 289, in wait
 waiter.acquire()
   File b.py, line 13, in _signal_handler
 self._termination_signal.notify()
   File 
 /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/threadin
 g.py, line 339, in notify
 raise RuntimeError(cannot notify on un-acquired lock)
 RuntimeError: cannot notify on un-acquired lock
 
 After a quick glance, I'm not sure why Python 2.7 is behaving 
 differently, e.g. not raising an error, since both versions of 
 Condition.notify have the same test so the difference is elsewhere.  
 Feel free to open an issue for not catching the error in 2.7 but you 
 should rethink what you are trying to do here.

That's not the whole story.  I was playing around with his example this 
morning (Python 2.7.1, OSX, Darwin Kernel Version 11.4.2).  My original 
thought was that maybe the wait() call is holding the GIL and breaking 
it up into two threads would solve that somehow.  So, I tried this:

-
from signal import signal, SIGINT, SIGTERM, SIGQUIT
from threading import Condition, Thread, current_thread
import time

class A:
def __init__(self):
self._termination_signal = Condition()

def _signal_handler(self, signum, frame):
print Received terminate request - signal = {0}.format(signum,)
del frame
return

def register_and_wait(self):
t = Thread(target=A.run, args=[self._termination_signal])
t.start()
signal(SIGINT, self._signal_handler)
signal(SIGTERM, self._signal_handler)
signal(SIGQUIT, self._signal_handler)

@staticmethod
def run(ts):
ts.acquire(blocking=0)
print Waiting to be interrupted!
ts.wait()  # control blocks here!   


print Notified!!

def main():
a = A()
a.register_and_wait()

if __name__ == __main__:
main()
---

I got the same result: _signal_handler() never gets called.  You may be 
right that at the point where notify() gets called, you don't have a 
lock, but that's moot because you never even get to that point.  That's 
the fundamental problem here, and it sure smells like a deadlock.  And 
since it happens even in the non-threaded version, my nose says it's 
somehow GIL related.

I just noticed that the acquire call is documented as taking 
specifically True or False, not generically something truthy or falsey.  
I tried it again with accept(blocking=False) and got the same result.

Hmmm, I just also noticed what I think is a bug in the docs 
(https://docs.python.org/2/library/threading.html).  It says, If a call 
with blocking set to True would block, return False immediately.  Isn't 
that backwards?  Doesn't that describe the blocking=False behavior?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PEP8 and 4 spaces

2014-07-03 Thread Simon Ward


On 3 July 2014 18:31:04 BST, Tobiah tshep...@rcsreg.com wrote:
Coworker takes PEP8 as gospel and uses 4 spaces
to indent.  I prefer tabs.  Boss want's us to
unify.

This isn't worth arguing about. Pick a convention, it's probably going to be a 
compromise, get used to it. PEP8 is as good a base as any, and is (mostly) 
directly supported by various syntax checking tools such as flake8 and pylama 
(which I think both use the pep8 tool underneath), and the modes of various 
editors. Any good editor will make indentation painless, whichever method you 
settle on.

Anyway, I gave up the 80 char line length long
ago, having little feeling for some dolt on
a Weiss terminal that for some reason needs to
edit my code.

Putting the code factoring considerations aside, because others have already 
mentioned them and I'm sure others will, there are some other practical reasons 
for limiting line width:

I often use multiple editors side-by-side or in split window mode. If I'm 
limited to one screen I'll probably also have documentation open on that 
screen. Having to side scroll, or have a single editor take up most of the 
width of the display forcing switching between windows, seems to me to be more 
harmful than good for productivity.

There is plenty of research on the readability of prose, less so on code, but 
some of the considerations apply to code too. I'll pick out three of them.

The first probably applies less to code (because code is generally line-based 
and the line widths vary; it's not just a big wall of text): people tend to 
find it harder to track from one line to the next with longer lines of text.

The second has to do with focus: as the reader continues along a line of text 
their focus dwindles, it seems that starting a new line renews focus.

Thirdly, it may seem unintuitive given that we appear to have more capacity for 
horizontal movement of the eyes, but excessively long lines can cause more work 
for them potentially inducing eyestrain. We focus near the centre. Our 
peripheral vision either side is less discerning of details and more on 
movement (such as an attacker). We must move our eyes to continue reading long 
lines, and possibly even move our heads. This is a problem for vertical 
movement too, and happens if lines are too short. (I have no idea how this 
affects readers of vertical scripts.)

 I feel rather the same about the
spaces and tabs, given that most people seem to
be using editors these days that are configurable
to show tabs a four characters.

Conversely, those same editors can probably automatically indent and unindent a 
configurable amount of spaces. If you don't use such an editor, and you really 
can't tolerate the different style, you can use another tool to reindent your 
code.

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


Re: PEP8 and 4 spaces

2014-07-03 Thread Tobiah

On 07/03/2014 12:40 PM, Tim Chase wrote:

On 2014-07-03 19:02, Grant Edwards wrote:

That may be true, but that same person is going to have a
difficult time editing the code.


That's true with Notepad, but with dozens of other programming
editors, code indented with spaces will read and edit prefectly.
Not so for tab-indented code.


A broken editor isn't the world's best argument.  If I used an editor
that changed my line-endings, randomly altered arbitrary characters,
or tried to compress multiple spaces into one, I'd complain that the
editor was broken.  If a file has tab characters and my editor
doesn't let me properly deal with tab characters, then THE EDITOR IS
BROKEN.

That said, even though I'm -0 on use 4 spaces rather than tabs, I
conform to the standard to reduce interop headache even if I'd rather
use tabs.

-tkc



I think your suggestion of having GIT handle the transformations
is the way we'll go.  nothing to quibble or worry about.  Well put
spaces in the repository since it still seems to be the community's
preference and I'll convert to tabs with GIT on the fly.  Problem
solved.

Thanks,

Tobiah

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


Re: PEP8 and 4 spaces

2014-07-03 Thread Tobiah



Anyway, I gave up the 80 char line length long ago, having little
feeling for some dolt


Same to you.


Haha, the language was too strong.  The code I'm talking about is
only going to be seen by a small group of programmers.  The current
trio has all been here for over 20 years.  I'd be more concerned if
the code were ever to be made public.


on a Weiss terminal that for some reason needs to edit my code.  I
feel rather the same about the spaces and tabs, given that most
people seem to be using editors these days that are configurable to
show tabs a four characters.

Any evidence out there that this part of PEP8 is becoming more
optional or even obsolete, as I've heard others say about the 80 char
line length?

Just need ammo for when the hammer of code unification comes down.


Just do the right thing and configure your editor to indent with
spaces.



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


Re: general module auditing

2014-07-03 Thread Rita
On Thu, Jul 3, 2014 at 8:36 AM, Mark Lawrence breamore...@yahoo.co.uk
wrote:

 On 03/07/2014 10:27, Rita wrote:




 On Thu, Jul 3, 2014 at 2:54 AM, Mark Lawrence breamore...@yahoo.co.uk
 mailto:breamore...@yahoo.co.uk wrote:

 On 03/07/2014 02:17, Rita wrote:


 On Wed, Jul 2, 2014 at 2:46 PM, Irmen de Jong
 irmen.nos...@xs4all.nl mailto:irmen.nos...@xs4all.nl
 mailto:irmen.nos...@xs4all.nl

 mailto:irmen.nos...@xs4all.nl__ wrote:

  On 2-7-2014 4:04, Rita wrote:
yes, this helps. But I want to know who uses the module,
 serpent.
  So, when
I upgrade it or remove it they won't be affected
 adversely.

  (Please don't top-post, it makes the discussion harder to
 follow.)

On Tue, Jul 1, 2014 at 2:16 PM, Irmen de Jong
  irmen.nos...@xs4all.nl mailto:irmen.nos...@xs4all.nl
 mailto:irmen.nos...@xs4all.nl mailto:irmen.nos...@xs4all.nl
 __


wrote:
   
On 1-7-2014 12:38, Rita wrote:
i work in a group of developers (15 or so)  who are
 located
  globally. I
would like to know what modules everyone is uses if I
 ever have to
upgrade
my python. Is there mechanism which will let me see who
 is
  using what?
   
ie,
   
tom,matplotlib
bob, pylab
nancy, numpy
nancy, matplotlib
   
etc...
   
   
   
Well, if your group is all using Pip (and perhaps even
  virtualenv), you
could use pip
list. In my case:
   
$ pip list

  [...]


  Why would the fact that you upgrade or remove a package,
 affect
  another developer in
  your group? Are you all using the same machine to develop
 on, with
  one Python installation?

  I think you'll have to tell us some more details about the
 way you
  work together before
  we can give a meaningful answer to your question.

  Irmen

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

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

 we have a shared mount point which has our python install. we
 have 3
 servers on one part of the campus  and 2 in another part.

 I want to find out what packages our user base is using thats
 the final
 goal. I can figure out who is using python by writing a wrapper
 but not
 what module.

 --
 --- Get your facts first, then you can distort them as you
 please.--


 You can check every users's program for import statements but do you
 really need to, why not check what's in the site-packages folder for
 your python install?

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

 Mark Lawrence

 how can i get frequency of the module usage? thats the end goal.

 --
 --- Get your facts first, then you can distort them as you please.--



 Count the number of imports or count the times a given program gets run
 for the number of imports depending on what you mean.


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

 Mark Lawrence

 ---
 This email is free from viruses and malware because avast! Antivirus
 protection is active.
 http://www.avast.com


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


here is what I am doing now,

egrep 'from|import' *.py | wc -l which is giving me that. But this does not
give me the number of times the particular module gets called. I was
thinking of adding a logging feature to all of my modules so every time
they get called it will be written to a log file with corresponding host
and username. Is there an easy way to do that?



-- 
--- Get your facts first, then you can distort them as you please.--
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PEP8 and 4 spaces

2014-07-03 Thread Emile van Sebille

On 7/3/2014 2:23 PM, Tobiah wrote:

I think your suggestion of having GIT handle the transformations
is the way we'll go.  nothing to quibble or worry about.  Well put
spaces in the repository since it still seems to be the community's
preference and I'll convert to tabs with GIT on the fly.  Problem
solved.


Just watch out for mixed tabs and spaces in the same file -- a tab 
counts as eight spaces and can be used interchangeably in python2.


Emile



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


Re: general module auditing

2014-07-03 Thread Mark Lawrence

On 04/07/2014 00:09, Rita wrote:


here is what I am doing now,

egrep 'from|import' *.py | wc -l which is giving me that. But this does
not give me the number of times the particular module gets called. I was
thinking of adding a logging feature to all of my modules so every time
they get called it will be written to a log file with corresponding host
and username. Is there an easy way to do that?



Start here https://docs.python.org/3/library/logging.html#module-logging

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


Mark Lawrence

---
This email is free from viruses and malware because avast! Antivirus protection 
is active.
http://www.avast.com


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


Re: Get named groups from a regular expression

2014-07-03 Thread Philip Shaw
On 2014-07-01, Florian Lindner mailingli...@xgm.de wrote:

 Is there a way I can extract the named groups from a regular
 expression?  e.g. given (?Ptestgrp\d) I want to get something
 like [testgrp].

The match object has an attribute called groupdict, so you can get
the found named groups using match.groupdict.keys. I can't remember
what happens to unnamed groups (I prefer to name every group I want),
but ISTR that there is a list of capture groups in which the indexes
are the capture groups number (i.e. what you'd use to backreference
them).

 Can I make the match object to return default values for named
 groups, even if no match was produced?

A lazy solution I've used was to write a default dict, then update it
with the groupdict. I doubt that's all that efficient, but the
defaults were constant strings and the program was network-bound
anyway.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: threading.Condition.wait() is not catching SIGTERM

2014-07-03 Thread Cameron Simpson

On 03Jul2014 16:43, Roy Smith r...@panix.com wrote:
[...]

Hmmm, I just also noticed what I think is a bug in the docs
(https://docs.python.org/2/library/threading.html).  It says, If a call
with blocking set to True would block, return False immediately.  Isn't
that backwards?  Doesn't that describe the blocking=False behavior?


If you mean this text under Lock.acquire:

  When invoked with the blocking argument set to False, do not block. If a call 
  with blocking set to True would block, return False immediately; otherwise, 
  set the lock to locked and return True.


that pretty clearly (to me) describes blocking=False, by contrasting it with a 
behaviour that would obtain if blocking=True. It is in the clause describing 
the blocking argument set to False, after all.


Cheers,
Cameron Simpson c...@zip.com.au
--
https://mail.python.org/mailman/listinfo/python-list


Re: threading.Condition.wait() is not catching SIGTERM

2014-07-03 Thread Sangeeth Saravanaraj

On 04-Jul-2014, at 1:43 am, Ned Deily n...@acm.org wrote:

 In article 17f05a1b-44c8-4f25-afe9-5dbcffb99...@gmail.com,
 I have the following code which when executed waits to be interrupted by 
 SIGINT, SIGTERM or SIGQUIT. When an object is initialized, it creates a 
 threading.Condition() and acquires() it! The program then registers the 
 signal handlers where notify() and release() is called when the above 
 mentioned signals are received. After registering the signal handlers, it 
 calls wait() on the condition variable and block.
 
 When I tried to stop the program with Ctrl-C, its did not respond. IOW, the 
 _signal_handler() method did not get called.  
 
 I'm not sure what you are trying to do but your test case seems flawed.  
 threading.Condition is designed to be used with multiple threads but 
 your test doesn't actually use threads.  If you run your test with a 
 reasonably current Python 3 (after changing print to print()), you can 
 see that it fails (and why it fails) when interrupting with Ctrl-C:
 
 Waiting to be interrupted!
 ^CReceived terminate request - signal = 2
 Traceback (most recent call last):
  File b.py, line 30, in module
main()
  File b.py, line 27, in main
a.register_and_wait()
  File b.py, line 22, in register_and_wait
self._termination_signal.wait()  # control blocks here!
  File 
 /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/threadin
 g.py, line 289, in wait
waiter.acquire()
  File b.py, line 13, in _signal_handler
self._termination_signal.notify()
  File 
 /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/threadin
 g.py, line 339, in notify
raise RuntimeError(cannot notify on un-acquired lock)
 RuntimeError: cannot notify on un-acquired lock
 
 After a quick glance, I'm not sure why Python 2.7 is behaving 
 differently, e.g. not raising an error, since both versions of 
 Condition.notify have the same test so the difference is elsewhere.  
 Feel free to open an issue for not catching the error in 2.7 but you 

Ned, thanks for the explanation. 

I have filed http://bugs.python.org/issue21913 to explore further on this issue.

Thank you,

Sangeeth 

 should rethink what you are trying to do here.
 
 -- 
 Ned Deily,
 n...@acm.org
 
 -- 
 https://mail.python.org/mailman/listinfo/python-list

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


Re: PEP8 and 4 spaces

2014-07-03 Thread Steven D'Aprano
On Thu, 03 Jul 2014 10:31:04 -0700, Tobiah wrote:

 Coworker takes PEP8 as gospel and uses 4 spaces to indent.  I prefer
 tabs.  Boss want's us to unify.  

Point out to your boss, and your co-worker, that PEP 8 *explicitly* 
states that it is not compulsory except for the standard library, and 
that for third-party and private code, local conventions over-rule PEP 8. 
In other words, if your co-worker is the only one who uses spaces when 
everyone else uses tabs, **he is violating PEP 8**.


 The sole thing you get with spaces as
 far as I can tell, is that someone loading the code into Notepad will
 still see a 4 character indent.  That may be true, but that same person
 is going to have a difficult time editing the code.

Advantages of spaces:
- It's a convention that many people follow.

Disadvantages of tabs:
- Many standard Unix/Linux/POSIX tools have a hard time dealing with tabs.

I call such tools *broken*, and there is a vicious circle going on: 
programmers use the fact that these tools don't support tabs to justify 
the use of spaces, and the majority consensus that you should use spaces 
as justification for not fixing the tools.

As I understand it, Unix coders tend to prefer spaces, and Windows users 
tend to be more comfortable with tabs. This isn't a hard-and-fast rule, 
you'll find plenty of exceptions, but it seems to me that Unix tools are 
unforgiving of tabs while Windows IDEs tend to default to tabs. I'm not a 
Windows person myself, any Windows guys like to comment?



 Anyway, I gave up the 80 char line length long ago, having little
 feeling for some dolt on a Weiss terminal that for some reason needs to
 edit my code.

How do you feel about some dolt who aligns two or three editor windows 
side-by-side so they can compare code? :-)

Being able to set code side-by-side, say in a horizontal diff, or two 
editors next to each other, is a much more important reason to support a 
79+1 maximum line width than Weiss terminals.




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


Re: PEP8 and 4 spaces

2014-07-03 Thread Chris Angelico
On Fri, Jul 4, 2014 at 11:02 AM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
 As I understand it, Unix coders tend to prefer spaces, and Windows users
 tend to be more comfortable with tabs. This isn't a hard-and-fast rule,
 you'll find plenty of exceptions, but it seems to me that Unix tools are
 unforgiving of tabs while Windows IDEs tend to default to tabs. I'm not a
 Windows person myself, any Windows guys like to comment?

I've worked both platforms extensively, and it's not really as
clear-cut as that. Most Unix tools are perfectly happy with tabs, *as
long as you let them mean eight spaces*; a lot, but not all, have an
option to configure tab width, but you have to specify it to every
program separately.

On the flip side, tab configurability can be a huge feature. There've
been times when I've looked at something with the tab width set to
something insane like 7 or 9 (no, folks, I did not say 7 of 9) to
highlight a display bug or other oddity. Not often, but it has its
uses - and you can't do that if there are actual spaces involved.

Anyone who's using a broken editor should fix it or switch editors.
That's easy. And if you really love your editor, sometimes you can fix
the issue outside it - maybe in a source control hook.

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


Re: PEP8 and 4 spaces

2014-07-03 Thread Steven D'Aprano
On Thu, 03 Jul 2014 21:07:28 +0300, Paul Sokolovsky wrote:

 Hello,
 
 On Fri, 4 Jul 2014 03:38:27 +1000
 Chris Angelico ros...@gmail.com wrote:
 
 On Fri, Jul 4, 2014 at 3:31 AM, Tobiah tshep...@rcsreg.com wrote:
  Coworker takes PEP8 as gospel and uses 4 spaces to indent.  I prefer
  tabs.  Boss want's us to unify.
 
 1) PEP 8 is meant to be guidelines, *not* a set of hard-and-fast rules.
 2) Tabs let different people display the indents at different widths.
 
 That's exactly the problem with tabs - whatever you think your code
 looks like with tabs, other people will see quite different picture.

Why do you consider this a problem?

The only rational reason I can think of is that you are concerned about 
line widths. If I write code with tabs set to two spaces, indent five 
times, and then write 50 characters of code, I'll see a total line width 
of 60 columns. Somebody who views tabs as four spaces will see a width of 
70, and someone else who views them as eight spaces will see a width of 
90 columns. So I can see that's somewhat of a problem, but not a huge one.


 Also, most people are not interested in doing mumbo-jumbo with tabs
 settings, and have them set to standard 8-char tabs. So, any python code
 which uses only tabs for indentation automatically violates 4-space
 convention

Mumbo-jumbo? In any decent editor, it's a single setting. In kwrite I 
go Settings  Configure Editor, click the Editing icon, and there's a 
Tab width field right there. Hardly mumbo-jumbo.

In any case, the 4-space convention is just a convention. If you're 
willing to go against PEP 8 and use tabs, going against PEP 8 and using 8-
column tab settings shouldn't worry you.


 (and mixing tabs and spaces is nowadays prohibited in Python).

Yes, that's because the algorithm used by the parser to determine the 
indentation level may not give the same answer as a human reader, in the 
presence of mixed tabs and spaces. In any case, in the entire history of 
the space/tab argument, I'm not aware of a single person who recommended 
mixed space/tabs for indents. There are two standard solutions for the 
problem of indenting code, not three: use spaces, or use tabs, but not 
arbitrarily pick one or the other each time you indent.


 Summing up: if you care about other human beings, use spaces. If you
 don't care about other human beings, you may use tabs, but other human
 beings surely will take how you treat them into account ;-).

Ha ha, that's funny, I would have said the opposite: if you care about 
keeping tools that expect spaces happy, use spaces, if you care about 
allowing people to configure the look of your code, or poor unfortunates 
who aren't using a programmer's editor, use tabs.


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


Re: PEP8 and 4 spaces

2014-07-03 Thread Chris Angelico
On Fri, Jul 4, 2014 at 11:21 AM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
 Summing up: if you care about other human beings, use spaces. If you
 don't care about other human beings, you may use tabs, but other human
 beings surely will take how you treat them into account ;-).

 Ha ha, that's funny, I would have said the opposite: if you care about
 keeping tools that expect spaces happy, use spaces, if you care about
 allowing people to configure the look of your code, or poor unfortunates
 who aren't using a programmer's editor, use tabs.

Right. And hey. If you're a sufficiently competent programmer, you CAN
get away with not caring about other human beings: either because
you're so utterly valuable that people accept you despite your rough
edges... or because you just script away the differences :)

Now, if your *boss* doesn't understand about these things, it's
possible to lose your job over stupid stuff like style guides.
Although to be fair, I'd been planning to quit for a long time, and
the style guide was the last in a long line of problems, so when I
kicked back and said basically No, your style guide is a bad idea,
it ended up with us parting ways. But that's a separate point.

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


Re: PEP8 and 4 spaces

2014-07-03 Thread Roy Smith
In article mailman.11478.1404437416.18130.python-l...@python.org,
 Chris Angelico ros...@gmail.com wrote:

 On Fri, Jul 4, 2014 at 11:21 AM, Steven D'Aprano
 steve+comp.lang.pyt...@pearwood.info wrote:
  Summing up: if you care about other human beings, use spaces. If you
  don't care about other human beings, you may use tabs, but other human
  beings surely will take how you treat them into account ;-).
 
  Ha ha, that's funny, I would have said the opposite: if you care about
  keeping tools that expect spaces happy, use spaces, if you care about
  allowing people to configure the look of your code, or poor unfortunates
  who aren't using a programmer's editor, use tabs.
 
 Right. And hey. If you're a sufficiently competent programmer, you CAN
 get away with not caring about other human beings: either because
 you're so utterly valuable that people accept you despite your rough
 edges... or because you just script away the differences :)
 
 Now, if your *boss* doesn't understand about these things, it's
 possible to lose your job over stupid stuff like style guides.
 Although to be fair, I'd been planning to quit for a long time, and
 the style guide was the last in a long line of problems, so when I
 kicked back and said basically No, your style guide is a bad idea,
 it ended up with us parting ways. But that's a separate point.
 
 ChrisA

The way I figure it, there are two things which have sucked up more 
time, effort, and productivity than anything else.  Buffer overrun bugs, 
and arguments about whitespace (and placement of braces in those sorts 
of languages).  I'm not sure which order they go in.

Solving buffer overruns is easy; you use bounds-checked containers, or 
languages which don't expose raw memory.  Killing whitespace arguments 
seems to be a far more intractable problem.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PEP8 and 4 spaces

2014-07-03 Thread Demian Brecht
On Jul 3, 2014 10:31 AM, Tobiah tshep...@rcsreg.com wrote:
 Just need ammo for when the hammer of code unification comes down.

One issue that I've encountered in the past (one of the reasons outside of
pep8) that I switched to spaces is when working with libraries other than
your own. If you want to stick print statements, breakpoints or make any
other modifications to the code you're working with, chances are if you're
using tabs in your editor, you're going to run into issues when making
those changes.

Most (of not all) libraries I've worked with use spaces. Pep8 suggests the
use of spaces. New hires who have spent any amount of time in python are
/likely/ most used to using spaces. For those reasons I much prefer spaces
over tabs.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: fixing an horrific formatted csv file.

2014-07-03 Thread flebber
I have taken the code and gone a little further, but I need to be able to 
protect myself against commas and single quotes in names.

How is it the best to do this?

so in my file I had on line 44 this trainer name.

Michael, Wayne  John Hawkes 

and in line 95 this horse name.
Inz'n'out

this throws of my capturing correct item 9. How do I protect against this?

Here is current code.

import re
from sys import argv
SCRIPT, FILENAME = argv


def out_file_name(file_name):
take an input file and keep the name with appended _clean
file_parts = file_name.split(.,)
output_file = file_parts[0] + '_clean.' + file_parts[1]
return output_file


def race_table(text_file):
utility to reorganise poorly made csv entry
input_table = [[item.strip(' ') for item in record.split(',')]
   for record in text_file.splitlines()]
# At this point look at input_table to find the record indices
output_table = []
for record in input_table:
if record[0] == 'Meeting':
meeting = record[3]
elif record[0] == 'Race':
date = record[13]
race = record[1]
elif record[0] == 'Horse':
number = record[1]
name = record[2]
results = record[9]
res_split = re.split('[- ]', results)
starts = res_split[0]
wins = res_split[1]
seconds = res_split[2]
thirds = res_split[3]
prizemoney = res_split[4]
trainer = record[4]
location = record[5]
print(name, wins, seconds)
output_table.append((meeting, date, race, number, name,
 starts, wins, seconds, thirds, prizemoney,
 trainer, location))
return output_table

MY_FILE = out_file_name(FILENAME)

# with open(FILENAME, 'r') as f_in, open(MY_FILE, 'w') as f_out:
# for line in race_table(f_in.readline()):
# new_row = line
with open(FILENAME, 'r') as f_in, open(MY_FILE, 'w') as f_out:
CONTENT = f_in.read()
# print(content)
FILE_CONTENTS = race_table(CONTENT)
# print new_name
f_out.write(str(FILE_CONTENTS))


if __name__ == '__main__':
pass
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue21896] Unexpected ConnectionResetError in urllib.request against a valid website

2014-07-03 Thread Ned Deily

Ned Deily added the comment:

It fails with Python 2's urllib2.urlopen as well.

--
nosy: +ned.deily, orsenthil
versions: +Python 2.7, Python 3.5 -Python 3.2, Python 3.3

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



[issue21909] PyLong_FromString drops const

2014-07-03 Thread Hristo Venev

New submission from Hristo Venev:

PyObject* PyLong_FromString(const char *str, char **pend, int base)

pend should be const char**

I think casting const away when not required should be a crime punishable by 
imprisonment.

--
messages: 222152
nosy: h.venev
priority: normal
severity: normal
status: open
title: PyLong_FromString drops const

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



[issue21909] PyLong_FromString drops const

2014-07-03 Thread Hristo Venev

Changes by Hristo Venev hri...@venev.name:


--
components: +Interpreter Core
type:  - security
versions: +Python 3.4

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



[issue16117] python2.7.3 struct misaligned when returned

2014-07-03 Thread Mark Lawrence

Mark Lawrence added the comment:

@Roland please accept our apologies for the delay in getting back to you.

Can someone else take a look please as I know nothing about ctypes, thanks.

--
nosy: +BreamoreBoy, amaury.forgeotdarc, belopolsky

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



[issue16132] ctypes incorrectly encodes .format attribute of memory views

2014-07-03 Thread Mark Lawrence

Mark Lawrence added the comment:

@David please accept our apologies for the delay in getting back to you.

Can someone else take a look please as I know nothing about ctypes, thanks.

--
nosy: +BreamoreBoy, amaury.forgeotdarc, belopolsky
versions: +Python 3.4, Python 3.5 -Python 3.3

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



[issue13985] Menu.tk_popup : menu doesn't disapear when main window is iconified.

2014-07-03 Thread Ned Deily

Ned Deily added the comment:

As far as I can tell, the problem you are seeing with the menu not disappearing 
when iconifying is caused by the use of grab_release() in do_popup().  If I 
remove it, using an X11-based Tk 8.6, the focus stays on the menu and clicking 
on the iconify button causes the menu to be dismissed.  With grab_release(), 
the focus is released from the menu and clicking on the iconify button causes 
the menu to stay.  Unfortunately, there are differences among the various Tk 
releases and, with the same release, among platform implementations (Windows 
Tk, X11 Tk, OS X Cocoa Tk, etc).  Another issue was the use of the 0 entry 
argument on the call on tk_popup call.  With the X11 Tk I tested with, that 
caused the menu to flash and disappear when clicking the window; removing the 0 
argument caused the menu to stay as expected.  With an OS X Cocoa Tk, your 
original test case worked fine without modification.  A good modern resource 
for using Tk is the TkDocs website, which covers use of Tk from Tcl, 
 Python, Ruby, and Perl.  The menus sections describes some of the platform 
differences you may encounter and need to deal with:

http://www.tkdocs.com/tutorial/menus.html

--
nosy: +ned.deily
resolution:  - not a bug
stage:  - resolved
status: open - closed

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



[issue13745] configuring --with-dbmliborder=bdb doesn't build the gdbm extension

2014-07-03 Thread Mark Lawrence

Changes by Mark Lawrence breamore...@yahoo.co.uk:


--
components: +Build
type:  - behavior
versions: +Python 3.4, Python 3.5 -Python 3.2, Python 3.3

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



[issue13784] Documentation of xml.sax.xmlreader: Locator.getLineNumber() and Locator.getColumnNumber()

2014-07-03 Thread Mark Lawrence

Mark Lawrence added the comment:

@patrick please accept our apologies for the delay in getting back to you.

--
nosy: +BreamoreBoy, christian.heimes
versions: +Python 3.4, Python 3.5 -Python 3.2

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



[issue20337] bdist_rpm should support %config(noreplace)

2014-07-03 Thread Vitaly Isaev

Vitaly Isaev added the comment:

I confirm the urgent need in this feature.

--
nosy: +vitalyisaev2

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



[issue15549] openssl version in windows builds does not support renegotiation

2014-07-03 Thread Ned Deily

Changes by Ned Deily n...@acm.org:


--
resolution:  - out of date
stage:  - resolved
status: open - closed
versions:  -Python 2.6

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



[issue12857] Expose called function on frame object

2014-07-03 Thread Mark Lawrence

Mark Lawrence added the comment:

Note that #13672 referred to in msg156962 refers to #13855.

--
nosy: +BreamoreBoy
versions: +Python 3.5 -Python 3.3

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



[issue13855] Add qualname support to types.FunctionType

2014-07-03 Thread Mark Lawrence

Mark Lawrence added the comment:

Note that #13672 refers to #12857.

--
nosy: +BreamoreBoy
type: behavior - enhancement
versions: +Python 3.5 -Python 3.3

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



[issue13672] Add co_qualname attribute in code objects

2014-07-03 Thread Berker Peksag

Changes by Berker Peksag berker.pek...@gmail.com:


--
versions: +Python 3.5 -Python 3.3

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



[issue13940] imaplib: Mailbox names are not quoted

2014-07-03 Thread Mark Lawrence

Mark Lawrence added the comment:

@Joe sorry for the delay in getting back to you.

@David is this within your remit?

--
nosy: +BreamoreBoy, r.david.murray
versions: +Python 3.4, Python 3.5 -Python 3.1

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



[issue13946] readline completer could return an iterable

2014-07-03 Thread Mark Lawrence

Mark Lawrence added the comment:

Is this a good, bad or indifferent idea?

--
nosy: +BreamoreBoy
versions: +Python 3.5 -Python 3.3

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



[issue10031] Withdraw anti-recommendation of relative imports from documentation

2014-07-03 Thread Andy Maier

Andy Maier added the comment:

Hi, I would like to revive this issue, and have a few comments:

1. In Darren's original proposal, I suggest to say implicit (old-style) 
relative imports instead of old-style relative imports, because that is the 
term used in the Python Tutorial (the description of the ´import´ statement in 
2.7 does not mention implicit relative imports at all).

2. It seems to me that David's suggestion is already reflected in the original 
proposal. Or maybe I don't understand it right...

3. I agree with Éric's comment that implicit relative imports should still be 
explained. However, I'm not sure that needs to be done in the FAQ. After all, 
the FAQ does not explain absolute or explicit relative imports either, and 
spending more words on the discouraged approach than on the recommended 
approaches does not seem appropriate to me.

4. I have to say that I'm generally unhappy if I see PEPs mentioned as a 
specification (See PEP 328 for details). I have sympathy for referencing PEPs 
as background information and for the rationales they usually contain. Could we 
reference the description of the ´import´ statement for details, instead of 
referencing the PEP (in both FAQs)?

Andy

--
nosy: +andymaier

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



[issue21571] Python build should check CPATH, C_INCLUDE_PATH for module dependencies

2014-07-03 Thread Jan Kanis

Jan Kanis added the comment:

I can write a patch. I haven't signed a contributor agreement but I have no 
problem doing so. I am not sure when I will have time to write a patch though, 
so it could take some time.

--

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



[issue10225] Fix doctest runable examples in python manual

2014-07-03 Thread Andy Maier

Andy Maier added the comment:

Hi, I would like to revive this issue and have added a review comment to 
issue10225-py3k.diff.

Otherwise, I have reviewed the changes in both diffs and think they are good to 
go.

Andy

--
nosy: +andymaier

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



[issue20069] Add unit test for os.chown

2014-07-03 Thread Claudiu Popa

Changes by Claudiu Popa pcmantic...@gmail.com:


--
nosy: +berker.peksag

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



[issue21910] File protocol should document if writelines must handle generators sensibly

2014-07-03 Thread Jan Kanis

New submission from Jan Kanis:

The resolution of issue 5445 should be documented somewhere properly, so people 
can depend on it or not.

IOBase.writelines handles generator arguments without problems, i.e. without 
first draining the entire generator and then writing the result in one go. That 
would require large amounts of memory if the generator is large, and fail 
entirely if the generator is infinite. 

codecs.StreamWriter.writelines uses self.write(''.join(argument)) as 
implementation, which fails on very large or infinite arguments.

According to issue 5445 it is not part of the file protocol that .writelines 
must handle (large/infinite) generators, only list-like iterables. However as 
far as I know this is not documented anywhere, and sometimes people assume that 
writelines is meant for this case. E.g. jinja 
(https://github.com/mitsuhiko/jinja2/blob/master/jinja2/environment.py#L1153, 
the dump method is explicitly documented to stream). The guarantees that 
.writelines makes or does not make in this regard should be documented 
somewhere, so that either .writeline implementations that don't handle large 
generators can be pointed out as bugs, or code that makes assumptions on 
.writeline handling large generators can be.

I personally think .writelines should handle large generators, since in the 
python 3 world a lot of apis were iterator-ified and it is wat a lot of people 
would probably expect. But having a clear and documented decision on this is 
more important. 

(note: I've copied most of the nosy list from #5445)

--
assignee: docs@python
components: Documentation, IO
messages: 222165
nosy: JanKanis, benjamin.peterson, dlesco, docs@python, hynek, lemburg, pitrou, 
stutzbach, terry.reedy
priority: normal
severity: normal
status: open
title: File protocol should document if writelines must handle generators 
sensibly
versions: Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4, Python 3.5

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



[issue21151] winreg.SetValueEx causes crash if value = None

2014-07-03 Thread Claudiu Popa

Changes by Claudiu Popa pcmantic...@gmail.com:


--
nosy: +steve.dower, zach.ware
priority: normal - high

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



[issue10536] Enhancements to gettext docs

2014-07-03 Thread Andy Maier

Andy Maier added the comment:

Éric,
I have reviewed the patch, and have one minor comment on it (see review page). 
Otherwise, I think it is good to go into v3 (The version list for this issue 
also shows 2.7, and the 2.7 version of this file is quite different from the v3 
tip version, so a backport is still needed).

Barry's review I think is also still needed :-)

My 2 cents on your questions to Barry:

On 3): I like your proposal.

On a): Can you be more specific on where it is POSIX specific, and what the 
issue is with that?

On b): After understanding that your comment is about the v3 version, I agree 
with the comment in general. However, the set of functions changes between 2.7 
and 3.x tip (for example, ugettext() from v2 is no longer in v3 because 
gettext() now returns Unicode strings), and if people try to understand what 
changed, I think it would be helpful to be more explicit, particularly because 
the v2 text is also explicit. So I would leave the Unicode string verbiage 
unchanged. But I don't have a strong opinion on this and can go either way.

Andy

--
nosy: +andymaier

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



[issue21906] Tools\Scripts\md5sum.py doesn't work in Python 3.x

2014-07-03 Thread Josh Rosenberg

Changes by Josh Rosenberg shadowranger+pyt...@gmail.com:


--
nosy: +josh.rosenberg

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



[issue21740] doctest doesn't allow duck-typing callables

2014-07-03 Thread Claudiu Popa

Claudiu Popa added the comment:

Here's a test patch which uses inspect.unwrap. Unfortunately, I can't test with 
numba, so I don't know if it works for that, but any decorated function which 
uses `functools.update_wrapper` or `wraps` should be detected by doctest.

--
keywords: +patch
Added file: http://bugs.python.org/file35838/issue21740.patch

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



[issue21911] IndexError: tuple index out of range should include the requested index and tuple length

2014-07-03 Thread Ram Rachum

New submission from Ram Rachum:

Ditto for lists and any other place this could be applicable.

--
components: Interpreter Core
messages: 222168
nosy: cool-RR
priority: normal
severity: normal
status: open
title: IndexError: tuple index out of range should include the requested 
index and tuple length
type: behavior
versions: Python 3.5

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



[issue20218] Add methods to `pathlib.Path`: `write_text`, `read_text`, `write_bytes`, `read_bytes`

2014-07-03 Thread Ram Rachum

Changes by Ram Rachum r...@rachum.com:


--
resolution:  - rejected
status: open - closed

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



[issue18212] No way to check whether Future is finished?

2014-07-03 Thread Ram Rachum

Ram Rachum added the comment:

What do you think about exposing this directly?

--

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



[issue20663] Introduce exception argument to iter

2014-07-03 Thread Ram Rachum

Ram Rachum added the comment:

Hey-ho... Anyone feels like implementing this? (I don't program in C so I 
can't.)

--

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



[issue21912] Deferred logging may use outdated references

2014-07-03 Thread Jonas Diemer

New submission from Jonas Diemer:

I was having trouble with the logging module under Jython: I was getting 
seemingly sporadic wierd null pointer exceptions in the logging code. 

The problem seemed to be related to references that were passed to the logger, 
e.g.

logger.debug(My object: %s, myObject)

It seems that logging defers the actual string formatting (maybe only when 
logging to files). By the time the string is formatted, the reference to the 
object may no longer be valid. In my case, myObject was a reference to a 
Java-class that had been invalidated.

Initially, I thought this was only a Java issue. But it seems like this could 
be an issue with pure Python scripts as well. E.g., what happens if the object 
behind myObject is changed after the call to debug(), but before the actual log 
message is formatted?

--
components: Library (Lib)
messages: 222171
nosy: Jonas.Diemer
priority: normal
severity: normal
status: open
title: Deferred logging may use outdated references
type: behavior
versions: Python 2.7

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



[issue21912] Deferred logging may use outdated references

2014-07-03 Thread Jonas Diemer

Jonas Diemer added the comment:

Find attached a demo script that causes the erratic behavior in regular Python 
(2.7.5 on Windows).

The log file contains two lines, both show the new name of the object, although 
the first debug() was called befor the name change.

I think this problem could be avoided if the message was formatted earlier 
(i.e. synchronous to the debug() call).

--
Added file: http://bugs.python.org/file35839/testlogging.py

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



[issue12842] Docs: first parameter of tp_richcompare() always has the correct type

2014-07-03 Thread Andrew Svetlov

Andrew Svetlov added the comment:

Fixed in 71a0743f36db and 06bdd7e8fffd

--
nosy: +asvetlov
resolution:  - fixed
stage: patch review - resolved
status: open - closed
versions: +Python 3.4, Python 3.5 -Python 2.7, Python 3.2, Python 3.3

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



[issue21755] test_importlib.test_locks fails --without-threads

2014-07-03 Thread R. David Murray

R. David Murray added the comment:

What is the reason for using the conditional approach rather than a skip 
decorator?  Does it not work in this context, or is it just that you copied the 
existing approach?  It's fine either way, but I'm curious.

--

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



[issue13940] imaplib: Mailbox names are not quoted

2014-07-03 Thread R. David Murray

R. David Murray added the comment:

Yes.  It will be necessary to check the RFC to figure out what should be done 
here.

--
components: +email
nosy: +barry

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



[issue21912] Deferred logging may use outdated references

2014-07-03 Thread Zachary Ware

Changes by Zachary Ware zachary.w...@gmail.com:


--
nosy: +vinay.sajip

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



[issue21912] Deferred logging may use outdated references

2014-07-03 Thread R. David Murray

R. David Murray added the comment:

The whole point of the logging API is that the message is *not* formatted 
unless the message is actually emitted.  So this is just how logging works, not 
something that can be fixed, as far as I can see.

--
nosy: +r.david.murray

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



[issue21912] Deferred logging may use outdated references

2014-07-03 Thread Jonas Diemer

Jonas Diemer added the comment:

I see your point. 

The decision whether to log or not is actually made synchronously to the actual 
logging call, as far as I can tell (i.e. if self.isEnabledFor... is checked 
directly in debug()). So at this place, the formatting could already happen.
I don't see a reason to defer the formatting to the actual output of the 
messages (other than the current implementation of logging).

--

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



[issue14014] codecs.StreamWriter.reset contract not fulfilled

2014-07-03 Thread Mark Lawrence

Mark Lawrence added the comment:

On Windows 7 206 codecs tests passed and 4 skipped with the patch included.

--
keywords: +patch
nosy: +BreamoreBoy
versions: +Python 3.4, Python 3.5 -Python 3.2, Python 3.3
Added file: http://bugs.python.org/file35840/Issue14014.diff

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



[issue14076] sqlite3 module ignores placeholders in CREATE TRIGGER code

2014-07-03 Thread Mark Lawrence

Mark Lawrence added the comment:

Can we have a reply to this please as I don't understand enough about sqlite3 
to comment.

--
nosy: +BreamoreBoy
title: sqlite3 module ignores placeholers in CREATE TRIGGER code - sqlite3 
module ignores placeholders in CREATE TRIGGER code

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



[issue14124] _pickle.c comment/documentation improvement

2014-07-03 Thread Mark Lawrence

Mark Lawrence added the comment:

Can we have a patch review on this please

--
nosy: +BreamoreBoy
versions: +Python 3.5 -Python 3.3

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



[issue14121] add a convenience C-API function for unpacking iterables

2014-07-03 Thread Mark Lawrence

Mark Lawrence added the comment:

Apparently not :)

--
nosy: +BreamoreBoy
versions: +Python 3.5 -Python 3.3

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



[issue14189] Documentation for some C APIs is missing clear specification of the type of reference they return

2014-07-03 Thread Mark Lawrence

Mark Lawrence added the comment:

Can someone comment please as I'm not brave enough to touch the C code or docs.

--
nosy: +BreamoreBoy

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



[issue21912] Deferred logging may use outdated references

2014-07-03 Thread R. David Murray

R. David Murray added the comment:

The decision as to whether or not to pass the message along to the next stage 
is made at numerous points in the pipeline.

--

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



[issue14287] sys.stdin.readline and KeyboardInterrupt on windows

2014-07-03 Thread Mark Lawrence

Mark Lawrence added the comment:

FWIW the same occurs on Windows 7 with 3.5.0 but given there are known 
differences between Windows and *nix is this really an issue?

--
nosy: +BreamoreBoy

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



[issue21912] Deferred logging may use outdated references

2014-07-03 Thread Vinay Sajip

Vinay Sajip added the comment:

 I don't see a reason to defer the formatting to the actual output of the 
 messages (other than the current implementation of logging).

The current implementation of logging is like that for a reason, even though 
you may not see it - it defers doing work until it is needed (which improves 
throughput). This idiom is hardly uncommon.

If you don't want to delay formatting until output, you can always do

logger.debug(My object: %s % myObject)

--
resolution:  - not a bug
status: open - closed

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



  1   2   >