Re: Checking for an exception

2017-06-24 Thread Cameron Simpson
On 25Jun2017 13:47, Ben Finney wrote: Steve D'Aprano writes: […] the result of passing a non-exception to raise is to raise an exception, so I cannot trivially distinguish between "caller passes an exception" and "caller passes a non-exception" (result is still an exception). Yes, hence my c

Re: environment variable

2017-06-24 Thread Cameron Simpson
On 24Jun2017 21:31, Gene Heskett wrote: On Saturday 24 June 2017 21:03:18 Steve D'Aprano wrote: On Sun, 25 Jun 2017 08:39 am, Gene Heskett wrote: > On Saturday 24 June 2017 16:49:25 Smith wrote: >> Hello to all, >> I wanted to ask you how I could delete a line of an environment >> variable (PAT

Re: Checking for an exception

2017-06-24 Thread Ben Finney
Steve D'Aprano writes: > […] the result of passing a non-exception to raise is to raise an > exception, so I cannot trivially distinguish between "caller passes an > exception" and "caller passes a non-exception" (result is still an > exception). Yes, hence my characterising this problem as the

Re: environment variable

2017-06-24 Thread Gene Heskett
On Saturday 24 June 2017 21:03:18 Steve D'Aprano wrote: > On Sun, 25 Jun 2017 08:39 am, Gene Heskett wrote: > > On Saturday 24 June 2017 16:49:25 Smith wrote: > >> Hello to all, > >> I wanted to ask you how I could delete a line of an environment > >> variable (PATH) > > [...] > > > export PATH= >

Re: Checking for an exception

2017-06-24 Thread Steve D'Aprano
On Sun, 25 Jun 2017 10:49 am, Ben Finney 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.) > > This being Python, it is Easier to Ask for Forgiveness than for > Permission. Some

Re: Checking for an exception

2017-06-24 Thread Steve D'Aprano
On Sun, 25 Jun 2017 09:37 am, Cameron Simpson wrote: > On 24Jun2017 20:31, Steve D'Aprano wrote: >>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.) >> >>I have: >> >>return (isinstance(obj, type) and issubclass(obj, B

Re: environment variable

2017-06-24 Thread Steve D'Aprano
On Sun, 25 Jun 2017 08:39 am, Gene Heskett wrote: > On Saturday 24 June 2017 16:49:25 Smith wrote: > >> Hello to all, >> I wanted to ask you how I could delete a line of an environment >> variable (PATH) [...] > export PATH= > > but be prepared to type the full path to anything you want to run.

Re: os.walk the apostrophe and unicode

2017-06-24 Thread Steve D'Aprano
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... -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure e

Re: Checking for an exception

2017-06-24 Thread Ben Finney
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.) This being Python, it is Easier to Ask for Forgiveness than for Permission. The corollary of that is, if you try to ask permission first (to

Re: Checking for an exception

2017-06-24 Thread Cameron Simpson
On 24Jun2017 20:31, Steve D'Aprano wrote: 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.) I have: return (isinstance(obj, type) and issubclass(obj, BaseException) or isinstance(obj, BaseException)) I haven'

Re: environment variable

2017-06-24 Thread Gene Heskett
On Saturday 24 June 2017 16:49:25 Smith wrote: > Hello to all, > I wanted to ask you how I could delete a line of an environment > variable (PATH) > > ~/Scaricati/pycharm-2017.1.4/bin$ echo $PATH | sed s/:/'\n'/g > /usr/local/sbin > /usr/local/bin > /usr/sbin > /usr/bin > /sbin > /bin > /usr/games

Re: environment variable

2017-06-24 Thread Michael F. Stemper
On 2017-06-24 15:49, Smith wrote: Hello to all, I wanted to ask you how I could delete a line of an environment variable (PATH) ~/Scaricati/pycharm-2017.1.4/bin$ echo $PATH | sed s/:/'\n'/g /usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin /usr/games /usr/local/games /snap/bin /path

Re: os.walk the apostrophe and unicode

2017-06-24 Thread Peter Otten
Rod Person wrote: > On Sat, 24 Jun 2017 21:28:45 +0200 > Peter Otten <__pete...@web.de> wrote: > >> Rod Person wrote: >> >> > Hi, >> > >> > I'm working on a program that will walk a file system and clean the >> > id3 tags of mp3 and flac files, everything is working great until >> > the follow

environment variable

2017-06-24 Thread Smith
Hello to all, I wanted to ask you how I could delete a line of an environment variable (PATH) ~/Scaricati/pycharm-2017.1.4/bin$ echo $PATH | sed s/:/'\n'/g /usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin /usr/games /usr/local/games /snap/bin /path/to/my/program ---> linea da elimi

Re: os.walk the apostrophe and unicode

2017-06-24 Thread MRAB
On 2017-06-24 20:47, Rod Person wrote: On Sat, 24 Jun 2017 13:28:55 -0600 Michael Torrie wrote: On 06/24/2017 12:57 PM, Rod Person wrote: > Hi, > > I'm working on a program that will walk a file system and clean the > id3 tags of mp3 and flac files, everything is working great until > the fo

Re: os.walk the apostrophe and unicode

2017-06-24 Thread Andre Müller
Can os.fsencode and os.fsdecode help? I've seen it somewhere. I've never used it. To fix encodings, sometimes I use the module ftfy Greetings Andre -- https://mail.python.org/mailman/listinfo/python-list

Re: os.walk the apostrophe and unicode

2017-06-24 Thread Rod Person
On Sat, 24 Jun 2017 13:28:55 -0600 Michael Torrie wrote: > On 06/24/2017 12:57 PM, Rod Person wrote: > > Hi, > > > > I'm working on a program that will walk a file system and clean the > > id3 tags of mp3 and flac files, everything is working great until > > the follow file is found > > > > '06

Re: os.walk the apostrophe and unicode

2017-06-24 Thread Rod Person
On Sat, 24 Jun 2017 21:28:45 +0200 Peter Otten <__pete...@web.de> wrote: > Rod Person wrote: > > > Hi, > > > > I'm working on a program that will walk a file system and clean the > > id3 tags of mp3 and flac files, everything is working great until > > the follow file is found > > > > '06 - Tod

Re: os.walk the apostrophe and unicode

2017-06-24 Thread Peter Otten
Rod Person wrote: > Hi, > > I'm working on a program that will walk a file system and clean the id3 > tags of mp3 and flac files, everything is working great until the > follow file is found > > '06 - Todd's Song (Post-Spiderland Song in Progress).flac' > > for some reason that I can't understa

Re: os.walk the apostrophe and unicode

2017-06-24 Thread Michael Torrie
On 06/24/2017 12:57 PM, Rod Person wrote: > Hi, > > I'm working on a program that will walk a file system and clean the id3 > tags of mp3 and flac files, everything is working great until the > follow file is found > > '06 - Todd's Song (Post-Spiderland Song in Progress).flac' > > for some reaso

Re: os.walk the apostrophe and unicode

2017-06-24 Thread MRAB
On 2017-06-24 19:57, Rod Person wrote: Hi, I'm working on a program that will walk a file system and clean the id3 tags of mp3 and flac files, everything is working great until the follow file is found '06 - Todd's Song (Post-Spiderland Song in Progress).flac' for some reason that I can't unde

Re: os.walk the apostrophe and unicode

2017-06-24 Thread John Ladasky
On Saturday, June 24, 2017 at 12:07:05 PM UTC-7, Rod Person wrote: > Hi, > > I'm working on a program that will walk a file system and clean the id3 > tags of mp3 and flac files, everything is working great until the > follow file is found > > '06 - Todd's Song (Post-Spiderland Song in Progress).

Re: os.walk the apostrophe and unicode

2017-06-24 Thread alister
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. -- "If you understand what you're doing, you're not learning anything." --

os.walk the apostrophe and unicode

2017-06-24 Thread Rod Person
Hi, I'm working on a program that will walk a file system and clean the id3 tags of mp3 and flac files, everything is working great until the follow file is found '06 - Todd's Song (Post-Spiderland Song in Progress).flac' for some reason that I can't understand os.walk() returns this file name a

Re: New to Python - Career question

2017-06-24 Thread J. Clarke
In article , larry.mart...@gmail.com says... > > On Tue, Jun 6, 2017 at 6:37 PM, Marko Rauhamaa wrote: > > pta...@gmail.com: > > > >> New to Python and have been at it for about a month now. I'm doing > >> well and like it very much. Considering a career change down the road > >> and have been w

Fw: Unable to convert pandas object to string

2017-06-24 Thread Albert-Jan Roskam
From: Albert-Jan Roskam Sent: Saturday, June 24, 2017 11:26:26 AM To: Paul Barry Subject: Re: Unable to convert pandas object to string (sorry for top posting) Try using fillna('') to convert np.nan into empty strings. df['desc'] = df.desc.fillna(''). Btw, np.ob

Re: Best way to ensure user calls methods in correct order?

2017-06-24 Thread Thomas Nyberg
On 06/24/2017 11:53 AM, Thomas Jollans wrote: > If the data is modified in-place, maybe it makes sense to to use a class > like the one you have, but then it's a bit bizarre to make your methods > create an artificial side effect (self._a_dirty) - why don't you simply > check for the actual effect

Re: Checking for an exception

2017-06-24 Thread Steve D'Aprano
On Sat, 24 Jun 2017 09:23 pm, mbyrne...@gmail.com wrote: > On Saturday, June 24, 2017 at 11:31:11 AM UTC+1, Steve D'Aprano wrote: >> 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.) >> >> I have: >> >> return (isins

Re: how to write add frequency in particular file by reading a csv file and then making a new file of multiple csv file by adding frequency

2017-06-24 Thread mbyrnepr2
On Thursday, June 22, 2017 at 12:16:28 PM UTC+1, kishan.samp...@gmail.com wrote: > I want to write a common file in which It can add the frequency by adding > multiple csv file and if the same words are repeated in python then it should > add the frequency in the common file can any one help me p

Re: Unable to convert pandas object to string

2017-06-24 Thread Paul Barry
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 >

how to write add frequency in particular file by reading a csv file and then making a new file of multiple csv file by adding frequency

2017-06-24 Thread Mark Byrne
A problem (possibly the problem) is the lines which use the get function: count = frequency.get(word,0) Since the dictionary is empty at the start of the loop, the get function is passing a value of 0 to count and count1. The subsequent updates to the dictionary are applying a value of zero As a

Re: Checking for an exception

2017-06-24 Thread mbyrnepr2
On Saturday, June 24, 2017 at 11:31:11 AM UTC+1, Steve D'Aprano wrote: > 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.) > > I have: > > return (isinstance(obj, type) and issubclass(obj, BaseException) > or i

Checking for an exception

2017-06-24 Thread Steve D'Aprano
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.) I have: return (isinstance(obj, type) and issubclass(obj, BaseException) or isinstance(obj, BaseException)) Any better ideas? -- Steve “Cheer up,” they said

Re: Best way to ensure user calls methods in correct order?

2017-06-24 Thread Thomas Jollans
On 22/06/17 17:31, Thomas Nyberg wrote: > Thanks for the response! I see the reasoning, but I can't entirely > square it with what I'm thinking. Probably it's either because I was > hiding some of my intention (sorry if I wasted your time due to lack of > details) or that I'm naive and regardless o

Re: Unable to convert pandas object to string

2017-06-24 Thread Paul Barry
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/jakevdp/PythonDataScienceHandbook Paul. On 24 June 2017 at 10:32, Bhaskar Dhariya

Unable to convert pandas object to string

2017-06-24 Thread Bhaskar Dhariyal
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_st