Hi,
I am pretty new to python and I have a really noobish question:
What does %s mean

Recommended Answers

All 9 Replies

Thanx for clearing that up.
Noobish question number 2:
python and the internet-
How can I embed python into HTML code and how do you interface with the internet using python

I was experimenting with python and was trying to create an adressbook style thing. I have a class which creates all of the neccasary attributes, but I also wanted a function which added things to it, but it doesn't work:

class Data:
    def __init__(self, home, mobile, email):
        self.home = home
        self.mobile = mobile
        self.email = email
    def Coll_Data(self):
        self.info = """
Home Phone: %s
Mobile Phone: %s
Email: %s
""" % (self.home, self.mobile, self.email)

def add_new():
    name = raw_input("Enter name to be added: ")
    h = raw_input("Enter home phone: ")
    m = raw_input("Enter Mobile phone: ")
    e = raw_input("Enter Email address: ")
    name = Data(h, m, e)

How can I get this to work????????

On your last post --> Please do not double post, it is rude!

Sorry, please do use the other post, how can i delete this post

It is used when using formatted strings.
I could try explain, but a great book has been written and has a bit about it :)
http://diveintopython.org/getting_to_know_python/formatting_strings.html

Read and enjoy the best free book on python imho

hope that helps

The book is a little outdated IMHO.
However, aren't most of us a little outdated or at least fell like it at times?
Darn time simply does not stand still to catch up.

@Your_mum
Firstly, welcome to our Python community.
Secondly, I recommend to create a new thread when you have a different question. Also. please be a bit more specific about the thread title.

OK then,
thanx

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.