3,386 Posted Topics
Re: My formatting of your calculations (notice that `len` is builtin function do not use it as variable name): """ calc_polyarea.py Calculating area and radius of polygons with known number of sides and the length of this side Adapted formulas used from this site: http://www.mathwords.com/a/area_regular_polygon.htm DM 17/09/2013 (with little help from … | |
Re: And Frank do check the signature facility on your profile and add your blog link there. And Turbo Pascal 3 was liberation on MSDOS pcs after starting with "compile, run and pick the report print from shelf" Burroughs Standard Pascal in 1985. | |
Re: Memberlist looks simply the length of list which is trivial. First case could use that with findall. | |
Re: I am not such a friend of banners but here is one version for you to learn some other features of Python (as you did mention format in your title) >>> def banner(filename, name, d, m, y=2013, width=80): print '#' * width print '''\ # Filename: {filename} # Copyright: {name} … | |
| |
Re: What is this printout is supposed to mean? [CODE] Enter a Node (9999 to finish)>1 Enter a Node (9999 to finish)>1 Enter a Node (9999 to finish)>2 Enter a Node (9999 to finish)>21 Enter a Node (9999 to finish)>1 Enter a Node (9999 to finish)>2 Enter a Node (9999 to … ![]() | |
Re: Fine, all the best with your studies of json and ConfigParser modules! | |
Re: No, Dani, cucumber is for Ruby. :) | |
Re: My little more advanced examples are in this code snippet: http://www.daniweb.com/software-development/python/code/364647/jail-input-and-looping-exercise | |
Re: Just for reference in future, that if you are not required to avoid it you can of course do this in standard way: a = raw_input('Type something to be reversed and hit enter: ') print('Your text in reverse is: "' + a[::-1] + '"') | |
Here is exercise in error handling, while looping and for looping with itertools.chain. It is also exercise of functions not letting user to go without giving proper input. I call them to myself 'jail functions'. Here you could add as an exercise breaking out of loop and continuing until user … | |
Re: This looks like you are using class, not class instance, so the instance variable is not initialized. | |
Re: Define the Node to keep reference of last created object and make it return that if node value is same as last before in the `__new__` class method or define Node as a factory function doing the same. | |
Re: In math.sqrt the math is module and sqrt is function. Nothing to do with objects. | |
Re: You are trying to get integer from the box even it has not yet been entered. You are reimporting Tkinter, even you imported it all to main namespace in the beginning. | |
Re: The test is quite limited as can be seen from these numbers, not accepted: 1e3 2+4j 0b01101 0x123abc and these numbers not numbers 1.2.2.3.4+.+ 9-2-34..123 If you want to be very general, you can use test: def is_numeric(n): try: n=complex(n) return True except: try: n = int(n,0) return True except: … | |
Re: You are counting twice numbers divisible by 15, I think. | |
Re: Here is alternative format for the code: ''' day_week_born.py ask to enter a birthday and show the day of the week the person was born some dates in history ... July 4, 1776 was on a Thursday December 7, 1941 was on a Sunday 3/14/1879 was on a Friday (Albert … | |
Re: http://docs.python.org/2/library/socketserver.html | |
Re: Would not the Config file fit? http://docs.python.org/2/library/configparser.html | |
Re: I would recommend to work through all excersices, looks for me that you have been looking but not doing the excersises. You learn mainly by doing the exercises, so you would be stupid not to do those. | |
Re: `str` function calls the appropriate method of the value to turn it to a string. | |
Re: It is tkinter in Python3. http://docs.python.org/dev/library/tkinter.html >tkinter.filedialog >Common dialogs to allow the user to specify a file to open or save. | |
| |
Re: I do not see connection of your code with other codes you posted, it says in class defination for example [CODE]class MyDialog(model.CustomDialog):[/CODE] Which you are not using, even you mention custom dialog in your title | |
Re: I think the list contains all programs run by pythonw.exe (probably python.exe has separate list), idle is one of them. The list is propably not files edited with idle.py (I can not check it from work computer). | |
Re: Python is indention sensitive, I tried to fix your code. Did I guess it right. So what is your question? | |
Re: Python has sets use those or there is module https://pypi.python.org/pypi/bitarray/ I will look your code later in home, if somebody does not review it before that. | |
Re: You problem comes up now and again here in DaniWeb. Here is some code snippets I wrote long time again that you might want to check: http://www.daniweb.com/software-development/python/code/364647/jail-input-and-looping-exercise http://www.daniweb.com/software-development/python/code/284490/integerfloating-point-string-check | |
Re: `or` is *shortcut version* and in this case it uses Lisp like philosophy of returning something usefull found instead of True or False. As `or` is true apon first non-zerolike value, it returns that desiding point's value and does not evaluate rest of the expressions, as they can not make … | |
Re: Simplest way to play sound is to import webbrowser and do webbrowser.open for the sound file. It uses the associated player for the file type. Other possibility is to for example to use pyGame's sound feature as above related Code Snippet for MIDI files. | |
Re: ... or do not assume that the that program seems to work does not have bugs... (I would not know, as this program is quite unverifyable for me because of repeating code instead of loops) | |
Re: Did you check http://www.youtube.com/watch?v=JovR98_BvlI or http://www.youtube.com/watch?v=zjf-SUNVfc0&list=SPAFB3A3B53B58CD26 | |
Re: It is just a normal text file, read as normal. | |
Re: There seems to be few alternatives based on simple Googling and not owning Apple hardware myself: http://www.saurik.com/id/5 or http://omz-software.com/pythonista/ | |
Re: it would be easier if you could post one specific problem together with the code you wrote. You are familiar with http://dirtsimple.org/2004/12/python-is-not-java.html ? | |
Re: You have infinite recursion to Master, function names should be small_case_with_underscores. | |
Re: Count is Count in your clause in line 8 does not make sense for me, why `:- Counter is 1.`? Why not simple facts like line 1? vowel([a],1). | |
Re: Here: [url]http://chaos.weblogs.us/archives/164[/url] There was code, which seemed to work. I paste here as it was normal text and messed up if copy pasting (also it had some stupid semicolons I removed): Server: [CODE]import socket import time ANY = '0.0.0.0' SENDERPORT=1501 MCAST_ADDR = '224.168.2.9' MCAST_PORT = 1600 sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, … | |
Re: I do not understand your while False blocks, as that means the statements are never executed. | |
Re: initials = set(input("Initials : ").lower()) # unique initials phrase = input("Phrase: ").lower() print(sum(c in initials for c in phrase)) """Output: Initials : VKL Phrase: Victor likes licking people 6 """ | |
Re: Your indention is incorrect and the line 3 is doing nothing as it is 1, which is not saved anywhere. I do not also understand your example. | |
Re: You should have not have mutable default values if you are not absolutely sure you want use them as for example memoization purpose. Use None instead and use if statement: http://stackoverflow.com/questions/366422/what-is-the-pythonic-way-to-avoid-default-parameters-that-are-empty-lists | |
Re: True is of course allways true so what else it could print, line 3 does nothing. | |
Re: And 999 out of 1000 times you should not be using this but you have bad design so do not shy away on explaining reason for this trickery, so we may recommend bretter way. | |
Re: import webbrowser webbrowser.open('trial.txt') | |
Re: global variables are available everywhere after their definiton in a module (and outside the module can be qualified by the module name) |
The End.