Search Results

Showing results 1 to 40 of 141
Search took 0.02 seconds.
Search: Posts Made By: shadwickman ; Forum: Python and child forums
Forum: Python Sep 17th, 2009
Replies: 9
Views: 448
Posted By shadwickman
Python doesn't need to explicity declare variables in the same way languages like C/C++, Java, etc. do. By writing for comment in inComment: you are creating a new variable called 'comment' that is...
Forum: Python Sep 17th, 2009
Replies: 9
Views: 448
Posted By shadwickman
Sneekula's correct. You're storing each item in the inComments like so: (lineNumber, lineText). So you just need to access the correct index of the tuple, the same way you would access an item in a...
Forum: Python Sep 15th, 2009
Replies: 14
Views: 525
Posted By shadwickman
Python is a good choice for easy-going desktop application development. Of course, you're going to want to get adjusted to and familiarized with classes, methods/functions, etc. before starting on...
Forum: Python Aug 9th, 2009
Replies: 2
Views: 209
Posted By shadwickman
If you don't mind as much about memory usage, you could use

if number in range(10, 24): # careful!
# This gives a range of 10 - 23.
# The end index (24) isn't included in it.

if number in...
Forum: Python Jul 31st, 2009
Replies: 10
Views: 873
Posted By shadwickman
No offense, but gross code you have there. You have an unbelievable amount that's just copy-pasted. I mean, all the questions are running pretty much the exact same code except for the Q it prints...
Forum: Python Jul 30th, 2009
Replies: 10
Views: 873
Posted By shadwickman
I'm quite sleepy, so excuse me if I'm way off here, but is armRight declared within the global scope of the script? If so, then you need to state global armRight within your function so that when you...
Forum: Python Jul 29th, 2009
Replies: 14
Views: 439
Posted By shadwickman
Instead of using a global variable for p, you could just pass that to the function as an optional parameter for the recursion you're doing. And you may want to rename the function. I think that loop...
Forum: Python Jul 29th, 2009
Replies: 14
Views: 439
Posted By shadwickman
Bumsfeld is putting you on the right track. I'll say not to convert the raw_input to an integer like you're doing now, so that you can cycle through each character in it as a string. Then just make...
Forum: Python Jul 29th, 2009
Replies: 4
Views: 345
Posted By shadwickman
Flash can take command-line arguments. So you can do os.system("flash.exe myFileToOpen.fla"). That'll open Flash and have it open the document "myFileToOpen.fla".

If the FLA is in a different...
Forum: Python Jul 25th, 2009
Replies: 10
Views: 414
Posted By shadwickman
Oh sorry! I didn't see your previous post metioning that :D Does anyone know if this has to do with Python 3.x? Changing the value of sys.sydout always worked for me...
Forum: Python Jul 25th, 2009
Replies: 10
Views: 414
Posted By shadwickman
Well I can see that the line you have redirecting the standard output (stdout) is commented out. So it won't be changing the output to that window you wanted. Or is there something I'm missing...? :P
Forum: Python Jul 24th, 2009
Replies: 10
Views: 414
Posted By shadwickman
I don't use Tkinter as I personally hate it :P But I'm going to assume that the Text control has a write function of some kind, just like the wxPython TextCtrls. If that's the case, then you redirect...
Forum: Python Jul 24th, 2009
Replies: 7
Views: 460
Posted By shadwickman
Oh damn, good point. I forgot about the new line thing being different on UNIX from Windows... UNIX is just \n and Windows is \r\n
I think?....
Forum: Python Jul 24th, 2009
Replies: 7
Views: 460
Posted By shadwickman
Yeah, the "\x##" is the format for encoding non-ansi (is that correct?...) characters. As far as I can tell, these are useless characters anyway, because if you pick through the segment:...
Forum: Python Jul 22nd, 2009
Replies: 5
Views: 332
Posted By shadwickman
You were on the right track. Find the 'del' part, then include backwards until you encounter an underscore; this allows for if the number was single, double, triple, quadruple, etc digits long.
...
Forum: Python Jul 18th, 2009
Replies: 6
Views: 417
Posted By shadwickman
From the py2exe site:
"py2exe does not currently (as of 0.6.5) work out of the box if some of your program's dependencies are in .egg form. "

So, here's...
Forum: Python Jul 18th, 2009
Replies: 6
Views: 417
Posted By shadwickman
Open the .egg in Notepad and see what sort of data in contains... I've personally never used mechanize, but then again I've never encountered a module that ran with only an egg file. It could be a...
Forum: Python Jul 18th, 2009
Replies: 6
Views: 417
Posted By shadwickman
Is there a file in the C:\Python25\Lib\site-packages folder named mechanize.pth or a folder named mechanize in that directory? There should be, and the data in mechanize.pth should simply say...
Forum: Python Jul 16th, 2009
Replies: 3
Views: 268
Posted By shadwickman
I'd go with using floats because I'm sure you want to allow for using decimal numbers in your program. And as I said before, math in Python = math in wxPython. All that wxPython is, is a wrapper for...
Forum: Python Jul 16th, 2009
Replies: 3
Views: 268
Posted By shadwickman
First, you should change the line where you bind the button to:
button.Bind(wx.EVT_BUTTON, self.onClick) or else give the button an id (it's the arg passed second in the button's constructor) and...
Forum: Python Jul 10th, 2009
Replies: 5
Views: 481
Posted By shadwickman
I'd put the window updating segment in a function and call that via a thread as well. Try how that works out.

P.S. As long as your style works for you. I personally can't stand it as whitespace is...
Forum: Python Jul 10th, 2009
Replies: 5
Views: 481
Posted By shadwickman
You'll need to use threading to handle this. One thread calls the function which does the subprocess, and the other calls a function which updates the GUI. Something along the lines of:

#...
Forum: Python Jul 9th, 2009
Replies: 3
Views: 860
Posted By shadwickman
Just read the file as-is and then write the output with the lines that aren't blank. Here's an example:

# Read lines as a list
fh = open("myfile", "r")
lines = fh.readlines()
fh.close()

#...
Forum: Python Jul 9th, 2009
Replies: 2
Views: 253
Posted By shadwickman
You need to use the 'self' keyword. So inside the function variable, you'd say self.f = 5. Then when you call printf, you'd say print(self.f).

By not making the variable a property of the class by...
Forum: Python Jul 9th, 2009
Replies: 6
Views: 258
Posted By shadwickman
I'm not entirely sure... Just have a look through the Python documentation! :P
Forum: Python Jul 9th, 2009
Replies: 6
Views: 258
Posted By shadwickman
Well if you're using Python 2.x there's the exec expression. I don't know if it still exists in Python 3.0, and I wouldn't normally use it, but it's all I can think of in this case. All you have to...
Forum: Python Jul 8th, 2009
Replies: 7
Views: 502
Posted By shadwickman
I personally think (as a side note), that he should:

a) Use a relative path so that he can keep the project in one folder and use a hierarchy of folders within that. This allows him to move the...
Forum: Python Jul 8th, 2009
Replies: 4
Views: 297
Posted By shadwickman
I forgot to mention that in solution #2, you assign temp_list2 to the same address of memory as list2, but then that's undone as you create a new list (and new address in memory for it) consisting of...
Forum: Python Jul 8th, 2009
Replies: 5
Views: 740
Posted By shadwickman
Here's an example of how to get the current date and time (as a string) using the datetime module.

import datetime
timestamp = str(datetime.datetime.now())
"""result ->
'2009-07-08...
Forum: Python Jul 8th, 2009
Replies: 4
Views: 297
Posted By shadwickman
Because your temporary list is the same thing as your other list. You said temp_list1 = list1. This means that the value for temp_list1 will be the same address in memory as the value for list1, i.e....
Forum: Python Jul 6th, 2009
Replies: 7
Views: 440
Posted By shadwickman
Ah, good point, I hadn't thought of that. This illustrates what woooee means:

>>> a = b = []
>>> a.append('hi')
>>> a.append('world!')
>>> a
['hi', 'world!']
>>> b.remove('hi')
>>> b...
Forum: Python Jul 6th, 2009
Replies: 10
Views: 553
Posted By shadwickman
Like I showed in my previous post, use a boolean to track it. It's initially False, but when it encounters a line you want to remove, it becomes True. While it's True, it will disregard the lines it...
Forum: Python Jul 6th, 2009
Replies: 7
Views: 440
Posted By shadwickman
Also, please put your code in tags next time so that the indentation is kept, as it's a crucial part of Python.

Other than that, I'm still confused what you are having a problem with. Maybe the...
Forum: Python Jul 6th, 2009
Replies: 10
Views: 553
Posted By shadwickman
So have a variable that, when set, it deletes each line it encounters until it finds one starting with a >
Then just have this set to True or something once you find a line you want to remove, and...
Forum: Python Jul 6th, 2009
Replies: 4
Views: 579
Posted By shadwickman
Ok, so I rewrote some stuff and commented it a bit to help you out.

room_num = raw_input("Enter your room number: ")
text_file = open("roombookings.txt", "r")
# store a list containing the lines...
Forum: Python Jul 6th, 2009
Replies: 4
Views: 579
Posted By shadwickman
First, your whole_thing variable should be text_file.read() if you want to return all the contents as a string. Or text_file.readlines() if you want to return all the contents as a list of each line....
Forum: Python Jul 5th, 2009
Replies: 4
Views: 387
Posted By shadwickman
By putting "s = d / t" before the conditionals would only calculate speed - but what happens when you give speed and distance for example? It wouldn't calculate time. You have to put each individual...
Forum: Python Jul 4th, 2009
Replies: 12
Solved: Py2exe
Views: 627
Posted By shadwickman
And I just found this:
http://www.pyinstaller.org/

It claims to make executables for Windows, Linux, and Mac. I have never used it myself though.
Forum: Python Jul 4th, 2009
Replies: 5
Views: 322
Posted By shadwickman
You may also want to look into unwrapping, like this example:

coords = [14, 16, 4]
x, y, z = coords
"""result -->
x = 14
y = 16
z = 4
"""
Forum: Python Jul 4th, 2009
Replies: 12
Solved: Py2exe
Views: 627
Posted By shadwickman
Well, I posted the tutorial which explains it well. Regardless, put this in a file called setup.py in the same location as your script. Put this in setup.py:

from distutils.core import setup...
Showing results 1 to 40 of 141

 


About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC