Re: Xah's edu corner: the Journey of Foreign Characters thru Internet

2005-11-02 Thread Brandon K
So just stop talking.  It's funny that you guys are having a 
conversations about not responding to a guys post.  First of all, 
freedom of speech, blah blah, who cares, just let him alone.  But 
certainly don't go on his post, reply, telling people not to reply. 
That's like saying EVEN THOUGH I'M doing this, YOU should not do it. 
JUST STOP ALREADY :-).

There is of course, the option...instead of starving the troll...FEED 
HIM TILL HE BURSTS!


== Posted via Newsgroups.com - Usenet Access to over 100,000 Newsgroups 
==
Get Anonymous, Uncensored, Access to West and East Coast Server Farms! 
== Highest Retention and Completion Rates! HTTP://WWW.NEWSGROUPS.COM ==


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Most efficient way of storing 1024*1024 bits

2005-11-02 Thread Brandon K
BTW, it'd be 6 megabits or 750kb ;)
 Six megabytes is pretty much nothing on a modern computer.



== Posted via Newsgroups.com - Usenet Access to over 100,000 Newsgroups 
==
Get Anonymous, Uncensored, Access to West and East Coast Server Farms! 
== Highest Retention and Completion Rates! HTTP://WWW.NEWSGROUPS.COM ==


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: computer programming

2005-11-02 Thread Brandon K
what is .tk?  Turkmenistan?  or is it just some arbitrary suffix.

 www.javaholics.tk



== Posted via Newsgroups.com - Usenet Access to over 100,000 Newsgroups 
==
Get Anonymous, Uncensored, Access to West and East Coast Server Farms! 
== Highest Retention and Completion Rates! HTTP://WWW.NEWSGROUPS.COM ==


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: coloring a complex number

2005-10-21 Thread Brandon K
I'm not 100% sure about this, but from what it seems like, the reason 
method B worked, and not method a is because class foo(complex) is 
subclassing a metaclass.  So if you do this, you can't init a meta class 
(try type(complex), it equals 'type' not 'complex'.  type(complex()) 
yields 'complex'), so you use the new operator to generator a class on 
the fly which is why it works in method B.  I hope that's right.

-Brandon
 Spending the morning avoiding responsibilities, and seeing what it would
 take to color some complex numbers.
 
 class color_complex(complex):
 def  __init__(self,*args,**kws):
 complex.__init__(*args)
 self.color=kws.get('color', 'BLUE')
 
 a=color_complex(1,7)
 print a
 (1+7j)  #good so far
 a=color_complex(1,7,color='BLUE') 
 Traceback (most recent call last):
  File pyshell#37, line 1, in -toplevel-
a=color_complex(1,7,color='BLUE')
 TypeError: 'color' is an invalid keyword argument for this function
 
 No good... it seems that I am actually subclassing the built_in function
 'complex' when I am hoping to have been subclassing the built_in numeric
 type - complex.
 
 but some googling sends me to lib/test/test_descr.py
 
 where there a working subclass of complex more in
 accordance with my intentions.
 
 class color_complex(complex):
def __new__(cls,*args,**kws):
result = complex.__new__(cls, *args)
result.color = kws.get('color', 'BLUE')
return result
 
 a=color_complex(1,7,color='BLUE')
 print a
 (1+7j)
 print a.color
 BLUE
 
 which is very good.
 
 But on the chance that I end up pursuing this road, it would be good if
 I understood what I just did. It would certainly help with my
 documentation  ;)
 
 Assistance appreciated.
 
 NOTE:
 
 The importance of the asset of the depth and breadth of Python archives
 -  for learning (and teaching) and real world production - should not be
 underestimated, IMO. I could be confident if there was an answer to
 getting the functionality I was looking for as above, it would be found
 easily enough by a google search.  It is only with the major
 technologies that one can hope to pose a question of almost any kind to
 google and get the kind of relevant hits one gets when doing a Python
 related search.  Python is certainly a major technology, in that
 respect.  As these archives serve as an extension to the documentation,
 the body of Python documentation is beyond any  normal expectation.
 
 True, this asset is generally better for answers than explanations.
 
 I got the answer I needed.  Pursuing here some explanation of that answer.
 
 Art
 
 


== Posted via Newsgroups.com - Usenet Access to over 100,000 Newsgroups 
==
Get Anonymous, Uncensored, Access to West and East Coast Server Farms! 
== Highest Retention and Completion Rates! HTTP://WWW.NEWSGROUPS.COM ==


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: C Extension - return an array of longs or pointer?

2005-10-12 Thread Brandon K
All the veteran programmers out there can correct me, but the way I did 
it in my extension was this:

static PyObject *wrap_doNumberStuff(PyObject* self, PyObject* args)
{
char* in = 0;
char* x = 0;
long* result = 0;
int i = 0;
PyObject* py = PyTuple_New()
int ok = PyArg_ParseTuple(args,ss,in, x);
if(!ok) return NULL;

result = doNumberStuff(in,x):
len = sizeof(result)/sizeof(long)
for(i;i  len; i++)
PyTuple_SET_ITEM(py, i,Py_BuildValue(l,*result[i])
}

Simple enough idea...i'm not quite sure if I've done everything 
correctly with the pointers, but I'm sure you can figure that out, the 
algorithm is simple enough.

 Hi,
I have been posting about writing a C extension for Python...so far,
 so good.  At least for the simple functions that I need to wrap.
 
 Ok, my c function looks like...
 
 MY_NUM *doNumberStuff(const char *in, const char *x) { ... }
 
 MY_NUM is defined as, typedef unsigned long MY_NUM;  (not sure if that
 matters, or can i just create a wrapper which handles longs?)
 
 anyhow..for my wrapper I have this..
 
 static PyObject *wrap_doNumberStuff(PyObject *self, PyObject args) {
 char *in = 0;
 char *x = 0;
 long *result = 0;
 int ok = PyArg_ParseTuple(args, ss, in, x);
 if (!ok) return 0;
 
 result = doNumberStuff(in, x);
 
 return Py_BuildValue(l, result);
 }
 
 ...my question is...in the c code, result is a pointer to an array of
 longs, how can I get the returned result to be a list or something
 similar to an array in Python?
 
 ...I also have a function which returns a character array (denoted by a
 char *)...would it work the same as the previous question?
 
 Thanks!!
 


== Posted via Newsgroups.com - Usenet Access to over 100,000 Newsgroups 
==
Get Anonymous, Uncensored, Access to West and East Coast Server Farms! 
== Highest Retention and Completion Rates! HTTP://WWW.NEWSGROUPS.COM ==


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: C Extension - return an array of longs or pointer?

2005-10-12 Thread Brandon K
I'm sorry...I just woke up and forgot my C...must have left it in the 
Coffee...Anyway, i made a few mistakes (can't initialize blank 
tuple...function should return a value, lol).

static PyObject* wrap_doNumberStuff(PyObject* self, PyObject* args)
{
char* in = 0;
char* x = 0;
long* result = 0;
int i = 0;
PyObject* py = NULL;
if(!PyArg_ParseTuple(args,ss,in,x) return NULL;

result = doNumberStuff(in,x);
len = sizeof(result)/sizeof(long);
py = PyTuple_New(len);
for(i; i  len; i++)
PyTuple_SET_ITEM(py, i, Py_BuildValue(l,*result[i]);

return py;
}

Additionally, the Python/C api in the docs tells you all of these nifty 
little abstract layer functions that you can call from your extension.

 All the veteran programmers out there can correct me, but the way I did 
 it in my extension was this:
 
 static PyObject *wrap_doNumberStuff(PyObject* self, PyObject* args)
 {
 char* in = 0;
 char* x = 0;
 long* result = 0;
 int i = 0;
 PyObject* py = PyTuple_New()
 int ok = PyArg_ParseTuple(args,ss,in, x);
 if(!ok) return NULL;
 
 result = doNumberStuff(in,x):
 len = sizeof(result)/sizeof(long)
 for(i;i  len; i++)
 PyTuple_SET_ITEM(py, i,Py_BuildValue(l,*result[i])   
 }
 
 Simple enough idea...i'm not quite sure if I've done everything 
 correctly with the pointers, but I'm sure you can figure that out, the 
 algorithm is simple enough.
 


== Posted via Newsgroups.com - Usenet Access to over 100,000 Newsgroups 
==
Get Anonymous, Uncensored, Access to West and East Coast Server Farms! 
== Highest Retention and Completion Rates! HTTP://WWW.NEWSGROUPS.COM ==


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Windows installer, different versions of Python on Windows

2005-10-10 Thread Brandon K
When you install Python it plug entries into the registry, so that when 
you go to install add-ons that are pre-compiled binaries, they look into 
the registry for the python directory.  If you can find out how to 
manipulate the registry so that the binaries would recognize different 
installations, you'd be good to go.  This would probably involve having 
copies of the same key with different values.


 I would like to install several copies of Python 2.4.2 on my machine, 
 but it doesn't seem to be possible.
 
 If I allready has a version installed, the installer only gives the 
 options to:
 
 - change python 2.4.2
 - repair python 2.4.2
 - remove python 2.4.2
 
 I would like to install different versions of Zope 3, and since it is 
 installed under a specific python version, the simplest solution would 
 be to install several Python versions, and install a different zope3 
 version under each python install.
 
 Have I misunderstood something here?
 
 


== Posted via Newsgroups.com - Usenet Access to over 100,000 Newsgroups 
==
Get Anonymous, Uncensored, Access to West and East Coast Server Farms! 
== Highest Retention and Completion Rates! HTTP://WWW.NEWSGROUPS.COM ==


-- 
http://mail.python.org/mailman/listinfo/python-list


Confused on Kid

2005-10-10 Thread Brandon K
Hey, so I heard about the TurboGears posting and decided to investigate. 
 I watched some of their video on building a wiki in 20 minutes and 
was totally blown away because I'm used to python...straight python, not 
melding together 4 different APIs into one to blah blah.  ANYWAY.  I was 
investigating each subproject individually and could not, for the life 
of me figure out how Kid worked.  I understand that it takes a 
well-formed XML document and transforms it, but I could not figure out 
where it transforms it, or how to transform a document.  They have 
plenty of template examples, but I'm left say, What do I do with this? 
I know I can't just pop in it a browser because it has no sort of style 
sheet or anything so it would just render as an XML document.  What do 
you do after you have a kid template?


== Posted via Newsgroups.com - Usenet Access to over 100,000 Newsgroups 
==
Get Anonymous, Uncensored, Access to West and East Coast Server Farms! 
== Highest Retention and Completion Rates! HTTP://WWW.NEWSGROUPS.COM ==


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: new forum -- homework help/chit chat/easy communication

2005-10-08 Thread Brandon K
Hrm...i find it demeaning to relegate Python to a scripting language 
while Visual Basic is in the software development section.  Python so 
outdoes VB in every way shape and form.


 I've launched a new forum not too long ago, and I invite you all to go
 there: www.wizardsolutionsusa.com (click on the forum link).  We offer
 all kinds of help, and for those of you who just like to talk, there's
 a chit chat section just for you...Just remember that forum
 communication is much easier, safer, and faster.
 


== Posted via Newsgroups.com - Usenet Access to over 100,000 Newsgroups 
==
Get Anonymous, Uncensored, Access to West and East Coast Server Farms! 
== Highest Retention and Completion Rates! HTTP://WWW.NEWSGROUPS.COM ==


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: new forum -- homework help/chit chat/easy communication

2005-10-08 Thread Brandon K
[EMAIL PROTECTED] wrote:
 I've launched a new forum not too long ago, and I invite you all to go
 there: www.wizardsolutionsusa.com (click on the forum link).  We offer
 all kinds of help, and for those of you who just like to talk, there's
 a chit chat section just for you...Just remember that forum
 communication is much easier, safer, and faster.
 

[.section Blurb]

About me:
My name is James (Cantley) Sheppard. I am a North Carolina resident, at 
the age of 16. I have been programming since the age of 12, and enjoy it 
as lifes[sic] greatest passion. In the future, I would love to become 
the leading Software Engineer at a fairly large company, and maybe 
someday own my own business. As of right now, I am currently in high 
school and planning on going to a four year college somewhere around the 
country. Well, that is my life story, and about all I got to say!


[.section Commentary]

Hrm, obviously hasn't had enough programming experience in 4 years to 
quite know what he's talking about.  Before making random assertions 
James, you might want to take into account the community you're talking 
to.  I don't know about you guys, but I've had enough teen start up 
webpages.  They clog the web.  No offense of course to the younger 
readers, its just...it's like E/N sites...junk most of the time.


== Posted via Newsgroups.com - Usenet Access to over 100,000 Newsgroups 
==
Get Anonymous, Uncensored, Access to West and East Coast Server Farms! 
== Highest Retention and Completion Rates! HTTP://WWW.NEWSGROUPS.COM ==


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: new forum -- homework help/chit chat/easy communication

2005-10-08 Thread Brandon K

 In other words, what is the difference between a scripting language 
 and a programming language.
 

Good point.


== Posted via Newsgroups.com - Usenet Access to over 100,000 Newsgroups 
==
Get Anonymous, Uncensored, Access to West and East Coast Server Farms! 
== Highest Retention and Completion Rates! HTTP://WWW.NEWSGROUPS.COM ==


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: recursive function

2005-10-07 Thread Brandon K

Is there no way to implement your idea in a classical loop? Usually the 
syntax is cleaner, and there is no limit (except the limit of the range 
function in certain cases).  For example what would be wrong with.

def foo(j):
 while j  n:
j+=1
 return j

I don't know much about the internals of python, but to me it seems like 
if you're going to be doing this on the level of 1000s of iterations, 
there might be some overhead to using recursion (i.e. function calls) 
that a loop wouldn't have (but that's just a guess).

 Hello,
 
 In a recursive function like the following :
 
 
 def foo( j ) :
  j += 1
  while j  n : j = foo( j )
  return j
 
 
 in found that the recursivity is limited (1000 iterations). Then, I have 
 two questions :
 - why this mecanism has been implemented ?
 - it is possible to increase or remove (and how) the number of iterations ?
 
 Regards,
 Mathieu


== Posted via Newsgroups.com - Usenet Access to over 100,000 Newsgroups 
==
Get Anonymous, Uncensored, Access to West and East Coast Server Farms! 
== Highest Retention and Completion Rates! HTTP://WWW.NEWSGROUPS.COM ==


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: recursive function

2005-10-07 Thread Brandon K

 def foo(j):
 while j  n:
 j+=1
 return j
 

of course I mean:
def foo(j):
 while j  n:
 j+=1
 return j

sorry


== Posted via Newsgroups.com - Usenet Access to over 100,000 Newsgroups 
==
Get Anonymous, Uncensored, Access to West and East Coast Server Farms! 
== Highest Retention and Completion Rates! HTTP://WWW.NEWSGROUPS.COM ==


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help with chaos math extensions.

2005-10-06 Thread Brandon K
Well, I didn't buy it JUST to compile python extensions, I'm looking to 
write C++ apps as well, I just use python for a lot of math and science 
simulations, and I got VS .NET at heavy discount since I'm a student.
 Brandon K wrote:
 In case you missed it, I said I have windows XP.  Windows XP 
 pre-compiled python binaries are built on VS .NET 2003.  In order to 
 build extensions, you need the compiler the interpreter was built on, 
 or at least that is what is reported to me by calling setup.py.  If I 
 was using linux, which I currently am not, it'd be a different story.  
 Additionally, GCC isn't available for windows XP, only MinGW, the 
 port, and I don't know that much about it to use it running on a 
 Windows platform.  Furthermore, I was asking for help on an extension, 
 not an economical question about my programming environment.

 Thanks


 On Oct 4, 2005, at 10:25 PM, Brandon Keown wrote:

   I have programmed a fractal generator (Julia Set/Mandelbrot Set) 
 in python in the past, and have had good success, but it would run 
 so slowly because of the overhead involved with the calculation.  I 
 recently purchased VS .NET 2003 (Win XP, precomp binary of python 
 2.4.2rc1) to make my own extensions.

 Why did you need to purchase anything when gcc is available for free?

 Since gcc isn't an option, the logical way to proceed would be to do 
 what others have done and install the Microsoft Toolkit compiler, 
 available from their web site for the outrageous price of nothing. I can 
 vouch that it really does compile extensions for Python 2.4 on Windows, 
 having done that myself.
 
 See
 
   http://www.vrplumber.com/programming/mstoolkit/
 
 regards
  Steve


== Posted via Newsgroups.com - Usenet Access to over 100,000 Newsgroups 
==
Get Anonymous, Uncensored, Access to West and East Coast Server Farms! 
== Highest Retention and Completion Rates! HTTP://WWW.NEWSGROUPS.COM ==


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Absolultely confused...

2005-10-06 Thread Brandon K

 If I take out the ! in the format string and just use O, I can at
 least get past PyArg_ParseTuple. 

Is this a compile-time error? Or a runtime error?



== Posted via Newsgroups.com - Usenet Access to over 100,000 Newsgroups 
==
Get Anonymous, Uncensored, Access to West and East Coast Server Farms! 
== Highest Retention and Completion Rates! HTTP://WWW.NEWSGROUPS.COM ==


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help with chaos math extensions.

2005-10-05 Thread Brandon K
In case you missed it, I said I have windows XP.  Windows XP 
pre-compiled python binaries are built on VS .NET 2003.  In order to 
build extensions, you need the compiler the interpreter was built on, or 
at least that is what is reported to me by calling setup.py.  If I was 
using linux, which I currently am not, it'd be a different story.  
Additionally, GCC isn't available for windows XP, only MinGW, the port, 
and I don't know that much about it to use it running on a Windows 
platform.  Furthermore, I was asking for help on an extension, not an 
economical question about my programming environment.

Thanks


 On Oct 4, 2005, at 10:25 PM, Brandon Keown wrote:

I have programmed a fractal generator (Julia Set/Mandelbrot Set) 
 in python in the past, and have had good success, but it would run so 
 slowly because of the overhead involved with the calculation.  I 
 recently purchased VS .NET 2003 (Win XP, precomp binary of python 
 2.4.2rc1) to make my own extensions.

 Why did you need to purchase anything when gcc is available for free?


 ---
 Andrew Gwozdziewycz
 [EMAIL PROTECTED]
 http://ihadagreatview.org
 http://plasticandroid.org






-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help with chaos math extensions.

2005-10-05 Thread Brandon K




Here's the Script it was being used in (forgive it if it seems a bit
messy, i have been tinkering with variables and such to try different
ideas and haven't really cleaned it up).

import ctest
import Tkinter
import threading

hue_map =
("#FF","#FEFEFF","#FDFDFF","#FCFCFF","#FBFBFF","#FAFAFF","#F9F9FF","#F8F8F8","#F7F7FF","#F6F6F6","#FF","#FF","#FF","#FF","#FF","#FF","#FF",\

"#FF","#FF","#FF","#FF","#FF","#FF","#FF","#FF")

class Mandelbrot_Set(Tkinter.Canvas):
 def __init__(self,master,iters):
 Tkinter.Canvas.__init__(self,master)
 self.dims = {'x':500,'y':500}
 self.config(height=self.dims['y'],width=self.dims['x'])
 self.r_range = (-2.0,2.0)
 self.i_range = (-2.0,2.0)
 self.iters = iters
 self.prec =
{'r':1.*(self.r_range[1]-self.r_range[0])/(self.dims['x']),'i':1.*(self.i_range[1]-self.i_range[0])/self.dims['y']}
 self.escapemap
=
ctest.escapeMap(-1j,self.iters,(self.dims['x'],self.dims['y']),(self.r_range[0],self.r_range[1]),(self.i_range[0],self.i_range[1]))
 self.select = False
 self.select_event = (0,0)
 self.sbox = None
 self.bind("Button-1",self.selection_box)
 self.bind("Motion",self.select_update)
 self.t_draw = threading.Thread(target=self.draw)
 self.t_draw.start()
 
 def draw(self):
 for j in range(self.dims['y']):
 i = 0
 while i  self.dims['x']:
 cur = 0;
 try:
 color = self.escapemap[j][i]
 while self.escapemap[j][i+cur] == color:
 cur+=1
 except IndexError:
 break;
 hue_step = 1.*len(hue_map)/self.iters
 if color == -1: f = "#00"
 else: f = hue_map[int(hue_step*color)]
 self.create_line(i,j,i+cur,j,fill=f)
 i+=cur
 
 def selection_box(self,event):
 if not self.select:
 self.select_event = (event.x,event.y)
 self.select = True
 else:
 self.r_range = self.new_range(event.x,self.select_event[0])
 self.i_range = self.new_range(event.y,self.select_event[1])
 print self.r_range,self.i_range
 self.select = False
 self.delete(Tkinter.ALL)
 self.t_draw.run()
 self.select_update(event)
 
 def new_range(self,x,y):
 if x  y:
 return (y,x)
 else:
 return (x,y)
 
 def select_update(self,event):
 if not self.select:
 return
 else:
 if self.sbox != None:
 self.delete(self.sbox)
 self.sbox =
self.create_rectangle(self.select_event[0],self.select_event[1],event.x,event.y,fill=None,outline="#00")
 else:
 self.sbox =
self.create_rectangle(self.select_event[0],self.select_event[1],event.x,event.y,fill=None,outline="#00")
 
if __name__ == "__main__":
 root = Tkinter.Tk()
 c = Mandelbrot_Set(root,50)
 c.pack()
 root.mainloop()

The error occurs in the instantiation of the Mandelbrot_Set object.
Additionally in little mini timing scripts such as

import time
import ctest

t = time.time()
c = ctest.escapeMap(-1j,100,(500,500))
print time.time()-t

this will crash it too
however I found that just opening up the interpreter and typing

import ctest
ctest.escapeMap(-1j,100,(50,50)) #50 yields much
smaller output than 500x500

it generates a 2d tuple fine. So the error seems really obscure to me,
and I don't understand it.

  Brandon Keown wrote:

  
  
   I have programmed a fractal generator (Julia Set/Mandelbrot Set) in
python in the past, and have had good success, but it would run so
slowly because of the overhead involved with the calculation.  I
recently purchased VS .NET 2003 (Win XP, precomp binary of python
2.4.2rc1) to make my own extensions.  I was wondering if anyone could
help me figure out why I'm getting obscure memory exceptions (runtime
errors resulting in automatic closing of Python) with my extension.  It
seems to run okay if imported alone, but when accompanied in a list of
instructions such as a function it crashes.

  
  
a short script or interpreter session that illustrates how to get the errors
would help.

/F 



  




-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Extending Python

2005-10-05 Thread Brandon K
I own Python in a Nutshell, as one person pointed out.  Alex Martelli 
does a great job of introducing the concepts, as long as your'e familiar 
with C.  Additionally he covers wrapping (which is sounds like you're 
trying to do) with SWIG, Pyrex, and a few other options.  It's a great 
book, I have used no other (save python docs) after my introduction.
 I am looking for a good tutorial on how to extend python with C code. I
 have an application built in C that I need to be able to use in Python.
 I have searched through various sources, starting of course with the
 Python site itself, and others, but I felt a bit lacking from the
 Python site, it seems it was only made for those who installed the
 source distribution, as for the other people... Anyways, thanks for the
 help!

   


-- 
http://mail.python.org/mailman/listinfo/python-list