Re: Where is 'palindrome' defined?

2015-06-02 Thread John Ladasky
On Monday, June 1, 2015 at 2:22:02 AM UTC-7, Marko Rauhamaa wrote:

 Sota-apina nakataan raastimeen.
   Apelle pane emit.
   Saarnaa takanani paatos.
 
 (= The war monkey will be chucked into a grater.
 Hand the pistils to father-in-law.
 Pathos does preach behind me.)

With this post, you have convinced me that 1) Finnish is a very interesting, 
and even poetic, language; and that 2) eating the velvet off of reindeer 
antlers must have a very similar effect to LSD.  :^)


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


Re: Where is 'palindrome' defined?

2015-06-02 Thread Marko Rauhamaa
John Ladasky john_lada...@sbcglobal.net:

 On Monday, June 1, 2015 at 2:22:02 AM UTC-7, Marko Rauhamaa wrote:

 Sota-apina nakataan raastimeen.
   Apelle pane emit.
   Saarnaa takanani paatos.
 
 (= The war monkey will be chucked into a grater.
 Hand the pistils to father-in-law.
 Pathos does preach behind me.)

 With this post, you have convinced me that 1) Finnish is a very
 interesting, and even poetic, language; and that 2) eating the velvet
 off of reindeer antlers must have a very similar effect to LSD. :^)

The phonetic structure of Finnish is ideal for palindromes, unlike
English.


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


Where is 'palindrome' defined?

2015-06-01 Thread fl
Hi,

When I search solution of reverse a string/number, I came across a short
function online:

 def palindrome(num):
return str(num) == str(num)[::-1]

I thought that it is a general function. And with the following variable:

 a
'1234_'

 parlindrome(a)

Traceback (most recent call last):
  File pyshell#126, line 1, in module
parlindrome(a)
NameError: name 'parlindrome' is not defined


Then, I find that parlindrome is a special checking mirrored word.
I use Python 2.7.9. Why does the error message show   

name 'parlindrome' is not defined



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


Re: Where is 'palindrome' defined?

2015-06-01 Thread Gary Herron

On 05/31/2015 09:46 PM, fl wrote:

Hi,

When I search solution of reverse a string/number, I came across a short
function online:


def palindrome(num):

return str(num) == str(num)[::-1]

I thought that it is a general function. And with the following variable:


No, this  function is not built into Python because  ...  Well it's hard 
to say why.  It's not very general, or not useful to many programmers, 
or nobody's thought about it or made a case for including it in Python, etc.


But that should be no problem.  You can define it yourself (by entering 
the two line you have above).  Then it will be defined, and calling

parlindrome('...')
will produce a result rather than an error.

Gary Herron





a

'1234_'


parlindrome(a)

Traceback (most recent call last):
   File pyshell#126, line 1, in module
 parlindrome(a)
NameError: name 'parlindrome' is not defined


Then, I find that parlindrome is a special checking mirrored word.
I use Python 2.7.9. Why does the error message show

name 'parlindrome' is not defined



Thanks,



--
Dr. Gary Herron
Department of Computer Science
DigiPen Institute of Technology
(425) 895-4418

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


Re: Where is 'palindrome' defined?

2015-06-01 Thread David Palao
Hi,
Because palindrome != parlindrome?
Have you read the error message? Did you try to understand it?

Best

2015-06-01 6:46 GMT+02:00 fl rxjw...@gmail.com:
 Hi,

 When I search solution of reverse a string/number, I came across a short
 function online:

 def palindrome(num):
 return str(num) == str(num)[::-1]

 I thought that it is a general function. And with the following variable:

 a
 '1234_'

 parlindrome(a)

 Traceback (most recent call last):
   File pyshell#126, line 1, in module
 parlindrome(a)
 NameError: name 'parlindrome' is not defined


 Then, I find that parlindrome is a special checking mirrored word.
 I use Python 2.7.9. Why does the error message show

 name 'parlindrome' is not defined



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


Re: Where is 'palindrome' defined?

2015-06-01 Thread Larry Hudson via Python-list

On 05/31/2015 09:46 PM, fl wrote:

Hi,

When I search solution of reverse a string/number, I came across a short
function online:


def palindrome(num):

return str(num) == str(num)[::-1]

I thought that it is a general function. And with the following variable:


a

'1234_'


parlindrome(a)


Traceback (most recent call last):
   File pyshell#126, line 1, in module
 parlindrome(a)
NameError: name 'parlindrome' is not defined


Then, I find that parlindrome is a special checking mirrored word.
I use Python 2.7.9. Why does the error message show

name 'parlindrome' is not defined



Thanks,


Don't be embarrassed, everybody does this:  You're blind to your own typos...

You define palindrome() then call parlindrome() -- with an extra 'r'.

 -=- Larry -=-

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


Re: Where is 'palindrome' defined?

2015-06-01 Thread Omar Abou Mrad
On Mon, Jun 1, 2015 at 7:46 AM, fl rxjw...@gmail.com wrote:

 Hi,

 When I search solution of reverse a string/number, I came across a short
 function online:

  def palindrome(num):
 return str(num) == str(num)[::-1]

 I thought that it is a general function. And with the following variable:

  a
 '1234_'

  parlindrome(a)

 Traceback (most recent call last):
   File pyshell#126, line 1, in module
 parlindrome(a)
 NameError: name 'parlindrome' is not defined

 snip


Further to the mentioned, be careful with your spelling, the function name
as you've shown is palindrome but you're invoking it using parlindrome.

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


Re: Where is 'palindrome' defined?

2015-06-01 Thread David Palao
2015-06-01 11:21 GMT+02:00 Marko Rauhamaa ma...@pacujo.net:
 David Palao dpalao.pyt...@gmail.com:

 Because palindrome != parlindrome?
 Have you read the error message? Did you try to understand it?

 When you are starting with any new thing, even the simplest problems
 look baffling. Once you have achieved a few successes, such error
 messages start to make sense.


I didn't intend to be harsh. Sorry if I failed.
Anyway, for me the errors provided by python are mostly very useful.
When I forget to read them, or I'm simply too impatient to try to
understand them, I use to get very hard debugging sessions. The
contrary is often true.
What I tried to emphasize is the importance of paying careful
attention to the error messages. It is a good habit to start doing
this from the beginning.

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


Re: Where is 'palindrome' defined?

2015-06-01 Thread Marko Rauhamaa
David Palao dpalao.pyt...@gmail.com:

 Because palindrome != parlindrome?
 Have you read the error message? Did you try to understand it?

When you are starting with any new thing, even the simplest problems
look baffling. Once you have achieved a few successes, such error
messages start to make sense.

 def palindrome(num):
 return str(num) == str(num)[::-1]

BTW, this simplistic function is not very practical for serious,
real-life palindromes. It does work for the naïve Finnish palindrome:

saippuakauppias
(= a soap merchant)

However, it fails to detect:

innostunut sonni
(= an enthusiastic bull)

let alone:

Sota-apina nakataan raastimeen.
  Apelle pane emit.
  Saarnaa takanani paatos.

(= The war monkey will be chucked into a grater.
Hand the pistils to father-in-law.
Pathos does preach behind me.)


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


Re: Where is 'palindrome' defined?

2015-06-01 Thread Grant Edwards
On 2015-06-01, Gary Herron gher...@digipen.edu wrote:
 On 05/31/2015 09:46 PM, fl wrote:
 Hi,

 When I search solution of reverse a string/number, I came across a short
 function online:

 def palindrome(num):
  return str(num) == str(num)[::-1]

 I thought that it is a general function. And with the following variable:

 No, this  function is not built into Python because...

Because writing a palindrome predicate is something that is only ever
done as a homework exercise in an introduction to programming class.
If it were part of the standard library, Python would not be
appropriate for such a class.

-- 
Grant Edwards   grant.b.edwardsYow! If Robert Di Niro
  at   assassinates Walter Slezak,
  gmail.comwill Jodie Foster marry
   Bonzo??
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Where is 'palindrome' defined?

2015-06-01 Thread Denis McMahon
On Sun, 31 May 2015 21:46:31 -0700, fl wrote:

 def palindrome(num):

Note carefully the spelling(1): palindrome

 parlindrome(a)

Note carefully the spelling(2): parlindrome

 NameError: name 'parlindrome' is not defined

Compare carefully spelling(1) and spelling(2).

palindrome is defined, pa_r_lindrome is not defined. The computer is not 
psychic yet, so it doesn't know that when you wrote pa_r_lindrome you 
meant palindrome, you have to spell it the same way every time for the 
computer to recognise that you mean the same name.

Now you also know that the error message:

NameError: name 'something' is not defined

means that you might have spelled something differently on the line in 
the error message to the word you meant, so next time you see this error 
message you know to carefully check the spellings of function names and 
variables.

-- 
Denis McMahon, denismfmcma...@gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Where is 'palindrome' defined?

2015-06-01 Thread MRAB

On 2015-06-02 01:55, fl wrote:

On Sunday, May 31, 2015 at 9:46:56 PM UTC-7, fl wrote:

Hi,

When I search solution of reverse a string/number, I came across a short
function online:

 def palindrome(num):
return str(num) == str(num)[::-1]

I thought that it is a general function. And with the following variable:

 a
'1234_'

 parlindrome(a)

Traceback (most recent call last):
  File pyshell#126, line 1, in module
parlindrome(a)
NameError: name 'parlindrome' is not defined


Then, I find that parlindrome is a special checking mirrored word.
I use Python 2.7.9. Why does the error message show

name 'parlindrome' is not defined



Thanks,


Thanks, I realize that it was spelled wrong. Now, with the correct spelling
the result is a 'False'. I have expected it gives reversed string. Is the
function behaves correct or not?


It compares 'num' as a string to the reverse of that to test whether 
it's a palindrome,

so, yes, it's behaving correctly.

Perhaps its purpose would have been clearer if it had been called
is_palindrome.




a='1234'
def palindrome(num):

return str(num) == str(num)[::-1]

palindrome(a)

False

palindrome(fread)

False



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


Re: Where is 'palindrome' defined?

2015-06-01 Thread sohcahtoa82
On Monday, June 1, 2015 at 5:55:14 PM UTC-7, fl wrote:
 On Sunday, May 31, 2015 at 9:46:56 PM UTC-7, fl wrote:
  Hi,
  
  When I search solution of reverse a string/number, I came across a short
  function online:
  
   def palindrome(num):
  return str(num) == str(num)[::-1]
  
  I thought that it is a general function. And with the following variable:
  
   a
  '1234_'
  
   parlindrome(a)
  
  Traceback (most recent call last):
File pyshell#126, line 1, in module
  parlindrome(a)
  NameError: name 'parlindrome' is not defined
  
  
  Then, I find that parlindrome is a special checking mirrored word.
  I use Python 2.7.9. Why does the error message show   
  
  name 'parlindrome' is not defined
  
  
  
  Thanks,
 
 Thanks, I realize that it was spelled wrong. Now, with the correct spelling
 the result is a 'False'. I have expected it gives reversed string. Is the 
 function behaves correct or not?
 
 
 Thanks,
 
 
 
 
  a='1234'
  def palindrome(num):
   return str(num) == str(num)[::-1]
  palindrome(a)
 False
  palindrome(fread)
 False

If you want the reversed string, then just use a[::-1].  Your palindrome 
function simply returns a boolean telling you whether or not the string you 
gave it is a palindrome.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Where is 'palindrome' defined?

2015-06-01 Thread fl
On Sunday, May 31, 2015 at 9:46:56 PM UTC-7, fl wrote:
 Hi,
 
 When I search solution of reverse a string/number, I came across a short
 function online:
 
  def palindrome(num):
   return str(num) == str(num)[::-1]
 
 I thought that it is a general function. And with the following variable:
 
  a
 '1234_'
 
  parlindrome(a)
 
 Traceback (most recent call last):
   File pyshell#126, line 1, in module
 parlindrome(a)
 NameError: name 'parlindrome' is not defined
 
 
 Then, I find that parlindrome is a special checking mirrored word.
 I use Python 2.7.9. Why does the error message show   
 
 name 'parlindrome' is not defined
 
 
 
 Thanks,

Thanks, I realize that it was spelled wrong. Now, with the correct spelling
the result is a 'False'. I have expected it gives reversed string. Is the 
function behaves correct or not?


Thanks,




 a='1234'
 def palindrome(num):
return str(num) == str(num)[::-1]
 palindrome(a)
False
 palindrome(fread)
False
-- 
https://mail.python.org/mailman/listinfo/python-list