[Tutor] Trouble in dealing with special characters.

2018-12-07 Thread Sunil Tech
Hi Tutor, I have a trouble with dealing with special characters in Python Below is the sentence with a special character(apostrophe) "MOUNTAIN VIEW WOMEN’S HEALTH CLINIC" with actually should be "MOUNTAIN VIEW WOMEN'S HEALTH CLINIC ". Please help, how to identify these kinds of special characters

Re: [Tutor] Regarding Python api script

2018-12-07 Thread Avi Gross
I left the "subject" above to be the same, as requested. The actual subject might have been "Pythonic variable name use" Alan says he had a challenge evaluating code (below) because the same variable names were reused and it made me wonder if the python community has general ideas about name re-u

[Tutor] playing sound files in python

2018-12-07 Thread nathan tech
Hello all! My name is nate, and I am relatively new to this list, relatively being just signed up. I have a question that you would think would be obvious, but alas I have struggled to figure out. How do I play sound files in python. More specificly, I want to play ogg files especially, with

Re: [Tutor] Trouble in dealing with special characters.

2018-12-07 Thread Alan Gauld via Tutor
On 07/12/2018 07:58, Sunil Tech wrote: > I have a trouble with dealing with special characters in Python Below is > the sentence with a special character(apostrophe) "MOUNTAIN VIEW WOMEN’S > HEALTH CLINIC" with actually should be "MOUNTAIN VIEW WOMEN'S HEALTH CLINIC > ". How do you define "specia

Re: [Tutor] Trouble in dealing with special characters.

2018-12-07 Thread Sunil Tech
Hi Alan, I am using Python 2.7.8 >>> tx = "MOUNTAIN VIEW WOMEN’S HEALTH CLINIC" >>> tx.decode() Traceback (most recent call last): File "", line 1, in UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 19: ordinal not in range(128) How to know whether in a given string(senten

Re: [Tutor] Trouble in dealing with special characters.

2018-12-07 Thread Alan Gauld via Tutor
On 07/12/2018 08:36, Sunil Tech wrote: > I am using Python 2.7.8 tx = "MOUNTAIN VIEW WOMEN’S HEALTH CLINIC" tx.decode() > Traceback (most recent call last): > File "", line 1, in > UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 19: > ordinal not in range(128) >

Re: [Tutor] Trouble in dealing with special characters.

2018-12-07 Thread Steven D'Aprano
On Fri, Dec 07, 2018 at 01:28:18PM +0530, Sunil Tech wrote: > Hi Tutor, > > I have a trouble with dealing with special characters in Python There are no special characters in Python. There are only Unicode characters. All characters are Unicode, including those which are also ASCII. Start her

Re: [Tutor] Trouble in dealing with special characters.

2018-12-07 Thread Steven D'Aprano
On Fri, Dec 07, 2018 at 02:06:16PM +0530, Sunil Tech wrote: > Hi Alan, > > I am using Python 2.7.8 That is important information. Python 2 unfortunately predates Unicode, and when it was added some bad decisions were made. For example, we can write this in Python 2: >>> txt = "abcπ" but it is

Re: [Tutor] playing sound files in python

2018-12-07 Thread Steven D'Aprano
On Fri, Dec 07, 2018 at 02:17:55AM +, nathan tech wrote: > Hello all! > > My name is nate, and I am relatively new to this list, relatively being > just signed up. > > I have a question that you would think would be obvious, but alas I have > struggled to figure out. > > How do I play soun

Re: [Tutor] Regarding Python api script

2018-12-07 Thread Steven D'Aprano
On Thu, Dec 06, 2018 at 09:13:01PM -0500, Avi Gross wrote: > But so much code I see in python does not only reuse the same variable names > but in a confusing way. > > file = "some name" > file = open(file, "r") > file = some_wrapper(file) I agree this is confusing: you have the same name, "fil

Re: [Tutor] Trouble in dealing with special characters.

2018-12-07 Thread Mats Wichmann
On 12/7/18 3:20 AM, Steven D'Aprano wrote: >> How to know whether in a given string(sentence) is there any that is not >> ASCII character and how to replace? > > That's usually the wrong solution. That's like saying, "My program can't > add numbers greater than 100. How do I tell if a number is

[Tutor] unzip and connect to Oracle database

2018-12-07 Thread Asad
Hi All , I would like to unzip a file using python and then execute the sql scripts in the file on Oracle database . >>> from zipfile import ZipFile >>> file_name = 'file.zip' >>> z = ZipFile(file_name) >>> print(z.namelist()) [] >>> z = ZipFile('file.zip') >>> print z.namelist() [] >>

Re: [Tutor] Regarding Python api script

2018-12-07 Thread Avi Gross
[[ Real SUBJECT: emulating decorators ]] Steven, I am not suggesting that a particular way of reusing a name is a good idea. I am asking if some ways are encouraged and others are discouraged in the python community. Just to clarify one point you asked about: # > I have often seen something l

Re: [Tutor] Regarding Python api script

2018-12-07 Thread Alan Gauld via Tutor
On 07/12/2018 02:13, Avi Gross wrote: > Alan says he had a challenge evaluating code (below) because the same > variable names were reused It wasn't the reuse per se but the generic nature of the names combined with reuse. Reusing names like i,j,k for simple integer indices etc is not a problem.

Re: [Tutor] unzip and connect to Oracle database

2018-12-07 Thread Alan Gauld via Tutor
On 07/12/2018 14:00, Asad wrote: > Hi All , > > I would like to unzip a file using python and then execute the sql > scripts in the file on Oracle database . Are you absolutely sure? That's a very dangerous thing to do from a security point of view. Potentially similar to using exec() o

Re: [Tutor] Regarding Python api script

2018-12-07 Thread Steven D'Aprano
On Fri, Dec 07, 2018 at 05:59:22PM +, Alan Gauld via Tutor wrote: [...] > > ... In languages without garbage collection, reusing > > the same name, like "index" repeatedly might save some > > small amount of space. > > Garbage collection only helps if the variable loses > its assignment. If

Re: [Tutor] Regarding Python api script

2018-12-07 Thread Steven D'Aprano
On Fri, Dec 07, 2018 at 12:30:18PM -0500, Avi Gross wrote: > # > I have often seen something like this done with methods, such as to > # > emulate decorator functionality where a method is created in an > # > object with a name > # > and the very next method created has the same name with the