4,305 Posted Topics
Re: 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] | |
Re: 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 … ![]() | |
Re: Or write and run your program using one of the many Python IDEs like IDLE or DrPython that have their own output window. | |
Re: 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 ... … | |
Re: 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! | |
Re: 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] | |
Re: 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 … | |
Re: 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] | |
Re: 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 """ … | |
Re: 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. | |
Re: Can you give us an example of your text and what you want to find/extract? | |
Re: Is it you against another human, or you against the computer? | |
Re: 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? | |
Re: 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 … | |
Re: Exploring the Natural Language Toolkit (NLTK) for Python sounds like a very interesting project! I will take a closer look at it. | |
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 … | |
Re: 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 … | |
Re: 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 … | |
Re: 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. | |
Re: Do yourself and the rest of us a favor and don't use tabs for indentations. | |
Re: 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) … | |
Re: 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), … | |
Re: 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. | |
Re: 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. | |
Re: 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 … | |
| |
Re: 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 … | |
Re: Not to mention that it would improve my looks by 88% or more. | |
Re: 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 … | |
Re: The amazing élan vital of other people! I must be very boring! | |
Re: 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. | |
Re: 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 … | |
Re: 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 … | |
Re: 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 | |
Re: 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 … | |
Re: See my note in post: [url]http://www.daniweb.com/forums/post815264-4.html[/url] | |
Re: See my note in post: [url]http://www.daniweb.com/forums/post815264-4.html[/url] | |
Re: Python is very much at home with Apple Computers. This could be a python file extension for Apple applications. Just my guess! | |
Re: 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' … | |
Re: 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?" … | |
Re: 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"). | |
Re: Just a note to jloyzaga, please do not use tabs for indents! Makes your code look rather nasty. | |
Re: 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() … | |
Re: [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. | |
Re: [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 … | |
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! | |
Re: Your code does not make much sense, but you could google for standard deviation and learn. | |
Re: 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 … | |
Re: 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] ![]() |
The End.