15,190 Topics

Member Avatar for
Member Avatar for Tcll

what I'm basically trying to do is: x = struct( size=4, order='var0', # <<< struct.__call__( size, order, **vars ) var0 = bu32 # { 'var0': bu32, } ) data = x() # read data from imported file print data.var0 # should return a bu32 int if data.__class__ == x: pass …

Member Avatar for Tcll
0
1K
Member Avatar for new2py

Hi, I'm new to Python - and new on here.... I've read lots of tutorials on Python and am currently in an intro to programming class using python, but I can't figure this out. I've searched stack overflow, dani web, java2s, github and many others but can't understand what I'm …

Member Avatar for new2py
0
308
Member Avatar for cheeseman125

So im extremely new to python. Im teaching it to myself for a school project and i heard that calculators are a good place to start so that's exactly what im doing. I have only been using it for about a day now so like i said im pretty newb. …

Member Avatar for BustACode
0
245
Member Avatar for fonzali

hi , I am trying to first ask the user how many numbers he has ( I have not coded this part yet but assumed number 5 ), then enter the first number , hit enter , enter another number in the same entery widget up until the numbers are …

Member Avatar for fonzali
0
4K
Member Avatar for BustACode

I needed a random color selector. I found one [here](http://peepspower.com/python-script-to-generate-random-css-colors). I rewrote it to make it more general purpose. "f_GenRandomColor" is the picker. The output is in list form, which should make it suitable for most general applications. "f_HTMLRandomColorChart" is just a way to create an HTML table to test …

Member Avatar for snippsat
2
521
Member Avatar for Tcll

alright, so here's what I got: # -*- coding: utf-8 -*- W = 25 l = [[u'░' for c in range(W)] for r in range(5)] _Y = 2 for X in range(W): Y = _Y+((X&3)-(X&2))-(2*((X&3)==3)) # <-- this could be better l[Y][X] = u'█' for r in l: print ''.join(r) …

Member Avatar for Tcll
0
258
Member Avatar for jolio5

I need to reduce the length of this code in Python3 as much as possible (even if it will be less readable): a,b,x,y=[int(i) for i in input().split()] while 1: r='' if y<b:r='S';y+=1 if y>b:r='N';y-=1 if x<a:r+='E';x+=1 if x>a:r+='W';x-=1 print(r) It's a map: you are on (x,y) and you need to …

Member Avatar for vegaseat
0
178
Member Avatar for Tcll

as the title states, on on linux (Wine32) it works perfectly: http://lh3.ggpht.com/-heB_VObWcwE/VUgfS4bkLkI/AAAAAAAAJAA/tHZzjq2RElw/s642/SIDE_firstPort.png but on windows (synced code) I get this: Python 2.7.9 (default, Dec 10 2014, 12:24:55) [MSC v.1500 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. >>> ================================ RESTART ================================ >>> C:\Documents and Settings\Owner\My …

Member Avatar for Tcll
0
2K
Member Avatar for ccandillo

I have a tkinter app that has 2 frames. The frame on the left has a bunch of buttons and the frame on the right has a text widget. I use the create_buttons function below to make the buttons. Is there a way to have the button stay sunken when …

Member Avatar for ccandillo
0
752
Member Avatar for fatalaccidents

I was wanting to create something very specific that I have yet to run into yet googling the topic. I want to create a radviz graph with many parameters, which is well documented. I'll give you an example that might help clarify what I'm trying to do. So here are …

0
116
Member Avatar for vulcano224

HI Guys, I am trying to Create a GUI in Python that calculate the average of three numbers. I am having some issues tring to create the three boxes where the user should enter the numbers, so can anybody please give me a hand? Thank you so much!!!!

Member Avatar for minyechil
0
423
Member Avatar for racigan

array = [10.4 , 10.4,10.4 ,10.4,11.0] Need to find the all the values in array are equal, if values are not equal get the first non equal value. expected: false for the above example. get the value 11.0

Member Avatar for 1nfinite
0
206
Member Avatar for davidbr

I have this code which if i press msgbox yes it opens another frame but if i do same thing from another function (counter) i get an error. Can someone help me and tell what is wrong? import tkMessageBox import Tkinter as tk from Tkinter import * from functools import …

Member Avatar for sepp2k
0
220
Member Avatar for Teeban Jay

This is a program that will calculate stockin expenses and other but the problem is whatever value i entered in the cement, bricks and etc(line 120-line155) part it keeps on showing zero import Tkinter Total_StockIn = 0 Total_Expenses = 0 def win1(): global root global s # this is the …

Member Avatar for vegaseat
0
222
Member Avatar for Tcll

so I was trying to think of ways to reduce python's memory usage when you write your code. my logic is telling me your class instances will use less memory if you write your class functions before writing your class: def classfunc( inst, arg ): pass class mainclass: pass inst …

Member Avatar for Tcll
0
230
Member Avatar for kouty

Hi my friends! Here is a wrong code, Wrong and I don't know why. My purpose is to make a **sieve of Erasthotene**. I make an unique function with many inner loops. But the execution **don't go cross the lines** I illustrate this with the help of printing the different …

0
201
Member Avatar for deonis

Hi Guys, I am trying to draw on PlotCanvas using wx.DC module. I have several problems with drawing on WXBufferedPaintDC, for some reason my DC text disappears after windows resizing and it looks that I draw my text in the wrong place. Any help appreciated. Here is my code: import …

Member Avatar for deonis
0
1K
Member Avatar for dadaas

Hi, i m new and i will sure seek for some help also i will try to help others as well with my for now limited knowledge of Python. So here is my problem: I m learnign and i want to learn how to scrape things. i did scrape some …

Member Avatar for dadaas
0
245
Member Avatar for johndumb77

Hey guys, I have this code at the end of my python game: root = Tk() root.title("Jack's Game") root.resizable(0,0) root.configure(bg="green") game = Board(root, width=8, height=8, letters=10) game.mainloop() And I also have a button somewhere above. I want to have function for the `command="xxx"`. What I want the function to do …

0
100
Member Avatar for mark103

I need some help with my code, I'm stored the list of elements in arrays and when I try to print the list of elements, it would print only one element where I have more than one. When I try this: pos_start = list() pos_top = list() pos_width = list() …

Member Avatar for woooee
0
279
Member Avatar for bunkus

Is there anybody having a code snippet for using the Bresenham circle algo and modifiying it in a way so that it actually draws arcs with specified start and end angle instead of complete circles? A Bresenham algo for a complete circle in Python would be like this: [CODE]import PIL.Image, …

Member Avatar for vegaseat
0
8K
Member Avatar for vegaseat

Just some interesting applications of the bitwise and (&), or (|) operators. You might find some other uses.

Member Avatar for vegaseat
0
279
Member Avatar for Raman_4

In the below python code, scrollbar for the panel is not working. I have added checkboxes under panel in the 2D for loop. Please help here def GenerateTree(self,event): v1=int(val1) v2=int(val2) print v1,v2 x=v1+v2 print x panel = wx.lib.scrolledpanel.ScrolledPanel(self,-1, size=(1100,1500), style=wx.RAISED_BORDER,pos=(10,145)) panel.SetupScrolling() UEarr=('UE1','UE2','UE3','UE4','UE5','UE6','UE7','UE8','UE9','UE10','UE11','UE12') LCarr=('LC3','LC4','LC5','LC6','LC7','LC8','LC9','LC10') y=0 i=0 j=0 k=0 for i in …

Member Avatar for vegaseat
0
239
Member Avatar for jeremywduncan

Exercise 11.1. Write a function that reads the words in words.txt and stores them as keys in a dictionary. It doesn’t matter what the values are. Then you can use the in operator as a fast way to check whether a string is in the dictionary. Trying to figure this …

Member Avatar for Mohammad_19
0
3K
Member Avatar for lapo3399

I'm new to Python, and as I was coding for Project Euler to develop my skills in this language, I needed a function for converting between two bases. I know that int() can convert anything to base 10, but before I looked for a Python module concerning this math, I …

Member Avatar for vegaseat
0
2K
Member Avatar for tony75

Hi I have this key How can I add \x between two number of hex as you see in my example. f0cbf260e0ca8ec2431089fb393a1c29513aaaa5847d13e8be84760968e64dc6 Change to “\xf0\xcb\xf2\x60\xe0\xca\x8e\xc2\x43\x10\x89\xfb\x39\x3a\x1c\x29\x51\x3a\xaa\xa5\x84\x7d\x13\xe8\xbe\x84\x76\x09\x68\xe6\x4d\xc6” I appreciate your help

Member Avatar for EMERSON_1
0
10K
Member Avatar for MustafaScript
Member Avatar for Seher_1

how to calculate term frequency,inverse document frequency(tf-idf) for own text files that consists of many terms.

Member Avatar for Gribouillis
0
164
Member Avatar for turntomyleft

One of my first programs was coded on paper tape. Another was via punched cards. I foresaw amazing stuff, e.g., artificial intelligence, models for weather, space travel, etc., but never imagined we would come this far in only 60 years. I now have a programmer son who wants me to …

Member Avatar for vegaseat
0
770
Member Avatar for BustACode

The End.