3,386 Posted Topics
Re: It is better to keep to Python convention for first parameter name self instead of this. | |
Re: Hmmm, maybe they should, but maybe the posters should practice their analysing of customers problems. How about reading a page from DaniWeb and finding out if it has mis/unformatted Code block in posts or not? | |
Re: Reason for this request? | |
Re: line 5 should be inside the loop | |
Re: Considering your mathematical background, if you need some exercises after you got the basics and before tackling recoding your old code to Python (nice and very recommendable own project to push you to learn more), you might want to go through mathematical coding chalenges of the [Project Euler](https://projecteuler.net/) I am … | |
Re: I would not use input as a variable name, especially as you also try to use also the function input, which is hidden due to this. | |
Re: I googled this from [url]http://bytes.com/topic/python/answers/642659-tkinter-label-widget-text-selection[/url]: [CODE]import Tkinter as Tk root = Tk.Tk() ent = Tk.Entry(root, state='readonly', readonlybackground='white', fg='black') var = Tk.StringVar() var.set('Some text') ent.config(textvariable=var, relief='flat') ent.pack() root.mainloop() [/CODE] | |
Re: > print("Hello World") > > Can anybody print out "Hello World" vertically? print('\n'.join("Hello World")) | |
Re: Here is bit more advanced version when you start to internalize the Python philosophy: # Lets make it run with Python2 from __future__ import print_function try: input = raw_input except: pass def acronym(phrase): return ''.join(word[0] for word in phrase.upper().split()) def main(): print("This program creates an acronym for a phrase") print("entered … | |
Re: You forget to state your problem or question. | |
Re: You did not ask anything and this is not functional prrogram, what is your reason for posting it? | |
Re: I changed the snippet to code snippet and added call to main. | |
Re: How about hashing the letters in file, generate random letters until random letter hits empty slot in hash. If there is enough empty slots in hash, it should not take too many guesses. And guess + hash + check is quite fast operation. This, if you want to find unicode … | |
Re: Despite the imports, the raw_input will not work in Python3. You must do assignment and decide which meaning to use. I normally assign raw_input to input in Python2. | |
Re: Please start a new thread for your question instead. If the file is not too long you can just read it in and use the replace method of strings to replace comma with nothing. That would not allow any commas inside the data. | |
![]() | Re: Use list comprehension/generator with min-function. |
Python helps in real life situation to automate things. This program helps you to prep up your kids ability to go over/under ten, which is essential not only by itself, but also when calculating with bigger numbers. Program is not any special, but shows how useful Python can be in … | |
Re: My simplest anagrams post snippet: https://www.daniweb.com/software-development/python/code/285434/super-simple-one-word-anagrams#post1227978 | |
Re: You do replace the APIKEY with the API key you actually received from them, don't you? url == 'http://api.data.gov/regulations/v3/documents.json?api_key=%s' % API_KEY | |
Re: from ScrolledText import * from Tkinter import * main = Tk() mywin = ScrolledText(main) mywin.pack(fill=BOTH, expand=YES) main.title('Favorite Movies') favorite_movies = [ "Gone with the Wind", "Batman IV", "Spiderman VII", "Sniper III"] mywin.insert(END,'\n'.join(favorite_movies)) mywin.focus_set() mywin.mainloop() | |
Re: I read this thread, and of course I would use the count method, but I got to make this task by yet another method and thought to share it. def count(haystack, needle): return sum(haystack[n:].startswith(needle) for n in range(len(haystack) - len(needle) + 1)) print(count('assessement', 'as')) # -> 1 print(count('assessement', 'sse')) # … | |
Re: Interesting HiHe, but I do not know if it is too biased to use only one number as case. Both isprime2 and isprime 3 seem to run more than my own isprime adapted as optimized from Project Euler (found in other prime tread recently posted to) Tony | |
Re: For win32 module based access see my snippet: https://www.daniweb.com/software-development/python/code/422325/using-clipboard-from-python | |
Re: tkinter can not freeze as the code does not use tkinter. Show us clearly your question. What a coinsidence, that your code appears very similar to code in http://stackoverflow.com/questions/25711934/pygame-window-becomes-unresponsive-when-the-code-is-run | |
Re: How about >>> 'tony veijalainen'.title() 'Tony Veijalainen' >>> 'book of shadows'.title() 'Book Of Shadows' >>> Second one is not actually how it is done, but otherwise it is OK. | |
Re: pymotw is good place to learn about using modules. Here is the lesson on zipfile: http://pymotw.com/2/zipfile/ Also by example of the module you see that text of the message is input as preamble: https://docs.python.org/2.7/library/email-examples.html Also I believe that you should be reading the file as normal file (not zf) with … | |
Re: If you have not emacs, this site has eliza in python and also this chatbot: [url]http://www.jezuk.co.uk/cgi-bin/view/software/whereskal[/url] The eliza uses whrandom, but just use replace whole words whrandom -> random, and it looks behaving OK. (I could have done [iCODE]import whrandom as random[/iCODE]) The code is little old style with maps … | |
Re: No, you can interpret Python code with Python. | |
Re: You must use serialization by cPickle or json or similar. http://stackoverflow.com/questions/2311223/how-do-i-store-a-dict-list-in-a-database | |
Re: You would also need to decide what to do us mods giving 10 newbies per day our lmgtfy.com link RTFM answer: give double reward or none :) | |
Re: maybe you have saved your code with name `csv.py` and you are importing it. Add `print csv` after import to check the path of file imported. | |
Re: I get only error from import FILE inside your second code, and also the bf32 in first code is undefined. But I would start from something like from collections import OrderedDict class Struct(object): def __init__(self, names, struct_type): self.struct = OrderedDict((name, struct_type(name)) for name in names.split()) @property def struct_size(self): # size … | |
Re: [QUOTE=Skrell;1705278]i have spent the last hour trying to figure out this section of code from above. [CODE]def translate(match): return wordDic[match.group(0)][/CODE] Can anyone PLEASE explain what this is doing and how it works?[/QUOTE] There should be lot of tutorials out there, for example [url]http://www.tutorialspoint.com/python/python_reg_expressions.htm[/url]. | |
Re: Combinations, permutations etc can be found in itertools module. | |
Re: Any reason why you can not use e.g. Python? I would start reviewing the find command if you are using Unix or related OS. Likely as you have Korn shell. http://www.softpanorama.org/Tools/Find/selecting_files_by_age.shtml | |
Re: It sounds that you are using statement `KeyGenerator(....)` which does not make sense. | |
Re: Add print statements to loadGraphFileName every few lines to check your assumptions, especially at end of for and before error place. | |
Re: It has run out of NetBeans for Java. How Lucky Lukes horse Jolly Jumper puts worm to his hook | |
Re: The DaniWeb policy is to keep discussions public so others in same situation may benefit. It is usefull to continue and learn also to use [URL="http://docs.python.org/tutorial/datastructures.html#dictionaries"]dictionaries[/URL]. Here unit conversion with them: [CODE]units = dict(mm=1., cm=10., m=1000., km=1000000., inch=254., ft=3048., mile=1609344.) while True: request = raw_input('\nGive amount and unit e.g. 125 … | |
Re: don't think there is Android for Blackberry even they are more unexisting here in Finland than Nokia in U.S. | |
Re: If you want to suggest exercises for novice programmers, you can contribute to sticky thread started by vegaseat for that purpose. If you want to ask question you need to provide proof of your efforts and specific question. | |
Re: I would like to suggest to change this class little: Add import in beginning:[CODE]import sys[/CODE] and define MyFrame: [CODE]class MyFrame(wx.Frame): def __init__(self, parent, mytitle, mysize, filename=None): wx.Frame.__init__(self, parent, wx.ID_ANY, mytitle, size=mysize) stc_edit = MySTC(self) # open a Python code file you have in the working folder # or give full … | |
Re: First I do not get why you have three calls to Tk in your code instead of regular one. | |
Re: You can reverse a string my doing the_string[::-1] There are also built in function for reverse `reversed` which produces reversed object which you can use for same purpose. It actually creates a new string, why you are limiting your self to 255 elements, no need for such limit. int function … | |
Re: You could collect the threads in some container and iterate through it and close each thread when you close the window. | |
Re: im.save('E:/Usuarios/Daniel/Documents/APNAE/QR/%s.jpeg' % nom) | |
Re: I also thought it remarkable thing, and really fresh version. Before version has lagged behind. Easy_install installed also? | |
Re: Lambda expressions are not used so extensively and are kind of limitted in Python compared to functional programming like Lisp/Scheme. I would use simple basic expression, maybe list comprehension form: [line for line in myfile if not line[0].isdigit()] | |
Re: You tried http://pymedia.org/ didn't you? |
The End.