Search Results

Showing results 1 to 40 of 608
Search took 0.04 seconds.
Search: Posts Made By: jrcagle
Forum: Python Mar 2nd, 2009
Replies: 4
Views: 506
Posted By jrcagle
I think I understand what you're trying to do. It still can be done with instances like so:


class Cube(object):
def __init__(self, x, y):

self.x = x
self.y = y
...
Forum: Python Mar 1st, 2009
Replies: 6
Views: 425
Posted By jrcagle
The phrase


for line in data:
...


assigns the variable "line" to each interated string terminated by '\n' within the data.

So if you inserted the statement
Forum: Python Mar 1st, 2009
Replies: 1
Views: 699
Posted By jrcagle
Hm. The only thing I can think of is that your LocalFileName is not valid ASCII.

Jeff
Forum: Python Feb 27th, 2009
Replies: 4
Views: 1,638
Posted By jrcagle
Search this forum for Vega's decimal to binary converter. Your code is reading the data correctly; now you just have to find the right way to display it.

Jeff
Forum: Python Feb 27th, 2009
Replies: 9
Views: 1,040
Posted By jrcagle
Interesting concept. Two potential problems:

(1) What if the images are not all the same size?

(2) How does the code decide what framerate to use?

Jeff
Forum: Python Feb 27th, 2009
Replies: 9
Views: 1,036
Posted By jrcagle
Mark as solved and give Bear of NH props. :)

Jeff
Forum: Python Feb 26th, 2009
Replies: 1
Views: 911
Posted By jrcagle
The standard way of repeating code is to use a while loop. There are two styles: the 'test first' and 'test last' methods.


# a test-first loop: set the sentinel and repeat until sentinel is...
Forum: Python Feb 26th, 2009
Replies: 4
Views: 806
Posted By jrcagle
OK, that makes sense. Here's what will happen:

In lines 9-10 of your current code, you read in an image from a file.

Instead, you will call your camera's "take a picture" method. It will...
Forum: Python Feb 25th, 2009
Replies: 9
Views: 1,036
Posted By jrcagle
That's cool. I didn't even know there was a PySerial module.

First, the error messages are confusing. Are those the result of the print motor.read(motor.InWaiting()) command?

Second, just to...
Forum: Python Feb 25th, 2009
Replies: 3
Views: 255
Posted By jrcagle
Well, here's the basic idea. You have a button in your GUI. The button has a callback function. That function can then call your program. Here's a typical instance:


def mycallback(self,...
Forum: Python Feb 25th, 2009
Replies: 4
Views: 806
Posted By jrcagle
Your question is a little confusing. When I display an image, I make it into a wx.Image() object or a wx.Bitmap() object. It doesn't really matter whether it came from a file or not.

So ... can...
Forum: Python Feb 22nd, 2009
Replies: 3
Views: 330
Posted By jrcagle
ermm... that should be tkFileDialog. Sorry. (and who disabled the "Edit" feature?!)

Jeff
Forum: Python Feb 22nd, 2009
Replies: 3
Views: 1,843
Posted By jrcagle
Lists of lists work fine as container arrays (not mathematical arrays, but you don't seem to be wanting that). So:


nlat=10
mylist = []

for x in range(0,nlat):
tmp = []

for y in...
Forum: Python Feb 22nd, 2009
Replies: 3
Views: 2,437
Posted By jrcagle
As well he should :)

Here's what wooee means:


def SD():
b = []
for n in range(r-1):
if r[n] > a:
b.append((r[n] - a)**2)
Forum: Python Feb 22nd, 2009
Replies: 3
Views: 330
Posted By jrcagle
For the file choosing, you should check out the filedialog module. Google for references on it.

For the endless looping, take a look at the code and think about how to remove the element of...
Forum: Python Feb 22nd, 2009
Replies: 2
Views: 877
Posted By jrcagle
You mean the center of mass?

Well, do it like the physicists do: Sum(moments) / Sum(masses):


>>> def findCOM(grid):
Mx = 0
My = 0
mass = 0
Forum: Python Feb 21st, 2009
Replies: 10
Views: 1,084
Posted By jrcagle
Hm. What happens if you send it an object of the required class? And what is the required class, anyways?

Jeff
Forum: Python Feb 18th, 2009
Replies: 10
Views: 1,084
Posted By jrcagle
Pass in the appropriate "Nothing" value for that type.

So if the COM function header is


Private Function MyFunc(text as String) as String


then you would pass in
Forum: Python Feb 17th, 2009
Replies: 8
Views: 508
Posted By jrcagle
Well, if you think about it, the problem does not have a unique solution.


x = Class()
x.name = 'the_name'
x.value = 10

y = Class()
y.name = 'the_name'
y.value = 20
Forum: Python Feb 17th, 2009
Replies: 10
Views: 1,084
Posted By jrcagle
Almost. In dynamically typed languages like Python, assigning a value and declaring the type occur in the same motion:

MyList = [1,2,3]

means

"Declare MyList as a reference to a list, and...
Forum: Python Feb 16th, 2009
Replies: 2
Views: 267
Posted By jrcagle
Well, start with a thought. How can you explain the process to someone else in English? Make it general: given data in rows of n, how would you rewrite it in rows of m?

Once you have that...
Forum: Python Feb 16th, 2009
Replies: 8
Views: 1,637
Posted By jrcagle
I really like the text we used for my high-school level class: Python Programming for the Absolute Beginner. Two caveats -- it's game-oriented, and it doesn't use Python 3.0.

That said, it...
Forum: Python Feb 16th, 2009
Replies: 1
Views: 431
Posted By jrcagle
This I can explain, but the boto framework is completely unknown to me.

When a new object is created, __new__() is called. I don't know all the details, but it seems from the documentation that...
Forum: Python Feb 16th, 2009
Replies: 10
Views: 1,084
Posted By jrcagle
Yeah, that's interesting ... None in Python is a special type, whereas Nothing is equivalent to NULL of whatever datatype one is working with: Dim b as Integer: b = Nothing -- this makes b a Nothing...
Forum: Python Feb 16th, 2009
Replies: 2
Views: 916
Posted By jrcagle
I'm confused. Here's the help on shutil.copy:



Can you be specific with your question?

Thanks,
Jeff
Forum: Python Feb 14th, 2009
Replies: 5
Views: 623
Posted By jrcagle
One more thought: lists of lists in Python function reasonably well as arrays:


mylist = [[1,2,3],[4,5,6],[7,8,9]]

print mylist[0][2]
3


I say "reasonably well" -- there aren't any linear...
Forum: Python Feb 14th, 2009
Replies: 6
Views: 507
Posted By jrcagle
I fully agree, Vega. The coding purists frown on while True loops, but I find them really useful. Glad to know someone else out there shares my guilty secret. :lol:

Jeff
Forum: Python Feb 14th, 2009
Replies: 4
Views: 274
Posted By jrcagle
Without contradicting the posters above, I would add that Python makes OOP really easy. And in the end, coding with objects is easier to wrap one's mind around than coding without objects -- once...
Forum: Python Feb 14th, 2009
Replies: 3
Views: 776
Posted By jrcagle
>>> class Thing(object):
pass

>>> t = Thing()
>>> dir(t)
['__class__', '__delattr__', '__dict__', '__doc__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__',...
Forum: Python Feb 14th, 2009
Replies: 4
Views: 324
Posted By jrcagle
Just to add to scru's point: Being able to re-use code is an extremely important but sometimes overlooked feature of programming. Its main value is not saving time, but eliminating bugs.

That is,...
Forum: Python Feb 14th, 2009
Replies: 3
Views: 468
Posted By jrcagle
Can't speak to IPython, but a simple file copy will solve the first problem.
Forum: Python Feb 14th, 2009
Replies: 2
Views: 469
Posted By jrcagle
Two thoughts.

(1) You're writing code as if it were C or Pascal. A better way is to write a class:


class Bird(object):

def __init__(self, nID=0, ter=0, year=0, fled=0, age=0.0):
...
Forum: Python Feb 8th, 2009
Replies: 4
Views: 328
Posted By jrcagle
Yes, I actually do the latter.

ACTUALLY, what I often do is this:


class MyClass(object):
....
@staticmethod
def test():
## Unit testing goes here
Forum: Python Feb 8th, 2009
Replies: 4
Views: 328
Posted By jrcagle
The style is good too. In general, functions should do one thing and do it well. Yours pass that criterion.

Although ... I don't usually have a "main()" for the simple reason that I like to...
Forum: Python Feb 8th, 2009
Replies: 2
Views: 307
Posted By jrcagle
I'm not getting your results:


class test(object):
a = 55
def dispmenu(self): print self.a


>>>
>>> instance = test()
Forum: Python Feb 8th, 2009
Replies: 2
Views: 283
Posted By jrcagle
In Python < 3.0, print is a keyword and as such cannot be deleted or clobbered, as far as I can tell. So for example, it's not a part of __builtins__ because it isn't a function.

Interesting that...
Forum: Python Feb 8th, 2009
Replies: 17
Views: 790
Posted By jrcagle
First of all, cool project!

Second: are you nuts?!! :) Seriously, though ... it will take a team and a lot of effort.

Third: You might start by contacting Fred Lundh and Robin Dunn and...
Forum: Python Feb 1st, 2009
Replies: 3
Views: 298
Posted By jrcagle
The newline character is '\n' (including the quotes), not \n\.

Hope it helps,
Jeff
Forum: Python Jan 31st, 2009
Replies: 7
Views: 472
Posted By jrcagle
If you have two genuinely separate programs, then they will have to signal each other. This would likely be accomplished with a pipe, and you'll need some kind of signal handling.

How badly do...
Forum: Python Jan 31st, 2009
Replies: 2
Views: 675
Posted By jrcagle
This appears to work:

>>> im = Image.open("24bit test.bmp")
>>> im2 = im.convert("P")
>>> im2.save("256bit test.bmp")

The bit-depth of the output file is 8, so I assume that's what you were...
Showing results 1 to 40 of 608

 


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

©2003 - 2009 DaniWeb® LLC