Re: Donald E. Knuth in Python, cont'd

2012-04-16 Thread Tim Daneliuk
to do much, but have a mental model for how things work with a deeper understanding of things like the aforementioned makes a huge difference when working on your own code. P.S. Jon Bentley's "Programming Pearls" are also must reads for serious programmers. -- -

Re: can I overload operators like "=>", "->" or something like that?

2012-04-20 Thread Tim Chase
On 04/20/12 11:45, Kiuhnm wrote: IOW, you can't define "->" or "=>", but you could define">=" or ">>". You can also "overload" '<-' ;) Oooh, that's evil. Slick, but evil! :-D -tkc -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie, homework help, please.

2012-04-21 Thread Tim Chase
On 04/21/12 14:44, Roy Smith wrote: *** * * * First Name and Last * * ENGR 109-X * * Fall 2999 * * Format Example * * * *** You

Re: why () is () and [] is [] work in other way?

2012-04-23 Thread Tim Delaney
kes the (sensible) choice to automatically intern short strings that look like names (in the Python sense) and leave everything else up to the programmer. It's possible for the programmer to manually intern their 1GB string, but they've then got to deal with the consequences of doing so. Tim Delaney -- http://mail.python.org/mailman/listinfo/python-list

Re: why () is () and [] is [] work in other way?

2012-04-23 Thread Tim Delaney
On 24 April 2012 09:08, Devin Jeanpierre wrote: > On Mon, Apr 23, 2012 at 6:26 PM, Tim Delaney > wrote: > > And doing that would make zero sense, because it directly contradicts the > > whole *point* of "is". The point of "is" is to tell you whether or no

Re: why () is () and [] is [] work in other way?

2012-04-23 Thread Tim Delaney
On 24 April 2012 10:18, Robert Kern wrote: > On 4/24/12 1:03 AM, Tim Delaney wrote: > >> On 24 April 2012 09:08, Devin Jeanpierre > <mailto:jeanpierr...@gmail.com**>> wrote: >> >> On Mon, Apr 23, 2012 at 6:26 PM, Tim Delaney >>> <

Re: why () is () and [] is [] work in other way?

2012-04-23 Thread Tim Delaney
hednan >except TypeError: >pass >return cache.setdefault(x, x) > > I hope, again, that I've demonstrated that we don't need to > canonicalize everything just to implement interning. Except that the above is a canonicalisation function. Tim Delaney -- http://mail.python.org/mailman/listinfo/python-list

Re: from calendar import* doesn't import everything

2012-04-24 Thread Tim Chase
On 04/24/12 18:18, Rotwang wrote: Sorry if this is a stupid question, but what is up with this: >>> from calendar import* >>> Calendar Traceback (most recent call last): File "", line 1, in Calendar NameError: name 'Calendar' is not defined >>> from calendar import Calendar

Re: csv: No fields, or one field?

2012-04-25 Thread Tim Roberts
t;I admit a blank, one-field csv record just isn't very >insteresting, but isn't this a special case that ought to be >documented? But that's what you have in the first line, and the reader has returned to you a list containing one (empty) string. I just don't see your interpretation. The results are exactly what I would have expected. -- Tim Roberts, t...@probo.com Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: Half-baked idea: list comprehensions with "while"

2012-04-27 Thread Tim Wintle
On Fri, 2012-04-27 at 19:57 +1000, Chris Angelico wrote: > On Fri, Apr 27, 2012 at 7:49 PM, Miles Rout wrote: > > We have if inside list comprehensions? I didn't know that, could you provide > > an example? > > You mean like: > > [x*2+1 for x in range(10) if x%3] Or like: >>> print [ 0 if b%2=

Re: Half-baked idea: list comprehensions with "while"

2012-04-27 Thread Tim Chase
On 04/27/12 07:23, Chris Angelico wrote: On Fri, Apr 27, 2012 at 10:17 PM, John O'Hagan wrote: results = [x = expensive_call(i) for i in iterable if condition(x)] Nest it: results = [x for x in (expensive_call(i) for i in iterable) if condition(x)] While it's what I do in cases like this,

Re: HTML Code - Line Number

2012-04-27 Thread Tim Roberts
is one tweak to the HTML, and your scraping fails although the page continues to look the same. A much better plan is to use sgmllib to write yourself a mini HTML parser. You can handle "td" tags with the attributes you want, and count down until you get to the "td" tag you want. --

Re: John Carmack glorifying functional programing in 3k words

2012-05-02 Thread Tim Bradshaw
On 2012-05-02 14:44:36 +, jaialai.technol...@gmail.com said: He may be nuts But he's right: programmers are pretty much fuckwits[*]: if you think that's not true you are not old enough. [*] including me, especially. -- http://mail.python.org/mailman/listinfo/python-list

Re: John Carmack glorifying functional programing in 3k words

2012-05-02 Thread Tim Wintle
On Wed, 2012-05-02 at 17:31 +0200, Tomasz Rola wrote: > positive aura drives more people and more permamently towards you. Perhaps he > should > develop an alter ego that could stand side by side with Dalai Lama and see > which one gets more attention. Really?

Re: Why variable used in list comprehension available outside?

2012-05-02 Thread Tim Chase
On 05/02/12 19:52, Peng Yu wrote: > The following example demonstrates the variable 'v' used in the > list comprehension is accessible out site the list > comprehension. It did in Python 2.x but has been fixed in 3.x: tim@bigbox:~$ python3 Python 3.1.3 (r313:86834, Nov 28 2

Re: key/value store optimized for disk storage

2012-05-02 Thread Tim Chase
On 05/02/12 21:14, Steve Howell wrote: > I'm looking for a fairly lightweight key/value store that works for > this type of problem: > > ideally plays nice with the Python ecosystem > the data set is static, and written infrequently enough that I > definitely want *read* performance to trump a

Re: When convert two sets with the same elements to lists, are the lists always going to be the same?

2012-05-03 Thread Tim Chase
On 05/03/12 19:36, Peng Yu wrote: > list(a_set) > > When convert two sets with the same elements to two lists, are the > lists always going to be the same (i.e., the elements in each list are > ordered the same)? Is it documented anywhere? Sets are defined as unordered which the documentation[1]

Re: key/value store optimized for disk storage

2012-05-04 Thread Tim Chase
On 05/04/12 10:27, Steve Howell wrote: > On May 3, 6:10 pm, Miki Tebeka wrote: >>> I'm looking for a fairly lightweight key/value store that works for >>> this type of problem: >> >> I'd start with a benchmark and try some of the things that are already in >> the standard library: >> - bsddb >> -

Re: key/value store optimized for disk storage

2012-05-04 Thread Tim Chase
On 05/04/12 12:22, Steve Howell wrote: > Which variant do you recommend? > > """ anydbm is a generic interface to variants of the DBM database > — dbhash (requires bsddb), gdbm, or dbm. If none of these modules > is installed, the slow-but-simple implementation in module > dumbdbm will be used. >

Re: key/value store optimized for disk storage

2012-05-04 Thread Tim Chase
On 05/04/12 14:14, Emile van Sebille wrote: > On 5/4/2012 10:46 AM Tim Chase said... > > I hit a few snags testing this on my winxp w/python2.6.1 in that getsize > wasn't finding the file as it was created in two parts with .dat and > .dir extension. Hrm...must be a

Re: Open Source: you're doing it wrong - the Pyjamas hijack

2012-05-08 Thread Tim Wintle
eral bits of work. Although I don't think I've met C Anthony Risinger, his behaviour has seriously put me off the project - and if I consider using it in the future I'm going to be "pricing in" the cost of maintaining a complete local fork as part of the decision. Tim -- http://mail.python.org/mailman/listinfo/python-list

Re: Minor gripe about module names

2012-05-12 Thread Tim Chase
On 05/12/12 05:51, Chris Angelico wrote: > On Sat, May 12, 2012 at 8:41 PM, John O'Hagan > wrote: >> Not sure if this is only package-manager specific, but >> occasionally I come across a module that sounds interesting, >> install it (in my case by apt-get), and then can't find it, >> because the

Re: Python web-framework with the widest scalability?

2012-05-12 Thread Tim Chase
On 05/12/12 03:30, Alec Taylor wrote: > I am building a project requiring high performance and scalability, > entailing: Most of the frameworks are sufficiently scalable. Scalability usually stems from design decisions (architecture and algorithm) and caching, and you'll usually hit bandwidth or

Re: .py to .pyc

2012-05-13 Thread Tim Chase
On 05/13/12 16:36, Irmen de Jong wrote: > Why do you care anyway? Pyc files are an implementation detail. I could see wanting to pre-compile .pyc files for performance if they'll then be stored on a read-only medium (a CD/DVD, a RO network share, or a RO drive partition all come to mind). You can

Re: %d not working in re at Python 2.7?

2012-05-14 Thread Tim Chase
On 05/11/12 13:58, vacu wrote: > I am frustrated to see %d not working in my Python 2.7 re.search, like > this example: > (re.search('%d', "asdfdsf78asdfdf")).group(0) > Traceback (most recent call last): > File "", line 1, in > AttributeError: 'NoneType' object has no attribute 'group' >

Re: Yet another "split string by spaces preserving single quotes" problem

2012-05-14 Thread Tim Chase
On 05/13/12 16:14, Massi wrote: > Hi everyone, > I know this question has been asked thousands of times, but in my case > I have an additional requirement to be satisfied. I need to handle > substrings in the form 'string with spaces':'another string with > spaces' as a single token; I mean, if I h

Re: Open Source: you're doing it wrong - the Pyjamas hijack

2012-05-15 Thread Tim Wintle
r cases and one person rule on them is incredibly common - it's how courts across the world work, and it's how management of any team (software related or not) goes. Tim -- http://mail.python.org/mailman/listinfo/python-list

Re: %d not working in re at Python 2.7?

2012-05-15 Thread Tim Roberts
st or web, >Do you have any idea what's problem here? Yes. %d has never worked. \d+ is the right answer. It's just that simple. Where did you read that %d should work? -- Tim Roberts, t...@probo.com Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: cPython, IronPython, Jython, and PyPy (Oh my!)

2012-05-16 Thread Tim Delaney
ve" record? What is the problem if you get back a reference to an inactive record? And if there is indeed a problem, don't you already have a race condition on CPython? 1. Record is active; 2. Get reference to record through weak ref; 3. Record becomes inactive; 4. Start trying to

Re: cPython, IronPython, Jython, and PyPy (Oh my!)

2012-05-16 Thread Tim Delaney
if self.refs == 0: self.write_record() rec = record_weakrefs.get('record_name') if rec is None: rec = load_record() record_weakrefs.put('record_name', rec) with rec: do_stuff Tim Delaney -- http://mail.python.org/mailman/listinfo/python-list

SocketServer.BaseRequestHandler and __init__/super()

2012-05-17 Thread Tim Chase
Sparring with a little sandbox/test code (in 2.6, FWIW), I'm trying to set up some instance variables in my __init__ but keep hitting my head against the wall. Initially, I had something of the form class MyServer(SocketServer.BaseRequestHandler): def __init__(self, *args, **kwargs):

Re: A question of style (finding item in list of tuples)

2012-05-21 Thread Tim Chase
On 05/21/12 08:10, Steven D'Aprano wrote: > On Mon, 21 May 2012 08:37:29 -0400, Roy Smith wrote: > > [...] >> The above code works, but it occurs to me that I could use the much >> shorter: >> >> def experience_text(self): >> return dict(CHOICES).get("self.level", "???") >> >> So, the

Re: Recruiting for Python Developer - Perm

2012-05-22 Thread Tim Golden
Someone will soon pop up and tell you that job ads are unwelcome on this list and that you should post to the Python Jobs board --> http://www.python.org/community/jobs/ However, the python-uk list is probably a better place for UK-focused jobs, as long as you have something which is definitely Py

Re: problem loading matlab data with ompc and python

2012-05-24 Thread Tim Williams
On May 23, 5:10 pm, no1 wrote: > Hi, we're investigating transitioning our company from matlab to python. We > found OMPC as a MATLAB m-file-to Python translator, but we're encountering a > problem using the translated code to import MATLAB data structures into > Python. For example, when we sa

Re: Dynamic comparison operators

2012-05-24 Thread Tim Chase
On 05/24/12 09:32, Phil Le Bienheureux wrote: >> I would like to pass something like this into a function >> test(val1,val2,'>=') > > You can pass an operator as an argument to your function. > > See : > http://docs.python.org/library/operator.html And if you want to use strings, you can map them

Re: DBF records API

2012-06-01 Thread Tim Chase
On 06/01/12 15:05, Ethan Furman wrote: > MRAB wrote: >> I'd probably think of a record as being more like a dict (or an >> OrderedDict) >> with the fields accessed by key: >> >> record["name"] >> >> but: >> >> record.deleted > > Record fields are accessible both by key and by attribute --

Re: DBF records API

2012-06-01 Thread Tim Chase
On 06/01/12 19:05, Jon Clements wrote: > On 01/06/12 23:13, Tim Chase wrote: >>dbf.scatter_fields >> >> *always* trump and refer to the method. > > I did think about *trumping* one way or the other, but both *ugh*. For the record, it sounded like the OP wante

Re: DBF records API

2012-06-02 Thread Tim Chase
On 06/02/12 00:16, Ethan Furman wrote: > Tim Chase wrote: >> On 06/01/12 19:05, Jon Clements wrote: >>> On 01/06/12 23:13, Tim Chase wrote: >>>>dbf.scatter_fields >>>> >>>> *always* trump and refer to the method. >>> I did think a

Re: English version for Mémento Python 3 (draft, readers needed)

2012-06-06 Thread Tim Wintle
ed", where the French would say "livre rouge" (I believe). If you want to put an adjective after the noun (for poetical reasons etc) then there needs to be another clause. e.g. "the book, which was red" > but English hyphenation is complicated and I'm not sure. You're German and you say English hyphenation is complicated! ;-) Tim -- http://mail.python.org/mailman/listinfo/python-list

Re: English version for Mémento Python 3 (draft, readers needed)

2012-06-07 Thread Tim Wintle
that > use "British English" spellings rather than "American English"? Perhaps - "overleaf" is relatively common in documents here - while filling out forms, in exam papers, etc. However a quick search suggests the usage is in British and American dictionaries with the

Installing MySQLdb via FTP?

2012-06-07 Thread Tim Johnson
ointers to relevant discussions would suffice. -- Tim tim at tee jay forty nine dot com or akwebsoft dot com http://www.akwebsoft.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Python libraries portable?

2012-06-07 Thread Tim Johnson
ctly from my workstation via ftp to a server, and have it work, given that sys.path contained the path? -- Tim tim at tee jay forty nine dot com or akwebsoft dot com http://www.akwebsoft.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Python libraries portable?

2012-06-07 Thread Tim Johnson
* Corey Richardson [120607 15:20]: > On Thu, 7 Jun 2012 15:09:36 -0800 > Tim Johnson wrote: > > > Does this mean that I could copy my MySQLdb module directly from > > my workstation via ftp to a server, and have it work, given that > > sys.path conta

Re: Python libraries portable?

2012-06-07 Thread Tim Johnson
* Corey Richardson [120607 17:01]: > On Thu, 7 Jun 2012 16:43:26 -0800 > Tim Johnson wrote: > > > So what to do if I can't install from the command line? > > I could use python's external command tools like > > subprocess.call(), but am not sure what

Re: Installing MySQLdb via FTP?

2012-06-08 Thread Tim Johnson
embarassment because I should have though of it myself) "Ssh to your client and from the client ssh hostmonster" and therein is the solution. I guess I would have thought of it in the next few days whilst visiting the little boys room or mowing the lawn, but Kudos to Rod Person for his solution. -- Tim tim at tee jay forty nine dot com or akwebsoft dot com http://www.akwebsoft.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Installing MySQLdb via FTP?

2012-06-09 Thread Tim Johnson
* Corey Richardson [120608 11:39]: > On Fri, 8 Jun 2012 09:55:23 -0800 > Tim Johnson wrote: > > > See the thread titled "Python libraries portable?" you will note > > that Corey Richardson makes the statement that MySQLdb is a C > > extension. I acce

Re: Installing MySQLdb via FTP?

2012-06-09 Thread Tim Johnson
* Tim Johnson [120609 07:30]: > > > > http://mysql-python.hg.sourceforge.net/hgweb/mysql-python/MySQLdb-2.0/file/566baac88764/src > > > > It definitely is. The C extension part is the '_mysql' module, here it > > is /usr/lib64/python2.7/site-packages/_mys

Re: which one do you prefer? python with C# or java?

2012-06-09 Thread Tim Johnson
pers crazy. Just mention 'newlisp' and watch the spittle fly. On the other hand, clojure and C# have a much larger user base. (small-user-base) is why I don't use newlisp or rebol for any new projects. MTCW -- Tim tim at tee jay forty nine dot com or akwebsoft dot co

Re: which one do you prefer? python with C# or java?

2012-06-12 Thread Tim Johnson
"Common Lisp" is not to Lisp what Ansi C is to C. IOWS, there does remain incompatibilities between different Common Lisp implementations. Whereas Ansi C is pretty strict as code portability (or was so when I was working in it) -- Tim tim at tee jay forty nine dot com or akwebsoft dot com http://www.akwebsoft.com -- http://mail.python.org/mailman/listinfo/python-list

Re: [newbie] Equivalent to PHP?

2012-06-13 Thread Tim Chase
On 06/13/12 17:44, Gilles wrote: > On 13 Jun 2012 22:16:51 GMT, Steven D'Aprano > wrote: >> Surely the obvious answer is that a framework offers the benefit that you >> don't have to write the application from scratch. > > Yes, but between receiving the query and sending the response, what > fea

Re: Why is this so much faster?

2011-06-02 Thread Tim Delaney
ram)) totalSum = sum(intermediateResult) # calculate rms return math.sqrt(totalSum / self.Area()) BTW, the following might (or might not) be faster again: # Pass a generator expression to sum() instead of manually summing def RMSBand(self, histogram): """Calculates the root-mean-squared value for the given colour stream histogram.""" totalSum = sum(h*(i**2) for (i, h) in enumerate(histogram)) # calculate rms return math.sqrt(totalSum / self.Area()) Tim Delaney -- http://mail.python.org/mailman/listinfo/python-list

Re: Why is this so much faster?

2011-06-03 Thread Tim Delaney
On 3 June 2011 19:05, Thomas Jollans wrote: > On Friday 03 June 2011, it occurred to Tim Delaney to exclaim: > > > Probably the biggest savings are list creating and jumping between C- and > > > Python-functions during the map call. The lambda is a Python function, > &

Re: Newby Python help needed with functions

2011-06-03 Thread Tim Chase
On 06/03/2011 09:42 AM, Cathy James wrote: I need a jolt here with my python excercise, please somebody!! How can I make my functions work correctly? I tried below but I get the following error: if f_dict[capitalize]: KeyError: def capitalize (s): Here you define the variable "capitalize" as

Re: how to inherit docstrings?

2011-06-10 Thread Tim Chase
On 06/09/2011 01:22 AM, Eric Snow wrote: Sometimes when using class inheritance, I want the overriding methods of the subclass to get the docstring of the matching method in the base class. You can do this with decorators (after the class definition), with class decorators, and with metaclasses

Re: Unsupported operand type(s) for +: 'float' and 'tuple'

2011-06-10 Thread Tim Chase
On 06/10/2011 05:30 AM, Francesc Segura wrote: Hello all, I'm new to this and I'm having problems on summing two values at python. I get the following error: Traceback (most recent call last): File "C:\edge-bc (2).py", line 168, in if (costGG<= cost + T0): TypeError: unsupported operand

Re: Question About Command line arguments

2011-06-10 Thread Tim Chase
On 06/10/2011 12:58 PM, Mark Phillips wrote: How do I write my script so it picks up argument from the output of commands that pipe input into my script? You can check if os.isatty(sys.stdin): # <-- this check do_stuff_with_the_terminal() else: read_options_from_stdin() -tkc -

Re: Question About Command line arguments

2011-06-10 Thread Tim Chase
On 06/10/2011 04:00 PM, Benjamin Kaplan wrote: On Fri, Jun 10, 2011 at 11:31 AM, Tim Chase if os.isatty(sys.stdin): #<-- this check Any reason for that over sys.stdin.isatty()? my knowledge of os.isatty() existing and my previous lack of knowledge about sys.stdin.isatty() :) -

Re: Python Card alternatives?

2011-06-11 Thread Tim Johnson
but my suggestion would be: 1)Get into one of the rebol communities - probably thru altme. 2)You will find that most rebol programmers work in other languages also, and quite a few (like me) in python. 3)You are likely to get a lot of ideas there. cheers -- Tim tim at johnsons-we

Re: __dict__ is neato torpedo!

2011-06-12 Thread Tim Chase
On 06/11/2011 08:32 PM, Andrew Berg wrote: I'm pretty happy that I can copy variables and their value from one object's namespace to another object's namespace with the same variable names automatically: b.__dict__.update(a.__dict__) The reason I'm posting this is to ask what to watch out for w

Re: Function declarations ?

2011-06-12 Thread Tim Roberts
n habits, not C habits. What construct led you to think you need to declare a function like that? This code, for example, works fine: def g(): return f() def f(): return 3 print g() The name "f" does not have to be defined until the function "g&

Re: Keyboard Layout: Dvorak vs Colemak: is it Worthwhile to Improve the Dvorak Layout?

2011-06-12 Thread Tim Roberts
ing in the design of the QWERTY layout is an urban legend. Once your fingers have the mapping memorized, the actual order is irrelevent. Studies have shown that even a strictly alphabetical layout works perfectly well, once the typist is acclimated. -- Tim Roberts, t...@probo.com Providenza &

dummy, underscore and unused local variables

2011-06-13 Thread Tim Johnson
from the python interpreter if I do >>> help(_) I get Help on bool object: class bool(int) | bool(x) -> bool .. I'd welcome comments on this as well. :) I expect to be edified is so many ways, some of them unexpected. thanks -- Tim tim at johnsons-web dot com or ak

Re: dummy, underscore and unused local variables[thanks]

2011-06-13 Thread Tim Johnson
* Tim Johnson [110613 07:58]: > > :) I expect to be edified is so many ways, some > of them unexpected. Thanks for all of the responses and for those which might come later. I'm going to stick with the convention of using a variable beginning with `dummy' and stick

Re: split long string in two code lines

2011-06-13 Thread Tim Chase
On 06/13/2011 04:55 PM, Tycho Andersen wrote: On Mon, Jun 13, 2011 at 11:31:29PM +0200, Tracubik wrote: 4print "this is a very long string that i'm going to write 5 here, it'll be for sure longer than 80 columns" Is there a better way to split the string? There is! Python (as C) c

Re: split long string in two code lines

2011-06-13 Thread Tim Chase
On 06/13/2011 05:38 PM, Chris Angelico wrote: On Tue, Jun 14, 2011 at 8:33 AM, Tim Chase wrote: print ("this is not " "such a huge line " "even though it has " "lots of text in it." ) print ( "this is not " "

Re: Keyboard Layout: Dvorak vs Colemak: is it Worthwhile to Improve the Dvorak Layout?

2011-06-15 Thread Tim Roberts
Dennis Lee Bieber wrote: > >On Sun, 12 Jun 2011 21:30:43 -0700, Tim Roberts >declaimed the following in gmane.comp.python.general: > >> More than that, any layout "more efficient" than QWERTY is practically >> meaningless. The whole "intentional inef

Re: integer to binary 0-padded

2011-06-15 Thread Tim Chase
On 06/15/2011 07:33 AM, Daniel Rentz wrote: Am 15.06.2011 14:29, schrieb Olivier LEMAIRE: Hi there, I've been looking for 2 days for a way to convert integer to binary number 0-padded, nothing... I need to get numbers converted with a defined number of bits. For example on 8 bits 2 = 0010

Trapping MySQLdb warnings

2011-06-15 Thread Tim Johnson
## replace with log(e) What else needs to be done? TIA -- Tim tim at johnsons-web dot com or akwebsoft dot com http://www.akwebsoft.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Trapping MySQLdb warnings

2011-06-15 Thread Tim Johnson
* geremy condra [110615 18:03]: > On Wed, Jun 15, 2011 at 6:58 PM, Tim Johnson wrote: > > Using Python 2.6.5 on linux. > > > > When using MySQLdb I am getting warnings printed to stdout, but I would > > like to trap, display and log those warnings. <..

Re: Trapping MySQLdb warnings

2011-06-16 Thread Tim Johnson
* Tim Johnson [110615 18:53]: > * geremy condra [110615 18:03]: > > On Wed, Jun 15, 2011 at 6:58 PM, Tim Johnson wrote: > > > Using Python 2.6.5 on linux. > > > > > > When using MySQLdb I am getting warnings printed to stdout, but I would > > >

Re: Trapping MySQLdb warnings

2011-06-16 Thread Tim Johnson
* Terry Reedy [110616 10:50]: > On 6/16/2011 11:55 AM, Tim Johnson wrote: > >* Tim Johnson [110615 18:53]: > >>* geremy condra [110615 18:03]: > >>>On Wed, Jun 15, 2011 at 6:58 PM, Tim Johnson wrote: > >>>>Using Python 2.6.5 on linux. > >

Re: Trapping MySQLdb warnings

2011-06-16 Thread Tim Johnson
the instantiation of the 'parent' connection object or the cursor object itself. -- Tim tim at johnsons-web dot com or akwebsoft dot com http://www.akwebsoft.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Trapping MySQLdb warnings

2011-06-16 Thread Tim Johnson
* srinivas hn [110616 11:06]: > Hi Tim, > > Use this method it will sort tour problem. > > def do_query(insert_query): >import warnings > > with warnings.catch_warnings(): > warnings.simplefilter('error', MySQLdb.Warning) >

Re: Trapping MySQLdb warnings

2011-06-16 Thread Tim Johnson
* srinivas hn [110616 11:06]: > Hi Tim, > >import warnings > > with warnings.catch_warnings(): > warnings.simplefilter('error', MySQLdb.Warning) > try: > cursor.execute(insert_query) > conn.commit() > return &#x

Re: Run Python script from JS

2011-06-16 Thread Tim Roberts
Gnarlodious wrote: > >Is there any way to call a Py script from Javascript in a webpage? It is POSSIBLE to install Python as an active language, so that Internet Explorer lets you write

Re: How do you copy files from one location to another?

2011-06-17 Thread Tim Golden
On 17/06/2011 06:06, John Salerno wrote: Based on what I've read, it seems os.rename is the proper function to use, but I'm a little confused about the syntax. Basically I just want to write a simple script that will back up my saved game files when I run it. So I want it to copy a set of files/d

Re: SQL Server 2008R2 databases via Python 2.7 and Windows XP and higher

2011-06-17 Thread Tim Golden
On 17/06/2011 16:01, pyt...@bdurham.com wrote: Looking for some real-world advice on what is the best way to access MS SQL Server 2008R2 databases via Python 2.7 running under Windows XP, Vista, and Windows 7 and Windows Server 2005 and 2008. Based on my research, here's my list of choices: mxODB

Re: Run Python script from JS

2011-06-17 Thread Tim Roberts
Hansmeet Singh wrote: > for xhtml wouldnt the syntax be

Re: What's the best way to write this base class?

2011-06-18 Thread Tim Chase
On 06/18/2011 05:55 AM, bruno.desthuilli...@gmail.com wrote: On 18 juin, 06:17, John Salerno wrote: class Character: base_health = 50 base_resource = 10 def __init__(self, name): self.name = name self.health = base_health self.resource = base_resource

Re: Strategy to Verify Python Program is POST'ing to a web server.

2011-06-18 Thread Tim Roberts
upload page. Any remedy? The amount of protection you need to take depends on what the cost of interference will be, and how likely it is to be spoofed. How will people find out about your interface? If they found out about it, what would they gain by spoofing it? -- Tim Roberts, t...@probo.com

Re: NEED HELP-process words in a text file

2011-06-18 Thread Tim Chase
On 06/18/2011 06:21 PM, Cathy James wrote: freq = [] #empty dict to accumulate words and word length While you say you create an empty dict, using "[]" creates an empty *list*, not a dict. Either your comment is wrong or your code is wrong. :) Given your usage, I presume you want a di

opening a file

2011-06-19 Thread Tim Hanson
Using linux and Python 2.6, learning how to work with files from a Windows oriented textbook: This works: infile=open('/foo/bar/prog/py_modules/this_is_a_test','r') This doesn't: infile=open('~/prog/py_modules/this_is_a_test','r') Can't I work with files using Unix expressions? -- http://mail.

Re: Is the mailing list to usenet gateway borked?

2011-06-20 Thread Tim Chase
On 06/19/2011 08:41 PM, Steven D'Aprano wrote: The last couple of messages on this list show up fine on the mailman archives, but are empty posts on comp.lang.python. Is there a problem with the mail -> usenet gateway? I haven't noticed any issues. I tend to send via email (python-list@pyth

Parsing a dictionary from a format string

2011-06-20 Thread Tim Johnson
e a python library that would provide an optimal way to parse from S the following {'latitude':"",'longitude':""} ? Thanks -- Tim tim at johnsons-web dot com or akwebsoft dot com http://www.akwebsoft.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Parsing a dictionary from a format string

2011-06-20 Thread Tim Johnson
* Tim Johnson [110620 10:28]: > Currently using python 2.6, but am serving some systems that have > older versions of python (no earlier than. > Question 1: > With what version of python was str.format() first implemented? > Question 2: > Given the following string: >

Re: Parsing a dictionary from a format string

2011-06-20 Thread Tim Johnson
* Hans Mulder [110620 12:15]: > On 20/06/11 20:14:46, Tim Johnson wrote: > >Currently using python 2.6, but am serving some systems that have > >older versions of python (no earlier than. > >Question 1: > > With what version of python was str.format() first implemen

Re: Parsing a dictionary from a format string

2011-06-20 Thread Tim Johnson
* Tim Johnson [110620 13:00]: > > I think later today, I will run some time tests using the `re' > module as well as your function and the one above. OK: Functions follow: def grabBetween(src,begin,end): """Grabs sections of text between `begin' and `end

Re: new string-formatting preferred? (was "What is this syntax ?")

2011-06-20 Thread Tim Chase
On 06/20/2011 05:19 PM, Ben Finney wrote: “This method of string formatting is the new standard in Python 3.0, and should be preferred to the % formatting described in String Formatting Operations in new code.” http://docs.python.org/library/stdtypes.html#str.format> Is there a good link to a

Re: parse date string having "EDT"

2011-06-20 Thread Tim Roberts
get error Right, because strptime doesn't support %Z. You'll have to handle that yourself and remove it before conversion. -- Tim Roberts, t...@probo.com Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: new string-formatting preferred? (was "What is this syntax ?")

2011-06-21 Thread Tim Chase
On 06/20/2011 09:17 PM, Terry Reedy wrote: On 6/20/2011 8:46 PM, Tim Chase wrote: On 06/20/2011 05:19 PM, Ben Finney wrote: “This method of string formatting is the new standard in Python 3.0, and should be preferred to the % formatting described in String Formatting Operations in new code

Re: Handling import errors

2011-06-21 Thread Tim Johnson
like any other variable, as far as I know and far as I have done. -- Tim tim at johnsons-web dot com or akwebsoft dot com http://www.akwebsoft.com -- http://mail.python.org/mailman/listinfo/python-list

Re: new string-formatting preferred? (was "What is this syntax ?")

2011-06-21 Thread Tim Chase
On 06/21/2011 05:19 PM, Terry Reedy wrote: On 6/21/2011 7:33 AM, Tim Chase wrote: http://docs.python.org/library/stdtypes.html#str.format> Is there a good link to a thread-archive on when/why/how .format(...) became "preferred to the % formatting"? That is a controversial sta

Re: User Authentication

2011-06-22 Thread Tim Golden
On 22/06/2011 14:34, Anurag wrote: Hi All, I am working on application which needs to do a authentication against LDAP, if LDAP not installed then local system account (administrator user in windows and root user in Linux). This should work on both Windows and Linux. Which library I should use

Re: what happens inside?

2011-06-22 Thread Tim Rowe
eful to be sure that something can't change. In particular, efficient dictionary implementations need the keys to be immutable, because it you change a key it /really/ fouls up the look-up. -- Tim Rowe -- http://mail.python.org/mailman/listinfo/python-list

doing cross platform file work

2011-06-22 Thread Tim Hanson
Thanks for your responses to my student question about using OS paths in Python. For the more general case, I am a Linux user interested in making my scripts platform neutral, which would include Linux, Unix (including Mac), and Windows. I have looked at the python.org os segment and didn't ge

Re: connect windows share

2011-06-22 Thread Tim Golden
On 22/06/2011 19:38, Travis Altman wrote: I want to be able to connect to a windows share via python. My end goal is to be able to recursively search through windows shares. I want to do this in Linux as well. So given a share such as \\computer\test I would like to search through the test dir

Re: parse date string having "EDT"

2011-06-22 Thread Tim Roberts
Ben Finney wrote: >Tim Roberts writes: > >> Right, because strptime doesn't support %Z. > >Au contraire: > >Support for the %Z directive is based on the values contained in >tzname and whether daylight is true. Because of this, it is >platform-spec

Re: How can I speed up a script that iterates over a large range (600 billion)?

2011-06-22 Thread Tim Roberts
ed to me on my own. Using your hint, I was able to write a 16-line script that also produced a result instantaneously. Very satisfying. I'm going to save that one... -- Tim Roberts, t...@probo.com Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python 2.7 and cmd on Windows 7 64 (files lost)

2011-06-23 Thread Tim Golden
On 23/06/2011 07:33, Michel Claveau - MVP wrote: Hi! (sorry for my bad english...) On Win 7 64 bits: Command-Line CD \Python27 dir C:\Windows\System32\SoundRecorder.exe:==> OK Python.exe import os os.system("dir C:\\Windows\\System32\\SoundRecorder.exe") ==> Do not found t

Re: User Authentication

2011-06-23 Thread Tim Golden
On 23/06/2011 06:02, Anurag wrote: On Jun 22, 7:01 pm, Adam Tauno Williams wrote: On Wed, 2011-06-22 at 06:34 -0700, Anurag wrote: Hi All, I am working on application which needs to do a authentication against LDAP, if LDAP not installed then local system account (administrator user in windo

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