Re: How to generate "a, b, c, and d"?

2011-12-15 Thread Tim Chase
On 12/15/11 10:48, Roy Smith wrote: I've got a list, ['a', 'b', 'c', 'd']. I want to generate the string, "a, b, c, and d" (I'll settle for no comma after 'c'). Is there some standard way to do this, handling all the special cases? [] ==> '' ['a'] ==> 'a' ['a', 'b'] ==> 'a and b' ['a', 'b

Re: test for list equality

2011-12-15 Thread Tim Chase
On 12/15/11 11:59, Miki Tebeka wrote: My sort issue... as in this doesn't work if x.sort == y.sort: You're missing the () to make it a function call. Also list.sort() returns none, it mutates the original list. You can either sorted(x) == sorted(y) or set(x) == set(y) Duplicates cau

Re: How to generate "a, b, c, and d"?

2011-12-15 Thread Tim Chase
On 12/15/11 12:19, Ethan Furman wrote: Tim Chase wrote: On 12/15/11 10:48, Roy Smith wrote: I've got a list, ['a', 'b', 'c', 'd']. I want to generate the string, "a, b, c, and d" (I'll settle for no comma after 'c'). Is th

Re: modifying a time.struct_time

2011-12-16 Thread Tim Golden
On 16/12/2011 10:44, Steven D'Aprano wrote: [ on time.struct_time ] Not a bug, but it does seem a very old and inelegant API more suited to hairy C programmers gathered around a smokey fire in a cave chewing on old dinosaur bones, and not worthy of space-age Python coders flying around on anti-g

Re: Make a small function thread safe

2011-12-16 Thread Tim Wintle
k: counter += 1 ... where counter_lock is a threading.Lock instance. (see docs for the threading module) Tim -- http://mail.python.org/mailman/listinfo/python-list

Re: Make a small function thread safe

2011-12-16 Thread Tim Wintle
] > for i in xrange(10): > thread = thread_example() > threads.append(thread) > > for thread in threads: > thread.start() you'll either need to lock again here, or join each thread: for thread in threads: thread.join() > for item in shared_container: > print item Tim -- http://mail.python.org/mailman/listinfo/python-list

Re: Make a small function thread safe

2011-12-16 Thread Tim Delaney
On 17 December 2011 02:05, Brad Tilley wrote: > On Dec 16, 9:36 am, Tim Wintle wrote: > > > should be: > > def run(t): > > with lock: > > shared_container.append(t.name) > > > > (or lock.acquire() and lock.release() as

Re: Question about Reading from text file with Python's Array class

2011-12-18 Thread Tim Chase
On 12/18/11 12:33, traveller3141 wrote: To test this, I made a small sample file (sillyNums.txt) as follows; 109 345 2 1234556 f=open("sillyNums.txt","r") data = array.array('i') data.fromstring(f.read(data.itemsize* bufferSize)) print data The output was nonsense: array('i', [171520049, 171258

Re: Make a small function thread safe

2011-12-18 Thread Tim Delaney
. The lock must be acquired outside the try: - otherwise if an exception is thrown while acquiring, you will try to release a lock that you have not acquired. Which again is why using with is a much better option - you can't make this kind of mistake. Tim Delaney -- http://mail.python.org/mailman/listinfo/python-list

Re: Transform two tuples item by item

2011-12-19 Thread Tim Chase
On 12/19/11 20:04, Gnarlodious wrote: What is the best way to operate on a tuple of values transforming them against a tuple of operations? Result can be a list or tuple: tup=(35, '34', 0, 1, 31, 0, '既濟') from cgi import escape [tup[0], " class='H'>{}".format(tup[1]), bool(tup[2]), bool(tup[3])

Re: Performing a number of substitutions on a unicode string

2011-12-20 Thread Tim Chase
On 12/20/11 08:02, Arnaud Delobelle wrote: Hi all, I've got to escape some unicode text according to the following map: escape_map = { u'\n': u'\\n', u'\t': u'\\t', u'\r': u'\\r', u'\f': u'\\f', u'\\': u'' } The simplest solution is to use str.replace: def escape_

Re: Anyone still using Python 2.5?

2011-12-21 Thread Tim Chase
On 12/21/11 07:07, Roy Smith wrote: In article<[email protected]>, Steven D'Aprano wrote: Centos and Red Hat production systems still use Python 2.4, so yes, absolutely, 2.5 and 2.4 still need to be supported. Is Python 2.4 destined to be the next IE-6?

Idiom for shelling out to $EDITOR/$PAGER?

2011-12-22 Thread Tim Chase
After a little searching, I've not been able to come up with what I'd consider canonical examples of consider calling an external editor/pager on a file and reading the results back in. (most of my results are swamped by people asking about editors written in Python, or what the best editors f

Re: Idiom for shelling out to $EDITOR/$PAGER?

2011-12-23 Thread Tim Chase
On 12/23/11 06:06, Ben Finney wrote: Cameron Simpson writes: On 23Dec2011 17:12, Ben Finney wrote: | That doesn't address the concern Tim raised: did the user actually do | anything, did the file change? I'm not sure it matters. I know of numerous applications where it matters, s

Re: How safe is this way of getting a default that allows None?

2011-12-25 Thread Tim Chase
On 12/25/11 18:49, Dan Stromberg wrote: How safe is this? I like the idea. UNSPECIFIED = object() def fn(x, y=UNSPECIFIED): if y is UNSPECIFIED: print x, 'default' else: print x, y safe? It's idiomatic :) -tkc -- http://mail.python.org/mailman/listinfo/python-list

Re: Python education survey

2011-12-27 Thread Tim Chase
On 12/27/11 19:56, Rick Johnson wrote: On Dec 27, 3:44 pm, Eelco wrote: Despite the fact that you mis-attributed that quote to me, im going to be a little bit offended in the name of its actual author anyway. Thats a lot of words to waste on your linguistic preferences. Personally, I reserve th

Re: How to get function string name from i-th stack position?

2011-12-30 Thread Tim Chase
On 12/30/11 11:51, dmitrey wrote: how to get string name of a function that is n levels above the current Python interpreter position? Use the results of traceback.extract_stack() from traceback import extract_stack def one(x): print "one", x stk = extract_stack() for mod, line

Re: .format vs. %

2011-12-31 Thread Tim Chase
On 12/31/11 12:57, Benjamin Kaplan wrote: format is a method of the string class. You store the string the same way you would any other. formatter = "Hello, {}" print(formatter.format("world")) Just to note that this syntax doesn't quite work in some earlier versions (tested below in 2.6, whi

Best Way To Bound Function Execution Time

2011-12-31 Thread Tim Daneliuk
Pythonic way to bound how long a function call can run, after which time it is forcefully terminated? TIA, -- Tim Daneliuk [email protected] PGP Key: http://www.tundraware.com/PGP/ -- http://mail.python.org

Re: [Windows 7, Python 2.6] Can't write to a directory made w/ os.makedirs

2012-01-01 Thread Tim Golden
On 31/12/2011 22:13, OlyDLG wrote: > Hi! I'm working on a script utilizing os.makedirs to make directories > to which I'm then trying to write files created by exe's spawned w/ > subprocess.call; I'm developing in Stani's Python Editor, debugging > using Winpdb. I've gotten to the point where >

Re: Can't write to a directory made w/ os.makedirs

2012-01-01 Thread Tim Golden
On 01/01/2012 12:05, David Goldsmith wrote: >> ie can the Python process creating the directories, > > Yes. > >> and a subprocess called from it create a simple file? > > No. > >> Depending on where you are in the filesystem, it may indeed >> be necessary to be running as administrator. But don't

Idiot-proof installs for python+pygame+pyopenal+app

2012-01-01 Thread Tim Chase
I'm looking at developing some tools that involve pygame+pyopenal and would like to make cross-platform distribution as painless as possible. Is there a "best practice" for doing this without forcing the user to install Python, install (say) pip, pull down pygame & pyopenal and install those,

Re: Can't write to a directory made w/ os.makedirs

2012-01-02 Thread Tim Golden
On 02/01/2012 03:14, David Goldsmith wrote: Here's my script, in case that helps: It certainly does. A few things occur to me. First, you shouldn't need to double-quote the path; the subprocess.call should do that for you as long as you're using the list version of the param -- which you are.

Re: python philosophical question - strong vs duck typing

2012-01-04 Thread Tim Wintle
ative code. > I am just thinking in my brain about the differences between cpp and > python, and if there is a way to compromise a bit on the python-ness > to get closer to cpp, but still be able to keep a lot of the goodness, > then put in a translator or converter to cpp and gain performance by > using cpp code. Sounds like Rpython, cython, shedskin are doing a lot > or all of this, so lots to study up on. Yup Tim Wintle -- http://mail.python.org/mailman/listinfo/python-list

Re: How to support a non-standard encoding?

2012-01-06 Thread Tim Wintle
does) then you could use a wrapped iconv library to avoid re-inventing the wheel. I've got a forked version of the "iconv" package from pypi available here: <https://github.com/timwintle/iconv-python> .. it should work on python2.5-2.7 Tim -- http://mail.python.org/mailman/listinfo/python-list

[ANN]: 'tsshbatch', Batch ssh Tool, Version 1.134 Released

2012-01-06 Thread Tim Daneliuk
'tsshbatch' Version 1.134 is now released and available for download at: http://www.tundraware.com/Software/tsshbatch This is the first public release. - What Is 'tsshbatch'? -- 'tsshbatch' is a tool

Re: How to support a non-standard encoding?

2012-01-06 Thread Tim Wintle
On Fri, 2012-01-06 at 12:00 -0800, jmfauth wrote: > The distibution of such a codec may be a problem. There is a register_codec method (or similar) in the codecs module. Tim -- http://mail.python.org/mailman/listinfo/python-list

Re: replacing __dict__ with an OrderedDict

2012-01-10 Thread Tim Wintle
On Tue, 2012-01-10 at 09:05 -0500, Roy Smith wrote: > > I guess MongoDB is not a serious database? That's opening up a can of worms ;) ... anyway, cassandra is far better. Tim -- http://mail.python.org/mailman/listinfo/python-list

Re: Unclear about verbose regex syntax (excaping whitespace)

2012-01-10 Thread Tim Chase
On 01/10/12 10:49, Roy Smith wrote: The docs for re.VERBOSE say, "Whitespace within the pattern is ignored, except when [...] preceded by an unescaped backslash". It's unclear exactly what that means. If my pattern is: is the second space considered to be preceded by a backslash, and thus ta

Re: defining class and subclass in C

2012-01-14 Thread Tim Roberts
= { PyObject_HEAD_INIT(NULL) }; You are creating a "type" object. It shouldn't be a surprise that it is displayed as a , just like int and dict. In a sweeping overgenerality, C modules define types and Python modules define classes. You could redefine the __repr__ method to display "" if you want. -- Tim Roberts, [email protected] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: can some one help me with my code. thanks

2012-01-20 Thread Tim Chase
On 01/20/12 13:46, Terry Reedy wrote: def average(bin): num=[] total = 0.0 count=0 for number in bin: if number!='end': total += float(number) count+=1 else: num.append(total/count) total = 0.0

Re: What's the very simplest way to run some Python from a button on a web page?

2012-01-21 Thread Tim Roberts
g page alone. If you aren't, then I think the easiest method is to use an invisible . From Javascript, you can set the "src" property of the to fire off a request while leaving the rest of the page alone. You could spend the rest of your career reading all of the good web material on A

Re: Splitting a file from specific column content

2012-01-22 Thread Tim Chase
On 01/22/12 08:45, Roy Smith wrote: I would do this with standard unix tools: grep '^[012]' input.txt> first-three-seconds.txt grep '^[34]' input.txt> next-two-seconds.txt grep '^[567]' input.txt> next-three-seconds.txt Sure, it makes three passes over the data, but for 20 MB of data, you co

Re: Splitting a file from specific column content

2012-01-22 Thread Tim Chase
On 01/22/12 13:26, Roy Smith wrote: If you wanted to do it in one pass using standard unix tools, you can use: sed -n -e'/^[0-2]/w first-three.txt' -e'/^[34]/w next-two.txt' -e'/^[5-7]/w next-three.txt' I stand humbled. In all likelyhood, you stand *younger*, not so much humbled ;-) -tkc

Re: Hitting send by mistake -- a solution

2013-02-05 Thread TIm Chase
On Tue, 05 Feb 2013 14:41:21 -0500, Terry Reedy wrote: > [comment about a double post] > > He must have hit the send button too early by mistake. > > I used to do that occasionally. The reason is that the default > position of [send] was on the left, under [File] and [Edit], and > sometimes I did

Re: Decimal 0**0

2013-02-06 Thread Tim Roberts
> >I suspect this is a bug in Decimal's interpretation of the standard. Can >anyone comment? I don't think Decimal ever promised to adhere to IEEE 754, did it? -- Tim Roberts, [email protected] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: Is Python programming language?

2013-02-09 Thread Tim Roberts
en a proof of that. I would assert that scripting languages are a proper subset of programming languages, not a separate category. -- Tim Roberts, [email protected] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: LangWart: Method congestion from mutate multiplicty

2013-02-10 Thread Tim Chase
On Sun, 10 Feb 2013 22:29:54 +1100, Steven D'Aprano wrote: > Rick Johnson wrote: > > map, mapped > > filter, filtered > > reduce, reduced > > Those are nonsense. None of those are in-place mutator methods. > Especially reduce, which reduces a list to a single item. You might > as well have sugg

Re: LangWart: Method congestion from mutate multiplicty

2013-02-10 Thread Tim Chase
> > > flatten, flattened > > > > flatten is another often requested, hard to implement correctly, > > function. The only reason that Python doesn't have a flatten is > > that nobody can agree on precisely what it should do. > > Steven, the definition of flatten (as relates to sequences) is > ver

Re: LangWart: Method congestion from mutate multiplicty

2013-02-11 Thread Tim Chase
On Mon, 11 Feb 2013 18:24:05 +1100 Chris Angelico wrote: > Is that Unicode string theory or ASCII string theory? +1 QOTW :-) -tkc -- http://mail.python.org/mailman/listinfo/python-list

Re: how to call shell?

2013-02-11 Thread Tim Roberts
uns, and terminates. Your first command adds a variable "i" to the environment for that shell, but the variable is deleted when the shell procsess terminates. -- Tim Roberts, [email protected] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: First attempt at a Python prog (Chess)

2013-02-13 Thread Tim Roberts
for col in range(8): with the more Pythonic: for row in board: for cell in row: I would probably replace the piece_type function with a map that maps the piece number directly to the piece -- Tim Roberts, [email protected] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: First attempt at a Python prog (Chess)

2013-02-15 Thread Tim Golden
On 15/02/2013 11:22, Oscar Benjamin wrote: > Why not make board a list of lists. Then you can do: > > for row in board: > for piece in row: > > rather than using range(). > > Or perhaps you could have a dict that maps position tuples to pieces, > e.g.: {(1, 2): 'k', ...} I'm laughing sligh

Re: First attempt at a Python prog (Chess)

2013-02-15 Thread Tim Golden
On 15/02/2013 13:11, Oscar Benjamin wrote: > On 15 February 2013 11:36, Tim Golden wrote: >> And the "how shall we represent the board?" question is pretty >> much the first thing any team asks themselves. And you always >> get someone in favour of lists of list

Re: First attempt at a Python prog (Chess)

2013-02-15 Thread Tim Golden
On Sat, Feb 16, 2013 at 2:36 AM, Tim Golden wrote: How true. This last time, my team split into two: one half to handle the display, the other working on the algorithm. We ended up having to draw a really simple diagram on the back of an envelope with the x,y pairs written out and pass it back

Re: Howto parse a string using a char in python

2013-02-15 Thread Tim Chase
On 2013-02-15 18:04, Steve Goodwin wrote: > Hi, > > I am looking for the python2.7 function(s) to parse a string from a > colon character ":" > > Sounds simple enough. > > For example, a string like "123456:789". I just need the "123456" > substring.(left of the :) > > I have looked at regula

Re: Can someone tell me what kinds of questions should be asked in this list and what kinds in the tutor section?

2013-02-17 Thread Tim Golden
On 17/02/2013 00:19, Claira wrote: Can someone tell me what kinds of questions should be asked in this list and what kinds in the tutor section? There's no clear-cut distinction. The rule of thumb I usually apply is that questions about the *language* (its syntax, its usage, its idioms etc.) an

Re: Instances as dictionary key, __hash__ and __eq__

2013-02-18 Thread Tim Delaney
st way is probably to have a _equal_fields() method that subclasses override, returning a tuple of the attributes that should be hashed. Then in __hash__() and __eq__ you iterate over the returned tuple, get the value for each attribute and either hash or compare. Of course, you have to take into account in __eq__ that the other instance may not have the same attributes (e.g. self is a subclass that uses extra attributes in its __hash__ and __eq__). Tim Delaney -- http://mail.python.org/mailman/listinfo/python-list

Re: First attempt at a Python prog (Chess)

2013-02-18 Thread Tim Roberts
Chris Hinsley wrote: > >Is a Python list as fast as a bytearray ? Python does not actually have a native array type. Everything in your program that looked like an array was actually a list. -- Tim Roberts, [email protected] Providenza & Boekelheide, Inc. -- http://mail.python.o

Re: Python 3.3 vs. MSDOS Basic

2013-02-19 Thread Tim Daneliuk
ss? I'd be interested in seeing your approach... -- -------- Tim Daneliuk [email protected] PGP Key: http://www.tundraware.com/PGP/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Python 3.3 vs. MSDOS Basic

2013-02-20 Thread Tim Daneliuk
On 02/19/2013 12:31 PM, Ian Kelly wrote: On Tue, Feb 19, 2013 at 7:46 AM, Tim Daneliuk wrote: Are you sure you wouldn't like to share with the class? I'd be interested in seeing your approach... Very well: def collatz(n, memo): if n not in memo: if

Re: Python 3.3 vs. MSDOS Basic

2013-02-20 Thread Tim Daneliuk
On 02/20/2013 12:38 PM, Ian Kelly wrote: On Wed, Feb 20, 2013 at 7:21 AM, Tim Daneliuk wrote: Thanks. I was specifically curious about your use of dynamic programming. What about this algorithm makes it particularly an example of this? Is it your use of memoization or something other than

Re: Python 3.3 vs. MSDOS Basic

2013-02-20 Thread Tim Daneliuk
On 02/20/2013 04:49 PM, Tim Daneliuk wrote: On 02/20/2013 12:38 PM, Ian Kelly wrote: On Wed, Feb 20, 2013 at 7:21 AM, Tim Daneliuk wrote: Thanks. I was specifically curious about your use of dynamic programming. What about this algorithm makes it particularly an example of this? Is it your

Re: What am I doing wrong installing Python 2.7.3?

2013-02-21 Thread Tim Golden
On 21/02/2013 14:39, Etherus wrote: > I have downloaded the windows installer for a 32 bit installation of > python 2.7.3 but it tells me that: > > The feature you are trying to use is on a network resource that is > unavailable. > > Click OK to try again, or enter an alternative path to a folder

Re: Checking for valid date input and convert appropriately

2013-02-22 Thread Tim Chase
On 2013-02-22 07:07, Ferrous Cranus wrote: > Actually it can, but instead of try: i have to create a function: > > def is_sane_date(date): > parts = [int(part) for part in date.split() if part.isdigit()] > if len(parts) == 3 and \ > 1 <= parts[0] <= 31 and \ > 1 <= parts[

Re: [Python-ideas] iterable.__unpack__ method

2013-02-24 Thread Tim Chase
On 2013-02-25 01:19, Chris Angelico wrote: > >>> command, subcommand = next(iterargs), next(iterargs) > >> > >> > >> Err is there a language guarantee of the order of evaluation > >> in a tuple, or is this just a "CPython happens to evaluate > >> independent expressions left-to-right"? Thi

Re: Do you feel bad because of the Python docs?

2013-02-26 Thread Tim Chase
On 2013-02-26 17:54, notbob wrote: > >> zsh? What docs!? > > You mean other than the gigantic user manual? > > http://zsh.sourceforge.net/Doc/ > > "This document was generated by Simon Ruderich on July 24, 2012" > > 'bout damn time!! ;) Generated...from source that has been around for age

Re: suggestions for improving code fragment please

2013-02-28 Thread Tim Chase
On 2013-02-28 19:47, The Night Tripper wrote: > Hi there > I'm being very dumb ... how can I simplify this fragment? > > > if arglist: > arglist.pop(0) > if arglist: > self.myparm1 = arglist.pop(0) > if arglist: >

Re: suggestions for improving code fragment please

2013-02-28 Thread Tim Chase
On 2013-02-28 16:28, Dave Angel wrote: > On 02/28/2013 03:37 PM, Tim Chase wrote: > >for attr in ("myparm1", "myparm2", "myparm3", ...): > > if arglist: > >setattr(self, attr, arglist.pop(0)) > > else: > >

Re: [Python-ideas] string.format() default variable assignment

2013-03-02 Thread Tim Golden
On 02/03/2013 14:53, Devin Jeanpierre wrote: On Sat, Mar 2, 2013 at 1:54 AM, Chris Angelico wrote: Yes, but reply-all sends a copy to the poster as well as the list. What I want is reply-list, acknowledging the list headers... and Gmail simply doesn't have that. I've been replying to the post

Re: simple GUI environment

2013-03-05 Thread Tim Golden
On 05/03/2013 14:55, Kevin Walzer wrote: > On 3/5/13 9:20 AM, Eric Johansson wrote: >> The main reason I discount both of those is that they are effectively >> dead as I can see. Last updates in the 2010/2011 range. > > Why not give EasyGUI a try? or PyGUI: http://www.cosc.canterbury.ac.nz/gr

Re: Config & ConfigParser

2013-03-05 Thread Tim Chase
On 2013-03-05 12:09, Chuck wrote: > I'm curious about using configuration files. Can someone tell me > how they are used? I'm writing a podcast catcher and would like > to set up some default configurations, e.g. directory, etcOther > than default directory, what are some of the things that

Re: Config & ConfigParser

2013-03-05 Thread Tim Chase
On 2013-03-05 15:58, Chuck wrote: > Thanks Tim! So much stuff I haven't thought of before. Out of > curiosity, what's the benefit of caching the download, instead of > downloading to the final destination? If your connection gets interrupted, the server goes down, etc,

Re: Why is Ruby on Rails more popular than Django?

2013-03-06 Thread Tim Johnson
;community" is indifferent to fastcgi and the shared hosting environment. As someone is new to shared hosting environments (I would mostly on dedicated servers) I get the impression that django is cutting itself out of some (if not a lot) of the market. I don't know about RoR tho

Re: Why is Ruby on Rails more popular than Django?

2013-03-06 Thread Tim Johnson
* Albert Hopkins [130306 17:14]: > > > On Wed, Mar 6, 2013, at 02:16 PM, Tim Johnson wrote: > > > I had problems getting django to work on my hostmonster account > > which is shared hosting and supports fast_cgi but not wsgi. I put > > that effort on hold f

Re: Interesting list() un-optimization

2013-03-06 Thread Tim Chase
On 2013-03-06 22:20, Roy Smith wrote: > I stumbled upon an interesting bit of trivia concerning lists and > list comprehensions today. I agree with Dave Angel that this is interesting. A little testing shows that this can be rewritten as my_objects = list(iter(my_query_set)) which seems to th

Re: Why is Ruby on Rails more popular than Django?

2013-03-08 Thread Tim Johnson
* rh [130307 20:21]: > On Wed, 6 Mar 2013 17:55:12 -0900 > Tim Johnson wrote: > > > > > I believe that indifference on the part of Python to fastcgi is a > > self-inflicted wound. I don't believe that there is any good > > excuse for such indiffere

Re: Reversing bits in a byte

2013-03-12 Thread Tim Chase
On 2013-03-11 15:32, Robert Flintham wrote: > I have a 'bytes' object which contains a simple bitmap image (i.e. > 1 bit per pixel). I can't work out how I would go about displaying > this image. Does anyone have any thoughts? You'd need to detail - how you want to display it (console, GUI, web

Re: changes on windows registry doesn�t take effect immediately

2013-03-14 Thread Tim Roberts
effect immediately, so >is there some way to change the windows registry and let the changes >take effect immediately without restarting IE ? No. This is an IE issue, not a registry issue. Other browsers might behave differently. -- Tim Roberts, [email protected] Providenza &am

Re: PyWart: NameError trackbacks are superfluous

2013-03-16 Thread Tim Chase
On 2013-03-16 15:39, Rick Johnson wrote: > On Saturday, March 16, 2013 4:19:34 PM UTC-5, Oscar Benjamin wrote: > > # tmp.py > > def broken(x): > > if x > 2: > > print(x) > > else: > > print(undefined_name) > > > > broken(1) > > Why would anyone write code lik

Re: Message passing syntax for objects

2013-03-18 Thread Tim Harig
On 2013-03-18, Mark Janssen wrote: > Alan Kay's idea of message-passing in Smalltalk are interesting, and > like the questioner says, never took off. My answer was that Alan > Kay's abstraction of "Everything is an object" fails because you can't > have message-passing, an I/O task, working in th

Re: Excel column 256 limit

2013-03-19 Thread Tim Chase
On 2013-03-19 14:07, Neil Cerutti wrote: > On 2013-03-18, Ana Dion?sio wrote: > > But I still get the error and I use Excel 2010. > > > > I'm trying to export data in a list to Excel > > xlrd: Library for developers to extract data from Microsoft Excel > (tm). > > It is for *reading* Excel files

Re: join()

2013-03-20 Thread Tim Chase
On 2013-03-20 14:39, Steven D'Aprano wrote: > Then you join the list of words back > into a single string, using the joint method. Sometimes when I see people make spelling errors, I wonder what they were smoking. Sometimes, it's more obvious... ;-) -tkc -- http://mail.python.org/mailman/list

Re: Test a list

2013-03-20 Thread Tim Chase
On 2013-03-20 11:15, Ana Dionísio wrote: > t= [3,5,6,7,10,14,17,21] > > Basically I want to print Test 1 when i is equal to an element of > the list "t" and print Test 2 when i is not equal: > > while i<=25: > if i==t[]: >print "Test1" > else: >print "Test2" > > What is m

Re: "monty" < "python"

2013-03-20 Thread Tim Delaney
He has shown no inclination to attempt to *fix* the regression and is rapidly coming to be regarded as a troll by most participants in this list. Tim Delaney -- http://mail.python.org/mailman/listinfo/python-list

Re: MySQL database schema discovery

2013-03-22 Thread Tim Golden
On 22/03/2013 16:01, Roy Smith wrote: > What are my options for MySQL schema discovery? I want to be able to > find all the tables in a database, and discover the names and types of > each column (i.e. the standard schema discovery stuff). > > PEP 249 doesn't seem to have any discovery methods.

Re: how does the % work?

2013-03-22 Thread Tim Roberts
Python 3. In Python 3, "print" is a function that returns None. So, the error is exactly correct. To fix it, you need to have the % operator operate on the string, not on the result of the "print" function: print('''Ah, so your name is %s, your quest is %s, and your favorite color is %s.''' % (name, quest, color)) -- Tim Roberts, [email protected] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: Separate Rows in reader

2013-03-24 Thread Tim Chase
On 2013-03-24 09:03, Dave Angel wrote: > >> [THANK YOU!] > > Sorry my typo in the output here is the correct output that i > > need : > > > > [('John Konon', 'Ministry of moon Walks', '4567882', '27-Feb'), > > ( 'Stacy Kisha', 'Ministry of Man Power', '1234567', 17-Jan')] > > > > the difference

Re: Separate Rows in reader

2013-03-24 Thread Tim Chase
On 2013-03-24 08:57, rusi wrote: > On Mar 24, 6:49 pm, Tim Chase wrote: > After doing: > > >>> import csv > >>> original = file('friends.csv', 'rU') > >>> reader = csv.reader(original, delimiter='\t') > > >

Re: how does the % work?

2013-03-24 Thread Tim Roberts
leonardo wrote: > >thank you all! So, what was the problem? -- Tim Roberts, [email protected] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Python 2.7.3 + Docutils + Cygwin = Aborted?

2013-03-25 Thread Tim Daneliuk
lem here is that the python abort is causing the makefile that drives the whole process to stop. The same thing works fine with the same input file on FreeBSD or Linux. Is there a known Cygwin python 2.7 interaction issue? -- ---

Re: list comprehension misbehaving

2013-03-28 Thread Tim Chase
On 2013-03-28 15:25, Wolfgang Maier wrote: > Dear all, with > a=list(range(1,11)) > > why (in Python 2.7 and 3.3) is this explicit for loop working: > for i in a[:-1]: > a.pop() and a As you discover: > Especially, since these two things *do* work as expected: > [a.pop() and a[:] for i in a[

Re: Separate Rows in reader

2013-03-28 Thread Tim Roberts
7; , '421', '27-Oct'), >('Stacy Kisha', 'Ministry of Man Power', '1234567,17-Jan')][/CODE] > >i need ' ' in all the row and the , to be remove after the date Do you have any intention of doing ANY of this work on your o

Re: How to find bad row with db api executemany()?

2013-03-29 Thread Tim Chase
On 2013-03-29 21:19, Roy Smith wrote: > We're doing it all in one transaction, on purpose. We start with > an initial dump, then get updates about once a day. We want to > make sure that the updates either complete without errors, or back > out cleanly. If we ever had a partial daily update, the

Re: How to find bad row with db api executemany()? (PS)

2013-03-29 Thread Tim Chase
On 2013-03-29 22:17, Tim Chase wrote: > 2) Load into a temp table in testable batches, then do some sort of > batch insert into your main table. Again, a quick google suggest > the "INSERT ... SELECT" syntax[2] It looks like there's a corresponding "REPLACE INTO

Re: How to find bad row with db api executemany()?

2013-03-30 Thread Tim Chase
On 2013-03-30 00:19, Dennis Lee Bieber wrote: > I think MySQL is the only common DBMS with an extension on > INSERT of allowing multiple records (I've not checked my Access > 2010 docs, and my MSDE/SQL-Server books are in storage -- but > SQLite3, Firebird, and PostgreSQL all seem to be "one

Re: PSF News: Guido van Rossum quitting Python to develop new, more difficult to learn, language.

2013-04-01 Thread Tim Daneliuk
ance, A la bouffe, ------- Tim Daneliuk -- http://mail.python.org/mailman/listinfo/python-list

Re: PSF News: Guido van Rossum quitting Python to develop new, more difficult to learn, language.

2013-04-01 Thread Tim Daneliuk
ry", do you not? -- --- Tim Daneliuk -- http://mail.python.org/mailman/listinfo/python-list

Re: Why does 1**2**3**4**5 raise a MemoryError?

2013-04-01 Thread Tim Roberts
morphex wrote: > >While we're on the subject, wouldn't it be nice to have some cap there so >that it isn't possible to more or less block the system with large >exponentiation? There IS a cap. It's called the "MemoryError" exception. But, seriously,

Re: Is there a simple stand alone python app I can use on my Kindle fire?

2013-04-01 Thread Tim Roberts
Kindle doesn't run Windows. >I've tried downloading ubuntu to my kindle and couldn't, Did you download the x86 version? That will not work. There are Ubuntu distributions available for the Kindle Fire, but it's going to require getting your hands dirty. Google is your frien

Re: PSF News: Guido van Rossum quitting Python to develop new, more difficult to learn, language.

2013-04-01 Thread Tim Roberts
ming language in which to implement an open source version of the ill-fated Microsoft Bob project. -- Tim Roberts, [email protected] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: question about csv.DictReader

2013-04-03 Thread Tim Chase
On 2013-04-03 18:26, Norman Clerman wrote: > Can anyone explain the presence of the characters "\xref\xbb\xbf" > before the first field contents "Holdings" ? (you mean "\xef", not "\xref") This is a byte-order-mark (BOM), which you can read about at [1]. In this case, it denotes the file as UTF-

Re: In defence of 80-char lines

2013-04-04 Thread Tim Chase
On 2013-04-04 08:43, Peter Otten wrote: > llanitedave wrote: >> self.mainLabel.SetFont(wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.BOLD, faceName >> = "FreeSans")) > > I think I would prefer > > labelfont = wx.Font( > pointSize=12, > style=wx.DEFAULT, > family=wx.NORMAL, > weight=wx.BO

Re: Getting USB volume serial number from inserted device on OSX

2013-04-04 Thread Tim Roberts
ble solution. Every operating system handles this kind of this very differently. Remember, the operating system abstractions are all designed to hide this from you. When you open a serial port or an audio device or use a file system, you aren't supposed to KNOW that there is a USB device behi

Re: How do I tell if I'm running under IDLE?

2013-04-05 Thread Tim Chase
On 2013-04-05 13:37, Steven D'Aprano wrote: > On Fri, 05 Apr 2013 07:04:35 -0400, Dave Angel wrote: > > > On 04/05/2013 05:30 AM, Steven D'Aprano wrote: > >> (Apologies in advance if you get multiple copies of this. My > >> Usenet connection seems to be having a conniption fit at the > >> moment.)

Re: is operator versus id() function

2013-04-05 Thread Tim Delaney
b90ebf2, Sep 29 2012, 10:57:17) [MSC v.1600 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> class A(object): ... def f(self): ... print("A") ... >>> a=A() >>> print(id(a.f) == id(a.f), a.f is a.f) True False >>> Tim Delaney -- http://mail.python.org/mailman/listinfo/python-list

Re: Splitting of string at an interval

2013-04-08 Thread Tim Chase
On 2013-04-08 21:09, Roy Smith wrote: >> http://codegolf.com/99-bottles-of-beer > > I see the top 10 entries are all written in Perl. I suppose this > says something. About the capabilities of Perl for writing such code, or about the drinking habits of Perl programmers? :-) Or-about-how-perl-dr

Re: I hate you all

2013-04-09 Thread Tim Chase
On 2013-04-09 13:39, Grant Edwards wrote: > On 2013-04-09, Mark Lawrence wrote: > > > >> But wouldn't it have been easier simply to do do a quick sed or > >> whatever rather than to spend hours here arguing? > > > > Where's the fun in that? :) > > What, you don't think sed is fun? > > -- > Gran

Re: python-noob - which container is appropriate for later exporting into mySql + matplotlib ?

2013-04-14 Thread Tim Chase
On 2013-04-14 09:40, Ned Deily wrote: > DNS client lookups use published, well-understood > Internet-standard protocols, not at all like talking to a > third-party database, be it open-source or not. That said, even though DNS is a publicly documented standard, I've reached for DNS code in the Py

Re: Grammar question: Englisn and Python: qualified names

2013-04-15 Thread Tim Chase
On 2013-04-15 07:50, Chris Angelico wrote: > Quirky question time! > ... or possibly a collections.OrderedDict... > ... or possibly an collections.OrderedDict... If you're smart enough to elide the "collections [dot]" from your pronunciation, you're smart enough to adjust the a/an accordingly. Use

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