Posts
 
Reputation
Joined
Last Seen
Ranked #288
Strength to Increase Rep
+9
Strength to Decrease Rep
-2
97% Quality Score
Upvotes Received
44
Posts with Upvotes
36
Upvoting Members
22
Downvotes Received
1
Posts with Downvotes
1
Downvoting Members
1
19 Commented Posts
5 Endorsements
Ranked #341
Ranked #284
~192.27K People Reached
Favorite Forums
Favorite Tags

169 Posted Topics

Member Avatar for amrutraj

Problem is, there's no way to know "when the internet is disconnected" ahead of time. You might be able to get to 99.99% of all websites but can't get to the one you're trying at the moment. Is "the internet disconnected" in that case? What if it's the other way …

Member Avatar for musawir_2
0
293
Member Avatar for aaron.breen.50

You would want something like this: for t in range(120,-1,-1): minutes = t / 60 seconds = t % 60 print "%d:%2d" % (minutes,seconds) # Python v2 only time.sleep(1.0) ... but that just prints out the time left. If you're supposed to put the time in a separate window, well, …

Member Avatar for rproffitt
0
8K
Member Avatar for vegaseat

I don't see much here on generators. They are a nice feature of Python that everyone should know. Generators are neat ways of doing certain things that involve iterative work. For example, instead of calling a fibonacci function to return fibonacci numbers in a list (say), we create a [I]generator …

Member Avatar for vegaseat
23
34K
Member Avatar for Shaji_1

Good suggestion rr, but I think that just capitalizes the first word of each line. Instead of `readlines()` you want `readwords()`, except that doesn't exist. I think judicious use of `split()` is in order, and remember each line will end with `\n` so you'll want to be sure to delete …

Member Avatar for TrustyTony
0
307
Member Avatar for Miyuki

You could start with this and maybe clean it up a bit. [code=Python] import struct import sys blocksize = 0x2000 errstart = 0 # File offset of start of error span errend = 0 # File offset just past end of error span diffct = 0 # Difference region count …

Member Avatar for Jack_9
0
531
Member Avatar for iuessele

I use 'T' instead of '10', but you can change this as needed[code=Python]import random rank = random.choice( ('A','2','3','4','5','6','7','8','9','T','J','Q','K') ) suit = random.choice( ('c','d','h','s') ) card = rank + suit print card # or print(card) for Python >= 2.6[/code]

Member Avatar for alexander.selin.7
0
13K
Member Avatar for akerman

I would use numpy and represent the matrix as an ARRAY datatype. Additionally, I'd look around numpy to see if somebody has already solved your problem. If not, please submit your solution when you got it working.

Member Avatar for BearofNH
0
163
Member Avatar for MrNoobieCoder
Member Avatar for Kai_Chang
0
6K
Member Avatar for bnn678
Member Avatar for tony75

Have you got a server listening on port 25? This is not the Windows default configuration. (>netstat -aon). It's easy enuf to write your own mail server that just looks for connects, accepts them, and logs appropriate data.

Member Avatar for tony75
0
1K
Member Avatar for marium.aslam.18
Member Avatar for SumTingWong59

Your example probably doesn't handle the case `L<W`, though that's a simple fix. I don't think I know what a tray is. If you hand me a 6-inch square of cardboard and a pair of scissors, I would cut out a 1-inch by 1-inch square at each of the 4 …

Member Avatar for SumTingWong59
0
148
Member Avatar for Guillermo_1

Why is line 11 (`for col...`) there? Shouldn't you just iterate over all the rows? Notice you don't use `col` anywhere in the program. I think `caca` ends up being a list of all the cell values in row `i`. In which case, after line 13, you would want something …

Member Avatar for BearofNH
0
186
Member Avatar for speen

Also, range(0,255) will only create a 255-entry list. If you want all 256 entries, indexed 0 to 255, use range(256).

Member Avatar for speen
0
247
Member Avatar for turbo22
Member Avatar for BearofNH
0
1K
Member Avatar for johnny_disco
Member Avatar for BearofNH
0
227
Member Avatar for robert99x

An `or` operation is evaluated left-to-right. In this case, if `self.getopt('-v')` returns 1 then the user entered `-v` on the command line, in which case we set self.verbose to `True` and ***go on to the next statement***. If there was no `-v` on the command line, we evaluate the second …

Member Avatar for robert99x
0
293
Member Avatar for John_47

> The integral rapidly becomes negligible if x is large so i understand you would simply use the limits of -5 to 5 to calculate this integral. However, i'm still unsure of how to do this. Unless I'm mistaken, I think you can fix this by inserting between line 11 …

Member Avatar for John_47
0
218
Member Avatar for HiHe

After a while you get used to using tuples where feasible. For instance, I've just written a program to generate an image with alternating yellow and pink (!) stripes. First lines of code were: yellow = (244, 244, 0, 255) pink = (255, 142, 200, 255) (for R,G,B,Alpha). Why choose …

Member Avatar for vegaseat
0
684
Member Avatar for glez_b

You didn't tell us what was in the DirViento column. I sincerely hope you are not trying to convert a temperature value in degrees to a temperature value in radians...

Member Avatar for glez_b
0
3K
Member Avatar for matthew.s.thomas.14
Member Avatar for matthew.s.thomas.14
Member Avatar for BearofNH
0
384
Member Avatar for Subhradeep

I've done this sort of stuff before. To answer your second question, here's a code sub-snippet: import copy import Image import numpy as np img = Image.open('E:\\JCH\\Snap.jpg') newx = img.size[0] newy = img.size[1] # Image is (newx,newy) pixels imga = np.asarray(img) # This is the secret; convert img to array …

Member Avatar for Gribouillis
0
2K
Member Avatar for bright.silva

> not_lapped= True """used to test if there was no lapping""" I don't see how this can work. You should be writing: not_lapped= True # used to test if there was no lapping > """this was the best i could come out with but didnt solve the problem""" You should …

Member Avatar for bright.silva
0
272
Member Avatar for hmx7

> I have no idea what to do. The underlying calculations are pretty simple but I myself am confused about what the other stuff means. You almost have to RTTM (Read The Teacher's Mind). For example: > ... For your demo, calculate the GPA to 2 decimal places for these …

Member Avatar for hmx7
0
790
Member Avatar for vegaseat

> Now here is a brain teaser, list all the states that joined the Union after 1865 Add the following to the end: print('-'*35) print("US states admitted after 1865:") for state in instance_list: if int(state.date[-4:]) > 1865: print("{:15} {}".format(state.state, state.date[-4:])) Works for me ...

Member Avatar for vegaseat
2
681
Member Avatar for farmwife

I don't know how others are faring here, but every time I try to post something I get an error message complaining my code is improperly formatted. Even if it's all comments! After which I'm often no longer able to type into the editing box. Something is clearly hosed. Is …

Member Avatar for vegaseat
0
218
Member Avatar for Jacklittle01

Well, pickle.dump() should have no problem saving a variable, as in `pickle.dump(variable,f)`. Now if pickle doesn't like that it will raise an exception, but I suspect if you just try it will work fine...based on pickle.dumps() working on a test case I just tried. You will probably find your real …

Member Avatar for Gribouillis
0
248
Member Avatar for vegaseat

> However, > print float('0x123abc') > does not work Isn't this a bug in Python?

Member Avatar for BearofNH
1
2K
Member Avatar for حسن_3

I'm a little curious about the control work starting at line 40 above. When you get a pygame.QUIT event, setting done=True doesn't automagically exit the loop...you just fall thru to the next set of code. It doesn't look like you should. Howzabout using **break** instead? Speaking of which, shouldn't the …

Member Avatar for حسن_3
0
315
Member Avatar for Turo1
Member Avatar for OurNation

You get back 23 Hooters T-shirts (one for the coach). I put in some beer and onion rings ...

Member Avatar for vinnitro
1
16K
Member Avatar for Edwards8
Member Avatar for jvangeld
0
310
Member Avatar for aot

Not to be overly pedantic, but in your example the problem is not in [B]time.sleep()[/B] but rather the [B]while True[/B] that never exits the loop. Your routine [B]checkSomething()[/B] is getting called every 0.1 seconds, but not saying the loop is over. Per demetrio, threading is probably what you need. Or, …

Member Avatar for txfoo
0
1K
Member Avatar for sarfrazashfaq
Member Avatar for dragon_sagrado

PMJI, but is the problem one of finding the Taylor series for sin(x+1), instead of using the Taylor series for sin(x)? Ask Wolfram Alpha for [b]taylor series sin (x+1)[/b] and it will tell you roughly: sin(x+1) = sin(1) + x*cos(1) - 1/2 * x^2 * sin(1) - 1/6 * x^3 …

Member Avatar for BearofNH
0
233
Member Avatar for jpaulsen

[QUOTE=;][/QUOTE] Maybe try something a little simpler. Limit yourself to things inside your house. Make a list of 100 or so items. Then figure out which questions lead to which objects. If every question has a 'y' or 'n' response, what you want is a sequence of y and n …

Member Avatar for woooee
0
157
Member Avatar for vbx_wx

[QUOTE=;][/QUOTE] Surely you mean "Dexter laboratory" is on at 10:30. Convert from HH:MM to pure minutes. Find the first entry which is in the future (which is Cow & Chicken) and select the one before that. Unless it's the first entry (as if you typed in 8:45) in which case …

Member Avatar for richieking
0
85
Member Avatar for mcenley

Just a guess; I don't know Turtles, but it seems to me you should move the [ICODE]t=turtle()[/ICODE] line from inside Koch() and do it separately. Otherwise you get a new turtle() instance every time you re-enter Koch(). Replace [CODE=Python]Koch("bob",540)[/CODE] with [CODE=Python]t=turtle() # And remove from inside Koch() t.delay=0.01 # And …

Member Avatar for vegaseat
0
3K
Member Avatar for Prachu

Have you looked at popen2? It's documented in the Python run-time library manual and I'm sure google will show lots of examples.

Member Avatar for changtraidoc
0
2K
Member Avatar for FreezeBlink

I have done this on occasion. The easiest way to do this is have your __init__() routine append [B]self[/B] to a list. If it's not "your" class I suppose you could override the __init__ method of the class. Fortunately I never had to worry about deletes...

Member Avatar for Gribouillis
0
576
Member Avatar for aint

[I]I checked out matplotlib, which is a bit complicated for me.[/I] Hey, the first time is always complicated but in reality matplotlib is fairly easy to use. The problem is picking [B]what[/B] to use. Herewith an example more or less like the chart you want, in under 50 lines of …

Member Avatar for TrustyTony
1
414
Member Avatar for newharvar

While ctypes is a good thing to know, it will not by itself solve all your problems. To call Windows you will need something like the pywin32 package. Are you aware of this? (Your post makes no reference to it).

Member Avatar for Tech B
0
192
Member Avatar for kfancy

[QUOTE] elif 2 <= self.rank <= 10: self.rank = str(self.rank) self.value = self.rank [/QUOTE] In LINE 20 you set [ICODE]self.rank[/ICODE] to a string, then assigned that same string to [ICODE]self.value[/ICODE]. Hence the error. You really are trying to add a string to an integer. Incidentally, I suggest avoiding the use …

Member Avatar for redyugi
0
178
Member Avatar for rjmiller

Go, Wildcats! When posting code you should wrap it around [B]code=Python[/B] and [B]/code[/B] tags, thusly: [code=Python] from scipy import * from numpy import * def Radiograph_data: try: file('c:/users/ross/desktop/radiograph_data.txt') #checks desktop for file except IOerror, e: e = urlopen('http://www.u.arizona.edu/~erdmann/mse350/radiograph_data.txt') #downloads file from internet data = numpy.loadtxt(e, dtype = float32, comments = …

Member Avatar for pythopian
0
216
Member Avatar for Darkangelchick

I too suggest the use of % to check for zero remainder, avoiding floating point in this problem. A nit on operators: when you want integer-style division, discarding any remainder, the proper operator is [ICODE]//[/ICODE] not [ICODE]/[/ICODE]. As in: [ICODE]l.append(n//i) [/ICODE]. In this particular case you already know the results …

Member Avatar for Progressivism
0
145
Member Avatar for gabec94

This will get you started, but there are many things you need to consider beyond the core function.[code=Python]def password_input(prompt, pw): while True: # Forever data = raw_input(prompt) if data == pw: return [/code]The key routine raw_input() is no longer recommended, but I've forgotten the replacement riff.

Member Avatar for Flameass
0
119
Member Avatar for snowfish

I noticed you have defined [ICODE]receive()[/ICODE]twice. This means the first definition is discarded and only the second one counts. Do you need [ICODE]receive()[/ICODE]at all? It depends on what you're doing. Normally you'd do a connect() then exchange many (possibly very many) messages via send() / recv(), then close() when all …

Member Avatar for snowfish
0
388
Member Avatar for EAnder

[QUOTE=vegaseat;821968][...] but since there is no Python assembler it's just an analytical tool.[/QUOTE] Some people might look at that and think [B]opportunity![/B] Google Summer of Code is coming up. Can daniweb.com be a mentoring organization?

Member Avatar for EAnder
0
194
Member Avatar for crumpet

The End.