About

Swaroop C H is 29 years of age. He is a coder and startupper. He has previously worked at Yahoo!, Adobe, his own startup and Infibeam.

Read more about him

Views
Personal tools
COLLECTION
Collection

Talk:Python en:Basics

From Notes

Jump to: navigation, search

the varname tag seems to not work on my browser (firefox3.0.1) --User:Horstjens 10:46, 29 August 2008 (UTC)

Swaroop said:

Hey Horst,

Thanks for finding the typo. The 'varname' was used in the old DocBook XML format, I have changed it to 'tt' for this wiki.


Vages said:

I don't think the section about "the format method" explains enough about why it's useful, for instance you could write something about how it saves time when you use the same variable(s) more than once, and that it also saves some time if you'll have to change the name of the variable (because the numbers stay the same, and the only thing you have to change is the names of the variables within the parantheses).

I've added a paragraph about this.

Thanks,

Swaroop 02:51, 16 January 2009 (UTC)


Vages said:

And the superscript in the section about numbers doesn't work. Know how to fix this?

I've fixed the CSS for this, it should look okay now.

Regards,

Swaroop 03:03, 16 January 2009 (UTC)


jenny said:

Hi, I typed the Formatmethodexample and it does'nt work.."str objecthas no attribute format" what should i do? thanks

@Jenny, Can you confirm that you are using Python 3.0? -- Swaroop 07:35, 27 November 2008 (UTC)

Contents

Indentation

Hi, I'm reading the pdf-version and in the section about indentation, more explicitly in the example of a bad indentation, the bad indentation is wrong (as ironically as this sounds), i.e. there is no indentation. The '^' sign in the error message is also placed wrong.

Just so you know ;)

Thanks for bringing the indentation issue in the PDF to my notice, I've written to the mwlib mailing list and hopefully we'll fix the problem.

Regards,

Swaroop 02:45, 16 January 2009 (UTC)

Strings

The fragment of the link to the unicode site points to a non existing id http://www.unicode.org/faq/basic_q.html#16

format somehow not working with float

I can't run this:

'{0:.3}'.format(1/3) 

returns:

>>> '{0:.3}'.format(1/3)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: Precision not allowed in integer format specifier

Swaroop says: Not sure, it seems to be working here (unless something has changed from RC1 to final release):

   $ python3
   Python 3.0rc1+ (py3k, Oct 28 2008, 09:23:29) 
   [GCC 4.3.2] on linux2
   Type "help", "copyright", "credits" or "license" for more information.
   >>> '{0:.3}'.format(1/3)
   '0.333'

-- Swaroop 02:36, 20 February 2009 (UTC)

Could he be using Python 2 without doing: from __future__ import division

is print() a statement?

There's a line saying "print the value of i using the print statement". I thought print() was supposed to be a function in python 3, not a statement. Please someone tell me, am I mistaken?

You're correct, this has been fixed. -- Swaroop 00:21, 10 September 2009 (UTC)

SyntaxError for import braces

Under the heading Indentation, if you type from __future__ import braces the response from Python is "SyntaxError: not a chance" when using IDLE.

Perhaps this doesn't apply if you are using Python 3?

I'm currently using Python 3.2.2 AMD64.