Re: beginners choice: wx or tk?

2015-07-12 Thread Ulli Horlacher
[email protected] wrote:

> On Windows, there are no more usable, working GUI toolkits (wrappers).

What is the problem with tkinter?
A first "hello world" program worked.

-- 
Ullrich Horlacher  Server und Virtualisierung
Rechenzentrum IZUS/TIK E-Mail: [email protected]
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: beginners choice: wx or tk?

2015-07-12 Thread Christian Gollwitzer

Am 12.07.15 um 09:55 schrieb Ulli Horlacher:

[email protected] wrote:


On Windows, there are no more usable, working GUI toolkits (wrappers).


What is the problem with tkinter?
A first "hello world" program worked.


Don't listen.
jmf is a troll, who always complains about Unicode support, which is 
broken accoring to him in all ways.


In the case of Tk, sadly he would have a point: Tk only supports the 
BMP, which means that you cannot input astral characters into an entry 
box (emoticons, some rare Chinese characters...) Still most scripts *do* 
work.

QT handles this better. And jmf's complaints are otherwise invalid.

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


Re: beginners choice: wx or tk?

2015-07-12 Thread Chris Angelico
On Sun, Jul 12, 2015 at 6:00 PM, Christian Gollwitzer  wrote:
> Am 12.07.15 um 09:55 schrieb Ulli Horlacher:
>>
>> [email protected] wrote:
>>
>>> On Windows, there are no more usable, working GUI toolkits (wrappers).
>>
>>
>> What is the problem with tkinter?
>> A first "hello world" program worked.
>>
> Don't listen.
> jmf is a troll, who always complains about Unicode support, which is broken
> accoring to him in all ways.
>
> In the case of Tk, sadly he would have a point: Tk only supports the BMP,
> which means that you cannot input astral characters into an entry box
> (emoticons, some rare Chinese characters...) Still most scripts *do* work.
> QT handles this better. And jmf's complaints are otherwise invalid.

I don't know about the Python bindings, but I know for sure that GTK
has excellent Unicode support. (My only concern is that one particular
API uses UTF-8 byte positions rather than Unicode codepoint indices,
which may or may not have been papered over in the Python bindings.)
Qt is probably comparable. wxPython/wxWindows maybe, maybe not, given
that it aims for Windows API similarity. But it's something worth
checking, given that Tk doesn't do so well. And yet... a few simple
tests will prove the point. Don't listen to jmf, just check if you
care.

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


Re: Why doesn't input code return 'plants' as in 'Getting Started with Beautiful Soup' text (on page 30) ?

2015-07-12 Thread Simon Evans
Dear Mark Lawrence, thank you for your advice. 
I take it that I use the input you suggest for the line :

soup = BeautifulSoup("C:\Beautiful Soup\ecological_pyramid.html",lxml")

seeing as I have to give the file's full address I therefore have to modify 
your :

soup = BeautifulSoup(ecological_pyramid,"lxml")

to :

soup = BeautifulSoup("C:\Beautiful Soup\ecological_pyramid," "lxml")

otherwise I get :


>>> with open("C:\Beautiful Soup\ecologicalpyramid.html"."r")as 
>>> ecological_pyramid:
>>> soup = BeautifulSoup(ecological_pyramid,"lxml")
Traceback (most recent call last):
  File "", line 1, in 
NameError: name 'ecological_pyramid' is not defined


so anyway with the input therefore as:

>>> with open("C:\Beautiful Soup\ecologicalpyramid.html"."r")as 
>>> ecological_pyramid: 
>>> soup = BeautifulSoup("C:\Beautiful Soup\ecological_pyramid,","lxml")
>>> producer_entries = soup.find("ul")
>>> print(producer_entries.li.div.string)

I still get the following output from the console:

Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'NoneType' object has no attribute 'li'
>>>

As is probably evident, what is the problem Python has with finding the 
required html code within the 'ecologicalpyramid' html file, or more 
specifically why does it respond that the html file has no such attribute as 
'li' ?
Incidentally I have installed all the xml, lxml, html, and html5 TreeBuilders/ 
Parsers. I am using lxml as that is the format specified in the text. 

I may as well quote the text on the page in question in 'Getting Started with 
Beautiful Soup':

'Since producers come as the first entry for the tag, we can use the find() 
method, which normally searches fo ronly the first occurrance of a particular 
tag in a BeautifulSoup object. We store this in producer_entries. The next line 
prints the name of the first producer. From the previous HTML diagram we can 
understand that the first producer is stored inside the first  tag of the 
first  tag that immediately follows the first  tag , as shown inthe 
following code: 



plants
10



So after running the preceding code, we will get plants, which is the first 
producer, as the output.'

(page 30)
-- 
https://mail.python.org/mailman/listinfo/python-list


Python backreference replacing doesn't work as expected

2015-07-12 Thread Yonggang Chen
There are two named groups in my pattern: myFlag and id, I want to add one more 
myFlag immediately before group id.

Here is my current code:
## code begin
# i'm using Python 3.4.2
import re
import os
contents = b'''
xdlg::xdlg(x_app* pApp, CWnd* pParent)
: customized_dlg((UINT)0, pParent, pApp)
, m_pReaderApp(pApp)
, m_info(pApp)
{

}
'''

pattern = rb'(?P[a-zA-Z0-9_]+)::(?P=myFlag).+:.+(?P\(UINT\)0 *,)'
res = re.search(pattern, contents, re.DOTALL)
if None != res:
print(res.groups()) # the output is (b'xdlg', b'(UINT)0,')

# 'replPattern' becomes 
b'(?P[a-zA-Z0-9_]+)::(?P=myFlag).+:.+((?P=myFlag)\\(UINT\\)0 *,)'
replPattern = pattern.replace(b'?P', b'(?P=myFlag)', re.DOTALL)
print(replPattern)
contents = re.sub(pattern, replPattern, contents)
print(contents)
# code end

The expected results should be:

xdlg::xdlg(x_app* pApp, CWnd* pParent)
: customized_dlg(xdlg(UINT)0, pParent, pApp)
, m_pReaderApp(pApp)
, m_info(pApp)
{

}

but now the result this the same with the original:

 xdlg::xdlg(x_app* pApp, CWnd* pParent)
: customized_dlg((UINT)0, pParent, pApp)
, m_pReaderApp(pApp)
, m_info(pApp)
{

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


Re: Why doesn't input code return 'plants' as in 'Getting Started with Beautiful Soup' text (on page 30) ?

2015-07-12 Thread Peter Otten
Simon Evans wrote:

> Dear Mark Lawrence, thank you for your advice.
> I take it that I use the input you suggest for the line :
> 
> soup = BeautifulSoup("C:\Beautiful Soup\ecological_pyramid.html",lxml")
> 
> seeing as I have to give the file's full address I therefore have to
> modify your :
> 
> soup = BeautifulSoup(ecological_pyramid,"lxml")
> 
> to :
> 
> soup = BeautifulSoup("C:\Beautiful Soup\ecological_pyramid," "lxml")
> 
> otherwise I get :
> 
> 
 with open("C:\Beautiful Soup\ecologicalpyramid.html"."r")as
 ecological_pyramid: soup = BeautifulSoup(ecological_pyramid,"lxml")
> Traceback (most recent call last):
>   File "", line 1, in 
> NameError: name 'ecological_pyramid' is not defined
> 
> 
> so anyway with the input therefore as:
> 
 with open("C:\Beautiful Soup\ecologicalpyramid.html"."r")as
 ecological_pyramid: soup = BeautifulSoup("C:\Beautiful
 Soup\ecological_pyramid,","lxml") producer_entries = soup.find("ul")
 print(producer_entries.li.div.string)

No. If you pass the filename beautiful soup will mistake it as the HTML. You
can verify that in the interactive interpreter:

>>> soup = BeautifulSoup("C:\Beautiful Soup\ecologicalpyramid.html","lxml")
>>> soup
C:\Beautiful Soup\ecologicalpyramid.html

You have to pass an open file to BeautifulSoup, not a filename:

>>> with open("C:\Beautiful Soup\ecologicalpyramid.html","r") as f:
... soup = BeautifulSoup(f, "lxml")
... 

However, if you look at the data returned by soup.find("ul") you'll see

>>> producer_entries = soup.find("ul")
>>> producer_entries



plants
10


algae
10



The first ... node does not contain a div

>>> producer_entries.li



and thus

>>> producer_entries.li.div is None
True

and the following error is expected with the given data. 
Returning None is beautiful soup's way of indicating that the
 node has no  child at all. If you want to 
process the first li that does have a  child a straight-forward 
way is to iterate over the children:

>>> for li in producer_entries.find_all("li"):
... if li.div is not None:
... print(li.div.string)
... break # remove if you want all, not just the first
... 
plants

Taking a second look at the data you probably want the li nodes with
class="producerlist":

>>> for li in soup.find_all("li", attrs={"class": "producerlist"}):
... print(li.div.string)
... 
plants
algae


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


Re: beginners choice: wx or tk?

2015-07-12 Thread Laura Creighton
In a message of Sat, 11 Jul 2015 15:50:05 -0700, Paul Rubin writes:
>Ulli Horlacher  writes:
>> This is not an option for me. My users only accept standalone executables.
>> They cannot install any runtime environment or extra libraries.
>
>Long ago I was involved with a thing like this and used Inno Setup,
>which was great.  It's a very slick installer whose user experience is
>similar to Install Shield if you're familiar with that.  I have no idea
>what current best practice is, but I see that Inno Setup is still
>around.

Docker is what I hear people are using now.
https://www.docker.com/

But I have never tried this myself.

Laura

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


EuroPython 2015: Recruiting Offers

2015-07-12 Thread M.-A. Lemburg
Many of our sponsors are looking for new employees, so EuroPython 2015
is not only an exciting conference, but may very well also be your
chance to find the perfect job you’ve always been looking for.

Sponsor job board
-

We will post sponsor recruiting offers on the job board of our website:

*** https://ep2015.europython.eu/en/sponsor/job-board/ ***

Sponsor recruiting messages
---

If you want to receive the sponsor messages directly to your inbox,
please log in to the website and enable the recruiting message option
in your privacy settings:

https://ep2015.europython.eu/accounts/profile/#account-spam-control

Enjoy,
--
EuroPython 2015 Team
http://ep2015.europython.eu/
http://www.europython-society.org/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why doesn't input code return 'plants' as in 'Getting Started with Beautiful Soup' text (on page 30) ?

2015-07-12 Thread Simon Evans
Dear Peter Otten, thank you for your reply that I have not gone very far into 
the detail of which, as it seems Python console cannot recognise the name 'f' 
as given it, re output below :


Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.

>>> from bs4 import BeautifulSoup
>>> with open("C:\Beautiful Soup\ecologicalpyramid.html","r")as f:
>>> soup = BeautifulSoup(f, "lxml")
Traceback (most recent call last):
  File "", line 1, in 
NameError: name 'f' is not defined
>>>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why doesn't input code return 'plants' as in 'Getting Started with Beautiful Soup' text (on page 30) ?

2015-07-12 Thread Peter Otten
Simon Evans wrote:

> Dear Peter Otten, thank you for your reply that I have not gone very far
> into the detail of which, as it seems Python console cannot recognise the
> name 'f' as given it, re output below :
> 
> 
> Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)]
> on win 32
> Type "help", "copyright", "credits" or "license" for more information.
> 
 from bs4 import BeautifulSoup
 with open("C:\Beautiful Soup\ecologicalpyramid.html","r")as f:
 soup = BeautifulSoup(f, "lxml")
> Traceback (most recent call last):
>   File "", line 1, in 
> NameError: name 'f' is not defined


Is that copy-and-paste? When I try to reproduce that I get

$ python
Python 2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from bs4 import BeautifulSoup
>>> with open("C:\Beautiful Soup\ecologicalpyramid.html","r")as f:
... soup = BeautifulSoup(f, "lxml")
  File "", line 2
soup = BeautifulSoup(f, "lxml")
   ^
IndentationError: expected an indented block

and when I indent the soup = ... line properly I don't get an error:

$ python
Python 2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from bs4 import BeautifulSoup
>>> with open("C:\Beautiful Soup\ecologicalpyramid.html","r")as f:
... soup = BeautifulSoup(f, "lxml")
... 
>>> 


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


Re: Why doesn't input code return 'plants' as in 'Getting Started with Beautiful Soup' text (on page 30) ?

2015-07-12 Thread Simon Evans
Dear Peter Otten,
Incidentally, you have discovered a fault in that there is an erroneous 
difference in my code of 'ecologicalpyramid.html' and that given in the text, 
in the first few lines re: 

 
 
 
 
 
 
plants 
10 
 
 
algae 
10 
 
 






plants
10


algae
10



I have removed the line  to the right html code of the 
lower 

version. Now there is a string ("plants") between the <"li class producerlist"> 
and 
Sorry about that.
However as you said, the input code as quoted in the text, still won't return 
'plants' 

re:

Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> from bs4 import BeautifulSoup
>>> soup = BeautifulSoup("C:\Beautiful Soup\ecological_pyramid,","lxml")
>>> producer_entries = soup.find("ul")
>>> print(producer_entries.li.div.string)
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'NoneType' object has no attribute 'li'
>>> 

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


Re: Why doesn't input code return 'plants' as in 'Getting Started with Beautiful Soup' text (on page 30) ?

2015-07-12 Thread Simon Evans
Dear Peter Otten, 
Yes, I have been copying and pasting, as it saves typing. I do get 'indented 
block' error responses as a small price to pay for the time and energy thus 
saved. Also Console seems to reject for 'indented block' reasons better known 
to itself, copy and pasted lines that it accepts and  are exactly the same on 
the following line of input. Maybe it is an inbuilt feature of Python's to 
discourage copy and pasting.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why doesn't input code return 'plants' as in 'Getting Started with Beautiful Soup' text (on page 30) ?

2015-07-12 Thread Peter Otten
Simon Evans wrote:

> Dear Peter Otten,
> Yes, I have been copying and pasting, as it saves typing. I do get
> 'indented block' error responses as a small price to pay for the time and
> energy thus saved. Also Console seems to reject for 'indented block'
> reasons better known to itself, copy and pasted lines that it accepts and 
> are exactly the same on the following line of input. Maybe it is an
> inbuilt feature of Python's to discourage copy and pasting.

You should not ignore the error. It means that the respective code was not 
executed.

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


Re: Why doesn't input code return 'plants' as in 'Getting Started with Beautiful Soup' text (on page 30) ?

2015-07-12 Thread Simon Evans

Dear Peter Otten, 
I typed in (and did not copy and paste) the code as you suggested just now 
(6.28 pm, Sunday 12th July 2015), this is the result I got: 

Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> from bs4 import BeautifulSoup
>>> with open("C:\Beautiful Soup\ecologicalpyramid.html","r")as f:
... soup = BeautifulSoup(f,"lxml")
  File "", line 2
soup = BeautifulSoup(f,"lxml")
   ^
IndentationError: expected an indented block
>>> soup = BeautifulSoup(f,"lxml")
Traceback (most recent call last):
  File "", line 1, in 
NameError: name 'f' is not defined
>>>

The first time I typed in the second line, I got the 
"Indentation error" 
the second time I typed in exactly the same code, I got the: 
"NameError:name 'f' is not defined"
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why doesn't input code return 'plants' as in 'Getting Started with Beautiful Soup' text (on page 30) ?

2015-07-12 Thread Laurent Pointal
Simon Evans wrote:


> -
 with open("C:\Beautiful Soup\ecologicalpyramid.html","r") as

You seem to run Python under Windows.

You have to take care of escape mechanism beyond \ char in string literals 
(see Python docs). 

By chance, \B and \e are not recognized as escape sequences, so they are 
left as is. But \a \b \f \n \r \t \v \x  will be processed differently

Double \ in your string:
"C:\\Beautiful Soup\\ecologicalpyramid.html"

Or use a raw string by prepending a r to disable escape sequences:
r"C:\Beautiful Soup\ecologicalpyramid.html"




A+
Laurent.

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


Re: Why doesn't input code return 'plants' as in 'Getting Started with Beautiful Soup' text (on page 30) ?

2015-07-12 Thread Chris Angelico
On Mon, Jul 13, 2015 at 3:54 AM, Laurent Pointal
 wrote:
> Double \ in your string:
> "C:\\Beautiful Soup\\ecologicalpyramid.html"
>
> Or use a raw string by prepending a r to disable escape sequences:
> r"C:\Beautiful Soup\ecologicalpyramid.html"

Or use forward slashes:
"C:/Beautiful Soup/ecologicalpyramid.html"

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


Re: Why doesn't input code return 'plants' as in 'Getting Started with Beautiful Soup' text (on page 30) ?

2015-07-12 Thread MRAB

On 2015-07-12 18:33, Simon Evans wrote:


Dear Peter Otten,
I typed in (and did not copy and paste) the code as you suggested just now 
(6.28 pm, Sunday 12th July 2015), this is the result I got:

Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.

from bs4 import BeautifulSoup
with open("C:\Beautiful Soup\ecologicalpyramid.html","r")as f:

... soup = BeautifulSoup(f,"lxml")
   File "", line 2
 soup = BeautifulSoup(f,"lxml")
^
IndentationError: expected an indented block

soup = BeautifulSoup(f,"lxml")

Traceback (most recent call last):
   File "", line 1, in 
NameError: name 'f' is not defined




The first time I typed in the second line, I got the
"Indentation error"
the second time I typed in exactly the same code, I got the:
"NameError:name 'f' is not defined"


Python parses the lines, and, if there are no syntax errors, it then
executes them.

That block of code (the 2 lines) contained a syntax (indentation)
error in the second line, so _none_ of the block was executed, and,
therefore, 'f' isn't defined.

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


Re: Why doesn't input code return 'plants' as in 'Getting Started with Beautiful Soup' text (on page 30) ?

2015-07-12 Thread Mark Lawrence

On 12/07/2015 18:33, Simon Evans wrote:


Dear Peter Otten,
I typed in (and did not copy and paste) the code as you suggested just now 
(6.28 pm, Sunday 12th July 2015), this is the result I got:

Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.

from bs4 import BeautifulSoup
with open("C:\Beautiful Soup\ecologicalpyramid.html","r")as f:

... soup = BeautifulSoup(f,"lxml")
   File "", line 2
 soup = BeautifulSoup(f,"lxml")
^
IndentationError: expected an indented block

soup = BeautifulSoup(f,"lxml")

Traceback (most recent call last):
   File "", line 1, in 
NameError: name 'f' is not defined




The first time I typed in the second line, I got the
"Indentation error"
the second time I typed in exactly the same code, I got the:
"NameError:name 'f' is not defined"



You can tell that to the marines :)

>>> with open("ecologicalpyramid.html","r")as f:
... soup = BeautifulSoup(f)
... producer_entries = soup.find("ul")
... producer_entries
...



plants
10


algae
10


>>>

Can I suggest that you slow down.  It strikes me that you're trying to 
run a marathon a day for a year before you can even walk.  For example 
is the file path in your call to open() correct?  Frankly I very much 
doubt it, although it is possible.


Perhaps you'd be more comfortable on the tutor mailing list?  If so see 
https://mail.python.org/mailman/listinfo/tutor or gmane.comp.python.tutor.


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

Mark Lawrence

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


Re: Why doesn't input code return 'plants' as in 'Getting Started with Beautiful Soup' text (on page 30) ?

2015-07-12 Thread Albert Visser
On Sun, 12 Jul 2015 19:33:17 +0200, Simon Evans  
 wrote:




Dear Peter Otten,
I typed in (and did not copy and paste) the code as you suggested just  
now (6.28 pm, Sunday 12th July 2015), this is the result I got:


Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit  
(Intel)] on win

32
Type "help", "copyright", "credits" or "license" for more information.

from bs4 import BeautifulSoup
with open("C:\Beautiful Soup\ecologicalpyramid.html","r")as f:

... soup = BeautifulSoup(f,"lxml")
  File "", line 2
soup = BeautifulSoup(f,"lxml")
   ^
IndentationError: expected an indented block

soup = BeautifulSoup(f,"lxml")

Traceback (most recent call last):
  File "", line 1, in 
NameError: name 'f' is not defined




The first time I typed in the second line, I got the
"Indentation error"
the second time I typed in exactly the same code, I got the:
"NameError:name 'f' is not defined"


"Expected an indented block" means that the indicated line should have  
started with at least one whitespace character more than the preceding  
line.


 >>> with open("C:\Beautiful Soup\ecologicalpyramid.html","r")as f:
 ... soup = BeautifulSoup(f,"lxml")

should have been something like

 >>> with open("C:\Beautiful Soup\ecologicalpyramid.html","r")as f:
 ... soup = BeautifulSoup(f,"lxml")
--
Vriendelijke groeten / Kind regards,

Albert Visser

Using Opera's mail client: http://www.opera.com/mail/
--
https://mail.python.org/mailman/listinfo/python-list


Re: Python backreference replacing doesn't work as expected

2015-07-12 Thread MRAB

On 2015-07-12 10:40, Yonggang Chen wrote:

There are two named groups in my pattern: myFlag and id, I want to add one more 
myFlag immediately before group id.

Here is my current code:
## code begin
# i'm using Python 3.4.2
import re
import os
contents = b'''
xdlg::xdlg(x_app* pApp, CWnd* pParent)
 : customized_dlg((UINT)0, pParent, pApp)
 , m_pReaderApp(pApp)
 , m_info(pApp)
{

}
'''

pattern = rb'(?P[a-zA-Z0-9_]+)::(?P=myFlag).+:.+(?P\(UINT\)0 *,)'
res = re.search(pattern, contents, re.DOTALL)
if None != res:
 print(res.groups()) # the output is (b'xdlg', b'(UINT)0,')

# 'replPattern' becomes 
b'(?P[a-zA-Z0-9_]+)::(?P=myFlag).+:.+((?P=myFlag)\\(UINT\\)0 *,)'


In a replacement template, the (?P...) parts are just literals.


replPattern = pattern.replace(b'?P', b'(?P=myFlag)', re.DOTALL)


This .replace method is a string method. It has nothing to do with
regex.


print(replPattern)
contents = re.sub(pattern, replPattern, contents)


You're not passing in the DOTALL flag; this function doesn't have an
argument for the flags, anyway.

You could compile the regex and then use its .sub method, or use inline
flags instead.


print(contents)
# code end

The expected results should be:

xdlg::xdlg(x_app* pApp, CWnd* pParent)
 : customized_dlg(xdlg(UINT)0, pParent, pApp)
 , m_pReaderApp(pApp)
 , m_info(pApp)
{

}

but now the result this the same with the original:

  xdlg::xdlg(x_app* pApp, CWnd* pParent)
 : customized_dlg((UINT)0, pParent, pApp)
 , m_pReaderApp(pApp)
 , m_info(pApp)
{

}



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


Re: Why doesn't input code return 'plants' as in 'Getting Started with Beautiful Soup' text (on page 30) ?

2015-07-12 Thread Laura Creighton
Simon Evans -- what editor are you using to write your Python code with?

Laura Creighton


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


Re: Why doesn't input code return 'plants' as in 'Getting Started with Beautiful Soup' text (on page 30) ?

2015-07-12 Thread Mark Lawrence

On 12/07/2015 20:47, Laura Creighton wrote:

Simon Evans -- what editor are you using to write your Python code with?

Laura Creighton



Editor?  His earlier posts clearly show he's using the 2.7.6 32 bit 
interactive interpreter on Windows.


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

Mark Lawrence

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


Re: Why doesn't input code return 'plants' as in 'Getting Started with Beautiful Soup' text (on page 30) ?

2015-07-12 Thread Larry Hudson via Python-list

On 07/12/2015 05:48 AM, Simon Evans wrote:

Dear Peter Otten,
Yes, I have been copying and pasting, as it saves typing. I do get 'indented 
block' error responses as a small price

> to pay for the time and energy thus saved.
>
You CANNOT ignore indenting.
Indenting is NOT optional, it is REQUIRED by Python syntax.
Changing indenting TOTALLY changes the meaning.

> Also Console seems to reject for 'indented block' reasons better known to 
itself, copy and
> pasted lines that it accepts and  are exactly the same on the following line 
of input.
>
As above, that is Python syntax.

> Maybe it is an inbuilt feature of Python's to discourage copy and pasting.
>
Absolutely not.  As noted above, this is the way Python is defined to work.

 -=- Larry -=-

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


Re: Why doesn't input code return 'plants' as in 'Getting Started with Beautiful Soup' text (on page 30) ?

2015-07-12 Thread Laura Creighton
In a message of Sun, 12 Jul 2015 21:09:22 +0100, Mark Lawrence writes:
>On 12/07/2015 20:47, Laura Creighton wrote:
>> Simon Evans -- what editor are you using to write your Python code with?
>>
>> Laura Creighton
>>
>
>Editor?  His earlier posts clearly show he's using the 2.7.6 32 bit 
>interactive interpreter on Windows.

He's sending us that stuff, but he may be writing it someplace else
first.  And that someplace else may be spitting out combined
spaces and tabs.  If he is pasting that into the interpreter,
that will cause tons of problems like he is seeing.

Laura

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


Re: Why doesn't input code return 'plants' as in 'Getting Started with Beautiful Soup' text (on page 30) ?

2015-07-12 Thread Mark Lawrence

On 12/07/2015 21:29, Laura Creighton wrote:

In a message of Sun, 12 Jul 2015 21:09:22 +0100, Mark Lawrence writes:

On 12/07/2015 20:47, Laura Creighton wrote:

Simon Evans -- what editor are you using to write your Python code with?

Laura Creighton



Editor?  His earlier posts clearly show he's using the 2.7.6 32 bit
interactive interpreter on Windows.


He's sending us that stuff, but he may be writing it someplace else
first.  And that someplace else may be spitting out combined
spaces and tabs.  If he is pasting that into the interpreter,
that will cause tons of problems like he is seeing.

Laura



At 18:33 BST Simon stated "I typed in (and did not copy and paste) the 
code...".  I started my reply with "You can tell that to the marines :)".


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

Mark Lawrence

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