3,386 Posted Topics

Member Avatar for pwolf

You should assign value of c first not last in if statement: [CODE]'Exercise 7.3' # modified program from exercise 7.2 print "press <Enter> to Exit!" while True: x_str = raw_input('Enter Start, [Stop], [Increment]: ') if not x_str: print "Exit Requested" break else: x_str_array = x_str.split(',') # splits the string where …

Member Avatar for pwolf
0
173
Member Avatar for Cenchrus
Member Avatar for pwolf
Member Avatar for Pythonbeginner!

Can you explain what you mean by string of integers (bytes? memoryview?) Also you must explain what you have tried to do and how the result differed from your expectations to show proper effort.

Member Avatar for TrustyTony
0
169
Member Avatar for scsi

I will check, did not catch the logic first. not the way I would program it. Does not look idiomatic Python. Not at computer at the moment. Print statements are useful to see what happens: [CODE]def num_even_digits(n): numeven = 0 while n: temp = n / 10 if (n - …

Member Avatar for TrustyTony
0
151
Member Avatar for lrh9

I have not used Abstract Base Classes until now, but this is about how I think I would organize your functionality (can not test without usage examples, seems to give syntax error in Python 2.7 but not in 3.2.2): [CODE]import abc import collections import math import weakref class AbstractNeuron(metaclass=abc.ABCMeta): def …

Member Avatar for TrustyTony
0
206
Member Avatar for sun_2588

[url]http://www.daniweb.com/software-development/python/code/280071[/url] is my snippet for email form. But you can easily adapt it to ip number check.

Member Avatar for TrustyTony
0
309
Member Avatar for natehome
Member Avatar for natehome
0
1K
Member Avatar for amir1990
Member Avatar for amir1990
0
82
Member Avatar for chris99
Member Avatar for RLS0812

Maybe this example helps. For this purpose I always use list comprehentions. Do not use n*[some_list] as it produces references to same list, not independent lists. [CODE]# pretty module from my code snippet in Daniweb: # http://www.daniweb.com/software-development/python/code/345935 import pretty def get_by_iter(data, iterable): # access data by single iterable instead of …

Member Avatar for TrustyTony
0
209
Member Avatar for TrustyTony

Got inspired to make computer to make moves in English Solitaire, I learned in childhood days to solve by myself consistently, no solving or game play interface at the moment (easy to add though). I added printing of the ready solution from the wikipedia, also maybe of your interest are …

0
349
Member Avatar for zekish

As I see, you are not getting any use out of your recursion, no modified self variables or using a return value from recursion (and actually no returned value in any case). And you should have one stack to keep saved states not new each time or I do not …

Member Avatar for zekish
0
1K
Member Avatar for mishabi

edge detection? Or find first black pixels and see if it is corner, use it to choose between alternatives starting with 1 or starting with 0. I think you do not give full info, for example there must be some background also.

Member Avatar for TrustyTony
0
117
Member Avatar for Catweazle

[QUOTE=;][/QUOTE] Only the first link of original post is working: [url]http://www.daniweb.com/techtalkforums/faq.php?[/url] Start new thread with updated information and remove sticky from old post?

Member Avatar for WaltP
3
1K
Member Avatar for Natsu

Do function like: [CODE]>>> def change(ind, info): return '<p>%(ind)i: <a href="%(info)s" target="blank">%(info)s</a></p>' % locals() >>> change(1, 'www.google.com') '<p>1: <a href="www.google.com" target="blank">www.google.com</a></p>' [/CODE]

Member Avatar for TrustyTony
0
171
Member Avatar for natehome

[CODE]import sys, random, time, pygame, os, threading #where you are using threading etc from pygame.locals import * ### for example this ## do not produce list and run linear search from long range if mouse_down_x in range(420,470) and mouse_down_y in range(70, 120) and hunger[2] > 20 and hunger[3] == 1: …

Member Avatar for natehome
0
293
Member Avatar for jackbauer24

break command is used to exit the current for or while statement from middle of loop.

Member Avatar for Gribouillis
0
337
Member Avatar for eoop.org

Candidates in that Narue's suggestion could include languages Python, Ruby, Prolog, Lisp/Scheme, J, Forth, Icon, Haskel,[URL="http://www.muppetlabs.com/~breadbox/bf/"] Brainf.[/URL].. ;)

Member Avatar for radc
0
324
Member Avatar for Findlebot

This maze program seems to work without the listing of all locations. Nice hack to initialize many variables with chars this [ICODE]OPEN, WALL, START, END, SEEN, GOOD = tuple(' #SE!0')[/ICODE] Here is alternative algorithm finding the road through maze. Actually it is originally logic to move ball in Lines game, …

Member Avatar for 0x69
0
3K
Member Avatar for glao
Member Avatar for glao
0
4K
Member Avatar for Tcll

I have only basic skills in C/C++, and do not know where you can get more help on that, but I am ready to help you make your final Python code nicer, of course the docstring stuff you should do yourself well as well as naming of the variables. Prepare …

Member Avatar for Tcll
0
445
Member Avatar for phorce

I happened to Google around for graphics and Prolog recently and got jealous of Mac people as [URL="http://xgp.sourceforge.net/"]XGP[/URL] seems to only support Cocoa interface. I myself learned Prolog with [URL="http://www.amazon.com/Art-Prolog-Second-Programming-Techniques/dp/0262193388"]Shapiro's book[/URL] and consider it quite a respectable job.

Member Avatar for phorce
0
397
Member Avatar for Ares08

basic framework for this kind of thing is normally something like [CODE]sep = '=' with open('myfile.txt') as filein: for line in filein: record = line.strip().split(sep) #process records fields[/CODE]

Member Avatar for woooee
0
156
Member Avatar for oli82

Use split with second argument 1 or partition. [CODE]>>> "Sarah me hy uuuuu".split(" ", 1) ['Sarah', 'me hy uuuuu'] >>> "Sarah me hy uuuuu".split(None, 1) ['Sarah', 'me hy uuuuu'] >>> "Sarah me hy uuuuu".partition(' ') ('Sarah', ' ', 'me hy uuuuu') >>> [/CODE]

Member Avatar for oli82
0
2K
Member Avatar for Jean Declaix

Please use code tags not color tags. I do not know what the program is supposed to do (for example you are calling class method at line 41 in ping, there is not reconfigure method) you must pass the object to function (it could event be method in App, I …

Member Avatar for Jean Declaix
0
251
Member Avatar for hovestar

counter has not local parameter or variable named value. It is local because it is used at left side of assignement in function. You probably should have the variable as parameter of recusive function counter. You will hit the limit of recursion pretty soon so you better use regular loop.

Member Avatar for TrustyTony
0
250
Member Avatar for hszforu

[CODE]for number in range(int(raw_input('How many? '))): open("%2i.txt" % number, 'w').close()[/CODE]or input if you use Python 3 produce more sensible 01txt etc number files. If you want different length names not in number order leave out the 2 length from format string.

Member Avatar for TrustyTony
0
173
Member Avatar for sabbib
Member Avatar for pythonstudent11

Your next job seems to be to learn about sequences like lists and tuples and replacing if..elif..elif... with dictionaries.

Member Avatar for pythonstudent11
0
426
Member Avatar for Daman824

If user enters negative numbers you discount them from total, is this correct? Use better names whuch are all self explanatory.

Member Avatar for Daman824
0
161
Member Avatar for jacob501

Did you check the content of mechanize.py in documents directory? Looks strange directory name for installing a module. In IDLE there is even special menu option for opening module in file menu.

Member Avatar for jacob501
0
1K
Member Avatar for C0deM0nkey

difference is uninitialized from alternatives '1' and '2', do you mean it to be indented inside branch for '3'?

Member Avatar for C0deM0nkey
0
245
Member Avatar for TrustyTony

This code is based on code from series of programs [URL="http://www.ferg.org/thinking_in_tkinter/"]'Thinking in tkinter'[/URL] This code is not perfect, especially it does not recognize key release when mouse moves out of button area during push. Leave event could also be captured for that to stop the event in that case.

0
499
Member Avatar for Koreakid101

Do not repeat code but use loop and argument with value from notelist by functools.partial. This code wont run as you have place holder functions without any statements, add pass statement. Record/Stop should be toggle switch changing the self.recording between True and False. Add self.recording check into play function. You …

Member Avatar for TrustyTony
0
9K
Member Avatar for jimmy19

why you should use object hierarchy? Tell the reason for the code. The form looks fitting for recursive algorithm if you realy must do it this way. The names are not unique look for example doc directories or readme files.

Member Avatar for TrustyTony
0
215
Member Avatar for Ismatus3
Member Avatar for veelasong
Member Avatar for veelasong
0
418
Member Avatar for pythonstudent11

You are not passing the line to your function and common idiom for inputting lines from file is: [CODE]with open('myfile.txt') as infile: for line in infile: #processing it[/CODE] time is not recommended name for variable name as it is standard library module name.

Member Avatar for pythonstudent11
0
333
Member Avatar for Lemony Lime
Member Avatar for Jaxyn

The dictionary is undefined. Here in DaniWeb you must but [CODE] and same with / before CODE as tags not simple square brackets. Like this: ['scarcity', 'scarce', '[A],', 'ity', '[N|A]', '[N]'] scarcity scarce [A], ity [N|A] [N] scarcity [A], ['sweet', ','] sweet , Traceback (most recent call last): File "final3.py", …

Member Avatar for Jaxyn
0
299
Member Avatar for sofia85

Still with this? :( [CODE]data = """prob=0.0093;ID=RGT430;BQRS=491;BRZ=-4.263;ID2=RT914;DRT=0.00;HRun=0;HaplotypeScore=0.2794; prob=0.003;ID=RGR301;BQRS=4;BRZ=-3.261;ID2=EV913;DRT=0.00;HRun=0;HaplotypeScore=0.2654; ....etcetc until last row: prob=0.345.""" def prob(line): if 'prob=' in line: line = line.split('prob=', 1)[1].rstrip('.') return float(line.split(';', 1)[0]) for line in data.splitlines(): pr = prob(line) if pr is not None: print(pr) [/CODE]

Member Avatar for sofia85
0
136
Member Avatar for AndresOend

[url]http://docs.python.org/copyright.html[/url] also you can type copyright at Python command prompt.

Member Avatar for TrustyTony
0
262
Member Avatar for jacob501

Your code is just doing so stupid things like redefining 25 times in loop (and two unnecessary imports still), and you have got your basic code from Gribouillis, so we would really appreciate some honest efforts.

Member Avatar for Ezzaral
0
313
Member Avatar for Huntersknoll

Looks quite nice but line 2 (overwriten by for) and last three lines does not make sense to me. i have written code snippet for producing lowercased words from file, check it out from code snippet archive

Member Avatar for TrustyTony
0
190
Member Avatar for Nevicar

Your code looked too difficult for me to understand, so I cut it to bare essentials. I did however get buttons to appear in current turns rows with buttons and I put in pygame.quit() for clean finish with also Q and escape. However, I never coded in PyGame my own …

Member Avatar for TrustyTony
0
287
Member Avatar for seek

Your indention is in unsupported format ;) CODE tags, please. This kind of condition for example is allways True: if hour >= 1 or hour <= 60: unlike for example this if 1 <= hour <= 60:

Member Avatar for vegaseat
0
223
Member Avatar for AdampskiB

No, Python way is known as "Ask for forgiveness, not permission". See for example my snippet: [url]http://www.daniweb.com/software-development/python/code/364647[/url]

Member Avatar for TrustyTony
0
199
Member Avatar for AndresOend

For me it would be lot cleaner style to use normal binary arithmetic for even/odd: [CODE]>>> def odd(n): return bool(n & 1) >>> def even(n): return not odd(n) >>> even(123123) False >>> odd(123123) True >>> [/CODE] If you want you could have class and have the things you like to …

Member Avatar for AndresOend
0
40K
Member Avatar for subhra1234

You should install either pygame-1.9.2a0.win32-py3.2.msi 6.4MB or instal Python 2.5.4 beside your Python 3.2 if you are able to learn both versions simultaneusly (like most regulars here do).

Member Avatar for subhra1234
0
293

The End.