4,305 Posted Topics

Member Avatar for dmpop

Any important reason you want to use Python30? There have been quite a few changes beyond the import lines. Python30 import lines are ... [code]import smtplib from email.mime.multipart import MIMEMultipart from email.mime.base import MIMEBase from email.mime.text import MIMEText from email import encoders as Encoders import os import sys [/code]

Member Avatar for vegaseat
1
146
Member Avatar for dhvl2712

You are trying to run your Python program file from the Python shell. That does not work! Use one of the many good Python IDEs like PyScripter or IDLE, write your program in the associated editor and run it from there. See: [url]http://www.daniweb.com/forums/post104834-1.html[/url] If you use Python30, adjust your print …

Member Avatar for leegeorg07
0
524
Member Avatar for BlueNN

Or write and run your program using one of the many Python IDEs like IDLE or DrPython that have their own output window.

Member Avatar for BlueNN
0
145
Member Avatar for tlinux

If you use Windows, you can write a batch file to force an IDE like IDLE to use Python30 this way ... [code]REM a batch file to force IDLE to use Pyhon30 REM saved as IDLE30.bat C:\Python30\pythonw.exe -u C:\Python30\Lib\idlelib\idle.pyw [/code]Conversely you can do the a similar thing for Python26 ... …

Member Avatar for scru
1
387
Member Avatar for shibby

I have noticed that too when you only have one widget with a tooltip. If you have two or more widgets with tooltips then it works just fine. Beats me!

Member Avatar for shibby
0
78
Member Avatar for tomtetlaw

Here would be a typical example using the tkFileDialog ... [code=python]# using the file dialog without a tk window import Tkinter as tk import tkFileDialog root = tk.Tk() # show file dialog without Tkinter window root.withdraw() # defaults to current directory and all file types filename = tkFileDialog.askopenfilename() print(filename) [/code]

Member Avatar for tomtetlaw
0
608
Member Avatar for Dave Sinkula

Nicotine is a natural ingredient of the Tobacco plant and functions as an insecticide. Maybe the smokers ought to try some other insecticides, readily available at your local garden store. Nicotine is fairly toxic. According to: [URL]http://en.wikipedia.org/wiki/Tobacco[/URL] A discarded cigarette butt can contain enough nicotine to kill a small child …

Member Avatar for jbennet
0
4K
Member Avatar for JeyC

Generally ... [code=python]text = "just a sample text" # open the file for writing fout = open('test.txt', 'w') # write the text string to the file fout.write(text) # close the file fout.close() [/code]

Member Avatar for Arrorn
0
135
Member Avatar for harrykokil
Member Avatar for lilkid

If I understand you right, it should look like this ... [code=python]# assumed test data (text from a data file) data_str = """\ T34712 ABERDEEN 0800 LANDED 08:00 BE171 SOUTHAMPTON 0820 LANDED 08:07""" # first create a list of lists data_list = [line.split() for line in data_str.split('\n')] print data_list """ …

Member Avatar for lilkid
0
164
Member Avatar for jessica2009

Looks to me that the code started with tabs and the usual 4 spaces mixed in, and then the tabs were converted to 8 spaces. Whatever you do, don't mix tabs and spaces! For your own sanity avoid tabs! Uniform indentations for the code blocks are critical with Python.

Member Avatar for vegaseat
0
129
Member Avatar for loren41
Member Avatar for sneekula
0
258
Member Avatar for Darkangelchick
Member Avatar for woooee
0
649
Member Avatar for Madbuda

I still remember the uproar here, when the local school showed a video from a typical chicken processing plant. The problem to the parents was that 60% of the children that saw the video refused to eat chicken at home. What do you feed the brats now?

Member Avatar for jbennet
0
414
Member Avatar for karenmaye

The last PyMedia release I saw was for Python24: [url]http://downloads.sourceforge.net/pymedia/pymedia-1.3.5.0-pre2.win32-py2.4.exe?use_mirror=voxel[/url] However, it is possible to create a video with it from within a Python program. Here is an example called make_video.py they list at [url]http://downloads.sourceforge.net/pymedia/pymedia-examples-1.3.7.zip?use_mirror=internap[/url] ... [code=python]#! /bin/env python import sys, os, time import pymedia.video.vcodec as vcodec import pygame def …

Member Avatar for sneekula
0
2K
Member Avatar for dilipkk

Exploring the Natural Language Toolkit (NLTK) for Python sounds like a very interesting project! I will take a closer look at it.

Member Avatar for woooee
0
239
Member Avatar for vegaseat

I recently bought the book "Beginning Python" Norton, Samuel, Aitel et al published by Wrox/Wiley in 2005. Has anybody else bought this book and actually found the source code at the website they list in the book? I don't want to sound vinegarish, but this has got to be the …

Member Avatar for vegaseat
0
217
Member Avatar for Prahaai

For right now the easiest way for you would be to study up on the bitmap file format, it is the simplest and most straight foreward format: [url]http://en.wikipedia.org/wiki/BMP_file_format#BMP_file_header[/url] Read the file in as binary, and using the offsets listed get past the header to the pixel portion of the file …

Member Avatar for vegaseat
0
343
Member Avatar for BigPappyJappy

You want to go into a circle so you get printable characters. Here is an example of Python's builtin rotation encoder, it starts in the middle of the 26 alpha character sets ... [code=python]# example of simple encoding/decoding using Python's 'rot13' # alphabet is shifted by 13 positions to nopqrstuvwxyzabcdefghijklm …

Member Avatar for BigPappyJappy
0
114
Member Avatar for serkan sendur

Would be interesting, but I can't even remember what I posted yesterday. Actually, following Narue's hint I think I found my first post: [url]http://www.daniweb.com/forums/post59563-4.html[/url] I was one of those know-it-all wannabes running around giving bad advice.

Member Avatar for Narue
0
309
Member Avatar for mahela007
Member Avatar for Gribouillis
0
118
Member Avatar for patelmitul

One way to split a path_list into two at selected filenames ... [code=python]import os # let's assume your path list looks like this ... path_list = ['d:\\del\\a_bc_01.jpg', 'd:\\del\\a_bc_02.jpg', 'd:\\del\\a_bc_03.jpg', 'd:\\del\\c_de_05.jpg', 'd:\\del\\c_de_06.jpg'] # create two empty path lists path_list1 = [] path_list2 = [] for path in path_list: fname = os.path.basename(path) …

Member Avatar for Gribouillis
0
378
Member Avatar for kiddo39

Here is an example ... [code=python]# show the list of (r, g, b) tuples of a bitmap image from PIL import Image img = Image.open("FrenchFlag.bmp") data = img.getdata() #show a list of (r, g, b) tuples print(list(data)) """ partial output --> [(6, 0, 240), (6, 0, 240), (6, 0, 240), …

Member Avatar for kiddo39
0
303
Member Avatar for EAnder

You can disassemble Python byte code with module dis to something that looks like assembler code, but since there is no Python assembler it's just an analytical tool.

Member Avatar for EAnder
0
194
Member Avatar for HatGuy

Just looking in the standard ASCII table you have a mix of control characters, for instance \x1b is escape, others are backspace, linefeed and some spanish characters.

Member Avatar for HatGuy
0
145
Member Avatar for Gadgeteer99

You can go with a while loop, but you have to add one to heads if it's a head, similarly with tail, also you have to deduct one from the amount within the loop. Look it over, it will make sense ... [code=python]import random amount = 100 heads = 0 …

Member Avatar for orinbai
0
206
Member Avatar for Jhun Phil
Member Avatar for blair.mayston

You can send your total information gathered as a text string ... [code=python]# gathering information from the internet import urllib import sys import xml.dom.minidom # The url of the feed address = 'http://www.stuff.co.nz/rss/' # Our actual xml document document = xml.dom.minidom.parse(urllib.urlopen(address)) # create an empty string to accumulate information in …

Member Avatar for blair.mayston
0
111
Member Avatar for ahihihi...
Member Avatar for GrimJack
0
294
Member Avatar for pythononmac

This works on my Windows machine ... [code=python]# -*- coding: iso-8859-15 -*- # check encoding in http://www.python.org/dev/peps/pep-0263/ # print strings with unicode characters name = 'café' print(name) """ my output --> café """ [/code] Using Python30 ... [code=python]# printing unicode characters # if don't have a french keyboard use this …

Member Avatar for pythononmac
0
684
Member Avatar for dirt14
Member Avatar for vegaseat
0
50
Member Avatar for Ancient Dragon

I guess you could arrested for sneezing too, that is really unsafe when you are driving. Asking a guy, that doesn't have a hair on his body, what his hair colour is? Very funny! Would make people laugh that drive by.

Member Avatar for vegaseat
0
44
Member Avatar for Norbert X

Q: a function with two positional parameters that returns two values (both integers or real numbers) A: hint, your function receives two values, let's say x, y and does some calculations on each and returns the changed values Q: a function which generates random numbers and returns them (any amount …

Member Avatar for jlm699
0
149
Member Avatar for barbosmaw

I assume that you downloaded and installed PIL-1.1.6.win32-py2.6.exe for Python26 I don't use Python26, but this program works just fine with Python25 and PIL116 ... [code=python]import Tkinter as Tk import Image import ImageTk root = Tk.Tk() c = Tk.Canvas(root, width=500, height=500) c.pack(fill='both', expand='yes') # Open a jpeg file into an …

Member Avatar for barbosmaw
0
349
Member Avatar for vmars

What was the name of your windows install file? It should be something like: wxPython2.8-win32-unicode-2.8.9.1-py26.exe You would normally find wx in: C:\Python26\Lib\site-packages\wx-2.8-msw-unicode\wx

Member Avatar for vmars
0
440
Member Avatar for Bart6114

I took code I had to dump hexadecimal image data and added a binary option to it ,,, [code=python]# hexadecimal and binary dump of image file data # modified to work with Python30 import binascii try: # pick an image file you have in the working directory # or give …

Member Avatar for Bart6114
0
14K
Member Avatar for vmars
Member Avatar for vegaseat
0
225
Member Avatar for vmars
Member Avatar for vyagee

Python is very much at home with Apple Computers. This could be a python file extension for Apple applications. Just my guess!

Member Avatar for karuppg
0
502
Member Avatar for karthik.c

In Python a dictionary is used to implement a switch/case statement ... [code=python]# a dictionary switch/case like statement to replace # multiple if/elif/else statements in Python def switch_case(case): return case + " --> " + { 'one hundred' : '100', 'two hundred' : '200', 'three hundred and fifty' : '350' …

Member Avatar for karthik.c
0
92
Member Avatar for StarZ

You are almost there, but you have to tell Python about all those foreign characters using a 'coding line' in the beginning of your code ... [code=python]# -*- coding: iso-8859-15 -*- # check encoding in http://www.python.org/dev/peps/pep-0263/ def function1(): print "Bonjour, comment allez-vous ?" def function2(): print "Hola, cómo esta usted?" …

Member Avatar for lllllIllIlllI
0
107
Member Avatar for Blujacker

At first blush, I would say no, since you have to assign a parent to the control widget and the parent has to be a wx frame. wx panel or such thing. You could however write a minimum wx program and then run that from within Tkinter with execfile("My_wxplayer.py").

Member Avatar for lllllIllIlllI
0
1K
Member Avatar for jloyzaga

Just a note to jloyzaga, please do not use tabs for indents! Makes your code look rather nasty.

Member Avatar for vegaseat
0
854
Member Avatar for Ene Uran

Here is an example: [php]import tarfile # uncompressed = "w" use extension .tar # gzip compressed = "w:gz" dito .tar.gz # bzip2 super compressed = "w:bz2" dito .tar.bz2 tar = tarfile.open("sample.tar.bz2", "w:bz2") # turn three regular files into a tar file archive for name in ["test1.py", "test2.py", "test3.py"]: tar.add(name) tar.close() …

Member Avatar for BearofNH
0
154
Member Avatar for curtshane

[QUOTE=curtshane;809036]how to fix a long pause or hang in windows start up process?[/QUOTE]How long is long? If it's less than 10 minutes, it's not unusual, particularly if your virus checker runs too.

Member Avatar for vegaseat
0
55
Member Avatar for dise652

[QUOTE=Lardmeister;805799]Japan is in a much worse economic crisis then the USA, so I guess their internet quality will suffer more.[/QUOTE]Interesting comment, I guess the internet infrastructure is dependent on each country's economy to a certain extent. I find it amazing how many folks think that the internet is just a …

Member Avatar for ahihihi...
-1
118
Member Avatar for vegaseat

Apparently the big collider will not be back in operation until late this year, but Hollywood has been busy making a film about it. A conspiracy film staring Tom Hanks to steal antimatter from CERN and to use it blow up the Holy City in Rome. [url]http://news.yahoo.com/s/nm/20090212/sc_nm/us_science_antimatter_3[/url] Holy Antimatter!

Member Avatar for sneekula
0
148
Member Avatar for gyu

Your code does not make much sense, but you could google for standard deviation and learn.

Member Avatar for vegaseat
0
86
Member Avatar for mruane

lines 18, 33, 48 for instance You don't need to declare globals outside the function, just inside the function that uses them. [code=python]def test_globals(): global gold # <-- this is needed for n in range(5): gold = gold + 15 print gold global gold # <-- this is not needed …

Member Avatar for vegaseat
0
93
Member Avatar for ITBarbie

PMW (Python megawidgets) is a toolkit for building high-level compound widgets in Python using the Tkinter. Things like selection widgets, paned widgets, scrolled widgets and dialog windows ... Free download from: sourceforge.net/projects/pmw/ for more info see: [url]http://pmw.sourceforge.net/[/url]

Member Avatar for leegeorg07
0
101

The End.