761 Posted Topics
Re: I'm approcimiately with @ddanbe: A class describes how an object will behave, an object behaves that way. This is very cool because we humans are used to dealing with actual real world objects that have behavior conditioned on what class of object they are: ATMs behave one way, and automobiles … | |
Re: Here's what I would do. Is it better?[CODE]import glob filepat = "/Users/Desktop/files/*.txt" # assuming they all have .txt suffix file_names = glob.glob(filepat) print file_names for fn in file_names: print fn with open(fn,'r') as f: # with is succinct and useful f = open(fn,'r') line1 = f.readline().strip() # note: Just one … | |
Re: You have to show some work to get some help. [thread=78223]This[/thread] explains things in more detail. | |
Re: Your code doesn't do what you expect it to do. Consider some simple example ranges: 1,2,3 (odd range, two odds) 2,3,4 (odd range, two evens) 1,2 (even range, one each) 2,3 (even range, one each) This suggests to me that for even length range, the algorithm is very simple. For … | |
Re: I actually have some very minor but real things on my wish list: Group one wishlist: Who's reading this thread:[LIST] [*]Easily see who is watching a thread while I'm in 'advanced editor' mode. [*]That same information available on any page of a multi-page thread [*]That information dynamically updated on the … | |
Re: Confusion: The token `self` is a 'community standard reserved word': It is legal to use as a token, but everybody who codes in Python uses it as the first argument to member functions; and in classes to refer to the class instance it self... and for no other purpose. So … | |
Re: You go to the library at your university and ask for help in finding Computer Science papers co-published at that university by (under) graduate students. Once in the right place, start taking notes. Or, very similar, do a search for papers co-published by the profs that you (might) have for … | |
Re: The essence of a chained hash table is that each key is located in exactly one slot, but the slot does not directly contain a value, rather it contains a list of values, all of which hash to that slot. To give you an idea, I'll write method [icode]contains[/icode] which … | |
Re: You need to use [ICODE]fin.seekg(0)[/ICODE] or [ICODE]fin.seekg(0,ios::beg)[/ICODE] to get the effect you are (ahem) seeking. Your technique is somewhat inefficient. More efficient to read blocks into memory, then count white space and newlines to get number of 'words' and 'lines'. If the blocks are obtained by a call to [ICODE]getline()[/ICODE] … | |
Re: That happens to me from the command line if I misspell the user name or the password. Mysql is a little bit picky in that it distinguishes host [ICODE]%[/ICODE] from host [ICODE]localhost[/ICODE] Look here [url]http://dev.mysql.com/doc/refman/5.1/en/grant.html[/url] (substituting /yourversion/ for the /5.1/ shown here... though most of them are very very similar. | |
![]() | Re: Welcome to Daniweb. First, please go read [thread=78223]this posting about how to use Daniweb[/thread] Then, let me point out the 'thread is solved' link near the bottom of the page. You, the OP (Original Poster) are the only one who has that link. When the thread is as done as … ![]() |
Re: Some quick thoughts: [LIST] [*]A password should never be stored "clear" in the database, so the password field should be password_hash, and it probably needs to be a bit larger to hold a good hash. [*]Why is the user profile in a different table from the user? They have a … | |
Re: @newbieha says: [B][I]any advice is apprentice[/I][/B] OK. The advice is "use the built in dict type": [URL="http://dirtsimple.org/2004/12/python-is-not-java.html"]The CPython dictionary implementation uses one of the most highly-tuned hashtable implementations in the known universe. No code that you write yourself is going to work better...[/URL] | |
Re: I decided to just see what I could do. Using my dictionary which holds 234,936 words, my code runs in a little under two seconds on my mac. The technique: Iterate the dictionary of words, creating a hash for each word that ignores letter order, making a dictionary that maps … | |
Re: No, you can do it. Here's some proof[CODE]class C: def __init__(self,color='white'): self.color = color class B: pass def changeColor(item,color): try: print("Change color from %s to %s"%(item.color,color)) except: print("Add color %s"%(color)) item.color = color a = C() b = C('black') c = B() print('a: %s'%(a.color)) print('b: %s'%(b.color)) try: print('c: %s'%(c.color)) except: … | |
Re: Try this:[ICODE]x=$((time sleep 1) 2>&1); echo $x[/ICODE] Here's what is going on: The shell (bash in my case) [ICODE]time[/ICODE]command is "reporting" timing info directly to the console. [LIST] [*]By putting [ICODE]()[/ICODE] around the command, which means "run in a subshell", that 'report' gets converted so it is on stderr. [*]The … | |
Re: For that matter, think about the type of [icode]w[/icode] which was returned by a call to [ICODE]malloc()[/ICODE] Why are you taking its address? and: what is [icode]pointer[/icode] which is being used to cast the [ICODE]void *[/ICODE] returned by [ICODE]malloc()[/ICODE] | |
Re: Try forcing the path to ex1.py: [icode]python .\ex1.py[/icode] to see what happens. Be aware that I'm not a Windows user. | |
Re: Short answer: It is in the standard. Medium answer: It is both in the standard AND a source of much confusion, because of the complexity of the issue. | |
Re: Start [URL="http://www.eclipse.org/cdt/"]here[/URL] and follow all the installation instructions, step by step, carefully. | |
Re: in a class, the first argument to each member function must be [icode]self[/icode]. If you count up, you'll see that is the one that is missing. However, at a more basic level, you do [B][I]not[/I][/B] need to use classes and inheritance to deal with your issue (although you may find … | |
Re: One problam that many new SQL users have is getting rid of their incorrect ideas about how it works best. If you think of SQL as just another programming language like C, Java or Python, you will have a hard time: Most programming languages allow you to tell the computer … | |
Re: You don't say what 'does not seem to work properly' means. It may be as simple as: Your $PATH and the program's are different. Try spelling the abspath to python in line 21 and see if that helps. If the script needs to live in a variety of places, you … | |
Re: Not sure I see the need for the first query. If the friends table is asymmetric and looks like [CODE]friends { i_am foreign key references user_info, my_friend foreign key references user_info }[/CODE]And you just [ICODE]SELECT p.message from posts p join friends f on f.my_friend = p.author where f.i_am = $my_id … | |
Re: About as much difference as there is in the syntax between C++ and Python: The results are very similar, but the way you get there is somewhat different. And of course all the other differences that aren't about OO or polymorphism. | |
Re: Is std::string considered a 'container class' by your prof? If not, then the recommendation to use it is very good. If so, then I hope you are in an advanced C++ class, because beginners should be given full use of all the tools. Otherwise they should be taking a C … | |
Re: @drjohn. Those back quotes around table or column names are legal (and often a good idea). I tend not to do it that way because I'm a lazy typist. I'd have written [CODE]"SELECT * FROM test1 as t1, test2 as t2, combination as c WHERE t1.IDONE = c.IDONE AND t2.IDTWO … | |
Re: Each parenthesized sub-expression creates a group. [url]http://docs.python.org/library/re.html#regular-expression-syntax[/url] (look for [ICODE](...)[/ICODE]) The [URL="http://docs.python.org/library/re.html#re.findall"] findall[/URL] method returns groups. | |
Re: Tough to write an RE To deal with all legal blockquotes. For instance[CODE=html]<blockquote> this is badly placed but legal html (and probably rendered "correctly"<p> <blockquote> this is a bogus close tag, bad html, but ignored by most browsers</p> <blockquote> <p>This should be cleaned</p> <p> so should this</p><p>and this </p></blockquote><p > … | |
Re: You are using Python 2.x which has two functions: [LIST] [*][ICODE]raw_input[/ICODE] returns a string: [url]http://docs.python.org/library/functions.html#raw_input[/url] [*][ICODE]input[/ICODE] attempts to evaluate the string as a python expression: [url]http://docs.python.org/library/functions.html#input[/url] [/LIST]You (almost) never want to use [ICODE]input()[/ICODE] when interacting with users: Too fraught with difficulty. Instead, use [ICODE]raw_input()[/ICODE] and if you need some other … | |
Re: [URL="http://docs.python.org/library/os.html#os.walk"]os.walk()[/URL] returns a triple: [ICODE](path, dirnames, filenames)[/ICODE] where the second and third items are themselves (possibly empty) lists. Beware that removing files while [ICODE]os.walk[/ICODE]-ing in the vicinity "may cause unstable behavior" :). The safest way is to collect all the things that will need removing, then do them all at … | |
Re: Talk to the folks that do student / career counseling at your school. Even if they cannot give you some actual tests or data, you can [LIST] [*]Ask to take some assessments yourself, which will give you a good idea about what they are (need not be the incoming student … | |
Re: I'll give you two hints: [LIST=1] [*]You need a constructor. Use this:[CODE]class myList(list): def __init__(self,*args): super(myList,self).__init__(args)[/CODE] [*]Your __iter__ method can use a similar technique, but beware infinite recursion if you try to iterate over myList in that method. I used the [ICODE]yield[/ICODE]keyword in my implementation [/LIST]I created a solution in … | |
Re: There are basically two kinds of sensors that I know of: [LIST] [*]The ones buried under the road that detect a conductive mass above them because their capacitance changes [*]The ones mounted near the light that detect the car by (radar? They seem to mess up my radio reception a … | |
Re: A ten minute search (Google) found a half dozen decent looking [B]free[/B] inventory control systems for Windows platforms (which always worries me, but that's a different issue). [URL="http://www.tucows.com/"]Tucows[/URL] is often a good resource (thought I usually go there indirectly). I was less successful looking for something on other platforms. If … | |
Re: In every case, you will have "<a href=[^>]*>" but that just finds all links. I'm not sure I agree with your list of matches and non matches. You can spend quite awhile digging through, for instance the [URL="http://www.ietf.org/rfc/rfc1808.txt"]Relative Uniform Resource Locators RFC[/URL] For my take, then: I think this matches … | |
Re: newest file within the list is problematic. If you look at the output of [ICODE]ftp.dir()[/ICODE]you will see a list of platform-specific lines. You will have to parse each line, in a way that is appropriate to that platform; and use that information to either sort the list or just keep … | |
![]() | Re: I suggest you notice the search window at the top right hand corner of this page. Type [ICODE]thesis topic[/ICODE] into the box and press return or the [search] button. Observe 49 results (as of this moment). But more to the point: It is [B]your[/B] thesis which [B]you[/B] will have to … |
Re: Your answer is too short. [LIST] [*]Is the EMP table in a database? Is it a csv flat file? Some other format file? Something else entirely? [*]What do you mean by 'hard coded values'? Are these values that are in the EMP table, and "never" change? Or do you mean … | |
Re: Probably you want to use split() function:[CODE]sample = "Mem: 62192 32440 29752 0 0" print sample.split()[/CODE]Note that this splits on every white space, so you get the 3rd column by asking for the appropriate index which for this sample would be 3 ("Mem:" is the zero-th column) | |
Re: I gather that 'Capstone' means something to you. It does not to me. Daniweb is not a great resource for generating project ideas. The general consensus here is that you need to actually do some work, then if you get stuck, we can be a good resource for helping you … | |
Re: You are missing join tables that associate: [LIST] [*]part with supplier (call that table supplier_part) [*]job with supplier_part [*]job with worker and billed time (Is this another table?) [*]If workers can bill their hours at different rates depending on circumstance, then you also need a join table to associate worker … | |
![]() | Re: You want to use a shell variable and basename function. Something like this file[CODE]#!/bin/bash while [ $# -gt 0 ] ; do case $1 in -h*|--h*)cat<<EOMSG Usage: $(basename $0) file_to_compile Compiles and runs a go program found in a single file EOMSG exit 0;; *) file=$1; shift ;; esac done … |
Re: Another way to look at it: Take coursework that will encourage you to think about things from a different viewpoint than you get from computer science. I have been well served by classes I took in accounting, English (very helpful), statistics, management. I also took great pleasure, but not much … | |
Re: [LIST] [*]What is your OS? [*]Do you want a GUI calculator or would you be content to launch a window in which a line by line calculator runs? [*]Have you looked for solved threads at DaniWeb? Near the top right corner of the page Type [ICODE]Python Calculator[/ICODE]in the SEARCH box … | |
Re: Of course there are other 'believe your eyes' issues: [url]http://www.youtube.com/watch?v=vJG698U2Mvo[/url] In general, I believe my eyes until there's a reason not. | |
Re: And simulations, graphics, heuristics development... | |
Re: snippsat's answer doesn't seem to relate to the 'search' part of your title... and doesn't actually do what you said needed to happen. Can you be a little more complete about the requirements? What is the description of what needs to happen? For instance this description of the task would … | |
Re: Yes. See for instance [URL="http://dev.mysql.com/doc/refman/5.0/en/insert-select.html"]this insert...select document[/URL] (this one is for 5.0 version, but i expect it is much the same for most) |
The End.