[issue31556] asyncio.wait_for can cancel futures faster with timeout==0

2017-09-22 Thread Viktor Kovtun
Viktor Kovtun added the comment: asyncio.wait_for is coroutine itself, to start executing code, no matter with this PR or not it needs to be awaited/yield from import asyncio @asyncio.coroutine def foo(): print(1) loop = asyncio.get_event_loop() fut = asyncio.wait_for(foo(), 0)

[issue19907] gettext - Non ascii chars in header

2017-09-22 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- status: open -> pending ___ Python tracker ___

Re: How to share class relationship representations?

2017-09-22 Thread Pavol Lisy
On 9/19/17, leam hall wrote: > I'm working on designing the classes, sub-classes, and relationships in my > code. What is a good visual way to represent it so it can be stored in git > and shared on the list without large images or attachments? > > Thanks! > > Leam

[issue31557] tarfile: incorrectly treats regular file as directory

2017-09-22 Thread Joe Tsai
New submission from Joe Tsai: The original V7 header only allocates 100B to store the file path. If a path exceeds this length, then either the PAX format or GNU formats must be used, which can represent arbitrarily long file paths. When doing so, most tar writers just store the first 100B of

[issue31555] Windows pyd slower when not loaded via load_dynamic

2017-09-22 Thread S Safihre
New submission from S Safihre: I have a Python 2.7 C-extension that was made for performance, however, I noticed something strange on Windows: When I run locally python setup.py install and it installs it the "egg" way, the performance of calling the function in the module 500x in a loop is:

[issue1612262] Class Browser doesn't show internal classes

2017-09-22 Thread Terry J. Reedy
Changes by Terry J. Reedy : -- pull_requests: +3686 ___ Python tracker ___ ___

[issue31556] asyncio.wait_for can cancel futures faster with timeout==0

2017-09-22 Thread Yury Selivanov
Yury Selivanov added the comment: I think this is a backwards incompatible change and thus will be rejected. Currently there's a guarantee that "wait_for" can throw a TimeoutError *only* when when you await it. fut = wait_for(something, 0) # some important code try: await

[issue1612262] Class Browser doesn't show internal classes

2017-09-22 Thread Terry J. Reedy
Terry J. Reedy added the comment: I settled on 'transform_children' for the new function. #31461 is the master issue for improving the browsers. -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker

[issue31423] Error while building PDF documentation

2017-09-22 Thread Ned Deily
Ned Deily added the comment: Thanks for looking into this. See also https://github.com/python/psf-salt/issues/118 where the question arose whether the version of Tex Live on docs is new enough. I'm no expert at anything Tex but the odd thing is that I had been able to build dist docs on my

Re: Issues with beginning Django use

2017-09-22 Thread mm0fmf
On 22/09/2017 19:50, Joey Steward wrote: Hello, I've been attempting to begin learning Django but have been having running Django and Python commands on windows. For example, when I run django-admin startproject mytestsite, I get the following error message django-admin : *The term

[issue12301] Use :role:`sys.thing` instead of ``sys.thing`` throughout

2017-09-22 Thread Éric Araujo
Changes by Éric Araujo : -- resolution: -> rejected stage: patch review -> resolved status: pending -> closed ___ Python tracker ___

[issue31556] asyncio.wait_for can cancel futures faster with timeout==0

2017-09-22 Thread Viktor Kovtun
Changes by Viktor Kovtun : -- keywords: +patch pull_requests: +3687 stage: -> patch review ___ Python tracker ___

Re: Assertions

2017-09-22 Thread jladasky
On Thursday, September 21, 2017 at 9:29:19 AM UTC-7, Tobiah wrote: > Are these completely equivalent? > > def foo(thing): > > assert(thing > 0), "Thing must be greater than zero" > > > def foo(thing): > > if not (thing > 0): raise AssertionError("Thing must be greater than >

[issue31556] asyncio.wait_for can cancel futures faster with timeout==0

2017-09-22 Thread Yury Selivanov
Yury Selivanov added the comment: Do you have a use case where this optimization is important? -- ___ Python tracker ___

[issue31556] asyncio.wait_for can cancel futures faster with timeout==0

2017-09-22 Thread Viktor Kovtun
Viktor Kovtun added the comment: If coroutine function has some blocking calls before first await/yield from statement maybe makes sense do no let them be executed, if timeout equals 0 -- ___ Python tracker

[issue1612262] Class Browser doesn't show internal classes

2017-09-22 Thread Terry J. Reedy
Terry J. Reedy added the comment: New changeset fa1cae5832cbcfafedc4b1879c2abc85452f4edd by Terry Jan Reedy in branch '3.6': [3.6] bpo-1612262: IDLE: Class Browser shows nested functions, classes (GH-2573) (#3702)

[issue31556] asyncio.wait_for can cancel futures faster with timeout==0

2017-09-22 Thread Viktor Kovtun
New submission from Viktor Kovtun: There is no need to create extra future and use loop.call_later to cancel base future from asyncio.wait_for when timeout==0. If loop is heavy loaded it can be cancelled simnifically later then 0 seconds later. -- components: asyncio messages: 302770

[issue31556] asyncio.wait_for can cancel futures faster with timeout==0

2017-09-22 Thread Yury Selivanov
Yury Selivanov added the comment: You're right! Let's work on the PR then, I've left a review comment. -- ___ Python tracker ___

[issue31556] asyncio.wait_for can cancel futures faster with timeout==0

2017-09-22 Thread Viktor Kovtun
Viktor Kovtun added the comment: Actually provided example without patch will print 1, which is not expected -- ___ Python tracker ___

[issue1612262] Class Browser doesn't show internal classes

2017-09-22 Thread Terry J. Reedy
Terry J. Reedy added the comment: New changeset 058de11360ea6816a6e978c7be0bcbea99a3f7da by Terry Jan Reedy (Cheryl Sabella) in branch 'master': bpo-1612262: IDLE: Class Browser shows nested functions, classes (#2573)

[issue31534] python 3.6.2 installation failed 0x80070002 error

2017-09-22 Thread Steve Dower
Steve Dower added the comment: If you look in your %TEMP% directory, there should be more log files near the one you attached (most of the filename will be the same). Could you zip them up and attach all of them here? I think there's some information in one of the others that I'll need to

Re: [Tutor] beginning to code

2017-09-22 Thread Bill
Marko Rauhamaa wrote: Bill : I figure that, internally, an address, a pointer, is being passed by value to implement pass by reference. Why do you say "they are right" above? Are you saying it's not pass by reference? Thank you for your examples. I studied them

[issue31092] multiprocessing.Manager() race condition

2017-09-22 Thread Lang
Lang added the comment: # code reproduce bug # KeyError in lib\multiprocessing\managers.py in incref import multiprocessing as mp from time import sleep def func(queue): pass if __name__ == '__main__': manager = mp.Manager() pool = mp.Pool(1) queue = manager.Queue() r =

Re: [Tutor] beginning to code

2017-09-22 Thread Steve D'Aprano
On Fri, 22 Sep 2017 07:53 pm, Bill wrote: > Marko Rauhamaa wrote: >> Bill : >> >>> I figure that, internally, an address, a pointer, is being passed by >>> value to implement pass by reference. Why do you say "they are right" >>> above? Are you saying it's not pass by

Re: Old Man Yells At Cloud

2017-09-22 Thread Paul Rubin
Steve D'Aprano writes: > Having to spend a few hours being paid to migrate code using "print x" > to "print(x)", or even a few months, is not a life-changing experience. Didn't someone further up the thread mention some company that had spent 1.5 years porting a py2

Re: [Tutor] beginning to code

2017-09-22 Thread Marko Rauhamaa
Bill : > I figure that, internally, an address, a pointer, is being passed by > value to implement pass by reference. Why do you say "they are right" > above? Are you saying it's not pass by reference? "Pass by reference" could be "pass by reference to object" (Python,

Re: How to ingore "AttributeError: exception

2017-09-22 Thread Paul Moore
On 22 September 2017 at 10:05, Thomas Jollans wrote: > On 2017-09-22 10:55, Ganesh Pal wrote: >> I have two possible values for Z_block in the block code i.e >> disk_object.data.data.di_data[0] or block.data.data.di_data.data[0][0] >> >> >> def get_block(): >> ''' Get Z block ''

[issue31551] test_distutils fails if current directory contains spaces

2017-09-22 Thread Serhiy Storchaka
New submission from Serhiy Storchaka: Running tests from the directory containing a space: '/home/serhiy/py/cpy thon'. $ ./python -m test -vuall test_distutils == CPython 3.7.0a1+ (heads/master:5e02c7826f, Sep 22 2017, 13:23:33) [GCC 6.3.0 20170406] ==

Re: How to ingore "AttributeError: exception

2017-09-22 Thread Thomas Jollans
On 2017-09-22 10:55, Ganesh Pal wrote: > I have two possible values for Z_block in the block code i.e > disk_object.data.data.di_data[0] or block.data.data.di_data.data[0][0] > > > def get_block(): > ''' Get Z block '' > > if block.data.data.di_data.data[0][0] is not None: >

Re: Assertions

2017-09-22 Thread alister via Python-list
On Fri, 22 Sep 2017 03:44:59 +1000, Steve D'Aprano wrote: > On Fri, 22 Sep 2017 02:29 am, Tobiah wrote: > >> Are these completely equivalent? >> >> def foo(thing): >> >> assert(thing > 0), "Thing must be greater than zero" >> >> >> def foo(thing): >> >> if not (thing > 0):

How to ingore "AttributeError: exception

2017-09-22 Thread Ganesh Pal
I have two possible values for Z_block in the block code i.e disk_object.data.data.di_data[0] or block.data.data.di_data.data[0][0] def get_block(): ''' Get Z block '' if block.data.data.di_data.data[0][0] is not None: Z_block = block.data.data.di_data.data[0][0] else:

[issue31423] Error while building PDF documentation

2017-09-22 Thread linkid
Changes by linkid : -- keywords: +patch pull_requests: +3680 stage: -> patch review ___ Python tracker ___

Re: [Tutor] beginning to code

2017-09-22 Thread bartc
On 22/09/2017 10:23, Marko Rauhamaa wrote: Bill : I figure that, internally, an address, a pointer, is being passed by value to implement pass by reference. Why do you say "they are right" above? Are you saying it's not pass by reference? "Pass by reference" could

Re: [Tutor] beginning to code

2017-09-22 Thread Steve D'Aprano
On Fri, 22 Sep 2017 08:48 pm, bartc wrote: > Can Python be used to write, say, a swap() function that works with any > argument types (not just classes or lists)? Example: > > def swap(,):# made up syntax > a, b = b, a > > x=10 > y="Z" > swap(x,y) >

Re: [Tutor] beginning to code

2017-09-22 Thread Bill
Bill wrote: Stefan Ram wrote: Bill writes: Stefan Ram wrote: bartc writes: On 20/09/2017 02:31, Bill wrote: it's implementation, I would say that C++ has it all over Python from the point of view of "intuitiveness". It's much easier to tell

[issue31423] Error while building PDF documentation

2017-09-22 Thread linkid
Changes by linkid : -- nosy: +linkid ___ Python tracker ___ ___

Re: [Tutor] beginning to code

2017-09-22 Thread Bill
Steve D'Aprano wrote: On Fri, 22 Sep 2017 02:57 pm, Bill wrote: I find Python to be more more like Java, with regard to "passing objects by reference". Which is not a surprise, since both Python and Java use the same value passing style: pass by object reference, or pass by sharing if you

Re: Convert pandas series to string and datetime object

2017-09-22 Thread Pavol Lisy
On 9/21/17, Peter Otten <__pete...@web.de> wrote: > zljubi...@gmail.com wrote: > >> I have sliced the pandas dataframe >> >> end_date = df[-1:]['end'] >> >> type(end_date) >> Out[4]: pandas.core.series.Series >> >> end_date >> Out[3]: >> 48173 2017-09-20 04:47:59 >> Name: end, dtype:

Re: [Tutor] beginning to code

2017-09-22 Thread Bill
Stefan Ram wrote: Bill writes: Stefan Ram wrote: bartc writes: On 20/09/2017 02:31, Bill wrote: it's implementation, I would say that C++ has it all over Python from the point of view of "intuitiveness". It's much easier to tell what's going on,

[issue31478] assertion failure in random.seed() in case the seed argument has a bad __abs__() method

2017-09-22 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: The more I think about this the more I like the idea of using int.__abs__() directly (PyLong_Type.tp_as_number->nb_absolute() in C). The C code doesn't call potentially overridable methods bit_length() and to_bytes(), it uses concrete implementations

Re: [Tutor] beginning to code

2017-09-22 Thread Steve D'Aprano
On Fri, 22 Sep 2017 02:57 pm, Bill wrote: > I find Python to be more more > like Java, with regard to "passing objects by reference". Which is not a surprise, since both Python and Java use the same value passing style: pass by object reference, or pass by sharing if you prefer. Java people

[issue30844] selectors: Add urgent data to read event

2017-09-22 Thread Pim Klanke
Pim Klanke added the comment: In the selectors module, the winsock select method is wrapped. The second parameter (writefds) is passed to both writefds and exceptfds and the returned number of fds for write and except are summed and returned in the second element of the tuple. Can anyone

[issue31459] IDLE: Rename Class Browser as Module Browser

2017-09-22 Thread Cheryl Sabella
Changes by Cheryl Sabella : -- keywords: +patch pull_requests: +3689 stage: test needed -> patch review ___ Python tracker ___

Re: How to share class relationship representations?

2017-09-22 Thread Stephan Houben
Op 2017-09-22, Pavol Lisy schreef : > On 9/19/17, leam hall wrote: >> I'm working on designing the classes, sub-classes, and relationships in my >> code. What is a good visual way to represent it so it can be stored in git >> and shared on the list

Re: Fw: Problems Installing Python36

2017-09-22 Thread Irmen de Jong
On 09/22/2017 08:34 PM, Stephan Houben wrote: > I was vaguely tempted to offer the Mingw-w64 (GCC) Python as an > alternative, since it doesn't rely on any optionally-installed Microsoft > DLLs and so avoids this issue. But I suppose that is not really the > newbie-friendly solution the OP was

[issue31558] gc.freeze() - an API to mark objects as uncollectable

2017-09-22 Thread Łukasz Langa
New submission from Łukasz Langa: When you're forking many worker processes off of a parent process, the resulting children are initially very cheap in memory. They share memory pages with the base process until a write happens [1]_. Sadly, the garbage collector in Python touches every

Re: [Tutor] beginning to code

2017-09-22 Thread Bill
Mark Lawrence wrote: On 22/09/2017 08:01, Bill wrote: Steve D'Aprano wrote: On Fri, 22 Sep 2017 02:57 pm, Bill wrote: I find Python to be more more like Java, with regard to "passing objects by reference". Which is not a surprise, since both Python and Java use the same value passing

Re: [Tutor] beginning to code

2017-09-22 Thread Bill
Bill wrote: Mark Lawrence wrote: On 22/09/2017 08:01, Bill wrote: Steve D'Aprano wrote: On Fri, 22 Sep 2017 02:57 pm, Bill wrote: I find Python to be more more like Java, with regard to "passing objects by reference". Which is not a surprise, since both Python and Java use the same value

[issue31553] Extend json.tool to handle jsonlines (with a flag)

2017-09-22 Thread Raymond Hettinger
Raymond Hettinger added the comment: This seems like a reasonable enhancement. -- nosy: +rhettinger ___ Python tracker ___

Re: Python Boolean Logic

2017-09-22 Thread Steve D'Aprano
On Sat, 23 Sep 2017 03:01 pm, Bill wrote: > s='(20 - 10) > 15' > b=(20 - 10) > 15 > print(s, " is ", ("true" if b else "false") ); ## inside parentheses > may be removed. > > I am new to Python. Maybe someone here is familiar with an elegant way > to get the the value of b directly from the

[issue31423] Error while building PDF documentation

2017-09-22 Thread Ned Deily
Ned Deily added the comment: Good news! It appears that the changes supplied by @linkid have indeed fixed the daily downloadable doc build failures, 3.7, 3.6, and 2.7 docs were built successfully and the 404s are gone. Thanks everyone for helping with this! -- stage: commit review ->

[issue31461] IDLE: Enhance module browser

2017-09-22 Thread Terry J. Reedy
Changes by Terry J. Reedy : -- title: IDLE: Enhance class browser -> IDLE: Enhance module browser ___ Python tracker ___

Re: Python Boolean Logic

2017-09-22 Thread Bill
Cai Gengyang wrote: Hey guys, I'm testing this on CodeAcademy, but I cant get the program to output a result even after pressing the run button. Just wanted to check if my logic is correct. Thanks alot Your answers appear correct, but you could write Python statements to test them (or any you

Re: Python Boolean Logic

2017-09-22 Thread Rick Johnson
On Friday, September 22, 2017 at 11:46:59 PM UTC-5, Cai Gengyang wrote: > Input : > > # Assign True or False as appropriate on the lines below! > > # (20 - 10) > 15 > bool_one = False# We did this one for you! > > # (10 + 17) == 3**16 > # Remember that ** can be read as 'to the power of'.

[issue31558] gc.freeze() - an API to mark objects as uncollectable

2017-09-22 Thread Łukasz Langa
Changes by Łukasz Langa : -- components: +Interpreter Core ___ Python tracker ___ ___

Re: Python Boolean Logic

2017-09-22 Thread Cai Gengyang
Input : # Assign True or False as appropriate on the lines below! # (20 - 10) > 15 bool_one = False# We did this one for you! # (10 + 17) == 3**16 # Remember that ** can be read as 'to the power of'. 3**16 is about 43 million. bool_two = False # 1**2 <= -1 bool_three = False # 40 * 4 >=

Re: Python Boolean Logic

2017-09-22 Thread Bill
Bill wrote: Cai Gengyang wrote: Hey guys, I'm testing this on CodeAcademy, but I cant get the program to output a result even after pressing the run button. Just wanted to check if my logic is correct. Thanks alot Your answers appear correct, but you could write Python statements to test them

[issue31558] gc.freeze() - an API to mark objects as uncollectable

2017-09-22 Thread Roundup Robot
Changes by Roundup Robot : -- keywords: +patch pull_requests: +3690 ___ Python tracker ___

Re: Fw: Problems Installing Python36

2017-09-22 Thread Stephan Houben
Op 2017-09-22, Irmen de Jong schreef : > On 09/22/2017 08:34 PM, Stephan Houben wrote: > >> I was vaguely tempted to offer the Mingw-w64 (GCC) Python as an >> alternative, since it doesn't rely on any optionally-installed Microsoft >> DLLs and so avoids this issue. But I

[issue31478] assertion failure in random.seed() in case the seed argument has a bad __abs__() method

2017-09-22 Thread Raymond Hettinger
Raymond Hettinger added the comment: > I don't see reasons why it should obey overriding the __abs__() method. I concur. -- ___ Python tracker ___

[issue31553] Extend json.tool to handle jsonlines (with a flag)

2017-09-22 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Jsonlines is an external to JSON format. You should split the data on lines and pass every line to the JSON parser separately. The same you should do with json.tool. $ echo -e '{"ingredients":["frog", "water", "chocolate",

[issue31425] Expose AF_QIPCRTR in socket module

2017-09-22 Thread Roundup Robot
Changes by Roundup Robot : -- keywords: +patch pull_requests: +3691 stage: -> patch review ___ Python tracker ___

Python Boolean Logic

2017-09-22 Thread Cai Gengyang
Hey guys, I'm testing this on CodeAcademy, but I cant get the program to output a result even after pressing the run button. Just wanted to check if my logic is correct. Thanks alot # Assign True or False as appropriate on the lines below! # (20 - 10) > 15 bool_one = False# We did this one

Re: Python Boolean Logic

2017-09-22 Thread steve . ferg . bitbucket
You have a lot of assignment statements, but nothing that produces output. Try adding statements like this at appropriate places... print ("bool_one = ", bool_one) -- https://mail.python.org/mailman/listinfo/python-list

[issue31452] asyncio.gather does not cancel tasks if one fails

2017-09-22 Thread Andrew Lytvyn
Andrew Lytvyn added the comment: Guido, look. The point is that if you change run_forever with run_until_complete, then behavior changes: success_coro(5) will not be executed. I think that it's strange that behavior differs depending on entrypoint: run_forever or run_untill_complete

Re: [Tutor] beginning to code

2017-09-22 Thread Mark Lawrence via Python-list
On 22/09/2017 08:01, Bill wrote: Steve D'Aprano wrote: On Fri, 22 Sep 2017 02:57 pm, Bill wrote: I find Python to be more more like Java, with regard to "passing objects by reference". Which is not a surprise, since both Python and Java use the same value passing style: pass by object

Re: xml: TypeError: write() got an unexpected keyword argument 'short_empty_elements'

2017-09-22 Thread Thomas Jollans
On 2017-09-22 14:29, Nagy László Zsolt wrote: > >> Result: >> >> Traceback (most recent call last): >>   File "C:/not_telling/c14n.py", line 16, in >>     short_empty_elements=False >>   File "lxml.etree.pyx", line 1869, in lxml.etree._ElementTree.write >> (src\lxml\lxml.etree.c:57004) >>

what is happening in panda "where" clause

2017-09-22 Thread Exposito, Pedro (RIS-MDW)
This code does a "where" clause on a panda data frame... Code: import pandas as pd; col_names = ['Name', 'Age', 'Weight', "Education"]; # create panda dataframe x = pd.read_csv('test.dat', sep='|', header=None, names = col_names); # apply "where" condition z = x[ (x['Age'] == 55)

Re: xml: TypeError: write() got an unexpected keyword argument 'short_empty_elements'

2017-09-22 Thread Nagy László Zsolt
> https://docs.python.org/3/library/xml.etree.elementtree.html#xml.etree.ElementTree.ElementTree.write > > The argument was added in Python 3.4. Presumably, lxml implemented the > API before this change. > > Maybe this would be considered a bug by lxml. Maybe it won't. Maybe it is not a bug, just

Re: [Tutor] beginning to code

2017-09-22 Thread Steve D'Aprano
On Fri, 22 Sep 2017 10:27 pm, Marko Rauhamaa wrote: > r...@zedat.fu-berlin.de (Stefan Ram): > >> Marko Rauhamaa writes: >>>swap(slot_ref(locals(), "x"), slot_ref(locals(), "y")) >> >> You need to be able to write the call as >> >> swap( x, y ) > > Why? Because that's the

Re: [Tutor] beginning to code

2017-09-22 Thread Marko Rauhamaa
bartc : > On 22/09/2017 10:23, Marko Rauhamaa wrote: >> However, Python doesn't need any language changes to implement memory >> slots. A memory slot could be defined as any object that implements >> "get()" and "set(value)" methods: > > I didn't understand your examples. > > Can

Re: [Tutor] beginning to code

2017-09-22 Thread Steve D'Aprano
On Fri, 22 Sep 2017 05:01 pm, Bill wrote: > Steve D'Aprano wrote: >> On Fri, 22 Sep 2017 02:57 pm, Bill wrote: >> >>> I find Python to be more more >>> like Java, with regard to "passing objects by reference". >> Which is not a surprise, since both Python and Java use the same value >> passing

Re: [Tutor] beginning to code

2017-09-22 Thread bartc
On 22/09/2017 12:47, Chris Angelico wrote: On Fri, Sep 22, 2017 at 9:24 PM, Marko Rauhamaa wrote: Yes, following my recipe: def swap(ref_a, ref_b): a, b = ref_a.get(), ref_b.get() ref_a.set(b) ref_b.set(a) x = 10 y = "Z"

Re: Assertions

2017-09-22 Thread alister via Python-list
On Fri, 22 Sep 2017 21:15:54 +1000, Steve D'Aprano wrote: > On Fri, 22 Sep 2017 08:50 pm, alister wrote: > >>> The bottom line is, if I saw >>> >>> if not (thing > 0): raise AssertionError(...) >>> >>> in a code review, I'd probably insist that either it be changed to use >>> `assert`, >>> or

Re: [Tutor] beginning to code

2017-09-22 Thread Mark Lawrence via Python-list
On 22/09/2017 10:53, Bill wrote: I just wanted to mention that my comment was made in the context that Python is implemented by an interpreter written in C.   I realize that this may not always be the case.  However, I haven't heard anyone mention a Python interpreter written in Python yet.

Re: [Tutor] beginning to code

2017-09-22 Thread Marko Rauhamaa
r...@zedat.fu-berlin.de (Stefan Ram): > Marko Rauhamaa writes: >>swap(slot_ref(locals(), "x"), slot_ref(locals(), "y")) > > You need to be able to write the call as > > swap( x, y ) Why? Marko -- https://mail.python.org/mailman/listinfo/python-list

Re: Assertions

2017-09-22 Thread Thomas Jollans
On 2017-09-22 14:03, alister via Python-list wrote: > On Fri, 22 Sep 2017 21:15:54 +1000, Steve D'Aprano wrote: >> On Fri, 22 Sep 2017 08:50 pm, alister wrote: >>> [snip] >>> >>> In a code review I would want the condition changed to be less noisy/ >>> confusing to the reader. >>> >>> if thing

Re: [Tutor] beginning to code

2017-09-22 Thread Steve D'Aprano
On Fri, 22 Sep 2017 09:24 pm, Marko Rauhamaa wrote: > bartc : > >> On 22/09/2017 10:23, Marko Rauhamaa wrote: >>> However, Python doesn't need any language changes to implement memory >>> slots. A memory slot could be defined as any object that implements >>> "get()" and

Re: How to ingore "AttributeError: exception

2017-09-22 Thread Ganesh Pal
> > > is a perfectly good pattern to use. > Thanks looks nice :) > > > > > > > > I am a Linux user on Python 2.7 > > Have you considered moving to Python 3? > Not yet , but Is there something that I need to consider in the current context? Regards, Ganesh --

[issue31351] ensurepip discards pip's return code which leads to broken venvs

2017-09-22 Thread Mariatta Wijaya
Mariatta Wijaya added the comment: New changeset eef49f5dd021d15396551880cf451042a79a1107 by Mariatta (Miss Islington (bot)) in branch '3.6': bpo-31351: Set return code in ensurepip when pip fails (GH-3626) (GH-3683)

Re: Assertions

2017-09-22 Thread Steve D'Aprano
On Fri, 22 Sep 2017 08:50 pm, alister wrote: >> The bottom line is, if I saw >> >> if not (thing > 0): raise AssertionError(...) >> >> in a code review, I'd probably insist that either it be changed to use >> `assert`, >> or the exception be changed to ValueError, whichever better expresses >>

[issue31149] Add Japanese to the language switcher

2017-09-22 Thread Julien Palard
Changes by Julien Palard : -- status: open -> closed ___ Python tracker ___ ___

Re: xml: TypeError: write() got an unexpected keyword argument 'short_empty_elements'

2017-09-22 Thread Nagy László Zsolt
> Result: > > Traceback (most recent call last): >   File "C:/not_telling/c14n.py", line 16, in >     short_empty_elements=False >   File "lxml.etree.pyx", line 1869, in lxml.etree._ElementTree.write > (src\lxml\lxml.etree.c:57004) > TypeError: write() got an unexpected keyword argument

Re: [Tutor] beginning to code

2017-09-22 Thread bartc
On 22/09/2017 13:34, Steve D'Aprano wrote: On Fri, 22 Sep 2017 09:24 pm, Marko Rauhamaa wrote: Yes, following my recipe: def swap(ref_a, ref_b): a, b = ref_a.get(), ref_b.get() ref_a.set(b) ref_b.set(a) x = 10 y = "Z" swap(slot_ref(locals(), "x"),

Re: [Tutor] beginning to code

2017-09-22 Thread Marko Rauhamaa
Chris Angelico : > Sure, let me just put that into a function. CPython 3.7, although I'm > pretty sure most CPython versions will do the same, as will several of > the other Pythons. > [demonstration that it didn't work] Ok. The reason is this: Note: The contents of this

Re: [Tutor] beginning to code

2017-09-22 Thread Marko Rauhamaa
r...@zedat.fu-berlin.de (Stefan Ram): > Marko Rauhamaa writes: >>r...@zedat.fu-berlin.de (Stefan Ram): >>>Marko Rauhamaa writes: swap(slot_ref(locals(), "x"), slot_ref(locals(), "y")) >>>You need to be able to write the call as >>>swap( x, y ) >>Why? > >

Re: Assertions

2017-09-22 Thread Steve D'Aprano
On Fri, 22 Sep 2017 10:03 pm, alister wrote: > On Fri, 22 Sep 2017 21:15:54 +1000, Steve D'Aprano wrote: > >> On Fri, 22 Sep 2017 08:50 pm, alister wrote: >> The bottom line is, if I saw if not (thing > 0): raise AssertionError(...) in a code review, I'd probably

Re: Assertions

2017-09-22 Thread Thomas Jollans
On 2017-09-22 14:43, Steve D'Aprano wrote: > In the case of floating point NANs, they are unordered with respect to all > numbers. So for any number x, we always have: > > NAN == x > NAN < x > NAN > x > NAN <= x > NAN >= x > > all return False, and > > NAN != x > > return True. Just to make

Re: [Tutor] beginning to code

2017-09-22 Thread Chris Angelico
On Fri, Sep 22, 2017 at 9:24 PM, Marko Rauhamaa wrote: > bartc : > >> On 22/09/2017 10:23, Marko Rauhamaa wrote: >>> However, Python doesn't need any language changes to implement memory >>> slots. A memory slot could be defined as any object that implements >>>

xml: TypeError: write() got an unexpected keyword argument 'short_empty_elements'

2017-09-22 Thread Nagy László Zsolt
Here is an MWE: import io from lxml import etree test_node = etree.fromstring(''' http://schemas.xmlsoap.org/soap/envelope/; xmlns:ns1="http://docs.oasis-open.org/ws-sx/ws-trust/200512;>     ''') output = io.BytesIO(b'') test_node.getroottree().write(output,

[issue31550] Inconsistent error message for TypeError with subscripting

2017-09-22 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I'm not sure that this is an enhancement. It makes an error message inconsistent with other error messages. >>> class I(int): pass ... >>> I()[0] Traceback (most recent call last): File "", line 1, in TypeError: 'I' object does not support indexing >>>

Re: what is happening in panda "where" clause

2017-09-22 Thread Peter Otten
Exposito, Pedro (RIS-MDW) wrote: > This code does a "where" clause on a panda data frame... > > Code: > import pandas as pd; > col_names = ['Name', 'Age', 'Weight', "Education"]; > # create panda dataframe > x = pd.read_csv('test.dat', sep='|', header=None, names = col_names); >

[issue31351] ensurepip discards pip's return code which leads to broken venvs

2017-09-22 Thread Mariatta Wijaya
Mariatta Wijaya added the comment: This has been backported to 3.6. Is backport to 2.7 needed? -- ___ Python tracker ___

[issue31552] IDLE: Convert browswers to use ttk.Treeview

2017-09-22 Thread Terry J. Reedy
Terry J. Reedy added the comment: >From #31461: Browsers currently use idlelib.tree.TreeWidget. Treeview is not >a drop-in replacement because TreeWidget has some of the higher-level >app-specific functions that users are expected to add to Treeview. But could >Treeview replace the

search and replace first amount of strings instances with one thing and a second amount of instances with another thing-

2017-09-22 Thread validationmail1
i have a code in python to search and replace what i need though is to replace the first say 10 instances of the number 1 with 2 and the second 10 instances with the number 3. anybody knows how to do that? fin = open(r'F:\1\xxx.txt') fout = open(r'F:\1\xxx2.txt', "wt") for line in fin:

Re: [Tutor] beginning to code

2017-09-22 Thread Chris Angelico
On Fri, Sep 22, 2017 at 10:26 PM, Marko Rauhamaa wrote: > Chris Angelico : >> (Side point: Your slot_ref function is rather bizarre. It's a closure >> AND a class, just in case one of them isn't sufficient. > > I don't see anything bizarre in it at all. I use

[issue31443] Possibly out of date C extension documentation

2017-09-22 Thread Christoph Reiter
Christoph Reiter added the comment: Building the following with gcc from msys2 (cygwin) worked fine here: https://bpaste.net/show/0cafd5fa8211 -- nosy: +lazka ___ Python tracker

Re: Convert pandas series to string and datetime object

2017-09-22 Thread Peter Otten
Pavol Lisy wrote: > pandas is one of reasons why python is so popular these days. But > "there is only milion way how to do it" (and other unpythonic issues) > I see there every time I am looking at it. :) Yeah, such a useful tool with such a byzantine API, completely at odds with the zen -- I

[issue31461] IDLE: Enhance class browser

2017-09-22 Thread Terry J. Reedy
Terry J. Reedy added the comment: #31552 ttk.Treeview -- dependencies: +IDLE: Convert browswers to use ttk.Treeview ___ Python tracker ___

Re: [Tutor] beginning to code

2017-09-22 Thread Marko Rauhamaa
Chris Angelico : > On Fri, Sep 22, 2017 at 10:26 PM, Marko Rauhamaa wrote: >> Chris Angelico : >>> (Side point: Your slot_ref function is rather bizarre. It's a closure >>> AND a class, just in case one of them isn't sufficient. >> >> I don't

  1   2   >