Re: append

2007-05-10 Thread Bill Pursell
On 10 May, 18:02, HMS Surprise <[EMAIL PROTECTED]> wrote: > Trying not to be a whiner but I sure have trouble finding syntax in > the reference material. I want to know about list operations such as > append. Is there a pop type function? I looked in tutorial, language > reference, and lib for list

Re: a newbi problem: can't find complete python curses library

2006-11-02 Thread Bill Pursell
docs.python.org/lib/curses-panel-objects.html -- Bill Pursell -- http://mail.python.org/mailman/listinfo/python-list

Re: unloading extension library

2006-10-18 Thread Bill Pursell
Bill Pursell wrote: > I've got a simple extension module that contains two functions: > void hi(void) __attribute__((constructor)); > void hi(void) { printf("Hi!\n");} > void bye(void) __attribute__((destructor)); > void bye(void) { printf("Bye!\n"

unloading extension library

2006-10-18 Thread Bill Pursell
;> import spam Hi! >>> del spam >>> Notice that the destructor isn't called. How can I force python to dlclose() the library and ensure that my destructors get called? -- Bill Pursell -- http://mail.python.org/mailman/listinfo/python-list

Re: Starting out.

2006-10-14 Thread Bill Pursell
Grant Edwards wrote: > > Perl has syntax? ROTFLMAO. In fact, that even motivated: Psychotically Engineered Random Language. -- Bill Pursell -- http://mail.python.org/mailman/listinfo/python-list

Re: how to get file name of the running .py file

2006-08-23 Thread Bill Pursell
Jason Jiang wrote: > Hi, > > How to get the name of the running .py file like the macro _FILE_ in C? There are many ways--IMO the easiest is with __file__: >>> print __file__ /home/bill/.pystart >>> [tmp]$ cat foo.py #!/usr/bin/env python print "The name of the file is:%s"%__file__ [tmp]$ ./foo

Re: List Splitting

2006-08-21 Thread Bill Pursell
t; ["c", "a", "t" ] ] > > The actual data isn't as simple as this, but if I can get the logic > sorted out, I can handle the other part. > > Anyone have any good ideas on how to do this? how about: >>> t = [ "a", "b", "c", "n", "a", "a", "t", "t", "t" ] >>> [t[i::3] for i in range(0,len(t)/3)] [['a', 'n', 't'], ['b', 'a', 't'], ['c', 'a', 't']] -- Bill Pursell -- http://mail.python.org/mailman/listinfo/python-list

Re: import

2006-08-20 Thread Bill Pursell
Georg Brandl wrote: > 01 wrote: > > Georg Brandl wrote: > >> [EMAIL PROTECTED] wrote: > >> > bugnthecode 写道: > >> > > >> >> How are you trying to import it? Is it in the same directory as your > >> >> other script? If not is your python path set correctly? > >> >> > >> >> When importing a module t

Re: sum and strings

2006-08-19 Thread Bill Pursell
Georg Brandl wrote: > Paul Rubin wrote: > > Sybren Stuvel <[EMAIL PROTECTED]> writes: > >> Because of "there should only be one way to do it, and that way should > >> be obvious". There are already the str.join and unicode.join methods, > > > > Those are obvious??? > > Why would you try to sum up

Re: PySequence_SetItem

2006-08-16 Thread Bill Pursell
Bill Pursell wrote: > The following code is pretty much straight out of > section 1.2.1.1 of the Python/C reference manual: > > #include > > int > main(void) > { > PyObject *l, *x; > > Py_Initialize(); > > l = PyList_

PySequence_SetItem

2006-08-16 Thread Bill Pursell
tupid, but it certainly looks like PySequence_SetItem() was expecting that there should already be an item at the desired index. Am I doing something stupid? -- Bill Pursell -- http://mail.python.org/mailman/listinfo/python-list

Re: Using a dictionary to pass data to/from embedded python functions

2006-08-13 Thread Bill Pursell
omitting flags for the sake of brevity, or if I'm actually missing something. -- Bill Pursell -- http://mail.python.org/mailman/listinfo/python-list

Re: Nested function scope problem

2006-08-05 Thread Bill Pursell
Gerhard Fiedler wrote: >There's no Python equivalent to "int*p=345; *p++;". Sure there is: os.kill(os.getpid(), signal.SIGSEGV) :) -- http://mail.python.org/mailman/listinfo/python-list

Re: reading specific lines of a file

2006-07-15 Thread Bill Pursell
Yi Xing wrote: > I want to read specific lines of a huge txt file (I know the line #). > Each line might have different sizes. Is there a convenient and fast > way of doing this in Python? Thanks. #!/usr/bin/env python import os,sys line = int(sys.argv[1]) path = sys.argv[2] os.system("sed -n %d

Re: attaching debugger to runinng python program

2006-07-13 Thread Bill Pursell
alf wrote: > Hi, > > I have a two fold question: > -how to attach the debugger to running multi threaded program > -the objective is to find an infinite loop in one of threads which > makes the whole thingy going craze (100%CPU) > > The program itself is not easy, in fact quite hude an

Re: Guide to using python for bash-style scripting

2006-05-23 Thread Bill Pursell
4zumanga wrote: > Yes, there is a stupid mistake in that script, last line should be: > > diff new_out1 new_out2 > > However, this is hopefully not important, what is important is the > general kind of (very simple) things I'm trying to do. I have been hoping for a good solution to this. An easy

Re: number of different lines in a file

2006-05-18 Thread Bill Pursell
r.e.s. wrote: > I have a million-line text file with 100 characters per line, > and simply need to determine how many of the lines are distinct. > > On my PC, this little program just goes to never-never land: > > def number_distinct(fn): > f = file(fn) > x = f.readline().strip() > L =

Re: Tabs versus Spaces in Source Code

2006-05-17 Thread Bill Pursell
Peter Decker wrote: > On 17 May 2006 06:51:19 -0700, Bill Pursell <[EMAIL PROTECTED]> wrote: > > > In my experience, the people who complain about the use > > of tabs for indentation are the people who don't know > > how to use their editor, and those peop

Re: Tabs versus Spaces in Source Code

2006-05-17 Thread Bill Pursell
Xah Lee wrote: > Tabs versus Spaces in Source Code > > Xah Lee, 2006-05-13 > > In coding a computer program, there's often the choices of tabs or > spaces for code indentation. > (2) Due to the first reason, they have created and > propagated a massive none-understanding and mis-use, to the degre

Re: Programming Tutorial for absolute beginners

2006-04-07 Thread bill pursell
Clodoaldo Pinto wrote: > I'm starting a programming tutorial for absolute beginners using Python > and I would like your opinions. > > http://programming-crash-course.com Very nicely laid out. Overall, a really nice presentation. 2 minor points: 1) in the section on the interactive interpreter

Re: Assignment in a while?

2006-04-02 Thread bill pursell
none wrote: > import pgdb; > > dbh = pgdb.connect(database = 'test') > sth = dbh.cursor() > sth.execute("SELECT * FROM capitals") > #while 1: > #results = sth.fetchone() > #if results == None: > #break > #print results > while results = sth.fetchone(): > print results

Re: How to learn python if I'm very familar with C++

2006-03-26 Thread bill pursell
[EMAIL PROTECTED] wrote: > Hi, > > I've been using C++ for a few years and have developed a few projects > in C++. And I'm familar with OO and template metaprogramming. > > There are some book like "Learning Perl". It is a little bit tedious > for me, because more material in that book seems obviou