Re: "Fuzzy" Counter?

2014-09-23 Thread Tim Chase
On 2014-09-23 05:34, Miki Tebeka wrote: > Before I start writing my own. Is there something like > collections.Counter (fore frequencies) that does "fuzzy" matching? > > Meaning x is considered equal to y if abs(x - y) < epsilon. (x, y > and my case will be numpy.array). Not that I know of -- the

pip install virtualenvwrapper complaining there's no module named "core"

2014-09-26 Thread Tim Chase
/bdist.linux-i686/egg/setuptools/dist.py", line 223, in __init__ File "/usr/local/lib/python2.6/distutils/dist.py", line 270, in __init__ self.finalize_options() File "build/bdist.linux-i686/egg/setuptools/dist.py", line 256, in finalize_options File "

Re: Recommended hosting

2014-10-02 Thread Tim Golden
On 02/10/2014 14:30, writeson wrote: > Hi all, > > I'd like to build a web site for myself, essentially a "vanity" web > site to show off whatever web development skills I have, and perhaps > do some blogging. I'm a Python developer, so I'd like to develop the > site with the following stack: > >

Re: Python 3.4.1 on W2K?

2014-10-06 Thread Tim Golden
On 06/10/2014 01:04, Pal Acreide wrote: > Hi, I'm a lurker here and enjoy the back-and-forth, especially among the > experts among you. > > My question is this: I have Python 3.4.1 installed on 64-bit Win 7 Home > Premium, and on 32-bit Win 7 Pro running on a virtual machine (Oracle > VirtualBox)

Re: [OT] spelling colour / color was Re: Toggle

2014-10-09 Thread Tim Delaney
o have some methods use "z" and others "s" in the same package. So since I'm currently working for a US company I have to consciously remind myself to use their abominations ;) Tim Delaney -- https://mail.python.org/mailman/listinfo/python-list

Re: Python 3.4.1 on W2K?

2014-10-11 Thread Tim Roberts
into a 16-bit app is pretty >impressive. Actually, Microsoft made it pretty easy to call 32-bit DLLs in a 16-bit process and vice versa. That's why many of us were surprised when they did not provide the same capability in the 32/64 transition. -- Tim Roberts, t...@probo.com Providenza &

Re: while loop - multiple condition

2014-10-12 Thread Tim Chase
On 2014-10-12 22:16, Marko Rauhamaa wrote: > is equivalent with > > while ans.lower()[0] != 'y': > ans = input('Do you like python?') And still better improved with while ans[:1].lower() != 'y': ans = input('Do you like python?') in the event that len(ans)==0 (a situation whi

Re: How to select every other line from a text file?

2014-10-13 Thread Tim Chase
On 2014-10-13 10:38, Rff wrote: > Hi, > I have a text file. Now it is required to select every other line > of that text to generate a new text file. I have read through > Python grammar, but still lack the idea at the beginning of the > task. Could you tell me some methods to get this? You could

Re: How to select every other line from a text file?

2014-10-13 Thread Tim Chase
On 2014-10-13 14:45, Joel Goldstick wrote: > Not apropos to the OP, but what came up in my mind was to write a > generator function that returns every other line. This would > separate the reading from the writing code. You mean like offset = 0 # or 1 if you prefer for line in itertools.isli

Re: Flush stdin

2014-10-18 Thread Tim Chase
On 2014-10-18 17:55, Nobody wrote: > On Fri, 17 Oct 2014 12:38:54 +0100, Empty Account wrote: > > > I am using netcat to listen to a port and python to read stdin > > and print to the console. > > > > nc -l 2003 | python print_metrics.py > > > > sys.stdin.flush() doesn’t seem to flush stdin, >

Re: (-1)**1000

2014-10-22 Thread Tim Chase
On 2014-10-22 12:29, Peter Otten wrote: > That looks like log(a) while a parity check takes constant time: > > $ python3 -m timeit -s 'a = 10**10' 'a & 1' > 1000 loops, best of 3: 0.124 usec per loop > $ python3 -m timeit -s 'a = 10**100' 'a & 1' > 1000 loops, best of 3: 0.124 usec per loo

Re: Processing a file using multithreads

2011-09-09 Thread Tim Roberts
ithreading is not a win. The threads will all compete with each other for the disk. -- Tim Roberts, t...@probo.com Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: optionparse: how to add a line break to the help text

2011-09-10 Thread Tim Chase
On 09/10/11 20:54, Gelonida N wrote: Unfortunately the help text is formatted using textwrap, which presumes that the entire text is a single paragraph. To get paragraphs in the help text, you'll need to write an IndentedHelpFormatter subclass that splits the text on "\n\n", textwraps the split

Re: optionparse: how to add a line break to the help text

2011-09-11 Thread Tim Chase
On 09/10/11 22:07, Gelonida N wrote: http://bytes.com/topic/python/answers/734066-how-output-newline-carriage-return-optparse It works (of course ;-) ) like a charm. Good to know, that I'm not the only one who want's to structure the help text a little nicer. Considering, that you posted the s

Re: Idioms combining 'next(items)' and 'for item in items:'

2011-09-11 Thread Tim Chase
On 09/10/11 14:36, Terry Reedy wrote: 1. Process first item of an iterable separately. A traditional solution is a flag variable that is tested for each item. first = True for item in iterable: if first: first = False else: (I have seen code like this posted on thi

Re: using python in web applications

2011-09-11 Thread Tim Roberts
s >becoming more popular to. Well, that's a religious argument. Personally, I've always been confused by the draw of MySql. From the very beginning, Postgres has always been more powerful, more reliable, more standard-compliant, and more professional. -- Tim Roberts, t...@probo.com

Need some experience

2011-09-13 Thread Tim Hanson
I have been a desktop Linux user for better than eleven years, as a hobby. Back when we still did most of our computing on desktops I even set up a rudimentary server setup in my home. Nothing fancy or anything, but I was proud of it and of the fact that it was built Microsoft free. I have no

Re: Need some experience

2011-09-13 Thread Tim Hanson
On Tuesday, September 13, 2011 01:37:05 pm Thomas Jollans wrote: > On 13/09/11 22:25, Tim Hanson wrote: > > I have been a desktop Linux user for better than eleven years, as a > > hobby. Back when we still did most of our computing on desktops I even > > set up a rudimenta

Re: Need some experience

2011-09-13 Thread Tim Hanson
On Tuesday, September 13, 2011 01:37:05 pm Thomas Jollans wrote: > On 13/09/11 22:25, Tim Hanson wrote: > > I have been a desktop Linux user for better than eleven years, as a > > hobby. Back when we still did most of our computing on desktops I even > > set up a rudimenta

Re: Need some experience

2011-09-13 Thread Tim Hanson
On Tuesday, September 13, 2011 02:36:52 pm Christian Heimes wrote: > Am 13.09.2011 22:52, schrieb Tim Hanson: > > That's not a bad idea. From the past I know that bug fixing is a great > > way to learn a language. If you know a specific site to key in on, feel >

Re: Need some experience

2011-09-13 Thread Tim Hanson
On Tuesday, September 13, 2011 06:12:27 pm Terry Reedy wrote: > >> It's a great idea. We are always looking for volunteers that help the > >> community to reduce the amount of open bugs. The bug tracker at > >> http://bugs.python.org/ even has a category for beginners. You just have > >> to search

Reconciling os.path.getmtime vs ftp.sendcmd('MDTM filename')

2011-09-14 Thread Tim Johnson
shtml') 1311648420.0 And I use >> ftp.sendcmd('MDTM 400.shtml') ## for the remote server '213 20110726004703' My question is how to compare the two outputs? Pointers to documentation and other resources are invited. thanks -- Tim tim at johnsons-web dot c

Re: Reconciling os.path.getmtime vs ftp.sendcmd('MDTM filename')

2011-09-14 Thread Tim Johnson
* Chris Rebert [110914 16:46]: > On Wed, Sep 14, 2011 at 12:50 PM, Tim Johnson wrote: > > I have written a class that uses ftplib.FTP as the parent. > > I need to reconcile the modified time of a workstation file with > > that same filename on a remote server. > > Let&

Re: Turkic I and re

2011-09-15 Thread Tim Chase
On 09/15/11 09:06, MRAB wrote: It's somewhat unlikely that Unicode will become locale-dependent in Python because it would cause problems; you don't want: "i".upper() == "I" to be maybe true, maybe false. An option would be to specify whether it should be locale-dependent. There have b

Re: Reconciling os.path.getmtime vs ftp.sendcmd('MDTM filename')

2011-09-15 Thread Tim Johnson
* Tim Johnson [110914 18:18]: > * Chris Rebert [110914 16:46]: > > On Wed, Sep 14, 2011 at 12:50 PM, Tim Johnson wrote: > > > I have written a class that uses ftplib.FTP as the parent. > > > I need to reconcile the modified time of a workstation file with > >

Re: Using tuples to eliminate multiple dict values

2011-09-16 Thread Tim Chase
On 09/16/11 13:47, Benshep wrote: I need a dictionary that returns the same value for multiple keys. i.e. (1)>>> dict = { (1,2,3) : 'text' , (5,6,7) : 'other text' } (2)>>>dict[1] (3) 'text' I cant figure out what i need on line 2 to make this scenario work. Is there a simple way to check i

Re: Suggested coding style

2011-09-24 Thread Tim Johnson
From my observance, python has developed with care and prudence. I have a feeling (instinctive of course), that Guido van Rossum is/was more likely to say 'no' to a request for a new implementation that Rasmus Lerdorf. MTCW -- Tim tim at tee jay forty nine dot com or akwebsof

Re: Suggested coding style

2011-09-24 Thread Tim Johnson
t; >>   more senior pythonists on this matter. > >> > > The documentation says "New in version 2.2.2". > > But zfill has been in the string module for a lot longer. :) Like I said. See timestamp. http://mail.python.org/pipermail/python-bugs-list/1999-July/000

Re: Python Mixins

2011-09-24 Thread Tim Chase
On 09/24/11 17:41, rantingrick wrote: On Sep 24, 3:57 am, Steven D'Aprano wrote: class StandardTestMixin: def test_requires_one_argument(self): self.assertRaises(TypeError, self.func) def test_has_docstring(self): self.assertTrue(self.func.__doc__) And this is ano

Re: Suggested coding style

2011-09-25 Thread Tim Johnson
g must implement that method. That's a > waste. I'm not sure what you mean. I've written my own `split' function. I don't believe that there would be any conflict if you wrote your own `zfill' function. Or if there would be, I'd want to know be

Re: Suggested coding style

2011-09-25 Thread Tim Johnson
this in principle, but > it doesn't really matter for strings. > > The situation I see with something like zfill as-a-method is that it > has nearly negligible benefit (less imports vs function?) and some > detriment. So I would conclude it should not exist. Other people loo

Re: Suggested coding style

2011-09-25 Thread Tim Johnson
* Chris Angelico [110925 13:50]: > On Mon, Sep 26, 2011 at 4:54 AM, Petite Abeille > wrote: > > > > On Sep 25, 2011, at 8:46 PM, Tim Johnson wrote: > > > >>  Why does it suck? And why do people say 'suck' so much, especially in > >>

Re: Hierarchical commnd line parsing / help texts

2011-09-26 Thread Tim Chase
On 09/26/11 13:57, Prasad, Ramit wrote: It seems it's time to start reading about argparse FYI, it only appears on Python 2.7+ However I believe it can be uneventfully copied and run under several versions earlier (likely back to 2.5, perhaps to 2.4 -- I no longer have 2.4 at my fingertips t

Re: Multiplication error in python

2011-09-27 Thread Tim Daneliuk
http://rebertia.com > > if i put i += 2*a it returns 155. Are you sure you don't have something indented incorrectly? How about a plain text copy of your program (without the interactive stuff) so we can run it independently... -- Tim Daneliuk tun...@tundraware.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Multiplication error in python

2011-09-27 Thread Tim Roberts
Is there any different multiplication pattern in python? My guess is that you actually typed p=3*a instead of p=2*a That produces 45. -- Tim Roberts, t...@probo.com Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Unittest testing assert*() calls rather than methods?

2011-09-28 Thread Tim Chase
While I asked this on the Django list as it happened to be with some Django testing code, this might be a more generic Python question so I'll ask here too. When performing unittest tests, I have a number of methods of the form def test_foo(self): data = ( (item1, result1),

Re: Suggested coding style

2011-09-28 Thread Tim Johnson
ined by calling someones belief a joke? My wife and I are devout christians, but not fundamentalist. We would not take rantingrick too seriously. If _you_ take him seriously, you're just giving him 'street cred'. -- 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: Unittest testing assert*() calls rather than methods?

2011-09-28 Thread Tim Chase
On 09/28/11 19:52, Roy Smith wrote: In many cases, there's only two states of interest: 1) All tests pass 2) Anything else Whether for better or worse, at some places (such as a previous employer) the number (and accretion) of test-points is a marketing bullet-point for upgrades & new relea

Re: syntax enhancement

2011-10-05 Thread Tim Chase
On 10/04/11 20:45, Terry Reedy wrote: On 10/4/2011 9:50 AM, Valiev Sergey wrote: - `[]` - used for list comprehension, - `()` - used for generators, - `[start:stop]` / `[start:stop:step]` - used for slices. The idea is to use `(start:stop)` / `(start:stop:step)` as 'lazy evaluated' slices (like

Re: urllib and parsing

2011-10-06 Thread Tim Roberts
ttp://lalal.hhdik/' values = {'password' : 'password', 'Entra' : 'Entra' } data = urllib.urlencode(values) req = urllib2.Request(url, data) response = urllib2.urlopen(req) the_page = response.read() -- Tim Roberts, t...@probo.com Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: httplib2 download forbidden

2011-10-06 Thread Tim Roberts
king for me. Do you have some kind of proxy in the way? -- Tim Roberts, t...@probo.com Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: Deleting files on a shared server

2011-10-07 Thread Tim Golden
On 07/10/2011 02:14, Josh English wrote: This is a follow-up to some questions I posted a month or two ago. I have two programs running on various Windows XP boxes, sharing several resource files on a Windows 2003 server. It's a mapped drive on the workstations to a shared folder. I am using a l

Re: Thread handling issue

2011-10-07 Thread Tim Golden
On 07/10/2011 09:29, Paul wrote: I'm wondering what the best solution for this problem is. I've got a wxpython app, in one part a user makes some selections then opens a dialog to select where to output. At which point the app starts a thread processing their selection while they're choosing an

Testing properties that are date-related

2011-10-07 Thread Tim Chase
Are there best practices for testing dates that are properties which take the current date into consideration? I have something like class Foo: def _get_year_range(self): return (self._min_year, self._max_year) def _set_year_range(self, year): if isinstance(year, tuple):

Re: Testing properties that are date-related

2011-10-07 Thread Tim Chase
On 10/07/11 07:38, Peter Otten wrote: Are there best practices for testing dates that are properties which take the current date into consideration The problem is that the behavior of the window_date function depends on the current date (the function makes a guess about adding the century if the

Re: Thread handling issue

2011-10-07 Thread Tim Golden
On 07/10/2011 11:15, Paul wrote: My first thought was to use a flag but wouldn't the new thread see the cancel flag and stop as well? I could set it back but then any other threads might have been busy and not seen it while the flag was on. The thread goes through the selection and does a few qu

Re: Testing properties that are date-related

2011-10-07 Thread Tim Chase
On 10/07/11 09:45, Ethan Furman wrote: Tim Chase wrote: On 10/07/11 07:38, Peter Otten wrote: def setUp(self): foo.window_date = functools.partial(foo.window_date, around=date(2011, 1, 1)) it worked like a charm. Another option is injection: import foo def window_date

Re: Is it possible to create C-style "main" function in Python? (for teaching purposes)

2011-10-08 Thread Tim Roberts
n in COBOL was conceptually ahead of its time. It makes you THINK about your data structures more than, say "struct" in C. -- Tim Roberts, t...@probo.com Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: Usefulness of the "not in" operator

2011-10-08 Thread Tim Roberts
hesis: If you need to look up whether they're >necessary or not, they are :-) Amen. +1 -- Tim Roberts, t...@probo.com Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: Working with spreadsheet files

2011-10-09 Thread Tim Golden
On 09/10/2011 07:30, Yaşar Arabacı wrote: Does anyone know a good tutorial about working with Spreadsheet files (e.g. excel files) with Python. I have found xlutils, but there doesn't seem to be any documentation or tutorial about it that I could find. So, any suggestions? http://www.python-exc

Re: Thread handling issue

2011-10-09 Thread Tim Golden
On 08/10/2011 11:51, Paul wrote: I think I'll wait for the user to actually make a change after cancelling the output selection, in case they go straight back without making changes. If they make a change I think I'll try what you suggested and send off a new thread, and send an event to the prev

DRY functions with named attributes used as default arguments

2011-10-09 Thread Tim Chase
My intent is to have a function object something like def foo(arg1, arg2=foo.DEFAULT): return int(do_stuff(arg1, arg2)) foo.SPECIAL = 42 foo.MONKEY = 31415 foo.DEFAULT = foo.SPECIAL so I can call it with either result = foo(myarg) or result = foo(myarg, foo.SPECIAL) However I

Re: DRY functions with named attributes used as default arguments

2011-10-09 Thread Tim Chase
On 10/09/11 10:37, Steven D'Aprano wrote: My intent is to have a function object something like def foo(arg1, arg2=foo.DEFAULT): return int(do_stuff(arg1, arg2)) foo.SPECIAL = 42 foo.MONKEY = 31415 foo.DEFAULT = foo.SPECIAL What's the purpose of having both foo.SPECIAL an

Re: Usefulness of the "not in" operator

2011-10-10 Thread Tim Roberts
es, we do, because I'm always reading code from other people that didn't follow that rule. -- Tim Roberts, t...@probo.com Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python library for generating SQL queries [selects, alters, inserts and commits]

2011-10-11 Thread Tim Chase
On 10/11/11 07:08, Alec Taylor wrote: I'm looking for a Python library for generating SQL queries [selects, alters, inserts and commits]. The popular ones are SQLObject and SQLAlchemy, both just a web-search away. Additionally, if you're working with Django, it has its own built-in ORM. -

Re: Python library for generating SQL queries [selects, alters, inserts and commits]

2011-10-12 Thread Tim Chase
On 10/11/11 22:13, alex23 wrote: They look good, but I'm looking for something which can "compile" down to normal SQL code. Then you're not looking hard enough. SQLAlchemy does this. I'm not sure it can entirely be chalked up to not looking hard enough. Because so many keywords of what's de

MySQLdb on Mac Lion

2011-10-12 Thread Tim Johnson
I'm most experienced with MySQLdb on ubuntu, which is installed via apt-get or synaptic. I am setting up a mac mini with osX 10.7 (Lion). Macports makes py27-mysql 1.2.2 available, but are there any .dmg packages available? thanks -- Tim tim at tee jay forty nine dot com or akwebsoft do

Re: MySQLdb on Mac Lion

2011-10-13 Thread Tim Johnson
* Ned Deily [111012 18:12]: > In article <20111013005244.gk6...@johnsons-web.com>, > Tim Johnson wrote: > > I'm most experienced with MySQLdb on ubuntu, which is installed via > > apt-get or synaptic. > > > > I am setting up a mac mini with osX 10.7 (L

Re: Can I search a list for a range of values?

2011-10-14 Thread Tim Chase
On 10/14/11 17:20, Chris Angelico wrote: Try a list comprehension: a = [2,4,5,6,3,9,10,34,39,59,20,15,13,14] [i for i in a if i>=10 if i<=20] [10, 20, 15, 13, 14] The double-if is new to me. I thought it was an error when I first saw it, but it seems to be legit syntax (or at least one th

Re: Can I search a list for a range of values?

2011-10-14 Thread Tim Chase
On 10/14/11 18:01, Ian Kelly wrote: On Fri, Oct 14, 2011 at 4:30 PM, Tim Chase or even more clearly: [i for i in a if 10<= i<= 20] As long as we're nitpicking, I'll point out that "i" is an inappropriate variable name here, since it is normally used to denote indice

Re: Can I search a list for a range of values?

2011-10-14 Thread Tim Chase
On 10/14/11 18:36, Troy S wrote: Can something like this be done with dictionarys? For example, these are the keys in the dictionary from the call: dict.keys() ['20110601', '20110604', '20110608', '20110611', '20110615', '20110618', '20110622', '20110625', '20110629', '20110702', '20110706','20

Re: COM / .NET

2011-10-20 Thread Tim Golden
On 20/10/2011 09:06, Uffe Kousgaard wrote: Is python able to access COM libraries or .NET assemblies? If both, which is the easist or most popular? You have a few choices in this regard: * CPython can access COM objects either via the pywin32 extensions[1] or via comtypes[2]. The former is mai

Re: Python based silent installer, how to?

2011-10-20 Thread Tim Golden
On 20/10/2011 09:45, Muhammad Bashir Al-Noimi wrote: On 20/10/2011 01:35 ص, Alec Taylor wrote: Just download the msi (script is available to regenerate yourself) and run it with the silent swtich, something like: msiexec /x nameofmsi.msi Sorry I didn't explain what I'm looking for exactly. I'

Re: spawnl issues with Win 7 access rights

2011-10-24 Thread Tim Golden
On 24/10/2011 13:43, Propad wrote: Hello everybody, I have some trouble with a program I run both on a WinXP and on Win 7. It boils down to this several lines: import os vePath = r'C:\Programme\RA Consulting_Webservices\DiagRA-MCD \DiagRA_D.exe' #vePath = r'C:\Windows\notepad.exe' process_id = o

Re: spawnl issues with Win 7 access rights

2011-10-24 Thread Tim Golden
On 24/10/2011 14:18, Tim Golden wrote: I ran this (on Python 2.7 on Win7): import os os.spawnl (os.P_NOWAIT, r"c:\windows\notepad.exe") and Python crashed hard! Long time since I've seen that happen. This may or may not be related to what you're seeing but it's d

Re: spawnl issues with Win 7 access rights

2011-10-25 Thread Tim Golden
On 25/10/2011 08:01, Propad wrote: Thnx again for all the answers. As stated before, I'm limited in my options. One of them just might be to switch to Python 2.5, rewrite the code that crashes using the subprocess module, and then somehow patch the library I use (which I'm not suposed to do, but.

Re: spawnl issues with Win 7 access rights

2011-10-26 Thread Tim Golden
On 26/10/2011 02:11, Terry Reedy wrote: OP reports 2.6 with XP works. Where do you see that, Terry? (Or was there an offlist email?) Did that use VS 2005? Maybe C runtime changed (regressed). That's possible -- and is essentially my main guess (faute de mieux). I've got the same results on

Re: spawnl issues with Win 7 access rights

2011-10-27 Thread Tim Golden
On 27/10/2011 11:27, Propad wrote: the suggestion to add the optional second parameter fixed the problem, spawnl now works on the Win 7 computer I'm responsible for (with Python 2.2). So the suggested cause seems to be right. FWIW, although it's not obvious, the args parameter to spawnl is inte

Re: spawnl issues with Win 7 access rights

2011-10-28 Thread Tim Golden
On 27/10/2011 20:53, Terry Reedy wrote: On 10/27/2011 6:36 AM, Tim Golden wrote: On 27/10/2011 11:27, Propad wrote: the suggestion to add the optional second parameter fixed the problem, spawnl now works on the Win 7 computer I'm responsible for (with Python 2.2). So the suggested cause

Re: save tuple of simple data types to disk (low memory foot print)

2011-10-29 Thread Tim Chase
On 10/29/11 11:44, Gelonida N wrote: I would like to save many dicts with a fixed (and known) amount of keys in a memory efficient manner (no random, but only sequential access is required) to a file (which can later be sent over a slow expensive network to other machines) Example: Every dict wi

Re: Efficient, built-in way to determine if string has non-ASCII chars outside ASCII 32-127, CRLF, Tab?

2011-10-31 Thread Tim Chase
On 10/31/11 18:02, Steven D'Aprano wrote: # Define legal characters: LEGAL = ''.join(chr(n) for n in range(32, 128)) + '\n\r\t\f' # everybody forgets about formfeed... \f # and are you sure you want to include chr(127) as a text char? def is_ascii_text(text): for c in text:

Re: simple file flow question with csv.reader

2011-11-02 Thread Tim Chase
On 11/02/11 16:13, Matt wrote: Hi All, I am trying to do a really simple file operation, yet, it befuddles me... I have a few hundred .csv files, and to each file, I want to manipulate the data, then save back to the original file. The code below will open up the files, and do the proper mani

Re: Dictionary sorting

2011-11-03 Thread Tim Chase
On 11/03/11 16:36, Terry Reedy wrote: > Is there a way to not sort them and leave the order as is? CPython iterates (and prints) dict items in their arbitrary internal hash table order, which depends on the number and entry order of the items. It is a bug to depend on that arbitrary order in

Decouplable CMS in python?

2011-11-08 Thread Tim Johnson
be too complex, regardless of its merits. Any recommendations? thanks -- 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: all() is slow?

2011-11-08 Thread Tim Chase
On 11/08/2011 04:51 PM, John Posner wrote: On 2:59 PM, Chris Angelico wrote: So really, it's not "all() is slow" but "function calls are slow". Maybe it'd be worthwhile making an all-factory: PLEASE say you're joking. If I saw code like that on any of our project, this would definitely qualify

Re: The python implementation of the "relationships between classes".

2011-11-10 Thread Tim Wintle
On Thu, 2011-11-10 at 22:25 +0800, Jerry Zhang wrote: > > > 2011/11/10 Chris Angelico > On Fri, Nov 11, 2011 at 12:58 AM, Jerry Zhang > wrote: > > Cls_a: > > def __init__(self): > > self.at1 = 1 > > Cls_b: > > def __init__(

Re: Use and usefulness of the as syntax

2011-11-12 Thread Tim Chase
On 11/12/11 05:56, candide wrote: First, could you confirm the following syntax import foo as f equivalent to import foo f = foo and the issuing "del foo" Now, I was wondering about the usefulness in everyday programming of the as syntax within an import statement. Here are some instances

Re: Use and usefulness of the as syntax

2011-11-12 Thread Tim Wintle
On Sat, 2011-11-12 at 12:56 +0100, candide wrote: > So what is the pragmatics of the as syntax ? Another case: try: import json except: import simplejson as json (same goes for several modules where the C implementation may or may not be available) Tim -- http://mail.python.

Re: can't decompress data; zlib not available

2011-11-13 Thread Tim Wintle
oks like you need python2.6 I've never had a missing zlib module - but it's possible that it might be missing if you don't have the zlib/deflate headers installed - if they're not available then I'd try installing them and then reinstalling the package you started with. Tim Wintle -- http://mail.python.org/mailman/listinfo/python-list

Re: Multilevel dicts/arrays v. tuples as keys? [Was: Re: Get keys from a dicionary]

2011-11-14 Thread Tim Golden
On 14/11/2011 10:05, Matej Cepl wrote: Dne 11.11.2011 14:31, macm napsal(a): def Dicty( dict[k1][k2] ): When looking at this I returned to the question which currently rolls in my mind: What's difference/advantage-disadvantage betweeng doing multi-level dicts/arrays like this and using tuple

Re: can't decompress data; zlib not available

2011-11-14 Thread Tim Wintle
for the command line is > the one in /usr/bin/python. Would this be the one I > reconfigure for zlib? Should I simply install python from > > Python-3.2.2.tgz? no - you need to use python2.6 - python3 is effectively a different language. python is a core part of *nix these days,

Re: python shell that saves history of typed in commands that will persist between reboots

2011-11-16 Thread Tim Golden
On 16/11/2011 03:38, goldtech wrote: Hi, Using Windows. Is there a python shell that has a history of typed in commands? Have a look at DreamPie: http://dreampie.sourceforge.net/ TJG -- http://mail.python.org/mailman/listinfo/python-list

Re: How to: Coordinate DictReader and Reader for CSV

2011-11-21 Thread Tim Chase
On 11/21/11 09:16, ray wrote: Is there a way to capture the keys outside of the for loop so when the for loop is entered, only data is extracted? I frequently do this for things like tweaking headers (stripping space, normalizing case, etc because clients love to send us messy data): def

Re: python shell that saves history of typed in commands that will persist between reboots

2011-11-23 Thread Tim Golden
On 23/11/2011 10:29, Steven D'Aprano wrote: On Wed, 23 Nov 2011 11:23:19 +0200, Anssi Saari wrote: goldtech writes: Using Windows. Is there a python shell that has a history of typed in commands? Is there a shell that doesn't have history then? At least both the vanilla shell and Idle both

Re: python shell that saves history of typed in commands that will persist between reboots

2011-11-24 Thread Tim Golden
On 24/11/2011 06:22, Chris Angelico wrote: On Thu, Nov 24, 2011 at 5:11 PM, Steven D'Aprano wrote: One of us is confused, and I'm pretty sure it's you :) Tim went on to say "Obviously this only applies when an underlying cmd session persists", which I understood a

Re: python shell that saves history of typed in commands that will persist between reboots

2011-11-25 Thread Tim Golden
On 25/11/2011 03:47, alex23 wrote: Tim Golden wrote: The interpreter inherits the command shell's history function: Open a cmd window and then a Python session. Do some stuff. Ctrl-Z to exit to the surrounding cmd window. Do some random cmd stuff: dir, cd, etc. Start a second Python se

Re: python shell that saves history of typed in commands that will persist between reboots

2011-11-25 Thread Tim Golden
On 25/11/2011 10:37, Ulrich Eckhardt wrote: Am 25.11.2011 04:49, schrieb alex23: On Nov 24, 6:51 pm, Tim Golden wrote: The Ctrl-Z thing is what *exits* the interpreter on Windows (a la Ctrl-D on Linux). With ActivePython, Ctrl-D works as well, which is a godsend as I'm constantly wo

cmd.Cmd asking questions?

2011-11-28 Thread Tim Chase
Are there best-practices for creating wizards or asking various questions (whether yes/no or text/numeric entry) in a cmd.Cmd class? Something like the imaginary confirm() and get_string() methods here: class MyCmd(cmd.Cmd): def do_name(self,line): s = get_string(prompt=line, defa

Re: cmd.Cmd asking questions?

2011-11-29 Thread Tim Chase
On 11/28/11 06:27, Robert Kern wrote: On 11/28/11 12:12 PM, Tim Chase wrote: I can monkey with printing messages and using raw_input(), but I'd like to know if there's a better way (such as something interacting with readline for text-entry-with-history-and-completion, If you impor

Re: order independent hash?

2011-11-30 Thread Tim Golden
On 30/11/2011 12:32, Neal Becker wrote: I like to hash a list of words (actually, the command line args of my program) in such a way that different words will create different hash, but not sensitive to the order of the words. Any ideas? How about? hash (frozenset ("hello world".split ()))

Re: How convert a list string to a real list

2011-11-30 Thread Tim Chase
On 11/30/11 16:48, Hidura wrote: Why you don't make this "['1','2','3']".strip("[]").split(',') work for me because it breaks on things like s = """ [[1,2,3],42,'''triple the fun!''', "can't touch this, eh?",r'"Back\\\slashes?!", she said.', [4,5,6]] """ Commas can be embedded in

Passing along cmd.Cmd completion to contained class

2011-12-01 Thread Tim Chase
I have sub-classes of cmd.Cmd in an arrangement somewhat like class Config(cmd.Cmd): def do_foo(self, line): print "Fooing %r" % line def complete_foo(self, text, line, begidx, endidx): ... class MyTUI(cmd.Cmd): def __init__(self, configger=Config, *args, **kwargs): c

Re: order independent hash?

2011-12-04 Thread Tim Chase
On 12/04/11 08:08, Chris Angelico wrote: 2011/12/5 Hrvoje Niksic: If a Python implementation tried to implement dict as a tree, instances of classes that define only __eq__ and __hash__ would not be correctly inserted in such a dict. Couldn't you just make a tree of hash values? Okay, that's p

Re: Python-list Digest, Vol 99, Issue 28

2011-12-06 Thread Tim Chase
12/06/11 11:34, Sergi Pasoev wrote: (after trimming all the digest rubbish the way you should have done in the first place) Coincidentally, I was working on that exact function last night, so you inspired me to put it up on the Python cookbook. This version should work on any POSIX system such as

Re: Misleading error message of the day

2011-12-08 Thread Tim Chase
On 12/08/11 09:30, Roy Smith wrote: On Thursday, December 8, 2011 9:47:02 AM UTC-5, Robert Kern wrote: Would including the respective numbers help your thought processes? ValueError: too many values to unpack (expected 2, got 3) I don't know if that would have done the trick for me on this p

Re: subprocess.Popen under windows 7

2011-12-09 Thread Tim Golden
On 09/12/2011 08:32, Ulrich Eckhardt wrote: Am 08.12.2011 23:41, schrieb Frank van den Boom: arglist = [PATH_TO_7ZIP,"a", "-sfx", archive_name, "*", "-r", "-p",PASSWORD] The "*" is resolved by the shell, this is not a wildcard that gets passed to the program. At least not normally, your case m

Obtaining user information

2011-12-09 Thread Tim Chase
Currently I can get the currently-logged-in-userid via getpass.getuser() which would yield something like "tchase". Is there a cross-platform way to get the full username (such as from the GECOS field of /etc/passed or via something like NetUserGetInfo on Win32 so I'd get &quo

Re: Obtaining user information

2011-12-10 Thread Tim Chase
On 12/10/11 01:37, Cameron Simpson wrote: On 09Dec2011 19:44, Tim Chase wrote: | Currently I can get the currently-logged-in-userid via | getpass.getuser() which would yield something like "tchase". _If_ you're on a terminal. _And_ that's exactly what you want. Personally I

Re: automate commands to an .exe console program through python

2011-12-13 Thread Tim Golden
On 13/12/2011 11:21, Juan Perez wrote: Well, if developers have to change something to the code, I'd continue with autoit, since is closer to real enviroment. You are right, autoit work by send parametres to GUI focused, but really I don't think it's something necessary for my purposes as I need

Re: Using methodcaller in a list sort - any examples anywhere?

2011-12-13 Thread Tim Chase
On 12/13/11 09:48, tinn...@isbd.co.uk wrote: I want to sort a list of 'things' (they're fairly complex objects) by the contents of one of the fields I can extract from the 'things' using a Python function. So I have a list L which is a list of objects of some sort. I can output the contents of

<    23   24   25   26   27   28   29   30   31   32   >