4,305 Posted Topics

Member Avatar for shanew21

Or try this ... slist = ['10015, John, Smith, 2, 3.01', '10334, Jane, Roberts, 4, 3.81' , '10208, Patrick, Green, 1, 3.95'] mylist = [item.strip() for s in slist for item in s.split(',')] print(mylist) ''' result ... ['10015', 'John', 'Smith', '2', '3.01', '10334', 'Jane', 'Roberts', '4', '3.81', '10208', 'Patrick', 'Green', …

Member Avatar for snippsat
0
195
Member Avatar for UnchainedDjango
Member Avatar for vegaseat

If you draw shapes that are closely spaced and shifted, you can create interesting interference patterns, so called moire patterns. Here is an example using the Python module PyGame to do the drawing.

2
728
Member Avatar for bdheeraj
Member Avatar for sneekula
0
580
Member Avatar for Lardmeister

Just to mention another famous futurist. The years 2008 through 2012 are referred to by Nostradamus as the "Time of Troubles", a period full of war, despair, and evil, but also of hope and promise.

Member Avatar for sneekula
2
2K
Member Avatar for <M/>

Of the huge number of eggs laid in history, one must have finally hatched a chicken.

Member Avatar for <M/>
0
389
Member Avatar for <M/>

In these days I code mostly in Python, and use an IDE geared for that language, like Eric or PyScripter. CodeBlocks isn't too bad for generic C or C++ code. I am still looking for an IDE for Jython. NetBeans was supposed to work, but was ghastly!

Member Avatar for sneekula
0
211
Member Avatar for giancan

Take a look at: http://www.daniweb.com/software-development/python/code/445504/an-almost-ide-wxpython Should have enough hints how to do this with wxPython. Basically ... # using module subprocess to get the # directory of drive C:\ # Python27 code import subprocess p = subprocess.Popen("dir C:\\", shell=True, stdout=subprocess.PIPE) # allow external program to work p.wait() # read the …

Member Avatar for sneekula
0
1K
Member Avatar for vegaseat

This small code example shows you how to approach the beginning concept of an very simple "IDE" for Python.

0
808
Member Avatar for welshly_2010

Interestingly, Python syntax is closer to normal pseudocode than any other computer language.

Member Avatar for vegaseat
0
7K
Member Avatar for krystosan

Here is a typical example: http://www.daniweb.com/software-development/python/code/445498/pyside-mainwindow

Member Avatar for vegaseat
0
201
Member Avatar for vegaseat

If you want a window with a menubar, toolbar, statusbar, dock and central widgets, you can use the PySide GUI toolkit's QMainWindow. To use the more traditional box and grid layouts, you simply add a QWidget instance as the central widget. Here is an example.

2
3K
Member Avatar for clouds_n_things

Load the data if phonelist is empty and data file exists. Something like this ... from tkinter import * import pickle import os def save_phonelist(addressbookfile, phonelist): addressbook = phonelist # write to storage f = open(addressbookfile, 'wb') pickle.dump(addressbook, f) f.close() def load_phonelist(addressbookfile): # 'r'ead back from storage f = open(addressbookfile, …

Member Avatar for clouds_n_things
0
321
Member Avatar for vegaseat

A colorful look at the PySide GUI toolkit and its QPainter class and methods. Well commented and demonstrated with the drawing of a number of rectangles and the different ways to apply colors.

1
1K
Member Avatar for pmec

If you use format minutes:seconds:milliseconds and show 00:02:20 do you mean 00:02:200

Member Avatar for ZZucker
0
5K
Member Avatar for Reverend Jim

Santa Claus is based on St. Nicholas of Myra. He was a 5-foot-tall Greek man with a broken nose, and lived in modern-day Turkey around A.D. 200 to 300. He was renowned for his generosity, his kindness to children and his amazing boxing skills.

Member Avatar for Reverend Jim
2
208
Member Avatar for pars99
Member Avatar for bulleh

Line 62 should be **else: print("Unknown Option. Goodbye")** Also put in a console wait line after that line ... **raw_input("Press Enter to go on ...")** Line 36 should be part of the line 29 if statment. Your print statements are misleading. For instance, line 38 is a dangerous mix of …

Member Avatar for bulleh
0
254
Member Avatar for krystosan

Replace **QtGui.QMainWindow** with **QtGui.QWidget** also comment out **win.floatingToolBar()** or you will be calling it twice

Member Avatar for krystosan
0
1K
Member Avatar for lukecalland

The class itself cannot be pickled, but the list of instances can. To use the pickled data file in another program, you have to recode the class in that program. See: http://www.daniweb.com/software-development/python/code/444923/pickle-class-instances-python#

Member Avatar for vegaseat
0
167
Member Avatar for vegaseat
Member Avatar for dashing.adamhughes
2
7K
Member Avatar for vegaseat
3
345
Member Avatar for vegaseat

This snippet shows you how to create a list of class instances. The class itself cannot be pickled, but the list of instances can. To use the pickled data file in another program, you have to recode the class in that program.

3
2K
Member Avatar for movielinks

A happy New Year to all! May the world be slightly less crazy this year!

Member Avatar for TracyPortner
0
223
Member Avatar for vegaseat

Jython is a version of Python that can use the extensive Java library. Jython uses Python syntax and avoids the rather ugly syntax (at least for Pythonions) of Java. Here we apply it to bring up an image from a file.

4
721
Member Avatar for TrustyTony
Member Avatar for ZZucker

You might take a look at: http://opencv.willowgarage.com/documentation/python/index.html Also check this paper: http://ojs.pythonpapers.org/index.php/tppm/article/download/94/111 Also: http://simplecv.org/ Simple starter code: http://examples.simplecv.org/en/latest/examples/helloworld.html

Member Avatar for ZZucker
0
220
Member Avatar for jimmyshote

What is the name of your directory, the name of your path file, and the contents of it?

Member Avatar for ZZucker
0
555
Member Avatar for Arizona33
Member Avatar for vegaseat
-1
139
Member Avatar for giancan

If I understand this right, you want something like this ... import pprint mylist = [['a00002.doc', 'image38.jpg'], ['a00003.doc', 'image40.jpg'], ['a00001.doc', 'image50.jpg']] newlist = [] for ix, item in enumerate(mylist): #print(item[0]) # testing item[0] = "a%05d.doc" % (ix+1) #print(item[0]) # testing newlist.append(item) pprint.pprint(newlist) ''' result ... [['a00001.doc', 'image38.jpg'], ['a00002.doc', 'image40.jpg'], ['a00003.doc', …

Member Avatar for vegaseat
0
187
Member Avatar for felix001

Just an observation on your code ... class Mac: def __init__(self,hexmac): self.hexmac = hexmac def resolve(self): return self.hexmac # after the above return the following will be ignored!!! return mac_address print(mac_address) mac_address = { '000000':'xerox0', '000001':'xerox1', '000002':'xerox2', } So rewrite your code as snippsat indicated already ... class Mac: def …

Member Avatar for vegaseat
0
124
Member Avatar for mgunia

Remember row index starts at zero, so use for instance ... contact_ID = row[0] email = row[25] rather than unpacking the whole row.

Member Avatar for vegaseat
0
9K
Member Avatar for nytman

For an example see: http://wiki.wxpython.org/LongRunningTasks?highlight=%28start%29|%28stop%29

Member Avatar for vegaseat
0
254
Member Avatar for chris99

Just a few changes will do ... from math import * from Tkinter import * #imports module class Calculation: def __init__(self,master): self.num = "" self.button = [None] # element at index 0 is None frame=Frame(master) frame.grid() self.returnScreen = Label(frame, background = "White", text="") self.returnScreen.grid(row=0, column=0,columnspan=3) r = 1 c = …

Member Avatar for woooee
0
133
Member Avatar for Mike Askew
Member Avatar for Frensi

() implies a function call You are using **self.clock_start = time.clock()** and **def clock_start(self):** This method would be called with self.clock_start(), but the name is used by a variable of the same name containing a float value. Simply rename one of them.

Member Avatar for TrustyTony
0
2K
Member Avatar for padton

This test code might help ... row = ['1.234', '4.563', '7.143'] print(row) # test # change list of strings to list of floats row_float = map(float, row) print(row_float) # test # change list of floats to list of integers row_int = map(int, row_float) print(row_int) # test # sum the integer …

Member Avatar for vegaseat
0
444
Member Avatar for vickim360

Here is an example ... """ rotate.py demonstrate rotating a sprite http://www.cs.iupui.edu/~aharris/pygame/ch08/rotate.py download image from: http://www.cs.iupui.edu/~aharris/pygame/ch08/ship.bmp """ import pygame pygame.init() class Ship(pygame.sprite.Sprite): def __init__(self): pygame.sprite.Sprite.__init__(self) self.imageMaster = pygame.image.load("ship.bmp") self.imageMaster = self.imageMaster.convert() self.image = self.imageMaster self.rect = self.image.get_rect() self.rect.center = (320, 240) self.dir = 0 def update(self): oldCenter = self.rect.center self.image …

Member Avatar for vegaseat
0
861
Member Avatar for ImZick
Member Avatar for runlevel3nut

Assuming you downloaded and installed Python with the python-2.7.3.msi installer, you can used a batch file like c:/python27/python.exe -u c:/myscriptfolder/myscript.py On a Windows machine you can also just double click on the script file. See: http://www.daniweb.com/software-development/python/threads/20774/starting-python#post104865 Even better, download the portable version of Python and use the PyScripter IDE that …

Member Avatar for vegaseat
1
186
Member Avatar for padton

`for d in data` will give you list objects Example ... ''' contents of file or.csv: 1, 23.27, 23.21, 83.22 2, 34.25, 65.31, 34.75 ''' import csv Or = csv.reader(open('Or.csv')) for d in Or: print(d, type(d)) ''' result ... ['1', ' 23.27', ' 23.21', ' 83.22'], <type 'list'> ['2', ' …

Member Avatar for padton
0
282
Member Avatar for Ancient Dragon
Member Avatar for shubham bhat
Member Avatar for knd15

You can get a selected list of Fibonacci numbers this way: http://www.daniweb.com/software-development/python/threads/20774/starting-python/18#post1910427

Member Avatar for vegaseat
0
243
Member Avatar for krystosan
Member Avatar for vegaseat
0
149
Member Avatar for satsujin

You will have to keep the PIL images in your list and convert them to something Tkinter can handle with `photo=ImageTk.PhotoImage(image)` just before you use them.

Member Avatar for satsujin
0
3K
Member Avatar for hotblink

The % (modulo) operator yields the remainder from the division of the first argument by the second.

Member Avatar for Xantipius
0
142
Member Avatar for dp121307

You have the pseudo code for your sort algorithm, so simply expand it to Python and test it ... mylist = [5, 3, 7, 2, 8, 4] print(mylist) n = len(mylist) for i in range(n): for j in range(1, n-i): # swap if prev value is less than current value …

Member Avatar for vegaseat
0
20K
Member Avatar for slasel

You can also use the Tkinter canvas as a label... ''' tk_canvas_create_text1.py show text at a given x, y location on a Tkinter canvas ''' try: # Python2 import Tkinter as tk except ImportError: # Python3 import tkinter as tk root = tk.Tk() root.title('Tkinter canvas text') canvas = tk.Canvas(root, height=200, …

Member Avatar for Lardmeister
0
110
Member Avatar for nitin1

I wouldn't mind spending some time exploring the Google Chromebook computer. Sleek, thin, leightweight and relatively inexpensive. If I could just get my hands on the Acer C7 Chromebook, sold out everywhere I go. Looks like Python is available too.

Member Avatar for nitin1
0
526

The End.