15,190 Topics

Member Avatar for
Member Avatar for mark103

Hi guys, I'm working on my python script to get the list of elements in the arrays. I'm using the variable `position_x = elem.getX()` to get the list of pixel size for the elements. Here is the output: 18:32:12 T:4060 NOTICE: 375 18:32:12 T:4060 NOTICE: 724 18:32:12 T:4060 NOTICE: 1073 …

Member Avatar for Gribouillis
0
242
Member Avatar for Chrislynn_1

I have a requirement to update a configuration file content at a specific lines location. How to do this in python. For example, I have a configuration file which is having below 5 lines now: define host{ name kiki-server; XXXX XXXX; XXXX XXXX; } I am interested have my python …

Member Avatar for Chrislynn_1
0
236
Member Avatar for ZeroEddy

Hi im new to python and am trying to make a simple tank game where I want the tank gun to follow the position of the mouse cursor. Im am having some trouble in doing this. Below is my code. Whenever I run I get an error. So far I …

Member Avatar for ZeroEddy
0
406
Member Avatar for Slavi

Hey guys, some of you might know me from other sub sections of Dani Web. I am about (just started) to learn Python. And not just learn but possibly make it my prefered language over all. So, I've read the thread from `vegaseat` for beginners and it has a link …

Member Avatar for vegaseat
0
238
Member Avatar for har58

Hi, I have created TY.py. The Ty.py file executes and runs successfully. I am trying to make its executable using py2exe and by creating setup.py. It is not able to include the requests. I think it is because 'requests' is not present in 'include' folder for python27. The path of …

Member Avatar for vegaseat
0
1K
Member Avatar for wesam.teto.9

Similarity(X,Y): For i = 0,...,m: SIM[i,0] = i*g For j = 1,...,n: SIM[0,j] = j*g For i = 1,...,m: For j = 1,...,n: SIM[i,j] = max( SIM[i-1,j-1] + s(X[i],Y[j]), SIM[i-1,j]+g, SIM[i,j-1]+g ) EndFor EndFor Return SIM[m,n]

Member Avatar for Gribouillis
0
227
Member Avatar for EdJones

As part of a study exercise I wrote a procedural script and would like to ask whether anyone has a more polished version. Your version can be procedural or object oriented. #! /usr/bin/env python3 # This script simulates a monkey on a typewriter trying to come up with one sentence …

Member Avatar for Gribouillis
0
131
Member Avatar for Tcll

so I've reverse-engineered Tkinter's tkfiledialog functions askopenfilename and asksaveasfilename to figure out how they work: import Tkinter class Open: "Ask for a filename to open" def __init__(self, master=None, **options): self.master, self.options = master, options if not master and options.get('parent'): self.master = options['parent'] def _fixoptions(self): try: self.options["filetypes"] = tuple(self.options["filetypes"]) # make …

Member Avatar for Tcll
0
295
Member Avatar for Tcll

I've been working on this in other places so it's a little ahead of it's time, but it still has a few minor issues... heh here's an example to get started: x = struct( 12, # struct size 'x,y,z', # variable order x = bf32, y = bf32, z = …

Member Avatar for Tcll
0
228
Member Avatar for vegaseat

This snippets shows how to have fun replacing multiple words in a text. The target words and the replacement words form key:value pairs in a dictionary. The search and replacement is done using Python's regular expression module re. The code also gives an example of a function within a function.

Member Avatar for Gribouillis
0
20K
Member Avatar for mappersas

I could use some assistance My final project in a python class is to calculate the distance between 2 lat/long points. My code is really just managing the input & output portions, while using existing code (properly credited) in a function to do the actual calculations. I've got it working …

Member Avatar for Peter_21
0
6K
Member Avatar for Cort3z

Hi. I am trying to make a script that will print out numbers in rapid succession after working a little with them. The script needs to write them in the console one after another (next line). The code works just fine when I do not utilize multi threading, but when …

Member Avatar for Puneet_1
0
16K
Member Avatar for Jordan_4

im a beginner with python, and I'm having trouble with some functions. I'm pretty sure it might be a syntax error or how i set up the code, since i am a beginner, however, i have no clue why this code works. Here is the code, its for a tic …

Member Avatar for woooee
0
389
Member Avatar for ram_10

Hello, When I'm using the 'open' function how should I specifiy the directory ? I'm getting an IOError and bit of confused! I'm not sure if my script is wrong or I've problems with specifying the directory. input = open('New.txt', 'r') text = input.read() wordlist = text.split() wordfreq = [wordlist.count(p) …

Member Avatar for vegaseat
0
456
Member Avatar for ram_10

Hello, I'm trying to script a Caesar cipher with the key, I find this exercise too much for me at this moment! I just can't come up with an algorith to get this done. Please advise. key = {'a':'n', 'b':'o', 'c':'p', 'd':'q', 'e':'r', 'f':'s', 'g':'t', 'h':'u', 'i':'v', 'j':'w', 'k':'x', 'l':'y', …

Member Avatar for vegaseat
0
249
Member Avatar for iamsupreeth

python function that creates automatically a dropdown year selector (that is a "select" element poulated with all years starting from current and dating back to a given year)? I don't need day/month (otherwise i'd have used the datepicker), i just need the year! Thanks in advance

Member Avatar for vegaseat
0
160
Member Avatar for vegaseat

An example how to use Tkinter's OptionMenu() as a combobox to allow one year to be selected from an option list of let's say the past 15 years.

2
1K
Member Avatar for qashnfhkh

don't work this: bg_fon2 = PhotoImage(file='2.GIF') from tkinter import* import random root = Tk() root.geometry("896x626") canv = Canvas(root, height = 626, width = 896) bg_fon = PhotoImage(file='fon.GIF') canv.create_image(0,0,image=bg_fon,anchor='nw') class Fish: image = 0 coor = 0 direct = 0 real_img = 0 obj = 0 canv = 0 def fiish1(): …

Member Avatar for sneekula
0
137
Member Avatar for Amit_25

hii I have a list having m1 m2 m3........ m922 and in each there are a1 a2 a3 a4 are there like m1=a1 a2 a3 a4 a5 a6 m2=a1 a2 a3 a4 a5 a6 m3=a1 a3 a5 a7 a8 a2 etc and i want this as m1=a1 a2 a3 a4 …

Member Avatar for sneekula
0
175
Member Avatar for EdJones

Is this considered good form when writing cross-platform code? #! /usr/bin/env python3 And how about this? if __name__ == "__main__": main() I've reviewed some recent sample snippets and not all of them use the shebang and the conditional main call, so I wasn't sure whether that is still considered good …

Member Avatar for sneekula
0
146
Member Avatar for Ben_8

Hi guys Just started to get into Python so this site seems liek a gtreat resource for hints and tips. Nice to meet you all. Ben

Member Avatar for Gribouillis
1
94
Member Avatar for EdJones

I'm learning python (and programming in general) through Runestone Interactive. What do people think of that site as a place for beginners to learn python? Also, is there any harm in trying to learn perl and web design languages at the same time? I'm concerned about becoming confused.

Member Avatar for Gribouillis
0
149
Member Avatar for ram_10

Hello again :) I'm trying to define a simple "spelling correction" function that takes a string and sees to it that 1) two or more occurrences of the space character is compressed into one, and 2) inserts an extra space after a period if the period is directly followed by …

Member Avatar for Gribouillis
0
308
Member Avatar for matrixdevuk

I am trying to get the following ENUM to work, but it's not working. Any help is appreciated. class Colour(Enum): WHITE = (255,255,255) BLACK = (0,0,0) RED = (215,45,45) BLUE = (45,87,214) YELLOW = (230,223,48) GREEN = (45,194,64) Using it: `Colour.BLACK` Error: /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 "/Users/blooop/main.py" Traceback (most recent call last): File …

Member Avatar for matrixdevuk
0
349
Member Avatar for Johnny Blaz

num = int(input("Enter a number: ")) if num==0 or num<0: continue else: if num > 1: if (num % i) == 0: print(num,"is not a prime number") print(i,"times",num//i,"is",num) break else: print(num,"is a prime number")

Member Avatar for sneekula
0
176
Member Avatar for ram_10

I've to write a function that takes a list of English words and returns a list of Swedish words. For example, {"merry":"god", "christmas":"jul", "and":"och", "happy":gott", "new":"nytt", "year":"år"} used to translate English into Swedish. def translate(a): a = {"merry":"god", "christmas":"jul", "and":"och", "happy":"gott", "new":"nytt", "year":"år"} for k, v in a.iteritems(): print k,v …

Member Avatar for snippsat
0
436
Member Avatar for matrixdevuk

I'm a beginner to Python and I decided to make a permutation finder program. Have fun and don't question the name. :)

Member Avatar for matrixdevuk
0
183
Member Avatar for ram_10

Hello, I'm trying to define a function that takes an integer 'n' and a character and returns a string, 'n' characters long. I'm totally lost and I've nothing. I read in a forum "".join might help. But that too is beyond perceivable for me at this moment. I do have …

Member Avatar for ram_10
0
412
Member Avatar for ram_10

Hello, I've been trying to write a function that takes a value (i.e. a number, string, etc) x and a list of values a, and returns True if x is a member of a, False otherwise. This is the script I could think of. I'm not even sure what might …

Member Avatar for Gribouillis
0
821
Member Avatar for itsthewendigo1111

I"ve been working on this dice game for the past few days. I made sure the game itself worked properly then I added a draw dice function that would show you the dice that were rolled on the canvas. I needed a continue button to make the rest of the …

Member Avatar for itsthewendigo1111
0
261

The End.