761 Posted Topics

Member Avatar for SaberExcalibur

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 …

Member Avatar for SaberExcalibur
0
134
Member Avatar for aint

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 …

Member Avatar for aint
0
135
Member Avatar for Korenai

You have to show some work to get some help. [thread=78223]This[/thread] explains things in more detail.

Member Avatar for griswolf
0
79
Member Avatar for rmbrown09

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 …

Member Avatar for mrnutty
0
621
Member Avatar for AndreRet

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 …

Member Avatar for WASDted
0
274
Member Avatar for benqb

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 …

Member Avatar for GDICommander
0
228
Member Avatar for steel dr@gon

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 …

Member Avatar for junry
0
192
Member Avatar for unrealj

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 …

Member Avatar for unrealj
0
365
Member Avatar for Phinisher

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] …

Member Avatar for griswolf
0
110
Member Avatar for muppet

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.

Member Avatar for griswolf
0
120
Member Avatar for irenejd

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 …

Member Avatar for irenejd
0
151
Member Avatar for Agent Cosmic

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 …

Member Avatar for Agent Cosmic
0
240
Member Avatar for newbieha

@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]

Member Avatar for newbieha
0
2K
Member Avatar for ShadyTyrant

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 …

Member Avatar for ShadyTyrant
0
586
Member Avatar for CharlieNewey

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: …

Member Avatar for griswolf
0
383
Member Avatar for linux.buzz

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 …

Member Avatar for griswolf
0
131
Member Avatar for aks_Truba
Member Avatar for fka

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]

Member Avatar for WaltP
0
155
Member Avatar for Enorym

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.

Member Avatar for Enorym
0
149
Member Avatar for gerard4143

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.

Member Avatar for gerard4143
0
99
Member Avatar for ram619

Start [URL="http://www.eclipse.org/cdt/"]here[/URL] and follow all the installation instructions, step by step, carefully.

Member Avatar for jonsca
0
79
Member Avatar for zizuno

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 …

Member Avatar for zizuno
0
175
Member Avatar for noniterum03

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 …

Member Avatar for griswolf
0
203
Member Avatar for rhuffman8

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 …

Member Avatar for griswolf
0
961
Member Avatar for Acute

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 …

Member Avatar for griswolf
0
186
Member Avatar for vbx_wx

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.

Member Avatar for bumsfeld
0
74
Member Avatar for ana_1234

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 …

Member Avatar for griswolf
0
91
Member Avatar for MDanz

@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 …

Member Avatar for griswolf
0
138
Member Avatar for mnmo88

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.

Member Avatar for mnmo88
0
145
Member Avatar for felix001

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 > …

Member Avatar for smantscheff
0
127
Member Avatar for rscubelek

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 …

Member Avatar for rscubelek
0
597
Member Avatar for danholding

[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 …

Member Avatar for griswolf
0
385
Member Avatar for cmjmson

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 …

Member Avatar for onjing
0
133
Member Avatar for br0wnm4n

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 …

Member Avatar for griswolf
0
89
Member Avatar for dexter88

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 …

Member Avatar for griswolf
0
82
Member Avatar for mr-antony

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 …

Member Avatar for mr-antony
0
104
Member Avatar for Xcelled194

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 …

Member Avatar for Xcelled194
0
107
Member Avatar for felix001

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 …

Member Avatar for felix001
0
162
Member Avatar for vjcagay

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 …

Member Avatar for griswolf
-2
47
Member Avatar for vasuv

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 …

Member Avatar for griswolf
0
346
Member Avatar for rssk

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)

Member Avatar for rssk
0
120
Member Avatar for RLB31384

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 …

Member Avatar for griswolf
0
383
Member Avatar for hime

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 …

Member Avatar for griswolf
0
124
Member Avatar for BobTheLob

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 …

Member Avatar for griswolf
0
98
Member Avatar for justinwarner

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 …

Member Avatar for Stefano Mtangoo
0
293
Member Avatar for vik.singh

[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 …

Member Avatar for bumsfeld
0
154
Member Avatar for GrimJack

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.

Member Avatar for griswolf
0
188
Member Avatar for Nisa1207
Member Avatar for skaliam

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 …

Member Avatar for griswolf
0
105
Member Avatar for Aeterna

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)

Member Avatar for griswolf
0
43

The End.