4,305 Posted Topics

Member Avatar for asif49

I just bought a 64G flash drive smaller than my thumbnail. That should be easy to hide your private data on.

Member Avatar for jwenting
0
751
Member Avatar for vegaseat

Use onMouseover to change the background color of your webpage. Can be applied to change other things like images and so on.

Member Avatar for TonyG_cyprus
0
3K
Member Avatar for Necrozze

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 …

Member Avatar for Necrozze
0
304
Member Avatar for entropic3105

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 …

Member Avatar for entropic3105
0
759
Member Avatar for otengkwaku

for a solution see ... http://www.daniweb.com/software-development/python/threads/454877/win32com-error-with-cx_freeze-#post1975839

Member Avatar for vegaseat
0
596
Member Avatar for Varunkrishna

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 …

Member Avatar for Varunkrishna
0
1K
Member Avatar for 26bm

Use this ... # set alpha to 0 (fully transparent) to 255 (not transparent) circle.set_alpha(150)

Member Avatar for 26bm
0
604
Member Avatar for vegaseat

Just a code sample that allows you to play your midi or mp3 music files with Python and module pygame.

4
2K
Member Avatar for vegaseat

You can draw a number of shapes directly on the PyGame window, and then save the drawing to an image file.

3
5K
Member Avatar for rude_god

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 …

Member Avatar for Lardmeister
0
4K
Member Avatar for nouth

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 …

Member Avatar for chriswelborn
1
631
Member Avatar for krystosan

Take a clode look at ... http://pycheesecake.org/wiki/PythonTestingToolsTaxonomy#MockTestingTools

Member Avatar for vegaseat
0
138
Member Avatar for nouth

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

Member Avatar for nouth
0
508
Member Avatar for mattster

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".

Member Avatar for Assembly Guy
0
857
Member Avatar for Xantipius

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 = …

Member Avatar for Xantipius
0
396
Member Avatar for vegaseat

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.

Member Avatar for diliupgabadamudalige
0
5K
Member Avatar for mad5245

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, …

Member Avatar for mad5245
0
956
Member Avatar for vegaseat

A somewhat newer look at Peter Parente's pywin32 based speech engine. It will read text on your computer.

Member Avatar for ZZucker
3
307
Member Avatar for bumsfeld

Sorry, mindreading is not my métier. Please gives us an example of your code and the error message you get.

Member Avatar for Kyss
0
240
Member Avatar for NiescierJ

Look at the Tkinter manual and fix the canvas.create_image() parameters. eg. http://effbot.org/tkinterbook/canvas.htm

Member Avatar for vegaseat
0
339
Member Avatar for NiescierJ

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 …

Member Avatar for vegaseat
0
14K
Member Avatar for vegaseat

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 …

Member Avatar for ZZucker
1
2K
Member Avatar for TrustyTony

Actually, nothing beats the convenience of C language n++ and n-- The eggheads of Python have discussed this, but have not acted.

Member Avatar for paddy3118
1
289
Member Avatar for vegaseat

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.

Member Avatar for TrustyTony
5
6K
Member Avatar for tony75
Member Avatar for tony75
0
174
Member Avatar for Helper guy

Swaroop C.H. has rewritten his excellent beginning Python tutorial for Python3: http://swaroopch.com/notes/python/

Member Avatar for M.S.
0
193
Member Avatar for Koljik

@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.

Member Avatar for Koljik
-1
240
Member Avatar for christopher.north.520125

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

Member Avatar for vegaseat
0
116
Member Avatar for laver68xo

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 '''

Member Avatar for HiHe
0
203
Member Avatar for otengkwaku

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': …

Member Avatar for dashing.adamhughes
0
692
Member Avatar for Dalek Caan
Member Avatar for Xantipius
0
285
Member Avatar for mkweska

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 …

Member Avatar for snippsat
0
479
Member Avatar for nouth
Member Avatar for vegaseat

A simple test of PySide's QFileDialog widget and its method getOpenFileNames. Use method getOpenFileName if you want just one file name.

3
3K
Member Avatar for rwe0

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.

Member Avatar for vegaseat
1
398
Member Avatar for tony75
Member Avatar for krystosan
Member Avatar for giancan

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.

Member Avatar for vegaseat
0
148
Member Avatar for tony75

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 …

Member Avatar for tony75
0
494
Member Avatar for mkweska

If your character picks starfighter, then those initial values have to be assigned to your character.

Member Avatar for Schol-R-LEA
0
219
Member Avatar for entropic3105

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 …

Member Avatar for bumsfeld
0
317
Member Avatar for jaison2

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, …

Member Avatar for bumsfeld
0
10K
Member Avatar for cobaltbravo

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?

Member Avatar for cobaltbravo
0
302
Member Avatar for NardCake

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 …

Member Avatar for deceptikon
0
564
Member Avatar for krystosan

Did you download this ... http://sourceforge.net/projects/pywin32/files/pywin32/Build%20218/pywin32-218.win32-py2.6.exe/download

Member Avatar for krystosan
0
828
Member Avatar for rwe0

I don't have a Linux machine handy, but Pillow should be installed in ../Python33/Lib/site-packages/PIL

Member Avatar for vegaseat
0
847
Member Avatar for mkweska

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

Member Avatar for vegaseat
0
302
Member Avatar for Subomi

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 …

Member Avatar for vegaseat
0
294
Member Avatar for vegaseat

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

Member Avatar for vegaseat
3
4K
Member Avatar for LastMitch

The End.