Re: Import module with non-standard file name

2006-08-07 Thread John Machin
Ben Finney wrote: > "John Machin" <[EMAIL PROTECTED]> writes: > > > Ben Finney wrote: > > > Now that I've got it written as a Python module, I'd like to write > > > unit tests for that module, which of course will need to import > >

Re: Getting previous file name

2006-08-08 Thread John Machin
Miki wrote: > Hello hj, > > > I have a small script here that goes to inside dir and sorts the file > > by create date. I can return the create date but I don't know how to > > find the name of that file... > > I need file that is not latest but was created before the last file. > > Any hints... I

Re: newb question: file searching

2006-08-08 Thread John Machin
[EMAIL PROTECTED] wrote: > And, finally, the python docs all note that symbols like . and .. > don't work with these commands. Where did you read that? The docs for os.listdir do say that '.' and '..' are (sensibly) not returned as *results*. AFAIK there is nothing to stop you using '.' or '..'

Re: Class data being zapped by method

2006-08-08 Thread John Machin
Kevin M wrote: > Figures. I'll try to complicate it sufficiently ;) > > > [edit] I was going to try to sum up what goes on, but I realized that I > was retyping what I already programmed in an effort to better > illustrate exactly what I'm doing. Pastebin it is. Don't fear, it's > only around 200 l

Re: Unicode/utf-8 data in SQL Server

2006-08-08 Thread John Machin
thebjorn wrote: > I'm working with a MS SQL Server database created by a program from a > fine US company who seems to have gotten run over by the Unicode truck. > In their infinite wisdom they've decided to store Unicode data directly > in regular varchar fields, utf-8 encoded! (on the bright sid

Re: Class data being zapped by method

2006-08-08 Thread John Machin
John Machin wrote: > print [i, len(x.data), id(x) for i, x in enumerate(arrTests)] but should have written: print [(i, len(x.data), id(x)) for i, x in enumerate(arrTests)] -- http://mail.python.org/mailman/listinfo/python-list

Re: newb question: file searching

2006-08-08 Thread John Machin
[EMAIL PROTECTED] wrote: > I do appreciate the advice, but I've got a 12 line function that does > all of that. And it works! I just wish I understood a particular line > of it. > > def getFileList(*extensions): > import os > imageList = [] > for dirpath, dirnames, files in os.walk('.

Re: Class data being zapped by method

2006-08-08 Thread John Machin
Kevin M wrote: > Inline > > > 1.) Why are you removing the .pyc file? > > After I had run the script once and subsequently changed the class > file, I would run the script again, and it would use the pyc file from > the older revision of the script. I got frustrated with having to > manually delet

Re: Unicode/utf-8 data in SQL Server

2006-08-09 Thread John Machin
Laurent Pointal wrote: > John Machin a écrit : > > The customer should be very happy if you do > > text.decode('utf-8').encode('cp1252') -- not only should the file > > import into Excel OK, he should be able to view it in > > Word/Notepad/whatev

Re: technique to enter text using a mobile phone keypad (T9 dictionary-based disambiguation)

2006-08-09 Thread John Machin
[EMAIL PROTECTED] wrote: > I've tested that sorting just the strings instead of the tuples (and > removing the stripping) reduces the running time enough: > > def __init__(self): > numbers = '222333444555666888' > conv = string.maketrans(string.lowercase, numbers) >

Re: What's the cleanest way to compare 2 dictionary?

2006-08-09 Thread John Machin
John Henry wrote: > Hi list, > > I am sure there are many ways of doing comparision but I like to see > what you would do if you have 2 dictionary sets (containing lots of > data - like 2 keys and each key contains a dozen or so of records) > and you want to build a list of differences about t

Re: technique to enter text using a mobile phone keypad (T9 dictionary-based disambiguation)

2006-08-09 Thread John Machin
[EMAIL PROTECTED] wrote: > John Machin: > > 2. All responses so far seem to have missed a major point in the > > research paper quoted by the OP: each word has a *frequency* associated > > with it. When there are multiple choices (e.g. "43" -> ["he",

Re: why does getpass() show the input?

2006-08-09 Thread John Machin
John Salerno wrote: > I'm guessing this might have something to do with my particular system? Is that meant to be a statement or a question? If it's a question, and you'd like a helpful answer, try telling us at least (1) what platform you are running on, (2) did you enter that at the usual OS c

Re: Class data being zapped by method

2006-08-09 Thread John Machin
Kevin M wrote: > Good news. I've fixed it up and all seems to be well. > > Thanks, all. I've learned a lot from this -:) Kindly share the learning by feeding back: (1) What the original problem ("class data being zapped by method") really was. (2) What was the cause of the drama with pyc files.

Re: using python with tar files and compressed files

2006-08-09 Thread John Machin
[EMAIL PROTECTED] wrote: > This syntax works on other bzipped tar files. But it's not unheard of > that large tarballs will get corrupted from a download mirror. Use a > download manager and try redownloading the file. Usually a mirror will > include an md5sum text file so that you can compare the

Re: why does getpass() show the input?

2006-08-09 Thread John Machin
John Machin wrote: > > If it's a question, and you'd like a helpful answer, try telling us at > least [snip] plus (6) what conclusions you have after reading /Lib/getpass.py -- http://mail.python.org/mailman/listinfo/python-list

Re: excel in unix?

2006-08-10 Thread John Machin
[EMAIL PROTECTED] wrote: > hi > is it possible to create excel files using python in Unix env? > if so, what module should i use? Try this: http://cheeseshop.python.org/pypi/pyExcelerator/0.6.0a ... writes Excel files without apparent difficulty, doesn't preach at you :-) -- http://mail.pytho

Re: why does getpass() show the input?

2006-08-10 Thread John Machin
Robin Haswell wrote: > [EMAIL PROTECTED]:~$ python > Python 2.4.2 (#2, Sep 30 2005, 21:19:01) > [GCC 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu8)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >>> > >>> # The cause of this problem is because you're usin

Re: What's the cleanest way to compare 2 dictionary?

2006-08-10 Thread John Machin
John Henry wrote: > John, > > Yes, there are several scenerios. > > a) Comparing keys only. > > That's been answered (although I haven't gotten it to work under 2.3 > yet) (1) What's the problem with getting it to work under 2.3? (2) Why not upgrade? > > b) Comparing records. You haven't got tha

Re: semi-Newbie question

2006-08-10 Thread John Machin
len wrote: > Hi all > > I have a file that I receive from another party which is basicly a csv > file containing the following type of information; > > Tagname Scope Value > "first_name","POL01","John" > "last_name","POL01","Doe" > "birthday","POL01","04/03/61" > etc > > I nee

Re: String Formatting

2006-08-10 Thread John Machin
OriginalBrownster wrote: > Hi there: > > I was wondering if its at all possible to search through a string for a > specific character. Don't wonder; read the tutorials, read the manuals, and ponder the sheer uselessness of any computer language that offered neither such a facility nor the means to

Re: hide python code !

2006-08-10 Thread John Machin
Bayazee wrote: > hi > can we hide a python code ? > if i want to write a commercial software can i hide my source code from [1] > users access ? > we can conver it to pyc but this file can decompiled ... so ...!! > do you have any idea about thi

Re: hide python code !

2006-08-10 Thread John Machin
Bayazee wrote: > hi > in compiled languages when we compile a code to an executable file it > convert to a machine code so now we cant access to source ... > but in python we easily open the program executable(ascii) file and > read source > i meen than any way to protect my code or convert

Re: error handling

2006-08-10 Thread John Machin
Chris wrote: > I want to handle errors for a program i'm building in a specific way, > but I don't want to use try/except/finally because it requires forming > new blocks of code. I want to be able things like this: > > a = [2, 423, "brownie", 234.34] > try: a[890] > except IndexError: # I don't u

Re: seaching a list...

2006-08-10 Thread John Machin
bruce wrote: > hi larry... > > thanks for the reply... > > the issue i'm having is that i'm going to have to compare multiple rows of > information to the information in the db. so essentially i'd have to do a > hit to the db, for each row of information i want to compare if i did it > your way...

Re: python/mysql/list question...

2006-08-10 Thread John Machin
bruce wrote: > hi. > > i have the following sample code. i'm trying to figure out if there's a way > to use a 'list of lists' in a mysql execute... > > i've tried a variety of combinations but i get an error: > Error 1241: Operand should contain 1 column(s) > > the test code is: > > insertSQL = "

Re: Python script setup

2006-08-11 Thread John Machin
2Good4You-Veki(Cro) wrote: > Hi all, > > When I want setup my script: > > I write: > > from distutils.core import setup > setup(name="myscript", > version='1.0', > scripts=["myscripts.py"]) > > or some else example,error is > > > Traceback (most recent call last): > File "", li

Re: Reading unformatted big-endian files

2006-08-11 Thread John Machin
Andrea Gavana wrote: > "err=8" means that, if an error occours in > reading the file, > it should go to the label "8 continue" and continue reading the file Silently ignoring errors when reading a file doesn't sound like a good idea to me at all, especially if different records have different for

Re: Read a file with open command

2006-08-11 Thread John Machin
jean-jeanot wrote: > I can access to a file with the command: > file_obj = open ( " D:\My documents\Textfile.txt",'r') With a space before the drive letter? I don't think so. When asking questions, *don't* type what you thought you used, copy/paste what you actually used. > > When I now try to re

Re: Reading unformatted big-endian files

2006-08-11 Thread John Machin
On 11/08/2006 8:35 PM, Andrea Gavana wrote: > I hope performances will not change so much: fortran is > very fast in reading files (but I use it only in this case, I love to > use Python)... well, let's see :-D Well FORTRAN would have to have *something* going for it :-) I vaguely recall in a pr

Re: Python checking for None/Null values

2006-08-11 Thread John Machin
Fuzzydave wrote: > > HistoryRep is an array value so historyRep[0] to [7] all have values > in them but historyRep[8] and [9] do not as the query does not always > return a full 10 values. I am trying to check all of the historyRep > items > to check if they are empty/null/None (whatever the term i

Re: datetime to timestamp

2006-08-11 Thread John Machin
On 11/08/2006 11:10 PM, Simen Haugen wrote: > Hi. > > How can I convert a python datetime to a timestamp? It's easy to convert > a timestamp to datetime (datetime.datetime.fromtimestamp(), but the > other way around...?) > > -Simen > Is the timetuple() method what you want? #>>> import datetim

Re: datetime to timestamp

2006-08-11 Thread John Machin
On 11/08/2006 11:35 PM, John Machin wrote: > On 11/08/2006 11:10 PM, Simen Haugen wrote: >> Hi. >> >> How can I convert a python datetime to a timestamp? It's easy to convert >> a timestamp to datetime (datetime.datetime.fromtimestamp(), but the >> other way a

Re: datetime to timestamp

2006-08-11 Thread John Machin
Tim Peters wrote: > [Simen Haugen] > >>> How can I convert a python datetime to a timestamp? It's easy to convert > >>> a timestamp to datetime (datetime.datetime.fromtimestamp(), but the > >>> other way around...?) > > [John Ma

Re: help with c <-> python buffer transfer

2006-08-11 Thread John Machin
[EMAIL PROTECTED] wrote: > How does one transfer a buffer object from python -> c and back again > (assuming the data gets modified)? > I can't seem to get this or anything else to work, but am clueless as > to what I'm doing wrong > > > using namespace boost::python; Looks like C++, not C. > > s

Re: iterator wrapper

2006-08-11 Thread John Machin
alf wrote: > Hi, > > I have a following task: let's say I do have an iterator returning the > some objects: > > >>i= > >>i.next() > 1 > >>i.next() > 'abgfdgdfg' > >>i.next() > > > > For some reason I need to wrap thos objects with a list. I thought I > could have a smart lamda or simple funct

Re: help with c <-> python buffer transfer

2006-08-11 Thread John Machin
[EMAIL PROTECTED] wrote: > This is the part I need help with. I've also used PyBuffer_... > subroutines which gave similar problems. Thanks for all of your other > comments, but I was hoping someone could just tell me what was wrong > with the code without having to worry about all of the other

Re: Read a file with open command

2006-08-12 Thread John Machin
[EMAIL PROTECTED] wrote: [snip] > My point is that this is a wonderful service you tutors provide, but > the Zappa signature may not be the best choice for this setting. This is *not* the tutor list. >Most people will read it and get a laugh (as did I), but how many have taken > it the way jean-j

Re: __LINE__ and __FILE__ functionality in Python?

2006-08-13 Thread John Machin
Joakim Hove wrote: > Hello, > > i have simple[1] function like this: > >def log_msg(msg , file , line): >print "%s:%s %s" % (file,line,msg) > > the file and line arguments should be the filename and linenumber of > the source file where the function is called. If this were C I would >

Re: Installed correctly

2006-08-13 Thread John Machin
Ray wrote: > I've just installed Python 2.4.3 on windows 2000. On the download page > it says that if python is installed the version number will be > displayed if you enter "python" in a command line window, but that > does not happen - it just says "unrecognized command". Rebooting does > not he

Re: open() and Arabic language

2006-08-13 Thread John Machin
MaaSTaaR wrote: > Hello ... > > firstly , sorry for my bad English . > > i have problem with open() function when i use it with file which name > in Arabic , the open() will not find the file , and i am sure the file > is exist . > > > so how i can solve this problem ? Provide more information --

recommended general-purpose string template packages?

2006-08-13 Thread John Machin
Hi, In general, I'm mainly interested in a template engine for dynamic web pages but would like a general purpose one to avoid learning yet another package for generating e-mail messages, form letters, source code, whatever. In particular, does anyone have much experience with the Python interfac

Re: outputting a command to the terminal?

2006-08-13 Thread John Machin
John Salerno wrote: > > I think I'll take a look at the subprocess module, just for fun. :) ... and for learning too :-) Also, consider that some operating system commands are built into the shell (i.e. not run as a separate process), which makes using the subprocess module a bit difficult -- f

Re: selecting base class from user input

2006-08-14 Thread John Machin
Jackson wrote: > I have 4 classes: > > Lion(Animal): > Ant(Animal): > Bee(Animal): > Human(Animal): > > which are all subclasses of some superclass called Animal. Now I want > to define an occupation. For example, Worker. A worker can exist as any > of the 4 classes above. Their constructors ar

Re: TypeError: 'module' object is not callable (newby question)

2006-08-14 Thread John Machin
Charles Russell wrote: > Why does this work from the python prompt, but fail from a script? > How does one make it work from a script? > > #! /usr/bin/python > import glob > # following line works from python prompt; why not in script? > files=glob.glob('*.py') > print files > > Traceback (most rec

Re: Memory problem

2006-08-14 Thread John Machin
Yi Xing wrote: > Hi, > > I need to read a large amount of data into a list. So I am trying to > see if I'll have any memory problem. When I do > x=range(2700*2700*3) I got the following message: > > Traceback (most recent call last): > File "", line 1, in ? > MemoryError > > Any way to get ar

Re: Memory problem

2006-08-14 Thread John Machin
[EMAIL PROTECTED] wrote: > If you know that you need floats only, then you can use a typed array > (an array.array) instead of an untyped array (a Python list): > > import array > a = array.array("f") > Clarification: typecode 'f' stores a Python float (64-bits, equivalent to a C double) as a 32

Re: Memory problem

2006-08-14 Thread John Machin
Yi Xing wrote: > I tried the following code: > > >>> i=0 > >>> n=2600*2600*30 > >>> a=array.array("f") > >>> while (i<=n): > .. i=i+1 > .. a.append(float(i)) Not a good idea. The array has to be resized, which may mean that a realloc won't work because of fragmentation, you're out of luck

Re: TypeError: 'module' object is not callable (newby question)

2006-08-14 Thread John Machin
Charles Russell wrote: > Marc 'BlackJack' Rintsch wrote: > > > > > Don't call your file `glob.py` because then you import this module and not > > the `glob` module from the standard library. > > > > Ciao, > > Marc 'BlackJack' Rintsch > > Yes, thanks. Renaming to myglob.py solved the problem.

Re: Memory problem

2006-08-14 Thread John Machin
Yi Xing wrote: > On a related question: how do I initialize a list or an array with a > pre-specified number of elements, something like > int p[100] in C? I can do append() for 100 times but this looks silly... > > Thanks. > > Yi Xing In the case of an array, you may wish to consider the fromfil

Re: Memory problem

2006-08-14 Thread John Machin
Yi Xing wrote: > Thanks! I just found that that I have no problem with > x=[[10.0]*2560*2560]*500, but x=range(1*2560*2560*30) doesn't work. > range(1*2560*2560*30) is creating a list of 196M *unique* ints. Assuming 32-bit ints and pointers: that's 4 bytes each for the value, 4 for the type pointe

Re: Memory problem

2006-08-14 Thread John Machin
Martin v. Löwis wrote: > John Machin wrote: > > Incredible. That's only 34 MB. What is the size of your paging file? > > What memory guzzlers were you running at the same time? What was the > > Task Manager "Performance" pane showing while your test was running

Re: Clean way to not get object back from instantiation attempt gone bad

2006-08-15 Thread John Machin
tobiah wrote: > I should have made it more clear that Foo is a class: > > > class Foo: > > def __init__(self, *args): > > for arg in args: > if is_fruit(arg): > del(self) > > > > tobiah wrote: > > Suppose I do: > > > > -*> > m

Re: Clean way to not get object back from instantiation attempt gone bad

2006-08-15 Thread John Machin
Simon Forman wrote: > > |>> class f: > ... def __init__(self): > ... del self Of course nothing happens. Args are local variables. 'self' is is a vanilla arg of a vanilla function. > ... > |>> e = f() > |>> e > <__main__.f instance at 0xb7dd91ec> > > > |>> class f: > ... def

Re: Printing n elements per line in a list

2006-08-15 Thread John Machin
Dan Sommers wrote: > > counter = 0 > for an_element in the_list: > print an_element, > counter = counter + 1 > if counter == n: > print > counter = 0 > Yes, often simple old-fashioned ways are the best. A little verbose, though. And I'd do

Re: Instantiate all objects in a module?

2006-08-15 Thread John Machin
Donald Westfield wrote: > I have my own module, called mystuff.py, which is to be imported for an > app. > > The number of classes in the module will vary, so I need a subroutine that > will instantiate all of them as objects, and assign a variable to each, > regardless of what names the classes ar

Re: Printing n elements per line in a list

2006-08-15 Thread John Machin
Steven D'Aprano wrote: > I think it's possible to > > hack it up using while loops and some ugly slicing, but hopefully I'm > > missing something > > I don't see why you think that's an ugly hack. > > def printitems(sequence, count=5): > """Print count items of sequence per line.""" > numr

Re: Printing n elements per line in a list

2006-08-15 Thread John Machin
Dan Sommers wrote: > On 15 Aug 2006 18:33:51 -0700, > "John Machin" <[EMAIL PROTECTED]> wrote: > > ... ctr = (ctr + 1) % n > > I'm old enough to remember the days when we avoided division like the > plague. Remember those zippy 1MHz (yes, that&#

Re: Very weird behavior that's driving me crazy

2006-08-16 Thread John Machin
Pupeno wrote: > Hello, > I am experiencing a weird behavior that is driving me crazy. I have module > called Sensors containing, among other things: > > class Manager: > def getStatus(self): > print "getStatus(self=%s)" % self > return {"a": "b", "c": "d"} > > and then I have a

Re: Memory usage of an 'empty' python interpreter

2006-08-16 Thread John Machin
Ant wrote: > [EMAIL PROTECTED] wrote: > > I was wondering what the approximate amount of memory needed to load a > > Python interpreter (only, no objects, no scripts, no nothing else) in a > > Linux 2.6 environment. According to ps, it appears to be 3312 bytes, > > which seems absurdly low to me.

Re: Printing n elements per line in a list

2006-08-16 Thread John Machin
Gerard Flanagan wrote: > > just variations on previous answers: > > rng = range(1,101) > > #ad hoc > for line in ( rng[i:i+5] for i in xrange(0,100,5) ): > print ' '.join(map(str,line)) > > #in general > def lines( seq, count=1 ): > n = len(seq) > for x in ( seq[i:i+count] for i in xr

Re: Printing n elements per line in a list

2006-08-16 Thread John Machin
Yu-Xi Lim wrote: > John Machin wrote: > > > How did you avoid division when testing for leap year? > > > > Well, you're testing for a modulus, not really a division, so a nasty hack: > > def isleapyear(year): > return not year&3 > > works for

Re: PySequence_SetItem

2006-08-16 Thread John Machin
Bill Pursell wrote: > Bill Pursell wrote: > > Also note that the problem goes away if I replace > the call to PySequence_SetItem with: > PySequence_SetItem(l, 0, PyInt_FromLong(1L)); Are you sure? It should make absolutely no difference. My experience so far: 1. crashes in call to PySequence_Se

Re: PySequence_SetItem

2006-08-16 Thread John Machin
Jack Diederich wrote: > Changing the PySequence_SetItem to PyList_SetItem and dropping the > DECREF works for me too (PyList functions steal a reference). I also > tried setting the list to length 1, still no dice. The PySequence > version segs under 2.4 and 2.5. It segs even when the Int is c

Re: PySequence_SetItem

2006-08-16 Thread John Machin
John Machin wrote: > Jack Diederich wrote: > > > Changing the PySequence_SetItem to PyList_SetItem and dropping the > > DECREF works for me too (PyList functions steal a reference). I also > > tried setting the list to length 1, still no dice. The PySequence > >

Re: PySequence_SetItem

2006-08-16 Thread John Machin
Jack Diederich wrote: > On Wed, Aug 16, 2006 at 02:39:24PM -0700, John Machin wrote: > > > > Jack Diederich wrote: > > > > > Changing the PySequence_SetItem to PyList_SetItem and dropping the > > > DECREF works for me too (PyList functions steal a reference

Re: Calling a python script, and getting the returned result in C

2006-08-16 Thread John Machin
Shuaib wrote: > Hi! > > I have a python script which returns an Integer value. How do I call > this script from a C programe, and use the result returned? To avoid confusion and possible irrelevant responses, please say which of the following options best matches your requirement: (a) your Pytho

Re: Clean way to not get object back from instantiation attempt gone bad

2006-08-16 Thread John Machin
Simon Forman wrote: > The entire post was meant as a pedantic exercise illustrating what not > to do (and how easy it is to figure that out with an interactive > session,) and sketching how to raise and check for an error instead. > Lessons usually start with the teacher asserting authority and

Re: Calling a python script, and getting the returned result in C

2006-08-16 Thread John Machin
Shuaib wrote: > John Machin wrote: > > Shuaib wrote: > > > Hi! > > > > > > I have a python script which returns an Integer value. How do I call > > > this script from a C programe, and use the result returned? > > > > To avoid confusion a

Re: Printing n elements per line in a list

2006-08-16 Thread John Machin
Matimus wrote: > unexpected wrote: > > If have a list from 1 to 100, what's the easiest, most elegant way to > > print them out, so that there are only n elements per line. > > > > So if n=5, the printed list would look like: > > > > 1 2 3 4 5 > > 6 7 8 9 10 > > 11 12 13 14 15 > > etc. > > > > My

Re: python-dev and setting up setting up f2py on Windows XP

2006-08-16 Thread John Machin
Sile wrote: > Hi, > > I've been trying to get f2py working on Windows XP, I am using Python > 2.3. I'm new to python so I'm not too sure what I'm doing yet. I need > the python-dev package to run f2py. I have been told this is just the > header files and .dll and I need to put them somewhere my C c

Re: PySequence_SetItem

2006-08-16 Thread John Machin
Jack Diederich wrote: > On Wed, Aug 16, 2006 at 03:25:39PM -0700, John Machin wrote: > > > > > > > > Not the OP's problem, but a bug in the manual: example in the chapter > > > > that the OP was reading acts as though the 2nd arg to PyObject_SetItem &

Re: Memory usage of an 'empty' python interpreter

2006-08-16 Thread John Machin
Ant wrote: > > > Are you sure ps is reporting in bytes not KB? The bare interpreter in > > > Windows is 3368KB. > > > > Where did you get that from? With Python 2.4.3, on my machine (Win XP > > SP2): > > > > C:\junk>dir \python24\python* > > [snip] > > 29/03/2006 05:35 PM 4,608 python

Re: Newbie needs Help

2006-08-16 Thread John Machin
len wrote: > Hi all > > I am writing a python program that inserts records into a database on > XP using mxODBC. > > I need to write a section of code which will create the following SQL > command as an example; > > INSERT INTO statecode (state, name) VALUES ('IL', 'Illinois') > > This statement wi

Re: Printing n elements per line in a list

2006-08-16 Thread John Machin
Matimus wrote: > Well, I have another at bat, so I will try to redeem myself... using > recursion: > > def printTable(l,c): > print(("%d "*len(l[:c]))%tuple(l[:c])) > if( len(l[:c]) > 0 ): > printTable(l[c:],c) > > printTable(range(1,101),5) Sorry. Recursion disqualified your bat

Re: Newbie needs Help

2006-08-16 Thread John Machin
[EMAIL PROTECTED] wrote: > Also, it may be easier to use string interpolation, as in: > > return "INSERT INTO statecode (state, name) VALUES ('%(state)s', > '%(name)s')" % insert_dict > > ...after all necessary escaping, of course. > Excuse me!? "statecode" needs to come from the first argument.

Re: Newbie needs Help

2006-08-16 Thread John Machin
Dennis Lee Bieber wrote: > c.execute("insert into %s (%s) values (%s)" > % ("statecode", > ", ".join(data.keys() ), > ", ".join(["%s"] * len(data.keys() ) ) ), > data.values() ) > # NOTE: on

Re: PySequence_SetItem

2006-08-17 Thread John Machin
Fredrik Lundh wrote: > John Machin wrote: > > > Are you suggesting a rework of the manual instead of inserting a X in > > the offending py_DECREF? > > are you suggesting slowing things down just because of a bug in the > documentation ? Not explicitly; not intentionall

Re: re.sub() backreference bug?

2006-08-17 Thread John Machin
[EMAIL PROTECTED] wrote: > using this code: > > import re > s = 'HelloWorld19-FooBar' > s = re.sub(r'([A-Z]+)([A-Z][a-z])', "\1_\2", s) > s = re.sub(r'([a-z\d])([A-Z])', "\1_\2", s) > s = re.sub('-', '_', s) > s = s.lower() > print "s: %s" % s > > i expect to get: > hello_world19_foo_bar > > but i

Re: Newbie SQL ? in python.

2006-08-17 Thread John Machin
len wrote: > I have tried both the pyodbc and mxODBC and with help from the ng been > able to do what I want using either. My needs are pretty basic some > simple selects and inserts. > > The current problem I have hit is the database I am inserting into have > a special ODBC driver that using the

Re: Optimizing Inner Loop Copy

2006-08-17 Thread John Machin
Mark E. Fenner wrote: > Here's my class of the objects being copied: Here's a couple of things that might help speed up your __init__ method, and hence your copy method: > > class Rule(list): > def __init__(self, lhs=None, rhs=None, nClasses=0, nCases=0): def __init__(self, lhs=None, r

Re: Search or compai problem

2006-08-18 Thread John Machin
Gallagher, Tim (NE) wrote: > I am new to python and I want to compare 2 strings, here is my code: > [start] > > import active_directory > import re > > lstUsers = [] Using "lst" or "l" as a variable name is bad news in any language; with many fonts they are too easily misread as "1st" or "1" respe

Re: couple more questions about sqlite

2006-08-18 Thread John Machin
John Salerno wrote: > [EMAIL PROTECTED] wrote: > >> 2. What's the difference between sqlite and pysqlite? Do you need both, > >> just one, or is one an older version of the same thing? > > > > To access your database from python you need both (or some alternative > > to pysqlite) > > I can understa

Re: couple more questions about sqlite

2006-08-18 Thread John Machin
John Salerno wrote: > John Machin wrote: > > > Your confusion is quite understandable. I started looking at sqlite > > when the announcement that it would be included in Python 2.5 came out. > > Puzzlement reigned. I ended up with the following up the front of my > &g

Re: couple more questions about sqlite

2006-08-19 Thread John Machin
Robert Kern wrote: > John Machin wrote: > > John Salerno wrote: > >> John Machin wrote: > >> > >>> Your confusion is quite understandable. I started looking at sqlite > >>> when the announcement that it would be included in Python 2.5 came

Re: couple more questions about sqlite

2006-08-19 Thread John Machin
Dennis Lee Bieber wrote: > > The only reason, then, to download the stand-alone SQLite package > (not the python package) would be to obtain the command line query/admin > tool. Pre-compiles binaries of the tool are available for Linux and Windows. http://www.sqlite.org/download.html

Re: How to get the ascii code of Chinese characters?

2006-08-19 Thread John Machin
many_years_after wrote: > Hi,everyone: > > Have you any ideas? > > Say whatever you know about this. > Perhaps you had better explain what you mean by "ascii code of Chinese characters". Chinese characters ("hanzi") can be represented in many ways on a computer, in Unicode as well as man

Re: Small Troll on notation of variables over time

2006-08-19 Thread John Machin
Hendrik van Rooyen wrote: [snip] > What do you guys think? The subject said it all. You should find some other way of entertaining yourself on the weekends :-) -- http://mail.python.org/mailman/listinfo/python-list

Re: How to get the ascii code of Chinese characters?

2006-08-19 Thread John Machin
many_years_after wrote: > John Machin wrote: > > many_years_after wrote: > > > Hi,everyone: > > > > > > Have you any ideas? > > > > > > Say whatever you know about this. > > > > > > > Perhaps you had bett

Re: How to get the ascii code of Chinese characters?

2006-08-19 Thread John Machin
many_years_after wrote: > hi: > > what I want to do is just to make numbers as people input some Chinese > character(hanzi,i mean).The same character will create the same > number.So I think ascii code can do this very well. > Possibly you have "create" upside-down. Could you possibly be talking

Re: sax barfs on unicode filenames

2006-10-04 Thread John Machin
Diez B. Roggisch wrote: > Edward K. Ream wrote: > > > Hi. Presumably this is a easy question, but anyone who understands the > > sax docs thinks completely differently than I do :-) > > > > > > > > Following the usual cookbook examples, my app parses an open file as > > follows:: > > > > > > > >

Re: PEP 358 and operations on bytes

2006-10-04 Thread John Machin
Paul Rubin wrote: > "John Machin" <[EMAIL PROTECTED]> writes: > > So why haven't you been campaigning for regular expression support for > > sequences of int, and for various array.array subtypes? > > regexps work on byte arrays. But not on other

Re: PEP 358 and operations on bytes

2006-10-04 Thread John Machin
Fredrik Lundh wrote: > John Machin wrote: > > > But not on other integer subtypes. If regexps should not be restricted > > to text, they should work on domains whose number of symbols is greater > > than 256, shouldn't they? > > they do: > > import re, arr

Re: Python crash when trying to generate an Excel worksheet with VBA macros

2006-10-04 Thread John Machin
Apologies in advance to anyone who gets this twice, but I posted this using Thunderbird over 11 hours ago and it's not showing up ... = On 4/10/2006 8:53 PM, dan_roman wrote: > Hi, > I developed a script with a nice interface in Tkinter that allows me to > edit some

Re: can't open chm files all of a sudden

2006-10-04 Thread John Machin
John Salerno wrote: > Keith Perkins wrote: > > > I used HTMLKit when I still used Windows, and liked it a lot. It's really > > a great HTML/PHP, etc. editor, if you can get past the front page. > > That being said (if I remember correctly) hh.exe is a part of htmlkit, and > > may have been the th

Re: can't open chm files all of a sudden

2006-10-04 Thread John Machin
John Salerno wrote: > John Machin wrote: > > > 6. Fire up a Comamnd Prompt window, and type this in: > > > > \windows\hh \python25\doc\python25.chm > > \windows\hh \windows\help\whatever.chm > > I tried this and got the same error. This is really upsetting. S

Re: How do I read Excel file in Python?

2006-10-05 Thread John Machin
kath wrote: > How do I read an Excel file in Python? > > I have found a package to read excel file, which can be used on any > platform. Hi Sudhir, So far, so good :-) > > http://www.lexicon.net/sjmachin/xlrd.htm > I installed and working on the examples, I found its printing of cell's > content

Re: How do I read Excel file in Python?

2006-10-05 Thread John Machin
[EMAIL PROTECTED] wrote: > > > >>> excel_date = 38938.0 > > > >>> python_date = datetime.date(1900, 1, 1) + > > > >>> datetime.timedelta(days=excel_date) > > > >>> python_date > > > datetime.date(2006, 8, 11) > > > > Err, that's the wrong answer, isn't it? Perhaps it shoud be > > datetime.date(190

Re: printing variables

2006-10-05 Thread John Machin
[EMAIL PROTECTED] wrote: > hi > say i have variables like these > > var1 = "blah" > var2 = "blahblah" > var3 = "blahblahblah" > var4 = "" > var5 = "...".. > > bcos all the variable names start with "var", is there a way to > conveniently print those variables out... > eg print var* ?? > i don'

Re: Pysqlite tables in RAM

2006-10-05 Thread John Machin
Ranjitha wrote: > Fredrik Lundh wrote: > > > Ranjitha wrote: > > > > > I want to store my data in a database on the disk. I also want to be > > > able to reload the tables into the RAM whenever I have a lot of disk > > > accesses and commit the changes back to the database. > > > > using the cache

<    1   2   3   4   5   6   7   8   9   10   >