- Strength to Increase Rep
- +15
- Strength to Decrease Rep
- -3
- Upvotes Received
- 337
- Posts with Upvotes
- 256
- Upvoting Members
- 105
- Downvotes Received
- 19
- Posts with Downvotes
- 19
- Downvoting Members
- 13
- Interests
- Guns, target/sharp shooting, martial arts, hunting, cooking
1,175 Posted Topics
Re: I would avoid using the Python shell to write multiline programs. Use one of the Python editors like IDLE, wirte your program, save it and run it. This would have given you an error message like: NameError: name 'timesflipped' is not defined Using FengG's advice your program should look like … | |
Re: Some cause happiness wherever they go; others, whenever they go. -- Oscar Wilde | |
Re: A kumquat and huckleberry combo with holy water. | |
Re: According to my engineering professor, the reason there is a variety of computer languages is that each language (at least the popular once) was written for a purpose. Python was not written to make Operating Systems, but C was (for Unix). So it would be a little silly to use … | |
Re: Probably the easiest way to do this is to use the local variable dictionary vars() to create new variables on the fly: [code=python]food = 'bread' vars()[food] = 123 print bread # --> 123 [/code]You can print out vars() to see what's going on. | |
Re: Looking at main.py this program is a nightmare of imports. https://github.com/PicciMario/iPhone-Backup-Analyzer-2/blob/master/main.py | |
Re: Go to: [url]http://www.daniweb.com/code/c.html[/url] and search for: image | |
Re: The American News Media can only handle three major events at a time. | |
Re: Try this: ''' wxBoxSizer101.py button1 at upper right corner button2 at lower right corner ''' import wx class MyFrame(wx.Frame): def __init__(self, parent, mytitle, mysize): wx.Frame.__init__(self, parent, wx.ID_ANY, mytitle, size=mysize) self.create_widgets() def create_widgets(self): self.button1 = wx.Button(self, wx.ID_ANY, label='Button1') self.button2 = wx.Button(self, wx.ID_ANY, label='Button2') # use a box sizer to lay out … | |
Re: A simple timing example: import time def print_timing(func): """ a decorator function to time another function time.clock() works on Windows systems only you can use time.time() instead, but it gets updated less frequently and can give 0.0 results on faster functions """ def inner(*arg): """*arg are the arguments of function … | |
Re: wxMediaCtrl uses native backends to render media, for example on Windows there is a ActiveMovie/DirectShow backend, and on Macintosh there is a QuickTime backend backend options:. wx.MEDIABACKEND_GSTREAMER for linux/unix wx.MEDIABACKEND_QUICKTIME for Mac | |
Re: How do you get a sweet little 80-year-old lady to say the F word? Get another sweet little 80-year-old lady to yell “BINGO!” | |
Re: Put the code between code tags. Read the lightgray message in the background of the Quick Reply field below. Or read: [url]http://www.daniweb.com/forums/announcement114-3.html[/url] | |
Re: The function sqrt(x) returns a float: [code=python]import math x = 9 y = math.sqrt(x) print y, type(y) # 3.0 <type 'float'> [/code]If you want the result to be an integer use int(y). | |
In the last couple of threads people have used the Python class, but really don't seem to know how to use them properly, or why to use them. Hence my question: "Why would you use a class in Python?" I though only Java forces you to use OOP. | |
Re: I think it's just style. | |
Re: Import the module shutil, it has functions for copying and moving files, copying whole directory trees, deleting directory trees and more. | |
Re: Predict the outcome of this Python code: [code=python]def sub_one(x): print "x before if -->", x if x > 1: x = x - 1 sub_one(x) print "x after if -->", x return x x = 5 final = sub_one(x) print "final result -->", final [/code]Can you explain the odd behaviour? | |
Re: Each king in a deck of playing cards represents a great king from history: Spades --> King David Clubs --> Alexander the Great Hearts --> Charlemagne Diamonds --> Julius Caesar | |
I got infected right after a Java and Adobe update on my Windows7 machine. folder \jnihmpibahpjjmcodbopcpdaelkbpjnc is most likely a random generated folder. Note on malware **PriceLess** (pops up as Chrome extension, highlights strings for ads): PriceLess is in folders: C:\Users\HomeGroupUser$\AppData\Local\Chromatic Browser\User Data\Default\Extensions\jnihmpibahpjjmcodbopcpdaelkbpjnc\5.2 C:\Users\HomeGroupUser$\AppData\Local\Comodo\Dragon\User Data\Default\Extensions\jnihmpibahpjjmcodbopcpdaelkbpjnc\5.2 C:\Users\HomeGroupUser$\AppData\Local\Google\Chrome\User Data\Default\Extensions\jnihmpibahpjjmcodbopcpdaelkbpjnc\5.2 C:\Users\HomeGroupUser$\AppData\Local\Google\Chrome SxS\User Data\Default\Extensions\jnihmpibahpjjmcodbopcpdaelkbpjnc\5.2 … | |
Re: In my book the only thing that lives on is meaningful communication you made with people that survive you. | |
Re: Here is a comparison of some common Python GUI toolkits. These were created on my Ubuntu/Linux machine, because I could never get PyGTK to go on my Windows Vista machine. I followed the installation routine carefully, but there was always a dll missing, or an entry point wasn't found, or … | |
| |
Re: There is also an error in line 12. Since you are not running Python3 but Python2 tkinter should be Tkinter | |
Re: According to Einstein the Sun uses up more and more matter, its gravitational pull should lessen and the Earth should move further away. | |
Re: Give us a short example of what your project data looks like. | |
Re: There might be a Persian version of Python. | |
Re: Normally you build a house from the bottom up. Try to understand the basics of Python first and put the windows in later. | |
Re: @ivel I looked at the code you have written and at NathanOliver's helpful suggestions. I came to the conclusion that you need beginner's help. I took your code and corrected it, please study it: /* modulus_exercise101.cpp Write a program that counts the numbers from 3 to 117. For multiples of … | |
Re: What operating system are you using? | |
Re: Try: def message(): print('Good morning') from Tkinter import * tk = Tk() message() tk.mainloop() | |
Re: Avoid using Python function names like **list** for variable names. if you use list = [1, 2, 3] and later abc_list = list('abc') it won't work! | |
Re: Hmm: ''' str_find_sub_index.py explore s.find(sub[ ,start[,end]]) returns index or -1 ''' text = "trans panamanian bananas" sub = "an" start = 0 count = 0 while True: ix = text.find(sub, start) if ix < 0: break # move up start in function find() start = ix + 1 count += … | |
Re: I would use **with**, it closes your files properly. Also use a protocol for larger files: import pickle fname = "films.db" with open(fname, "wb") as fout: # default protocol is zero # -1 gives highest prototcol and smallest data file size pickle.dump(favorite_movies, fout, protocol=-1) # pickle load the object back … | |
Re: Just a little faster than isprime2(): def isprime5(n): if n == 2 or n == 3: return True if n < 2 or n%2 == 0: return False if n < 9: return True if n%3 == 0: return False sqr = int(n**0.5) f = 5 while f <= sqr: … | |
You can accesss the clipboard simply by using the Tkinter GUI toolkit that comes with your Python installation. | |
Re: The elegant thing about the **while True** loop is that you can break at a given point between statements. | |
Re: Something like that: // removes the third bit, simple way to create upper case char char toupper(char ch) { return ch & 0xDF; } Sorry doesn't handle numbers etc. | |
Re: I wish Hollywood could come up something better than endless sequels. | |
Re: Here you go: s = "happy Hello World!" print(s) print(s.capitalize()) print(" ".join(w.capitalize() for w in s.split())) print(s.lower()) print(s.upper()) print(s.swapcase()) ''' my result --> happy Hello World! Happy hello world! Happy Hello World! happy hello world! HAPPY HELLO WORLD! HAPPY hELLO wORLD! ''' | |
I have a Toshiba Satellite notebook with Windows7 OS. How would I go about it to replace Windows7 with Kubuntu? | |
Re: If you saved your file as hello.py somewhere Python looks for, do this from the shell: >>> import hello >>> hello.thefunc() | |
On Windows7 I am trying to read file C:\programdata\microsoft\application virtualization client\SoftGrid Client\sftfs.fsd using a Python program, but I get a PermissionError. How do I get permission? Why does folder programdata not show in the Microsoft file manager/explorer? | |
Re: Nicely explained in: http://www.tutorialspoint.com/python/python_for_loop.htm | |
Re: Assume the individual data has to come from the user via cin. | |
| |
On my Raspberry Pi computer I did a search for PIL and matplotlib with apt-cache search python but could not find anything close in the list. Is PIL/Pillow and matplotlib available for Linux and what is it called? The Raspberry Pi has Python27 and Python32 installed. | |
The End.