3,386 Posted Topics

Member Avatar for vegaseat

It is better to keep to Python convention for first parameter name self instead of this.

Member Avatar for vegaseat
9
45K
Member Avatar for deceptikon

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?

Member Avatar for vegaseat
3
749
Member Avatar for bunkus
Member Avatar for jeremywduncan
Member Avatar for turntomyleft

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 …

Member Avatar for vegaseat
0
785
Member Avatar for 家宁

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.

Member Avatar for woooee
0
289
Member Avatar for Wumbate

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]

Member Avatar for woooee
0
10K
Member Avatar for vegaseat

> print("Hello World") > > Can anybody print out "Hello World" vertically? print('\n'.join("Hello World"))

Member Avatar for ZZucker
1
910
Member Avatar for Courtney_1

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 …

Member Avatar for TrustyTony
0
6K
Member Avatar for Edward_6
Member Avatar for Edward_6

You did not ask anything and this is not functional prrogram, what is your reason for posting it?

Member Avatar for Edward_6
0
174
Member Avatar for BustACode
Member Avatar for Gribouillis

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 …

Member Avatar for Gribouillis
0
334
Member Avatar for DragonMastur

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.

Member Avatar for DragonMastur
0
427
Member Avatar for kiddo39

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.

Member Avatar for TrustyTony
0
31K
Member Avatar for ShilohAmi
Member Avatar for preciousjame
Member Avatar for TrustyTony

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 …

Member Avatar for TrustyTony
0
277
Member Avatar for marcelocent

My simplest anagrams post snippet: https://www.daniweb.com/software-development/python/code/285434/super-simple-one-word-anagrams#post1227978

Member Avatar for vegaseat
0
255
Member Avatar for ben.juarez.773

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

Member Avatar for richieking
0
528
Member Avatar for Niloofar24

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()

Member Avatar for sneekula
0
11K
Member Avatar for kouty

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')) # …

Member Avatar for Gribouillis
0
409
Member Avatar for vegaseat

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

Member Avatar for vegaseat
2
3K
Member Avatar for sneekula

For win32 module based access see my snippet: https://www.daniweb.com/software-development/python/code/422325/using-clipboard-from-python

Member Avatar for TrustyTony
1
14K
Member Avatar for nugnug1616

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

Member Avatar for TrustyTony
0
469
Member Avatar for Shaji_1

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.

Member Avatar for TrustyTony
0
307
Member Avatar for Slavi

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 …

Member Avatar for Slavi
0
8K
Member Avatar for frankinaround

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 …

Member Avatar for magnus.wootton
0
398
Member Avatar for Azmah
Member Avatar for mark103

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

Member Avatar for TrustyTony
0
248
Member Avatar for Dani

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 :)

Member Avatar for Dani
0
2K
Member Avatar for 4evrmrepylrning

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.

Member Avatar for Nisar222
0
13K
Member Avatar for Tcll

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 …

Member Avatar for Tcll
0
232
Member Avatar for vegaseat

[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].

Member Avatar for Gribouillis
0
20K
Member Avatar for Amit_25
Member Avatar for sneekula
0
178
Member Avatar for mnparikh

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

Member Avatar for rubberman
0
459
Member Avatar for MasterHacker110
Member Avatar for MasterHacker110
0
343
Member Avatar for JJHT7439

Add print statements to loadGraphFileName every few lines to check your assumptions, especially at end of for and before error place.

Member Avatar for James_41
0
3K
Member Avatar for awesomelemonade

It has run out of NetBeans for Java. How Lucky Lukes horse Jolly Jumper puts worm to his hook

Member Avatar for Slavi
1
2K
Member Avatar for joustwilliams

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 …

Member Avatar for vegaseat
0
2K
Member Avatar for ToucheAmore

don't think there is Android for Blackberry even they are more unexisting here in Finland than Nokia in U.S.

Member Avatar for priyaspageo
0
550
Member Avatar for rebekah.stacy1

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.

Member Avatar for vegaseat
0
528
Member Avatar for vegaseat

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 …

Member Avatar for HiHe
2
21K
Member Avatar for Screwby
Member Avatar for Lardmeister
0
11K
Member Avatar for psichoman5

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 …

Member Avatar for Gribouillis
0
2K
Member Avatar for davidbr

You could collect the threads in some container and iterate through it and close each thread when you close the window.

Member Avatar for Gribouillis
0
220
Member Avatar for acrocephalus
Member Avatar for vegaseat

I also thought it remarkable thing, and really fresh version. Before version has lagged behind. Easy_install installed also?

Member Avatar for sneekula
2
3K
Member Avatar for chophouse

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()]

Member Avatar for Gribouillis
0
343
Member Avatar for WinDSP

The End.