3,386 Posted Topics
Re: You have only the Robots instead of Robot as name error, otherwise everything seems fine. class Robot: '''Represents a robot, with a name.''' #A class variable, counting the number of Robot population = 0 def __init__(self, name): '''Initializes the data ''' self.name = name print("(Initializing {0})".format(self.name)) #When this person is … | |
Re: page.findAll('a')[2].get('href') | |
Re: This code seems to be explained with diagram of the state machine at http://www.python-course.eu/finite_state_machine.php | |
Re: Use **Inline Code** (backticking), less painfull than escapes: glob pattern `H:\\*` | |
Re: How would your module compare with https://github.com/odie5533/Python-RTSP ? | |
Re: The response seems not alphanumeric, you must find out how the response should be interpreted and use struct module, for example. | |
Re: You have a for without any statements in it at line 38, as line 37 ends in ;. It looks strange for me as it has not effect except increasing i, so line 39 is in effect d += num[b]. Also learn to use proper indention for your code. | |
Re: You can use else: instead of second if at line 5, otherwise correct, even the whole function seems pointless as it is only print 'Account' + ('exists' if str(myobj) in config_file else "doesn't exist") Where myobj is of type of the your class definition. I would at least define only … | |
Re: You read the lines until you find 'look for this line', then you discard lines until you find 'until this line is found' (you read them, but do not save them), then loop again to look for 'look for this line'. At end you write out all lines you saved, … | |
Re: `' '` backticked quote test myself, code block ' ' | |
Re: If len of list is 14, last index is 13, so line 10 does not make sense. It is more clear to index the last element of list with -1. | |
Re: What you mean Punch Cards, that is media, not computer language. Language of implementation is typicallyl Pascal, so the compiler is self hosting: [QUOTE]The first Pascal compiler was designed in Zürich for the CDC 6000 series mainframe computer family. Niklaus Wirth reports that a first attempt to implement it in … | |
Re: Show effort and post the part of your own code you have problem with to c# forum, if necessary. | |
Re: If you have only not optional alternatives without repeats in [], you could do something like this to avoid complicated transformations (you could improve the matching with more advanced string matching algorithm) : dna = r'atata[atg]ca[atgc]atatagtagcctgt' grouping = [] s = set() reading = False for acid in dna: if … | |
Re: Every time group of statements follows, that line ends in colon and the block is indented. | |
Re: This is not about your own code, but I find this too hackish > if not min(c.isalnum() or c=='_' for c in name): raise ValueError('Type names and field names can only contain ' 'alphanumeric characters and underscores: %r' % name) I would prefer to use something like (untested) if any(not … | |
Re: Iterate through the array keeping track of two largest so far. | |
Re: word=raw_input('enter the word you want to search\n') for fn in '2.txt', '3.txt': with open(fn) as this_file: print fn, 'has', this_file.read().count(word), word | |
Re: Post example code, so we get better picture of your meaning. | |
Re: I hope the message is expected in alphanumeric string not as binary values. | |
Re: We seem to be experiencing determined PM spammer attack and we are raising measures to help block such cases. We are sorry that big amount of these junk messages got sent, you can PM *happygeek*, for example http://www.daniweb.com/members/961217/queenjobe (I announced just now that) any such posters info page url, in … | |
Re: Looks OK excersise, post your code if you get any questions to ask. | |
Re: Looks pretty standars stuff found in many codes in our Code Snippet section. Cut is usually not done but it would be simple to do: Determine cut_point deck = deck[cut_point:] + deck[:cut_point] | |
Re: Post your code and ask specific questions, I can not catch the connection with your request with Python. > What language is Dwarf Fortress programmed in? Would you ever switch to or develop another project in a language like OCaml(pronounced o-camel)? (Aaron Ogden) I wrote DF in C with some … | |
Re: Inorder -> E is the root, I think. The problem is when to move from innode to child nodes. I suspect that this is supposed to be balanced binary tree, but even that is not given by th poster. In that case A would be left child and H right … ![]() | |
Re: def get_list(): myList = ['1','2','a','b'] return myList print get_list() | |
Re: You must also convert the ip number to normal number or keep it as string. I have posted as one of my first Code Snppets functions for the conversion. | |
Re: You assume the correct form and use try...except for input check. Snippsat gave good quote about it, even Gribouillis class was neat coding, only that is not the Pythonic way. Have you read about concept of duck typing? | |
Re: That is software page, not Python module. Check http://www.astro.washington.edu/users/rowen/AstroPy.html | |
Re: There is few views you can have in OOP and Python. This is from a guy more familiar with structured/modular programming than object oriented. 1. Python lets you use objects when you need, otherwise do not bother. That means generally that when you have many instances you want to create, … | |
Re: Sorry for the spanking, it is sometimes diffiult to post suggestgions to OP so they are understood, not give ready answer to home work etc... Your post kind of remainded me of my own post to newbies, which I used to link to in my signature before Markdown change, so … | |
Re: I do not understand the else statement of the first while (and lot of other things of your script) as there is not any break statements inside the loop, which would not enter in it. I have no idea what is your logic. | |
Re: You are trying to call by reference, when parameters are by value. Integer is not standard C type, how is it defined. | |
Re: And there is of course one of my snippets for safer alternative for the code snippet competition, http://www.daniweb.com/software-development/python/code/426488/mathexpression-safer-evaluation , if you want to make that your user does not make joke of erasing your hard disk empty. | |
Re: Paste your code by pushing **Code** from reply menu bar and explain your problem. We are not home work automate, but want to help people to learn. | |
Re: I do not understand your error explanations, your code seems working OK. Naturally you must lift the finger from key to push it again and the message you posted is normal SystemExit message (sys.exit() is same as `raise SystemExit`) | |
Re: Maybe you would benefit from my post some time ago http://www.daniweb.com/software-development/python/threads/426837/echo-user-specified-text#post1826036 ? | |
| |
Re: "without external modules", I would not think it would be easy "without nonstandard modules" or "with only modules included with Python base", sure it is possible to do socket programming, you usually do not directly manipulate signals in Ethernet, but use 'tcp/ip stack'. | |
Re: Your code failed to execute with the strange "wt" mode, with "w" mode everything seemed to work in Python 2.7.3 | |
Re: Actually I was ready to ask after the count, just checked these recent threads. It is kind of dounting when writing code snippets to demonstarate things and finalizing them reasonably well, my only feed back have been occational kudos from Gribouillis. And I in my turn have commented his more … | |
Re: Or you should move to the complex numbers domain as Python supports that. See module cmath. | |
Re: You specify path relative path relative to ftp root directory, you have Windows file path specified. Check first that the ftp you try works from command line ftp, before trying to do it with ftplib. | |
Re: If somebody entered 300 spaces before and after the email address, I quess it would be legitimated. You are stripping spaces from ends, aren't you? | |
Re: Looks quite a tidy effort, I would like if you changed to Python PEP8 style naming like print_report() and would indent with 4 spaces. I personally find it more clear also to use startswith method instead of == with slice. Another suboptimal thing is that you are using if where … | |
Re: How about just reading the file to clipboard? Then just use normal paste. http://www.daniweb.com/software-development/python/code/422325/using-clipboard-from-python |
The End.