4,305 Posted Topics
Re: I just bought a 64G flash drive smaller than my thumbnail. That should be easy to hide your private data on. | |
Use onMouseover to change the background color of your webpage. Can be applied to change other things like images and so on. | |
Re: Here is an example that you can play with ... '''Class_Animal1.py a look at a simple Python class a class combines methods/functions that belong together to keep methods private, prefix with a double underline only see also: http://neopythonic.blogspot.com/2008/10/why-explicit-self-has-to-stay.html tested with python27, python32, python33 ''' class Animal(): """ class names by … | |
Re: Should be part of your Python installation. random.py should be in your /Lib folder You may have created a test file **random.py** in your working directory. Rename that one to something like random_test.py so Python will look further. Remember that Python will look in your working directory first and than … | |
Re: for a solution see ... http://www.daniweb.com/software-development/python/threads/454877/win32com-error-with-cx_freeze-#post1975839 | |
Re: Another approach ... ''' re_sub_translate2.py a simple and rough English to German translator specifically replace whole words only will replace I but not change Italy note that this replacement is case sensitive attached quotes and punctuation marks are neutral ''' import re def re_replacer(match_obj): ''' this function will be called … | |
Re: Use this ... # set alpha to 0 (fully transparent) to 255 (not transparent) circle.set_alpha(150) | |
Just a code sample that allows you to play your midi or mp3 music files with Python and module pygame. | |
You can draw a number of shapes directly on the PyGame window, and then save the drawing to an image file. | |
Re: An example might explain it better ... # normal function declaration def timestwo1(x): return x * 2 # using lambda (not anonymous) timestwo2 = lambda x: x * 2 # test it ... print(timestwo1(4)) # 8 print(timestwo2(4)) # 8 # or make it anonymous ('on the fly') print((lambda x: x … | |
Re: You can run this simple code ... ''' names_reserved101.py show all builtin functions/methods and keywords avoid using any of those names for your variables, or you will get conflicts, using keywords flag as error ''' from keyword import kwlist print("A list of Python's keywords:") print('\n'.join(kwlist)) print('-'*60) print("Show all Python builtin … | |
Re: Take a clode look at ... http://pycheesecake.org/wiki/PythonTestingToolsTaxonomy#MockTestingTools | |
Re: > can I import a file from the very same folder as the file I want to run? Yes, this is one way Python can find the import file. | |
Re: The Google Chromebook has Ubuntu under the hood. It boots up very fast. Access to the Ubuntu layer seems to be discouraged by Google. After all, they mouth off about being "Virus Save". | |
Re: I was born on a Sunday as a Gemini. Here is a little Python script to help ... ''' calendar_day_of_week.py find the day of the week for a given date ''' import calendar # for instance Albert Einstein's birthday year = 1879 month = 3 day = 14 days = … | |
Here is a short Python program using the module pygame that lets you play a midi music file. Midi files are instrumental music files that pack a lot of good sound into a small file. They are very popular with web page designers. ![]() | |
Re: Here is an example .... ''' pqt_thread_test102.py test Qthread threading time delay works properly modified from ... http://joplaete.wordpress.com/2010/07/21/threading-with-pyqt4/ ''' import sys, time from PyQt4 import QtCore, QtGui class GenericThread(QtCore.QThread): def __init__(self, function, *args, **kwargs): QtCore.QThread.__init__(self) self.function = function self.args = args self.kwargs = kwargs def __del__(self): self.wait() def run(self): self.function(*self.args, … | |
A somewhat newer look at Peter Parente's pywin32 based speech engine. It will read text on your computer. | |
Re: Sorry, mindreading is not my métier. Please gives us an example of your code and the error message you get. | |
Re: Look at the Tkinter manual and fix the canvas.create_image() parameters. eg. http://effbot.org/tkinterbook/canvas.htm | |
Re: A working example ... ''' tk_Canvas_BGImage1.py use a Tkinter canvas for a background image for result see http://prntscr.com/12p9ux ''' try: # Python2 import Tkinter as tk except ImportError: # Python3 import tkinter as tk root = tk.Tk() root.title('background image') # pick a .gif image file you have in the working … | |
Yes, you can let your computer read text to you. The task is relatively easy, if you have Windows on your machine. All you need is Microsoft's speech-API SAPI, the Python Text to Speech module pyTTS, and an updated version of win32com, all free downloads. Here are some experiments with … | |
Re: Actually, nothing beats the convenience of C language n++ and n-- The eggheads of Python have discussed this, but have not acted. | |
This code example shows how to create a dictionary with row,column indexed (r,c) key tuples from a typical list of lists 2D matrix. Also an example is shown of the ease of processing the resulting dictionary. | |
| |
Re: Swaroop C.H. has rewritten his excellent beginning Python tutorial for Python3: http://swaroopch.com/notes/python/ | |
Re: @tony75, what is line 10 going to do? There is no **goto** in Python. Design your program properly and you don't need this old **Basic Language** horror. | |
Re: # Python2 uses raw_input() for strings # Python3 uses input() for strings # ---------------------------------------------- # add these few lines near the start of you code import sys # make string input work with Python2 or Python3 if sys.version_info[0] < 3: input = raw_input # ---------------------------------------------- # test ... # now … | |
Re: Hint ... s = '''\ taxon1 ACCGTGGATC CCTATTGATT GGATATTATC ''' s2 = "" for ix, line in enumerate(s.split('\n')): line = line.rstrip() if ix == 0: # add a space line += ' ' s2 += line print(s2) ''' result ... taxon1 ACCGTGGATCCCTATTGATTGGATATTATC ''' | |
Re: The key word argument **kw indicates a dictionary of variable number of key:val arguments Used when the number of arguments is not known ahead of time, an example ... def make_dic(**kw): print(vars()) # show local dictionary return kw d = make_dic(dg='dog', bw='bow', ct='cat') print('-'*50) print(d) ''' result ... {'kw': {'dg': … | |
![]() | Re: It should be your manager's job to keep you busy, inspired and productive. |
Re: Not sure which version of Python you are using, but this should work with Python27 and Python33 ... ''' file_read103.py assume mynames.txt has these content lines ... Fred Mary Lisa Amy ''' fname = "mynames.txt" with open(fname) as fin: k = 1 for name in fin: # rstrip() removes trailing … | |
Re: Need to see some coding on your part. What have you tried? | |
A simple test of PySide's QFileDialog widget and its method getOpenFileNames. Use method getOpenFileName if you want just one file name. | |
Re: My semi-educated guess is that the error is caused by Window's insistance to use '\n\r' for a newline rather than the more common '\n'. PyQT/PySide QFileDialog.getOpenFileNames() behaves better. | |
Re: What type of **Version** do you have in mind? | |
Re: See ... http://www.python.org/dev/peps/pep-0343/ | |
Re: Computers are binary beasts. You will always have a small roundoff error with the way floating point values are represented in a binary world. In your case pixels are integers and your calculations give floats. You might want to play with Python's round() and int() functions. | |
Re: Expanding on snippsat's code ... ''' word_frequency102.py file your.txt has data ... I love the python programming How love the python programming? We love the python programming Do you like python for kids? I like Hello World Computer Programming for Kids and Other Beginners. ''' import re from collections import … | |
Re: If your character picks starfighter, then those initial values have to be assigned to your character. | |
Re: Here is an example ... ''' Tk_Entry_numbers1.py a general Tkinter program to enter two data items process the data and display the result tested with Python27/33 ''' try: # Python2 import Tkinter as tk except ImportError: # Python3 import tkinter as tk def calculate(): """ in this case the data … | |
Re: I hope you are not stuck with an outdated module like [B]graphics[/B], which is a wrapper for Tkinter, written by some guy to sell his book. You are much better off using the Tkinter GUI toolkit directly and learn something you can actually use later on. To say it bluntly, … | |
Re: from random import randint def pick_secret(): secret = randint(1, 10) return secret secret = pick_secret() print(secret) # test You have to call your function somewhere in your code. Do not use the same name for function and variable. Are you using Python3 or Python2? | |
Re: I think some of the nastier space saving habits come from the days code had to be to printed out on paper. For me proper indentation is a must. I run my C code through the Code::Blocks IDE source code formatter ... // create a delay(millisec) function #include <stdio.h> #include … | |
Re: Did you download this ... http://sourceforge.net/projects/pywin32/files/pywin32/Build%20218/pywin32-218.win32-py2.6.exe/download | |
Re: I don't have a Linux machine handy, but Pillow should be installed in ../Python33/Lib/site-packages/PIL | |
Re: This is the solution (assuming Python3) ... def main(): num = float(input('Please enter a number: ')) print(times_ten(num)) def times_ten(num): return 10 * num main() | |
Re: Our friend **rrashkin** gave you a modified insertion sort (quoted wikipedia): Insertion sort is a simple sorting algorithm that is relatively efficient for small lists and mostly sorted lists, and often is used as part of more sophisticated algorithms. It works by taking elements from the list one by one … | |
Simple code to show you how to display an image from a Web URL using the Tkinter Python GUI toolkit, the Python Image Library (PIL) and the data_stream created with io.BytesIO(). | |
![]() |
The End.