Re: [Tutor] Help me out please
On Tue, Jul 19, 2016 at 4:31 AM, Marc Sànchez Quibuswrote: > Hi, > First of all I'm gonan introduce myself. My name is Marc and I'm a student > and also a python's programmer begginer. I've been studying/learning python > and now I need some help to finish my project. > I have two scripts, one of them in python (the main script) and the other > one written in html. Well, is just a brief javascript (an app) that I took > by Github. I need to change a variable inside this html script. I was > wondering wether I could change this variable from my python script or not. > Is there some way to do it? Hi Marc, Yes. You might want to read something like this to get some background. Phil Greenspun's Guide to Web Publishing: http://philip.greenspun.com/panda/ Specifically, the chapter "Sites that are really progarms". http://philip.greenspun.com/panda/server-programming You mentioned that you have two scripts, one in Python and the other in HTML. A web site can be seen as this: something that (1) takes in a web request sent by a browser, and (2) spits out a web response. A static web site takes in a web request, looks for an appropriate file, and prints that file back as a web response. But that's not the only way we can build web responses. A programmatic web site can take that request and *generate* a web page on the fly. A web site can actually be a program: not just a plain text file. There are a lot of resources to teach how to write programs that serve web sites. Another by the same author is http://philip.greenspun.com/seia/, which goes into a lot more detail. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help me out please
On Jul 19, 2016 9:24 AM, "Marc Sànchez Quibus"wrote: > > Hi, > First of all I'm gonan introduce myself. My name is Marc and I'm a student > and also a python's programmer begginer. I've been studying/learning python > and now I need some help to finish my project. > I have two scripts, one of them in python (the main script) and the other > one written in html. Well, is just a brief javascript (an app) that I took > by Github. I need to change a variable inside this html script. I was > wondering wether I could change this variable from my python script or not. > Is there some way to do it? There might be. Tell us more about your situation. > Thanks in advance and sorry for the inconvenience. Since we are here to help, the only inconvenience his when we don't get enough information. That seems to be typical for first time questioners. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help me out please
On 19/07/16 12:31, Marc Sànchez Quibus wrote: > and now I need some help to finish my project. > I have two scripts, one of them in python (the main script) and the other > one written in html. Well, is just a brief javascript (an app) that I took > by Github. I need to change a variable inside this html script. I was > wondering wether I could change this variable from my python script or not. > Is there some way to do it? The easiest way is to put the entire html code into a string inside a module: # file: myhtml.py html = """ Hello %s """ Then import that and use string formatting to insert the variable #file: myscript.py import myhtml myvar = "World" print myhtml.html % myvar Instead of printing you could overwrite the original html file. Or you could write a web based app using a framework like Flask or Pylons and call your myscript.py from a web url and get it to just serve the html string directly. We don't know enough about your system and how the two scripts are related to say more than that. But it might give you some ideas. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: 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] Help me out please
Hi, First of all I'm gonan introduce myself. My name is Marc and I'm a student and also a python's programmer begginer. I've been studying/learning python and now I need some help to finish my project. I have two scripts, one of them in python (the main script) and the other one written in html. Well, is just a brief javascript (an app) that I took by Github. I need to change a variable inside this html script. I was wondering wether I could change this variable from my python script or not. Is there some way to do it? Thanks in advance and sorry for the inconvenience. -- *Marc Sànchez Quibus* ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] help me
hi I need your help plz with this cods ( I want u to tell wht cod I miss to stop the while loop whene I get 3 stars) rm = [] stars = 0 ##if stars == 3: ## print You win ##else: ## print hh def ask_yes_no(question): Ask a yes or no question. answer = None while answer not in (y, n): answer = raw_input(question).lower() return answer def congrate_winner(stars = 3): print congradulation you have., stars, stars you won!\n return stars ##def stars(): ## #stars = 0 ## global stars ## stars = stars + 1 ## print stars:, stars, \n ## ## if stars == 3: ## print congadulation you win ## else: ## print Go to the next room ## return stars def rest_room(): restroom = [shower, sink] print restroom global stars ans = ask_yes_no(It does star ther?: ) print This is the value of ans., ans if ans == y: print \nOK stars = stars + 1 print Stars:, stars, \n\n else: print hmm go to another room. print Stars:, stars, \n\n return ans, restroom def living_room(): livingroom = [uyyg, hfgfd, star] print livingroom global stars ans = ask_yes_no(It does star ther?: ) print Your answe is., ans if ans == y: print \nOK stars = stars + 1 print Stars:, stars, \n\n else: print hmm go to another room. print Stars:, stars, \n\n return ans, livingroom def bed_room(): bedroom = [iuyg, star] print bedroom global stars ans = ask_yes_no(It does star ther?: ) print Your answe is., ans if ans == y: print \nOK stars = stars + 1 print Stars:, stars, \n\n else: print hmm go to another room. print Stars:, stars, \n\n return ans, bedroom def Kichen(): kichen = [star, jyhffd] global stars print kichen ans = ask_yes_no(It does star ther?: ) print Your answe is., ans if ans == y: print \nOK stars = stars + 1 print Stars:, stars, \n\n else: print hmm go to another room. print Stars:, stars, \n\n return ans, kichen def main(): print Wlecome to my house. rm = None while rm != stars: print\ 0 - Northe 1 - South 2 - East 3 - Weast rm = raw_input(What room you want to go?: ) if rm == 0: rest_room() elif rm == 1: living_room() elif rm == 2: bed_room() elif rm == 3: Kichen() ##if stars == 3: ## congrate_winner() main() raw_input(\nPress the enter key to exit.) On Saturday, February 1, 2014 6:40 PM, hind fathallah hind_fathal...@yahoo.com wrote: thank you so much because I got it :) On Saturday, February 1, 2014 1:28 PM, Danny Yoo d...@hashcollision.org wrote: On Fri, Jan 31, 2014 at 8:55 PM, hind fathallah hind_fathal...@yahoo.com wrote: hi can you answer this question for me plz [question omitted] Many of us probably could answer this. But this is not a homework-answering mailing list. The problem itself is not interesting to us. What is interesting is why the problem is giving you trouble. We'd rather focus on where you are having difficulty: we'd rather help *you*. Tell us what you've tried, where you're getting stuck, what other kinds of problems you've done that are similar to this one. That is, show us what general problem solving strategies you're using now. Maybe some of those strategies are not working for you.___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] help me
hind fathallah hind_fathal...@yahoo.com Wrote in message: while rm != stars:     print\         0 - Northe     1 - South     2 - East     3 - Weast         rm = raw_input(What room you want to go?: ) Why are you looping till he gets to the weast room? Why not loop till stars reaches 3? -- DaveA ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] help me
hind fathallah wrote: hi I need your help plz with this cods ( I want u to tell wht cod I miss to stop the while loop whene I get 3 stars) rm = [] I think you are comparing a string and an integer. That gives False even if the values look the same: i = 3 s = 3 print i, s 3 3 i == s False Use repr() debug the problem: print repr(i), repr(s) 3 '3' ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] help me
thank you so much because I got it :) On Saturday, February 1, 2014 1:28 PM, Danny Yoo d...@hashcollision.org wrote: On Fri, Jan 31, 2014 at 8:55 PM, hind fathallah hind_fathal...@yahoo.com wrote: hi can you answer this question for me plz [question omitted] Many of us probably could answer this. But this is not a homework-answering mailing list. The problem itself is not interesting to us. What is interesting is why the problem is giving you trouble. We'd rather focus on where you are having difficulty: we'd rather help *you*. Tell us what you've tried, where you're getting stuck, what other kinds of problems you've done that are similar to this one. That is, show us what general problem solving strategies you're using now. Maybe some of those strategies are not working for you.___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] help me
hi can you answer this question for me plz Modify the Guess My number program from this chapter so that the player has only five guesses. If the player run out of guess, the program should end the game and display an appropriately chastising message. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] help me
On 01/02/2014 04:55, hind fathallah wrote: hi can you answer this question for me plz Modify the Guess My number program from this chapter so that the player has only five guesses. If the player run out of guess, the program should end the game and display an appropriately chastising message. Please give your message a sensible subject. Better still tell us which chapter from which book so that we can help you, or copy the contents here so that we can see them. Your Python version and OS are useful as well. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] help me
On Fri, Jan 31, 2014 at 8:55 PM, hind fathallah hind_fathal...@yahoo.com wrote: hi can you answer this question for me plz [question omitted] Many of us probably could answer this. But this is not a homework-answering mailing list. The problem itself is not interesting to us. What is interesting is why the problem is giving you trouble. We'd rather focus on where you are having difficulty: we'd rather help *you*. Tell us what you've tried, where you're getting stuck, what other kinds of problems you've done that are similar to this one. That is, show us what general problem solving strategies you're using now. Maybe some of those strategies are not working for you. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] help me decide
hey guys i just like to thank everyone for their input. Its really helped me in deciding a lot of things. also @ Alan i think? as ive started writing this mail it won;t let me look up previous senders but thanks for your input. Also your field of work sounds very interesting indeed. I can't dare to imagine the amount of hard work that got you there.:) i only hope my dedication can take me half as far:) Best wishes to everyone:x ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] help me decide
Hi Alan thanks so much for your helpful answers. probably wxPython or GTk But if you want to get serious about GUIs I'd probably suggest wxPython instead - it ultimately is more powerful and complete and if you are only just starting will be easy to learn whereas learning Tkinter and converting is more difficult (IMHO). PyQt is powerful too but there are several limitations in its licensing model that leave me slightly wary. Gtk is another option. Both of these were originally made popular in the Linux community but both are available cross platform now. (as are Tkinter and wxPython) After your response ive decided GUI programming is defintely better for me at this stage. I read Pyside is a replica of pyqt, same makers qt but it covers all the licensing that PyQt doesnt, and if you learn 1 the other is almost exactly the same. Would this be a good enough reason to give it and pyqt a try? how does it compare to wxPython? also please could you tell me why you suggest wxPython over GTK? what are the factors you looked at, is it better for beginners to start out with a simpler toolkit and decide later on if its enough for them? would you say out of the GUIs we have mentioned, apart from Tkinter, that wxPython is the easiet to pick up yet a lot more complete than Tkinter? I'm not a big fan of user interface programming in any shape. I started my career writing embedded software where the UI was a switch and some LEDs. So i am more interested in the internals of a program than in its outer appearance, but from necessity I've done a little bit of GUI work and even less web work. this has interested me. is embedded programming a different field to the type of programming in Python? it sounds like thats more lower level prgroamming better suited to a language like C? is your work today still related to this area? somewhere down the learn, after i have mastered Python i'd definately like to learn about internals of a program, even though the thought of that really scares me:) ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] help me decide
From: Matthew Ngaha [snip] i feel confident using Python now but im still not sure which direction i want to go in. I would at some point like to learn how to use GUIs and a web Framework(Django). But i don't know which of the 2 to start out with. a) IF you happen to have used both, which one fills you with joy and is more fun for you to program with, GUI programming, or web related / Framework programming? b) which was easier and less complex for you to learn? or should i say had a lower learning curve? i ask this because the sooner i get an understanding of one, i can maybe give the other one a go. But if it's too hard i usually give 100% to it and never try learning anything else until it computes. [snip] Before i try to learn either, GUIs or a web Framework, i was looking into maybe getting a deeper understanding of OOP. my tutorial only covered it briefly. f) would this be a good idea tackling OOP next before the other 2, or is this a skill you master with more programming experience? ok my last question is not so important:) im just curious as i grow more fond of programming. well i keep reading Python is an all-purpose general programming language(web frameworks, desktop apps, science/maths etc..). I notice Java has similar features so should also be considered an all-purpose general programming language. my question is: g) not a comparison in 1 specific area, but which language is better or more suited to all around all-purpose quality. thanks guys I would second the wxPython framework as a popular and fully featured framework; being popular means it will likely be easier to get help on it. I was *not* a fan of GUI in Java using Swing. Stick with Python, but this list is probably biased. :) The real question is what do you want to *do* with it? The purpose or intent probably matters more than which you pick. If you are learning for the sake of learning I would probably point you in the direction of web frameworks. In my personal opinion there is more opportunity there. Not to mention that the basics you learn in web frameworks will help you design web sites in other languages as well. Whereas desktop applications will probably be a lot more specific to the framework/language and project. That is just my personal observations. Others (including you) may disagree. Ramit ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] help me decide
On 05/09/12 11:04, Matthew Ngaha wrote: also please could you tell me why you suggest wxPython over GTK? Support, there are probably more beginner friendly resources for wxPython than for GTk, although that is changing. that wxPython is the easiet to pick up yet a lot more complete than Tkinter? I can't really comment since Tkinter and wxPython are the only two i've really used. I did a PyQt tutorial a long time back and have never used GTk at all so can't really comment on them. this has interested me. is embedded programming a different field to the type of programming in Python? Yes, it is usually done using assembler and C or C++. Some embedded work nowadays is done in Java - a reflection of how cheap memory has become! is your work today still related to this area? Not really, my company (a big telecomms business) got out of making bespoke hardware and now buys in standard commercial kit. My core job these days is as an Enterprise Architect and I do almost no programming now. I determine what IT systems are needed, the interfaces between them and review the high level systems designs. I act as a bridge between the business folks and the IT tech heads... I 'own' around 250 systems and oversee the technical work of around 1000 developers, with about 20 projects running at any one time. Python programming has become more of a hobby and personal productivity tool nowadays. It keeps me sane and connected! :-) -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] help me decide
On 05-Sep-12 10:40, Alan Gauld wrote: On 05/09/12 11:04, Matthew Ngaha wrote: also please could you tell me why you suggest wxPython over GTK? Support, there are probably more beginner friendly resources for wxPython than for GTk, although that is changing. Yeah, and wxPython is a large, comprehensive package that should handle all of your GUI needs and then some. I wrote one tool using wxPython and was quite happy with the results, and pleasantly surprised at the performance of widget updates and refreshes it achieved, even for the bits in pure Python. that wxPython is the easiet to pick up yet a lot more complete than Tkinter? Not sure about that. I started Tk programming back (way back) in my Tcl/Tk phase years ago, so I'm really used to Tk and that may bias me, but I'd say Tkinter is a lot easier to learn than wxPython, partly because it's smaller with fewer moving parts to tweak. And yet, Tkinter is complete enough to be quite satisfactory for a lot of applications. Even after using wx, I've gone back to Tkinter when it sufficed for my applications, since it's a little easier to use and is a lot easier to distribute, coming for free with Python and all that. this has interested me. is embedded programming a different field to the type of programming in Python? Yes, it is usually done using assembler and C or C++. Some embedded work nowadays is done in Java - a reflection of how cheap memory has become! Right. Although Java here doesn't necessarily mean the JVM is running on the embedded machine; it could be Java source code compiled down to something a compact runtime can execute. -- Steve Willoughby / st...@alchemy.com A ship in harbor is safe, but that is not what ships are built for. PGP Fingerprint 4615 3CCE 0F29 AE6C 8FF4 CA01 73FE 997A 765D 696C ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] help me decide
No matter what the kit used for GUI, make sure it's well documented, and has plenty of tuts/docs. I used tkinter, and wxpython, and like the widget set/cross OS usages in wxpython better. However, with more experience, now I'm moving toward the Blender Game Engine to give more feel, and a 3-d pop to my apps through it's Python API. So, consider that over time your preferences will change in relation to your knowledge, and the wisdom that comes with the application of this knowledge...experience. Also, don't get hung up on just python. Always take a beginner's guide or two with a well referenced language(all the way down to assembly/machine language) for familiarity. -- Best Regards, David Hutto *CEO:* *http://www.hitwebdevelopment.com* ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] help me decide
On Tue, 4 Sep 2012, Matthew Ngaha wrote: a) IF you happen to have used both, which one fills you with joy and is more fun for you to program with, GUI programming, or web related / Framework programming? Honestly - both. It's really a highly subjective question and depends what you want to do (although with modern browsers like Google Chrome and Firefox the line is becoming more and more blurry). If you want to provide an application that requires no interaction with the outside world, a GUI is probably a better fit and has the advantage that you'll probably only be using one language - in this case, Python ;) But if you begin doing web programming then you'll start to learn about HTML, JavaScript, and CSS (all valuable technologies and look like they'll be here to stay!) b) which was easier and less complex for you to learn? or should i say had a lower learning curve? i ask this because the sooner i get an understanding of one, i can maybe give the other one a go. But if it's too hard i usually give 100% to it and never try learning anything else until it computes. Honestly, I picked up learning HTML before I learned to actually program. That's what got me interested, was being able to make small changes in the text and see large changes happen in my page. I would say as far as complexity goes, learning basic GUI programming has less pieces. But again, both directions are perfectly valid and valuable things to learn. my tutorial had a small section on tkinter. I have now looked for some tutorials and noticed Python tutorials on both tkinter and Tk. As i understand they are not the same thing but tkinter is like the interface of Tk? my question is: I'm sure someone has addressed this already, but Tkinter is the Python bindings for Tk/Tcl. It allows you to write Python code to do Tk things. c) which tutorial would be better to study, Tkinter or Tk? and what exactly is the difference? why do they have separate tutorials? You would definitely want to focus on Tkinter - and there are quite a few good tutorials, including the effbot tutorial. That's a reference I turn to almost any time I'm doing Tkinter. i looked at some pyQT articles, but its coding looks less organised than Tkinter. I wouldn't say it's less organized, but there's a *lot* more to Qt than Tkinter. d) is this true? is Tkinter a lot more straight forward and Python friendly? One thing I noticed about Qt is that you'll be using the Q key a lot. So your left pinky (assuming two hands and a Qwerty keyboard) will get a massive workout. It was super awkward for me while I was learning it. e) Does pyQT have grids (rows and columns) to place your widgets on like Tkinter, or do you have to use x and y axis to position widgets etc..? You can do both... In terms of GUI frameworks, I rank them in this order from least- to most-complex: 1. Tkinter 2. wxPython 3. PyGTK+ 4. PyQt Tkinter is kinda the raw materials. You get a few widgets (though that's really grown in the past few years with ttk and tix), and some building blocks. wxPython gives you some tools to interface with the native UI - so if you set it up right, the same Python application will look like a real Windows app, a real Gnome(GTK) app, or what have you. PyGTK seems to me like it gives you a bit more than wx. Again, this is largely subjective. I used to do quite a bit with PyGTK. The normal GTK documentation maps quite well, though it can be a little difficult to figure out why something is doing what it's doing. PyQt... well that's everything and the kitchen sink. I mean seriously - there's a timer widget built in! It's quite the powerhouse, but ultimately I didn't like using my left pinky to hit the Q key so much. Before i try to learn either, GUIs or a web Framework, i was looking into maybe getting a deeper understanding of OOP. my tutorial only covered it briefly. f) would this be a good idea tackling OOP next before the other 2, or is this a skill you master with more programming experience? I personally would consider OOP fundamentals essential to learning GUI programming with anything besides Tkinter. It's pretty easy to write procedural-ish Tkinter code. ok my last question is not so important:) im just curious as i grow more fond of programming. well i keep reading Python is an all-purpose general programming language(web frameworks, desktop apps, science/maths etc..). I notice Java has similar features so should also be considered an all-purpose general programming language. my question is: g) not a comparison in 1 specific area, but which language is better or more suited to all around all-purpose quality. I'm sure the other folks have mentioned that Java is an extremely verbose language that (at least to me) is entirely too noisy. I did *not* enjoy the two semesters in college that I had to use it. The term Martin Fowler uses to describe it is a guiding language. That means that Java has
[Tutor] help me decide
hey guys as i program more, i think of silly questions i would like answers to. if anyone doesnt mind entertaining my question, please do answer:) I have just about finished my beginner tutorial, just a few exercises left. i feel confident using Python now but im still not sure which direction i want to go in. I would at some point like to learn how to use GUIs and a web Framework(Django). But i don't know which of the 2 to start out with. a) IF you happen to have used both, which one fills you with joy and is more fun for you to program with, GUI programming, or web related / Framework programming? b) which was easier and less complex for you to learn? or should i say had a lower learning curve? i ask this because the sooner i get an understanding of one, i can maybe give the other one a go. But if it's too hard i usually give 100% to it and never try learning anything else until it computes. my tutorial had a small section on tkinter. I have now looked for some tutorials and noticed Python tutorials on both tkinter and Tk. As i understand they are not the same thing but tkinter is like the interface of Tk? my question is: c) which tutorial would be better to study, Tkinter or Tk? and what exactly is the difference? why do they have separate tutorials? i looked at some pyQT articles, but its coding looks less organised than Tkinter. d) is this true? is Tkinter a lot more straight forward and Python friendly? e) Does pyQT have grids (rows and columns) to place your widgets on like Tkinter, or do you have to use x and y axis to position widgets etc..? Before i try to learn either, GUIs or a web Framework, i was looking into maybe getting a deeper understanding of OOP. my tutorial only covered it briefly. f) would this be a good idea tackling OOP next before the other 2, or is this a skill you master with more programming experience? ok my last question is not so important:) im just curious as i grow more fond of programming. well i keep reading Python is an all-purpose general programming language(web frameworks, desktop apps, science/maths etc..). I notice Java has similar features so should also be considered an all-purpose general programming language. my question is: g) not a comparison in 1 specific area, but which language is better or more suited to all around all-purpose quality. thanks guys ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] help me decide
Matthew, Program what is fun for you. I prefer PHP for web work but I'm learning Python for my day job. Python provides a wider range of abilities but PHP is more fun for me. If Python GUIs are fun, then do that. The more you enjoy the topic the more reason you will have to learn more and more. I doubt you will exhaust Python's capabilities any time soon. Python or Java? For me it's Python. The only real Java advantage might be Android programming. Leam -- Mind on a Mission http://leamhall.blogspot.com/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] help me decide
sorry wrong i didnt send mail right. hey i didnt explain it properly, i wasn't asking what language to use or learn. I am only going to be using Python. I meant whic area to study on 1st, GUI programing e.g Tkinter or Programming with a web framwork e.g Django. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] help me decide
hey you didnt read my question:( i dont enjoy either because i have no experience with them. so im asking questions about peoples personal experiences with the 2 areas which can give me further information to research on. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Help me in this programme
this is one of the problem based on list which i found at pyschool. CountWords(google) [('e',1),('g',2),('l',1),('o',2)] by the level of this question you can easily understand i am new in python.the problem i am facing is how to make set of word and count(e,1) and add this to list?? ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help me in this programme
On 06/10/11 08:15, Praveen Singh wrote: CountWords(google) [('e',1),('g',2),('l',1),('o',2)] by the level of this question you can easily understand i am new in python.the problem i am facing is how to make set of word and count(e,1) and add this to list?? Some clues: a for loop will iterate over a string: for letter in google: print letter A dictionary holds a value against a key. A key can be a letter. The corresponding value can be a number. Does that help? -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Help me understand this tkinter related code
I've just begun learning Python and programming using the Head First Programming from O'Reilly. The following code works on my Mac just fine, but there is a mystery as to how its working that escapes me so far. The local function change_volume(v) requires the argument v to operate properly, but I'm unclear where the value of that argument is being set or why the code fails without it. It appears to be a detail that isn't explained in the text. When I compare the two widgets and their associated functions, both seem to use the .get method to access the value set by the widget, so in that case the v seems superfluous. I thought that perhaps the answer might be found in the tkinter code that defines Scale, but I'm not even sure where on the computer that code is located. Thank you! Bob Here is the code (the comments are mine, otherwise the code matches the book except that I grouped some items differently -- I like to keep variables all in one place as much as possible): #!/usr/local/bin/python3 # load external libraries from tkinter import * import pygame.mixer # initialize the visual interface app = Tk() app.title(Head First Mix) app.geometry('250x100+200+100') # initialize the sound player mixer = pygame.mixer mixer.init() # initialize the variables sound_file = 50459_M_RED_Nephlimizer.wav track = mixer.Sound(sound_file) track_playing = IntVar() # local functions def shutdown(): track.stop() app.destroy() def track_toggle(): if track_playing.get() == 1: track.play(loops = -1) else: track.stop() def change_volume(v): track.set_volume(volume.get()) # define interface widgets track_button = Checkbutton(app, variable = track_playing, command = track_toggle, text = sound_file) track_button.pack() volume = DoubleVar() volume.set(track.get_volume()) volume_scale = Scale(app, variable = volume, from_= 0.0, to = 1.0, resolution = 0.1, command = change_volume, label= Volume, orient = HORIZONTAL) volume_scale.pack() # main entry point app.protocol(WM_DELETE_WINDOW, shutdown) app.mainloop() ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help me understand this tkinter related code
Please don't hijack an old message to create a new subject. Those of us using threaded readers might not see it and you lose potential answers. Robert DeLaurentis li...@bobdel.com wrote The local function change_volume(v) requires the argument v to operate properly, but I'm unclear where the value of that argument is being set or why the code fails without it. def change_volume(v): track.set_volume(volume.get()) volume_scale = Scale(app, variable = volume, from_= 0.0, to = 1.0, resolution = 0.1, command = change_volume, label= Volume, orient = HORIZONTAL) I'm not familiar with the wodget in question but it looks like the command callback expects to pass a parameter to the callback function. Therefore the function needs to provide a placeholder even though it doesn't use it! You would need to find the documentation for the widget to confirm that theory however. A Google seartch threw up this: http://infohost.nmt.edu/tcc/help/pubs/tkinter/scale.html Which seems to confirm my theory :-) -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] help me and ill love u!!! :)
On 3/21/07, p l [EMAIL PROTECTED] wrote: im a new python programmer and iv been given a task to get as much details that i can on my system memory... Since this is very low level hacking, you need to specify which operating system you use. -- - Rikard - http://bos.hack.org/cv/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] help me and ill love u!!! :)
hello tutor! im a new python programmer and iv been given a task to get as much details that i can on my system memory... now, i have allready found how to get the total physical memory and the avalible memory.. iv also found how to get the virtual mem and a few more stuff... but now im stuck!! i must find a way to find out the amount of memory sticks i have on the system (if possible how many slots are there and how many slots are being used) and also if it is possible the size in mb each one of sticks has... also i need to know the type of memory (f.e ddr, ddr2) those 2 are basicly the most important things but the more info i can get about the memory the better thanks! electricitymen ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] help me to do my exercise
On 3/5/07, Vasile Filat [EMAIL PROTECTED] wrote: I just started learning Python from a book translated intro Russian. It is my first exercise from the book and I don't know why it is not working. Help me please to correct my code which I will include below. You need to tell us why it's not working. Do you get any error messages? Unexpected output? Loops never exiting? -- - Rikard. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] help me to do my exercise
Vasile Filat schrieb: Help me please to correct my code which I will include below. It is customary to include code examples either inline in your message or attach them as a plain text source code file. Some mailing list frown on attachments in general (but this one doesn't, to my knowledge), but binary attachments, like the image you sent, should be avoided. If you want to show us longer code examples, use a pasting bin [1] One reason why it's not a good idea to show us your code as a screenshot from your editor is that we have to type it up again, if we want to refer to it in our replies. Would you want to make this (unnecessary) effort? Chris [1] http://en.wikipedia.org/wiki/Pastebin ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] help me to do my exercise
In addition to what the others have said, you have a syntax error on line 7 of your leap.py file. The 'for' loop will want an iterable to loop over. The syntax error relates to the list you are trying to use, a slice of sys.argv. Remember, lists are denoted by square brackets '[' and ']'. http://diveintopython.org/native_data_types/lists.html ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] help me to do my exercise
Vasile Filat [EMAIL PROTECTED] wrote I just started learning Python from a book translated intro Russian. It is my first exercise from the book and I don't know why it is not working. OK, First please send the code as text rather than as an image. It makes it much easier to comment when we can cut n paste sections into email. Secondly please send along any error messages. OK, Now looking at you code. Thee are several syntax errors which python should be complaining about. The first I see is: for i in sys.argvj 1:]: I suspect the j should be a [ Next you have no indentation after the except: also you have a colon after the continue plus a block of code. continue just makes the loop go round again... Next your test for y*100 == 0 will only pass if y is zero! You only print the Gregorian result if y % 4 is zero, but not if y%400 is zero... That should be enough to keep you busy. Please post text next time. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.freenetpages.co.uk/hp/alan.gauld ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help me with this problem relating to datetime
Thanks for your reply, John. I'll get back to you if I get stuck. Regards, Asrarahmmed On 11/16/06, John Fouhy [EMAIL PROTECTED] wrote: On 16/11/06, Asrarahmed Kadri [EMAIL PROTECTED] wrote: Hi Folks, I have got a date (as string), time (as string) , number of slots ( integer) and delta ( which is in seconds). I want to create a dictionary which has got date as the key, and the value should be a tuple with two elements (start_time, end_time). I will take start_time and find the end_time using delta. This pair of start and end times have a corresponding date. The date will be used as the key for the dictionary. Once the time crosses midnight, the date will change. Which part are you having trouble with? To convert a string into a Date or Datetime object, use time.strptime(), and then build a Datetime from the resulting time_tuple. (in Python2.5, I think, the datetime module has its own strptime() function, which short-cuts this process) -- John. -- To HIM you shall return. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Help me with this problem relating to datetime
Hi Folks, I have got a date (as string), time (as string) , number of slots ( integer) and delta ( which is in seconds). I want to create a dictionary which has got date as the key, and the value should be a tuple with two elements (start_time, end_time). I will take start_time and find the end_time using delta. This pair of start and end times have a corresponding date. The date will be used as the key for the dictionary. Once the time crosses midnight, the date will change. Can you help me to implement this functionality? TIA. Best Regards, Asrarahmed -- To HIM you shall return. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help me with this problem relating to datetime
SOrry for that. I was wondering if someoen can give a hint about the implementation. I am not asking for the actual code. Regards, Asrarahmed On 11/16/06, Luke Paireepinart [EMAIL PROTECTED] wrote: Asrarahmed Kadri wrote: Hi Folks, I have got a date (as string), time (as string) , number of slots ( integer) and delta ( which is in seconds). I want to create a dictionary which has got date as the key, and the value should be a tuple with two elements (start_time, end_time). I will take start_time and find the end_time using delta. This pair of start and end times have a corresponding date. The date will be used as the key for the dictionary. Once the time crosses midnight, the date will change. Can you help me to implement this functionality? yes. http://catb.org/esr/faqs/smart-questions.html#prune :). -Luke TIA. Best Regards, Asrarahmed -- To HIM you shall return. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor -- To HIM you shall return. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help me with this problem relating to datetime
Asrarahmed Kadri wrote: Hi Folks, I have got a date (as string), time (as string) , number of slots ( integer) and delta ( which is in seconds). I want to create a dictionary which has got date as the key, and the value should be a tuple with two elements (start_time, end_time). I will take start_time and find the end_time using delta. This pair of start and end times have a corresponding date. The date will be used as the key for the dictionary. Once the time crosses midnight, the date will change. Can you help me to implement this functionality? yes. http://catb.org/esr/faqs/smart-questions.html#prune :). -Luke TIA. Best Regards, Asrarahmed -- To HIM you shall return. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help me with this problem relating to datetime
On 16/11/06, Asrarahmed Kadri [EMAIL PROTECTED] wrote: Hi Folks, I have got a date (as string), time (as string) , number of slots ( integer) and delta ( which is in seconds). I want to create a dictionary which has got date as the key, and the value should be a tuple with two elements (start_time, end_time). I will take start_time and find the end_time using delta. This pair of start and end times have a corresponding date. The date will be used as the key for the dictionary. Once the time crosses midnight, the date will change. Which part are you having trouble with? To convert a string into a Date or Datetime object, use time.strptime(), and then build a Datetime from the resulting time_tuple. (in Python2.5, I think, the datetime module has its own strptime() function, which short-cuts this process) -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help me with installing Soappymodule
Asrarahmed Kadri wrote: Hi Folks, I want to install SOAPpy module. As stated on http://pywebsvcs.sourceforge.net/soappy.txt, there are two modules that should be installed prior to installing SOAPpy. One in pyXML and the other is fpconst. I installed pyXML from the URL stated on teh above website. But the URL for fpconst download is not valid. Any idea as to where can I get the module . Try this one: http://cheeseshop.python.org/pypi/fpconst/0.7.2 Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Help me with installing Soappymodule
Hi Folks, I want to install SOAPpy module. As stated on http://pywebsvcs.sourceforge.net/soappy.txt, there are two modulesthat should be installed prior to installing SOAPpy. One in pyXML and the other is fpconst. I installed pyXML from the URL stated on teh above website. But the URL for fpconst download is not valid. Any idea as to where can I get the module . TIA. Regards, Asrarahmed -- To HIM you shall return. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Help me to debug this script .. I tried but ....
Hi Folks, I have a function defined in a module. I am using this module in a script but its giving me error: the traceback is as follows: Beginning of Output: 29/2/2003['29', '2', '2003']Traceback (most recent call last): File C:\Python24\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py, line 310, in RunScript exec codeObject in __main__.__dict__ File C:\project stuff-programs\Scriptdate.py, line 18, in ? t1 = my_version_datecheck.dateCheck(dt1,0) File my_version_datecheck.py, line 38, in dateCheck import traceback NameError: global name 'traceback' is not defined OUTPUT Ends The module name is : my_version_datecheck.py CODE BEGINS import stringimport datetimeimport time def dateCheck(date1,num_days): flag = True startdate = None enddate = None if num_days 0 or num_days 31: flag = False print The argument for -n has to be between 0 and 31 return (flag,startdate,enddate) else: print date1 date_lst = string.split(date1,/) print date_lst ln = len(date_lst) if ln != 3: flag = False print The argument for -D option has to be in the format: dd/mm/ return (flag,startdate,enddate) else: date_lst.reverse() try: startdate = datetime.date(int(date_lst[0]),int(date_lst[1]),int(date_lst[2])) enddate = startdate + datetime.timedelta(days=num_days) except ValueError: import traceback flag = False err_msg = traceback.format_exc() index = string.find(err_msg,'Value') print err_msg[index:] return (flag,startdate,enddate) return (flag,startdate,enddate) CODE ENDS The code for test script is as follows: Code Begins import my_version_datecheck import traceback dt = '12/3/2005' dt1 = '29/2/2003' dt2 = '3/32/5m' t = my_version_datecheck.dateCheck(dt,0) print t t1 = my_version_datecheck.dateCheck(dt1,0) print t1 t2 = my_version_datecheck.dateCheck(dt2,0) print t2 Code Ends TIA. Regards, Asrarahmed-- To HIM you shall return. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help me to debug this script .. I tried but ....
Asrarahmed Kadri wrote: C:\Python24\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py, line 310, in RunScript exec codeObject in __main__.__dict__ File C:\project stuff-programs\Scriptdate.py, line 18, in ? t1 = my_version_datecheck.dateCheck(dt1,0) File my_version_datecheck.py, line 38, in dateCheck import traceback NameError: global name 'traceback' is not defined This tells you everything you need to know right here. What version of Python are you using? I know traceback existed at least in 2.3. Might be time to consider an upgrade. Dustin ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help me to debug this script .. I tried but ....
Dustin J. Mitchell wrote: Asrarahmed Kadri wrote: C:\Python24\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py, line 310, in RunScript exec codeObject in __main__.__dict__ File C:\project stuff-programs\Scriptdate.py, line 18, in ? t1 = my_version_datecheck.dateCheck(dt1,0) File my_version_datecheck.py, line 38, in dateCheck import traceback NameError: global name 'traceback' is not defined This tells you everything you need to know right here. What version of Python are you using? I know traceback existed at least in 2.3. Might be time to consider an upgrade. If traceback was not a valid module name the import would raise ImportError, not NameError. Something strange is going on here; have you shown us all the code? Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help me to debug this script .. I tried but ....
Kent Johnson wrote: Dustin J. Mitchell wrote: Asrarahmed Kadri wrote: C:\Python24\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py, line 310, in RunScript exec codeObject in __main__.__dict__ File C:\project stuff-programs\Scriptdate.py, line 18, in ? t1 = my_version_datecheck.dateCheck(dt1,0) File my_version_datecheck.py, line 38, in dateCheck import traceback NameError: global name 'traceback' is not defined This tells you everything you need to know right here. What version of Python are you using? I know traceback existed at least in 2.3. Might be time to consider an upgrade. If traceback was not a valid module name the import would raise ImportError, not NameError. Something strange is going on here; have you shown us all the code? Python caches the text of programs, and will show that in later tracebacks. Try restarting your IDE and running the script again, or look on line 38 of my_version_datecheck.py -- I bet it doesn't say import traceback. Dustin ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help me to debug this script .. I tried but ....
When I am running the script from the command line, its working fine but when I am trying to run from Pythonwin, its giving me error. Can anyone explain the reason? Regards, Asrarahmed On 11/5/06, Kent Johnson [EMAIL PROTECTED] wrote: Dustin J. Mitchell wrote: Asrarahmed Kadri wrote: C:\Python24\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py, line 310, in RunScript exec codeObject in __main__.__dict__ File C:\project stuff-programs\Scriptdate.py, line 18, in ? t1 = my_version_datecheck.dateCheck(dt1,0) File my_version_datecheck.py, line 38, in dateCheck import traceback NameError: global name 'traceback' is not defined This tells you everything you need to know right here. What version of Python are you using?I know traceback existed at least in 2.3.Might be time to consider an upgrade.If traceback was not a valid module name the import would raiseImportError, not NameError. Something strange is going on here; have you shown us all the code?Kent___Tutor maillist-Tutor@python.org http://mail.python.org/mailman/listinfo/tutor-- To HIM you shall return. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help me to debug this script .. I tried but ....
On Sun, 5 Nov 2006, Asrarahmed Kadri wrote: When I am running the script from the command line, its working fine but when I am trying to run from Pythonwin, its giving me error. Can anyone explain the reason? Hi Asrarahmed, Did you see Kent's reply? He mentioned: Something strange is going on here; have you shown us all the code? I agree with Kent. I suspect something very funky is going on here, especially since the error message says that you're doing an 'import traceback' within a function called dateCheck(). That's highly unusual: people usually put their imports at the top level. The error message that's coming out has hints of weirdness in it: File C:\project stuff-programs\Scriptdate.py, line 18, in ? t1 = my_version_datecheck.dateCheck(dt1,0) File my_version_datecheck.py, line 38, in dateCheck import traceback NameError: global name 'traceback' is not defined Why would the code try to do an import on line 38? That's way deep in the middle of your program. Very strange. The most likely thing that's going on, given the information so far, is that the line numbers are wrong, and that 'my_version_datecheck' has been changed while the program is running. We don't have enough information to duplicate your error yet. So please show us your 'my_version_datecheck.py'. Otherwise, we really can't do much else except guess at the problem. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Help me with graphs...using tkinter
Hi folks, I want to draw bar-charts using Tkinter. I am not able to find material on this topic. Help me Regards, Asrarahmed -- To HIM you shall return. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help me with graphs...using tkinter
Hi Asrarahmed, On Wed, 1 Nov 2006 16:16:31 + Asrarahmed Kadri [EMAIL PROTECTED] wrote: Hi folks, I want to draw bar-charts using Tkinter. I am not able to find material on this topic. have a look at the Canvas widget and especially at its create_rectangle() method. Documentation is here: http://effbot.org/tkinterbook/ I hope this helps Michael ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help me.. problem in building calculator application
Asrarahmed Kadri wrote: Hi folks, I am trying to build a rudimentary calculator application using Tkinter... I have used one Entry widget for displaying the input and output data. All this is put in a class. The porblem is when I click teh '+' button, teh callback function is called but it gives me an error message: AttributeError: 'str' object has no attribute 'get' I have defined a variable, self.str1 = StringVar() to bind it with the entry widget and I am calling the function when + is clciked. The function is as follows: self.buttonPlu = Button(self.container3,text='+',command = lambda: self.oprClick('+',*self.str1.get()))* Can't we use the get() method to access the contents of the entry widget. Is there any other way to access the contents of the entry widget??? The error message is saying that the object you are calling get() on is a string, not a StringVar. Please post complete code and the complete error message including traceback. Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help me.. problem in building calculator application
Message: 7 Date: Thu, 26 Oct 2006 13:31:37 +0100 From: Asrarahmed Kadri [EMAIL PROTECTED] Subject: [Tutor] Help me.. problem in building calculator application To: pythontutor tutor@python.org Message-ID: [EMAIL PROTECTED] Content-Type: text/plain; charset=iso-8859-1 Hi folks, I am trying to build a rudimentary calculator application using Tkinter... Hi, Asrar! Try this article instead: http://www.devshed.com/c/a/Python/Designing-a-Calculator-in-wxPython/ Paulino ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Help me abt this error
I am trying to write to a file, but I am getting this errror. IOError: (0, 'Error') Can someone explain what is it and whats the solution?? Thanks. Regards, Asrar ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help me abt this error
Asrarahmed Kadri wrote: I am trying to write to a file, but I am getting this errror. IOError: (0, 'Error') Can someone explain what is it and whats the solution?? No. Give us the actual source and the full traceback. Cheers, -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help me abt this error
I am trying to write to a file, but I am getting this errror. IOError: (0, 'Error') Can someone explain what is it and whats the solution?? Hi Asrarahmed, Did you read my response from the last few days? http://mail.python.org/pipermail/tutor/2006-October/049958.html Did you find it helpful? I thought it directly addressed the question you had on: http://mail.python.org/pipermail/tutor/2006-October/049937.html If it doesn't apply, at least please mention that it didn't work for you; at least we'll be able to cross off that possibility. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help me abt this error
Oops, I replied off-list. Forwarding to list. ---BeginMessage--- Mike Hansen wrote: -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Luke Paireepinart Sent: Tuesday, October 17, 2006 11:50 AM To: Asrarahmed Kadri Cc: pythontutor Subject: Re: [Tutor] Help me abt this error Asrarahmed Kadri wrote: I am trying to write to a file, but I am getting this errror. IOError: (0, 'Error') Can someone explain what is it and whats the solution?? No. Give us the actual source and the full traceback. Cheers, -Luke Luke, don't fall to the dark side. You must be a kind Python Jedi. E-mail is a strange communication tool in that the reader doesn't see your kind Python Jedi disposition but instead can interpret your bluntness as being mean and Sith-like. Haha. At least you didn't say that Vader quote I hear oh-so-much. Luke, I am your father! Uh, 1) You're not my father, so it doesn't make sense, and 2) Vader never actually said that. He said No. I am your father. :O Yeah, I didn't mean to sound cold. I thought I put a smiley at the end so he'd know I wasn't serious, but I guess I forgot! Nevertheless, it's important that the OP asks good questions. I'm pretty sure I know what caused his error, but I don't want to encourage him to ask incomplete questions, so I'm withholding an answer. :) -Luke ---End Message--- ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help me abt this error
I changed to append mode and itis working. But the thing is that I have another problem. I am trying to insert usernames that are unique. Please look at the code and help me. import sys fd = open('usr.txt','a') def chk(str): global fd fd.seek(0,0) print fd done = 0 list1 = [] answer = True while not done: aline = fd.readline () if aline == : done = 1 else: list1.append(aline) print list1 for i in list1: print i j = i.split(':') if str == j[0]: answer = False break return answer def make_entry(uname,passwd): global fd fd.seek(0,2) str1 = uname+':'+passwd fd.write(str1+'\n') enter_choice() def die(): sys.exit(0) def new_user(): uname = raw_input(Enter your desired username) ans = chk(uname) print ans if ans: passwd = raw_input(Enter your password) make_entry(uname,passwd) else: showerror('Login Error...','Id already taken') new_user() def display_menu(): print - * 30 print Select 1 for new user: print Select 2 to exit print - * 30 def enter_choice(): display_menu() print choice = raw_input(Enter your choice) if choice == '1': new_user() else: die() enter_choice() The problem is in the chk() function.. It is not reading the file The file is a txt file with colon (:) as the delimiter between username and password. I cannot understand why its not reading??? Please help... On 10/17/06, Luke Paireepinart [EMAIL PROTECTED] wrote: Asrarahmed Kadri wrote: I am trying to write to a file, but I am getting this errror. IOError: (0, 'Error') Can someone explain what is it and whats the solution??No.Give us the actual source and the full traceback.Cheers,-Luke-- To HIM you shall return. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help me abt this error
Asrarahmed Kadri wrote: I changed to append mode and it is working. But the thing is that I have another problem. I am trying to insert usernames that are unique. Please look at the code and help me. import sys fd = open('usr.txt','a') append mode is write-only. more comments further down. def chk(str): global fd fd.seek(0,0) print fd done = 0 list1 = [] answer = True while not done: aline = fd.readline () if aline == : done = 1 else: list1.append(aline) print list1 for i in list1: print i j = i.split(':') if str == j[0]: answer = False break return answer Can I politely request that you don't add color to your functions? It makes it harder for me to read them. I know you're trying to place emphasis on which functions are giving you problems, but if you were to just comment them instead I'd be happy :) For your problem about reading the file, I would suggest that you keep the contents in memory, or read the file each time and close it, instead of trying to keep an open copy of it around and seeking and such. Since you're opening the file in append mode, you aren't able to do reads. you could use 'a+', but I don't recommend it. You'll probably run into weird behavior, and maybe only on certain inputs (I.E. scary bugs that you might not notice till your program is in use already.) HTH, -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Help me : Why this code is not working??
I have created two buttons. The code for button2 is not working as I want it to be. When I click button2, the application should exit, but it isnt. Can someone fix it?? from Tkinter import *from tkMessageBox import * def callback(): showinfo('message','I am here...') def QUIT(): ans = askyesno('Confirm','Do you really want to quit?') if ans: root.exit else: showinfo('Selection','You have decided to stay on') root = Tk()win = Frame(root)win.pack() button1 = Button(win,text='Hello',command=callback)button1.pack(side=LEFT) button2 = Button(win,text='Quit',command=QUIT)button2.pack(side=RIGHT) root.mainloop()-- To HIM you shall return. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help me : Why this code is not working??
Asrarahmed Kadri wrote: I have created two buttons. The code for button2 is not working as I want it to be. When I click button2, the application should exit, but it isnt. Can someone fix it?? from Tkinter import * from tkMessageBox import * def callback(): showinfo('message','I am here...') def QUIT(): ans = askyesno('Confirm','Do you really want to quit?') if ans: root.exit SEND US THE TRACEBACK :) Don't just tell us that something doesn't work. The traceback contains valuable information that tells you (or us) how to debug it. In this case,the traceback was #// Exception in Tkinter callback Traceback (most recent call last): File C:\Python24\lib\lib-tk\Tkinter.py, line 1345, in __call__ return self.func(*args) File C:/Python24/temp.py, line 10, in QUIT root.exit File C:\Python24\lib\lib-tk\Tkinter.py, line 1654, in __getattr__ return getattr(self.tk, attr) AttributeError: exit # Okay, so what do we see here? Start reading from the bottom. AttributeError: exit. okay, so that means that we tried to access a method or a variable of a class, and it wasn't there. It lacked that attribute. Which class was it? looking further up the stack, we see where we access 'exit.' line 10, in QUIT: root.exit This means that whatever class root is an instance of doesn't have a method named exit. Remember, the computer is stupid. To the computer, 'exit' and 'quit' mean something as different as 'root beer' and 'trash can' would to us. The method you're trying to access is called 'quit', not 'exit' That's your first problem. The second problem you have, is that you're not calling this method, you're just accessing it, which doesn't really do anything. What you'll want to do is root.quit() and not root.quit HTH, -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help me : Why this code is not working??
Thanks a lot. It was quick. I will send the traceback from now on. -Asrar On 10/13/06, Luke Paireepinart [EMAIL PROTECTED] wrote: Asrarahmed Kadri wrote: I have created two buttons. The code for button2 is not working as I want it to be. When I click button2, the application should exit, but it isnt. Can someone fix it?? from Tkinter import * from tkMessageBox import * def callback(): showinfo('message','I am here...') def QUIT(): ans = askyesno('Confirm','Do you really want to quit?') if ans: root.exitSEND US THE TRACEBACK :) Don't just tell us that something doesn't work.The traceback contains valuable information that tells you (or us) howto debug it.In this case,the traceback was#//Exception in Tkinter callback Traceback (most recent call last):File C:\Python24\lib\lib-tk\Tkinter.py, line 1345, in __call__ return self.func(*args)File C:/Python24/temp.py, line 10, in QUIT root.exitFile C:\Python24\lib\lib-tk\Tkinter.py, line 1654, in __getattr__ return getattr(self.tk, attr)AttributeError: exit#Okay, so what do we see here?Start reading from the bottom.AttributeError: exit.okay, so that means that we tried to access a method or a variable of a class,and it wasn'tthere.It lacked that attribute.Which class was it?looking further up the stack, we see where we access 'exit.'line 10, in QUIT:root.exitThis means that whatever class root is an instance of doesn't have a method named exit.Remember, the computer is stupid.To the computer, 'exit' and 'quit'mean something as differentas 'root beer' and 'trash can' would to us.The method you're trying toaccess is called 'quit', not 'exit' That's your first problem.The second problem you have, is that you're not calling this method,you're just accessing it, which doesn't really do anything.What you'll want to do isroot.quit() and notroot.quitHTH,-Luke-- To HIM you shall return. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help me with this Tkinter code
On Tue, 10 Oct 2006 23:32:57 +0100 Asrarahmed Kadri [EMAIL PROTECTED] wrote: The error message is as under: *Microsoft Visual C++ Runtime Library* * Runtime Error! Program: C:\python\Lib\site-packages\pythonwin\Pythonwin.exe* * This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more inforamtion.* Any idea??? what is this and how can it be fixed??? If you run a Tkinter program from IDLE you should not call mainloop(), as Alan pointed out before, you try to run a new mainloop inside the already existing one which confuses Tk (at least this was true for the version of IDLE i had used). I hope this helps Michael ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Help me with this Tkinter code
Folks, Just started to get my feet wet with basics of Tkinter Programming. Here is a code which is giving me some problem; when I run it, it displays me the button widget, but when I click it, the window doesn't goes away. the program gets stuck up. Can anyone help me to resolve this issue?? import sysfrom Tkinter import * root = Tk()widget = Button(root, text='Hello widget world', command=root.quit)widget.pack( )widget.mainloop( ) Thanks. Regards, Asrar -- To HIM you shall return. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help me with this Tkinter code
Asrarahmed Kadri wrote: Folks, Just started to get my feet wet with basics of Tkinter Programming. Here is a code which is giving me some problem; when I run it, it displays me the button widget, but when I click it, the window doesn't goes away. the program gets stuck up. Can anyone help me to resolve this issue?? *import sys from Tkinter import ** *root = Tk() widget = Button(root, text='Hello widget world', command=root.quit) widget.pack( ) widget.mainloop( )* shouldn't you mainloop your root? also, are you using IDLE? Thanks. Regards, Asrar -- To HIM you shall return. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help me with this Tkinter code
yeh, I am using IDLE. why, is it a problem?? On 10/10/06, Luke Paireepinart [EMAIL PROTECTED] wrote: Asrarahmed Kadri wrote: Folks, Just started to get my feet wet with basics of Tkinter Programming. Here is a code which is giving me some problem; when I run it, it displays me the button widget, but when I click it, the window doesn't goes away. the program gets stuck up. Can anyone help me to resolve this issue?? *import sys from Tkinterimport ** *root = Tk() widget = Button(root, text='Hello widget world', command=root.quit) widget.pack( ) widget.mainloop ( )*shouldn't you mainloop your root?also, are you using IDLE? Thanks. Regards, Asrar -- To HIM you shall return. ___ Tutor maillist-Tutor@python.org http://mail.python.org/mailman/listinfo/tutor -- To HIM you shall return. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help me with this Tkinter code
i changed the code from widget.mainloop() to root.mainloop(); but still its not working On 10/10/06, Asrarahmed Kadri [EMAIL PROTECTED] wrote: yeh, I am using IDLE. why, is it a problem?? On 10/10/06, Luke Paireepinart [EMAIL PROTECTED] wrote: Asrarahmed Kadri wrote: Folks, Just started to get my feet wet with basics of Tkinter Programming. Here is a code which is giving me some problem; when I run it, it displays me the button widget, but when I click it, the window doesn't goes away. the program gets stuck up. Can anyone help me to resolve this issue?? *import sys from Tkinterimport ** *root = Tk() widget = Button(root, text='Hello widget world', command=root.quit) widget.pack( ) widget.mainloop ( )*shouldn't you mainloop your root?also, are you using IDLE? Thanks. Regards, Asrar -- To HIM you shall return. ___ Tutor maillist-Tutor@python.org http://mail.python.org/mailman/listinfo/tutor -- To HIM you shall return. -- To HIM you shall return. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help me with this Tkinter code
On 11/10/06, Luke Paireepinart [EMAIL PROTECTED] wrote: shouldn't you mainloop your root? By convention, you should, but you don't have to. mainloop is mainloop; calling it on root just makes it easy to find. -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help me with this Tkinter code
The error message is as under: Microsoft Visual C++ Runtime Library Runtime Error!Program: C:\python\Lib\site-packages\pythonwin\Pythonwin.exe This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more inforamtion.Any idea??? what is this and how can it be fixed??? On 10/10/06, John Fouhy [EMAIL PROTECTED] wrote: On 11/10/06, Luke Paireepinart [EMAIL PROTECTED] wrote: shouldn't you mainloop your root?By convention, you should, but you don't have to.mainloop ismainloop; calling it on root just makes it easy to find.--John.___ Tutor maillist-Tutor@python.orghttp://mail.python.org/mailman/listinfo/tutor -- To HIM you shall return. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help me with this Tkinter code
yeh, I am using IDLE. why, is it a problem?? IDLE is a Tkinter program. So you are trying to run a Tkinter program inside a Tkinter program which can confuse things. The latest versions of IDLE are a lot better but I stilll strongly recommend running any Tkinter , indeed any GUI) programme, from the OS prompt - or by double clicking in Windows exploder Alan G. On 10/10/06, Luke Paireepinart [EMAIL PROTECTED] wrote: Asrarahmed Kadri wrote: Folks, Just started to get my feet wet with basics of Tkinter Programming. Here is a code which is giving me some problem; when I run it, it displays me the button widget, but when I click it, the window doesn't goes away. the program gets stuck up. Can anyone help me to resolve this issue?? *import sys from Tkinter import ** *root = Tk() widget = Button(root, text='Hello widget world', command=root.quit) widget.pack( ) widget.mainloop( )* shouldn't you mainloop your root? also, are you using IDLE? Thanks. Regards, Asrar -- To HIM you shall return. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor -- To HIM you shall return. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help me with two dimensional arrays in Python
Dear Asrarahmed, I have found the next recipe in the cookbook. It should be interesting for you :) http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/392153 Message: 1 Date: Thu, 05 Oct 2006 10:26:19 -0400 From: Kent Johnson [EMAIL PROTECTED] Subject: Re: [Tutor] Help me with two dimensional arrays in Python Cc: tutor@python.org Message-ID: [EMAIL PROTECTED] Content-Type: text/plain; charset=ISO-8859-1; format=flowed Asrarahmed Kadri wrote: Its something very close. What I want is: 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 Yours sincerely, __ János Juhász ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help me with two dimensional arrays in Python
Its something very close. What I want is: 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 This can be done using arrays, right or is there any other way?? My logic in C is: int arr[5][5]; for (i=0;i5;i++) { flag = 0; for (j=0;j=i;j++) { if (flag == 0 || j == i) // print 1 if the array element is the first or the last number { arr[i][j] = 1; flag = 1; } arr[i][j] = arr[i-1][j-1] + arr[i-1][j]; } thanks. On 10/4/06, Matthew White [EMAIL PROTECTED] wrote: Asrarahmed,How about something like this: arr = [] arr.append(['Blue', 'Yellow', 'Green', 'Brown', 'White']) arr[0][0]'Blue' arr.append(['Up', 'Down', 'Left', 'Right', 'Center']) arr[1][4]'Center'Is this what you were thinking of?-mtwOn Wed, Oct 04, 2006 at 06:38:09PM +0100, Asrarahmed Kadri ( [EMAIL PROTECTED]) wrote: I am looking for something like this: int arr[5][5]; // C statement; declaring an array of 5 * 5 size Is there an easy and clean way to achieve this in python??? Thanks On 10/4/06, Kent Johnson [EMAIL PROTECTED] wrote: Asrarahmed Kadri wrote: Hi folks, I am stuck.. Please help me with implementing two dimensional array in Python. Nested lists are the simplest way though beware the gotcha shown here: http://www.python.org/doc/faq/programming/#how-do-i-create-a-multidimensional-list You can also use a dict with tuple indices, e.g. d[1,2] = 3 Numpy is an extension designed for high-performance numerical work, it includes a multidimensional array type: http://numpy.scipy.org// Kent -- To HIM you shall return. ___ Tutor maillist-Tutor@python.org http://mail.python.org/mailman/listinfo/tutor -- To HIM you shall return. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help me with two dimensional arrays in Python
Asrarahmed Kadri wrote: Its something very close. What I want is: 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 This can be done using arrays, right or is there any other way?? They're not arrays, they're lists! arrays imply contiguous memory blocks and single data types. Lists are neither of these. My logic in C is: int arr[5][5]; for (i=0;i5;i++) { flag = 0; for (j=0;j=i;j++) { if (flag == 0 || j == i) // print 1 if the array element is the first or the last number { arr[i][j] = 1; flag = 1; } arr[i][j] = arr[i-1][j-1] + arr[i-1][j]; } Yes, you could do this in Python. I'm guessing it'd be something like this: lst = [] for x in range(5): tmp = [] for y in range(x): if y == 0: tmp.append(1) else: tmp.append(tmp[y-1]) #this line would be different lst.append(tmp) That's the best I can do. HTH, -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help me with two dimensional arrays in Python
Thank you so much. I am trying to implement. I hope I can do it. A gentle note: This is not a homework question. I am learning python as a part of my Project work. On 10/5/06, Luke Paireepinart [EMAIL PROTECTED] wrote: Asrarahmed Kadri wrote: Its something very close. What I want is: 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 This can be done using arrays, right or is there any other way??They're not arrays, they're lists!arrays imply contiguous memory blocks and single data types. Lists are neither of these. My logic in C is: int arr[5][5]; for (i=0;i5;i++) {flag = 0;for (j=0;j=i;j++) {if (flag == 0 || j == i)// print 1 if the array element is the first or the last number{ arr[i][j] = 1; flag = 1; } arr[i][j] = arr[i-1][j-1] + arr[i-1][j]; }Yes, you could do this in Python.I'm guessing it'd be something like this: lst = []for x in range(5): tmp = [] for y in range(x):if y == 0: tmp.append(1)else: tmp.append(tmp[y-1]) #this line would be different lst.append(tmp) That's the best I can do.HTH,-Luke-- To HIM you shall return. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help me with two dimensional arrays in Python
Asrarahmed Kadri wrote: Its something very close. What I want is: 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 This can be done using arrays, right or is there any other way?? Is this a homework assignment? A list of lists seems like the appropriate way to represent this, especially since it is not actually a square array. Here is a simpler example that might give you some ideas: In [5]: b=[] In [6]: for i in range(5): ...: b.append(range(i)) ...: ...: In [7]: b Out[7]: [[], [0], [0, 1], [0, 1, 2], [0, 1, 2, 3]] Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Help me with two dimensional arrays in Python
Hi folks, I am stuck.. Please help me with implementing two dimensional array in Python. Thanks. -- To HIM you shall return. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help me with two dimensional arrays in Python
Asrarahmed Kadri wrote: Hi folks, I am stuck.. Please help me with implementing two dimensional array in Python. There are no such things as arrays in Python, silly! I can help you with a two-dimensional list, though :) Okay, imagine that a list of integers (or any other objects) is a single object itself, that keeps track of the integers (or other objects) for you in whatever order you want. somelist = [1,2,3,4,5] anotherlist = [6,7,8,9,10] Now what you want out of a two-dimensional list is where there are multiple inner lists, with each individual list being a full row, right? so... two_dimensional = [somelist,anotherlist] Or: two_dimensional = [ [1,2,3,4,5] , [6,7,8,9,10] ] This isn't a homework question, right? Good luck, -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help me with two dimensional arrays in Python
Asrarahmed Kadri wrote: Hi folks, I am stuck.. Please help me with implementing two dimensional array in Python. Nested lists are the simplest way though beware the gotcha shown here: http://www.python.org/doc/faq/programming/#how-do-i-create-a-multidimensional-list You can also use a dict with tuple indices, e.g. d[1,2] = 3 Numpy is an extension designed for high-performance numerical work, it includes a multidimensional array type: http://numpy.scipy.org// Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help me with two dimensional arrays in Python
Asrarahmed Kadri wrote: I am looking for something like this: int arr[5][5]; // C statement; declaring an array of 5 * 5 size Is there an easy and clean way to achieve this in python??? Can you say something about your use case? If I had to guess I would say numpy is what you are looking for. Did you look at my suggestions? Are you a Python beginner? Kent Thanks On 10/4/06, *Kent Johnson* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Asrarahmed Kadri wrote: Hi folks, I am stuck.. Please help me with implementing two dimensional array in Python. Nested lists are the simplest way though beware the gotcha shown here: http://www.python.org/doc/faq/programming/#how-do-i-create-a-multidimensional-list http://www.python.org/doc/faq/programming/#how-do-i-create-a-multidimensional-list You can also use a dict with tuple indices, e.g. d[1,2] = 3 Numpy is an extension designed for high-performance numerical work, it includes a multidimensional array type: http://numpy.scipy.org// Kent -- To HIM you shall return. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help me with two dimensional arrays in Python
I am stuck.. Please help me with implementing two dimensional array in Python. Hi Asrarahmed, What do you need a two-dimensional array for? This is a serious question: what's your application? What are you trying to represent, and why? As a glib possible answer: you can use a dictionary to map 2-tuples to values. If you think about it, that's almost what a 2d array does in other languages. ## points = {} points[(3, 4)] = 1 points[(1, 7)] = 2 ## But this may not be the right approach for your problem. Tell us more of what you are trying to do. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help me make it look pretty!
On Thu, 20 Jul 2006 20:16:58 +0100 John CORRY [EMAIL PROTECTED] wrote: Good evening all. I am writing a program using python 2.4, glade 2 and pygtk. It takes input from the user using textentry boxes. The input should be a number. When the user keys the data in, it automatically left justifies. The function below, takes the input for four boxes and right justifies it by using an ugly, string format. The boxes are 45 characters big, so I use the len function to fit them into the box. The code is below. I am looking for a way to set the text entry up, so that there is a decimal point in the box regardless of what the user does and I am also looking for a way to keep the numbers right justified. Any suggestions or comments as always are greatly appreciated. Hi John, I don't know about gtk, but have made some experience validating the user input in Tkinter Entries, so I can only try to give you some general advice. First, the Tkinter.Entry has a configuration option justify, so entry.config(justify=RIGHT) would very simply solve the first problem; are you sure the gtk entry box does not have something similar? Second, I found validating (and especially on-the-fly-converting) user input is always a very tricky thing. Usually when testing some solution that seemed to work, I found that in some special cases the widget showed an completely unexpected behavior. Generally it is safer not to restrict user input too much and do the validation when the entry boxes' contents are actually needed; if it is not valid you can pop up a message box that tells the user what to do. If you really need to perform real time validation, make sure to test your widgets very carefully. Again, I don't know about gtk, in Tkinter you can pass a validatecommand to the entry widget to which you can pass the old and the new entry's contents, that is called each time the user types something into the entry box. If gtk offers something similar, you could start with something like: # pseudo code def validate(old, new): x = text38.get_text() if x in ('', '.'): ok = 1 elif '.' in x: try: float(x) ok = 1 except ValueError: print '\a'#acoustic feedback, in Tkinter I would use bell() of course ok = 0 else: try: int(x) text38.set_text('.'+x)#don't know how this would actually look in gtk, I hope you know what I mean ok = 1 except ValueError: print '\a' ok = 0 if not ok: # the new text is not allowed, restore the old text38.set_text(old) I bet this kind of solution has its traps, too. Maybe the best solution is a web search if someone else has already written such a widget. A quick google search for pygtk entry validation for example lead me here: http://www.astro.umass.edu/~dpopowich/python/ : ValidatedEntry, a pygtk extension providing a validated Entry widget ValidatedEntry is a subclass of gtk.Entry, providing validation of input based on programmable functions. Sample functions included in the package provide validation for integers, floats, non-empty strings, ISBN numbers, phone numbers, money and bounded values (e.g., integers in a range). A demo app is included in the package. The latest version, 1.0.4, can be downloaded here. Good luck! Michael ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help me make it look pretty!
John CORRY wrote: Good evening all. I am writing a program using python 2.4, glade 2 and pygtk. It takes input from the user using textentry boxes. The input should be a number. When the user keys the data in, it automatically left justifies. The function below, takes the input for four boxes and right justifies it by using an ugly, string format. The boxes are 45 characters big, so I use the len function to fit them into the box. The code is below. I'm not familiar with GTK but I would look for a way to set the alignment of the text field so it always right aligns. gtk-entry-set-alignment() looks promising: http://www.gtk.org/api/2.6/gtk/GtkEntry.html#gtk-entry-set-alignment More notes below I am looking for a way to set the text entry up, so that there is a decimal point in the box regardless of what the user does and I am also looking for a way to keep the numbers right justified. Any suggestions or comments as always are greatly appreciated. Regards, John. def callback36(self,data,text37,text38,text39,text40,text41,text42,label): a = text37.get_text() b = text38.get_text() c = text39.get_text() d = text40.get_text() a= float(a) b= float(b) c= float(c) d= float(d) try: e = float(a + b + c + d) g = e/a e = %0.2f % e g = %0.2f % g g = str(g) label.hide() e = %s % e a = %s % a b = %s % b c = %s % c d = %s % d g = %s%% % g String formatting can create the strings you want directly. str.rjust() is also useful here. For example In [1]: e=1./3 In [3]: '% 20.2f' % e Out[3]: '0.33' In [4]: '0.33'.rjust(20) Out[4]: '0.33' text42.set_text(str(g)) if len(e)45: x = len(e) - 45 x = x + 4 y = e[x:] text41.set_text(str(y)) return I think this is taking the last 41 chars of e if len(e) 45. You can get the last 41 chars of e directly with e[-41:] Kent else: text41.set_text(str(e)) return except: label.show() return ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Help me make it look pretty!
Good evening all. I am writing a program using python 2.4, glade 2 and pygtk. It takes input from the user using textentry boxes. The input should be a number. When the user keys the data in, it automatically left justifies. The function below, takes the input for four boxes and right justifies it by using an ugly, string format. The boxes are 45 characters big, so I use the len function to fit them into the box. The code is below. I am looking for a way to set the text entry up, so that there is a decimal point in the box regardless of what the user does and I am also looking for a way to keep the numbers right justified. Any suggestions or comments as always are greatly appreciated. Regards, John. def callback36(self,data,text37,text38,text39,text40,text41,text42,label): a = text37.get_text() b = text38.get_text() c = text39.get_text() d = text40.get_text() a= float(a) b= float(b) c= float(c) d= float(d) try: e = float(a + b + c + d) g = e/a e = %0.2f % e g = %0.2f % g g = str(g) label.hide() e = %s % e a = %s % a b = %s % b c = %s % c d = %s % d g = %s%% % g text42.set_text(str(g)) if len(e)45: x = len(e) - 45 x = x + 4 y = e[x:] text41.set_text(str(y)) return else: text41.set_text(str(e)) return except: label.show() return ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help me please
yogeshwarran Nadeson wrote: Hello, I am a newbie in python programming without previous programming experience.Here i would like to ask a question based on the exercises given by Josh Cogliatti in his tutorial.I'll paste the question.Hope you can help me to solve it.I'd like to end it by saying thanks for all yourr help. Have you written a program that uses loops? Could you write a program that uses a loop to print Hello three times? Kent *:Modify the password guessing program to keep track of how many times the user has entered the password wrong. If it is more than 3 times, print ``That must have been complicated.'' * This is the previous password program: Password.py # Waits until a password has been entered. Use control-C to break out with out # the password #Note that this must not be the password so that the # while loop runs at least once. password = foobar #note that != means not equal while password != unicorn: password = raw_input(Password:) print Welcome in ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Help me please
Hello, I am a newbie in python programming without previous programming experience.Here i would like to ask a question based on the exercises given by Josh Cogliatti in his tutorial.I'll paste the question.Hope you can help me to solve it.I'd like to end it by saying thanks for all yourr help. :Modify the password guessing program to keep track of how many times the user has entered the password wrong. If it is more than 3 times, print ``That must have been complicated.'' This is the previous password program: Password.py # Waits until a password has been entered. Use control-C to break out with out # the password #Note that this must not be the password so that the # while loop runs at least once. password = "foobar" #note that != means not equal while password != "unicorn": password = raw_input("Password:") print "Welcome in" Password.py # Waits until a password has been entered. Use control-C to break out with out # the password #Note that this must not be the password so that the # while loop runs at least once. password = "foobar" #note that != means not equal while password != "unicorn": password = raw_input("Password:") print "Welcome in" -- ___ Search for businesses by name, location, or phone number. -Lycos Yellow Pages http://yp.lycos.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Help me
Hi There, I am planning to start my career in computer programming.But i don't have specific resource(websire/book) to improve my basic computer programming skills.If you know any helpful resources,please let me know. Thanks in advance. Priya. Yahoo! FareChase - Search multiple travel sites in one click. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help me
On Tue, 15 Nov 2005, sivapriya pasupathi wrote: I am planning to start my career in computer programming.But i don't have specific resource(websire/book) to improve my basic computer programming skills.If you know any helpful resources,please let me know. Hi Priya, Welcome aboard! If you're looking for Python-specific resources, have you had a chance to look through the Python.org web site? There should be a lot of useful links from the Beginners Guide and the Non Programmers tutorial list: http://wiki.python.org/moin/BeginnersGuide http://wiki.python.org/moin/BeginnersGuide/NonProgrammers As far as books on paper, there's a good list here: http://wiki.python.org/moin/IntroductoryBooks I've used Learning Python, and from what I remember, it was a fine tutorial. Unfortunately, I came to Python with previous programming experience, so I might not be the best person to point out what books are friendly to people starting from scratch. *grin* Does anyone else have recommendations? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help me
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Danny Yoo On Tue, 15 Nov 2005, sivapriya pasupathi wrote: I am planning to start my career in computer programming.But i don't have specific resource(websire/book) to improve my basic computer programming skills.If you know any helpful resources,please let me know. Hi Priya, Welcome aboard! [SNIP Danny's suggestions] Unfortunately, I came to Python with previous programming experience, so I might not be the best person to point out what books are friendly to people starting from scratch. *grin* Does anyone else have recommendations? Python was my first programming language (I don't count PHP). I started learning about 4 years ago. I found the standard tutorial by Guido quite helpful. I had to read it a few times though, as it moves quite fast for a tutorial (for a raw beginner, at least). I also went through How to Think Like a Computer Scientist. It is a great book that is freely available online. Finally, the interactive interpreter is sitting there just waiting for you to start typing stuff in. The help() and dir() functions are particularly helpful when playing around in the interpreter. Python Tutorial - http://docs.python.org/tut/tut.html How to Think Like a Computer Scientist - http://www.ibiblio.org/obp/thinkCSpy/ -also- The Python Cookbook - http://www.oreilly.com/catalog/pythoncook2/ Good luck and welcome to Python! Christian ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help me
On 15/11/05, sivapriya pasupathi [EMAIL PROTECTED] wrote: Hi There, I am planning to start my career in computer programming.But i don't have specific resource(websire/book) to improve my basic computer programming skills.If you know any helpful resources,please let me know. Thanks in advance. Priya. I'd suggest Alan Gauld's tutorial as well, python was pretty much my first language (I don't count VB) and his tutorial really helped. http://www.freenetpages.co.uk/hp/alan.gauld/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] HELP ME DUDE
Also, please use punctuation and paragraphs. I'm not a grammar Nazi per se, but sheesh, that stuff is unreadable. And, as a general rule, a 56 kilobits pers second will download at 5.6 Kilobytes per second at the very best. You're lucky to get 4 Kilobytes per second. Hence, ADSL is good. On 7/23/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:Quoting Suranga Sarukkali [EMAIL PROTECTED] : Hay, you know what? when I connect to the internet the modem software(Error Free Software for Sure)say's a around 50-53.3Kbps connected though when I download a file from a server not p2ps or any of the kind service the downloads are even when connection is idle without any other method of bandwidth usage the downloads are at 4 Kilobytes per second but that should be around 8 Kilobytes per second as a thumb rule, you know that right? so I wonder is it's the malware or any type or WHAT could be the reason or even not how to get the said 53.3k (8KBs per second) download rate to my pc? oh remember to reply to me as soon as possible. Hi Suranga,This is a Python programming group.If you have any Python questions, then thisis the place to ask them.However, Anything outside of that scope willprobably not get you too much help.;-) Byron---This message was sent using IMP, the Internet Messaging Program.___ Tutor maillist-Tutor@python.orghttp://mail.python.org/mailman/listinfo/tutor -- 'There is only one basic human right, and that is to do as you damn well please.And with it comes the only basic human duty, to take the consequences.' ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] HELP ME DUDE
Hay, you know what? when I connect to the internet the modem software(Error Free Software for Sure) say's a around 50-53.3Kbps connected though when I download a file from a server not p2ps or any of the kind service the downloads are even when connection is idle without any other method of bandwidth usage the downloads are at 4 Kilobytes per second but that should be around 8 Kilobytes per second as a thumb rule, you know that right? so I wonder is it's the malware or any type or WHAT could be the reason or even not how to get the said 53.3k (8KBs per second) download rate to my pc? oh remember to reply to me as soon as possible. BEGIN:VCARD VERSION:2.1 N:Sarukkali;Suranga;;Ms FN:Suranga Sarukkali NICKNAME:saruk TEL;HOME;VOICE:0942610560 ADR;HOME:;;12B, 4th Cross Lane, Borupana Road,;Ratmalana,;WP,;10345;Sri Lanka LABEL;HOME;ENCODING=QUOTED-PRINTABLE:12B, 4th Cross Lane, Borupana Road,=0D=0ARatmalana,, WP, 10345=0D=0ASri Lank= a X-WAB-GENDER:2 BDAY:19891011 EMAIL;PREF;INTERNET:[EMAIL PROTECTED] REV:20050720T155521Z END:VCARD ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] HELP ME DUDE
Quoting Suranga Sarukkali [EMAIL PROTECTED]: Hay, you know what? when I connect to the internet the modem software(Error Free Software for Sure) say's a around 50-53.3Kbps connected though when I download a file from a server not p2ps or any of the kind service the downloads are even when connection is idle without any other method of bandwidth usage the downloads are at 4 Kilobytes per second but that should be around 8 Kilobytes per second as a thumb rule, you know that right? so I wonder is it's the malware or any type or WHAT could be the reason or even not how to get the said 53.3k (8KBs per second) download rate to my pc? oh remember to reply to me as soon as possible. Hi Suranga, This is a Python programming group. If you have any Python questions, then this is the place to ask them. However, Anything outside of that scope will probably not get you too much help. ;-) Byron --- This message was sent using IMP, the Internet Messaging Program. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] help me on python + snack
On Tue, 17 May 2005 21:18:09 -0700 (PDT) Mahmad Sadique Hannure [EMAIL PROTECTED] wrote: Hi Mahmad, Hello friends, I m currently working on sound stuff. I have installed all stuff related to Snack. My code for playing mp3 song is like this #!/usr/bin/python2.3 from Tkinter import * import tkSnack def main(): root = Tk() tkSnack.initializeSnack(root) mysound = tkSnack.Sound('xyz.mp3') I believe the last line is the problematic one. Try to change it into: mysound = tkSnack.Sound(file='xyz.mp3') #mysound.read() mysound.play() if __name__=='__main__': main() I works fine without any error but can't get any sound. So friend help me, I don't know whats wroung with my code. I hope this helps Michael ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] help me on python + snack
Hello friends, I m currently working on sound stuff. I have installed all stuff related to Snack. My code for playing mp3 song is like this #!/usr/bin/python2.3 from Tkinter import * import tkSnack def main(): root = Tk() tkSnack.initializeSnack(root) mysound = tkSnack.Sound('xyz.mp3') #mysound.read() mysound.play() if __name__=='__main__': main() I works fine without any error but can't get any sound. So friend help me, I don't know whats wroung with my code. Help! Thank You. Regards, Mahmad Sadique. __ Do you Yahoo!? Make Yahoo! your home page http://www.yahoo.com/r/hs ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] help me please!!!
Ok some thing is messed up.. when i try to open the python shell i get a error meesage saying socket error:connection refused and the head line at the top says IDLE subprocess error.. and then the python shell pops up with a error message on it saying. IDLE's subprocess didn't make connention. Either IDLE can't start or personal firewall software is blocking the connection. and the head line at the top says subprocess startup error.. and i did not even have to be online to use to befor i don't know what it problem is please help me..lol..thank you!!! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] help me please!!!
[EMAIL PROTECTED] said unto the world upon 2005-03-11 19:00: Ok some thing is messed up.. when i try to open the python shell i get a error meesage saying socket error:connection refused and the head line at the top says IDLE subprocess error.. and then the python shell pops up with a error message on it saying. IDLE's subprocess didn't make connention. Either IDLE can't start or personal firewall software is blocking the connection. and the head line at the top says subprocess startup error.. and i did not even have to be online to use to befor i don't know what it problem is please help me..lol..thank you!!! Hi, IDLE isn't the python shell. You appear to be on Windows XP. A python shell is what you get when you open a command prompt (a DOS prompt on older Windows version; I don't know XP) and type python. IDLE is a basic Integrated DeLopment Environment with an enhanced shell. The problem you are experiencing with IDLE is a known bug. When it occurs, open up your task manager (CTRL + ALT + DEL on pre-XP Windows at least) and look for a Python related process (one with python in the name). Kill it. Try launching IDLE again. You should be fine thereafter. There is more information about this bug (and a more permanent fix) in one or both of the archives of this list and of the edu-sig list. Last, as a windows user, you might be interested in PythonWin. It is part of the Windows extensions by Mark Hammond http://starship.python.net/crew/mhammond. The editor is a bit nicer and more featurefull than that of IDLE. If you try that and have problems running it consistently (I did) see http://mail.python.org/pipermail/python-win32/2002-July/000460.html Best, Brian vdB ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] help me please!!!
[EMAIL PROTECTED] said unto the world upon 2005-03-11 20:21: ok i just restarted my pc and it works now thank you ..ok when i go to the start menu then go to all programs then to python 2.4 it gives me five things ok it says IDLE (python GUI) Module Docs python (command line) python manuals uninstall python When i click on IDLE (python GUI) the screan pops up and at the top it say python shell *PLEASE* Reply to All. (For the reasons Danny Yoo mentioned. More than once.) Yes, the window that pops up and is entitled 'Python Shell' is IDLE's enhanced python shell. I believe that 'python shell' (without further modification) is conventionally understood to mean the bare Python shell one gets from clicking on Python (command line). (That is the same you get by opening a DOS box and typing Python.) The IDLE shell is only a part of the IDLE program. (Try File-New Window. Now you've got an IDLE editor window where you can write, save, and load scripts.[1].) The IDLE shell is enhanced by things such as syntax highlighting, and, compared to the bare shell on my Windows version at least, a scrollable and saveable history. There are also things that won't work well from the IDLE shell -- since it is itself a Python Tkinter GUI program, running a Tkinter GUI program from within it doesn't work too well. [1] To stave off future worries -- when saving a script from IDLE, you have to explicitly give it the .py extension if you want your script to have it. (You do -- it makes it runable in Windows by double-click on the icon and tells IDLE to use the Python syntax highlighting which makes editing Python code much easier.) Best, Brian vdB ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor