324 Posted Topics

Member Avatar for HiHe

I was exploring random art and modified this nice example from vegaseat: [code]# random circles in Tkinter # a left mouse double click will idle action for 5 seconds # modified vegaseat's code from: # http://www.daniweb.com/software-development/python/code/216626 import random as rn import time try: # Python2 import Tkinter as tk except …

Member Avatar for HiHe
0
18K
Member Avatar for Arbus

[B]Basic Instinct[/B] with Michael Douglas and Sharon Stone. Now that's a thriller!

Member Avatar for predator78
0
206
Member Avatar for Falcon25

Not all scientists are mad. The problem is that the general public is simply not interested in science.

Member Avatar for WolfShield
0
142
Member Avatar for skald89

I drink coffee to keep from falling asleep. Not sure what does it, probably the awful taste!

Member Avatar for oalee
0
183
Member Avatar for royng

Compared to a soldier's life, a students life is like going to Sunday School.

Member Avatar for HiHe
0
566
Member Avatar for HiHe

This works with Python 2.7 [code]class B: def __init__(self, arg): print(arg) class C(B): def __init___(self, arg): super(C, self).__init__(arg) c = C('abc') # abc [/code]Here super() gives a TypeError: must be type, not classobj [code]from math import pi class Circle: """with Python3 object is inherited automagically""" def __init__(self, r): self.r = …

Member Avatar for HiHe
0
282
Member Avatar for abelLazm
Member Avatar for HiHe
0
116
Member Avatar for sneekula

A massive galactic gamma ray burst would destroy all living organisms. Except for maybe some gold miners way down underground in South Africa.

Member Avatar for bumsfeld
2
935
Member Avatar for vmars
Member Avatar for terence193

Two ducks go on their honeymoon and stay in a hotel. As they are about to make love, the duckman says, ''Oh, we haven't got any condoms. I'll ring down to room service.'' So the duckman calls and asks for some condoms. The room service woman says, ''OK sir, would …

Member Avatar for vegaseat
0
885
Member Avatar for wolfeater017

To go one step further, the working folder is the folder/directory your working file (present program) is in. Run this little program: [code]# save this program as working.py import os # this will show the folder you saved working.py in print( os.getcwd() ) [/code]

Member Avatar for vegaseat
0
138
Member Avatar for mrnutty

[QUOTE=dvdreplication;1218852]Its not looks like a forum though but i am feeling comfortable with it, its working well. :)[/QUOTE]Isn't signature spamming fun? What kind of sticks and poor quality DVDs are you unloading on the naive public? Too bad the new design doesn't prevent that.

Member Avatar for jwenting
1
189
Member Avatar for Aeronobe

In your case page is a string. To make it a list of lines modify your code this way: [code] document = urllib2.urlopen(url,'r') page_lines = document.readlines() for index, line in enumerate(page_lines): print index [/code]

Member Avatar for Aeronobe
0
145
Member Avatar for quicktpgo

I envy those people to whom "Ignorance is bliss" has a real meaning!

Member Avatar for HiHe
0
123
Member Avatar for Kruptein
Member Avatar for HiHe
0
168
Member Avatar for xxxchopsakexxx
Member Avatar for nsutton
Member Avatar for vandalised

[QUOTE=vandalised;1219445]On that note i'm going to bed, that is really a slap hand on forehead moment (DOH). Its what you get for trying to learn programming at 3am eh? Cheers btw vegaseat[/QUOTE]Happens to the best of us!

Member Avatar for HiHe
0
108
Member Avatar for ultimatebuster

[QUOTE=ultimatebuster;1214796]Is this needed? [CODE] class Test: def __init__(self, f): self.f = open(f) def __del__(self): try: self.f.close() except: pass [/CODE] Also, how can i open a file, and have it in append mode. However, if the file doesn't exist, python creates it?[/QUOTE] Tha class approach is somewhat awkward, but you could …

Member Avatar for HiHe
0
132
Member Avatar for HiHe
0
9K
Member Avatar for HiHe

The small code shown below works fine with Python26, however Python31 gives an error: fout.write('.snd' + pack('>5L', 24, 8*dur, 2, 8000, 1)) TypeError: Can't convert 'bytes' object to str implicitly Does anyone know what I need to do to make it work with Python31? [code]# create a soundfile in AU …

0
79
Member Avatar for Dave Sinkula

If we would have voted for McCain, he would still not have realized that there is a recession going on. Might just be God's blessing.

Member Avatar for jephthah
0
6K
Member Avatar for happygeek
Member Avatar for HiHe

Airport screening simplified! Provide a booth that each person can step into, that will not X-ray the person, but will detonate any explosive device the person may have on him/her. There would be none of this crap about racial profiling and this method would eliminate a long and expensive trial.

Member Avatar for Lardmeister
0
147
Member Avatar for cwarn23
Member Avatar for HiHe

I am using Python 3.1.2 What is the best way to get numeric (float or int) user input?

Member Avatar for TrustyTony
0
4K
Member Avatar for HiHe
Member Avatar for HiHe
0
117
Member Avatar for mariosbikos
Member Avatar for yunmin
Member Avatar for deckchairboy
Member Avatar for aot

[QUOTE=Dan08;1164676]You did not specify what OS you're coding in, but [URL="http://www.daniweb.com/code/snippet230886.html"]this one[/URL] is to get the mouse position in Linux, and apparently in the same thread, Gribouillis gives an answer on how to do it in Windows as well. Also read vagaseat's post, which is interesting. Hope this helps.[/QUOTE]I think …

Member Avatar for Gribouillis
0
4K
Member Avatar for jeffery12109

[code]s = """Sign in an Irish pub: We are open from 10 a.m. until 11 p.m. and if you haven't had enough to drink at that hour the management feels that you haven't really been trying.""" fh = open("IrishSign.txt", "w") fh.write(s) fh.close() [/code]

Member Avatar for HiHe
0
101
Member Avatar for barabass

You could try something like this example: [code]# create a series of wx.StaticText() labels with a for loop import wx class MyFrame(wx.Frame): def __init__(self, parent, mytitle, pinto_beans): wx.Frame.__init__(self, parent, wx.ID_ANY, mytitle) self.SetBackgroundColour("blue") # use wx.GridSizer(rows, cols, vgap, hgap) for layout gsizer = wx.GridSizer(6, 1, 0, 0) # create a list …

Member Avatar for barabass
0
385
Member Avatar for Dan08

The Tkinter GUI toolkit widgets have a very homely look on Windows, the look improves with Linux and particularly the Mac OS.

Member Avatar for snippsat
0
124
Member Avatar for jeffery12109

When you call bloodXHealerZZ.buy(gold, arrows, whip, ...) you need to have a value for gold, arrows, whip, and so on.

Member Avatar for Stefano Mtangoo
0
215
Member Avatar for HiHe

Does anyone have a code example for using the mouse wheel with the Tkinter GUI toolkit handy?

Member Avatar for vegaseat
0
123
Member Avatar for Salem

Think about all those high paying jobs repairing and reprogramming robots.

Member Avatar for vegaseat
1
179
Member Avatar for lrh9

I understand that the "\r\n" or "\n\r" combination goes back to the old mechanical printers where you had to feed the paper up one line and set the carriage to the beginning margin. I guess this was the standard then.

Member Avatar for HiHe
0
174
Member Avatar for adam4u

[QUOTE=adam4u;1117916]I didn't understand on what you trying to say, but I'm leaving this problem for "[B][U]professionals people[/U][/B]"[/QUOTE]I would say you need professional help! Leaving your homework problem for others to do for you is cheating! You are cheating the teacher, your fellow students and actually yourself.

Member Avatar for HiHe
-3
171
Member Avatar for HiHe

When I run this code: [code]class C(object): print("Hello from inside class C") [/code]It gives the same result as if I had used this code: [code]print("Hello from inside class C") [/code]However when I use: [code]class B(object): def __init__(self): print("Hello from inside class B") [/code]The class behaves like I had expected. Does …

Member Avatar for HiHe
0
104
Member Avatar for mrnutty
Member Avatar for staufa

You could do it like that: [code=c]#include <stdio.h> #include <stdlib.h> #include <string.h> #define SIZE 50 int main(int argc, char *argv[]) { char string[SIZE], c; int i; // just a test printf("len = %d\n", strlen(string)); // len = 0 printf("Enter a string: "); for (i=0; i < SIZE; i++){ c = …

Member Avatar for cthoes
0
327
Member Avatar for caperjack
Member Avatar for HiHe

Does anyone use Python on a Windows7 machine? What is your experience? Does it work well? I am thinking about getting a new computer and also start some Python programming.

Member Avatar for mn_kthompson
0
112
Member Avatar for saikeraku

Vagaseat, I tested your code and actually you can just add the two lists this way ... [code=python]def add_lists(a, b): """add lists a and b without changing list a""" return a + b a = ['a', 'b', 'c'] b = [1, 2, 3] c = add_lists(a, b) print( a ) …

Member Avatar for saikeraku
0
92
Member Avatar for ffs82defxp

I think you are talking about function calls. You really don't need to clear the console screen, besides it is too OS specific. Most programmers will tell you that goto is a bad habit. Design your program so that you don't need goto.

Member Avatar for snippsat
0
121
Member Avatar for Mensa180

If you are familiar with C and its printf() function then you can use %s for strings and %0.2f for floats with 2 decimals. In Python like in Ruby you can use %s also for unformatted numbers. In Ruby (much like C): [code=C]printf( "Number: %5.2f, String: %s\n", 1.23456, "hello" ) …

Member Avatar for Mensa180
1
343
Member Avatar for linux
Member Avatar for unsure

Sounds familiar, but you have to realize that instructors are there to teach some outdated computer language with ever so failing enthusiasm.

Member Avatar for johnvitc
0
46
Member Avatar for chrisamangole

Good productivity with the c programming language and c++! These are the most active language forums here in Daniweb. Hope to see you there.

Member Avatar for johnvitc
0
159

The End.