[issue26067] test_shutil fails when gid name is missing

2016-01-11 Thread Ezio Melotti

Ezio Melotti added the comment:

We looked at this at the PyLadies Sprint in Helsinki.
When the group has an id but not a name (see "gid=203135016" in the "id" output 
-- the name is missing), its entry is missing from the list returned by 
grp.getgrall().

If this behaviour is expected and desired, then the test should be fixed to 
handle cases where the name is missing and the KeyError is raised.
Otherwise, the entry could still be included with "None" as name.

--
nosy: +serhiy.storchaka
stage:  -> needs patch
type:  -> behavior

___
Python tracker 

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



[issue26083] ValueError: insecure string pickle in subprocess.Popen on Python 2

2016-01-11 Thread Gregory P. Smith

Gregory P. Smith added the comment:

note: this was not a security issue nor was it a crash.  an exception was being 
raised anyways from the forked child prior to the exec(), this bug just caused 
that to be swallowed and this ValueError raised instead.

--
resolution:  -> fixed
stage:  -> commit review
status: open -> closed
type: crash -> behavior

___
Python tracker 

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



Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2016-01-11 Thread homiemusa
On Tuesday, December 29, 2015 at 1:30:18 AM UTC+3, Cameron Simpson wrote:
> On 28Dec2015 01:34, Prince Udoka  wrote:
> >bu i have come up with a solution, that will work but encounter a problem in 
> >the set, giving set not manipulated correctly:
> >
> >def manipulate_data(kind, data):
> >if kind == 'list':
> >return list(data)[::-1]
> >elif kind == 'set':
> >return set(data)
> >elif kind == 'dictionary':
> >return dict.keys(data)
> >manipulate_data("list", range(1,6))
> >manipulate_data("set", {"a", "b", "c", "d", "e", "ANDELA", "TIA", "AFRICA"})
> >manipulate_data("dictionary", {"apples": 23, "oranges": 15, "mangoes": 3, 
> >"grapes": 45})
> >
> >the thing now is the function to use in adding "ANDELA", "TIA", "AFRICA"
> >pls 4give my use of language
> 
> You are very close. Let me remind you of the original task text:
> 
>   add items `"ANDELA"`, `"TIA"` and `"AFRICA"` to the set and return the 
>   resulting set
> 
> Your previous attempt (with hardwired values inside the function) actually 
> had 
> code to do it.
> 
> While you have pulled out all the hardwired values from the function (good) 
> and 
> put them in the external calls, note that the task explicitly says "add items 
> `"ANDELA"`, `"TIA"` and `"AFRICA"` to the set". So _those_ values _are_ 
> supposed to be hardwired inside the function - they are a fixed part of the 
> task. So move them back in, as in your previous attempt.
> 
> There is some ambiguity in that part of the question: should you return a 
> _new_ 
> set consistint of the original set plus the three new values, or simply add 
> the 
> three values to the original set? Your prior code modified the original set, 
> which may fit the task specification.
> 
> However, it is a common design objective that functions do not, _normally_, 
> modify their arguments. So, consider this code:
> 
>   set1 = {"a", "b", "c", "d", "e"}
>   set2 = manipulate_data("set", set1)
> 
> After running this, set2 should look like this:
> 
>   {"a", "b", "c", "d", "e", "ANDELA", "TIA", "AFRICA"}
> 
> (in some order -- sets are not ordered). However, what about set1? In your 
> current code, set1 is modified, so it will be the same. But you can imagine 
> that it would be more useful for the caller if set1 were unchanged.
> 
> In python, the convention is usually that if a function returns the new value 
> then it should not modify the original. So you should probably construct a 
> copy 
> of the original set and modify that:
> 
>   data = set(data)
>   ... add the new values ...
>   return data
> 
> Cheers,
> Cameron Simpson 


please help me how can i add a function  to this code am a star
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue25517] regex howto example in "Lookahead Assertions"

2016-01-11 Thread Ezio Melotti

Ezio Melotti added the comment:

Fixed, thanks for the patch!

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

___
Python tracker 

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



[issue25517] regex howto example in "Lookahead Assertions"

2016-01-11 Thread Roundup Robot

Roundup Robot added the comment:

New changeset c6b5c03183e3 by Ezio Melotti in branch '2.7':
#25517: fix regex in the regex howto.  Patch by Elena Oat.
https://hg.python.org/cpython/rev/c6b5c03183e3

New changeset 6bd4a4907f66 by Ezio Melotti in branch '3.5':
#25517: fix regex in the regex howto.  Patch by Elena Oat.
https://hg.python.org/cpython/rev/6bd4a4907f66

New changeset 48e2f5915d49 by Ezio Melotti in branch 'default':
#25517: merge with 3.5.
https://hg.python.org/cpython/rev/48e2f5915d49

--
nosy: +python-dev

___
Python tracker 

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



[issue25887] awaiting on coroutine more than once should be an error

2016-01-11 Thread Brett Cannon

Brett Cannon added the comment:

I don't like "coroutine was already awaited". I feel like either "on" should be 
appended to that or another sentence like "coroutine had 'await' called on it" 
or something.

--

___
Python tracker 

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



Re: When I need classes?

2016-01-11 Thread Bernardo Sulzbach
On Mon, Jan 11, 2016 at 9:45 PM, Travis Griggs  wrote:
>
>> On Jan 10, 2016, at 9:48 AM, Bernardo Sulzbach  
>> wrote:
>>
>> Essentially, classes (as modules) are used mainly for organizational 
>> purposes.
>>
>> Although you can solve any problem you would solve using classes
>> without classes, solutions to some big problems may be cheaper and
>> more feasible using classes.
>
> I think, this is often why, for a simple script, OO just kind of gets in the 
> way. You have a straightforward procedure that you just want to do. The state 
> (data) is not rich enough to make making it the focal point of your program.

Your answer is quite good. I am not a purist myself (when it comes to
Java and C++, I am never going to instantiate a Math class to get a
logarithm function), but I understand the value of OO from experience.
As I mentioned those "tuples and dictionaries" to pass data around, I
would like to add that when a single script has two kinds of tuples or
dictionaries, you may be better of using two different classes, as
having "dedicated" types simplifies project organization and
enhances readability.

I have never gone "seriously OO" with Python though. I never wrote
from scratch an application with more than 10 classes as far as I can
remember. However, I would suppose that the interpreter can handle
thousands of user-defined classes simultaneously.

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


[issue25887] awaiting on coroutine more than once should be an error

2016-01-11 Thread Yury Selivanov

Yury Selivanov added the comment:

Nick,

> After all, waiting for the result with "await" is only one way to terminate a 
> coroutine - you can also get there with direct calls to next(), send(), 
> throw() and close().

Yes, but I expect that almost nobody will use 'send', 'throw' etc on 
coroutines, it's too low level.  In asyncio there is only one place where this 
magic happens.  Regular user will only understand the 'await' part -- that's 
why I wanted to mention it in the error message.

  async def something():
  await coro
  ^ RuntimeError('Cannot resume terminated coroutine')

The above use case might be a bit hard for users to actually understand, as 
opposed to

  async def something():
  await coro
  ^ RuntimeError('coroutine was already awaited on')

What do you think?

Martin, thanks for the review!

--

___
Python tracker 

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



[issue25486] Resurrect inspect.getargspec() in 3.6

2016-01-11 Thread Martin Panter

Martin Panter added the comment:

Now the documentation says it will be removed in 3.6. I guess the 3.5 
documentation also needs updating.

--
nosy: +martin.panter

___
Python tracker 

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



[issue26068] re.compile() repr end quote truncated

2016-01-11 Thread Ezio Melotti

Ezio Melotti added the comment:

FTR the repr was added in #13592.

--
nosy: +serhiy.storchaka
type:  -> behavior
versions: +Python 3.5, Python 3.6 -Python 3.4

___
Python tracker 

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



[issue25967] Devguide: add 2to3 to the "Changing CPython's Grammar" checklist

2016-01-11 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 367486fbab84 by Ezio Melotti in branch 'default':
#25967: add note about updating lib2to3 when the grammar is updated.  Patch by 
Chris Thomas.
https://hg.python.org/devguide/rev/367486fbab84

--
nosy: +python-dev

___
Python tracker 

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



Confused by python-dbus weird behavior

2016-01-11 Thread Travis Griggs
This may not be a great list for this question (which would be?); it’s a big 
group, and I’m hoping there’s some people here that cross into these same areas.

I’m new to dbus, it seems it’s a sort of CORBA for the Linux world. :) Python 
seems to be a popular way to interact with it. I’m trying to interact with the 
BlueZ services for Bluetooth LE stuff, and the scant hints I can find seem to 
indicate dbus is the preferred way going forward. The BlueZ distribution even 
provides example code. That said, my question should be independent of whether 
this was BLE or a dbus interface for a Calculator program.

There is a class defined as such:

class Characteristic(dbus.service.Object):
def __init__(self, bus, index, uuid, flags, service):
# … set a bunch of attributes
dbus.service.Object.__init__(self, bus, self.path)

@dbus.service.method(GATT_CHRC_IFACE, in_signature='ay')
def WriteValue(self, value):
print('Default WriteValue called, returning error’)
raise NotSupportedException()

Then I have a subclass of my own:

class MyCharacteristic(Characteristic):
def __init__(self, bus, index, uuid, flags, service):
Characteristic.__init__(self, bus, index, uuid, flags, service)
# … set some of my own attributes

def WriteValue(self, value):
print(‘Got write value:’, value)
self.anotherMethod(value)
print(‘back from anotherMethod’)

def anotherMethod(self, value):
print(‘pondering this value:’, value)

My program does not call WriteValue directly. It seems to be called by the 
bluetooth machinery. The mainloop, or something like that. I don’t honestly 
know. I just know I use some other boilerplate code involving registration and 
the mainloop, to get it all running. And so the MyCharacteristic.WriteValue() 
method DOES get fired. I see the output. But when it gets to the anotherMethod 
call, it just seems to... not. More callbacks may fire later. But that’s the 
end of that one. I’ve tried this under python2 AND python3.

So my basic python-dbus question is: Is this some nuance where a callback 
method, inheriting from what looks like a proxy of some sort 
(dbus.service.Object) should/can not send messages to itself?

Help me python-obis, help me. You’re my only hope.


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


[issue23942] Explain naming of the patch files in the bug tracker

2016-01-11 Thread Martin Panter

Martin Panter added the comment:

I guess if people wonder about this, you could at least say the naming doesn’t 
matter very much for the review system.

If I am generating my own patches, I try to name them with one or two concise 
words describing the particular solution, and then insert “.v2”, “.v3” etc for 
the revised patches. If I just gave them an issue number, it would get lost my 
Mercurial patch queue among a sea of other numbers. If I did not add the “.v2” 
revision number, people would have to refer to the patches by upload date 
rather than name or version.

--
nosy: +martin.panter

___
Python tracker 

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



[issue26082] functools.lru_cache user specified cachedict support

2016-01-11 Thread Josh Rosenberg

Josh Rosenberg added the comment:

Given that lru_cache uses the cache dict in very specific ways, supporting 
arbitrary mapping types would be extremely hard. Among other things:

1. The C code uses the concrete dict APIs (including private APIs) that would 
not work on arbitrary mappings that don't directly inherit from dict (and often 
wouldn't work properly even if they do inherit from dict). Changing to use the 
abstract mapping APIs would slow all use cases for an extremely uncommon use 
case.

2. The C code is operating under the assumption that specific operations cannot 
release the GIL (e.g. dict insertion and deletion is done after precomputing 
the hash of the key, so it's impossible for Python byte code to be executed), 
so it can safely ignore thread safety issues. If a non-dict mapping was 
provided, implemented in Python rather than C, these assumptions could easily 
be violated.

3. This is basically a superset of the request from #23030, which rhettinger 
has rejected (you can read the rationale there)

--
nosy: +josh.r, rhettinger

___
Python tracker 

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



[issue26063] Update copyright in the devguide

2016-01-11 Thread Roundup Robot

Roundup Robot added the comment:

New changeset a4c18139d9b0 by Ezio Melotti in branch 'default':
#26063: future-proof copyright updating.
https://hg.python.org/devguide/rev/a4c18139d9b0

--

___
Python tracker 

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



[issue25888] awaiting on coroutine that is being awaited should be an error

2016-01-11 Thread Yury Selivanov

Yury Selivanov added the comment:

Will commit this patch tomorrow to 3.5 and 3.6.

It only affects coroutines (async defs): if an await expression is used on a 
coroutine object while it's being already awaited by another coroutine, a 
`RuntimeError("coroutine is being awaited already")` will be triggered.

--

___
Python tracker 

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



Re: I'm missing something here...

2016-01-11 Thread sohcahtoa82
On Monday, January 11, 2016 at 3:27:21 PM UTC-8, Skip Montanaro wrote:
> Here's a dumb little bit of code, adapted from a slightly larger script:
> 
> #!/usr/bin/env python
> 
> "dummy"
> 
> import glob
> import os
> 
> def compare_prices(*_args):
> "dummy"
> return set()
> 
> def find_problems(cx1, cx2, cx3, prob_dates):
> "dummy"
> for fff in sorted(glob.glob("/path/to/*.nrm")):
> sym = os.path.splitext(os.path.basename(fff))[0]
> prob_dates |= compare_prices("E:%s"%sym, cx1, cx2, cx3)
> 
> When I run pylint against it, it complains:
> 
> junk.py:10: [W0613(unused-argument), find_problems] Unused argument 
> 'prob_dates'
> 
> I must be misunderstanding something about the |= operator as applied
> to sets. If I read the docs correctly, s1 |= s2 is equivalent to
> s1.update(s2). A dumb "test" at the prompt suggests that's true:
> 
> >>> s1 = set("abc")
> >>> s2 = set("cde")
> >>> s1 | s2
> set(['a', 'c', 'b', 'e', 'd'])
> >>> s1 |= s2
> >>> s1
> set(['a', 'c', 'b', 'e', 'd'])
> >>> s1 = set("abc")
> >>> s1.update(s2)
> >>> s1
> set(['a', 'c', 'b', 'e', 'd'])
> 
> If I change the last line of find_problems to call
> prob_dates.update(), the message disappears. Why is pylint (1.4.2 BTW)
> complaining that the prob_dates argument of find_problems is unused
> when I use the |= operator?
> 
> Thx,
> 
> Skip

The pipe character on its own also functions as the binary OR operator, with x 
|= y being a shortcut for x = x | y.

If prob_dates is an integer, then it is immutable and the your prob_dates |= 
compare_prices(...) line won't do anything (The variable is being set, but 
never again read outside the function and it doesn't change the function's 
return value), which is probably what pylint is complaining about.  Pylint 
doesn't know that your function is expecting a mutable iterable for the 
prob_dates argument.

If you change it to prob_dates.update(...), does pylint complain?
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue25887] awaiting on coroutine more than once should be an error

2016-01-11 Thread Nick Coghlan

Nick Coghlan added the comment:

The patch looks good to me, but I'd like to see the error message convey two 
points:
- the coroutine has already terminated (regardless of how that happened)
- the calling code attempted to resume it anyway

That is, something like "Cannot resume terminated coroutine", rather than 
specifically referring to "await".

After all, waiting for the result with "await" is only one way to terminate a 
coroutine - you can also get there with direct calls to next(), send(), throw() 
and close().

--

___
Python tracker 

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



Re: Which Python editor has this feature?

2016-01-11 Thread Bernardo Sulzbach
On Mon, Jan 11, 2016 at 10:14 PM, Chris Angelico  wrote:
>
> Next IDLE feature request: Can you make it so that, across all
> platforms, it magically installs PostgreSQL and psycopg2? That would
> solve so many of my students' problems...
>

Wouldn't this make the installer much bigger?

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


Re: Which Python editor has this feature?

2016-01-11 Thread Chris Angelico
On Tue, Jan 12, 2016 at 8:21 AM, Terry Reedy  wrote:
>
> The context is currently read-only.  Clicking on context lines does nothing.
> As a result of this thread, I am thinking that clicking on a context line
> should scroll up the main text window to display that line at the top (and
> remove that line and any below from the context box).  I *think* that this
> should be fairly easy.

That'd be pretty cool.

Next IDLE feature request: Can you make it so that, across all
platforms, it magically installs PostgreSQL and psycopg2? That would
solve so many of my students' problems...

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


Re: I'm missing something here...

2016-01-11 Thread Erik

On 11/01/16 23:26, Skip Montanaro wrote:

If I change the last line of find_problems to call
prob_dates.update(), the message disappears. Why is pylint (1.4.2 BTW)
complaining that the prob_dates argument of find_problems is unused
when I use the |= operator?


Is it complaining about that, or is it because the 'for' loop body might 
be executed zero times?


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


[issue25888] awaiting on coroutine that is being awaited should be an error

2016-01-11 Thread Martin Panter

Martin Panter added the comment:

Missing word in a comment on the review

--
nosy: +martin.panter

___
Python tracker 

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



[issue25887] awaiting on coroutine more than once should be an error

2016-01-11 Thread Martin Panter

Martin Panter added the comment:

The patch looks like it adds checks for the special generator-like send() etc 
methods, but I was expecting __await__() to also (or instead) do this check. 
That way you wouldn’t have to break the iterator protocol by the iterator not 
raising StopIteration a second time.

Also left some other review comments.

--

___
Python tracker 

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



[issue19251] bitwise ops for bytes of equal length

2016-01-11 Thread Gregory P. Smith

Changes by Gregory P. Smith :


--
nosy: +gregory.p.smith

___
Python tracker 

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



I'm missing something here...

2016-01-11 Thread Skip Montanaro
Here's a dumb little bit of code, adapted from a slightly larger script:

#!/usr/bin/env python

"dummy"

import glob
import os

def compare_prices(*_args):
"dummy"
return set()

def find_problems(cx1, cx2, cx3, prob_dates):
"dummy"
for fff in sorted(glob.glob("/path/to/*.nrm")):
sym = os.path.splitext(os.path.basename(fff))[0]
prob_dates |= compare_prices("E:%s"%sym, cx1, cx2, cx3)

When I run pylint against it, it complains:

junk.py:10: [W0613(unused-argument), find_problems] Unused argument 'prob_dates'

I must be misunderstanding something about the |= operator as applied
to sets. If I read the docs correctly, s1 |= s2 is equivalent to
s1.update(s2). A dumb "test" at the prompt suggests that's true:

>>> s1 = set("abc")
>>> s2 = set("cde")
>>> s1 | s2
set(['a', 'c', 'b', 'e', 'd'])
>>> s1 |= s2
>>> s1
set(['a', 'c', 'b', 'e', 'd'])
>>> s1 = set("abc")
>>> s1.update(s2)
>>> s1
set(['a', 'c', 'b', 'e', 'd'])

If I change the last line of find_problems to call
prob_dates.update(), the message disappears. Why is pylint (1.4.2 BTW)
complaining that the prob_dates argument of find_problems is unused
when I use the |= operator?

Thx,

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


Re: When I need classes?

2016-01-11 Thread Travis Griggs

> On Jan 10, 2016, at 9:48 AM, Bernardo Sulzbach  
> wrote:
> 
> Essentially, classes (as modules) are used mainly for organizational purposes.
> 
> Although you can solve any problem you would solve using classes
> without classes, solutions to some big problems may be cheaper and
> more feasible using classes.

As a long term OO purist practitioner, I would add to this. Obviously, you can 
organize your code any way you want, with or without classes. You could put all 
your functions with an odd number of letters in one class, and all of the even 
numbered ones in another class. 

Having listened to the guy (Alan Kay) who coined the term (Object Oriented 
Programming) quite a bit over the years, I believe that the focus of OO (of 
which classes are a particular implementation approach) is to bind behavior to 
data. In “traditional” programming approaches, one focused on the algorithm 
(behavior) first, and then figured out what data needed to flow where to get 
the job done. Classes provided a mechanism to turn that equation, generally 
speaking, around. One thinks about the data first, and then figures out what 
behavior binds best to that data. And how that data will interact (inter-object 
behavior, often called messages) to get your job done. For some (many) 
problems, this can be a real win. And for some, not so much.

I think, this is often why, for a simple script, OO just kind of gets in the 
way. You have a straightforward procedure that you just want to do. The state 
(data) is not rich enough to make making it the focal point of your program.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue25994] File descriptor leaks in os.scandir()

2016-01-11 Thread Guido van Rossum

Guido van Rossum added the comment:

It was a bit more subtle. I think like this:

def f():
with some_lock:
yield 0
yield 1

def g():
with another_lock:
it = f()
for i in it:
raise

We determined that another_lock was freed *before* some_lock.  This is because 
the local variable 'it' keeps the generator object returned by f() alive until 
after the with-block in g() has released another_lock.

I think this does not strictly require f to be a generator -- it's any kind of 
closable resource that only gets closed by its destructor.

The solution is to add a try/finally that calls it.close() before leaving the 
with-block in g().

Hope this helps.

--

___
Python tracker 

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



Re: I'm missing something here...

2016-01-11 Thread Skip Montanaro
Sorry, I should have been explicit. prob_dates (the actual argument of the
call) is a set. As far as I know pylint does no type inference, so pylint
can't tell if the LHS and RHS of the |= operator are appropriate, nor can
it tell if it has an update() method.

Before writing, I had more-or-less concluded I had hit a bug, but in my
experience when I hit something I think is a bug, it's not. It's me.
Terry's reply convinced me that I had hit something.

Something else just occurred to me. I should have tried disassembling the
two versions of the function. Here's the output near prob_dates.update()
call:

 14
​  ​
   62 LOAD_FAST3 (prob_dates)
 65 LOAD_ATTR6 (update)
 68 LOAD_GLOBAL  7 (compare_prices)
 71 LOAD_CONST   3 ('E:%s')
 74 LOAD_FAST5 (sym)
 77 BINARY_MODULO
 78 LOAD_FAST0 (cx1)
 81 LOAD_FAST1 (cx2)
 84 LOAD_FAST2 (cx3)
 87 CALL_FUNCTION4
 90 CALL_FUNCTION1

Here's how the |= version disassembles in that region:

 20
​  ​
 62 LOAD_FAST3 (prob_dates)
 65 LOAD_GLOBAL  6 (compare_prices)
 68 LOAD_CONST   3 ('E:%s')
 71 LOAD_FAST5 (sym)
 74 BINARY_MODULO
 75 LOAD_FAST0 (cx1)
 78 LOAD_FAST1 (cx2)
 81 LOAD_FAST2 (cx3)
 84 CALL_FUNCTION4
 87 INPLACE_OR
 88 STORE_FAST   3 (prob_dates)

I think what's throwing pylint is that last
​STORE_FAST. That tells pylint the argument is ignored.

I'll at least bring up the issue on the code-quality list.

Thanks,

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


Re: Understanding " 'xml.etree.ElementTree.Element' does not support the buffer interface"

2016-01-11 Thread Steven D'Aprano
On Tue, 12 Jan 2016 08:54 am, Saran Ahluwalia wrote:

> Hi Steven:
> 
> Just as an update - apparently there were bytes in the Windows Command
> Terminal that were interrupting the process execution. I didn't realize
> this was happening until I dug around Windows' Q forum.

Thanks for letting us know, I'm glad you've solved your problem to your
satisfaction, but now I'm curious as to what sort of bytes in the Windows
terminal could cause the symptoms you were seeing. Could you share the
link(s) you found that explain this?



-- 
Steven

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


[issue26083] ValueError: insecure string pickle in subprocess.Popen on Python 2

2016-01-11 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 268d13c7e939 by Gregory P. Smith in branch '2.7':
Fixes issue #26083: Workaround a subprocess bug that raised an incorrect
https://hg.python.org/cpython/rev/268d13c7e939

--
nosy: +python-dev

___
Python tracker 

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



[issue26086] Bug in standardmodule os

2016-01-11 Thread Eryk Sun

Changes by Eryk Sun :


--
components: +Windows
nosy: +paul.moore, steve.dower, tim.golden, zach.ware

___
Python tracker 

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



[issue26086] Bug in standardmodule os

2016-01-11 Thread Eryk Sun

Eryk Sun added the comment:

The "yield from" syntax was added in Python 3.3, so somehow you're using the 
3.5 standard library with either an old 3.x or 2.x version. The older version 
shouldn't use 3.5's standard library, unless you have either PYTHONHOME or 
PYTHONPATH defined. Generally neither of these variables should be defined, 
especially not PYTHONHOME. In the command prompt run "set PYTHON" to list all 
environment variables that start with "PYTHON".

You also appear to be running with the 3.5 site-packages as the working 
directory. Even without the other problems, I recommend against this since the 
current directory has precedence in sys.path. You're moving site-packages to 
the head of the list, in front of the standard library. For example:

C:\Program Files\Python35\Lib\site-packages>type subprocess.py
print("This isn't the subprocess you're looking for.")

C:\Program Files\Python35\Lib\site-packages>py -3 -c "import subprocess"
This isn't the subprocess you're looking for.

Save your scripts in the top-level Scripts directory or a directory in your 
user profile. Generally leave everything under Lib alone, to be managed by pip 
and other installers.

--
nosy: +eryksun

___
Python tracker 

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



[issue25887] awaiting on coroutine more than once should be an error

2016-01-11 Thread Yury Selivanov

Yury Selivanov added the comment:

Attaching another patch.  Please review (I plan to commit it tomorrow in 3.5 
and 3.6 branches).

The patch affects generators machinery in the following way:

1. Generators behaviour isn't touched, the patch is only for 'async def' 
coroutines.

2. Calling 'send()' or 'throw()' on a coroutine object after it is exhausted or 
closed triggers a `RuntimeError("coroutine was already awaited")`

3. Calling 'close()' method on an exhausted or closed coroutines is a no-op.  
'close()' can be called multiple times -- same as for generators.

--
Added file: http://bugs.python.org/file41587/Issue25887_3.patch

___
Python tracker 

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



[issue25994] File descriptor leaks in os.scandir()

2016-01-11 Thread Martin Panter

Martin Panter added the comment:

Guido are you saying in the following code, the “finally” message is not 
guaranteed to be printed out? Or just that you cannot limit a ResourceWarning 
to garbage collection?

def g():
try:
yield "item"
finally:
# Run at exhaustion, close(), and garbage collection
print("finally")

gi = g()
try:
item = next(gi)
print(item / 2)  # Oops, TypeError
finally:
# Should be run as the exception passes through. GeneratorExit is raised 
inside the generator, causing the other “finally” block to execute. All before 
the original exception is caught and a traceback is printed.
gi.close()

But as I understand it, os.scandir() is not a generator, so none of these 
problems would apply.

--
nosy: +martin.panter

___
Python tracker 

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



Re: Which Python editor has this feature?

2016-01-11 Thread Chris Angelico
On Tue, Jan 12, 2016 at 11:55 AM, Bernardo Sulzbach
 wrote:
> On Mon, Jan 11, 2016 at 10:14 PM, Chris Angelico  wrote:
>>
>> Next IDLE feature request: Can you make it so that, across all
>> platforms, it magically installs PostgreSQL and psycopg2? That would
>> solve so many of my students' problems...
>>
>
> Wouldn't this make the installer much bigger?

Yes, and it's also completely and utterly inappropriate. But I am
seeing a lot of cool magic getting added to Idle. Since I met Python,
it's gone from being "well, yeah, Python *does* include a GUI, but
it's pretty unexciting compared to others" to "Python includes a
pretty decent editor, but it's (unsurprisingly) Python-specific, so I
don't use it for multilingual work".

Shout-out to Terry and the other Idle devs for the work they've put in. Thanks!

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


Re: When I need classes?

2016-01-11 Thread Chris Angelico
On Tue, Jan 12, 2016 at 11:53 AM, Bernardo Sulzbach
 wrote:
> On Mon, Jan 11, 2016 at 9:45 PM, Travis Griggs  wrote:
>>
>>> On Jan 10, 2016, at 9:48 AM, Bernardo Sulzbach  
>>> wrote:
>>>
>>> Essentially, classes (as modules) are used mainly for organizational 
>>> purposes.
>>>
>>> Although you can solve any problem you would solve using classes
>>> without classes, solutions to some big problems may be cheaper and
>>> more feasible using classes.
>>
>> I think, this is often why, for a simple script, OO just kind of gets in the 
>> way. You have a straightforward procedure that you just want to do. The 
>> state (data) is not rich enough to make making it the focal point of your 
>> program.
>
> Your answer is quite good. I am not a purist myself (when it comes to
> Java and C++, I am never going to instantiate a Math class to get a
> logarithm function), but I understand the value of OO from experience.
> As I mentioned those "tuples and dictionaries" to pass data around, I
> would like to add that when a single script has two kinds of tuples or
> dictionaries, you may be better of using two different classes, as
> having "dedicated" types simplifies project organization and
> enhances readability.
>

Yeah. One thing I often recommend, especially to students, is to start
with the very simplest and most naive code they can knock together,
and then look at making it tidier afterwards. Classes, decorators, the
unittest setUp/tearDown methods, and even functions themselves, are
all just ways of improving code that could be written some other way.
They're not rigid structures that you HAVE to comply with or your code
is *just* *not* *good* *enough*. So start simplistic, and then look
into it like this: "Hey, see how you're doing this five times? There
HAS to be a better way!" (With acknowledgement to Raymond Hettinger.)

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


Re: Understanding " 'xml.etree.ElementTree.Element' does not support the buffer interface"

2016-01-11 Thread Saran Ahluwalia
Hi Steven:

Just as an update - apparently there were bytes in the Windows Command
Terminal that were interrupting the process execution. I didn't realize
this was happening until I dug around Windows' Q forum.

Cheers

On Sun, Jan 10, 2016 at 12:53 PM, Saran Ahluwalia <
ahlusar.ahluwa...@gmail.com> wrote:

> Hi Steven:
>
> The previous code was a stand along under the " if __name__ ==
> '__main__': ". The full function suite that I have made (and indeed
> includes a try and except block):
>
> import os.path
> import sys
> import csv
> from io import StringIO
> import xml.etree.cElementTree as ElementTree
> from xml.etree.ElementTree import XMLParser
> # import xml
> # import xml.sax
> # from xml.sax import ContentHandler
>
>
> def flatten_list(self, aList, prefix=''):
>
> for i, element in enumerate(aList, 1):
> eprefix = "{}{}".format(prefix, i)
> if element:
> # treat like dict
> if len(element) == 1 or element[0].tag != element[1].tag:
> yield from flatten_dict(element, eprefix)
> # treat like list
> elif element[0].tag == element[1].tag:
> yield from flatten_list(element, eprefix)
> elif element.text:
> text = element.text.strip()
> if text:
> yield eprefix[:].rstrip('.'), element.text
>
>
> def flatten_dict(parent_element, prefix=''):
>
> prefix = prefix + parent_element.tag
> if parent_element.items():
> for k, v in parent_element.items():
> yield prefix + k, v
> for element in parent_element:
> eprefix = element.tag
> if element:
> # treat like dict - we assume that if the first two tags
> # in a series are different, then they are all different.
> if len(element) == 1 or element[0].tag != element[1].tag:
> yield from flatten_dict(element, prefix=prefix)
> # treat like list - we assume that if the first two tags
> # in a series are the same, then the rest are the same.
> else:
> # here, we put the list in dictionary; the key is the
> # tag name the list elements all share in common, and
> # the value is the list itself
> yield from flatten_list(element, prefix=eprefix)
> # if the tag has attributes, add those to the dict
> if element.items():
> for k, v in element.items():
> yield eprefix+k
> # this assumes that if you've got an attribute in a tag,
> # you won't be having any text. This may or may not be a
> # good idea -- time will tell. It works for the way we are
> # currently doing XML configuration files...
> elif element.items():
> for k, v in element.items():
> yield eprefix+k
> # finally, if there are no child tags and no attributes, extract
> # the text
> else:
> yield eprefix, element.text
>
>
>
> def just_xml_data(path):
> with open(path, 'rU', encoding='UTF-8') as data:
> separated = data.read().split('","')
> print(separated)
> try:
> x = ElementTree.XML(separated[3])
> print(x)
> xml.etree.ElementTree.dump(x)
> y = ElementTree.XML(separated[4])
> xml.etree.ElementTree.dump(y)
> # response = ElementTree.XML(separated[4])  # work on the
> Response column
> # root = ElementTree.XML(response) #serialize and parse into
> XML object
> except Exception as e:
> print(e)
> else:
> xml_field = dict(flatten_dict(y))
> return xml_field
>
> def read_data(path):
> headers= set()
> rows = []
> with open(path, 'rU', encoding='utf-8') as data:
> reader = csv.DictReader(data, dialect=csv.excel,
> skipinitialspace=True)
> for row in reader:
> xml_field = row["CLIENT_RESP_DATA"]
> # xml_data = just_xml_data(xml_field) ## function
> if xml_data is not None:
> row.update(xml_data)
> headers.update(row.keys())
> rows.append(row)
> else:
> print("Failure")
> pass
> with open(os.path.splitext(textFile)[0] + '_' + 'parsed' + '.csv',
> "wt", newline='') as output_file:
> wr = csv.writer(output_file)
> csv_headers = list(headers)
> wr.writerow(csv_headers)
> for row in rows:
> values = []
> for field in csv_headers:
> value = row.get(field, None)
> values.append(value)
> wr.writerow(values)
> return output_file
>
>
>
> if __name__ == '__main__':
> Response = "s.csv"
> just_xml_data(Response)
>
>
> Hopefully this will provide you with enough information to emulate
> (apologies for any and all indentation 

[issue26083] ValueError: insecure string pickle in subprocess.Popen on Python 2

2016-01-11 Thread Gregory P. Smith

Gregory P. Smith added the comment:

I strongly recommend people use https://pypi.python.org/pypi/subprocess32/ 
instead of Python 2.7's subprocess module whenever possible.

That said, the fix is pretty easy.

--
assignee:  -> gregory.p.smith

___
Python tracker 

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



[issue26083] ValueError: insecure string pickle in subprocess.Popen on Python 2

2016-01-11 Thread Eryk Sun

Eryk Sun added the comment:

> I strongly recommend people use https://pypi.python.org/pypi/subprocess32/

I think this warrants a note that draws more attention to itself than the "see 
also" text.

--
nosy: +eryksun

___
Python tracker 

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



[issue25967] Devguide: add 2to3 to the "Changing CPython's Grammar" checklist

2016-01-11 Thread Ezio Melotti

Ezio Melotti added the comment:

Fixed, thanks for the patch!

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

___
Python tracker 

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



[issue25887] awaiting on coroutine more than once should be an error

2016-01-11 Thread Yury Selivanov

Yury Selivanov added the comment:

> I don't like "coroutine was already awaited". I feel like either "on" should 
> be appended to that or another sentence like "coroutine had 'await' called on 
> it" or something.

Fine with me to have "coroutine was already awaited on".

--

___
Python tracker 

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



Re: When I need classes?

2016-01-11 Thread Michael Torrie
On 01/11/2016 04:45 PM, Travis Griggs wrote:
> As a long term OO purist practitioner, I would add to this.
> Obviously, you can organize your code any way you want, with or
> without classes. You could put all your functions with an odd number
> of letters in one class, and all of the even numbered ones in another
> class.

And of course in Java you have to use classes for namespaces and
organization.  In python, the equivalent is simply a module.  It's
essentially a singleton object without having to do any boiler plate.  A
module can even keep state, so long as you only need to keep track of
one instance or set of states at a time.

> Having listened to the guy (Alan Kay) who coined the term (Object
> Oriented Programming) quite a bit over the years, I believe that the
> focus of OO (of which classes are a particular implementation
> approach) is to bind behavior to data. In “traditional” programming
> approaches, one focused on the algorithm (behavior) first, and then
> figured out what data needed to flow where to get the job done.
> Classes provided a mechanism to turn that equation, generally
> speaking, around. One thinks about the data first, and then figures
> out what behavior binds best to that data. And how that data will
> interact (inter-object behavior, often called messages) to get your
> job done. For some (many) problems, this can be a real win. And for
> some, not so much.
> 
> I think, this is often why, for a simple script, OO just kind of gets
> in the way. You have a straightforward procedure that you just want
> to do. The state (data) is not rich enough to make making it the
> focal point of your program.

The beauty of Python is that you can program procedurally, and still
work with objects as needed.  Every data type in Python is some kind of
object and you can call appropriate methods on those objects.  Even if
you do no OOP programming yourself.  For example,

some_string = "foo:bar"
(a,b) = some_string.split(':')

The ease with which Python can be used in many programming paradigms is
one reason I like Python so much.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: I'm missing something here...

2016-01-11 Thread Terry Reedy

On 1/11/2016 6:26 PM, Skip Montanaro wrote:

Here's a dumb little bit of code, adapted from a slightly larger script:

#!/usr/bin/env python

"dummy"

import glob
import os

def compare_prices(*_args):
 "dummy"
 return set()

def find_problems(cx1, cx2, cx3, prob_dates):
 "dummy"
 for fff in sorted(glob.glob("/path/to/*.nrm")):
 sym = os.path.splitext(os.path.basename(fff))[0]
 prob_dates |= compare_prices("E:%s"%sym, cx1, cx2, cx3)

When I run pylint against it, it complains:

junk.py:10: [W0613(unused-argument), find_problems] Unused argument 'prob_dates'

I must be misunderstanding something about the |= operator as applied
to sets. If I read the docs correctly, s1 |= s2 is equivalent to
s1.update(s2). A dumb "test" at the prompt suggests that's true:


s1 = set("abc")
s2 = set("cde")
s1 | s2

set(['a', 'c', 'b', 'e', 'd'])

s1 |= s2
s1

set(['a', 'c', 'b', 'e', 'd'])

s1 = set("abc")
s1.update(s2)
s1

set(['a', 'c', 'b', 'e', 'd'])

If I change the last line of find_problems to call
prob_dates.update(), the message disappears. Why is pylint (1.4.2 BTW)
complaining that the prob_dates argument of find_problems is unused
when I use the |= operator?


A bug in pylint. It should treat both cases the same.


--
Terry Jan Reedy

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


[issue25994] File descriptor leaks in os.scandir()

2016-01-11 Thread Martin Panter

Martin Panter added the comment:

Okay I understand. You have to explicitly call the close() method if you want a 
generator to be cleaned up properly, which parallels how Serhiy’s proposal 
would be used.

--

___
Python tracker 

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



Re: Which Python editor has this feature?

2016-01-11 Thread jfong
Chris Angelico at 2016/1/11  UTC+8 10:59:47AM wrote:
> On Mon, Jan 11, 2016 at 12:59 PM,   wrote:
> > It lets you jump between the current cursor position and the line the upper 
> > level indentation start, something like the bracket matching in C editor. 
> > Because of Python use indentation as its code block mark, It might be 
> > helpful if we can jump between different level of it:-)
> 
> I coded this up as a patch for SciTE/Scintilla at one point, but it
> didn't get accepted. It was used for a while at my work, but never
> really settled in as being useful. Python code tends not to be as big
> and complex as C code often is, so it's not as useful to have a
> feature like this.
> 
> If you want it, I can probably hunt down the patch file somewhere.
> 
> ChrisA

I am studying the PyUSB package now as the learning object of how to write a 
Python program in a "formal" way. In those modules, there are many comment 
inserted between codes to explain what it does. It's good to the user 
comprehension, but also easily makes a Class size expanded to over 100 lines. 
Also many Classes has the same named method such as __getitem__ etc. When 
searching a specific name I usually have to roll back the screen a few times to 
find out what Class I am looking at. That's really annoy.

But, just like you said, this feature may be not so useful to a Python 
programmer. I should try the editor I am using now to see if I can "patch" a 
such feature, just as you had did on SciTE before:-)

--Jach

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


Re: Strange crash while running a script with a embedded python interpreter

2016-01-11 Thread Chris Angelico
On Mon, Jan 11, 2016 at 6:55 PM, Rickard Englund
 wrote:
> On Friday, January 8, 2016 at 11:28:53 PM UTC+1, Michael Torrie wrote:
>> On 01/08/2016 09:18 AM, Rickard Englund wrote:
>> > First, some system info
>> > * Windows 7 (also tested on 8 and 10)
>> > * Python 3.5.1 64bit (previously also tested using several 3.x versions)  
>> > (also tested with 32 bit, but with 3.4.2)
>> > * Microsoft Visual Studio 2015 (earlier version of python also tested with 
>> > Visual Studio 2013)
>>
>> Are you using the same version of Visual Studio that Python itself was
>> compiled with?  If not there can be subtle problems with incompatible
>> msvcrt dlls.  No idea if this would be contributing to the problem or
>> not, though.
>
> I've just downloaded the python source code and build it myself, the compiler 
> settings in our project is the same as in the python projects.
>
>
> Though, your comment led me in the correct direction. When using the 
> libs/binary I built my self it let me see the values of the PyObjects around 
> the crash and it seems like it is related to our modules and/or how we expose 
> them to the interpreter. When disabling our own modules everything seems to 
> be working as it should.
>

Interesting. So somewhere along the way, you have native code (C
code?) that's creating a module, and that's where the trouble starts?
I would first look at all your refcount management; if that goes
wrong, all sorts of craziness could happen (if you still have a
pointer to a block of memory that gets released and reused, hilarity
will ensue - or, something will). Have you considered using Cython?
That might let you do what you need without worrying about all those
annoying internal API details.

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


Re: Strange crash while running a script with a embedded python interpreter

2016-01-11 Thread Rickard Englund
On Friday, January 8, 2016 at 11:28:53 PM UTC+1, Michael Torrie wrote:
> On 01/08/2016 09:18 AM, Rickard Englund wrote:
> > First, some system info
> > * Windows 7 (also tested on 8 and 10) 
> > * Python 3.5.1 64bit (previously also tested using several 3.x versions)  
> > (also tested with 32 bit, but with 3.4.2) 
> > * Microsoft Visual Studio 2015 (earlier version of python also tested with 
> > Visual Studio 2013)  
> 
> Are you using the same version of Visual Studio that Python itself was
> compiled with?  If not there can be subtle problems with incompatible
> msvcrt dlls.  No idea if this would be contributing to the problem or
> not, though.

I've just downloaded the python source code and build it myself, the compiler 
settings in our project is the same as in the python projects. 


Though, your comment led me in the correct direction. When using the 
libs/binary I built my self it let me see the values of the PyObjects around 
the crash and it seems like it is related to our modules and/or how we expose 
them to the interpreter. When disabling our own modules everything seems to be 
working as it should. 

I think I got it wokring now, used some ugly hacks I need to clean up before I 
certain it works. 

Thanks for the help. 

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


looking for windows testers

2016-01-11 Thread Ulli Horlacher
I have written a Python client for F*EX(*). It is designed for Windows
users, though it runs on UNIX, too. I am now looking for testers. If you
are interested, I will give you an account on my server.


(*) Frams' Fast File EXchange is a service to send files of any size to
any user anywhere in the internet: 
http://fex.rus.uni-stuttgart.de:8080/index.html

-- 
Ullrich Horlacher  Server und Virtualisierung
Rechenzentrum IZUS/TIK E-Mail: horlac...@tik.uni-stuttgart.de
Universitaet Stuttgart Tel:++49-711-68565868
Allmandring 30aFax:++49-711-682357
70550 Stuttgart (Germany)  WWW:http://www.tik.uni-stuttgart.de/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Fwd: python unit test framework sample code

2016-01-11 Thread Ganesh Pal
Totally stuck with this
On Jan 10, 2016 7:11 PM, "Ganesh Pal"  wrote:

> Apologies,  looks like I did a reply instead of reply-all. So
> forwarding this email , please provide guidance on the same
>
> -- Forwarded message --
> From: Ganesh Pal 
> Date: Thu, Jan 7, 2016 at 12:26 PM
> Subject: Re: python unit test framework sample code
> To: Terry Reedy 
>
> > Unless you have a large program already in 2.6 and are just adding tests
> > (perhaps so you can more easily upgrade someday), consider upgrading to a
> > newer version.
>
> Sure , but for now Iam limited to use 2.6 , hence I cant upgrade need
> to work with 2.6
>
> >>
> >> class FileSystemTest(unittest2.TestCase):
> >>  block_address = {}
> >>  report = ""
> >>
> >>  @classmethod
> >>  def setUpClass(cls):
> >>  cls.FileSystemSetup()
> >
> >
> > This is senseless.  Put the body of FileSystemSetup here.
>
> I didn't understand  which line is senseless. I was trying to refer
> this example on stack overflow
>
> http://stackoverflow.com/questions/5938517/not-able-call-a-local-method-from-setupclass
>
>
> class TestSystemPromotion(unittest2.TestCase):
>
>   @classmethod
>   def setUpClass(cls):
> cls.setup_test_data()
>
>
>   @classmethod
>   def setup_test_data(cls):
> ...
>
>   def test_something(self):
> ...
>
>
> class FileSystemTest(unittest2.TestCase):
> block_address = {}
> report = ""
>
> @classmethod
> def setUpClass(cls):
> cls.FileSystemSetup()
>
> @classmethod
> def FileSystemSetup(cls):
> """
> Initial setup before unittest is run
> """
> logging.info("SETUP.Started !!!")
>
> >>  def inode_corruption(self):
> >>  """ test_01: inode  corruption """
> >>  self.assertTrue(corrupt.run_query_tool(self.__class__.report,
> >
> >
> > self.block_address['test_01']))
> >
> > Assuming that unittest2 is same as unittest, test methods must be called
> > test_xyz.  So this is not run, hence no error.
>
> Sorry  I have changed this from inode_corruption' to 'test_inode_corruption
>
> >
> >>  @classmethod
> >>  def tearDownClass(cls):
> >>  cls.tearDown()
> >
> >
> > Ditto.  Put real body here.
> >
> >>  @classmethod
> >>  def tearDown(cls):
> >
> >
>
> > The above refers to functions you did not post.  For current unittest, it
> > looks likes you should be using a setUpModule (possible tearDownModule)
> > functions, but I don't know if those are available in the older
> unittest2.
>
>
> we have tearDownClass and setUpClass in python 2.6 and under unittest2
>
> >>> help(unittest2.TestCase.tearDownClass)
> Help on method tearDownClass in module unittest2.case:
>
> tearDownClass(cls) method of __builtin__.type instance
> Hook method for deconstructing the class fixture after running all
> tests in the class.
>
> >>> help(unittest2.TestCase.setUpClass)
> Help on method setUpClass in module unittest2.case:
>
> setUpClass(cls) method of __builtin__.type instance
> Hook method for setting up class fixture before running tests in the
> class.
>
> Regards,
> Ganesh
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Which Python editor has this feature?

2016-01-11 Thread Gordon Levi
jf...@ms4.hinet.net wrote:

>It lets you jump between the current cursor position and the line the upper 
>level indentation start, something like the bracket matching in C editor. 
>Because of Python use indentation as its code block mark, It might be helpful 
>if we can jump between different level of it:-)

Jetbrains Pycharm has "go to start of block" and "go to end of block"
commands .

Unfortunately the free version of Pycharm does not support remote
debugging and my main use for Python is for programming a Raspberry
Pi. I use Visual Studio instead and its "go to end of block" does not
work in the Python editor
.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Which Python editor has this feature?

2016-01-11 Thread jfong
Tim Chase at 2016/1/11 UTC+8 11:16:27AM wrote:
> On 2016-01-10 17:59, jf...@ms4.hinet.net wrote:
> > It lets you jump between the current cursor position and the line
> > the upper level indentation start, something like the bracket
> > matching in C editor. Because of Python use indentation as its code
> > block mark, It might be helpful if we can jump between different
> > level of it:-)
> 
> While not quite what you're asking for, vim offers an "indent text
> object" plugin[1] that allows you to use a block of indentation
> around the cursor as an object.  So you can use vim's grammar to issue
> commands like "dai" to delete the current indentation-defined block;
> or you can use ">ii" to add a level of indentation to the
> indentation-defined block.

Thanks, Tim.
I always admire people who can remember all those detail 
commands/parameters/options which a DOS-style editor as vim has. It's almost 
like a mission impossible to me:-(

> If you want to make a vim mapping that will jump up to the top of the
> previous level of indentation, the following should do the trick
> 
>   :nnoremap  Q '?^'.repeat(' ', (strlen(substitute(getline('.'), 
> '\S.*', '', ''))-)).'\S?e'."\"

But, but... this line??? won't it goes too far for a human being to read?

--Jach

> There might be some edge-cases that I haven't caught there, but, as
> long as you edit with spaces rather than tabs, it should work,
> including the accommodation of your 'shiftwidth', even if it's not
> PEP8 4-spaces-per-indent.
> 
> -tkc
> 
> [1]
> https://github.com/michaeljsmith/vim-indent-object

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


[issue25887] awaiting on coroutine more than once should be an error

2016-01-11 Thread Yury Selivanov

Yury Selivanov added the comment:

Attaching an updated patch.  The RuntimeError says 'coroutine was already 
awaited on' for now.

--
Added file: http://bugs.python.org/file41588/Issue25887_4.patch

___
Python tracker 

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



[issue25991] readline example eventually consumes all memory

2016-01-11 Thread Martin Panter

Martin Panter added the comment:

Thanks Ezio for handling this. Ignore my previous comment; I missed the key 
word “example” :)

--

___
Python tracker 

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



Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2016-01-11 Thread ifeanyioprah
How do I use hack to move to the next question
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2016-01-11 Thread ifeanyioprah
How do I use hack to move to the next question
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Which Python editor has this feature?

2016-01-11 Thread Terry Reedy

On 1/11/2016 8:51 PM, jf...@ms4.hinet.net wrote:

Terry Reedy at 2016/1/12 UTC+8 5:22:35AM wrote:

IDLE has an optional 'code context' feature that shows header lines that
have scrolled up off the top of the screen.  This would let you see
which class you are in,


Thanks, Terry. It's just what I am looking for:-)
By the way, do you know how to open file in a new tab, instead of in a separate 
window, in the IDLE editor?


Revamping IDLE to 1. use ttk widgets and 2. become a modern single 
window app with multiple panes, including a tabbed editor pane, is a 
goal for 2016.



--
Terry Jan Reedy

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


[issue25788] fileinput.hook_encoded has no way to pass arguments to codecs

2016-01-11 Thread Terry J. Reedy

Terry J. Reedy added the comment:

fileinput is in Python, hence the source is in Lib.  Online version is
https://hg.python.org/cpython/file/tip/Lib/fileinput.py
https://hg.python.org/cpython/file/tip/Lib/test/test_fileinput.py

Patching openhook itself looks trivial.  A test is the hard part. Laura, can 
you provide a test case? -- a short (one line?) file that fails with 
errors=strict and passes with something else?  A new test_errors method should 
be added to class Test_hook_encoded (the last testCase in the file).  I think 
the 'test' method would need revision.

--
nosy: +terry.reedy

___
Python tracker 

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



[issue25348] Update pgo_build.bat to use --pgo flag for regrtest

2016-01-11 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 113c524aed93 by Zachary Ware in branch '2.7':
Issue #25348: Add --pgo and --pgo-job flags to PCbuild\build.bat
https://hg.python.org/cpython/rev/113c524aed93

New changeset 01ab138f4133 by Zachary Ware in branch '3.5':
Issue #25348: Add --pgo and --pgo-job flags to PCbuild\build.bat
https://hg.python.org/cpython/rev/01ab138f4133

New changeset 9442b4a60379 by Zachary Ware in branch 'default':
Closes #25348: Merge with 3.5
https://hg.python.org/cpython/rev/9442b4a60379

--
nosy: +python-dev
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

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



[issue25348] Update pgo_build.bat to use --pgo flag for regrtest

2016-01-11 Thread Zachary Ware

Zachary Ware added the comment:

Thanks for the review, Steve.

--
assignee: brett.cannon -> zach.ware

___
Python tracker 

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



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

2016-01-11 Thread Zach Byrne

Zach Byrne added the comment:

Anybody still looking at this? I can take another stab at it if it's still in 
scope.

--

___
Python tracker 

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



Re: How to remove item from heap efficiently?

2016-01-11 Thread Cem Karan

On Jan 11, 2016, at 9:53 AM, srinivas devaki  wrote:

> On Jan 11, 2016 12:18 AM, "Sven R. Kunze"  wrote:
>> Indeed. I already do the sweep method as you suggested. ;)
>> 
>> Additionally, you provided me with a reasonable condition when to do the
> sweep in order to achieve O(log n). Thanks much for that. I currently used
> a time-bases approached (sweep each 20 iterations).
>> 
>> PS: Could you add a note on how you got to the condition (
> 2*self.useless_b > len(self.heap_b))?
>> 
> 
> oh that's actually simple,
> that condition checks if more than half of heap is useless items.
> the sweep complexity is O(len(heap)), so to keep the extra amortized
> complexity as O(1), we have to split that work(virtually) with O(len(heap))
> operations, so when our condition becomes true we have done len(heap)
> operations, so doing a sweep at that time means we splitted that
> work(O(len(heap))) with every operation.

Jumping in late, but...

If you want something that 'just works', you can use HeapDict:

http://stutzbachenterprises.com/

I've used it in the past, and it works quite well.  I haven't tested its 
asymptotic performance though, so you might want to check into that.

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


Re: How to remove item from heap efficiently?

2016-01-11 Thread Paul Rubin
srinivas devaki  writes:
> I googled about "timing wheels" and "Linux kernel scheduler"

Sorry, correct term was "timer wheel" rather than "timing wheel".

http://www.elinux.org/Kernel_Timer_Systems has some links.

The Erlang BEAM internal scheduler works the same way, iirc.

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


[issue25887] awaiting on coroutine more than once should be an error

2016-01-11 Thread Yury Selivanov

Yury Selivanov added the comment:

"Cannot await previously awaited coroutine" might be confusing if raised on 
"coro.send(..)"-like code...

So far "coroutine was already awaited on" (do you want to drop "was", btw?) is 
less of all evil IMHO.

--

___
Python tracker 

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



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

2016-01-11 Thread Zach Byrne

Zach Byrne added the comment:

> Can you figure why unpack_sequence and other benchmarks were slower?
I didn't look really closely, A few of the slower ones were floating point 
heavy, which would incur the slow path penalty, but I can dig into 
unpack_sequence.

--

___
Python tracker 

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



[issue25887] awaiting on coroutine more than once should be an error

2016-01-11 Thread Yury Selivanov

Yury Selivanov added the comment:

Oh, choosing a good error message is hard :(

I've a few comments.  Sorry, this thread is growing rather rapidly, but please 
help me to pick one of them:


> From the point of view of the error message, the reason I changed my 
> suggestion was because I liked your idea of optimising it for the "only using 
> await" case and trusting that the folks delving into the lower level plumbing 
> of calling methods manually can figure it out. [...]

We either have to use a sub-optimal error message tailored for 'await' 
expression users, or we can choose a longer error message.  I'm not very fond 
of this option, but maybe it's because I can't come up with something long and 
concise at the same time.  Maybe something along the lines of: "cannot resume 
terminated coroutine (was it awaited on before?)"


> That is, "Cannot resume terminated coroutine" is always accurate, but relies 
> on the reader knowing that "await" both resumes a coroutine and waits for it 
> to terminate.

Not sure I like the "terminated" word here.  The coroutine was either awaited 
before, which means that the coroutine object is now exhausted, or it was 
manually closed at some point.  To me "terminated" is closer to the latter.


> "Coroutine was previously awaited on" may be wrong about how the coroutine 
> was originally terminated, but at least hints that the error may be related 
> to awaiting the coroutine.

Agree.


> "Cannot resume previously awaited coroutine" would be inaccurate under the 
> same circumstances.

Thinking about "resume"...  If a user sees this message pointing to an "await" 
expression, it might confuse them, since "await coro" does not just resume 
"coro".  It inits and consumes "coro" until it raises a StopIteration.


"Cannot await previously awaited coroutine" would only be entirely accurate for 
"double await" errors, but doesn't rely on the reader making any assumptions at 
all in that case.

Agree.  But I don't like that we have two "await" words in one short message.


> (The bulk of the problem here is that my brain is happy to accept "awaited" 
> as a novel adjective modifying "coroutine", but balks at "awaited" as a verb 
> or "awaited on" as a verb phrase. I'm extrapolating from that to guess that 
> other folks would find the verb form similarly jarring)

I trust your brain here, you're a native speaker ;)  If you think that "Cannot 
await previously awaited coroutine" is the best option here, let's stick to it.

--

___
Python tracker 

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



[issue25486] Resurrect inspect.getargspec() in 3.6

2016-01-11 Thread Yury Selivanov

Yury Selivanov added the comment:

> Now the documentation says it will be removed in 3.6. I guess the 3.5 
> documentation also needs updating.

Good catch!

--

___
Python tracker 

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



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

2016-01-11 Thread Yury Selivanov

Yury Selivanov added the comment:

> Anybody still looking at this? I can take another stab at it if it's still in 
> scope.

There were some visible speedups from your patch -- I think we should merge 
this optimization.  Can you figure why unpack_sequence and other benchmarks 
were slower?

--
nosy: +yselivanov

___
Python tracker 

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



[issue25887] awaiting on coroutine more than once should be an error

2016-01-11 Thread Nick Coghlan

Nick Coghlan added the comment:

Sorry, dropping the "was" was a typo (I should have copied & pasted it instead 
of rewriting).

>From the point of view of the error message, the reason I changed my 
>suggestion was because I liked your idea of optimising it for the "only using 
>await" case and trusting that the folks delving into the lower level plumbing 
>of calling methods manually can figure it out. Anything that mentions await 
>*at all* will be wrong in some cases, since what we're actually reporting is 
>an attempt to resume (by some means) a coroutine that was previously 
>terminated (by some means).

That is, "Cannot resume terminated coroutine" is always accurate, but relies on 
the reader knowing that "await" both resumes a coroutine and waits for it to 
terminate.

"Coroutine was previously awaited on" may be wrong about how the coroutine was 
originally terminated, but at least hints that the error may be related to 
awaiting the coroutine.

"Cannot resume previously awaited coroutine" would be inaccurate under the same 
circumstances.

"Cannot await previously awaited coroutine" would only be entirely accurate for 
"double await" errors, but doesn't rely on the reader making any assumptions at 
all in that case.

(The bulk of the problem here is that my brain is happy to accept "awaited" as 
a novel adjective modifying "coroutine", but balks at "awaited" as a verb or 
"awaited on" as a verb phrase. I'm extrapolating from that to guess that other 
folks would find the verb form similarly jarring)

--

___
Python tracker 

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



OT: There are no words for how broken everything is

2016-01-11 Thread Steven D'Aprano
There are no words to explain just how broken everything is. This post 
tries:

https://medium.com/message/everything-is-broken-81e5f33a24e1

but barely covers even a fraction of the breakage.

Thanks goodness for anti-virus, right?

One of the leading anti-virus vendors in the world, TrendMicro, has been 
opening their victims^W users' computers to trivially-discoverable remote 
execution attacks, exposing passwords to the internet, and running an old 
and insecure browser with security settings disabled (no sandbox).

https://code.google.com/p/google-security-research/issues/detail?id=693


What's the worst security screw-up you've seen? The worst I've seen was a 
sys admin I used to work with who put a new Linux server on the internet 
with root ssh enabled. Guess what password he used for the root account? 
"test". Guess how long it took before it was broken into? Less than two 
hours.

That is at the top of my list only because I can prove exactly what 
happened. Otherwise it would be an incident that I can't completely explain. 
I have my suspicions, but I'm not entire sure what happened.

This was one of the last incidents that drove me off Windows. I was running 
Windows XP, protected behind a firewall, with commercial up-to-date anti-
virus installed. I started up Windows update one day, and went out for a few 
hours, and came back to find the computer absolutely swarming with malware 
and the firewall turned off. I don't know what happened, I can only guess 
that the Windows update process turned off the firewall, but I don't really 
know. All I know is that whatever it was, it was a completely automated 
attack, as nobody was home to click on any buttons or visit any dubious 
websites.

Took me three weeks to remove the last of the malware, and another two weeks 
to track down the cause of an annoying glitch where every 30 seconds the PC 
would freeze up for a fraction of a second. It was one of the anti-virus 
programs I had installed.



-- 
Steve

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


Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2016-01-11 Thread ifeanyioprah
Please how did you back it to move over to the next question pls need your help
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue25887] awaiting on coroutine more than once should be an error

2016-01-11 Thread Nick Coghlan

Nick Coghlan added the comment:

I expect whatever message we use will become a Stack Overflow question in 
fairly short order, so "good enough" is almost certainly good enough here, and 
I'm massively overthinking the problem :)

However, combining my last suggestion with a variant of Martin's would give us:

"Cannot reuse already awaited coroutine"

The generic "reuse" both eliminated the repetition of "await", and also gets us 
away from worrying about exactly what the caller was doing.

--

___
Python tracker 

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



[issue25887] awaiting on coroutine more than once should be an error

2016-01-11 Thread Yury Selivanov

Yury Selivanov added the comment:

> IMO “yield from coroutine_iterator” might be plausable for some strange 
> combination of 3.4 code and a 3.5 coroutine, but I think it would be rare. 
> And if you added a check in __await__() then the using “await” wouldn’t need 
> to rely on next() raising the RuntimeError.

Adding the check *only* to __await__ will allow you to wrap an exhausted 
coroutine in an 'asyncio.Task' and await on it (the await will do nothing, 
which this patch fixes).

I think it's important to fix all coroutines' APIs to throw an error if they're 
manipulated in any way after being exhausted/closed, that's why I decided to 
fix the lower level.

To be honest, I don't care too much about 'yield from coro.__await__()' raising 
a RuntimeError (if the coro is an 'async def' coroutine that *is* 
closed/exhausted).  To me it's a clear behaviour.  Again, coroutine-iterators 
(objects returned by native coroutines from their __await__() method) aren't 
classical iterators meant to produce a fibonacci sequence in a for..in loop.  
They are a low level interface to their coroutine objects.

--

___
Python tracker 

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



[issue25887] awaiting on coroutine more than once should be an error

2016-01-11 Thread Martin Panter

Martin Panter added the comment:

Isn’t the combined point of this issue and Issue 25888 to make it only legal to 
“await” a coroutine instance that has not yet been started? Perhaps “Cannot 
[re]start terminated coroutine” would be better.

--

___
Python tracker 

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



Re: OT: There are no words for how broken everything is

2016-01-11 Thread Rick Johnson
On Monday, January 11, 2016 at 10:26:40 PM UTC-6, Steven D'Aprano wrote:
> [...]
> Took me three weeks to remove the last of the malware, and another two weeks 
> to track down the cause of an annoying glitch where every 30 seconds the PC 
> would freeze up for a fraction of a second. It was one of the anti-virus 
> programs I had installed.

Three weeks??? Dude, you could have rebuilt the system in a few hours! :-) But 
this is *WAY* off topic. Hey Steven, they have these new inventions now called 
"blogs", maybe you should sign up for one? Heck, *I* even have a blog now!

  http://arantadaykeepsthemonstersaway.blogspot.com/

PS: And there's an nice Easter Egg on my google profile you might enjoy. *wink*
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: I'm missing something here...

2016-01-11 Thread Cameron Simpson

On 11Jan2016 23:55, Erik  wrote:

On 11/01/16 23:26, Skip Montanaro wrote:

If I change the last line of find_problems to call
prob_dates.update(), the message disappears. Why is pylint (1.4.2 BTW)
complaining that the prob_dates argument of find_problems is unused
when I use the |= operator?


Is it complaining about that, or is it because the 'for' loop body might be 
executed zero times?


The former. Almost any loop _might_ be executed zero times. Compilers and 
linters etc should only complain if they can prove the loop is always executed 
zero times.


Cheers,
Cameron Simpson 
--
https://mail.python.org/mailman/listinfo/python-list


Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2016-01-11 Thread mrkimanindegwa
On Saturday, December 12, 2015 at 12:05:29 PM UTC+3, Harbey Leke wrote:
> Create a class called BankAccount
> 
> .Create a constructor that takes in an integer and assigns this to a 
> `balance` property.
> 
> .Create a method called `deposit` that takes in cash deposit amount and 
> updates the balance accordingly.
> 
> .Create a method called `withdraw` that takes in cash withdrawal amount and 
> updates the balance accordingly. if amount is greater than balance return 
> `"invalid transaction"`
> 
> .Create a subclass MinimumBalanceAccount of the BankAccount class
> 
> Please i need help on this i am a beginer into python programming.
> 
> 
> Also below is a test case given for this project 
> 
> 
> import unittest
> class AccountBalanceTestCases(unittest.TestCase):
>   def setUp(self):
> self.my_account = BankAccount(90)
> 
>   def test_balance(self):
> self.assertEqual(self.my_account.balance, 90, msg='Account Balance 
> Invalid')
> 
>   def test_deposit(self):
> self.my_account.deposit(90)
> self.assertEqual(self.my_account.balance, 180, msg='Deposit method 
> inaccurate')
> 
>   def test_withdraw(self):
> self.my_account.withdraw(40)
> self.assertEqual(self.my_account.balance, 50, msg='Withdraw method 
> inaccurate')
> 
>   def test_invalid_operation(self):
> self.assertEqual(self.my_account.withdraw(1000), "invalid transaction", 
> msg='Invalid transaction')
>   
>   def test_sub_class(self):
> self.assertTrue(issubclass(MinimumBalanceAccount, BankAccount), msg='No 
> true subclass of BankAccount')



I would try.

class BankAccount:
def __init__(self,balance):
self.balance=balance
def deposit(self):
print("Please enter ammount to deposit")
dep=input()
global depbalance
depbalance=int(self.balance)+int(dep)
print("New balance is",depbalance)

def withdraw(self):
print("Please enter ammount to withdraw")
withd=input()
if int(withd) > int(depbalance):
print("Invalid Transaction")
else:
withbalance= depbalance-int(withd)
print("New balance after widthdrawal is",withbalance)

myAccount=BankAccount(0)
myAccount.deposit()
myAccount.withdraw()

class minimumBalanceAccount(BankAccount):
def msg(self):
print("This is a sub class")

mini=minimumBalanceAccount(0)
mini.msg()
mini.deposit()
mini.withdraw()

It may not be as fancy.
Although i dont understand the relevance of the test part in your question


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


[issue24712] Docs page's sidebar vibrates on mouse wheel scroll on Chrome.

2016-01-11 Thread Mike Taylor

Mike Taylor added the comment:

I can reproduce on Chrome and Firefox Nightly --

Carol, if I'd like to write a patch where would I do that? I see 
https://github.com/python/pythondotorg, but am not sure that's the right repo. 
Thanks!

--
nosy: +Mike Taylor

___
Python tracker 

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



Re: Which Python editor has this feature?

2016-01-11 Thread jfong
Terry Reedy at 2016/1/12 UTC+8 5:22:35AM wrote:
> IDLE has an optional 'code context' feature that shows header lines that 
> have scrolled up off the top of the screen.  This would let you see 
> which class you are in,

Thanks, Terry. It's just what I am looking for:-)
By the way, do you know how to open file in a new tab, instead of in a separate 
window, in the IDLE editor?

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


[issue25887] awaiting on coroutine more than once should be an error

2016-01-11 Thread Nick Coghlan

Nick Coghlan added the comment:

Good point about having "await" in the error message to make it more obvious 
what it's referring to in the "awaiting twice" case.

I'll tender "Cannot await previously awaited coroutine" as one final 
alternative, but if you don't like that, I can cope with "Coroutine already 
awaited on" :)

--

___
Python tracker 

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



[issue26087] PEP 0373 should be updated

2016-01-11 Thread Chi Hsuan Yen

New submission from Chi Hsuan Yen:

Current PEP 0373 lists Python 2.7.11 as a future release, and there's no 
information about Python 2.7.12. Please update it, thanks!

--
assignee: docs@python
components: Documentation
messages: 258063
nosy: Chi Hsuan Yen, docs@python
priority: normal
severity: normal
status: open
title: PEP 0373 should be updated
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



[issue25887] awaiting on coroutine more than once should be an error

2016-01-11 Thread Yury Selivanov

Yury Selivanov added the comment:

>"Cannot reuse already awaited coroutine"

Great, I like it!  Thanks Martin and Nick.

Please check out issue #25888 just in case.

--

___
Python tracker 

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



[issue25486] Resurrect inspect.getargspec() in 3.6

2016-01-11 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 36a54e30bcbd by Yury Selivanov in branch '3.5':
Issue #25486: Drop "removed in 3.6" wording from inspect.getargspec docs.
https://hg.python.org/cpython/rev/36a54e30bcbd

New changeset 4f1a0e5deca6 by Yury Selivanov in branch 'default':
Merge 3.5 (issue #25486)
https://hg.python.org/cpython/rev/4f1a0e5deca6

--

___
Python tracker 

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



[issue25887] awaiting on coroutine more than once should be an error

2016-01-11 Thread Martin Panter

Martin Panter added the comment:

If the coroutine-iterator is going to raise RuntimeError rather than 
StopIteration, do you think the __await__() documentation 
 should 
be clarified?

IMO “yield from coroutine_iterator” might be plausable for some strange 
combination of 3.4 code and a 3.5 coroutine, but I think it would be rare. And 
if you added a check in __await__() then the using “await” wouldn’t need to 
rely on next() raising the RuntimeError.

--

___
Python tracker 

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



Re: How to remove item from heap efficiently?

2016-01-11 Thread srinivas devaki
On Jan 10, 2016 12:05 AM, "Paul Rubin"  wrote:
>
> You could look up "timing wheels" for a simpler practical approach that
> the Linux kernel scheduler used to use (I think it changed a few years
> ago).

this is not related to OP's topic

I googled about "timing wheels" and "Linux kernel scheduler", I couldn't
find any learning resources or at least the resources that I can
understand. Could you please point me to some learning resources for a
beginner.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2016-01-11 Thread ifeanyioprah
How do I use hack to move to the next question
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue26085] Tkinter spoils the input text

2016-01-11 Thread fresh_nick

New submission from fresh_nick:

Hello, I have Python 3.4.3 and Tk/Tcl 8.5 (built in Python; reported by 
tk.TclVersion and tk.TkVersion). When I assign printing 'This works' to a 
hotkey, the program prints 'This worsk'. After pressing the hotkey again, 
'worsk' is replaced with 'works', but when the hotkey is pressed repeatedly, we 
can see 'worsk' sometimes (see the attachment).

Have a nice day.

--
components: Tkinter
files: 2016-01-11--1452545267_1920x1080_scrot.png
messages: 258019
nosy: fresh_nick
priority: normal
severity: normal
status: open
title: Tkinter spoils the input text
type: behavior
versions: Python 3.4
Added file: 
http://bugs.python.org/file41585/2016-01-11--1452545267_1920x1080_scrot.png

___
Python tracker 

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



[issue26083] ValueError: insecure string pickle in subprocess.Popen on Python 2

2016-01-11 Thread Ned Deily

Changes by Ned Deily :


--
nosy: +gregory.p.smith

___
Python tracker 

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



Re: Which Python editor has this feature?

2016-01-11 Thread Terry Reedy

On 1/11/2016 6:04 AM, jf...@ms4.hinet.net wrote:


I am studying the PyUSB package now as the learning object of how to
write a Python program in a "formal" way. In those modules, there are
many comment inserted between codes to explain what it does. It's
good to the user comprehension, but also easily makes a Class size
expanded to over 100 lines. Also many Classes has the same named
method such as __getitem__ etc. When searching a specific name I
usually have to roll back the screen a few times to find out what
Class I am looking at. That's really annoy.


IDLE has an optional 'code context' feature that shows header lines that 
have scrolled up off the top of the screen.  This would let you see 
which class you are in,


In current releases, Code Context is configured in the Extensions tab of 
the Settings dialog.  For previous releases after Aug 2014, it was 
configured in the separate Extensions dialog.


The most important setting is the (fixed) number of lines in the context 
box (default 3).  I would like to make the box re-size as needed, so the 
outermost context (like the class statement) is always visible without 
using more screen space than needed.


The context is currently read-only.  Clicking on context lines does 
nothing.  As a result of this thread, I am thinking that clicking on a 
context line should scroll up the main text window to display that line 
at the top (and remove that line and any below from the context box).  I 
*think* that this should be fairly easy.


--
Terry Jan Reedy

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


Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2016-01-11 Thread homiemusa
On Monday, December 28, 2015 at 12:39:41 PM UTC+3, Won Chang wrote:
> def manipulate_data(kind, data): 
> if kind == 'list': 
> return list(data)[::-1] 
> elif kind == 'set':
> return set(data)
> elif kind == 'dictionary': 
> return dict.keys(data) 
> manipulate_data("list", range(1,6)) 
> manipulate_data("set", {"a", "b", "c", "d", "e",}) 
> manipulate_data("dictionary", {"apples": 23, "oranges": 15, "mangoes": 3, 
> "grapes": 45})
> just use a function to add "ANDELA", "TIA", "AFRICA" to the set, the u are don


how con i add a fuction
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python

2016-01-11 Thread Thomas 'PointedEars' Lahn
Sean Melville wrote:

>> On 11 Jan 2016, at 20:33, Cameron Simpson  wrote:
>>> On 11Jan2016 19:17, Sean Melville  wrote:
>>> I've downloaded python 3.5.1 but when I try and open it always says that
>>> I have to either uninstall it, repair it or modify it. However, I've
>>> tried all of them and it still doesn't work.
>> 
>> On what operating system are you trying to install it?
>> 
>> If you are using XP you need to download Python 3.4; Python 3.5 is not
>> compatible with it.
> 
> I don't believe it's xp, it's a new laptop

You can quickly find out by pressing the key combination +.

Please do not top-post.  The bats are reading elsewhere ;-)


-- 
PointedEars

Twitter: @PointedEars2
Please do not cc me. / Bitte keine Kopien per E-Mail.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue25991] readline example eventually consumes all memory

2016-01-11 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 9a2c891a4333 by Ezio Melotti in branch '2.7':
#25991: fix readline example to limit history size.  Patch by Daniel Dye.
https://hg.python.org/cpython/rev/9a2c891a4333

New changeset 416db1a2fb81 by Ezio Melotti in branch '3.5':
#25991: fix readline example to limit history size.  Patch by Daniel Dye.
https://hg.python.org/cpython/rev/416db1a2fb81

New changeset cb08e5271cc0 by Ezio Melotti in branch 'default':
#25991: merge with 3.5.
https://hg.python.org/cpython/rev/cb08e5271cc0

--
nosy: +python-dev

___
Python tracker 

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



[issue25991] readline example eventually consumes all memory

2016-01-11 Thread Ezio Melotti

Ezio Melotti added the comment:

Fixed, thanks for the patch!

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

___
Python tracker 

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



[issue25995] os.walk() consumes a lot of file descriptors

2016-01-11 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Both patches are basically equivalent. The first one collects all scandir() 
results in a list, the second one collects only directory names in a list. The 
purpose of using os.scandir() in os.walk() was a speed up (issue23605), and 
both patches preserve it.

Yes, the number of FDs used is equivalent to the depth of the tree which can be 
very deep (I just created a tree depth of 1000 levels). And what is worse, all 
these FDs can be effectively leaked if the walking was not finished. This is 
unwanted behavior change.

--

___
Python tracker 

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



[issue26086] Bug in standardmodule os

2016-01-11 Thread Hana Larsen

New submission from Hana Larsen:

I get a error in the stardard module "os" (I use Python 3.5.1 64bit for Windows 
10!)
What is wrong and have someone a patch
See the "os-bug.PNG"-file.

--
files: os-bug.PNG
messages: 258023
nosy: Johano
priority: normal
severity: normal
status: open
title: Bug in standardmodule os
type: crash
versions: Python 3.5
Added file: http://bugs.python.org/file41586/os-bug.PNG

___
Python tracker 

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



[issue24918] Docs layout bug

2016-01-11 Thread Ezio Melotti

Ezio Melotti added the comment:

Georg, do you have any opinion on this?
AFAIK all the div.highlight contain a  with the actual code and it's own 
background color, so using background: none; should be fine.

--
nosy: +georg.brandl
stage: needs patch -> patch review

___
Python tracker 

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



Re: python

2016-01-11 Thread Terry Reedy

On 1/11/2016 2:17 PM, Sean Melville wrote:


I've downloaded python 3.5.1 but when I try and open it


You need to be more specific.  (Is 'it' the python installer or python 
program?)


1. What version of Windows, including 32/64 bit.  For pre-10, service 
packs matter (you should have the latest).


2. What installer did you download, from where?  There are, I believe, 6 
choices at python.org.


3. How did you run the installer?  Admin or normal user?  What options 
did you select.  Did the installer say 'finished' or 'error'.


4.  How you you try to run Python (if indeed you did)?  Be very specific 
here, as this may be the problem.


> always says that I

have to either uninstall it, repair it or modify it. However, I've tried
all of them and it still doesn't work.


You see this if you open the installer after installing.  You should not 
see this if you run python itself.  You will not see this if python is 
properly installed and you run python and not the installer.


--
Terry Jan Reedy

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


[issue26041] Update deprecation messages of platform.dist() and platform.linux_distribution()

2016-01-11 Thread Ezio Melotti

Changes by Ezio Melotti :


--
stage: needs patch -> patch review

___
Python tracker 

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



[issue25995] os.walk() consumes a lot of file descriptors

2016-01-11 Thread Guido van Rossum

Guido van Rossum added the comment:

I am all for preventing the leaks. But using FDs proportional to the tree
depth seems reasonable to me. (If you are worried about some kind of DoS
attack on the algorithm by someone who can build a tree with depth 1000,
well, if they can do that they can also create a flat folder with a million
files in it.)

Is there a potential hybrid strategy, where for small directories we close
the FD but for large directories we keep it open?

--

___
Python tracker 

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



[issue25486] Resurrect inspect.getargspec() in 3.6

2016-01-11 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 32c8bdcd66cc by Yury Selivanov in branch 'default':
Issue #25486: Resurrect inspect.getargspec in 3.6. Backout a565aad5d6e1.
https://hg.python.org/cpython/rev/32c8bdcd66cc

--
nosy: +python-dev

___
Python tracker 

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



[issue26083] ValueError: insecure string pickle in subprocess.Popen on Python 2

2016-01-11 Thread Chi Hsuan Yen

New submission from Chi Hsuan Yen:

Originally reported at [1] and [2].

On Mac OS X, read() on pipes may return only the first 512 bytes. The remaining 
bytes are not read into `data` in _execute_child(). There's a patch proposal at 
[3]. I didn't test it myself because I can't reproduce the broken situation.

[1] https://github.com/rg3/youtube-dl/issues/6840
[2] https://github.com/matplotlib/matplotlib/issues/5386
[3] https://github.com/matplotlib/matplotlib/issues/5386#issuecomment-16817

--
components: Library (Lib), Macintosh
messages: 258011
nosy: Chi Hsuan Yen, ned.deily, ronaldoussoren
priority: normal
severity: normal
status: open
title: ValueError: insecure string pickle in subprocess.Popen on Python 2
type: crash
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



  1   2   >