3,386 Posted Topics

Member Avatar for LastMitch

> people complained that the "favorite" forums it showed weren't where they wanted to go usually. How about putting selection boxes beside the forums member contribute in user page or similar thing in **EDIT PROFILE** and show only those?

Member Avatar for LastMitch
0
243
Member Avatar for zeusprog
Member Avatar for Jacklittle01

Still better, you can do that yourself, just read http://docs.python.org/tutorial/ first.

Member Avatar for Jacklittle01
0
137
Member Avatar for I_m_rude
Member Avatar for foodstamps

Hint, this guesses the spelling from sentence from keyboard: # replace the raw_input with your file read function s = ' '.join(correct(word) for word in words(raw_input('Give sentence: '))).capitalize()+'.' print s The function overfavors shorter words quite much so it suggests *day* for correcting *tday*, even *today* is more likely to …

Member Avatar for TrustyTony
0
330
Member Avatar for ryantroop

Something along the lines of http://code.google.com/p/perfmetrics/ for Windows or [iotop](http://www.serverwatch.com/tutorials/article.php/3859271/Monitoring-Disk-Usage-With-Iotop.htm) for Linux?

Member Avatar for ryantroop
0
99
Member Avatar for henry.sj.shin
Member Avatar for kwolfe

lines 8-12 are misindented, quotes are not allowed in IP addresses (FtpIP is also against the Python naming convention suggesting it is class, not variable): import ftplib import re with open("params.txt", "r") as param: for line in param: if re.match("(.*)IP(.*)", line): print ("" + re.sub('IP = ','',line)) FtpIP = re.sub('IP …

Member Avatar for snippsat
0
2K
Member Avatar for lukerobi
Member Avatar for SnHnBoLt

Take out .Keys()(it is .keys() but it is default for iteration) Variable name number is not logical for string.

Member Avatar for TrustyTony
0
353
Member Avatar for GrimJack

.... You notice that your mobile has 1000 times the storage of your first computer... And 10 times your university mainframes!

Member Avatar for vinnitro
1
3K
Member Avatar for StarscreamTim

You can put everything inside while True: loop, you may use break instead of exit then. Or you may move opposite of your exit condition as while condition.

Member Avatar for TrustyTony
0
165
Member Avatar for crag0

You searched Daniweb, didn't you? http://www.daniweb.com/software-development/python/code/216863/zip-and-unzip-an-archieve-of-files-python ,for example, did not help?

Member Avatar for crag0
0
1K
Member Avatar for hedwards

Also you can not use integer valued variable length as function like you are doing at line 12.

Member Avatar for hughesadam_87
0
180
Member Avatar for nchy13
Member Avatar for toyotajon93

I do not have android myself, but why not just use Android Scripting Environment and Python?

Member Avatar for M.S.
0
152
Member Avatar for maurya10
Member Avatar for alakaboom1

This much I got running, the gifs were missing so I had to replace them with something from myself. [CODE]import pygame, sys, os #Player Class, moves according to keyboard input class Player: #Player Constructor, takes arguments image and position def __init__(self, image, x, y): self.image= image self.xPos=x self.yPos=y self.dir=1 #Updates …

Member Avatar for jmorris1324
0
422
Member Avatar for TrustyTony

Here are instructions for voting for winner of the code snippet competition! http://www.daniweb.com/community-center/threads/429756/code-snippet-contest-...-cast-your-vote

Member Avatar for TrustyTony
0
207
Member Avatar for Twist43
Member Avatar for dwhite12

new.write('\n'.join(keep)).rstrip('\n') (or .lstrip if in beginning) instead of lines 18-23 ?

Member Avatar for dwhite12
0
215
Member Avatar for alex.ashton.58

Usually you would have more that one piece in list. Also you do not recreate object when you change it's position. Position would be more natural to be a (named)tuple or list also. For movement you usually need to check if Board position is unoccupied, so normally you should have …

Member Avatar for alex.ashton.58
0
199
Member Avatar for kudakwashe.kadzungura

You do not need to store the years, just do for loop after determining the last year you need to test and do function for [testing for leap year](http://en.wikipedia.org/wiki/Leap_year#Algorithm) you call inside the loop.

Member Avatar for np complete
0
120
Member Avatar for ryantroop

I do not want go give direct solutions, but here could be usefull one from my [100+ code snipets](http://www.daniweb.com/members/734700/pyTony/code/) : http://www.daniweb.com/software-development/python/code/321725/lowercase-word-generator That could give some ideas including the discussion of various methods.

Member Avatar for TrustyTony
0
155
Member Avatar for Jarreds
Member Avatar for glenford11
Member Avatar for glenford11
0
301
Member Avatar for matt.w.deakos
Member Avatar for TrustyTony
0
149
Member Avatar for rwe0

In Python strings are Unicode, and what you are talking about is encodings of bytes. Use bytes type and it is just bytes. If you want to encode them in utf8, do so explicitely. But for me that does not make sense as it is variable length encoding of all …

Member Avatar for rwe0
0
234
Member Avatar for I_m_rude

You just need to put next element in order to sorted data structure and drop biggest (k+1st) if size exceeds k. The answer is kth element if length is k, error otherwise (less than k values read)

Member Avatar for sfuo
0
146
Member Avatar for eternalcomplex

Python.org website is a great place for all kind of help, learn to use it: http://pypi.python.org/pypi/setuptools/

Member Avatar for G_S
0
353
Member Avatar for maurya10

What part of **Computer Science** your question is, looks like you posted C code here? I transfer your post to correct forum.

Member Avatar for Banfa
0
92
Member Avatar for rev_ollie
Member Avatar for rev_ollie
0
8K
Member Avatar for Niner710

You have your values and keys reversed, looks like. It is simple to reverse a dict however if the values are unique: data_reversed = dict((b,a) for a,b in dataDict.items())

Member Avatar for TrustyTony
0
171
Member Avatar for kuchi

> 'd\xc3\xb3\xc3\xb1ez What kind of encoding you are using, utf8, it would seem: >>> print 'd\xc3\xb3\xc3\xb1ez'.decode('utf8') dóñez >>>

Member Avatar for kuchi
0
143
Member Avatar for debbie.chen.946

words global variable has no value, main is never called (and name is misleading as it does nothing but sets local variables and exits.)

Member Avatar for woooee
0
237
Member Avatar for deepthought

Why should you want to print binary data as string, it is list of bytes, not characters > print ("received message:- ", data,addr) print("""received message:- %s from %s""" % (data,addr)) # produce same output in Python 2 as in Python 3

Member Avatar for TrustyTony
0
1K
Member Avatar for np complete

Most used term is maybe multi-precission numbers. Be sure not to forget first to test candidates with pseudoprime test like http://mathworld.wolfram.com/Rabin-MillerStrongPseudoprimeTest.html

Member Avatar for TrustyTony
0
243
Member Avatar for Frensi

Use dictionary of strengths. Your functions player and rat do nothing. import random player= dict( hp = 100, att = random.randint(10, 30)) enemy = dict( hp = 20, att = random.randint(5, 25) ) attack = player['att'] - enemy['hp'] print(enemy['hp'])

Member Avatar for TrustyTony
0
173
Member Avatar for I_m_rude

It makes no sense to optimize fibonacci when using only standard precicions, as you can precompute the lookup table and do lookup in O(1) from the table. 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765 10946 17711 28657 …

Member Avatar for I_m_rude
0
123
Member Avatar for Zeref

I think in GUIs generally you just set user timer event after 6 hours for update event and do nothing. No threads are needed.

Member Avatar for Zeref
0
318
Member Avatar for hughesadam_87

Second one is easier, the form without True is definately better in my opinion. The first condition with only returns I would actually use ternary condition: def test(val): return a if val > 10 else b else-less if I would usually use with condition that have not much connection to …

Member Avatar for sneekula
0
99
Member Avatar for deepthought

All code must be inside functions, except any code you want only run when running directly, which you can put inside if __name__ == '__main__':

Member Avatar for deepthought
0
162
Member Avatar for resmi sanker

See the http://www.genetic-programming.org/ Examples http://www.genetic-programming.org/combined.html

Member Avatar for TrustyTony
0
84
Member Avatar for SHASHWATH
Member Avatar for hughesadam_87

try except statement is usually considered most Pythonic , "ask for forgiveness, not permission" You could consider however using least efficient common way as default, which works both for mutable and immutable object. Then you could offer optimised version mutating the parameter. This could be good as natural way to …

Member Avatar for hughesadam_87
0
116
Member Avatar for rotten69
Member Avatar for TrustyTony

There was discussion thread http://www.daniweb.com/software-development/python/threads/424953/polynomial-division for class based implementation for polynomials, and I developed a version utilizing the magic methods to enable operation with normal arithmetic operation. I only inherited sequence structure from list type. Interoperability with scalar types is not implemented to avoid too complicated type checks of the …

Member Avatar for TrustyTony
1
1K
Member Avatar for Dani

As the rule was missing from the rules, I of course had to **check if it is possible** to vote yourself by trying it out, and it was. Even in my mobile I only saw the first two columns and did not vote for all categories due to that. I …

Member Avatar for TrustyTony
1
460
Member Avatar for sokolov

You would save movement status of each ball in Ball object itself, list or dictionary. Then you would have after event which you would set up to call the updating function for movement, say after 0.05 seconds.

Member Avatar for TrustyTony
0
1K
Member Avatar for hughesadam_87

>>> class NewClass(object): def __init__(self, **kwargs): self.__dict__.update(kwargs) def __repr__(self): return self.__class__.__name__ + ': '+ ', '.join('%s=%s'%(k, v) for (k,v) in self.__dict__.items()) >>> test=NewClass(a=1,b=2) >>> test NewClass: a=1, b=2

Member Avatar for hughesadam_87
0
184

The End.