4,305 Posted Topics
Re: I assume this is a well orchestrated April Fools event. | |
Re: Here is my limited info ... # using the module ctypes you can access DLLs written in C/C++ # ctypes converts between Python types and C types # there are two ways to write DLLs: # most common uses cdecl, import with cdll # Win and VB may use stdcall, … | |
Re: To me proper indentations and object names are important. | |
Re: You Python version is important. For Python3x see the wxPython Phoenix project. | |
Re: You can test it with id() ... mylist = [1,3,5] newlist = mylist print id(mylist), id(newlist) mylist = [2,4,6] print id(mylist), id(newlist) | |
Re: You could try wxPython's excellent tabbed notebook widget ... ''' pwx_Notebook_simple1.py experiments with wxPython's wx.Notebook() widget wx.Notebook(parent, id, pos, size, style, name) tab position style=wx.NB_TOP is default others are wx.NB_BOTTOM, wx.NB_LEFT or wx.NB_RIGHT tested with Python273 and wxPython291 For Python32 downloaded the most recent wxPython-Phoenix-r73709-win32-py3.2.tar.gz from http://wxpython.org/Phoenix/snapshot-builds/ then simply extracted … | |
Re: Like them both. | |
Re: This seems to work ... message = 'your mother wears army socks' shift = 1 def cipher(message, shift): result = '' for letter in message: x = ord(letter) if letter.isalpha(): x = x + shift offset = 65 if letter.islower(): offset = 97 while x < offset: x += 26 … | |
Re: You download your data into a file on your hard drive or any USB flash card. | |
Re: Just a few more hints ... s = "abcdefg" for x in range(1, len(s)+1): print(s[-x:]) print(list(s[-x:])) | |
Re: You can use the Python Image Library (PIL) to resize your image to fit into your display widget. See: http://www.daniweb.com/software-development/python/code/450373/resize-an-image-from-the-web-pil-tkinter# | |
So you want to find out which day of the week you were born. Well at least some of us do. I actually wrote this program because my whole family was born on Sundays, and my friends didn't believe it! An oldie but goodie, moved from DeSmet C to Turbo … | |
Re: @nytman, as a beginner you could also use a list of tuples ... # index constants for (name, salary, mark) tuple NAME = 0 SALARY = 1 MARK = 2 # create a list of (name, salary, mark) tuples mylist = [] while True: name = raw_input("Enter your name (q … | |
Re: I used an oldfashioned loop to make it more clear ... mylist = [('Meat', 'Milk'), ('Cake - Cookie',), ('Apple', 'Orange')] newlist = [] for item in mylist: print(item) if '-' in item[0]: item = tuple(item[0].split(' - ')) print(item) newlist.append(item) print(newlist) ''' result ... ('Meat', 'Milk') ('Cake - Cookie',) ('Cake', 'Cookie') … | |
| |
Re: The problem is your data lines don't split nicely into identity, name, category, price fields. | |
Re: s = '''"No, thanks, Mom," I said, "I don't know how long it will take."''' print(s) | |
Re: When you use grid() the width of the grid column is determined by the largest widget width in it. Dito for height. | |
Re: Sneekula's answer should pretty well solve your problem. Are you sure you have read it? Opal, Ruby and Moonstone appear once and Diamond appears 3 times. | |
Re: Which GUI toolkit did you use? | |
Re: Is this like something you are thinking about? [php] // time the bubblesort of an array of random integers #include <windows.h> // GetTickCount() #include <stdio.h> // printf(), getchar() #include <stdlib.h> // srand(), rand() #define NUM_ITEMS 10000 void bubbleSort(int numbers[], int array_size); int numbers[NUM_ITEMS]; int main() { int k; long te, … | |
| |
This short piece of code shows you how to display text in color in a C# windows console program. The corresponding WIN32 API functions are in the kernel32.dll and are imported and declared external. The only other problem is to assign variable types that accommodate the types listed in the … | |
Re: Your code has a handful of mistakes and misconceptions. I corrected some of them to get this to work ... class Account: '''Wells Fargo.''' #global balance def __init__(self, name, pin_number, balance): self.name = name self.pin_number = pin_number self.balance = balance def alter_pin(self, enter_a_pin): '''needs work''' '''To be used a later … | |
Re: Looks like our friend otengkwaku is on the right track. You have to rebuild a new ID string. The only problem with his code are names like "Matt Mummert" | |
Re: Had to test this ... try: # for Python2 import Tkinter as tk import tkFileDialog as tkfd except ImportError: # for Python3 import tkinter as tk import tkinter.filedialog as tkfd def list_dir(): dirname = tkfd.askdirectory(parent=root, initialdir="/", title='Please select a folder/directory') root.title(dirname) # test only myvar.set('Current Folder Selected is: ' + … | |
Re: Thanks for the detailed info ZZucker. | |
A permutation is the arrangement of a set of items in different order. One interesting application is the rearrangement of characters in a word to create other words. If all the n characters are unique, you should get n! unique permutations. You can make a list of words unique by … | |
Scientists and deficit spenders like to use Python because it can handle very large numbers. I decided to give it a test with factorials. Factorials reach astronomical levels rather quickly. In case you can't quite remember, the factorial of 12 is !12 = 1*2*3*4*5*6*7*8*9*10*11*12 = 479001600, that is 479 million … | |
![]() | Re: I have to honestly say that I never heard of St. Davids day. |
Re: About 6 hours during the week and 2 hours on the weekend. I don't watch much TV, but spend time outside. | |
Re: I as far as I understand, the **Raspberry Pi** is a tiny inexpensive ($35) computer board based on Linux and Python. It came out about a year ago in the UK and sold over one million units so far. Correct me if I am wrong. Sounds like an interesting project … | |
Re: Look into the **java.awt.dnd** package | |
Re: A combination with the maximum sample size is called a permutation. | |
Re: Can you mix 32 bit Python and 64 bit Excel? Give it a try. If you are using a third party module to interface with Excel, make sure its available in 64 bit format. I am thinking of xlrd or xlwt which are still 32 bits. | |
Re: It might be because you are mixing layout managers place() and pack(). Never a good idea. | |
This snippet allows you to find the number of ordered permutations of items taken from a population of known size. It uses the well know algorithm with factorials. For very large populations you may want to use an approximation of factorials. | |
If you want to know the number of combinations of x things taken n at a time, you can use the Python module gmpy. The module gmpy is a C-coded Python extension module that supports fast multiple-precision arithmetic, very handy if x things reach a large number. | |
Re: Here is an example ... ''' class_private101.py class variables and methods can be made private to the class ''' class C(object): ''' inheriting object is automatic in Python3 ''' # k is public to all instances of class C k = 1234 # variable names with double underline prefix like … | |
Re: In other words, game in your code is just one combination. To get a list of all combinations you have to append to an empty list (as shown by Lucaci Andrew) or use the list(combinations()) approach (shown by Griboullis) ... from itertools import combinations numbers = [1,2,3,4,5,6,7,8,9,10] games = [] … | |
Re: Just another way ... with open('numbers.txt') as f: raw_list = f.readlines() print raw_list mylist = [eval(item) for item in raw_list] print mylist ''' ['1\n', '2\n', '3\n', '4\n', '5\n', '6\n', '7\n', '8\n', '9\n', '10\n'] [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] ''' | |
Re: The code snippet at http://www.daniweb.com/software-development/python/code/448444/control-visual-3d-object-with-tkinter-buttons shows you how to control a 3D visual object. | |
This Python snippet shows how to control a VPython visual 3D sphere with Tkinter GUI toolkit button clicks. | |
Re: ... and your problem is? | |
Re: In the restroom at work, the Boss had placed a sign directly above the sink. It had a single word on it -- "Think!" The next day, when he went to the restroom, he looked at the sign and right below, immediately above the soap dispenser, someone had carefully lettered … | |
Re: Python has been written to have a clear and readable syntax. Ruby allows for a lot of symbolism similar to Perl. It saves you some typing, but makes things harder to read and understand. Much of the use of Ruby can be attributed to a web development framework called Rails, … | |
Let's imagine you are taking a lot of pictures and modify them with one of those fancy image editors. You burned the image files to a CD, and decided to purge some of the outdated files because your hard drive is getting full. This Python code allows you to set … |
The End.