Re: How much sanity checking is required for function inputs?

2016-04-21 Thread Stephen Hansen
On Thu, Apr 21, 2016, at 08:33 PM, Christopher Reimer wrote: > On 4/21/2016 7:20 PM, Stephen Hansen wrote: > > I... that... what... I'd forget that link and pretend you never went > > there. Its not helpful. > > I found it on the Internet, so it must be true -- and Pythonic at that! My advice is

Re: Error 0*80070570

2016-04-21 Thread eryk sun
On Thu, Apr 21, 2016 at 11:15 PM, Allan Leo wrote: > On Apr 21, 2016 9:51 PM, "eryk sun" wrote: >> On Thu, Apr 21, 2016 at 4:06 AM, Allan Leo wrote: >> > When running the setup for your 3.5.1(32-bit version), the setup >> > experiences error 0*80070570 and tells me to check the log file. What >

Re: How much sanity checking is required for function inputs?

2016-04-21 Thread Ethan Furman
On 04/21/2016 08:33 PM, Christopher Reimer wrote: On 4/21/2016 7:20 PM, Stephen Hansen wrote: Keep in mind that I'm coming from a Java background (not by choice) with a smattering of C programming. A refugee! Water! Food! import this!! :) Oh! and Enum!!! ;) -- ~Ethan~ -- https://mai

Re: How much sanity checking is required for function inputs?

2016-04-21 Thread Christopher Reimer
On 4/21/2016 7:20 PM, Stephen Hansen wrote: Whyyy are you using getattr? Something wrong with PieceFactory.factory(color, piece, position)? (Or, better yet, yield piece_factory(color, piece, position) where piece_factory is just a function) Because the example I found used it, I implemented i

Re: How much sanity checking is required for function inputs?

2016-04-21 Thread Christopher Reimer
On 4/21/2016 7:10 PM, Ethan Furman wrote: I do plan to incorporate a sanity test in each Piece class to validate the initial position value. Pawns have 16 specific positions. Bishop, Knight and Rook each have four specific positions. King and Queen each have two specific positions. An invalid val

Re: How much sanity checking is required for function inputs?

2016-04-21 Thread Christopher Reimer
On 4/21/2016 6:54 PM, Tim Chase wrote: I'd simplify this code to something like class PieceFactory(object): @staticmethod def factory(color, piece, position): try: return { 'Bishop': Bishop, 'King': King, 'Knight': Knight,

Re: How much sanity checking is required for function inputs?

2016-04-21 Thread Steven D'Aprano
On Fri, 22 Apr 2016 11:34 am, Christopher Reimer wrote: > Greetings, > > Thanks to everyone for providing feedback. Here's my revised code to > generate a set of chess pieces. > class PieceFactory(object): > > def factory(color, piece, position): > if piece == 'Bishop': >

Re: How much sanity checking is required for function inputs?

2016-04-21 Thread Tim Chase
On 2016-04-21 18:34, Christopher Reimer wrote: > class PieceFactory(object): > > def factory(color, piece, position): > if piece == 'Bishop': > return Bishop(color, position) > if piece == 'King': > return King(color, position) >

Re: How much sanity checking is required for function inputs?

2016-04-21 Thread Stephen Hansen
On Thu, Apr 21, 2016, at 06:34 PM, Christopher Reimer wrote: > class PieceFactory(object): > > def factory(color, piece, position): > if piece == 'Bishop': > return Bishop(color, position) > if piece == 'King': > return King(colo

Re: How much sanity checking is required for function inputs?

2016-04-21 Thread Ethan Furman
On 04/21/2016 06:34 PM, Christopher Reimer wrote: class PieceFactory(object): > [...] Better. I do plan to incorporate a sanity test in each Piece class to validate the initial position value. Pawns have 16 specific positions. Bishop, Knight and Rook each have four specific positions. King a

Re: A pickle problem!

2016-04-21 Thread Paulo da Silva
Às 22:43 de 21-04-2016, Paulo da Silva escreveu: > Hi. > > Why in this code fragment self.__name is not kept between pickle > dumps/loads? How to fix it? > > Thanks. > > import pickle > import pandas as pd > import numpy as np > > class C(pd.DataFrame): > def __init__(self,name,*a,**b): >

Re: How much sanity checking is required for function inputs?

2016-04-21 Thread Christopher Reimer
Greetings, Thanks to everyone for providing feedback. Here's my revised code to generate a set of chess pieces. class PieceFactory(object): def factory(color, piece, position): if piece == 'Bishop': return Bishop(color, position) if piece == 'K

A pickle problem!

2016-04-21 Thread Paulo da Silva
Hi. Why in this code fragment self.__name is not kept between pickle dumps/loads? How to fix it? Thanks. import pickle import pandas as pd import numpy as np class C(pd.DataFrame): def __init__(self,name,*a,**b): super(C,self).__init__(*a,**b) self.__name

Re: Error 0*80070570

2016-04-21 Thread eryk sun
On Thu, Apr 21, 2016 at 4:06 AM, Allan Leo wrote: > When running the setup for your 3.5.1(32-bit version), the setup > experiences error 0*80070570 and tells me to check the log file. What could > be the problem and whats the solution. ERROR_FILE_CORRUPT (0x0570) seems to occur frequently with t

Re: Re: Error 0*80070570

2016-04-21 Thread sohcahtoa82
On Thursday, April 21, 2016 at 10:47:04 AM UTC-7, Allan Leo wrote: > I need help with this setup error. > -- Forwarded message -- > From: "Allan Leo" > Date: Apr 21, 2016 10:06 AM > Subject: Re: Error 0*80070570 > To: > Cc: > > When running the setup for your 3.5.1(32-bit versio

Re: Different names for Unicode codepoint

2016-04-21 Thread Eli Zaretskii
> From: Lele Gaifax > Date: Thu, 21 Apr 2016 21:04:32 +0200 > Cc: python-list@python.org > > is there a particular reason for the slightly different names that Emacs > (version 25.0.92) and Python (version 3.6.0a0) give to a single Unicode > entity? They don't. > Just to mention one codepoint,

python regex dna processing

2016-04-21 Thread Joel Goldstick
>From time to time there are DNA related question posted here. I came upon this in the hopes it may be useful to those who do that kind of software http://benchling.engineering/dna-regex-search/ -- Joel Goldstick http://joelgoldstick.com/blog http://cc-baseballstats.info/stats/birthdays -- htt

Re: Fwd: Re: Error 0*80070570

2016-04-21 Thread Stephen Hansen
On Thu, Apr 21, 2016, at 10:46 AM, Allan Leo wrote: > I need help with this setup error. > -- Forwarded message -- > From: "Allan Leo" > Date: Apr 21, 2016 10:06 AM > Subject: Re: Error 0*80070570 > To: > Cc: > > When running the setup for your 3.5.1(32-bit version), the setup >

Re: How are you supposed to define subclasses in C?

2016-04-21 Thread Stefan Behnel
Random832 schrieb am 21.04.2016 um 18:35: > I was trying to write a proof of concept on including descriptors (e.g. > a "sys.recursionlimit" instead of set/get methods) in the sys module, > and couldn't figure out how to "properly" define a type using > PyType_FromSpecWithBases. Everything I tried

Fwd: Re: Error 0*80070570

2016-04-21 Thread Allan Leo
I need help with this setup error. -- Forwarded message -- From: "Allan Leo" Date: Apr 21, 2016 10:06 AM Subject: Re: Error 0*80070570 To: Cc: When running the setup for your 3.5.1(32-bit version), the setup experiences error 0*80070570 and tells me to check the log file. What c

Re: How are you supposed to define subclasses in C?

2016-04-21 Thread Zachary Ware
On Thu, Apr 21, 2016 at 11:35 AM, Random832 wrote: > I was trying to write a proof of concept on including descriptors (e.g. > a "sys.recursionlimit" instead of set/get methods) in the sys module, > and couldn't figure out how to "properly" define a type using > PyType_FromSpecWithBases. Everythin

How are you supposed to define subclasses in C?

2016-04-21 Thread Random832
I was trying to write a proof of concept on including descriptors (e.g. a "sys.recursionlimit" instead of set/get methods) in the sys module, and couldn't figure out how to "properly" define a type using PyType_FromSpecWithBases. Everything I tried just segfaulted. I ended up just calling PyObject_

Re: PEP proposal: sequence expansion support for yield statement: yield *

2016-04-21 Thread Chris Angelico
On Fri, Apr 22, 2016 at 1:19 AM, justin walters wrote: > I agree with the others that the new syntax is not needed. > > I would also like to point out that I believe any new added syntax or > functionality should avoid the use of '*' and '**' as both of these > characters are already used for many

Re: Error 0*80070570

2016-04-21 Thread justin walters
On Thu, Apr 21, 2016 at 2:06 AM, Allan Leo wrote: > When running the setup for your 3.5.1(32-bit version), the setup > experiences error 0*80070570 and tells me to check the log file. What could > be the problem and whats the solution. > On Apr 21, 2016 7:05 AM, "Allan Leo" wrote: > > > When ru

Re: PEP proposal: sequence expansion support for yield statement: yield *

2016-04-21 Thread justin walters
I agree with the others that the new syntax is not needed. I would also like to point out that I believe any new added syntax or functionality should avoid the use of '*' and '**' as both of these characters are already used for many things such as optional arguments and mathematical operators. Ad

Re: Detecting repeated subsequences of identical items

2016-04-21 Thread Chris Angelico
On Fri, Apr 22, 2016 at 12:30 AM, Oscar Benjamin wrote: > On 21 April 2016 at 15:12, Chris Angelico wrote: >> On Fri, Apr 22, 2016 at 12:01 AM, Oscar Benjamin >> wrote: >>> In the recursive stack overflow case what you'll usually have is >>> >>> 1) A few frames leading up to the start of recursi

Re: Detecting repeated subsequences of identical items

2016-04-21 Thread Oscar Benjamin
On 21 April 2016 at 15:12, Chris Angelico wrote: > On Fri, Apr 22, 2016 at 12:01 AM, Oscar Benjamin > wrote: >> In the recursive stack overflow case what you'll usually have is >> >> 1) A few frames leading up to the start of recursion >> 2) A long repetitive sequence of frames >> 3) A few frames

Re: Detecting repeated subsequences of identical items

2016-04-21 Thread Chris Angelico
On Fri, Apr 22, 2016 at 12:01 AM, Oscar Benjamin wrote: > In the recursive stack overflow case what you'll usually have is > > 1) A few frames leading up to the start of recursion > 2) A long repetitive sequence of frames > 3) A few frames at the end showing how the exception was ultimately trigge

Re: Detecting repeated subsequences of identical items

2016-04-21 Thread Oscar Benjamin
On 21 April 2016 at 13:15, Steven D'Aprano wrote: > On Thu, 21 Apr 2016 06:53 pm, Oscar Benjamin wrote: > >> On 21 April 2016 at 04:07, Steven D'Aprano wrote: >>> I want to group repeated items in a sequence. For example, I can group >>> repeated sequences of a single item at a time using groupby

Re: delete from pattern to pattern if it contains match

2016-04-21 Thread Jussi Piitulainen
harirammano...@gmail.com writes: > On Monday, April 18, 2016 at 12:38:03 PM UTC+5:30, > hariram...@gmail.com wrote: >> HI All, >> >> can you help me out in doing below. >> >> file: >> >> guava >> fruit >> >> >> mango >> fruit >> >> >> orange >> fruit >> >> >> need to dele

Re: Detecting repeated subsequences of identical items

2016-04-21 Thread Steven D'Aprano
On Thu, 21 Apr 2016 06:53 pm, Oscar Benjamin wrote: > On 21 April 2016 at 04:07, Steven D'Aprano wrote: >> I want to group repeated items in a sequence. For example, I can group >> repeated sequences of a single item at a time using groupby: >> >> >> from itertools import groupby >> for key, grou

Re: Detecting repeated subsequences of identical items

2016-04-21 Thread Nobody
On Thu, 21 Apr 2016 18:05:40 +1000, Steven D'Aprano wrote: > The specific problem I am trying to solve is that I have a sequence of > strings (in this case, error messages from a Python traceback) and I'm > looking for repeated groups that may indicate mutually recursive calls. E.g. > suppose I

Re: Detecting repeated subsequences of identical items

2016-04-21 Thread Serhiy Storchaka
On 21.04.16 06:07, Steven D'Aprano wrote: Now I want to group subsequences. For example, I have: "ABCABCABCDEABCDEFABCABCABCB" and I want to group it into repeating subsequences. [...] How can I do this? Does this problem have a standard name and/or solution? This is a part of lossless da

Re: delete from pattern to pattern if it contains match

2016-04-21 Thread Peter Otten
harirammano...@gmail.com wrote: > On Monday, April 18, 2016 at 12:38:03 PM UTC+5:30, hariram...@gmail.com > wrote: >> HI All, >> >> can you help me out in doing below. >> >> file: >> >> guava >> fruit >> >> >> mango >> fruit >> >> >> orange >> fruit >> Is that literally what you have i

Re: delete from pattern to pattern if it contains match

2016-04-21 Thread harirammanohar
On Monday, April 18, 2016 at 12:38:03 PM UTC+5:30, hariram...@gmail.com wrote: > HI All, > > can you help me out in doing below. > > file: > > guava > fruit > > > mango > fruit > > > orange > fruit > > > need to delete from start to end if it contains mango in a file... >

Re: Error 0*80070570

2016-04-21 Thread Allan Leo
When running the setup for your 3.5.1(32-bit version), the setup experiences error 0*80070570 and tells me to check the log file. What could be the problem and whats the solution. On Apr 21, 2016 7:05 AM, "Allan Leo" wrote: > When running the setup for your 3.5.1(32-bit version) the setup > expe

Re: Detecting repeated subsequences of identical items

2016-04-21 Thread Oscar Benjamin
On 21 April 2016 at 04:07, Steven D'Aprano wrote: > I want to group repeated items in a sequence. For example, I can group > repeated sequences of a single item at a time using groupby: > > > from itertools import groupby > for key, group in groupby("BBCDDEEE"): > group = list(group) >

Re: Detecting repeated subsequences of identical items

2016-04-21 Thread Steven D'Aprano
On Thursday 21 April 2016 16:35, Michael Selik wrote: > On Wed, Apr 20, 2016 at 11:11 PM Steven D'Aprano > wrote: > >> I want to group [repeated] subsequences. For example, I have: >> "ABCABCABCDEABCDEFABCABCABCB" >> and I want to group it into repeating subsequences. I can see two >> ways... Ho

Re: Detecting repeated subsequences of identical items

2016-04-21 Thread Alain Ketterlin
Steven D'Aprano writes: > I want to group repeated items in a sequence. For example, I can group > repeated sequences of a single item at a time using groupby: [...] > Now I want to group subsequences. For example, I have: > > "ABCABCABCDEABCDEFABCABCABCB" > > and I want to group it into repeatin

Re: Detecting repeated subsequences of identical items

2016-04-21 Thread Michael Selik
On Thu, Apr 21, 2016 at 2:55 AM Vlastimil Brom wrote: > 2016-04-21 5:07 GMT+02:00 Steven D'Aprano : > > I want to group subsequences. > > "ABCABCABCDEABCDEFABCABCABCB" > > ABC ABC ABCDE ABCDE F ABC ABC ABC B > > or: > > ABC ABC ABC D E A B C D E F ABC ABC ABC B > > if I am not missing something,