Re: [Tutor] Removing Unnecessary Indentation and other problems
Including tutor list. Please use ReplyAll when responding to the list. Sorry about that. I am new to this so I didnt know I have to be very specific towards every detailIt depends on what you are asking, but in this case different downloads include different packages so we need to know which OS, which version and which web site you got it from. In this case I'll assume you got it from the python.org site? . I downloaded 'Python 3.3.2 Windows x86 MSI Installer (Windows binary -- does not include source)' Thats fine it does have Tkinter included. Personally, for Windows users I recommend getting the Activestate.com version of Python instead. It includes some nice extra features and it integrates Python more closely with the Windows environment. But thats not the cause of your problem here. from Tkinter import * This is the problem. In Python v3 they changed the name of the Tkinter module from Tkinter to tkinter(no caps). I think it was just to make the name more consistent with other modules... The result is you need to change your import to be from tkinter import * For the second part of the question.. I don't know which font I am using but I think its default font? OK, So in that case how are you running the program? Are you using IDLE or a CMD shell window? Or something else? One of the problems of using tabs, and of printing directly in general, is that the program may be displaying in many different environments and therefore with different fonts. You therefore have limited control over the output. That's why generating an HTML page which can have font information embedded into it and use tables etc to control layout is a more reliable option if you need precise control of layout. If precise control is not so necessary and you think the font will be monospaced then you can do some things in a print statement that will help, just be aware that it may not be 100% effective. while sMainContinue == yor sMainContinue ==yes or sMainContinue ==YESor sMainContinue ==Y: userMainInput = (input(Please select one option from menu: )) You are making this hard for yourself./ Its usually better to convert the input to lowercase (or uppercase if you prefer!) and then compare. So your line above could be: while sMainContinue.lower() in ('y','yes'): Also in the input() line you don't need the outer set of parens. But see below... #Robust Options: if input is a letter if userMainInput.isdigit(): userInput = int(userMainInput)Again its more common in Python to just do the conversion at the input stage and catch an exception if the data is bad., so that would look like try: userInput = int( input(Please select one option from menu: ) ) except ValueError: # deal with non numeric input here #Options1 if userInput == 1: print(\nRoad Information**) print(Road Name,Speed,sep = \t\t) for key,value in Dic.items(): print(key,value,sep = \t\t)And here is the display part and it relies on tabs. Tabs work on fixed column positions so to be consistent you would need to check the length of the strings and insert the correct number of tabs depending on whether the string was shorter or longer. In your case it could be anywhere from 1 tab to 3 tabs... That's messy and using tabs for formatting like that is not recommended. Instead Python offers a formatting mechanism that you can apply to a string before it is printed which gives you much more control over spacing and justification etc. You could read about it in the official docs but there is a more accessible tutorial here: http://infohost.nmt.edu/tcc/help/pubs/python/web/new-str-format.html The key is to use fixed length string fields to output your data. You may optionally choose to left justify the name and right justify the speeds, or you could just left justify everything. The choice is yours. But remember format() still relies on the user having monospaced fonts for it to work properly. HTH, -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.flickr.com/photos/alangauldphotos ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Need help on Python API programmig
Hi Sourav, Please use Reply all when you reply an email so that everyone else also gets your messages and your chances of getting better help increases. On Sat, Nov 16, 2013 at 3:35 PM, Sourav Biswas sob...@gmail.com wrote: Hi Amit, Yes I know, the question is not quite good. Currently I am trying to learn web API programming with Python. The ultimate goal is work with OpenStack API. Can you please let me know, how to start on this. Thanks for the reply and thanks in advance. Sorry, I certainly didn't mean that your question was not good. Now that you have mentioned what specifically you are looking to learn, it becomes slightly easier to make some suggestions. I don't have any personal experience with OpenStack API. However, looking at [1], it seems like you will be mostly dealing with making HTTP requests and reading responses. There are couple of standard library modules such as urlllib2 and httplib that may be useful to you. However, in this case, you would certainly benefit from directly learning to use Requests [2]. Note that however, you will need to be familiar with Python data structures such as dictionaries and know how to work with JSON data ( please see the 'json' standard module). [1] http://docs.openstack.org/api/quick-start/content/ [2]http://www.python-requests.org/en/latest/ I am hoping those prove helpful. All the best, Amit. -- http://echorand.me ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Tutor Digest, Vol 117, Issue 25
is this active? 2013/11/16 tutor-requ...@python.org Send Tutor mailing list submissions to tutor@python.org To subscribe or unsubscribe via the World Wide Web, visit https://mail.python.org/mailman/listinfo/tutor or, via email, send a message with subject or body 'help' to tutor-requ...@python.org You can reach the person managing the list at tutor-ow...@python.org When replying, please edit your Subject line so it is more specific than Re: Contents of Tutor digest... Today's Topics: 1. Re: TypeError: generatePersonID() takes exactly 1 argument (0 given) (Suhas Bhairav) -- Message: 1 Date: Sat, 16 Nov 2013 08:58:54 +0530 From: Suhas Bhairav suhasbhai...@hotmail.com To: Alex Kleider aklei...@sonic.net, tutor@python.org tutor@python.org Subject: Re: [Tutor] TypeError: generatePersonID() takes exactly 1 argument (0 given) Message-ID: bay176-w298f272acd25f10f8fe94d4...@phx.gbl Content-Type: text/plain; charset=iso-8859-1 Hello, In your program, when you're calling generatePersonID(), you need to pass an argument to the function i.e. the value of fullName.This is because when you're defining the function generatePersonID(), it is generatePersonID(fullName) and not just generatePersonID(). So you have pass an arguments while you're calling it. Eg:def main(): getUserInput () generatePersonID (Suhas) RegardsSuhas Date: Thu, 14 Nov 2013 09:24:50 -0800 From: aklei...@sonic.net To: tutor@python.org Subject: Re: [Tutor] TypeError: generatePersonID() takes exactly 1 argument (0 given) On 2013-11-14 07:54, Thabile Rampa wrote: Hi, So I'm learning how to define my own functions, and in an exercise I was given, I get this error: Traceback (most recent call last): File X:/X/xxx/X/function_practice.py, line 36, in module main () File X:/X/xxx/X/function_practice.py/function_practice.py [1], line 34, in main generatePersonID () TypeError: generatePersonID() takes exactly 1 argument (0 given) Here is the code: def getUserInput(): Get input from the user, i.e fullname, grossSalary, costs. Returns: fullName, grossSalary, costs grossSalary =None ; costs =None fullName= while not fullName: fullName = raw_input (First and Last Names: ) while not grossSalary: #TODO grossSalary = int (raw_input (Annual Gross Salary: )) while not costs: #TODO costs = int(raw_input (Yearly costs: )) return fullName, grossSalary, costs def generatePersonID (fullName): generates unique ID global id id = (fullName) + 1 personID = str (id) + fullName return personID def main (): getUserInput () generatePersonID () main () raw_input (Press the enter key to exit.) You define 'generatePersonID' as a function that requires one parameter but you do not give it a parameter when you call it with in your 'main' function. That's exactly what your error message is trying to tell you. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor -- next part -- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tutor/attachments/20131116/c172caf5/attachment-0001.html -- Subject: Digest Footer ___ Tutor maillist - Tutor@python.org https://mail.python.org/mailman/listinfo/tutor -- End of Tutor Digest, Vol 117, Issue 25 ** ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Is this list active?
Hi, On 16 November 2013 11:02, Vlad Olariu florinvlad.ola...@gmail.com wrote: is this active? Yes. (Please don't reply to digest posts without at least trimming it and adjusting the subject as appropriate.) Walter ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Tutor Digest, Vol 117, Issue 25
On 16/11/13 11:02, Vlad Olariu wrote: is this active? If you mean the mailing list then yes, but not massively busy and there is an archive of posts that you can search/review. If you mean did this mail get here then again yes but via the moderator queue so a little later than most. Otherwise you'll need to be more specific. Speaking of which we appreciate knowing, when you post, what OS and Python version you are using, what exactly the problem is (not just its broke) and the full printout of any error messages not a summary. Shortish code listing illustrating the problem are welcome too. Finally, use a meaningful subject line and please do not send the entire digest contents (only one message in this case but can be much longer) since some people pay by the byte and others are earn a living by the minute so don't want to waste time looking for clues. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.flickr.com/photos/alangauldphotos ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] Class attribute error
class myclass(): def test(self): print print this line if __name__ == '__main__': myclass.run() -- View this message in context: http://python.6.x6.nabble.com/Class-attribute-error-tp5039199.html Sent from the Python - tutor mailing list archive at Nabble.com. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] basic function concept
def main(x, y, z): print (x, y, z) def funct(): x = 1 y = 2 z = 3 return x, y, z main() Can someone tell me why main is not being given any arguments? ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] basic function concept
main() Can someone tell me why main is not being given any arguments? Because you didn't write any there. -nik -- Wer den Grünkohl nicht ehrt, ist der Mettwurst nicht wert! PGP-Fingerprint: 3C9D 54A4 7575 C026 FB17 FD26 B79A 3C16 A0C4 F296 signature.asc Description: Digital signature ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Class attribute error
On Sat, Nov 16, 2013 at 09:13:13AM -0800, reutest wrote: class myclass(): def test(self): print print this line if __name__ == '__main__': myclass.run() Is that a question? If I were to guess, I'd say you should have asked Why does this say that myclass does not havea run method?. Then the simple answer is: Because, well, it doesn't! Why do you expect it to have one? -nik -- Wer den Grünkohl nicht ehrt, ist der Mettwurst nicht wert! PGP-Fingerprint: 3C9D 54A4 7575 C026 FB17 FD26 B79A 3C16 A0C4 F296 signature.asc Description: Digital signature ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] basic function concept
On 16/11/13 21:20, Byron Ruffin wrote: def main(x, y, z): print (x, y, z) def funct(): x = 1 y = 2 z = 3 return x, y, z main() Can someone tell me why main is not being given any arguments? Because somebody made a mistake. I don't know if this is your code or something you found in a book or web page but whichever it's an error and Python won't run it. Also funct() is a waste of space since its never used... -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.flickr.com/photos/alangauldphotos ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Class attribute error
On 16/11/13 17:13, reutest wrote: class myclass(): def test(self): print print this line if __name__ == '__main__': myclass.run() If you have a question it helps if you ask it rather than have us guess. In this case I'm guessing you got an error and you are wondering why? It's because you are calling the run() class method of myclass. And there is no such method. If that's not your question please post again with a bit more of a clue about what you want to know. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.flickr.com/photos/alangauldphotos ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] Fwd: Need help on Python API programmig
Hi John, Perhaps your answer was directed towards Sourav. CCing tutor. -- Forwarded message -- From: John Steedman johnsteedman...@gmail.com Date: Sun, Nov 17, 2013 at 6:26 AM Subject: Re: [Tutor] Need help on Python API programmig To: Amit Saha amitsaha...@gmail.com Hi Amit, I've been using Django Rest Framework for developing a database-driven API. If you choose to follow their tutorial, you may accomplish your goal quite quickly while learning a lot about web APIs and quite good engineering at the same time. Tastypie is a similar option. John On Fri, Nov 15, 2013 at 9:14 PM, Amit Saha amitsaha...@gmail.com wrote: Hello Sourav, On 16/11/2013 6:53 AM, Sourav Biswas sob...@gmail.com wrote: Hi All, This is my first post. I want to learn API programming with Python. I have basic knowledge of Python Programming. Could you please let me know the starting points for this programming. Since your question is fairly vague, could you please describe what you are trying to learn? An API is an interface. It can be an operating system interface, a vehicle web API or simply a web API. Some more details will be a lot of help. Best, Amit. -- http://echorand.me ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor