I am from a c background. started learning python few days ago. my question is what is the end of string notation in python. like we are having \0 in c. is there anything like that in python.
-
2Why does this matter for a high-level programming like Python?user2665694– user26656942013-10-07 09:33:32 +00:00Commented Oct 7, 2013 at 9:33
-
1Python is not C and strings are objects not not simple pointers to some memory area.user2665694– user26656942013-10-07 09:34:01 +00:00Commented Oct 7, 2013 at 9:34
-
Valid question but one that does not make much sense. Downvoted.user2665694– user26656942013-10-07 09:34:36 +00:00Commented Oct 7, 2013 at 9:34
-
@user2799617 i mentioned that i am coming from c background. did not have much idea about python. to be clear about memory allocation in case of sting, i asked this question.user2847429– user28474292013-10-07 09:37:43 +00:00Commented Oct 7, 2013 at 9:37
3 Answers
Python's string management is internally a little more complex than that. Strings is a sequence type so that from a python coder's point of view it is more an array of characters than anything. (And so it has no terminating character but just a length property.)
If you must know: Internally python strings' data character arrays are null terminated. But the String object stores a couple of other properties as well. (e.g. the hash of the string for use as key in dictionaries.)
For more detailed info (especially for C coders) see here: http://www.laurentluce.com/posts/python-string-objects-implementation/