Posts
 
Reputation
Joined
Last Seen
Ranked #4K
Strength to Increase Rep
+0
Strength to Decrease Rep
-0
77% Quality Score
Upvotes Received
16
Posts with Upvotes
13
Upvoting Members
11
Downvotes Received
5
Posts with Downvotes
4
Downvoting Members
4
2 Commented Posts
~95.7K People Reached
Favorite Forums
Favorite Tags

93 Posted Topics

Member Avatar for halo_123

[CODE="python"] if assignment.hard or self.lazy: submit_to_daniweb(assignment) else: self.DoHomework(assignment) [/CODE]

Member Avatar for PartVIII
-11
2K
Member Avatar for Cup of Squirrel
Member Avatar for Jason_15
1
18K
Member Avatar for iuessele

Another idea that might be useful is to start with one list of all the unused cards in the deck (AC, 2C, 3C, etc). Randomly select cards from the list and put them into another list called used_cards and remove them from the list of unused cards. I'm not sure …

Member Avatar for alexander.selin.7
0
13K
Member Avatar for keyoh

OK, check this out. The code you're using to find files is pretty good. If you're looking to improve that part of the code you could use recursion so that your function will descend into subdirectories and pull out those files too. Here is some code I whipped up that …

Member Avatar for The Geek Scope
0
5K
Member Avatar for mahela007

I've only done this one time, and I found that I had to use sys.stdout.flush() before I wrote the \b characters. Just in case you run into any problems.

Member Avatar for Lucaci Andrew
0
11K
Member Avatar for Deepak.G

I tried out your code, and it worked fine for me. There were a couple changes that I made that were specific for my environment. For example, my mail server does not support authentication, so I commented out line 22 (mailserver.login). The most significant change that I made, and one …

Member Avatar for rogerkrush
0
1K
Member Avatar for lewashby

[QUOTE]It will be a great help to you if you know the python standard library, or are at least able to navigate it.[/QUOTE] And in my opinion there is no better way to learn the python standard library than spending time in these forums answering and asking questions. Great code, …

Member Avatar for lrh9
0
263
Member Avatar for mn_kthompson

For those of you that are familiar with wx... I'm just dipping my toe into the world of wxPython and I've been trying to put together a very simple Wizard app. Right now I have code that is working properly, but I'd like to know how I can change the …

Member Avatar for mn_kthompson
0
139
Member Avatar for baskar007

I'm just guessing here, but I wonder if your code is less efficient because you open and close the output file repeatedly throughout the process. You perform an open and close operation every 10K, so for a 5MB file you would be opening and closing the file 512 times. Maybe …

Member Avatar for Archenemie
0
187
Member Avatar for Musafir

So you're going to ask the user to put in a starting temperature [CODE="python"] start_temp = int( raw_input('Enter a temperature: ') ) [/CODE] Then you need to give the user some kind of menu or options [CODE="python"] choice = raw_input('Enter C for celcius, F for farenheit, or Q for quit:') …

Member Avatar for sneekula
0
393
Member Avatar for ffs82defxp

I don't understand why someone modded the OP down. He clearly showed effort in his homework, and has a legitimate newby question.

Member Avatar for vegaseat
0
142
Member Avatar for leegeorg07

One thing you could try doing is to give the user two different programs. Prog1 is the auto updater and Prog2 is the twitter client. The user will always run prog1. Prog1 will check for a version string in prog2 and check if an updated version of prog2 is available. …

Member Avatar for Stefano Mtangoo
0
200
Member Avatar for Archenemie

I might be on to something for you. First I took out the print line that you have at line 24. Then I put in this statement at line 23, right before the rename happens. [CODE="python"] temp = raw_input('about to rename '+fname+' to '+ b) [/CODE] This shows me what …

Member Avatar for Archenemie
0
217
Member Avatar for Archenemie

I think that line 14 might be your problem. Even though you ask the user for a path on line 5, you perform your renaming on the operating systems current working directory (CWD) on line 14. I think you should try changing line 14 to [CODE=python] for fname in os.listdir(targetfolder): …

Member Avatar for Archenemie
0
197
Member Avatar for mn_kthompson

I have some processes that I need to keep running on a linux host. For some reason the processes are dying (possibly being killed by another admin). I can hunt that down later, right now I need to make sure the processes are running and relaunch them if necessary Launching …

Member Avatar for donaldw
0
133
Member Avatar for lewashby

Add this in line 12 and I think you'll see it getting called. [CODE="python"] print "__str__ has been called." [/CODE] The __str__ is called when you try to turn something that is not a string (in this case a critter) into a string. So when you print critter, python first …

Member Avatar for mn_kthompson
0
201
Member Avatar for sravan953

One thing you might want to consider is writing the code so that the users password isn't stored in clear text. The way to do this is to hash the user's password with a cryptographic algorithm and store that. Then you hash the password that the user provides at logon …

Member Avatar for mn_kthompson
0
113
Member Avatar for HiHe

I have installed and run python on my Windows 7 Enterprise machine at work. I had no problems with the installer or a simple wxPython application.

Member Avatar for mn_kthompson
0
111
Member Avatar for lewashby

Difficult to say without more context. Is the author talking about inheritance at that point?

Member Avatar for mn_kthompson
0
130
Member Avatar for J-M DESMETTRE

I guess it depends on what you mean by simplify. If you mean fewer lines of code, then yeah there are ways to simplify it. If you mean make the code more readable so that the next person who has to maintain your code will be able to, then probably …

Member Avatar for orinbai
0
3K
Member Avatar for calccrypto

You said that when you hash a string (not a file) that your algorithm and the sha1 library come back with the same results? That's awesome! You're definitely close. What length of string are we talking here? I seem to remember thinking that SHA1 breaks files down into smaller blocks …

Member Avatar for mn_kthompson
0
145
Member Avatar for denniskhor

You're probably going to want to use some recursion when you're searching through the directories. If you copy subfolders you're going to want to know if the files in the subfolders have also copied properly. You can see some examples of using recursion to list all the files in a …

Member Avatar for vansoking
0
1K
Member Avatar for figved

First open a file for writing [CODE=python] outFile = open('/home/figved/file.txt','w') [/CODE] Then replace your print statement with this. I have never used BeautifulSoup so I don't know about the encoding part. I'm just making my best guess based on the code above. But you're asking how to write to a …

Member Avatar for pythopian
0
316
Member Avatar for xm1014

It doesn't look like you're using a dictionary. It appears that you have a list of tuples, and each tuple consists of a string and a list. I can't think of a built in way to do this. You might have to look at writing your own version of a …

Member Avatar for vegaseat
0
443
Member Avatar for lewashby

I think both would work really well, but you'll have an easier time getting support if you're using PHP because that is a very common setup. PHP makes it really easy to grab the form fields and it might not be that easy in python. There are tons of directions …

Member Avatar for pythopian
0
634
Member Avatar for saikeraku

You could also try some string formatting. Check this out... [CODE=python] text = 'Hello World' for x in text: print x.rjust(2) # output is H e l l o W o r l d [/CODE]

Member Avatar for pythopian
0
126
Member Avatar for pyprog

What is the load_airports function? Are you sure that it is returning something into your dictionaries?

Member Avatar for vegaseat
0
268
Member Avatar for gangster88

What error are you getting? It seems to run fine for me. [CODE="python"] >>> import math >>> def distance(p1, p2): ... return float(math.sqrt((p2-p1)**2+(p2-p1)**2)) ... >>> print distance(1,6) 7.07106781187 >>> [/CODE]

Member Avatar for gangster88
0
177
Member Avatar for Fo_Be_La

No,that doesn't quite work. What you would be doing is assigning the key 'Boo' to have the same value as they key 'Hoo'. The question wants you to change the value of dict1['Boo'] to 'Hoo' [CODE="python"] >>> mydict = { 'bar':'none', 'Boo':'something' } >>> print mydict['Boo'] something >>> mydict['Boo'] = …

Member Avatar for Fo_Be_La
0
157
Member Avatar for kisan

There is no built in function that I know of to check that. On thing you might try doing is reversing the string and then comparing each element. [CODE=python] inString = 'racecar' reversestring = '' for i in range(0,len(inString)-1: reversestring.append(inString[i] [/CODE] Another way to do it would be to compare …

Member Avatar for Gribouillis
-1
192
Member Avatar for python123

I think on programs like this you need to start by thinking about how it should look to the end user. What do you want the program to ask for and what do you want it to respond with. Then I like to start by breaking it down into smaller …

Member Avatar for python123
0
243
Member Avatar for Ri0o

Remember, the first thing you want to do is read in the input, so start by working out that problem. Read in the file and strip off the first and last lines: [CODE=python] infile = open('grades1.txt','r') all_lines = infile.readlines() all_lines = all_lines[1:] all_lines = all_lines[:-2] [/CODE] Then you could take …

Member Avatar for Ri0o
-1
123
Member Avatar for lewashby
Member Avatar for vegaseat
0
236
Member Avatar for efecto

Keep in mind that vegaseat's solution will only show you when the photo was created in the filesystem. If you took the photo on a digital camera and then put it on your computer three days later, the creation date would not be the time the picture was taken. A …

Member Avatar for efecto
0
247
Member Avatar for zyrus001

This is a good exercise if you're just playing around with the code because you're trying to learn. But if you're actually planning to implement encryption in an application that needs security then you should follow a couple pieces of advise. The firs is that "If you're typing the letters …

Member Avatar for mn_kthompson
0
556
Member Avatar for wotthe2000

try this... [CODE=python] badletters = ['C', 'R', 'I'] # later on in your program... if word[0].upper() not in badletters: print "Other message has been found" else: print "No other messages were found" [/CODE]

Member Avatar for bumsfeld
0
2K
Member Avatar for mn_kthompson

A couple weeks ago I was reading a thread about character counting and Vegaseat made the comment that [QUOTE]Function calls are time expensive in Python, so I modified Sneekula's count_char2() approach by replacing all those calls to islower(), isupper(), isdigit() and isspace(), and also changing the order of if/elif to …

Member Avatar for vegaseat
0
274
Member Avatar for gabec94

You might want to look at using hashlib so that your password function is more secure. For example, someone could examine the plaintext of your python and find out what the password is. An easy way to get around this is to use a hashing function like SHA1 to encrypt …

Member Avatar for Flameass
0
118
Member Avatar for rajasekhar1242

The first thing I would like to look at is whether or not this is a problem with the server or permissions on the script. So my recommendation would be to run your python script from the command line and see if you get the expected outcome. If so, then …

Member Avatar for rajasekhar1242
0
152
Member Avatar for vinoth_python

How would you even do that? I mean outside of python how can you figure out if you're receiving natted traffic and what kind of natting is being done?

Member Avatar for vinoth_python
0
104
Member Avatar for icu222much

When you use the range function each iteration of the loop sets the value of i back to what the next step in range is. Luckily for you, you can specify how many numbers you want range() to skip on each pass by setting the step [CODE=python] for i in …

Member Avatar for icu222much
0
204
Member Avatar for drew7py

Each line of your file is read in as a list, so you need to loop through the list and print each item. [CODE=python] for item in bird: outgroup.write(item) [/CODE]

Member Avatar for drew7py
0
17K
Member Avatar for l_w

It gets weirder. Check this out [CODE=python] a = 3.333333 round(a,2) # output> 3.3300000000000001 a = round(a,2) a # output> 3.3300000000000001 print a # output> 3.33 [/CODE] What's up with that?

Member Avatar for l_w
0
142
Member Avatar for The Idiot

I've had this happen to me too, where something works on a small scale, but after I've run it against something huge it bombs out. In my case it was a web spider. I don't know what was causing it. The reason I'm replying is because I was wondering if …

Member Avatar for The Idiot
0
92
Member Avatar for leegeorg07

This is a good place to start. [URL="http://cis.poly.edu/cs912/parsing.txt"]http://cis.poly.edu/cs912/parsing.txt[/URL] That is sample code that you can use to gather all of the links on a particular web page. Once you have the list of links on a page, you could repeat the process for each one of those links. Repeat the …

Member Avatar for leegeorg07
0
126
Member Avatar for madurai07

I think the problem is when you test the line to see if the word sample is in the line. In this case your code is asking if the line that you just read in consists of sample* and nothing else. Instead, read in your line and use line.find('sample'). This …

Member Avatar for madurai07
0
136
Member Avatar for Carlo Gambino

You learn through practice. For me, I read the basic python books, and then I came to this board. I read the questions that people ask and I try to answer ever one that I can. This gives me the ability to apply python to real world needs...and in the …

Member Avatar for Stefano Mtangoo
0
136
Member Avatar for besktrap

Have you looked at the code here? [URL="http://code.activestate.com/recipes/360649/"]http://code.activestate.com/recipes/360649/[/URL]

Member Avatar for mn_kthompson
0
112
Member Avatar for revenge2

This one helped me a bit [URL="http://cis.poly.edu/cs912/parsing.txt"]http://cis.poly.edu/cs912/parsing.txt[/URL]

Member Avatar for mn_kthompson
0
204
Member Avatar for revenge2

Q1: On those last three lines you're setting up a list of stuff (line 40). Then you're going into a loop that will perform the same action on each item in your list. The list that you created has a teacher and a student in it, so your for loop …

Member Avatar for Ene Uran
0
125

The End.