Re: [Tutor] Creating a pojo in python
On Feb 8, 2015 11:21 PM, "rakesh sharma" wrote: > > How can one create a POJO in python.I mean a class like this > class A { private a; private b; public getA() { return a; } public getB() { return b }} > I tried creating class in python but the variables were accessible as public data members. The acronym POJO stands for "plain old Java object", so technically speaking, Python style won't encourage what you're trying. Traditionally, if you add an underscore as a prefix to your field name, other programmers are supposed to pretend that it is private. This is conventional. If you are an advanced user, you can look into properties which can be used to lock down access more thoroughly. But for most users, using the underscore convention is enough. Can you explain more why you are trying to do a POJO? In Java, POJOs are used because of the desire to manage the access to data exclusively through method calls. But we can get this in Python with properties, without doing the exact same thing as Java. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] Creating a pojo in python
How can one create a POJO in python.I mean a class like this class A { private a; private b; public getA() { return a; } public getB() { return b }} I tried creating class in python but the variables were accessible as public data members. Any help? ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Explanation of this print statement
On 02/08/2015 06:01 PM, Shawn Byers wrote: Hello I was wondering if someone could explain this print statement for r in range(6,0,-1): print((6-r)*''+r*'o') You probably intended to have a blank between the first two single-quotes. for r in range(6,0,-1): print((6-r)*' '+r*'o') Perhaps it'd be more interesting to put some other character in the quotes: for r in range(6,0,-1): print( (6-r)*'X' + r*'o' ) -- DaveA ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Explanation of this print statement
On 09/02/2015 00:19, Alan Gauld wrote: On 08/02/15 23:01, Shawn Byers wrote: Hello I was wondering if someone could explain this print statement for r in range(6,0,-1): print((6-r)*''+r*'o') Have you tried running it? Do you see what it is doing? Try evaluating range(6,0,-1) at the interpreter (you may want to convert it to a list) to see what it does. >>> print( list(range(6,0,-1)) ) Try substituting values for (6-r) and see what string results you get for each value. eg >>> print(6 * '' + 0 * 'o') >>> print(0 * '' + 6 * 'o') >>> print(3 * '' + 3 * 'o') >>> print(3 * '' + 4 * 'o') >>> etc In other words, experiment in the >>> interpreter. That's what it's there for. And its quicker than sending an email and waiting for a reply (which may not cover the bit you want to understand anyway). Then if there's still something you don't understand come back and ask us about that specific aspect. If it is a print statement the brackets are not needed, otherwise it's either the Python 3 or (Python 2 with from __future__ import print_function) print function. -- 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] Explanation of this print statement
On 08/02/15 23:01, Shawn Byers wrote: Hello I was wondering if someone could explain this print statement for r in range(6,0,-1): print((6-r)*''+r*'o') Have you tried running it? Do you see what it is doing? Try evaluating range(6,0,-1) at the interpreter (you may want to convert it to a list) to see what it does. >>> print( list(range(6,0,-1)) ) Try substituting values for (6-r) and see what string results you get for each value. eg >>> print(6 * '' + 0 * 'o') >>> print(0 * '' + 6 * 'o') >>> print(3 * '' + 3 * 'o') >>> print(3 * '' + 4 * 'o') >>> etc In other words, experiment in the >>> interpreter. That's what it's there for. And its quicker than sending an email and waiting for a reply (which may not cover the bit you want to understand anyway). Then if there's still something you don't understand come back and ask us about that specific aspect. -- 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] Explanation of this print statement
Hello I was wondering if someone could explain this print statement for r in range(6,0,-1): print((6-r)*''+r*'o') ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Need help writing code with python
Alan Gauld writes: > Third, > The attachment didn't get here. So I've no idea what your assignment > was. Its usually better to copy the text into the mail body. Given that the attachment was described as “my project”, I would advise not sending it here in any form. Copy text here if it's *small*, and *focussed*, and relevant to some part of the discussion. If the text is “my project”, it's better not put here at all. I am glad the attachment was discarded, it sounds like sending it to all recipients of this forum would have been only an annoyance. Conner, please obtain the time to do the project unhurried; then, feel free to come to this forum with *focussed* questions on aspects of the Python code you are writing. We don't need to see the project. -- \ “I find the whole business of religion profoundly interesting. | `\ But it does mystify me that otherwise intelligent people take | _o__)it seriously.” —Douglas Adams | Ben Finney ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Need help writing code with python
On 02/07/2015 05:36 PM, Conner Wood wrote: I fell behind 2 weeks in my class due to surgery and have a coding project due tonight (Saturday, Feb. 7). I've attached my project to this email. Please help! Also, I'm using a Mac laptop if that helps in anyway. Please get back to me as soon as you can. Welcome to Python-tutor. This seems to be your first post. Thanks for making it a text email. And for mentioning your OS. But you also should be specifying the Python version. There's no attachment to your message in the mailing list. And many people here can't see attachments anyway. If your project is too big to include directly in your email message, you may be out of luck. How big a project is it, and how much of it have you been able to do so far? Is there some particular problem that has you stumped? We're here to help you get past some sticking point, not to do your assignment for you. I'd expect your prof would give you an extension if you can't get it in because of unexpected surgery. -- DaveA ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Need help writing code with python
On 07/02/15 22:36, Conner Wood wrote: I fell behind 2 weeks in my class due to surgery and have a coding project due tonight (Saturday, Feb. 7). I've attached my project to this email. Please help! Also, I'm using a Mac laptop if that helps in anyway. Please get back to me as soon as you can. First. We won't do homework for you so we need to see what you have done. You need to have made some kind of attempt. Or at least have some specific questions. Second Asking for a response on the day that the assignment is due on a mailing list isn't going to work, it didn't get here until Sunday. I hope you got something done on Saturday but you need to give a mailing list a bit more notice. Email can take up to 24 hours to reach its destination, never assume it will be quicker than that (even if 99% of the time it is). Third, The attachment didn't get here. So I've no idea what your assignment was. Its usually better to copy the text into the mail body. Fourth. Please give more than the fact you've got a Mac. So have I; its an old iBook that runs MacOS 10.4 on a 600MHz PowerPC chip. I suspect that's quite different to yours. Tell us the OS version and the Python version you are using. -- 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
Re: [Tutor] Need help writing code with python
Conner Wood writes: > I fell behind 2 weeks in my class due to surgery and have a coding > project due tonight (Saturday, Feb. 7). I've attached my project to > this email. My sympathies with your situation, I hope your surgery was successful and you are in good health. This is not a forum for doing your project; you will need to do your own project. Rather, this is a forum for publicly discussing much more focussed topics. We tutor each other in learning Python and its idioms and ecosystem. We don't do one-on-one tutoring, and we don't do coding for you. If you have a *small* portion of code that demonstrates some behaviour that confuses you, we can talk you through the confusion (provided the code can also behave the same for us, and provided we know what you expected from that code). If you have a large project, you'll need to do the work, or get some largesse from the people expecting that work. It seems you have an entirely valid reason to ask for a time extension. Good hunting! -- \ “I knew things were changing when my Fraternity Brothers threw | `\ a guy out of the house for mocking me because I'm gay.” | _o__) —postsecret.com, 2010-01-19 | Ben Finney ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] Need help writing code with python
I fell behind 2 weeks in my class due to surgery and have a coding project due tonight (Saturday, Feb. 7). I've attached my project to this email. Please help! Also, I'm using a Mac laptop if that helps in anyway. Please get back to me as soon as you can. Thanks, Conner Wood ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor