top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is doc string in Python? How you can convert a number to a string?

+1 vote
393 views
What is doc string in Python? How you can convert a number to a string?
posted Dec 3, 2014 by Kali Mishra

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

A Python documentation string is known as doc string, it is a way of documenting Python functions, modules and classes.

In order to convert a number into a string, use the inbuilt function str(). If you want a octal or hexadecimal representation, use the inbuilt function oct() or hex().

answer Dec 3, 2014 by Amit Kumar Pandey
Similar Questions
+4 votes

I just started rewritting my project from python 2 to python 3. I noticed that there are these new parameter and return value annotations. I have docstrings everywhere in my project, but I plan to convert many of them into annotations. The question is: what kind of auto documenting system should I use for this? Previously I have used Sphinx. Is it okay to use that for python 3 source code? Is there a better alternative?

+2 votes

I have a numpy array consisting of 1s and zeros for representing binary numbers:

e.g.

 >>> binary
 array([ 1., 0., 1., 0.])

I wish the array to be in the form 1010, so it can be manipulated. I do not want to use built in binary converters as I am trying to build my own.

+4 votes

I want to make an animated GIF from 3200+ png. I searched and found http://code.google.com/p/visvis/source/browse/#hg/vvmovie and I wrote:

allPic=glob.glob('*.png')
allPic.sort()
allPic=[Image.open(i) for i in allPic]
writeGif('lala3.gif',allPic, duration=0.5, dither=0)

However I got

 allPic=[Image.open(i) for i in allPic]
 File "e:prgpypython-2.7.3libsite-packagesPILImage.py", line 1952, in open
 fp = __builtin__.open(fp, "rb")
IOError: [Errno 24] Too many open files: 'out0572.png'

Is there other lib for py?

+2 votes

I have a multi-line string and I need to remove the very first line from it. How can I do that? I looked at StringIO but I can't seem to figure out how to properly use it to remove the first line.

...