Re: ANN: intervalset Was: Set type for datetime intervals

2016-04-04 Thread Nagy László Zsolt

> I don't know if I like it being immutable. Maybe have separate mutable
> and immutable versions.
The reason for making it immutable is implementation specific. These
intervals are stored in an ordered list. Overlapping intervals are
unified by the constructor. This makes sure that sets with equal
elements are represented equally, and makes it possible to hash the set.
Comparing them by these hashes is fast and easy.

If you want to manipulate an interval set, you cannot just "add another
interval" to it. Adding an interval may result in unifying thousands of
other intervals. It is possible that you add a wide interval to a set
with 1000 elements, and as a result the set will have only a single
element.
> Like I said before, I don't think the set-like operations on Intervals
> are useful - what can you accomplish with them rather than by making a
> set consisting of only one interval and doing operations on that?
Well, then don't use them. I believe that the intersection of two
intervals is especially useful. Easy to check if two intervals have a
common non-empty part or not. You can also check this with a condition,
but that condition is a long one.
 element ::= (start_point_in_time, end_point_in_time)
 intervalset ::= { element1, element2,  }
>>> Are these open intervals or closed intervals?
>> Closed. In my particular implementation, there is a singleton for all
>> empty intervals. It is not possible to create an arbitrary interval with
>> the same starting and ending time (the singleton being the only
>> exception).
> An "arbitrary interval with the same starting and ending time" would be
> more like an isolated datetime (i.e. 00:00 is in the set but 23:59 or
> 00:01 is not)
Yes, that is true. Again: my task was to represent non-empty intervals.
We can say that a zero sized closed interval is also a special interval
that identifies a single point of time. Since the base class has been
rewritten to support any ordered type, it makes sense. Probably this is
a good idea to do. There are applications where the user is not
interested in zero sized intervals. For example, if you want to store
the working time of an employee then obviously you don't want to store
zero sized intervals.

How about creating two classes for this? One that supports zero sized
intervals, and another that doesn't?
Or maybe create a method that removes all zero sized intervals?
>> I think that implementing open intervals would be much more
>> difficult, and we would have to know and use the smallest possible
>> increment (resolution) of the date/time type. Which may be platform
>> dependent.
> My suggestion was to use boolean flags, and to use that to control
> whether to use < or <= to test for membership.
>
> An open interval is more like an hour where 00:00 is included and
> 00:59:59.99 is included but 01:00 is not. With discrete resolution
> it's as simple as just moving the endpoint off by one unit, but I think
> it'd be cleaner to use flags (you'd need it for numeric intervals, since
> numeric types can have any resolution).
Well, here is the problem: floats, ints, decimals and datetimes are all
ordered types. But they all have a different resolution, and some of
them are implementation dependent. We must know and use the smallest
resolution, even if we use boolean flags to denote openness. For
example: if we use integer values, then the closed interval [1,9] is
equal to the open interval (0,10) or the left-open interval (0,10]. We
want to be able to compare them, so we must know the resolution! If we
stay at the generalized form of the class that can be used on any
ordered type, then we cannot avoid using the concept of the "resolution
of the type". Here are the choices:

  * Use boolean flags to denote openness:
  o We do not support testing for interval equality - I think that
missing this fundamental operator would make the implementation
useless.
  o Support testing for internal equality - this requires knowledge
about the smallest resolution, so in this case using flags to
denote openness makes it possible to represent the same interval
in 4 different ways! (left opened/closed, right opened/closed).
I think this is also a bad idea.
  o We may have an agreement about how we should represent certain
intervals from the 4 different possible opportunities, but the
simplest way would be to always store them as closed intervals -
which makes these boolean flags unneccessary
  * Do not use boolean flags to denote openness - I don't see any
problem here.


I think the problem is that you are thinking the mathematical way, where
an open interval can never be equal to a closed interval. I was thinking
the IT way, where everything is represented with bits, and the "open
interval" is just a concept that always has a biggest and a smallest
possible value.

I'm not saying that your suggestion is wrong. I'm just saying that it

[issue25544] cleanup temporary files in distutils.has_function

2016-04-04 Thread Min RK

Min RK added the comment:

Absolutely, I'll try to do that tomorrow.

--

___
Python tracker 

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



[issue6953] readline documentation needs work

2016-04-04 Thread Berker Peksag

Berker Peksag added the comment:

readline-doc.v3.patch looks good to me.

--
stage: patch review -> commit review

___
Python tracker 

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



[issue26693] Exception exceptions.AttributeError '_shutdown' in

2016-04-04 Thread Martin Panter

Martin Panter added the comment:

I am seeing an AssertionError, but no AttributeError. In your original post you 
did mention AssertionError, but that contradicts the report title. Please 
clarify what the problem is.

$ CFLAG="$(python3.5m-config --includes)"
$ LDFLAG="$(python3.5m-config --ldflags)"
$ g++ ${CFLAG} ${LDFLAG} test2.C
$ ./a.out
['/home/proj/python/lib', '/usr/lib/python35.zip', '/usr/lib/python3.5', 
'/usr/lib/python3.5/plat-linux', '/usr/lib/python3.5/lib-dynload', 
'/home/.local/lib/python3.5/site-packages', '/usr/lib/python3.5/site-packages']
Exception ignored in: 
Traceback (most recent call last):
  File "/usr/lib/python3.5/threading.py", line 1292, in _shutdown
assert tlock.locked()
AssertionError:

--
nosy: +martin.panter
status: pending -> open

___
Python tracker 

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



Re: module alias in import statement

2016-04-04 Thread Rustom Mody
On Tuesday, April 5, 2016 at 9:53:30 AM UTC+5:30, Chris Angelico wrote:
> On Tue, Apr 5, 2016 at 2:08 PM, Rustom Mody  wrote:
> >> 'import tk.ttk' looks for 'tk' in sys.modules, does not find it, looks
> >> for a module named 'tk' on disk, does not find it, and says so.
> >
> > A well-known quote comes to mind:
> >
> > | There are only two hard things in Computer Science: cache invalidation and
> > | naming things.
> >
> > eg. http://martinfowler.com/bliki/TwoHardThings.html
> >
> > particularly since this seems to be in both categories :-)
> 
> sys.modules isn't really a cache in that sense, though. The "hard
> problem" of cache invalidation comes from the fundamental assumption
> that a cache hit should be semantically identical to a cache miss;

Following looks like a cache miss to me (certainly did to the OP):

On Monday, April 4, 2016 at 9:01:41 PM UTC+5:30, ast wrote:
> hello
> 
> >>> import tkinter as tk
> >>> import tk.ttk as ttk
> 
> Traceback (most recent call last):
>   File "", line 1, in 
> import tk.ttk as ttk
> ImportError: No module named 'tk'
> 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: module alias in import statement

2016-04-04 Thread Chris Angelico
On Tue, Apr 5, 2016 at 2:08 PM, Rustom Mody  wrote:
>> 'import tk.ttk' looks for 'tk' in sys.modules, does not find it, looks
>> for a module named 'tk' on disk, does not find it, and says so.
>
> A well-known quote comes to mind:
>
> | There are only two hard things in Computer Science: cache invalidation and
> | naming things.
>
> eg. http://martinfowler.com/bliki/TwoHardThings.html
>
> particularly since this seems to be in both categories :-)

sys.modules isn't really a cache in that sense, though. The "hard
problem" of cache invalidation comes from the fundamental assumption
that a cache hit should be semantically identical to a cache miss;
Python's import system has fundamentally different semantics,
specifically that modules can exist independently of anything on the
disk, and modules are guaranteed to be singletons - which means that
"import decimal; decimal.getcontext().prec = 50" will affect anyone
else who uses the decimal module, because there can't be a duplicate.
(The one exception to this, where __main__ gets reimported under
another name, causes significant confusion despite being extremely
uncommon.)

If you like, you can look at sys.modules as a mandatory cache that
never records negatives and always records positives. Once an import
has succeeded, it will always be resolved from the cache, until
program termination; failed imports will always be retried. Python
dodges the cache invalidation problem by never invalidating anything
:)

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


Re: Trouble trying to install Python 3.5.1 (32-bit) for windows

2016-04-04 Thread Rustom Mody
On Tuesday, April 5, 2016 at 8:19:44 AM UTC+5:30, Yuri Armellei wrote:
> Dear Python,
> 
> I  encountered difficulties when installing  the python.
> 
> Could you guys help me to solve and install it?!
> 
> Attached log error  to  help you guys to help me out. =)  ;)
> 
> Regards,
> 
> 
> 
> [cid:image001.png@01D18EA7.4A69B7E0]
> 
> 
> [cid:image006.jpg@01D152DC.ACCAF540]
> 
> Yuri Armellei

Images dont get through this list -- sorry -- text only.
Please cut paste the error as inline text and mail again.

And while you are at it give this info also
- Which OS
- Which installer did you try
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Launcher for 64 bits doesnt work

2016-04-04 Thread Ben Finney
Gustaf  writes:

> Enviado desde mi iPhone

Perhaps you could wait until you're at a better computer for
corresponding, and compose messages with more information to work out
what's happening.

-- 
 \  “Contentment is a pearl of great price, and whosoever procures |
  `\it at the expense of ten thousand desires makes a wise and |
_o__)  happy purchase.” —J. Balguy |
Ben Finney

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


Re: Launcher for 64 bits doesnt work

2016-04-04 Thread Gustaf
Thsnk you for your response, the pip installer doesnt work, only for the 
launcher for 32 bits. 

But my mainproblem is that I cant connect pygresql. I can download the package 
but after it says that it cant find the module

Enviado desde mi iPhone

> El 4 apr 2016, a las 22:39, Zachary Ware  
> escribió:
> 
> Hi Gustaf,
> 
> On Mon, Apr 4, 2016 at 9:38 PM, Gustaf Nilsson
>  wrote:
>> Hi!
>> 
>> The only 3.5.1 versio that works for me is the 32 bits version, will it be
>> a problem to use the 32 bits version for 64 bits computer?
> 
> From your mention of a 'launcher' I'm assuming you're on Windows.
> It's perfectly fine to use 32-bit Python on 64-bit Windows.  However,
> how exactly does the launcher for the 64-bit version not work?  What
> happens?  What did you expect to happen that didn't?  What error
> message do you get?  It's entirely possible that your version of
> Windows is in fact 32-bit, even though the computer itself has a
> 64-bit processor.
> 
> Hope this helps,
> -- 
> Zach
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: module alias in import statement

2016-04-04 Thread Rustom Mody
On Tuesday, April 5, 2016 at 2:17:24 AM UTC+5:30, Terry Reedy wrote:
> On 4/4/2016 11:31 AM, ast wrote:
> > hello
> >
>  import tkinter as tk
>  import tk.ttk as ttk
> >
> > Traceback (most recent call last):
> >   File "", line 1, in 
> > import tk.ttk as ttk
> > ImportError: No module named 'tk'
> >
> >
> > of course
> >
>  import tkinter.ttk as ttk
> >
> > works
> >
> > Strange, isn't it ?
> 
> Nope. As other said, 'import tkinter as tk' imports a module named 
> 'tkinter' and *in the importing modules, and only in the importing 
> module*, binds the module to 'tk'.  It also caches the module in 
> sys.modules under its real name, 'tkinter'.
> 
>  >>> import tkinter as tk
>  >>> import sys
>  >>> 'tkinter' in sys.modules
> True
>  >>> 'tk' in sys.modules
> False
> 
> 'import tk.ttk' looks for 'tk' in sys.modules, does not find it, looks 
> for a module named 'tk' on disk, does not find it, and says so.

A well-known quote comes to mind:

| There are only two hard things in Computer Science: cache invalidation and
| naming things.

eg. http://martinfowler.com/bliki/TwoHardThings.html

particularly since this seems to be in both categories :-)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Launcher for 64 bits doesnt work

2016-04-04 Thread Zachary Ware
Hi Gustaf,

On Mon, Apr 4, 2016 at 9:38 PM, Gustaf Nilsson
 wrote:
> Hi!
>
> The only 3.5.1 versio that works for me is the 32 bits version, will it be
> a problem to use the 32 bits version for 64 bits computer?

>From your mention of a 'launcher' I'm assuming you're on Windows.
It's perfectly fine to use 32-bit Python on 64-bit Windows.  However,
how exactly does the launcher for the 64-bit version not work?  What
happens?  What did you expect to happen that didn't?  What error
message do you get?  It's entirely possible that your version of
Windows is in fact 32-bit, even though the computer itself has a
64-bit processor.

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


[issue26693] Exception exceptions.AttributeError '_shutdown' in

2016-04-04 Thread Zachary Ware

Zachary Ware added the comment:

After your `import threading` line, try `print(threading.__file__)`.  The path 
should be something like `/usr/local/lib/python3.4/threading.py`; if it's not 
(particularly if the current directory is part of the path), you've found the 
source of your problem, and you should move/rename the extra threading.py, as 
suggested by Brandon in msg144004.

--
nosy: +zach.ware
resolution:  -> duplicate
status: open -> pending
superseder:  -> Exception exceptions.AttributeError '_shutdown' in 

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



Trouble trying to install Python 3.5.1 (32-bit) for windows

2016-04-04 Thread Yuri Armellei
Dear Python,

I  encountered difficulties when installing  the python.

Could you guys help me to solve and install it?!

Attached log error  to  help you guys to help me out. =)  ;)

Regards,



[cid:image001.png@01D18EA7.4A69B7E0]


[cid:image006.jpg@01D152DC.ACCAF540]

Yuri Armellei
Tesouraria
Tel.: +55 11 3034-5004 - Cel.: (11) 9.9916-8323
www.casadocredito.com.br

Av. Queiroz Filho, 1700 - Torre E - 9º. andar - conj. 907
Vila Hamburguesa - São Paulo - SP - Brasil - 05319-000



Este e-mail e qualquer documento anexo ao mesmo é destinado somente às pessoas 
elencadas acima, podendo conter informações confidenciais e ou legalmente 
privilegiadas. Se você não for um dos destinatários do presente e-mail e seus 
anexos, por meio do presente toma ciência que sua disseminação, distribuição ou 
cópia é estritamente proibida. Se tiver recebido este e-mail e seus anexos por 
engano, agradeço comunicação imediata através do telefone (11) 3034-5004 e 
exclusão permanente do original e de qualquer cópia ou impressão que tenha sido 
realizada.

This e-mail and any attachments thereto, are intended only for use by the 
addresses named herein and may contain legally privileged and or confidential 
information. If you are not the intended recipient of this e-mail, you are 
hereby notified that any dissemination, distribution or copying of this e-mail, 
and any attachments thereto, is strictly prohibited. If you have received this 
e-mail in error, please immediately notify me at +55(11) 3034-5004 and 
permanently delete the original and any copy of any e-mail and any printout 
thereof.

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


Launcher for 64 bits doesnt work

2016-04-04 Thread Gustaf Nilsson
Hi!

The only 3.5.1 versio that works for me is the 32 bits version, will it be
a problem to use the 32 bits version for 64 bits computer?
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue25928] Add Decimal.as_integer_ratio()

2016-04-04 Thread Raymond Hettinger

Raymond Hettinger added the comment:

I don't think a new public method should have been added.

Historically, we've been careful to not grow the API beyond what is in the spec 
or the dunder methods required to interface with standard Python.

The feature creep is at odds with the intended goals for the module that have 
been present since the outset.  As long as the spec remains unchanged, the API 
for this module should be treated as stable.

Another issue is that the API for the module is already so large that it 
impairs usability.  Please don't make it worse by adding new methods and 
inventing details that aren't in the spec.

--
nosy: +tim.peters

___
Python tracker 

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



[issue26609] Wrong request target in test_httpservers.py

2016-04-04 Thread Xiang Zhang

Xiang Zhang added the comment:

Get the slash prefixed path in Setup() is a good idea. I change the patch. I 
retain self.tempdir_name so we can use it in a test for no leading slash. The 
case creating index.html is OK with self.tempdir_name since we have changed our 
working directory to basetempdir.

I didn't think about compatibility but I know it's important. So rejecting the 
invalid request-targets is not a good idea to me now.

--
Added file: 
http://bugs.python.org/file42369/request_target_in_test_httpservers_v2.patch

___
Python tracker 

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



Re: How can I install

2016-04-04 Thread Steven D'Aprano
On Tue, 5 Apr 2016 05:51 am, Mohamed Ali wrote:

> 
> I have tried to install python and nltk but I couldn't. Please could you
> please help me because I need to work on natural language processing using
> Python.

There are about ten thousand different things that could be going wrong, "I
couldn't install" doesn't give us any of narrowing the problems down. We
can't read your mind. You have to tell us what you did and what went wrong.

What operating system are you using? Linux, Mac OS, Windows, FreeBSD,
OpenBSD, Android, something else? What version?

How did you try to install the packages? What did you do? Did the
installation appear to work? Was there a problem? Did the computer print an
error message, or crash, or BSOD? Catch fire?

If you get an error message, COPY and PASTE the error, in full. Don't
summarise, and especially don't retype it from memory. Don't send a
screen-shot: people won't be able to see it.

If the error message has been localised into some language other than
English, please provide the original error, and a translation into English,
if you can.

What happened when you try to run Python? How are you running it?

- type "python" into a command shell?

- double-click an icon on the desktop?

- choose "Python" from the Start menu?

- something else?


The more detail you can give, the better the chances we can help you. If you
give no detail, we can give no help.



-- 
Steven

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


Re: Plot/Graph

2016-04-04 Thread Steven D'Aprano
On Tue, 5 Apr 2016 08:33 am, Muhammad Ali wrote:

[couple of hundred lines of quoted text]

[followed by about a thousand lines of code]

Seriously? Do you really expect people to read through hundreds of lines of
quotes, going at least three levels > > > deep, and then read a thousand
lines of code, to do your work for you? For free?

We try to be friendly and helpful, but there are limits. Please read this
before replying:

http://www.sscce.org/


Thank you.


-- 
Steven

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


[issue26693] Exception exceptions.AttributeError '_shutdown' in

2016-04-04 Thread skydoom

skydoom added the comment:

This is how I compile my code:
CFLAG is obtained from `python3.5m-config --includes`
LDFLAG is obtained from `"python-3.5m-config --ldflags`
g++ ${CFLAG} ${LDFLAG} test2.C 

I am running on Linux.

--

___
Python tracker 

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



[issue26693] Exception exceptions.AttributeError '_shutdown' in

2016-04-04 Thread skydoom

New submission from skydoom:

I did a search and find the issue 1947, however it's set to "not a bug". In its 
last note, it's suggested a 'packaging/environment issue'. But since I can 
reliably reproduce the issue with the "official python package"(that installed 
by the system, such as I am not building the python from source), Also, the 
same issue does not occurred on python 2.6.2, but 3.4.3 and 3.5.1. Even though 
it seems the "AssertionError" message is non-harmful but it's still a bit 
annoying. I am wondering if you can take a look my issue?

Please compile the attached source codes to reproduce my issue. Note that it 
only occurred when we (explicitly or implicitly) import the 'threading' module. 
If we comment out that line, it works fine.

--
components: Library (Lib)
files: test2.C
messages: 262884
nosy: skydoom
priority: normal
severity: normal
status: open
title: Exception exceptions.AttributeError '_shutdown' in 
type: behavior
versions: Python 3.4, Python 3.5
Added file: http://bugs.python.org/file42368/test2.C

___
Python tracker 

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



Re: Best Practices for Internal Package Structure

2016-04-04 Thread Steven D'Aprano
On Tue, 5 Apr 2016 02:47 am, Josh B. wrote:

> My package, available at https://github.com/jab/bidict, is currently laid
> out like this:
> 
> bidict/
> ├── __init__.py
> ├── _bidict.py
> ├── _common.py
> ├── _frozen.py
> ├── _loose.py
> ├── _named.py
> ├── _ordered.py
> ├── compat.py
> ├── util.py


The purpose of packages isn't enable Java-style "one class per file" coding,
especially since *everything* in the package except the top level "bidict"
module itself is private. bidict.compat and bidict.util aren't flagged as
private, but they should be, since there's nothing in either of them that
the user of a bidict class should care about.

(utils.py does export a couple of functions, but they should be in the main
module, or possibly made into a method of BidirectionalMapping.)

Your package is currently under 500 lines. As it stands now, you could
easily flatten it to a single module:

bidict.py

Unless you are getting some concrete benefit from a package structure, you
shouldn't use a package just for the sake of it. Even if the code doubles
in size, to 1000 lines, that's still *far* below the point at which I
believe a single module becomes unwieldy just from size. At nearly 6500
lines, the decimal.py module is, in my opinion, *almost* at the point where
just size alone suggests splitting the file into submodules. Your module is
nowhere near that point.

It seems to me that you're paying the cost of the increased complexity
needed to handle a package, but not (as far as I can tell) gaining any
benefit from it. Certainly the *users* of your package aren't: all the
public classes are pre-imported by the __init__.py file, so they don't even
get the advantage of only needing to import classes that they actually use. 

So my recommendation would be to collapse the package to a single file.

If you choose to reject that recommendation, or perhaps you are getting some
benefit that I haven't spotted in a cursory look over the package, then my
suggestion is to document that the *only* public interface is the
top-level "import bidict", and that *all* submodules are private. Then drop
the underscores, possibly re-arrange a bit:


bidict/
├── __init__.py  # the only public part of the package
├── bidict.py
├── common.py  # includes compat and util
├── frozen.py
├── loose.py
├── named.py
├── ordered.py


If you're worried about the lack of underscores for private submodules, then
consider this alternate structure:


_bidict/
├── __init__.py
├── bidict.py
├── common.py
├── frozen.py
├── loose.py
├── named.py
├── ordered.py
bidict.py


where "bidict.py" is effectively little more than:

from _bidict import *



> What do you think of the code layout, specifically the use of the _foo
> modules? It seems well-factored to me, but I haven't seen things laid out
> this way very often in other projects, and I'd like to do this as nicely
> as possible.

It's very pretty, and well-organised, but I'm not sure you're actually
gaining any advantage from it.


> It does kind of bug me that you see the _foo modules in the output when
> you do things like this:
> 
 import bidict
 bidict.bidict
> 
 bidict.KeyExistsError
> 
> 
> 
> In https://github.com/jab/bidict/pull/33#issuecomment-205381351 a reviewer
> agrees:
> 
> """
> Me too, and it confuses people as to where you should be importing things
> from if you want to catch it, inviting code like
> 
> ```
> import bidict._common


That, at least, should be an obvious no-no, as it's including a single
underscore private name. I wouldn't worry about that too much: if your
users are so naive or obnoxious that they're ignoring your documentation
and importing _private modules, there's nothing you can do: they'll find
*some* way to shoot themselves in the foot, whatever you do.

[Aside: my devs at work had reason to look inside a script written by one of
their now long-moved away former colleagues yesterday, as it recently
broke. After reading the script, the *first* thing they did was change the
way it was called from:

scriptname --opts steve
# yes, he really did use my name as the mandatory argument to the script

to

scriptname --opts forfucksakeandrew

where the name "andrew" has been changed to protect the guilty. Using my
name as the script argument is, apparently, the *least* stupid thing the
script does.]


> try:
> ...
> except bidict._common.KeyExistsError:
> ...
> ```
> ie. becoming dependent on the package internal structure.
> 
> I would be tempted to monkey-patch .__module__ = __name__ on each imported
> class to get around this. Maybe there are downsides to doing magic of that
> kind, but dependencies on the internals of packages are such a problem for
> me in our very large codebase, that I'd probably do it anyway in order to
> really explicit about what the public API is. """

Does his team not do internal code reviews? I hate code that lies about
where it comes from. I certainly wouldn't do it in a futile attempt to
protect idiots from 

[issue3213] "pydoc -p" should listen to [::] if IPv6 is supported

2016-04-04 Thread Martin Panter

Martin Panter added the comment:

I understand Windows XP isn’t so important these days. So maybe we just need to 
disable IPV6_V6ONLY. (Unless we want this for 2.7 maybe?)

--
stage:  -> needs patch
versions: +Python 3.6 -Python 3.3

___
Python tracker 

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



Re: Plot/Graph

2016-04-04 Thread Muhammad Ali
On Tuesday, April 5, 2016 at 8:16:22 AM UTC+8, Muhammad Ali wrote:
> On Sunday, April 3, 2016 at 2:35:58 PM UTC-7, Oscar Benjamin wrote:
> > On 3 Apr 2016 22:21, "Muhammad Ali"  wrote:
> > >
> > >  How do I convert/change/modify python script so that my data could be
> > extracted according to python script and at the end it generates another
> > single extracted data file instead of displaying/showing some graph? So
> > that, I can manually plot the newly generated file (after data extraction)
> > by some other software like origin.
> > 
> > It depends what you're computing and what format origin expects the data to
> > be in. Presumably it can use CSV files so take a look at the CSV module
> > which can write these.
> > 
> > (You'll get better answers to a question like this if you show us some code
> > and ask a specific question about how to change it.)
> > 
> > --
> > Oscar
> 
> Yes, it is complete script and it works well with matplotlib.

But I have to modify it to extract data into a single .dat file instead of 
directly plotting it by using matplotlib. I want to plot the data file in some 
other software.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue26680] Incorporating float.is_integer into the numeric tower and Decimal

2016-04-04 Thread Raymond Hettinger

Raymond Hettinger added the comment:

* For most users, this will just be noise (even the existing float method is 
rarely used).   It is unimportant enough that Python existed without it for a 
very long time and it is unimportant enough that it didn't arise during the 
lengthy process of creating the decimal module.  

* The numeric tower doesn't require that we take new methods and push them to 
every type whether or not it makes sense.  Most of the ABCs have only a subset 
of the methods in the concrete types.

* There are already simple workarounds using a try/except or a conditional 
expression.

-1 I really don't want more clutter added to all the numeric classes.  (Clutter 
being something rarely needed, easily implemented in other ways, something that 
looks weird or confusing in classes like int or Fraction, something that we 
have done without to 26 years, something not covered by the decimal spec, and 
something that isn't part of the floats API for either Java* or Smalltalk)

* http://www.tutorialspoint.com/java/lang/java_lang_float.htm

--

___
Python tracker 

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



[issue26692] cgroups support in multiprocessing

2016-04-04 Thread Satrajit Ghosh

New submission from Satrajit Ghosh:

multiprocessing cpucount returns the number of cpus on the system as returned 
by /proc/cpuinfo. 

this is true even on machines where linux kernel cgroups is being used to 
restrict cpu usage for a given process. this results in significant thread 
swithcing on systems with many cores. 

some ideas have been implemented in the following repos to handle cgroups:

https://github.com/peo3/cgroup-utils
http://cpachecker.googlecode.com/svn-history/r12889/trunk/scripts/benchmark/runexecutor.py

it would be nice if multiprocessing was a little more intelligent and queried 
process characteristics.

--
components: Library (Lib)
messages: 262881
nosy: Satrajit Ghosh
priority: normal
severity: normal
status: open
title: cgroups support in multiprocessing
type: behavior

___
Python tracker 

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



Re: Request Help With Function

2016-04-04 Thread Wildman via Python-list
On Mon, 04 Apr 2016 21:02:53 +0100, MRAB wrote:

> On 2016-04-04 20:42, Wildman via Python-list wrote:



>> launch_help()
>>
> .Popen will accept either a string or a list of strings.
> 
> You're giving it a list that contains a string and a list.

Yep, that was my foolish mistake.  Thanks.

> BTW, I don't know what you mean by "you can't pass a list to a 
> function", because you can. How were you trying to do it?

The above mistake I made caused me to get a similar error
when I tried to pass the arguments as lists.  I made an
assumption that I should have not made.  After making
the correction Mr. Kelly suggested, I was able to rewrite
the code that way I had it (with the correction), passing
the arguments as lists and it works correctly.

The learning process continues... Thanks again.

-- 
 GNU/Linux user #557453
"Philosophy is common sense with big words."
  -James Madison
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Request Help With Function

2016-04-04 Thread Wildman via Python-list
On Mon, 04 Apr 2016 13:54:56 -0600, Ian Kelly wrote:

> On Mon, Apr 4, 2016 at 1:42 PM, Wildman via Python-list
>  wrote:
>> commandlist = commandlist.split(",")
> 
> commandlist is a list.
> 
>> command = [target, commandlist]
>> subprocess.Popen(command)
> 
> This is passing a list containing two elements: the first is a string,
> and the second is a list of strings. You should just pass a list of
> strings. Probably you wanted to do this:
> 
> command = [target] + commandlist

Thank you, that fixed the problem.  It did occur to me that the
problem was in how "command" was put together but I wasn't sure.
A rookie mistake from a rookie.  Whoda thunk it?

-- 
 GNU/Linux user #557453
Why is it that all instruments seeking intelligent
life in the universe are pointed away from Earth?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Plot/Graph

2016-04-04 Thread Muhammad Ali
On Sunday, April 3, 2016 at 2:35:58 PM UTC-7, Oscar Benjamin wrote:
> On 3 Apr 2016 22:21, "Muhammad Ali"  wrote:
> >
> >  How do I convert/change/modify python script so that my data could be
> extracted according to python script and at the end it generates another
> single extracted data file instead of displaying/showing some graph? So
> that, I can manually plot the newly generated file (after data extraction)
> by some other software like origin.
> 
> It depends what you're computing and what format origin expects the data to
> be in. Presumably it can use CSV files so take a look at the CSV module
> which can write these.
> 
> (You'll get better answers to a question like this if you show us some code
> and ask a specific question about how to change it.)
> 
> --
> Oscar

Yes, it is complete script and it works well with matplotlib.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Plot/Graph

2016-04-04 Thread MRAB

On 2016-04-04 23:35, Muhammad Ali wrote:

On Sunday, April 3, 2016 at 5:19:15 PM UTC-7, MRAB wrote:

On 2016-04-04 01:04, Muhammad Ali wrote:
> On Sunday, April 3, 2016 at 2:35:58 PM UTC-7, Oscar Benjamin wrote:
>> On 3 Apr 2016 22:21, "Muhammad Ali"  wrote:
>> >
>> >  How do I convert/change/modify python script so that my data could be
>> extracted according to python script and at the end it generates another
>> single extracted data file instead of displaying/showing some graph? So
>> that, I can manually plot the newly generated file (after data extraction)
>> by some other software like origin.
>>
>> It depends what you're computing and what format origin expects the data to
>> be in. Presumably it can use CSV files so take a look at the CSV module
>> which can write these.
>>
>> (You'll get better answers to a question like this if you show us some code
>> and ask a specific question about how to change it.)
>>
>> --
>> Oscar
>
> How could the python script be modified to generate data file rather than 
display a plot by using matplotlib?
>
>
> def make_plot(plot):
>  indent = plot.plot_options.indent
>  args = plot.plot_options.args
>  # Creating the plot
>  print ('Generating the plot...')
>  fig = plt.figure(figsize=(plot.fig_width_inches,plot.fig_height_inches))
>  ax = fig.add_subplot(111)
>  # Defining the color schemes.
>  print (indent + '>>> Using the "' + plot.cmap_name + '" colormap.')
>  if(plot.plot_options.using_default_cmap and not args.running_from_GUI):
>  print (2 * indent + 'Tip: You can try different colormaps by 
either:')
>  print (2 * indent + ' * Running the plot tool with the option 
-icmap n, ' \
> 'with n in the range from 0 to', len(plot.plot_options.cmaps) 
- 1)
>  print (2 * indent + ' * Running the plot tool with the option "-cmap 
cmap_name".')
>  print (2 * indent + '> Take a look at')
>  print (4 * indent + 
'')
>  print (2 * indent + '  for a list of colormaps, or run')
>  print (4 * indent + '"./plot_unfolded_EBS_BandUP.py --help".')
>
>  # Building the countour plot from the read data
>  # Defining the (ki,Ej) grid.
>  if(args.interpolation is not None):
>  ki = np.linspace(plot.kmin, plot.kmax, 2 * len(set(plot.KptsCoords)) 
+ 1, endpoint=True)
>  Ei = np.arange(plot.emin, plot.emax + plot.dE_for_hist2d, 
plot.dE_for_hist2d)
>  # Interpolating
>  grid_freq = griddata((plot.KptsCoords, plot.energies), 
plot.delta_Ns, (ki[None,:], Ei[:,None]),
>   method=args.interpolation, fill_value=0.0)
>  else:
>  ki = np.unique(np.clip(plot.KptsCoords, plot.kmin, plot.kmax))
>  Ei = np.unique(np.clip(plot.energies, plot.emin,  plot.emax))
>  grid_freq = griddata((plot.KptsCoords, plot.energies), 
plot.delta_Ns, (ki[None,:], Ei[:,None]),
>   method='nearest', fill_value=0.0)
>
>  if(not args.skip_grid_freq_clip):
>  grid_freq = grid_freq.clip(0.0) # Values smaller than zero are just 
noise.
>  # Normalizing and building the countour plot
>  manually_normalize_colorbar_min_and_maxval = False
>  if((args.maxval_for_colorbar is not None) or (args.minval_for_colorbar 
is not None)):
>  manually_normalize_colorbar_min_and_maxval = True
>  args.disable_auto_round_vmin_and_vmax = True
>  maxval_for_colorbar = args.maxval_for_colorbar
>  minval_for_colorbar = args.minval_for_colorbar
>  else:
>  if not args.disable_auto_round_vmin_and_vmax:
>  minval_for_colorbar = float(round(np.min(grid_freq)))
>  maxval_for_colorbar = float(round(np.max(grid_freq)))
>  args.round_cb = 0
>  if(manually_normalize_colorbar_min_and_maxval or not 
args.disable_auto_round_vmin_and_vmax):
>  modified_vmin_or_vmax = False
>  if not args.disable_auto_round_vmin_and_vmax and not 
args.running_from_GUI:
>  print (plot.indent + '* Automatically renormalizing color scale 
'\
> '(you can disable this with the option 
--disable_auto_round_vmin_and_vmax):')
>  if manually_normalize_colorbar_min_and_maxval:
>  print (plot.indent + '* Manually renormalizing color scale')
>  if(minval_for_colorbar is not None):
>  previous_vmin = np.min(grid_freq)
>  if(abs(previous_vmin - minval_for_colorbar) >= 0.1):
>  modified_vmin_or_vmax = True
>  print (2 * indent + 'Previous vmin = %.1f, new vmin = %.1f' 
% (previous_vmin,
>   
  minval_for_colorbar))
>  else:
>  minval_for_colorbar = np.min(grid_freq)
>  if(maxval_for_colorbar is not None):
>  

[issue25609] Add a ContextManager ABC and type

2016-04-04 Thread Brett Cannon

Brett Cannon added the comment:

Tracker issue created and assigned.

--

___
Python tracker 

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



[issue26691] Update the typing module to match what's in github.com/python/typing

2016-04-04 Thread Brett Cannon

New submission from Brett Cannon:

The code in Lib/typing.py is outdated compared to what's at 
github.com/python/typing.

--
assignee: gvanrossum
messages: 262879
nosy: brett.cannon, gvanrossum
priority: normal
severity: normal
status: open
title: Update the typing module to match what's in github.com/python/typing

___
Python tracker 

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



[issue25609] Add a ContextManager ABC and type

2016-04-04 Thread Brett Cannon

Changes by Brett Cannon :


--
dependencies: +Update the typing module to match what's in 
github.com/python/typing

___
Python tracker 

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



testing python program,project and django site

2016-04-04 Thread Xristos Xristoou
hello,

i am python user and i have some projects,programs and sites with django
in python.
i want one more step deeper,i want to test my programs for
bugs,weaknesses,vulnerability,security or penetration test,on my sites for 
crashes(because use python apps).because the user i am now on the feature maybe 
i have thousand users to work with my programs.
can you tell me how to find this?some propram to do that or some for that ?
some method to do that?
some program to testing the programs?

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


Re: From email addresses sometimes strange on this list - was Re: [beginner] What's wrong?

2016-04-04 Thread Michael Torrie
On 04/04/2016 04:58 PM, Chris Angelico wrote:
> O That probably explains it. It's because of Yahoo and mailing
> lists. Yahoo did stuff that breaks stuff, so Mailman breaks stuff
> differently to make sure that only Yahoo people get messed up a bit.
> It means their names and addresses get slightly obscured, but delivery
> works.

That explains it! The other folks with messages like that are coming
from Yahoo as well.  I can live with it.

Thank you!
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue26632] __all__ decorator

2016-04-04 Thread Barry A. Warsaw

Barry A. Warsaw added the comment:

Here's my implementation based on eryksun's idea:

def public(thing=None, **kws):
mdict = (sys._getframe(1).f_globals
 if thing is None
 else sys.modules[thing.__module__].__dict__)
dunder_all = mdict.setdefault('__all__', [])
if thing is not None:
dunder_all.append(thing.__name__)
for key, value in kws.items():
dunder_all.append(key)
mdict[key] = value
return thing

--

___
Python tracker 

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



[issue3213] "pydoc -p" should listen to [::] if IPv6 is supported

2016-04-04 Thread Josh Lee

Changes by Josh Lee :


--
nosy: +jleedev

___
Python tracker 

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



[issue24209] Allow IPv6 bind in http.server

2016-04-04 Thread Josh Lee

Changes by Josh Lee :


--
nosy: +jleedev

___
Python tracker 

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



Re: From email addresses sometimes strange on this list - was Re: [beginner] What's wrong?

2016-04-04 Thread Chris Angelico
On Tue, Apr 5, 2016 at 8:55 AM, Michael Torrie  wrote:
> Usenet-orginating posts look fine.  For example:
>
> From: Marko Rauhamaa 
> Newsgroups: comp.lang.python
>
> Whereas email ones are sometimes looking like this:
>
> From: Mark Lawrence via Python-list 
> Reply-To: Mark Lawrence 

O That probably explains it. It's because of Yahoo and mailing
lists. Yahoo did stuff that breaks stuff, so Mailman breaks stuff
differently to make sure that only Yahoo people get messed up a bit.
It means their names and addresses get slightly obscured, but delivery
works.

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


[issue25609] Add a ContextManager ABC and type

2016-04-04 Thread Guido van Rossum

Guido van Rossum added the comment:

No, but feel free to create one and assign it to me -- I will take
care of the rest then.

--

___
Python tracker 

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



From email addresses sometimes strange on this list - was Re: [beginner] What's wrong?

2016-04-04 Thread Michael Torrie
On 04/04/2016 08:04 AM, Mark Lawrence via Python-list wrote:
> On 02/04/2016 23:49, Michael Torrie wrote:
>> Mark, your messages are showing up to the list as being from "python,"
>> at least on my email.  Any reason for this?
>>
> 
> Assuming that you're referring to me, frankly I haven't a clue.  I read 
> this list with Thunderbird on Windows, I hit "reply" to something, I 
> type, I hit "send", job done.  Thereafter, as far as I'm concerned, a 
> miracle occurs and hundreds if not thousands of subscribers get to see 
> my reply.

Interesting.  The problem is definitely not on your end at all, though I
first noticed this with your recent posts. Other posts are showing up a
bit weirdly too.  The problem appears to be partly in my Thunderbird
client, and partly the mailing list gateway.  And maybe Gmail is
screwing things up too. Usenet-orginating posts look fine.  For example:

From: Marko Rauhamaa 
Newsgroups: comp.lang.python

Whereas email ones are sometimes looking like this:

From: Mark Lawrence via Python-list 
Reply-To: Mark Lawrence 

Thunderbird on my machine is only seeing the From email address
(python-list@python.org) and I must have that in my address list
somewhere as "python."

What's odder is that my own messages show up as "From:
torr...@gmail.com" and not "via Python-list ".



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


[issue25609] Add a ContextManager ABC and type

2016-04-04 Thread Brett Cannon

Brett Cannon added the comment:

Is there a tracking issue I can set as a dependency?

--

___
Python tracker 

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



Re: Plot/Graph

2016-04-04 Thread Muhammad Ali
On Sunday, April 3, 2016 at 5:19:15 PM UTC-7, MRAB wrote:
> On 2016-04-04 01:04, Muhammad Ali wrote:
> > On Sunday, April 3, 2016 at 2:35:58 PM UTC-7, Oscar Benjamin wrote:
> >> On 3 Apr 2016 22:21, "Muhammad Ali"  wrote:
> >> >
> >> >  How do I convert/change/modify python script so that my data could be
> >> extracted according to python script and at the end it generates another
> >> single extracted data file instead of displaying/showing some graph? So
> >> that, I can manually plot the newly generated file (after data extraction)
> >> by some other software like origin.
> >>
> >> It depends what you're computing and what format origin expects the data to
> >> be in. Presumably it can use CSV files so take a look at the CSV module
> >> which can write these.
> >>
> >> (You'll get better answers to a question like this if you show us some code
> >> and ask a specific question about how to change it.)
> >>
> >> --
> >> Oscar
> >
> > How could the python script be modified to generate data file rather than 
> > display a plot by using matplotlib?
> >
> >
> > def make_plot(plot):
> >  indent = plot.plot_options.indent
> >  args = plot.plot_options.args
> >  # Creating the plot
> >  print ('Generating the plot...')
> >  fig = 
> > plt.figure(figsize=(plot.fig_width_inches,plot.fig_height_inches))
> >  ax = fig.add_subplot(111)
> >  # Defining the color schemes.
> >  print (indent + '>>> Using the "' + plot.cmap_name + '" colormap.')
> >  if(plot.plot_options.using_default_cmap and not args.running_from_GUI):
> >  print (2 * indent + 'Tip: You can try different colormaps by 
> > either:')
> >  print (2 * indent + ' * Running the plot tool with the option 
> > -icmap n, ' \
> > 'with n in the range from 0 to', 
> > len(plot.plot_options.cmaps) - 1)
> >  print (2 * indent + ' * Running the plot tool with the option 
> > "-cmap cmap_name".')
> >  print (2 * indent + '> Take a look at')
> >  print (4 * indent + 
> > '')
> >  print (2 * indent + '  for a list of colormaps, or run')
> >  print (4 * indent + '"./plot_unfolded_EBS_BandUP.py --help".')
> >
> >  # Building the countour plot from the read data
> >  # Defining the (ki,Ej) grid.
> >  if(args.interpolation is not None):
> >  ki = np.linspace(plot.kmin, plot.kmax, 2 * 
> > len(set(plot.KptsCoords)) + 1, endpoint=True)
> >  Ei = np.arange(plot.emin, plot.emax + plot.dE_for_hist2d, 
> > plot.dE_for_hist2d)
> >  # Interpolating
> >  grid_freq = griddata((plot.KptsCoords, plot.energies), 
> > plot.delta_Ns, (ki[None,:], Ei[:,None]),
> >   method=args.interpolation, fill_value=0.0)
> >  else:
> >  ki = np.unique(np.clip(plot.KptsCoords, plot.kmin, plot.kmax))
> >  Ei = np.unique(np.clip(plot.energies, plot.emin,  plot.emax))
> >  grid_freq = griddata((plot.KptsCoords, plot.energies), 
> > plot.delta_Ns, (ki[None,:], Ei[:,None]),
> >   method='nearest', fill_value=0.0)
> >
> >  if(not args.skip_grid_freq_clip):
> >  grid_freq = grid_freq.clip(0.0) # Values smaller than zero are 
> > just noise.
> >  # Normalizing and building the countour plot
> >  manually_normalize_colorbar_min_and_maxval = False
> >  if((args.maxval_for_colorbar is not None) or (args.minval_for_colorbar 
> > is not None)):
> >  manually_normalize_colorbar_min_and_maxval = True
> >  args.disable_auto_round_vmin_and_vmax = True
> >  maxval_for_colorbar = args.maxval_for_colorbar
> >  minval_for_colorbar = args.minval_for_colorbar
> >  else:
> >  if not args.disable_auto_round_vmin_and_vmax:
> >  minval_for_colorbar = float(round(np.min(grid_freq)))
> >  maxval_for_colorbar = float(round(np.max(grid_freq)))
> >  args.round_cb = 0
> >  if(manually_normalize_colorbar_min_and_maxval or not 
> > args.disable_auto_round_vmin_and_vmax):
> >  modified_vmin_or_vmax = False
> >  if not args.disable_auto_round_vmin_and_vmax and not 
> > args.running_from_GUI:
> >  print (plot.indent + '* Automatically renormalizing color 
> > scale '\
> > '(you can disable this with the option 
> > --disable_auto_round_vmin_and_vmax):')
> >  if manually_normalize_colorbar_min_and_maxval:
> >  print (plot.indent + '* Manually renormalizing color scale')
> >  if(minval_for_colorbar is not None):
> >  previous_vmin = np.min(grid_freq)
> >  if(abs(previous_vmin - minval_for_colorbar) >= 0.1):
> >  modified_vmin_or_vmax = True
> >  print (2 * indent + 'Previous vmin = %.1f, new vmin = 
> > %.1f' % (previous_vmin,
> > 

[issue24505] shutil.which wrong result on Windows

2016-04-04 Thread Bob Alexander

Bob Alexander added the comment:

Oops, clarification...

I just reread my kind of long previous post, and realized it wasn't very 
explicit that anything concerning file extensions or prepending the current 
directory to the PATH apply to Windows only; not Unix (of course).

The "returning absolute, normalized paths" suggestions are multi-platform

I only tested the modified code on Windows.

--

___
Python tracker 

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



[issue25609] Add a ContextManager ABC and type

2016-04-04 Thread Guido van Rossum

Guido van Rossum added the comment:

I have some significant changes to typing.py (and test_typing.py)
upstream in https://github.com/python/typing/. We should coordinate
our changes to stdlib (test_)typing.py.

--

___
Python tracker 

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



[issue25609] Add a ContextManager ABC and type

2016-04-04 Thread Brett Cannon

Brett Cannon added the comment:

When I have a chance I'll do up a new patch where the definition of 
typing.ContextManager is guarded, add a What's New entry, and commit it. My 
planned guard will be:

if hasattr(contextlib, 'AbstractContextManager'):
class ContextManager(...): ...
__all__.append('ContextManager')

--

___
Python tracker 

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



[issue25609] Add a ContextManager ABC and type

2016-04-04 Thread Guido van Rossum

Guido van Rossum added the comment:

(Everything else looks great BTW.)

--

___
Python tracker 

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



qutebrowser v0.6.0 released!

2016-04-04 Thread Florian Bruhin
Hi,

I'm happy to annouce the release of qutebrowser v0.6.0!

qutebrowser is a vim-like browser with a minimal user interface, based
on Qt and Python: http://www.qutebrowser.org/

This release comes with dozens of bugfixes and various new features -
the most notable one probably being a :buffers command with
completion. Talking about completion, it now completes everything e.g.
containing "github" and "qutebrowser" when doing ":open github
qutebrowser" which makes it much easier to find pages in the history.

sidenote: If you haven't seen it yet, qutebrowser's crowdfunding for
the QtWebEngine backend is still running: http://igg.me/at/qutebrowser

The full changelog:

Added
~

- New `:buffer` command to easily switch tabs by name. This is not bound to a
  key by default for existing users due to a conflict with the `gt`/`gT`
  bindings (which are now removed from the default bindings).
  You can bind it by hand by running `:bind -f gt set-cmd-text -s :buffer`.
- New `--quiet` argument for the `:debug-pyeval` command to not open a tab with
  the results. Note `:debug-pyeval` is still only intended for debugging.
- The completion now matches each entered word separately.
- A new command `:paste-primary` got added to paste the primary selection, and
  `` got added as a binding so it pastes primary rather than
  clipboard.
- New mode `word` for `hints -> mode` which uses a dictionary and link-texts
  for hints instead of single characters.
- New `--all` argument for `:download-cancel` to cancel all running downloads.
- New `password_fill` userscript to fill passwords using the `pass` executable.
- New `current` hinting mode which forces opening hints in the current tab
  (even with `target="_blank"`)

Changed
~~~

- Pasting multiple lines via `:paste` now opens each line in a new tab.
- `:navigate increment/decrement` now preserves leading zeroes in URLs.
- `general -> editor` can now also handle `{}` inside another argument (e.g. to 
open `vim` via `termite`)
- Improved performance when scrolling with many tabs open.
- Shift-Insert now also pastes primary selection for prompts.
- `:download-remove --all` got un-deprecated to provide symmetry with
  `:download-cancel --all`. It does the same as `:download-clear`.
- Improved detection of URLs/search terms when pasting multiple lines.
- Don't remove `qutebrowser-editor-*` temporary file if editor subprocess 
crashed
- Userscripts are also searched in `/usr/share/qutebrowser/userscripts`.
- Blocked hosts are now also read from a `blocked-hosts` file in the config dir
  (e.g. `~/.config/qutebrowser/blocked-hosts`).

Fixed
~

- Fixed starting with -c "".
- Fixed crash when a tab is closed twice via javascript (e.g. Dropbox
  authentication dialogs)
- Fixed crash when a notification/geolocation prompt is answered after closing
  the tab it belongs to.
- Fixed crash when downloading a file without any path information (e.g a
  magnet link).
- Fixed crashes when opening an empty URL (e.g. via pasting).
- Fixed validation of duplicate values in `hints -> chars`.
- Fixed crash when PDF.js was partially installed.
- Fixed crash when XDG_DOWNLOAD_DIR was not an absolute path.
- Fixed very long filenames when downloading `data://`-URLs.
- Fixed ugly UI fonts on Windows when Liberation Mono is installed
- Fixed crash when unbinding key from a section which doesn't exist in the 
config
- Fixed report window after a segfault
- Fixed some directory browser issues on Windows
- Fixed crash when closing a window with a finished download and delayed
  `remove-finished-downloads` setting.
- Fixed crash when hitting `` then `` on pages without keyboard
  focus.
- Fixed "Frame load interrupted by policy change" error showing up when
  downloading files with Qt 5.6.

Removed
~~~

- The `gt`/`gT` bindings (luakit-like alternatives to `J`/`K`) were removed
  (except for existing configs) to make room for the `gt` binding to show
  buffers.

Since v0.5.0, the following people have contributed to qutebrowser:

- Daniel Schadt
- Felix Van der Jeugt
- Tarcisio Fedrizzi
- Philipp Hansch
- Kevin Velghe
- avk
- Milan Svoboda
- Clayton Craft
- Oliver Caldwell
- Thorsten Wißmann
- Jakub Klinkovský
- Patric Schmitz
- Michael Ilsaas
- Jimmy
- Link
- Ryan Roden-Corrent
- Marcelo Santos
- issue
- haxwithaxe
- evan
- Tomasz Kramkowski
- Tomas Orsava
- Tobias Werth
- Stefan Tatschner
- Sorokin Alexei
- Alexander Cogneau

Thank you!

Florian

-- 
http://www.the-compiler.org | m...@the-compiler.org (Mail/XMPP)
   GPG: 916E B0C8 FD55 A072 | http://the-compiler.org/pubkey.asc
 I love long mails! | http://email.is-not-s.ms/


signature.asc
Description: Digital signature
-- 
https://mail.python.org/mailman/listinfo/python-announce-list

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


Twisted 16.1 Release Announcement

2016-04-04 Thread Amber "Hawkie" Brown
On behalf of Twisted Matrix Laboratories, I am honoured to announce the release 
of Twisted 16.1!

This release is hot off the heels of 16.0 released last month, including some 
nice little tidbits. The highlights include:

- twisted.application.internet.ClientService, a service that maintains a 
persistent outgoing endpoint-based connection -- a replacement for 
ReconnectingClientFactory that uses modern APIs;
- A large (77% on one benchmark) performance improvement when using 
twisted.web's client on PyPy;
- A few conch modules have been ported to Python 3, in preparation for further 
porting of the SSH functionality;
- Full support for OpenSSL 1.0.2f and above;
- t.web.http.Request.addCookie now accepts Unicode and bytes keys/values;
- `twistd manhole` no longer uses a hard-coded SSH host key, and will generate 
one for you on the fly (this adds a 'appdirs' PyPI dependency, installing with 
[conch] will add it automatically);
- Over eighteen tickets overall closed since 16.0.

For more information, check the NEWS file (link provided below).

You can find the downloads at  (or 
alternatively ). The NEWS file is 
also available at .

Many thanks to everyone who had a part in this release - the supporters of the 
Twisted Software Foundation, the developers who contributed code as well as 
documentation, and all the people building great things with Twisted!

Twisted Regards,
Amber Brown (HawkOwl)


signature.asc
Description: Message signed with OpenPGP using GPGMail
-- 
https://mail.python.org/mailman/listinfo/python-announce-list

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


Re: IDLE's subprocess didn't make connection. Either IDLE can't start or personal firewall software is blocking connection.

2016-04-04 Thread Terry Reedy

On 4/4/2016 4:19 PM, Steven Gao wrote:

I’m getting “IDLE's subprocess didn't make connection. Either IDLE can't start 
or personal firewall software is blocking connection.”. Any ideas?


Depending on how you started, another possibility is a file in your 
local directory that masks a stdlib module.  Or a network (socket) 
configuration issue.



--
Terry Jan Reedy


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


[issue25942] subprocess.call SIGKILLs too liberally

2016-04-04 Thread Martin Panter

Martin Panter added the comment:

Even if we can’t agree on any behaviour change, I think it might be worth 
documenting how these functions behave on exceptions (interrupts) other than 
TimeoutExpired. Currently all I can find is “If the timeout expires, the child 
process will be killed and waited for.” I think this could be expanded to also 
say what happens if the parent is interrupted by a signal such as 
KeyboardInterrupt:

* Current behaviour: Immediately kill child (i.e. timeout expiry is not special)

* Previous behaviour: Return without waiting for child, which will become a 
zombie

* Mike’s proposal: Wait indefinitely for child without killing it, which could 
defeat the purpose of the timeout, especially if the child ignores or does not 
receive the same signal as the parent

--

___
Python tracker 

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



[issue25609] Add a ContextManager ABC and type

2016-04-04 Thread Guido van Rossum

Guido van Rossum added the comment:

A slight problem is that I'd really like to keep the source of typing.py 
identical in Python 3.5 and 3.6. So maybe the definition should be conditional 
on the presence of AbstractContextManager?

--

___
Python tracker 

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



[issue21048] Index 'as' in import and with statements

2016-04-04 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Second try.

--

___
Python tracker 

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



[issue12494] subprocess: check_output() doesn't close pipes on error

2016-04-04 Thread Martin Panter

Martin Panter added the comment:

As I understand it, this change only made it to 3.3+

--
nosy: +martin.panter
versions:  -Python 2.7, Python 3.2

___
Python tracker 

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



Re: [Beginner] - Hanging in the code, can't figure out what's wrong

2016-04-04 Thread Ben Finney
"Loop.IO"  writes:

> You now seem to be on some sort of rampage

You've mis-interpreted Erik's attempts to help. Somehow the requests for
details have made you defensive; I'm not sure why. Erik certainly was
not being hostile to you.

Hopefully you can take a more dispassionate position when you ask the
volunteers here for help next time.

-- 
 \ “Education is learning what you didn't even know you didn't |
  `\  know.” —Daniel J. Boorstin, historian, 1914–2004 |
_o__)  |
Ben Finney

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


Re: IDLE's subprocess didn't make connection. Either IDLE can't start or personal firewall software is blocking connection.

2016-04-04 Thread Mark Lawrence via Python-list

On 04/04/2016 21:19, Steven Gao wrote:

I’m getting “IDLE's subprocess didn't make connection. Either IDLE can't start 
or personal firewall software is blocking connection.”. Any ideas?

Sent from Mail for Windows 10



Asked and answered repeatedly, please search the archives for the answer.

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

Mark Lawrence

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


Re: module alias in import statement

2016-04-04 Thread Terry Reedy

On 4/4/2016 11:31 AM, ast wrote:

hello


import tkinter as tk
import tk.ttk as ttk


Traceback (most recent call last):
  File "", line 1, in 
import tk.ttk as ttk
ImportError: No module named 'tk'


of course


import tkinter.ttk as ttk


works

Strange, isn't it ?


Nope. As other said, 'import tkinter as tk' imports a module named 
'tkinter' and *in the importing modules, and only in the importing 
module*, binds the module to 'tk'.  It also caches the module in 
sys.modules under its real name, 'tkinter'.


>>> import tkinter as tk
>>> import sys
>>> 'tkinter' in sys.modules
True
>>> 'tk' in sys.modules
False

'import tk.ttk' looks for 'tk' in sys.modules, does not find it, looks 
for a module named 'tk' on disk, does not find it, and says so.


--
Terry Jan Reedy

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


IDLE's subprocess didn't make connection. Either IDLE can't start or personal firewall software is blocking connection.

2016-04-04 Thread Steven Gao
I’m getting “IDLE's subprocess didn't make connection. Either IDLE can't start 
or personal firewall software is blocking connection.”. Any ideas?

Sent from Mail for Windows 10



---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue21048] Index 'as' in import and with statements

2016-04-04 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Test email to see if I can get tracker email at different address, now the 
google is dumping some tracker email.  Issue selected as it is closed and I am 
only nosy listed.

--

___
Python tracker 

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



Re: Best Practices for Internal Package Structure

2016-04-04 Thread Mark Lawrence via Python-list

On 04/04/2016 19:45, Michael Selik wrote:

On Mon, Apr 4, 2016 at 6:04 PM Sven R. Kunze  wrote:


Hi Josh,

good question.

On 04.04.2016 18:47, Josh B. wrote:

My package, available at https://github.com/jab/bidict, is currently

laid out like this:


bidict/
├── __init__.py
├── _bidict.py
├── _common.py
├── _frozen.py
├── _loose.py
├── _named.py
├── _ordered.py
├── compat.py
├── util.py


I'd like to get some more feedback on a question about this layout that

I originally asked here: <
https://github.com/jab/bidict/pull/33#issuecomment-193877248>:


What do you think of the code layout, specifically the use of the _foo

modules? It seems well-factored to me, but I haven't seen things laid out
this way very often in other projects, and I'd like to do this as nicely as
possible.



Using the _module.py convention for internals is fine, except that you have
few enough lines of code that you could have far fewer files. Why create a
package when you can just have a module, bidict.py?

I find it easier to find the right section of my code when I have just a
few files open rather than a dozen or so in different windows and tabs.



+1

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

Mark Lawrence

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


Re: How can I install

2016-04-04 Thread MRAB

On 2016-04-04 20:51, Mohamed Ali via Python-list wrote:


I have tried to install python and nltk but I couldn't. Please could you please 
help me because I need to work on natural language processing using Python.


You haven't given any details.

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


Re: Request Help With Function

2016-04-04 Thread MRAB

On 2016-04-04 20:42, Wildman via Python-list wrote:

I am working on a Linux gui program where I want to be able
to click a Help button and open a man page using a viewer.
I wrote a search function that can be called several times,
if needed, with different arguments.  I wrote a test program
that tries to open the Bash man page in a terminal and will
display a message box if the search fails.  It passes the
system path, terminal emulators and command line arguments
to the search function.  I appears that you can't pass a list
to a function so I am passing the arguments as strings and then
converting them to lists for parsing in the search function.

When I run the test program, I get this error:

Traceback (most recent call last):
   File "./man.py", line 38, in 
 launch_help()
   File "./man.py", line 10, in launch_help
 if search(pathlist, executelist, commandlist):
   File "./man.py", line 27, in search
 subprocess.Popen(command)
   File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
 errread, errwrite)
   File "/usr/lib/python2.7/subprocess.py", line 1335, in _execute_child
 raise child_exception
TypeError: execv() arg 2 must contain only strings

I have not been able to figure out why I'm getting the error.
Any help would be appreciated.  Below is the complete code for
the test program:

#!/usr/bin/env python

import os, subprocess, tkMessageBox

def launch_help():
 pathlist = os.environ["PATH"]
 executelist = "xvt,xfce4-terminal"
 commandlist = "-e,man bash"
 if search(pathlist, executelist, commandlist):
 return None
 message = "Open a terminal and enter:  man bash"
 tkMessageBox.showinfo("Help", message)

def search(pathlist, executelist, commandlist):
 pathlist = pathlist.split(":")
 executelist = executelist.split(",")
 commandlist = commandlist.split(",")
 done = False
 for path in pathlist:
 for execute in executelist:
 target = path + "/" + execute
 if os.path.isfile(target):
 done = True
 command = [target, commandlist]
 subprocess.Popen(command)
 if done:
 break
 if done:
 break
 if done:
 return True
 else:
 return False


launch_help()


.Popen will accept either a string or a list of strings.

You're giving it a list that contains a string and a list.

BTW, I don't know what you mean by "you can't pass a list to a 
function", because you can. How were you trying to do it?


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


How can I install

2016-04-04 Thread Mohamed Ali via Python-list

I have tried to install python and nltk but I couldn't. Please could you please 
help me because I need to work on natural language processing using Python.

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


Re: Request Help With Function

2016-04-04 Thread Ian Kelly
On Mon, Apr 4, 2016 at 1:42 PM, Wildman via Python-list
 wrote:
> commandlist = commandlist.split(",")

commandlist is a list.

> command = [target, commandlist]
> subprocess.Popen(command)

This is passing a list containing two elements: the first is a string,
and the second is a list of strings. You should just pass a list of
strings. Probably you wanted to do this:

command = [target] + commandlist
-- 
https://mail.python.org/mailman/listinfo/python-list


Request Help With Function

2016-04-04 Thread Wildman via Python-list
I am working on a Linux gui program where I want to be able
to click a Help button and open a man page using a viewer.
I wrote a search function that can be called several times,
if needed, with different arguments.  I wrote a test program
that tries to open the Bash man page in a terminal and will
display a message box if the search fails.  It passes the
system path, terminal emulators and command line arguments
to the search function.  I appears that you can't pass a list
to a function so I am passing the arguments as strings and then
converting them to lists for parsing in the search function.

When I run the test program, I get this error:

Traceback (most recent call last):
  File "./man.py", line 38, in 
launch_help()
  File "./man.py", line 10, in launch_help
if search(pathlist, executelist, commandlist):
  File "./man.py", line 27, in search
subprocess.Popen(command)
  File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1335, in _execute_child
raise child_exception
TypeError: execv() arg 2 must contain only strings

I have not been able to figure out why I'm getting the error.
Any help would be appreciated.  Below is the complete code for
the test program:

#!/usr/bin/env python

import os, subprocess, tkMessageBox

def launch_help():
pathlist = os.environ["PATH"]
executelist = "xvt,xfce4-terminal"
commandlist = "-e,man bash"
if search(pathlist, executelist, commandlist):
return None
message = "Open a terminal and enter:  man bash"
tkMessageBox.showinfo("Help", message)

def search(pathlist, executelist, commandlist):
pathlist = pathlist.split(":")
executelist = executelist.split(",")
commandlist = commandlist.split(",")
done = False
for path in pathlist:
for execute in executelist:
target = path + "/" + execute
if os.path.isfile(target):
done = True
command = [target, commandlist]
subprocess.Popen(command)
if done:
break
if done:
break
if done:
return True
else:
return False


launch_help()

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue19944] Make importlib.find_spec load packages as needed

2016-04-04 Thread Eric Snow

Eric Snow added the comment:

Yeah, I'm pretty sure that TODO is out of date.

--

___
Python tracker 

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



[issue26690] PyUnicode_Decode breaks when Python / sqlite3 is built with sqlite 3.12.0

2016-04-04 Thread mike bayer

mike bayer added the comment:

i realized this is probably with my build overall.  let me do some more testing 
and ill reopen if i can confirm this more closely.

--
resolution:  -> works for me
status: open -> closed

___
Python tracker 

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



[issue26690] PyUnicode_Decode breaks when Python / sqlite3 is built with sqlite 3.12.0

2016-04-04 Thread mike bayer

New submission from mike bayer:

So I really don't know *where* the issue is in this one, because I don't know 
enough about the different bits.

Step 1:  Save this C program to demo.c:

#include 

static PyObject *
unicode_thing(PyObject *self, PyObject *value)
{
char *str;
Py_ssize_t len;

if (value == Py_None)
Py_RETURN_NONE;

if (PyString_AsStringAndSize(value, , ))
return NULL;

   return PyUnicode_Decode(str, len, "utf-8", "ignore");
}


static PyMethodDef UnicodeMethods[] = {
{"unicode_thing",  unicode_thing, METH_O,
 "do a unicode thing."},
{NULL, NULL, 0, NULL}/* Sentinel */
};



PyMODINIT_FUNC
initdemo(void)
{
(void) Py_InitModule("demo", UnicodeMethods);
}


Step 2:  Build with a setup.py:

from distutils.core import setup, Extension

module1 = Extension('demo',
sources = ['demo.c'])

setup (name = 'PackageName',
   version = '1.0',
   description = 'This is a demo package',
   ext_modules = [module1])


$ python setup.py build_ext

3. Run with a normal Python that is *not* built against SQLite 3.12.0:

$ python
Python 2.7.10 (default, Sep  8 2015, 17:20:17) 
[GCC 5.1.1 20150618 (Red Hat 5.1.1-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import demo
>>> demo.unicode_thing('sql')
u'sql'

4. Now build Python 2.7.11 *with* SQLite 3.12.0 in the -I / -L paths.  Run the 
same program *With* that Python:

$ /opt/Python-2.7.11-sqlite-3.12.0/bin/python
Python 2.7.11 (default, Apr  4 2016, 14:20:47) 
[GCC 5.3.1 20151207 (Red Hat 5.3.1-2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import demo
>>> demo.unicode_thing('sql')
u's\x00q'

Somehow the presence of sqlite-3.12.0 in the build is breaking the Python 
interpreter.   I think.  I really don't know.   The bad news is, this is the 
code for SQLAlchemy's unicode processor, and as SQlite 3.12.0 starts getting 
put in distros, the world is going to break.  So this is kind of really hard to 
test, I don't understand it, and it's totally urgent.  Any insights would be 
appreciated!

--
components: Extension Modules
messages: 262864
nosy: zzzeek
priority: normal
severity: normal
status: open
title: PyUnicode_Decode breaks when Python / sqlite3 is built with sqlite 3.12.0
versions: Python 2.7

___
Python tracker 

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



[issue26689] Add `has_flag` method to `distutils.CCompiler`

2016-04-04 Thread Sylvain Corlay

Sylvain Corlay added the comment:

A new version of the patch using `NamedTemporaryFile` instead a the regular 
fdopen.

--
Added file: http://bugs.python.org/file42367/has_flag.diff

___
Python tracker 

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



[issue19944] Make importlib.find_spec load packages as needed

2016-04-04 Thread Terry J. Reedy

Terry J. Reedy added the comment:

pyclbr.py has this comment
   # XXX This will change once issue19944 lands.
above the line that was changed by the patch applied.  Am I correct in thinking 
that the comment is obsolete and should be removed?

--
nosy: +terry.reedy

___
Python tracker 

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



Re: Best Practices for Internal Package Structure

2016-04-04 Thread Michael Selik
On Mon, Apr 4, 2016 at 6:04 PM Sven R. Kunze  wrote:

> Hi Josh,
>
> good question.
>
> On 04.04.2016 18:47, Josh B. wrote:
> > My package, available at https://github.com/jab/bidict, is currently
> laid out like this:
> >
> > bidict/
> > ├── __init__.py
> > ├── _bidict.py
> > ├── _common.py
> > ├── _frozen.py
> > ├── _loose.py
> > ├── _named.py
> > ├── _ordered.py
> > ├── compat.py
> > ├── util.py
> >
> >
> > I'd like to get some more feedback on a question about this layout that
> I originally asked here: <
> https://github.com/jab/bidict/pull/33#issuecomment-193877248>:
> >
> > What do you think of the code layout, specifically the use of the _foo
> modules? It seems well-factored to me, but I haven't seen things laid out
> this way very often in other projects, and I'd like to do this as nicely as
> possible.
>

Using the _module.py convention for internals is fine, except that you have
few enough lines of code that you could have far fewer files. Why create a
package when you can just have a module, bidict.py?

I find it easier to find the right section of my code when I have just a
few files open rather than a dozen or so in different windows and tabs.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue26391] typing: Specialized sub-classes of Generic never call __init__

2016-04-04 Thread Guido van Rossum

Guido van Rossum added the comment:

This is fixed upstream 
(https://github.com/python/typing/commit/8c6aaf30751fec28f1a7e467139ae23c9cc30c81).
 I'm keeping this open until I've merged typing.py into CPython 3.5 and 3.6.

--

___
Python tracker 

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



[issue25987] collections.abc.Reversible

2016-04-04 Thread Guido van Rossum

Guido van Rossum added the comment:

Done. Thanks!

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

___
Python tracker 

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



[issue25987] collections.abc.Reversible

2016-04-04 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 07f73360ea8e by Guido van Rossum in branch 'default':
Add collections.Reversible. Patch by Ivan Levkivskyi. Fixes issue #25987.
https://hg.python.org/cpython/rev/07f73360ea8e

--
nosy: +python-dev

___
Python tracker 

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



[issue25987] collections.abc.Reversible

2016-04-04 Thread Guido van Rossum

Guido van Rossum added the comment:

Looks good. I'll merge this in a sec.

--

___
Python tracker 

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



[issue26623] JSON encode: more informative error

2016-04-04 Thread Mahmoud Lababidi

Mahmoud Lababidi added the comment:

Serhiy,

I've attached a patch without the Object representation. Choose whichever you 
feel is better.

--
Added file: http://bugs.python.org/file42366/json_encode.patch

___
Python tracker 

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



Python programs and relative imports

2016-04-04 Thread Rob Gaddi
Does anyone know the history of why relative imports are only available
for packages and not for "programs"?  It certainly complicates life.

-- 
Rob Gaddi, Highland Technology -- www.highlandtechnology.com
Email address domain is currently out of order.  See above to fix.
-- 
https://mail.python.org/mailman/listinfo/python-list


Twisted 16.1 Release Announcement

2016-04-04 Thread Amber "Hawkie" Brown
On behalf of Twisted Matrix Laboratories, I am honoured to announce the release 
of Twisted 16.1!

This release is hot off the heels of 16.0 released last month, including some 
nice little tidbits. The highlights include:

- twisted.application.internet.ClientService, a service that maintains a 
persistent outgoing endpoint-based connection -- a replacement for 
ReconnectingClientFactory that uses modern APIs;
- A large (77% on one benchmark) performance improvement when using 
twisted.web's client on PyPy;
- A few conch modules have been ported to Python 3, in preparation for further 
porting of the SSH functionality;
- Full support for OpenSSL 1.0.2f and above;
- t.web.http.Request.addCookie now accepts Unicode and bytes keys/values;
- `twistd manhole` no longer uses a hard-coded SSH host key, and will generate 
one for you on the fly (this adds a 'appdirs' PyPI dependency, installing with 
[conch] will add it automatically);
- Over eighteen tickets overall closed since 16.0.

For more information, check the NEWS file (link provided below).

You can find the downloads at  (or 
alternatively ). The NEWS file is 
also available at .

Many thanks to everyone who had a part in this release - the supporters of the 
Twisted Software Foundation, the developers who contributed code as well as 
documentation, and all the people building great things with Twisted!

Twisted Regards,
Amber Brown (HawkOwl)


signature.asc
Description: Message signed with OpenPGP using GPGMail
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Best Practices for Internal Package Structure

2016-04-04 Thread Sven R. Kunze

Hi Josh,

good question.

On 04.04.2016 18:47, Josh B. wrote:

My package, available at https://github.com/jab/bidict, is currently laid out 
like this:

bidict/
├── __init__.py
├── _bidict.py
├── _common.py
├── _frozen.py
├── _loose.py
├── _named.py
├── _ordered.py
├── compat.py
├── util.py


I'd like to get some more feedback on a question about this layout that I originally 
asked here: :

What do you think of the code layout, specifically the use of the _foo modules? 
It seems well-factored to me, but I haven't seen things laid out this way very 
often in other projects, and I'd like to do this as nicely as possible.

It does kind of bug me that you see the _foo modules in the output when you do 
things like this:
[code]


we had a similar discussion internally. We have various packages 
requiring each other but have some internals that should not be used 
outside of them.


The _ signifies that actually clearly but it looks weird within the 
package itself.


We haven't found a solution so far. Maybe others do.


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


[issue25544] cleanup temporary files in distutils.has_function

2016-04-04 Thread SilentGhost

SilentGhost added the comment:

Hi Min RK, could you please update your patch so that it would cleanly apply to 
the tip of default branch. Also since you're re-writing a big chunk of that 
function, could I ask you to use with context manager for the temporary source 
file.

--
nosy: +SilentGhost
stage:  -> needs patch
versions:  -Python 3.4

___
Python tracker 

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



[issue26689] Add `has_flag` method to `distutils.CCompiler`

2016-04-04 Thread SilentGhost

SilentGhost added the comment:

I guess it would make sense to depend on issue25544 and implement the has_flag 
with minrk's patch in mind. I guess his patch didn't get a second look because 
it didn't apply cleanly.

In any case, for implementing has_flag using current best practice is what I'd 
recommend.

--
dependencies: +cleanup temporary files in distutils.has_function

___
Python tracker 

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



Best Practices for Internal Package Structure

2016-04-04 Thread Josh B.
My package, available at https://github.com/jab/bidict, is currently laid out 
like this:

bidict/
├── __init__.py
├── _bidict.py
├── _common.py
├── _frozen.py
├── _loose.py
├── _named.py
├── _ordered.py
├── compat.py
├── util.py


I'd like to get some more feedback on a question about this layout that I 
originally asked here: 
:

What do you think of the code layout, specifically the use of the _foo modules? 
It seems well-factored to me, but I haven't seen things laid out this way very 
often in other projects, and I'd like to do this as nicely as possible.

It does kind of bug me that you see the _foo modules in the output when you do 
things like this:

>>> import bidict
>>> bidict.bidict

>>> bidict.KeyExistsError



In https://github.com/jab/bidict/pull/33#issuecomment-205381351 a reviewer 
agrees:

"""
Me too, and it confuses people as to where you should be importing things from 
if you want to catch it, inviting code like

```
import bidict._common

try:
...
except bidict._common.KeyExistsError:
...
```
ie. becoming dependent on the package internal structure.

I would be tempted to monkey-patch .__module__ = __name__ on each imported 
class to get around this. Maybe there are downsides to doing magic of that 
kind, but dependencies on the internals of packages are such a problem for me 
in our very large codebase, that I'd probably do it anyway in order to really 
explicit about what the public API is.
"""

Curious what folks on this list recommend, or if there are best practices about 
this published somewhere.

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


[issue24505] shutil.which wrong result on Windows

2016-04-04 Thread Bob Alexander

Bob Alexander added the comment:

Since there seems to be ongoing work on the "which"
function, here are a few more thoughts on this function's
future:

  - The existing version does not prepend the current
directory to the path if it is already in the path.
If the current directory is in the path but is not
the first element, it will not be the first directory
searched. It seems that the desired behavior is to
search the current directory first, so the current
directory should *always* be prepended. The existing
"which" function already has an optimization to only
search each directory once, so it's not a problem if
the current directory is unconditionally prepended
and may end up in there twice. This change would
actually be a "correction", since the doc says the
current directory is prepended

  - The function should always return an absolute path,
which is the behavior of the Unix(1) "which" command
and, I think, is the typical expected behavior of a
"which"-type request. The existing implementation
returns a relative path in certain cases, such as if
the file is found via a relative directory reference
in the path. This change is not inconsistent with
the doc, since the doc does not address it.

  - It would be nice if the extension added when the
given command has no extension were lower case,
instead of the upper case extension retrieved from
the PATHEXT environment variable. Several other
"which" implementations work that way (e.g.
see Go's os/exec.LookPath function), producing
a more aesthetically pleasing name, as well as
being more consistent with naming practices of the
last 20+ years. The shocking-looking upper case
sxtensions remind me of VERY OLD DOS programs  :-)
This presents no conflict with the doc, and does
not affect "correctness" since Windows file names
are case-independent.

A previous commenter objected to adding lower case
extensions, but consider:
  - The current version never returns the extension
case of the actual file. It returns the extension
of the command string passed to the function,
if any, otherwise it adds the extension from the
PATHEXT environment variable, either of which
might not match the actual file.
  - Returning the actual extension of the found file
might be nice, but would require additional I/O;
added expense for little return. This is not
done in the current version.
  - The PATHEXT variable that ships with Windows
contains the allowable extensions in upper case,
an old DOS artifact. Few executable files these
days have uppercase extensions. Using a lower
case extension when the function has to invent
one is a "modernization".

  - It would be nice if the returned file path were
normalized. Currently, sometimes an unnormalized
path is returned with a leading ".\".

I did write an update to "which" with the above changes,
and also updated the unit tests with:
  - 2 new tests to catch the bug that is the subject of
this issue.
  - some tests were updated for the small changes such
as normalization and lower case added extensions.
A zip file is attached with my updates. I'm not an
official "contributor", but feel free incorporate the
contents in any way you deem appropriate. The files are:

shutil.py
updated shutil module
shutil.py_3_5_1
existing 3.5.1 shutil module -- basis for updates
test_shutil_for_current_w_added_tests.py
unit tests for existing 3.5.1 version of shutil with
new tests to catch this bug
test_shutil_for_new_version.py
unit tests for attached updated version of shutil
test_shutil_3_5_1.py
existing 3.5.1 unit tests -- basis for updates

Bob

--
Added file: http://bugs.python.org/file42365/new_which_bug_files.zip

___
Python tracker 

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



[issue26689] Add `has_flag` method to `distutils.CCompiler`

2016-04-04 Thread Sylvain Corlay

Sylvain Corlay added the comment:

@minrk submitted 
http://bugs.python.org/file40933/0001-cleanup-temporary-files-in-ccompiler.has_function.patch
doing what you describe for `has_function`. 

I don't know much about the process to contribute to cpython. I would be glad 
to open a "PR" incorporating Min's commits too.

--

___
Python tracker 

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



Re: troubleshooting

2016-04-04 Thread Steven D'Aprano
On Tue, 5 Apr 2016 02:03 am, Sk. Amirul Islam wrote:

> i recently installed the application but when i ran it it gave a 'runtime
> error". i even reinstalled it. but it gives the same error everytime i
> try. im eclosing a screenshot of the error . thank you

Hi. Which application are you talking about? If you mean Python, please tell
us exactly which version, where you downloaded it from, and most
importantly, what operating system and version you are using:

Linux, Mac OS X, Windows, FreeBSB, OpenBSB, Android, something else?

Which version of the OS?

A screenshot is of little or no use to us, I'm afraid. Firstly, that means
that people who are blind or visually impaired and are reading this using
screen-reader software cannot contribute. But more importantly, the
newsgroup is a "Text" newsgroup, not a "Binary" newsgroup, so attachments
are deleted.

Please copy and paste the text of the error, if you can. Otherwise, if it is
short, please retype it into your message. If it is too long to retype, you
can upload your screen shot to Imgur and then link to that.



-- 
Steven

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


Re: module alias in import statement

2016-04-04 Thread Steven D'Aprano
On Tue, 5 Apr 2016 01:31 am, ast wrote:

> hello
> 
 import tkinter as tk
 import tk.ttk as ttk
> 
> Traceback (most recent call last):
>   File "", line 1, in 
> import tk.ttk as ttk
> ImportError: No module named 'tk'
> 
> 
> of course
> 
 import tkinter.ttk as ttk
> 
> works
> 
> Strange, isn't it ?

No. You have to understand what the import statement does.

"import tkinter" does at least three steps:

- locate a Python file called (for example) "tkinter.py", 
  or a package "tkinter/__init__.py"
- execute that module or package file to create a module object
- create a local variable "tkinter" bound to the module object.

In pseudo-code:

# import tkinter
path = find module("tkinter")
tkinter = execute(path)


"import tkinter as tk" changes the last step:

# import tkinter as tk
path = find module("tkinter")
tk = execute(path)


Running "import tkinter as tk" doesn't change the name of the module or
package on disk. It doesn't change (say) the directory "tkinter/" to "tk/".


What happens if there is a dot in the module name?

"import tkinter.ttk as ttk" is similar to above:

- first import the package "tkinter"
- then import the submodule "ttk" inside that package.

In other words:

- locate a directory called "tkinter", containing a file called
  "__init__.py"; this is the package;
- execute that file "tkinter/__init__.py" to create a module object
- create a local variable "tkinter" bound to that module object

- then locate the module or subpackage "ttk" inside that same 
  directory;
- execute that file "tkinter/ttk.py" (for example" to create a 
  module object;
- create a local variable "ttk" bound to that module object.



So you can see why this doesn't work:


import tkinter as tk
import tk.ttk as ttk


is looking for a directory on disk called "tk", which doesn't exist. The
name "tk" is only local to your code, it doesn't rename the directory on
disk.



The real import statement is much more complicated than this, but as a
simplified description, I hope this helps.


-- 
Steven

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


Re: troubleshooting

2016-04-04 Thread Igor Korot
Hi,

On Mon, Apr 4, 2016 at 12:03 PM, Sk. Amirul Islam  wrote:
> i recently installed the application but when i ran it it gave a 'runtime
> error". i even reinstalled it. but it gives the same error everytime i try.
> im eclosing a screenshot of the error . thank you

Attachments are not going thru on this list.
You will need to cut and paste the error in the email. ;-)

Also, basic questions:
1. What OS are you running?
2 What version of OS are you running?
3. What version of python do you have?
4. Is all dependencies for this program are satisfied?

Thank you.

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


troubleshooting

2016-04-04 Thread Sk. Amirul Islam
i recently installed the application but when i ran it it gave a 'runtime
error". i even reinstalled it. but it gives the same error everytime i try.
im eclosing a screenshot of the error . thank you
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: module alias in import statement

2016-04-04 Thread Ned Batchelder
On Monday, April 4, 2016 at 11:31:41 AM UTC-4, ast wrote:
> hello
> 
> >>> import tkinter as tk
> >>> import tk.ttk as ttk
> 
> Traceback (most recent call last):
>   File "", line 1, in 
> import tk.ttk as ttk
> ImportError: No module named 'tk'
> 
> 
> of course
> 
> >>> import tkinter.ttk as ttk
> 
> works
> 
> Strange, isn't it ?

Yes, I can see that seeming strange.  There are two things to know about
how imports work that will help explain it:

First, import statements are really just special syntax for an assignment.
When you say "import tkinter as tk", it means (in pseudocode):

tk = __import__("tkinter")

The module named "tkinter" is sought, and when found, executed, and the
resulting module object is assigned to the name "tk".

Second, notice that "import tkinter" doesn't try to evaluate "tkinter" as
an expression. If it did, that import would raise an error, because "tkinter"
isn't defined.

So in your code, you defined the name "tk" in the first line, but that
doesn't mean the name "tk" is available for you to use in the second line.

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


Re: Set type for datetime intervals

2016-04-04 Thread Martin A. Brown

Greetings László,

>I need to compare sets of datetime intervals, and make set 
>operations on them: intersect, union, difference etc. One element 
>of a set would be an interval like this:
>
>element ::= (start_point_in_time, end_point_in_time)
>intervalset ::= { element1, element2,  }
>
>Operations on elements:
>
>element1.intersect(element2)
>element1.union(element2)
>element1.minus(element2)
>
>Operations on sets:
>
>intervalset1.intersect(intervalset2)
>intervalset1.union(intervalset2)
>intervalset1.minus(intervalset2)
>
>Does anyone know a library that already implements these functions?

Sorry to be late to the party--I applaud that you have already 
crafted something to attack your problem.  When you first posted, 
there was a library that was tickling my memory, but I could not 
remember its (simple) name.  It occurred to me this morning, after 
you posted your new library:

  https://pypi.python.org/pypi/intervaltree

This handles overlapping ranges nicely and provides some tools for 
managing them.  Before posting this, I checked that it works with 
datetime types, and, unsurprisingly, it does.

Happy trails!

-Martin

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


Re: ANN: intervalset Was: Set type for datetime intervals

2016-04-04 Thread Random832
On Mon, Apr 4, 2016, at 11:32, Oscar Benjamin wrote:
> On 4 April 2016 at 16:09, Random832  wrote:
> > Like I said before, I don't think the set-like operations on Intervals
> > are useful - what can you accomplish with them rather than by making a
> > set consisting of only one interval and doing operations on that?
> 
> I guess it depends what your application is but sympy has interval
> sets and can do computation on them to represent the solutions of
> equations/inequalities (many other types of set are also included).

Yes, my question is why it's useful to have a single Interval as a
*distinct* type, separate from the interval set type, which supports a
sharply limited number of set-like operations (such as the union of two
overlapping intervals but NOT two non-overlapping ones). This doesn't
appear to be the case in sympy based on your examples.

Having an interval as a distinct type may be useful (to iterate over the
intervals of a set, for example), but his design blurs the line between
intervals and sets (by supporting some set operations) without
eliminating it as sympy seems to do.

> In [6]: Interval(1, 2) | Interval(3, 4)
> Out[6]: [1, 2] ∪ [3, 4]
> 
> There is some discussion about why it's good to do this stuff with
> sets (for sympy's purposes here):
> http://docs.sympy.org/latest/modules/solvers/solveset.html#why-do-we-use-sets-as-an-output-type
-- 
https://mail.python.org/mailman/listinfo/python-list


module alias in import statement

2016-04-04 Thread ast

hello


import tkinter as tk
import tk.ttk as ttk


Traceback (most recent call last):
 File "", line 1, in 
   import tk.ttk as ttk
ImportError: No module named 'tk'


of course


import tkinter.ttk as ttk


works

Strange, isn't it ?
--
https://mail.python.org/mailman/listinfo/python-list


Re: ANN: intervalset Was: Set type for datetime intervals

2016-04-04 Thread Oscar Benjamin
On 4 April 2016 at 16:09, Random832  wrote:
> On Mon, Apr 4, 2016, at 03:12, Nagy László Zsolt wrote:
>>
>>   Hi All,
>>
>> If anyone is interested, a module was born:
>>
>> https://bitbucket.org/nagylzs/intervalset
>> https://pypi.python.org/pypi/intervalset/0.1.1
>
> I don't know if I like it being immutable. Maybe have separate mutable
> and immutable versions.
>
> Like I said before, I don't think the set-like operations on Intervals
> are useful - what can you accomplish with them rather than by making a
> set consisting of only one interval and doing operations on that?

I guess it depends what your application is but sympy has interval
sets and can do computation on them to represent the solutions of
equations/inequalities (many other types of set are also included).
For example:

In [1]: from sympy import Interval

In [2]: Interval
Out[2]: sympy.core.sets.Interval

In [3]: Interval(1, 2)
Out[3]: [1, 2]

In [4]: help(Interval)


In [5]: Interval(1, 2) & Interval(3, 4)
Out[5]: ∅

In [6]: Interval(1, 2) | Interval(3, 4)
Out[6]: [1, 2] ∪ [3, 4]

There is some discussion about why it's good to do this stuff with
sets (for sympy's purposes here):
http://docs.sympy.org/latest/modules/solvers/solveset.html#why-do-we-use-sets-as-an-output-type

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


Re: Set type for datetime intervals

2016-04-04 Thread Random832
On Mon, Apr 4, 2016, at 06:15, Nagy László Zsolt wrote:
> If you define the intersection operation on interval sets only, then you
> need to write something like this:
> 
> if IntervalSet(i1)*IntervalSet(i2):
> pass
> 
> which is both uglier and an overkill.

I guess what I don't understand in this situation is why aren't i1 and
i2 already IntervalSets? I'm not sure I see why user code would be
working directly with Intervals at all. Any use for it could be replaced
with an IntervalSet constructor to directly make a set of one interval.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue25942] subprocess.call SIGKILLs too liberally

2016-04-04 Thread Robert Cope

Changes by Robert Cope :


--
nosy: +rpcope1

___
Python tracker 

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



Re: ANN: intervalset Was: Set type for datetime intervals

2016-04-04 Thread Random832
On Mon, Apr 4, 2016, at 03:12, Nagy László Zsolt wrote:
> 
>   Hi All,
> 
> If anyone is interested, a module was born:
> 
> https://bitbucket.org/nagylzs/intervalset
> https://pypi.python.org/pypi/intervalset/0.1.1

I don't know if I like it being immutable. Maybe have separate mutable
and immutable versions.

Like I said before, I don't think the set-like operations on Intervals
are useful - what can you accomplish with them rather than by making a
set consisting of only one interval and doing operations on that?

> I have some unit tests, but testers and comments are welcome.
> 
> Also see below.
> 
> Yes, you are right. It is a set of non-intersecting intervals.
> 
> > It could
> > also be useful to have one for numbers (the datetime version could even
> > maybe be implemented in terms of it)
> Well, please check sources on bitbucket. You are more than welcome to
> join the project.
> >
> >> element ::= (start_point_in_time, end_point_in_time)
> >> intervalset ::= { element1, element2,  }
> > Are these open intervals or closed intervals?
> Closed. In my particular implementation, there is a singleton for all
> empty intervals. It is not possible to create an arbitrary interval with
> the same starting and ending time (the singleton being the only
> exception).

An "arbitrary interval with the same starting and ending time" would be
more like an isolated datetime (i.e. 00:00 is in the set but 23:59 or
00:01 is not)

> I think that implementing open intervals would be much more
> difficult, and we would have to know and use the smallest possible
> increment (resolution) of the date/time type. Which may be platform
> dependent.

My suggestion was to use boolean flags, and to use that to control
whether to use < or <= to test for membership.

An open interval is more like an hour where 00:00 is included and
00:59:59.99 is included but 01:00 is not. With discrete resolution
it's as simple as just moving the endpoint off by one unit, but I think
it'd be cleaner to use flags (you'd need it for numeric intervals, since
numeric types can have any resolution).

>def __contains__(self, other):
>"""Containment relation.
>
>Tell if `other` is contained *completely* in this set. The argument 
> can either be an Interval or an
>IntervalSet.
>"""

I don't think this is appropriate for this operation; this should be
__gt__. __contains__ should test a datetime (or whatever type item), not
another Interval/IntervalSet.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [beginner] What's wrong?

2016-04-04 Thread BartC

On 04/04/2016 15:04, Mark Lawrence wrote:

On 02/04/2016 23:49, Michael Torrie wrote:

Mark, your messages are showing up to the list as being from "python,"
at least on my email.  Any reason for this?



Assuming that you're referring to me, frankly I haven't a clue.  I read
this list with Thunderbird on Windows, I hit "reply" to something, I
type, I hit "send", job done.  Thereafter, as far as I'm concerned, a
miracle occurs and hundreds if not thousands of subscribers get to see
my reply.


On the same setup, I click 'Followup' to reply to a post, which sends to 
the group.


Other options on the dropdown box below the Followup button are Reply 
and Reply All.


Clicking Reply (on your post) starts an email to you, while Reply All 
starts an email to you and to the group.


--
Bartc



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


Re: Collection: weak error prompt drives beginner crazy

2016-04-04 Thread Ned Batchelder
On Monday, April 4, 2016 at 7:31:38 AM UTC-4, animalize wrote:
> An example, the file-name is conflict with library-name in stdlib or 
> installed library.
> 
> There is a file uuid.py that only has two lines:
> 
>  import uuid
>  print(uuid.uuid4())
> 
> Run uuid.py, output on Python 3.5.1:
> 
>  Traceback (most recent call last):
>File "D:\uuid.py", line 1, in 
>  import uuid
>File "D:\uuid.py", line 3, in 
>  print(uuid.uuid4())
>  AttributeError: module 'uuid' has no attribute 'uuid4'
> 
> I was spending about an hour to find out what happend when I was a 
> beginner, and I found I'm not the only one who confused by this problem.
> 
> If the prompt can be beginner-friendly a little bit, I think it's a very 
> good thing.
> E.g. says you are importing the file itself, rather than importing other 
> file or library.

I agree that it would be good if Python would be clear about this error.
I suggested as much on Python-Ideas a few months ago:
https://groups.google.com/d/topic/python-ideas/dNbXlL2XoJ8/discussion
or https://mail.python.org/pipermail/python-ideas/2016-January/038165.html

The thread did not end with a strong opinion one way or the other, though
it did get distracted by other kinds of import mistakes.

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


Re: how to optimize the below code with a helper function

2016-04-04 Thread Martin A. Brown

Hello again,

>(1)  Any tips how I can optimize this i.e test case, should have a 
>helper function that all test cases call.
>
>(2) Also note that failure.run_tool function can have variable 
>number of argments how to handle this in the helper function?

Here's a little example of how you could coerce your problem into a 
ConfigParser-style configuration file.

With this example, I'd think you could also see how to create a 
config section called [lin_02] that contains the parameters you want 
for creating that object.  Then, it's a new problem to figure out 
how to refer to that object for one of your tests.

Anyway, this is just another way of answering the question of "how 
do I simplify this repetitive code".

Good luck and enjoy,

-Martin

#! /usr/bin/python

from __future__ import absolute_import, division, print_function

import os
import sys
import collections
from ConfigParser import SafeConfigParser as ConfigParser
import logging


logging.basicConfig(stream=sys.stderr, level=logging.INFO)
logger = logging.getLogger(__name__)

LOG_DIR = '/var/log/frobnitz'

def readCfgTestCases(cfgfile):
data = collections.defaultdict(dict)
parser = ConfigParser()
parser.read(cfgfile)
for section in parser.sections():
for name, value in parser.items(section):
data[section][name] = value
return data

def main(cfgfile):
testdata = readCfgTestCases(cfgfile)
for k, v in testdata.items():
print(k, v)


if __name__ == '__main__':
main(sys.argv[1])

# -- end of file


# -- config file

[test01]
offset = 18
size = 4
object = inode
optype = set

[test02]
# -- no way to capture lin=lin_02; must reproduce contents of lin_02
object = lin
offset = 100
size = 5
optype = set


[test100]
# -- no way to capture baddr=lin_02; must reproduce contents of lin_02
object = baddr
offset = 100
size = 5
optype = set


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


Re: [beginner] What's wrong?

2016-04-04 Thread Mark Lawrence via Python-list

On 02/04/2016 23:49, Michael Torrie wrote:

Mark, your messages are showing up to the list as being from "python,"
at least on my email.  Any reason for this?



Assuming that you're referring to me, frankly I haven't a clue.  I read 
this list with Thunderbird on Windows, I hit "reply" to something, I 
type, I hit "send", job done.  Thereafter, as far as I'm concerned, a 
miracle occurs and hundreds if not thousands of subscribers get to see 
my reply.


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

Mark Lawrence

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


Re: how to optimize the below code with a helper function

2016-04-04 Thread Martin A. Brown

Greetings (again) Ganesh,

I notice that you ask about how to optimize the code, but I think 
what you mean is you want simpler code that is less repetitive and 
less copy/paste error-prone.  Is that correct?

Below, I make a few suggestions about how to simplify, although, 
there probably is further simplification that could be done.

>I am on python 2.7.10 and Linux.

Noted.  I tested my answer to your question on a Python 2.7, as 
well.

>I have a python function where the similar kind of pattern 
>repeating 100 of times

When you have a repetitive sequence of operations (or test cases, it 
looks like), you can often figure out a way to store the parameters 
as data.  When the parameters become data, then, the code becomes 
simpler.

>Sample code snippet:
>
>test01_log = os.path.join(LOG_DIR, "test01.log")
>cls.get_baddr['test01'] = failure.run_tool(
>test01_log, object="inode", offset="18", size="4",
>optype="set")
>
>test02_log = os.path.join(LOG_DIR, "test02.log")
>cls.get_baddr['test02'] = failure.run_tool(
>test02_log, lin=lin_02, object="lin", offset="100", size="5",
>optype="set")
> ..
>
>test100_log = os.path.join(LOG_DIR, "test100.log")
>cls.get_baddr['test100'] = failure.run_tool(
>test02_log, baddr=lin_02, object="baddr", offset="100", size="5",
>optype="set")

I observe that here in the failure.run_tool() call, the logfile is 
test02_log.  I would have expected it to be test100_log.  I'm 
guessing that this is exactly the sort of copy/paste error that you 
wish to avoid.

>(1)  Any tips how I can optimize this i.e test case, should have a helper
>function that all test cases call.

One function that jumps out very easily (to my eye) is a function to 
create the logfile name from the test case name.  You will see how I 
do that in the sample, so that you can call the run_tool function as 
you are currently calling it.

(You might consider putting the logfile name generation into the 
run_tool function, though, in which case, run_tool gets even simpler 
and you can get rid of my function, addLogFilename.  Hopefully, that 
makes sense to you)

>(2) Also note that failure.run_tool function can have variable 
>number of argments how to handle this in the helper function?

A variable number of arguments:  this seems like the perfect case 
for using keyword arguments!

  https://docs.python.org/2/tutorial/controlflow.html#keyword-arguments

I have one additional observation about your sample code, Ganesh.  
When I read this:

  cls.get_baddr['test01'] = failure.run_tool(
   test01_log, object="inode", offset="18", size="4",
   optype="set")

I am guessing that you are calling an external program in your test.  
I also notice that you have string contents in your variables, for 
example, offset="18".  (That's part of why I guess you are calling 
an external program as part of your test.)

If you are calling an external command in 'run_tool', why not put 
the exact command-line you want to execute into the test data.  
This would simplify your code and makes the test more transparent, 
as well.

  d = dict()
  d['test01'] = dict(cmd=['some_command', '--offset', '18', '--size', '4'],
 optype="set", object='inode')

Then, in run_tool, something like this:

  subprocess.Popen(cmd, shell=False, stderr=logfile)

But, these suggestions are all, basically, different riffs on the 
same basic idea:

  Where you have many testing scenarios, try to figure out a way to 
  store all of the test cases in data and then have the test runner 
  operate on the data.

Good luck,

-Martin


#! /usr/bin/python

from __future__ import absolute_import, division, print_function

import os
import sys
import logging


logging.basicConfig(stream=sys.stderr, level=logging.INFO)
logger = logging.getLogger(__name__)

LOG_DIR = '/var/log/frobnitz'


def createTestCases(LOG_DIR):
'''create a test case data dictionary with parameters'''
d = dict()
d['test01'] = dict(object="inode", offset="18", size="4", optype="set")
lin_02 = "something"
d['test02'] = dict(object="lin", lin=lin_02, offset="18", size="5",
   optype="set")
d['test100'] = dict(object="baddr", baddr=lin_02, offset="100", size="5",
optype="set")
return addLogFilename(d, LOG_DIR)


def run_tool(logfile, **kw):
logger.info('%s would execute with %r', logfile, kw)


def addLogFilename(d, logdir):
'''put the logfile name into the test case data dictionary'''
for casename, args in d.items():
args['logfile'] = os.path.join(logdir, casename + '.log')
return d


def main():
testcases = createTestCases(LOG_DIR)
get_baddr = dict()
for casename, kw in testcases.items():
# -- yank the logfile name out of the dictionary, before calling func
logfile = 

  1   2   >