Re: [Tutor] If a method has no return type?
Dear Sunil, No method or function in Python has a *static* return type. That's because Python is by nature a dynamic language, with duck typing and dynamic dispatch. In fact, any method or function may well return any of a number of different types: def crazy_function(return_int) if return_int: return 1 else: return 'foo' It's probably bad design, but there is nothing in the Python grammar and semantics that stops you from doing that. So your question is better phrased as: if I don't explicitly return anything, what is returned? The answer to that would be: the None object Cheers, Kal On 7 February 2013 14:09, Sunil Tech sunil.tech...@gmail.com wrote: If a method has no return type? what will it return? ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] unclear topic
On 15 January 2013 05:19, Prasad, Ramit ramit.pra...@jpmorgan.com wrote: Matthew Ngaha wrote: hey guys, this is not really a Python question. When ever im doing a tutorial, it could be pygame or some gui application, i usually find everything straight forward until the demonstration involves drawing. Then maths is applied and i can't follow along as easily. In the end by commenting out certain lines of code, i understand what each line is doing but the fact is im still faced with being very weak at drawing and working out the logic behind it. I also can't imagine if im designing a program and need to do drawings of my own how i would work out the calculations and be able to think for myself. The help im asking for is what do i need to study to be able to design my own programs that involve drawing? do i need to go off and learn maths? if so which type? some sort of geometry? or do i start studying some sort of physics? or does the answer lie within some framework/library python tutorial? on amazon ive seen: maths books physics book 2d engine physics books(box2d etc) game physics books - http://www.amazon.co.uk/Game-Physics-/dp/147103397X/ my other problem is i don't want to over do it. do i need to buy a game physics book, if all i want to do is understand how to implement my own calculations for complex objects etc? then again maybe that's not so bad. If you know your way around this stuff? what did you learn that gave you these skills? You should at least have enough math knowledge to understand Cartesian coordinates systems. Once you think of things in terms of objects based on their the coordinate location (x, y, z) it becomes easier to place objects where you want them and move them. Some trigonometry/ algebra might also be helpful. I (personally) would not buy a game physics book unless you are looking to create a 3D game or a 2D game with an actual physics engine (e.g. World of Goo). Of course, this is based on my personal experience and education which may vastly vary from your own. Or, as they say on them internets, YMMV. ~Ramit This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor Hi Matthew, Knowledge of Lineage Algebra is also invaluable. It forms the basis for geometric transformations in 2D and 3D. ~Kal ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] New to Python - simple question
On 18 November 2012 07:40, Alan Gauld alan.ga...@btinternet.com wrote: On 16/11/12 17:40, Unaiza Ahsan wrote: There is a function created for histogram equalization of images (called *histeq*), and saved in imtools.py. from PIL import Image from numpy import * im = array(Image.open('Tulips.jpg').convert('L')) im2,cdf = imtools.histeq(im) I get this: Traceback (most recent call last): im2,cdf = imtools.histeq(im) File C:\Python27\imtools.py, line 18, in histeq imhist,bins = histogram(im.flatten(),nbr_bins,normed=True) NameError: global name 'histogram' is not defined This tells us that the name histogram is not defined in the imtools.py file. Is it one of the modules ytou show imported above? If so it will not be visible inside imtools.py. You need to import the required module in that file too. But that's just a guess... And the relevant portion in imtools.py is: def histeq(im,nbr_bins=256): Histogram equalization of a grayscale image. #get image histogram imhist,bins = histogram(im.flatten(),nbr_bins,normed=True) This is the call, but where is histogram? If it is in imtools are you sure the spelling is correct? If its not there you need to import it from wherever it is defined. HTH -- 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 Hi all, The function histogram is supposed to come from the numpy module; at least that's the case on my computer (I have numpy 1.6.2 for Python 2.7): from numpy import * histogram function histogram at 0x10b0c0ed8 Maybe something is wrong with Unaiza's version of numpy. Kal ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Scheme
That's left as an exercise to the reader. On Friday, August 31, 2012, Mark Lawrence wrote: On 31/08/2012 08:55, Alan Gauld wrote: Now just translate that into Scheme :-) HTH Anyone know of an application to automate Python to Scheme translation? :) -- Cheers. Mark Lawrence. __**_ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/**mailman/listinfo/tutorhttp://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Scheme
And this looks like a homework problem, too. It is against etiquette to just ask for the solution to homework on ANY forum, message board, or mailing list. Since it's been given to you as homework, you're supposed to give it enough thoughts, and (hopefully) come up with your solution. Even when you go to the Lisp or Scheme mailing list, you should at least show what you have tried, paste your own code, and tell them where you are stuck. On 31 August 2012 07:32, Ashley Fowler afowl...@broncos.uncfsu.edu wrote: This is a problem using the Scheme programming...Can anybody help me with this problem? 2. Write a procedure (sphere r) that takes the radius of a sphere as the value of its input parameter and returns the volume of that sphere given by the formula: (4/3)π(r^3). Use (require scheme/math) or (require racket/math) to load the math library containing the pi constant. Be sure to use cube from problem (1) to find the cube of r (r^3). Tests: (sphere 2) == 33.51 ... (sphere 5.3) == 623.61 ... ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Prescriptive vs descriptive docstring
Hello, PEP 257 says that docstrings should be written in a prescriptive way (i.e. using the imperative mood) instead of a descriptive way (indicative mood). This seems like a rather odd recommendation. Since the docstring is supposed to tell the programmer *how* to use a function/method, I've always thought that a description in the indicative mood is appropriate. What's the point in saying it like a command? Who are you commanding when what you really want is to learn what the function/method does? In Javadoc and XML doc (Java's and .NET's equivalent to docstrings), the de-facto convention is to use the indicative mood (as can be seen in the whole standard java class library and .net class library). Is this difference somehow a corollary of the difference in programming paradigms? Was there a discussion in doc-...@python.org about the reason(s) to use the imperative mood instead of the indicative mood, which then led to the recommendation in PEP 257? Best Regards, Kal ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor