| | |
Raw_input...
Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Aug 2008
Posts: 162
Reputation:
Solved Threads: 49
You can pass value in as argument.
python Syntax (Toggle Plain Text)
new = raw_input('Enter name: ') class Test(object): def __init__(self,value): self.value = value x = Test(new) print x.value ''' output--> Enter name: hi hi '''
Last edited by snippsat; Jul 19th, 2009 at 12:02 pm.
Not really recommended, since you don't really always want to pause your code but I think you want this:
However, I'd have to agree that snippsat's solution is a better written class, because if neccessary you could use it on names that you don't get through raw_input like...a list! For example:
python Syntax (Toggle Plain Text)
class Name: def __init__(self): self.name = raw_input("Name: ")
However, I'd have to agree that snippsat's solution is a better written class, because if neccessary you could use it on names that you don't get through raw_input like...a list! For example:
python Syntax (Toggle Plain Text)
#snippseat's class class Test(object): def __init__(self,value): self.value = value for name in namelist: test = Test(name)
-Zac
![]() |
Similar Threads
- Starting Python (Python)
- How to do Input in Python? (Python)
- Insert text in raw_input (Python)
- raw_input StartsWith and other questions (Python)
- raw_input exception (Python)
Other Threads in the Python Forum
- Previous Thread: wxpython GUI error....
- Next Thread: Incrementing loops within loops
| Thread Tools | Search this Thread |
accessdenied apache application argv array beginner book builtin change color converter countpasswordentry curved dan08 dictionary dynamic edit enter examples file filename float format function gui homework import inches input java keyboard lapse library line lines linux list lists loop microphone mouse movingimageswithpygame mysql mysqlquery newb number numbers numeric output parameters parsing path phonebook plugin port prime programming projects py2exe pygame pyopengl pysimplewizard python random recursion redirect remote reverse scrolledtext session simple smtp software sprite statictext string strings syntax table tennis terminal text textarea thread threading time tkinter tlapse trick tuple tutorial ubuntu unicode unit urllib urllib2 variable windows wordgame wxpython





