Re: os.walk the apostrophe and unicode

2017-06-25 Thread Peter Otten
Steve D'Aprano wrote:

> On Sun, 25 Jun 2017 07:17 am, Peter Otten wrote:
> 
>> Then I'd fix the name manually...
> 
> The file name isn't broken.
> 
> 
> What's broken is parts of the OP's code which assumes that non-ASCII file
> names are broken...

Hm, the OP says

'06 - Todd\xe2\x80\x99s Song (Post-Spiderland Song in Progress).flac'

Shouldn't it be

'06 - Todd’s Song (Post-Spiderland Song in Progress).flac'

if everything worked correctly? Though I don't understand why the OP doesn't 
see

'06 - Toddâ\x80\x99s Song (Post-Spiderland Song in Progress).flac'

which is the repr() that I get.

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


Re: Checking for an exception

2017-06-25 Thread Paul Rubin
Steve D'Aprano  writes:
> What's the right/best way to test whether an object is an exception
> ahead of time? (That is, without trying to raise from it.)

Maybe I'm missing something but 
   isinstance(obj, Exception)
seems to work.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: os.walk the apostrophe and unicode

2017-06-25 Thread Steve D'Aprano
On Sun, 25 Jun 2017 04:57 pm, Peter Otten wrote:

> Steve D'Aprano wrote:
> 
>> On Sun, 25 Jun 2017 07:17 am, Peter Otten wrote:
>> 
>>> Then I'd fix the name manually...
>> 
>> The file name isn't broken.
>> 
>> 
>> What's broken is parts of the OP's code which assumes that non-ASCII file
>> names are broken...
> 
> Hm, the OP says
> 
> '06 - Todd\xe2\x80\x99s Song (Post-Spiderland Song in Progress).flac'
> 
> Shouldn't it be
> 
> '06 - Todd’s Song (Post-Spiderland Song in Progress).flac'

It should, if the OP did everything right.

He has a file name containing the word "Todd’s":

# Python 3.5

py> fname = 'Todd’s'
py> repr(fname)
"'Todd’s'"

On disk, that is represented in UTF-8:

py> repr(fname.encode('utf-8'))
"b'Todd\\xe2\\x80\\x99s'"

The OP appears to be using Python 2, so when he calls os.listdir() he gets the
file names as bytes, not Unicode. That means he'll see:

- the file name will be Python 2 str, which is *byte string* not text string;
- so not Unicode
- rather the individual bytes in the UTF-8 encoding of the file name.

So in Python 2.7 instead of 3.5 above:

py> fname = u'Todd’s'
py> repr(fname)
"u'Todd\\u2019s'"
py> repr(fname.encode('utf-8'))
"'Todd\\xe2\\x80\\x99s'"


> if everything worked correctly? Though I don't understand why the OP doesn't
> see
> 
> '06 - Toddâ\x80\x99s Song (Post-Spiderland Song in Progress).flac'
> 
> which is the repr() that I get.

That's mojibake and is always wrong :-) I'm not sure how you got that. Something
to do with an accidental decode to Latin-1?

# Python 2.7
py> repr(fname.encode('utf-8').decode('latin-1'))
"u'Todd\\xe2\\x80\\x99s'"

# Python 3.5
py> repr(fname.encode('utf-8').decode('latin-1'))
"'Toddâ\\x80\\x99s'"



-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.

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


Re: os.walk the apostrophe and unicode

2017-06-25 Thread Peter Otten
Steve D'Aprano wrote:

> On Sun, 25 Jun 2017 04:57 pm, Peter Otten wrote:

>> if everything worked correctly? Though I don't understand why the OP
>> doesn't see
>> 
>> '06 - Toddâ\x80\x99s Song (Post-Spiderland Song in Progress).flac'
>> 
>> which is the repr() that I get.
> 
> That's mojibake and is always wrong :-) 

Yes, that's my very point. 

> I'm not sure how you got that.

I took the OP's string at face value and pasted it into the interpreter:

# python 3.4
>>> '06 - Todd\xe2\x80\x99s Song (Post-Spiderland Song in Progress).flac'
'06 - Toddâ\x80\x99s Song (Post-Spiderland Song in Progress).flac'

> Something to do with an accidental decode to Latin-1?

If the above filename is the only one or one of a few that seem broken, and 
other non-ascii filenames look OK the OP's toolchain/filesystem may work 
correctly and the odd name might have been produced elsewhere, e. g. by 
copying an already messed-up freedb.org entry.

[Heureka]

However, the most likely explanation is that the filename is correct and 
that the OP is not using Python 3 as he claims but Python 2.

Yes, it took that long for me to realise ;) Python 2 is slowly sinking into 
oblivion...

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


Re: os.walk the apostrophe and unicode

2017-06-25 Thread alister
On Sun, 25 Jun 2017 02:23:15 -0700, wxjmfauth wrote:

> Le samedi 24 juin 2017 21:10:47 UTC+2, alister a écrit :
>> On Sat, 24 Jun 2017 14:57:21 -0400, Rod Person wrote:
>> 
>> > \xe2\x80\x99,
>> 
>> because the file name has been created using "Right single quote"
>> instead of apostrophe, the glyphs look identical in many fonts.
>> 
>> 
> Trust me. Fonts are clearly making distinction between \u0027 and
> \u2019.



Not all, and even when they do it has absolutely nothing to do with the 
point of the post
the character in the file name is \u2019 right quotation mark & not an 
apostrophe which the op was assuming.
he needs to decode the file name correctly 

-- 
You will be held hostage by a radical group.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: os.walk the apostrophe and unicode

2017-06-25 Thread Rod Person
Ok...so after reading all the replies in the thread, I thought I would
be easier to send a general reply and include some links to screenshots.

As Peter mention, the logic thing to do would be to fix the file name
to what I actually thought it was and if this was for work that
probably what I would have done, but since I want to understand what's
going on I decided to waste time on that.

I have to admit, I didn't think the file system was utf-8 as seeing what
looked to be an apostrophe sent me down the road of why is this
apostrophe screwed up instead of "ah this must be unicode".

But doing a simple ls of that directory show it is unicode but the
replacement of the offending character.

http://rodperson.com/graphics/uc/ls.png

I am in fact using Python 3.5. I may be lacking in unicode skills but I
do have the sense enough to know the version of Python I am invoking.
So I included this screenshot of that so the version of Python and the
files list returned by os.walk

http://rodperson.com/graphics/uc/files.png

So the fact that it shows as a string and not bytes in the debugger was
throwing me for a loop, in my log section I was trying to determine if
it was unicode decode it...if not don't do anything which wasn't working

http://rodperson.com/graphics/uc/log_section.png




On Sun, 25 Jun 2017 10:47:18 +0200
Peter Otten <__pete...@web.de> wrote:

> Steve D'Aprano wrote:
> 
> > On Sun, 25 Jun 2017 04:57 pm, Peter Otten wrote:  
> 
> >> if everything worked correctly? Though I don't understand why the
> >> OP doesn't see
> >> 
> >> '06 - Toddâ\x80\x99s Song (Post-Spiderland Song in Progress).flac'
> >> 
> >> which is the repr() that I get.  
> > 
> > That's mojibake and is always wrong :-)   
> 
> Yes, that's my very point. 
> 
> > I'm not sure how you got that.  
> 
> I took the OP's string at face value and pasted it into the
> interpreter:
> 
> # python 3.4
> >>> '06 - Todd\xe2\x80\x99s Song (Post-Spiderland Song in
> >>> Progress).flac'  
> '06 - Toddâ\x80\x99s Song (Post-Spiderland Song in Progress).flac'
> 
> > Something to do with an accidental decode to Latin-1?  
> 
> If the above filename is the only one or one of a few that seem
> broken, and other non-ascii filenames look OK the OP's
> toolchain/filesystem may work correctly and the odd name might have
> been produced elsewhere, e. g. by copying an already messed-up
> freedb.org entry.
> 
> [Heureka]
> 
> However, the most likely explanation is that the filename is correct
> and that the OP is not using Python 3 as he claims but Python 2.
> 
> Yes, it took that long for me to realise ;) Python 2 is slowly
> sinking into oblivion...
> 



-- 
Rod

http://www.rodperson.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: os.walk the apostrophe and unicode

2017-06-25 Thread Michael Torrie
On 06/25/2017 06:19 AM, Rod Person wrote:
> But doing a simple ls of that directory show it is unicode but the
> replacement of the offending character.
> 
> http://rodperson.com/graphics/uc/ls.png

Now that is really strange.  Your OS seems to not recognize that the
filename is in UTF-8.  I suspect this has something to do with the NAS
file sharing protocol (smb). Though I'm pretty sure that Samba can
handle UTF-8 filenames correctly.

> I am in fact using Python 3.5. I may be lacking in unicode skills but I
> do have the sense enough to know the version of Python I am invoking.
> So I included this screenshot of that so the version of Python and the
> files list returned by os.walk
> 
> http://rodperson.com/graphics/uc/files.png

If I create a file that has the U+2019 character in it on my Linux
machine (BtrFS), and do os.walk on it, I see the character in then
string properly.  So it looks like Python does the right thing,
automatically decoding from UTF-8.

In your situation I think the problem is the file sharing protocol that
your NAS is using. Somehow some information is being lost and your OS
does not know that the filenames are in UTF-8, and just thinks they are
bytes. And therefore Python doesn't know to decode the string, so you
just end up with each byte being converted to a unicode code point and
being shoved into the unicode string.

How to get around this issue I don't know.  Maybe there's a way to
convert the unicode string to bytes using the value of each character,
and then decode that back to unicode.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: os.walk the apostrophe and unicode

2017-06-25 Thread Peter Otten
Rod Person wrote:

> Ok...so after reading all the replies in the thread, I thought I would
> be easier to send a general reply and include some links to screenshots.
> 
> As Peter mention, the logic thing to do would be to fix the file name
> to what I actually thought it was and if this was for work that
> probably what I would have done, but since I want to understand what's
> going on I decided to waste time on that.
> 
> I have to admit, I didn't think the file system was utf-8 as seeing what
> looked to be an apostrophe sent me down the road of why is this
> apostrophe screwed up instead of "ah this must be unicode".
> 
> But doing a simple ls of that directory show it is unicode but the
> replacement of the offending character.
> 
> http://rodperson.com/graphics/uc/ls.png

Have you set LANG to something that implies ASCII?

$ touch Todd’s ähnlich üblich löblich
$ ls
ähnlich  löblich  Todd’s  üblich
$ LANG=C ls
Todd???s  l??blich  ??hnlich  ??blich
$ python3 -c 'import os; print(os.listdir())'
['Todd’s', 'üblich', 'ähnlich', 'löblich']
$ LANG=C python3 -c 'import os; print(os.listdir())'
['Todd\udce2\udc80\udc99s', '\udcc3\udcbcblich', '\udcc3\udca4hnlich', 
'l\udcc3\udcb6blich']
$ LANG=en_US.utf-8 python3 -c 'import os; print(os.listdir())'
['Todd’s', 'üblich', 'ähnlich', 'löblich']

For file names Python resorts to surrogates whenever a byte does not 
translate into a character in the advertised encoding.
 
> I am in fact using Python 3.5. I may be lacking in unicode skills but I
> do have the sense enough to know the version of Python I am invoking.

I've made so many "stupid errors" myself that I always consider them first 
;)

> So I included this screenshot of that so the version of Python and the
> files list returned by os.walk
> 
> http://rodperson.com/graphics/uc/files.png
> 
> So the fact that it shows as a string and not bytes in the debugger was
> throwing me for a loop, in my log section I was trying to determine if
> it was unicode decode it...if not don't do anything which wasn't working
> 
> http://rodperson.com/graphics/uc/log_section.png
> 
> 
> 
> 
> On Sun, 25 Jun 2017 10:47:18 +0200
> Peter Otten <__pete...@web.de> wrote:
> 
>> Steve D'Aprano wrote:
>> 
>> > On Sun, 25 Jun 2017 04:57 pm, Peter Otten wrote:
>> 
>> >> if everything worked correctly? Though I don't understand why the
>> >> OP doesn't see
>> >> 
>> >> '06 - Toddâ\x80\x99s Song (Post-Spiderland Song in Progress).flac'
>> >> 
>> >> which is the repr() that I get.
>> > 
>> > That's mojibake and is always wrong :-)
>> 
>> Yes, that's my very point.
>> 
>> > I'm not sure how you got that.
>> 
>> I took the OP's string at face value and pasted it into the
>> interpreter:
>> 
>> # python 3.4
>> >>> '06 - Todd\xe2\x80\x99s Song (Post-Spiderland Song in
>> >>> Progress).flac'
>> '06 - Toddâ\x80\x99s Song (Post-Spiderland Song in Progress).flac'
>> 
>> > Something to do with an accidental decode to Latin-1?
>> 
>> If the above filename is the only one or one of a few that seem
>> broken, and other non-ascii filenames look OK the OP's
>> toolchain/filesystem may work correctly and the odd name might have
>> been produced elsewhere, e. g. by copying an already messed-up
>> freedb.org entry.
>> 
>> [Heureka]
>> 
>> However, the most likely explanation is that the filename is correct
>> and that the OP is not using Python 3 as he claims but Python 2.
>> 
>> Yes, it took that long for me to realise ;) Python 2 is slowly
>> sinking into oblivion...
>> 
> 
> 
> 


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


Re: os.walk the apostrophe and unicode

2017-06-25 Thread Rod Person
On Sun, 25 Jun 2017 08:18:45 -0600
Michael Torrie  wrote:

> On 06/25/2017 06:19 AM, Rod Person wrote:
> > But doing a simple ls of that directory show it is unicode but the
> > replacement of the offending character.
> > 
> > http://rodperson.com/graphics/uc/ls.png  
> 
> Now that is really strange.  Your OS seems to not recognize that the
> filename is in UTF-8.  I suspect this has something to do with the NAS
> file sharing protocol (smb). Though I'm pretty sure that Samba can
> handle UTF-8 filenames correctly.
> 
> > I am in fact using Python 3.5. I may be lacking in unicode skills
> > but I do have the sense enough to know the version of Python I am
> > invoking. So I included this screenshot of that so the version of
> > Python and the files list returned by os.walk
> > 
> > http://rodperson.com/graphics/uc/files.png  
> 
> If I create a file that has the U+2019 character in it on my Linux
> machine (BtrFS), and do os.walk on it, I see the character in then
> string properly.  So it looks like Python does the right thing,
> automatically decoding from UTF-8.
> 
> In your situation I think the problem is the file sharing protocol
> that your NAS is using. Somehow some information is being lost and
> your OS does not know that the filenames are in UTF-8, and just
> thinks they are bytes. And therefore Python doesn't know to decode
> the string, so you just end up with each byte being converted to a
> unicode code point and being shoved into the unicode string.
> 
> How to get around this issue I don't know.  Maybe there's a way to
> convert the unicode string to bytes using the value of each character,
> and then decode that back to unicode.

I think you theory is on the correct path. I'm actually attached to the
NAS via NFS not samba. And just quickly looking into that it seems the
NFS server needs and option set to pass unicode correctly...but my NAS
software doesn't allow my access to settings only to turn it on or off.

Looks like my option is the original correct the file name.


-- 
Rod

http://www.rodperson.com

Who at Clitorius fountain thirst remove 
Loath Wine and, abstinent, meer Water love.

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


Fwd: Unable to convert pandas object to string

2017-06-25 Thread Paul Barry
Forgot to include this reply to the list (as others may want to comment).

-- Forwarded message --
From: Paul Barry 
Date: 24 June 2017 at 12:21
Subject: Re: Unable to convert pandas object to string
To: Bhaskar Dhariyal 


Note that .info(), according to its docs, gives you a "Concise summary of a
DataFrame".  Everything is an object in Python, including strings, so the
output from .info() is technically correct (but maybe not very helpful in
your case).

As I've shown, we can work out that the data you want to work with is in
fact a string, so I've added some code to my notebook to show you how to
tokenize the first row of data.  This should get you started on doing this
to the rest of your data.

Note, too, that some of the data in these specific columns contains
something other than a string, so you'll need to clean up that first (see
the end of the updated notebook, attached, for how I worked out that this
was indeed the case).

I hope this all helps.

Paul.



On 24 June 2017 at 11:31, Bhaskar Dhariyal 
wrote:

> The data type showing there is object. In[4] in the first page. I wanted
> to tokenize the name & desc column and clean it
>
>
> On Sat, Jun 24, 2017 at 3:54 PM, Paul Barry 
> wrote:
>
>> Hi Bhaskar.
>>
>> Please see attached PDF of a small Jupyter notebook.  As you'll see, the
>> data in the fields you mentioned are *already* strings.  What is it you are
>> trying to do here?
>>
>> Paul.
>>
>> On 24 June 2017 at 10:51, Bhaskar Dhariyal 
>> wrote:
>>
>>> ​
>>>  train.csv
>>> 
>>> ​here it is thanks for quick reply
>>>
>>> On Sat, Jun 24, 2017 at 3:14 PM, Paul Barry 
>>> wrote:
>>>
 Any chance you could post one line of data so we can see what we have
 to work with?

 Also - have you taken a look at Jake VanderPlas's notebooks? There's
 lot of help with pandas to be found there: https://github.com/jake
 vdp/PythonDataScienceHandbook

 Paul.

 On 24 June 2017 at 10:32, Bhaskar Dhariyal 
 wrote:

> 
> Int64Index: 171594 entries, 0 to 63464
> Data columns (total 7 columns):
> project_id  171594 non-null object
> desc171594 non-null object
> goal171594 non-null float64
> keywords171594 non-null object
> diff_creat_laun 171594 non-null int64
> diff_laun_status171594 non-null int64
> diff_status_dead171594 non-null int64
> dtypes: float64(1), int64(3), object(3)
>
> not able to convert desc and keywords to string for preprocessing.
> Tried astype(str). Please help
> --
> https://mail.python.org/mailman/listinfo/python-list
>



 --
 Paul Barry, t: @barrypj  - w:
 http://paulbarry.itcarlow.ie - e: paul.ba...@itcarlow.ie
 Lecturer, Computer Networking: Institute of Technology, Carlow, Ireland.

>>>
>>>
>>
>>
>> --
>> Paul Barry, t: @barrypj  - w:
>> http://paulbarry.itcarlow.ie - e: paul.ba...@itcarlow.ie
>> Lecturer, Computer Networking: Institute of Technology, Carlow, Ireland.
>>
>
>


-- 
Paul Barry, t: @barrypj  - w:
http://paulbarry.itcarlow.ie - e: paul.ba...@itcarlow.ie
Lecturer, Computer Networking: Institute of Technology, Carlow, Ireland.



-- 
Paul Barry, t: @barrypj  - w:
http://paulbarry.itcarlow.ie - e: paul.ba...@itcarlow.ie
Lecturer, Computer Networking: Institute of Technology, Carlow, Ireland.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Checking for an exception

2017-06-25 Thread Steve D'Aprano
On Sun, 25 Jun 2017 05:50 pm, Paul Rubin wrote:

> Steve D'Aprano  writes:
>> What's the right/best way to test whether an object is an exception
>> ahead of time? (That is, without trying to raise from it.)
> 
> Maybe I'm missing something but
>isinstance(obj, Exception)
> seems to work.

Not well enough I'm afraid:



py> isinstance(KeyboardInterrupt(), Exception)
False
py> isinstance(ValueError, Exception)
False





-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.

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


Re: Checking for an exception

2017-06-25 Thread Skip Montanaro
>
> py> isinstance(KeyboardInterrupt(), Exception)
> False
> py> isinstance(ValueError, Exception)
> False
>

I might have missed something, but don't you want to be using BaseException
as your class/type? Also, Checking isinstance() between two classes isn't
likely to work, I don't think.

Both the 2.7 and 3.6 docs indicate that BaseException is the base class for
all built-in exceptions:

https://docs.python.org/2/library/exceptions.html
https://docs.python.org/3/library/exceptions.html

Of course, YMMV when dealing with user-defined exception classes.

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


Re: Checking for an exception

2017-06-25 Thread D'Arcy Cain

On 06/25/17 12:10, Steve D'Aprano wrote:

py> isinstance(KeyboardInterrupt(), Exception)
False
py> isinstance(ValueError, Exception)
False


That's because KeyboardInterrupt is not a subclass of Exception.  If you 
want to catch that as well you need to check against BaseException.


https://docs.python.org/3.6/library/exceptions.html#exception-hierarchy

--
D'Arcy J.M. Cain
Vybe Networks Inc.
http://www.VybeNetworks.com/
IM:da...@vex.net VoIP: sip:da...@vybenetworks.com
--
https://mail.python.org/mailman/listinfo/python-list


exception_guard context manager and decorator

2017-06-25 Thread Steve D'Aprano
As discussed in the Python-Ideas mailing list, sometimes we want to suppress a
particular kind of exception and replace it with another.

For that reason, I'd like to announce exception_guard, a context manager and
decorator which catches specified exceptions and replaces them with a given
exception (RuntimeError by default).

https://code.activestate.com/recipes/580808-guard-against-an-exception-in-the-wrong-place/

or just

https://code.activestate.com/recipes/580808


It should work with Python 2.6 through 3.6 and later.

try:
with exception_guard(ZeroDivisionError):
1/0  # raises ZeroDivisionError
except RuntimeError:
print ('ZeroDivisionError replaced by RuntimeError')


See the recipe on ActiveState for links to discussions on Python-Ideas.




-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.

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


Re: Checking for an exception

2017-06-25 Thread Steve D'Aprano
On Mon, 26 Jun 2017 02:40 am, Skip Montanaro wrote:

>> py> isinstance(KeyboardInterrupt(), Exception)
>> False
>> py> isinstance(ValueError, Exception)
>> False
>>
> 
> I might have missed something, but don't you want to be using BaseException
> as your class/type? 

Yes I do, which is why I was demonstrating to Paul that his suggestion to use
Exception instead of BaseException is not good enough.

*wink*

> Also, Checking isinstance() between two classes isn't 
> likely to work, I don't think.

Indeed it doesn't, which is why I was demonstrating that Paul's suggestion to
use isinstance instead of issubclass is not good enough.

*wink*


> Both the 2.7 and 3.6 docs indicate that BaseException is the base class for
> all built-in exceptions:

Indeed it is. Which is why in my original post I used BaseException.

*eye spasms from winking too much*


> https://docs.python.org/2/library/exceptions.html
> https://docs.python.org/3/library/exceptions.html
> 
> Of course, YMMV when dealing with user-defined exception classes.

No, user-defined exceptions must derive from BaseException too.




-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.

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


Re: comp.lang.python killfile rule

2017-06-25 Thread Mirage Web Studio
Just felt like posting, wouldn't it be pythonic if it was
if word in [list]:
ignore

Save time and easily maintainable

Cmg

On 23 Jun 2017 02:41, "John Black"  wrote:

All, in case this is useful to anyone, this rule that tells my newsreader
which posts to kill really cleans up the group.  I could not find a way
to key off of anything in the header except keywords because the From
keeps changing and I didn't want to overkill real posts.  I may have to
add a thing or two to this over time, but right now, this seems to be
nailing everything.

John Black

Subject contains "PEDOFILO"
Or
Subject contains "MAI"
Or
Subject contains "SEGRETO"
Or
Subject contains "SETTA"
Or
Subject contains "BAMBINI"
Or
Subject contains "FIGLIO"
Or
Subject contains "PAOLO"
Or
Subject contains "NATALE"
Or
Subject contains "SONO"
Or
Subject contains "GRAZIA"
Or
Subject contains "PORNOSTAR"
Or
Subject contains "PEZZO"
Or
Subject contains "MERDA"
Or
Subject contains "CAZZO"
Or
Subject contains "GALERA"
Or
Subject contains "SICARIO"
Or
Subject contains "ESSERE"
Or
Subject contains "CRIMINALE"
Or
Subject contains "LECCA"
Or
Subject contains "COCAINA"
Or
Subject contains "LESBICA"
Or
Subject contains "NESSUNO"
Or
Subject contains "MAFIOSO"
Or
Subject contains "BERLUSCONI"
Or
Subject contains ""
Or
Subject contains "HARDCORE"
Or
Subject contains "PEDERASTA"
Or
Subject contains "CULO"
Or
Subject contains "NOSTRA"
Or
Subject contains "FOGLIO"
Or
Subject contains "USARE"
Or
Subject contains "FAMIGLIA"
Or
Subject contains "FECE"
Or
Subject contains "CAPO"
Or
Subject contains "SUICIDARE"
Or
Subject contains "OGNI"
Or
Subject contains "CANE"
Or
Subject contains "MERCATO"
Or
Subject contains "VOLTA"
Or
Subject contains "MAFIOSA"
Or
Subject contains "ALMENO"
Or
Subject contains "BASTARDO"
Or
Subject contains "FIGLIA"
Or
Subject contains "BASTARD"
Or
Subject contains "CRIMINAL"
Or
Subject contains "ANNI"
Or
Subject contains "PEDINA"
--
https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: comments and the continuation prompt

2017-06-25 Thread Steve D'Aprano
On Mon, 26 Jun 2017 08:44 am, Stefan Ram wrote:

>   When I enter »12\«, I get a continuation prompt in the
>   Python 3.6 console:
> 
 12\
> ...
> 
>   . I thought that this might indicate that the logical line
>   is not terminated yet.

No. You get the level 2 prompt (sys.ps2) for a number of reasons:

- after statements that require a block (def, class, if, while, for, 
  with, try, and any others I have missed);

- in triple-quoted strings;

- bracketed expressions which haven't been closed yet ( [ { 

- after comments.

 
>   According to The Python Language Reference Release 3.6.0,
>   2.1.3 Comments, »A comment signifies the end of the logical
>   line unless the implicit line joining rules are invoked.«.
> 
>   So, why do I get a continuation prompt when I enter a comment?

Why not? As far as the interactive interpreter is concerned, you haven't yet
entered a statement.



-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.

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


Re: comments and the continuation prompt

2017-06-25 Thread Ben Finney
Steve D'Aprano  writes:

> On Mon, 26 Jun 2017 08:44 am, Stefan Ram wrote:
>
> >   According to The Python Language Reference Release 3.6.0, 2.1.3
> >   Comments, »A comment signifies the end of the logical line unless
> >   the implicit line joining rules are invoked.«.
> > 
> >   So, why do I get a continuation prompt when I enter a comment?
>
> Why not? As far as the interactive interpreter is concerned, you
> haven't yet entered a statement.

And yet, according to the Language Reference, the logical line has ended
and another begun.

So I think the question is worth exploring: Why does the interactive
prompt imply the logical line is continuing, when the Language Reference
would say otherwise?

Maybe the answer is “the continuation prompt does not prompt for the
continuation of a logical line, but the continuation of ”.

What exactly goes in the “” placeholder; that is,
exactly what should the user understand by that transition from one
prompt to a different one?

-- 
 \   “Philosophy is questions that may never be answered. Religion |
  `\  is answers that may never be questioned.” —anonymous |
_o__)  |
Ben Finney

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


GUI Designer[s]

2017-06-25 Thread Edward Montague
 I've become a bit more familiar with wxglade , wxFormBuilder and to a
lesser extent BoaConstructor.

 There are however numerous other possiblities and
extensions .
  I'd like to eventually have 3D graphics within an
application constructed through a GUI Designer ;
preferably with quality approaching or exceeding that
of MayaVI2.

 Is there any project underway to meld the plethora
of possibilties into something more comprehensive as
a GUI Designer.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: GUI Designer[s]

2017-06-25 Thread Ben Finney
Edward Montague  writes:

>   I'd like to eventually have 3D graphics within an application

For that requirement, your application will need to make use of a
library for presenting and interacting with 3D objects.

To my knowledge there is no such thing in the standard library, so
you'll need to bring in a third-party distribution for that.

> constructed through a GUI Designer ; preferably with quality
> approaching or exceeding that of MayaVI2.

I haven't used Blender https://www.blender.org/> for a separate
Python program, but I know that people like its Python API
https://docs.blender.org/manual/en/dev/advanced/scripting/introduction.html>.

-- 
 \   “Most people are other people. Their thoughts are someone |
  `\  else’s opinions, their lives a mimicry, their passions a |
_o__)   quotation.” —Oscar Wilde, _De Profundis_, 1897 |
Ben Finney

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


Re: comments and the continuation prompt

2017-06-25 Thread Terry Reedy

On 6/25/2017 11:32 PM, Ben Finney wrote:

Steve D'Aprano  writes:


On Mon, 26 Jun 2017 08:44 am, Stefan Ram wrote:


   According to The Python Language Reference Release 3.6.0, 2.1.3
   Comments, »A comment signifies the end of the logical line unless
   the implicit line joining rules are invoked.«.

   So, why do I get a continuation prompt when I enter a comment?


In IDLE, you don't.

>>> #
>>> #sjflksj
>>>

Maybe this was once true for the interactive interpreter and changed. 
Or maybe this is buglet in IDLE in terms of imitating the console 
interpreter.  I have no idea.



Why not? As far as the interactive interpreter is concerned, you
haven't yet entered a statement.


And yet, according to the Language Reference, the logical line has ended
and another begun.

So I think the question is worth exploring: Why does the interactive
prompt imply the logical line is continuing, when the Language Reference
would say otherwise?

Maybe the answer is “the continuation prompt does not prompt for the
continuation of a logical line, but the continuation of ”.

What exactly goes in the “” placeholder; that is,
exactly what should the user understand by that transition from one
prompt to a different one?


Look into the behavior of compile('code', 'fake', 'single').


--
Terry Jan Reedy


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