Re: delete from pattern to pattern if it contains match

2016-04-24 Thread harirammanohar
On Friday, April 22, 2016 at 4:41:08 PM UTC+5:30, Jussi Piitulainen wrote: > Peter Otten writes: > > > harirammano...@gmail.com wrote: > > > >> On Thursday, April 21, 2016 at 7:03:00 PM UTC+5:30, Jussi Piitulainen > >> wrote: > >>> harirammano...@gmail.com writes: > >>> > >>> > On Monday, April 1

Re: delete from pattern to pattern if it contains match

2016-04-24 Thread harirammanohar
On Friday, April 22, 2016 at 3:20:53 PM UTC+5:30, Peter Otten wrote: > harirammano...@gmail.com wrote: > > >> @peter yes here it is not xml, but real data is an xml..believe me.. > > > > @peter this is the similar xml i am having, you can correlate. > > > > https://tomcat.apache.org/tomcat-5.5-d

Re: asyncio and subprocesses

2016-04-24 Thread Terry Reedy
On 4/24/2016 6:07 PM, David wrote: Is this a bug in the asyncio libraries? Is this a fixed bug, already? I am using Python 3.4.2 as distributed in Ubuntu Lucid, with built-in asyncio. The people who patch asyncio do not read this list. Either install a current release or try the tulip rele

Re: Optimizing Memory Allocation in a Simple, but Long Function

2016-04-24 Thread Derek Klinge
So I tried the recommended limit approach and got some interesting results. ## Write a method to approximate Euler's Number using Euler's Method import math class EulersNumber(): def __init__(self,n): self.n = n self.e = 2 def linearApproximation(self,x,h,d): # f(x+h)=f(x)+h*f'(x) return x + h *

Re: Optimizing Memory Allocation in a Simple, but Long Function

2016-04-24 Thread Derek Klinge
Actually, I'm not trying to speed it up, just be able to handle a large number of n. (Thank you Chris for the suggestion to use xrange, I am on a Mac using the stock Python 2.7) I am looking at the number of iterations of linear approximation that are required to get a more accurate representation

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

2016-04-24 Thread Michael Selik
On Sun, Apr 24, 2016 at 2:08 PM Steven D'Aprano wrote: > On Sun, 24 Apr 2016 04:40 pm, Michael Selik wrote: > > I think we're giving mixed messages because we're conflating > "constants" and globals that are expected to change. > > When you talk about "state", that usually means "the current stat

Re: Scraping email to make invoice

2016-04-24 Thread Michael Torrie
On 04/24/2016 12:58 PM, CM wrote: > 1. INPUT: What's the best way to scrape an email like this? The > email is to a Gmail account, and the content shows up in the email as > a series of basically 6x7 tables (HTML?), one table per PO > number/task. I know if the freelancer were to copy and paste the

Re: Python TUI that will work on DOS/Windows and Unix/Linux

2016-04-24 Thread Peter Brittain
I noticed this trail on Google... if you're still interested, you could try out https://github.com/peterbrittain/asciimatics I ported it to Windows from Linux so exactly the same API works on both. -- https://mail.python.org/mailman/listinfo/python-list

Re: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 54:

2016-04-24 Thread Peter Otten
arthur sherman wrote: > m using a python web applic (adagios, a nagios configuration tool). > when attempting a certain operation on the client side browser i get the > above error. the client side is ubunti 14.04. servers side is debian 8. > browser is ff or chrome. both show: > echo $LANG > en_U

asyncio and subprocesses

2016-04-24 Thread David
Is this a bug in the asyncio libraries? This code: ''' proc = yield from asyncio.create_subprocess_exec(*cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env) # read all data from subprocess pipe, copy to nextCoro ln = yield from proc.stdout.read(1024) while ln:

Re: Optimizing Memory Allocation in a Simple, but Long Function

2016-04-24 Thread Oscar Benjamin
On 24 April 2016 at 19:21, Chris Angelico wrote: > On Mon, Apr 25, 2016 at 4:03 AM, Derek Klinge wrote: >> Ok, from the gmail web client: > > Bouncing this back to the list, and removing quote markers for other > people's copy/paste convenience. > > ## Write a method to approximate Euler's Number

Re: Scraping email to make invoice

2016-04-24 Thread Friedrich Rentsch
On 04/24/2016 08:58 PM, CM wrote: I would like to write a Pythons script to automate a tedious process and could use some advice. The source content will be an email that has 5-10 PO (purchase order) numbers and information for freelance work done. The target content will be an invoice. (Th

UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 54:

2016-04-24 Thread arthur sherman
m using a python web applic (adagios, a nagios configuration tool). when attempting a certain operation on the client side browser i get the above error. the client side is ubunti 14.04. servers side is debian 8. browser is ff or chrome. both show: echo $LANG en_US.UTF-8 before i dive into the c

Re: Remove directory tree without following symlinks

2016-04-24 Thread eryk sun
On Sun, Apr 24, 2016 at 5:42 AM, Albert-Jan Roskam wrote: > Aww, I kinda forgot about that already, but I came across this last > year [1]. Apparently, shutil.rmtree(very_long_path) failed under Win 7, > even with the "silly prefix". I believe very_long_path was a > Python2-str. > [1] > https://ma

Scraping email to make invoice

2016-04-24 Thread CM
I would like to write a Pythons script to automate a tedious process and could use some advice. The source content will be an email that has 5-10 PO (purchase order) numbers and information for freelance work done. The target content will be an invoice. (There will be an email like this every w

Re: Comparing Python enums to Java, was: How much sanity checking is required for function inputs?

2016-04-24 Thread Ian Kelly
On Sun, Apr 24, 2016 at 10:04 AM, Ethan Furman wrote: > On 04/24/2016 08:20 AM, Ian Kelly wrote: >> * Java doesn't have the hokey notion of enum instances being distinct >> from their "value". The individual enum members *are* the values. >> Whereas in Python an enum member is an awkward class ins

Re: from __future__ import print_function

2016-04-24 Thread Ethan Furman
On 04/24/2016 11:14 AM, Joel Goldstick wrote: On Sun, Apr 24, 2016 at 2:05 PM, San wrote: I want details explanation(why this statement used,when it can be used,etc) of following statement in python code "from __future__ import print_function" It lets python 2.7 use python 3.x print functi

Re: Comparing Python enums to Java, was: How much sanity checking is required for function inputs?

2016-04-24 Thread Ethan Furman
On 04/24/2016 11:27 AM, Chris Angelico wrote: On Mon, Apr 25, 2016 at 4:12 AM, Ethan Furman wrote: Values can be anything. The names are immutable and hashable. I know they *can* be, because I looked in the docs; but does it make sense to a human? Sure, we can legally do this: Well, not m

Re: Comparing Python enums to Java, was: How much sanity checking is required for function inputs?

2016-04-24 Thread Chris Angelico
On Mon, Apr 25, 2016 at 4:12 AM, Ethan Furman wrote: > On 04/24/2016 09:47 AM, Chris Angelico wrote: > >> I would normally expect enumerated values to be immutable and >> hashable, but that isn't actually required by the code AIUI. Under >> what circumstances is it useful to have mutable enum valu

Re: Optimizing Memory Allocation in a Simple, but Long Function

2016-04-24 Thread Chris Angelico
On Mon, Apr 25, 2016 at 4:03 AM, Derek Klinge wrote: > Ok, from the gmail web client: Bouncing this back to the list, and removing quote markers for other people's copy/paste convenience. ## Write a method to approximate Euler's Number using Euler's Method import math class EulersNumber():

Re: from __future__ import print_function

2016-04-24 Thread Joel Goldstick
On Sun, Apr 24, 2016 at 2:05 PM, San wrote: > Hi All, > I want details explanation(why this statement used,when it can be used,etc) > of following statement in python code > > "from __future__ import print_function" > > Thanks in advance. > -- > https://mail.python.org/mailman/listinfo/python-lis

Re: Comparing Python enums to Java, was: How much sanity checking is required for function inputs?

2016-04-24 Thread Ethan Furman
On 04/24/2016 09:47 AM, Chris Angelico wrote: I would normally expect enumerated values to be immutable and hashable, but that isn't actually required by the code AIUI. Under what circumstances is it useful to have mutable enum values? Values can be anything. The names are immutable and hasha

from __future__ import print_function

2016-04-24 Thread San
Hi All, I want details explanation(why this statement used,when it can be used,etc) of following statement in python code "from __future__ import print_function" Thanks in advance. -- https://mail.python.org/mailman/listinfo/python-list

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

2016-04-24 Thread Steven D'Aprano
On Sun, 24 Apr 2016 04:40 pm, Michael Selik wrote: > I think we're giving mixed messages because we're conflating "constants" > and globals that are expected to change. When you talk about "state", that usually means "the current state of the program", not constants. math.pi is not "state". >

Re: Comparing Python enums to Java, was: How much sanity checking is required for function inputs?

2016-04-24 Thread Chris Angelico
On Mon, Apr 25, 2016 at 3:54 AM, BartC wrote: > On 24/04/2016 17:47, Chris Angelico wrote: >> >> On Mon, Apr 25, 2016 at 2:42 AM, Ethan Furman wrote: Easy: allow an empty list to have the same meaning as an empty tuple. Every time you have [] in your source code, you're guaranteed

Re: Optimizing Memory Allocation in a Simple, but Long Function

2016-04-24 Thread Chris Angelico
On Mon, Apr 25, 2016 at 3:56 AM, Derek Klinge wrote: > Doesn't range(n) create a list n long? Not in Python 3. If your code is running on Python 2, use xrange instead of range. I rather doubt that's your problem, though. ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Re: Optimizing Memory Allocation in a Simple, but Long Function

2016-04-24 Thread Derek Klinge
Doesn't range(n) create a list n long? On Sun, Apr 24, 2016 at 10:21 AM Chris Angelico wrote: > On Mon, Apr 25, 2016 at 3:02 AM, Derek Klinge > wrote: > > My problem is this: my attempt at Euler's Method involves creating a > list of > > numbers that is n long. Is there a way I can iterate over

Re: Comparing Python enums to Java, was: How much sanity checking is required for function inputs?

2016-04-24 Thread BartC
On 24/04/2016 17:47, Chris Angelico wrote: On Mon, Apr 25, 2016 at 2:42 AM, Ethan Furman wrote: Easy: allow an empty list to have the same meaning as an empty tuple. Every time you have [] in your source code, you're guaranteed to get a new (unique) empty list, and then multiple assignment will

Re: Optimizing Memory Allocation in a Simple, but Long Function

2016-04-24 Thread Chris Angelico
On Mon, Apr 25, 2016 at 3:02 AM, Derek Klinge wrote: > My problem is this: my attempt at Euler's Method involves creating a list of > numbers that is n long. Is there a way I can iterate over the linear > approximation method without creating a list of steps (maybe recursion, I am > a bit new at t

Re: Optimizing Memory Allocation in a Simple, but Long Function

2016-04-24 Thread Chris Angelico
On Mon, Apr 25, 2016 at 3:06 AM, Derek Klinge wrote: > I think my e-mail client may be stripping the indentation, here it is with > 4-space indentation I think it is. Both your reposted versions have indentation lost. You may need to use a different client. My posts come from the Gmail web clien

Challenge: Shadow lots of built-ins

2016-04-24 Thread Chris Angelico
This is mostly just for the fun of it, but every now and then I have a discussion with people about why it's legal to shadow Python's built-in names, and it'd be handy to have a go-to piece of demo code. So here's the challenge: Write a short, readable block of code that shadows as many built-ins a

Re: Optimizing Memory Allocation in a Simple, but Long Function

2016-04-24 Thread Derek Klinge
I think my e-mail client may be stripping the indentation, here it is with 4-space indentation ## Write a method to approximate Euler's Number using Euler's Method import math class EulersNumber(): def __init__(self,n): self.eulerSteps = n self.e = self.EulersMethod(self.eulerSteps) def linearApp

Re: Optimizing Memory Allocation in a Simple, but Long Function

2016-04-24 Thread Derek Klinge
Sorry about the code indentation, I was using Pythonista (iOS), and it did not have any problem with that indentation... Here is a new set of the code: ## Write a method to approximate Euler's Number using Euler's Method import math class EulersNumber(): def __init__(self,n): self.eulerSteps = n

Re: Comparing Python enums to Java, was: How much sanity checking is required for function inputs?

2016-04-24 Thread Chris Angelico
On Mon, Apr 25, 2016 at 2:42 AM, Ethan Furman wrote: >> Easy: allow an empty list to have the same meaning as an empty tuple. >> Every time you have [] in your source code, you're guaranteed to get a >> new (unique) empty list, and then multiple assignment will work. > > > *sigh* > > Where were yo

Re: Comparing Python enums to Java, was: How much sanity checking is required for function inputs?

2016-04-24 Thread Ethan Furman
On 04/24/2016 09:10 AM, Chris Angelico wrote: On Mon, Apr 25, 2016 at 2:04 AM, Ethan Furman wrote: Unfortunately, the empty tuple tends to be a singleton, so there is no way to tell that red and default are (supposed to be) the same and blue is (supposed to be) different: --> a = b = () --> c

Re: Optimizing Memory Allocation in a Simple, but Long Function

2016-04-24 Thread Chris Angelico
On Sun, Apr 24, 2016 at 1:05 PM, Derek Klinge wrote: > I have been writing a python script to explore Euler's Method of > approximating Euler's Number. I was hoping there might be a way to make > this process work faster, as for sufficiently large eulerSteps, the process > below becomes quite slow

Re: Comparing Python enums to Java, was: How much sanity checking is required for function inputs?

2016-04-24 Thread Chris Angelico
On Mon, Apr 25, 2016 at 2:04 AM, Ethan Furman wrote: > Unfortunately, the empty tuple tends to be a singleton, so there is no way > to tell that red and default are (supposed to be) the same and blue is > (supposed to be) different: > > --> a = b = () > --> c = () > --> a is b > True > --> a is c

Re: Comparing Python enums to Java, was: How much sanity checking is required for function inputs?

2016-04-24 Thread Ethan Furman
On 04/24/2016 08:20 AM, Ian Kelly wrote: On Sun, Apr 24, 2016 at 1:20 AM, Ethan Furman wrote: On 04/23/2016 06:29 PM, Ian Kelly wrote: Python enums are great. Sadly, they're still not quite as awesome as Java enums. What fun things can Java enums do? Everything that Python enums can do,

Comparing Python enums to Java, was: How much sanity checking is required for function inputs?

2016-04-24 Thread Ian Kelly
On Sun, Apr 24, 2016 at 1:20 AM, Ethan Furman wrote: > On 04/23/2016 06:29 PM, Ian Kelly wrote: > >> Python enums are great. Sadly, they're still not quite as awesome as Java >> enums. > > > What fun things can Java enums do? Everything that Python enums can do, plus: * You can override methods

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

2016-04-24 Thread Ethan Furman
On 04/23/2016 06:00 PM, Christopher Reimer wrote: Hmm... What do we use Enum for? :) from enum import Enum class Piece(Enum): king = 'one space, any direction' queen = 'many spaces, any direction' bishop = 'many spaces, diagonal' knight = 'two spaces cardinal, one space sidewa

RE: Remove directory tree without following symlinks

2016-04-24 Thread Albert-Jan Roskam
> From: eryk...@gmail.com > Date: Sat, 23 Apr 2016 15:22:35 -0500 > Subject: Re: Remove directory tree without following symlinks > To: python-list@python.org > > On Sat, Apr 23, 2016 at 4:34 AM, Albert-Jan Roskam > wrote: >> >>> From: eryk...@gmail.com >>> Date: Fri, 22 Apr 2016 13:28:01 -0500

Re: A pickle problem!

2016-04-24 Thread Fabien
On 04/21/2016 11:43 PM, Paulo da Silva wrote: class C(pd.DataFrame): Note also that subclassing pandas is not always encouraged: http://pandas.pydata.org/pandas-docs/stable/internals.html#subclassing-pandas-data-structures Cheers, Fabien -- https://mail.python.org/mailman/listinfo/python-lis

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

2016-04-24 Thread Ethan Furman
On 04/23/2016 06:21 PM, Michael Selik wrote: On Sat, Apr 23, 2016 at 9:01 PM Christopher Reimer wrote: Hmm... What do we use Enum for? :) You can use Enum in certain circumstances to replace int or str constants. It can help avoid mistyping mistakes and might help your IDE give auto-complete

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

2016-04-24 Thread Ethan Furman
On 04/23/2016 06:29 PM, Ian Kelly wrote: Python enums are great. Sadly, they're still not quite as awesome as Java enums. What fun things can Java enums do? -- ~Ethan~ -- https://mail.python.org/mailman/listinfo/python-list