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

2012-05-16 Thread Ethan Furman
Tim Delaney wrote: On 17 May 2012 07:33, Ethan Furman wrote: Just hit a snag: In cPython the deterministic garbage collection allows me a particular optimization when retrieving records from a dbf file -- namely, by using weakrefs I can tell if the record is still in memory and active, and if

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

2012-05-16 Thread Ethan Furman
Chris Angelico wrote: On Thu, May 17, 2012 at 9:01 AM, Ethan Furman wrote: A record is an interesting critter -- it is given life either from the user or from the disk-bound data; its fields can then change, but those changes are not reflected on disk until .write_record() is called; I do

Re: A better contextlib.contextmanager

2012-05-23 Thread Ethan Furman
Michele Simionato wrote: but I am asking a question instead: should I add this feature to the next release of the decorator module? I think it would be an excellent addition to your module. ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: Scoping Issues

2012-05-25 Thread Ethan Furman
Error: inconsistent use of tabs and spaces in indentation`. (Python 3, of course. ;) ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

DBF records API

2012-06-01 Thread Ethan Furman
hough probably with shorter names. Thoughts? ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: DBF records API

2012-06-01 Thread Ethan Furman
MRAB wrote: On 01/06/2012 18:50, Ethan Furman wrote: I'm getting towards an actual non-beta release, which means even more tests, polishings, cleaning up of various things, and actual documentation. :) However, I am wondering about my current record API: Currently, one does things

Re: DBF records API

2012-06-01 Thread Ethan Furman
uch behave just like my record class (although its indexes are only numbers, not strings as well). ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: Import semantics?

2012-06-08 Thread Ethan Furman
://www.python.org/dev/peps/pep-0420/] ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: [Python-Dev] Import semantics?

2012-06-08 Thread Ethan Furman
Eric V. Smith wrote: On 6/8/2012 6:41 PM, Ethan Furman wrote: Dan Stromberg wrote: On Fri, Jun 8, 2012 at 3:16 PM, Ethan Furman wrote: Dan Stromberg wrote: Did the import semantics change in cpython 3.3a4? I used to be able to import treap.py even though I had a treap directory in my cwd

Re: using identifiers before they are defined

2012-06-12 Thread Ethan Furman
each other: def aa(): ... ... a call of bb() somewhere in the body of aa ... def bb(): ... ... a call of aa() somewhere in the body of bb ... Whatever the order of definition of aa and bb the problem remains No. The reply from MRAB explains this. ~Ethan~ --

Re: using identifiers before they are defined

2012-06-12 Thread Ethan Furman
Julio Sergio wrote: Ethan Furman stoneleaf.us> writes: No. The reply from MRAB explains this. ~Ethan~ Thanks, you're right! I was confusing statemens with declarations. Yeah, it took me a while to get that straight as well. ~Ethan~ -- http://mail.python.org/mailman/listinf

Re: Academic citation of Python

2012-06-18 Thread Ethan Furman
, Max". On one occasion Guido complained that Americans always get his name wrong. I've read that now he prefers Guido V. Rossum, Jr. Citation needed. But what format should it take? ;) ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem porting class to python3.2

2011-06-02 Thread Ethan Furman
experienced no problems (besides the tkinter name change). Please post the actual code that is causing the problem ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem porting class to python3.2

2011-06-02 Thread Ethan Furman
I changed to def ld(filename): exec(compile(open(file).read(), file, 'exec')) when I tried ld('starDate.py') at the python3.2 prompt I got the indicated errors Don't know if this helps at all, but when I tried your ld command (after changing 'file'

Re: how to avoid leading white spaces

2011-06-03 Thread Ethan Furman
, 'bar', '', 'spam', 'maps'] I think you've got a typo in there... this is what I get: --> re.split('[ ,]', 'foo bar, spam,maps') ['foo', 'bar', '', 'spam', 'maps'] I would add a

Re: float("nan") in set or as key

2011-06-03 Thread Ethan Furman
Steven D'Aprano wrote: NANs are not necessarily errors, they're hardly silent, and if you don't want NANs, the standard mandates that there be a way to turn them off. So how does one turn them off in standard Python? ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: float("nan") in set or as key

2011-06-04 Thread Ethan Furman
Steven D'Aprano wrote: On Fri, 03 Jun 2011 23:04:38 -0700, Ethan Furman wrote: Steven D'Aprano wrote: NANs are not necessarily errors, they're hardly silent, and if you don't want NANs, the standard mandates that there be a way to turn them off. So how does one turn

Re: Standard Deviation One-liner

2011-06-05 Thread Ethan Furman
experimental stats package, which includes coroutine-based running statistics, including standard deviation: --> s = stats.co.stdev() --> s.send(3) nan Look! A NaN in the wild! :) ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: how to avoid leading white spaces

2011-06-06 Thread Ethan Furman
"TABLE='") + 7 end = line.index("'", start) except ValueError: pass else: line = line[:start] + line[start:end].rstrip() + line[end:] print(line, end='') I like the readability of this version, but isn't generating an exception on every other line going to kill performance? ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: new string formatting with local variables

2011-06-06 Thread Ethan Furman
bad_dude}".format( hapless_twit=solo, mega_bad_dude=jabba) ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: new string formatting with local variables

2011-06-06 Thread Ethan Furman
Prasad, Ramit wrote: print "{} was captured by {}".format(solo, jabba) Is this Python2.7 specific? Python 2.6.x : print "{} was captured by {}".format('t1', 't2') ValueError: zero length field name in format Apparently it is 2.7 and greater -- my ap

Re: GIL in alternative implementations

2011-06-07 Thread Ethan Furman
d self.h changes in between? Surely that would be a major headache. ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: Dynamic Zero Padding.

2011-06-07 Thread Ethan Furman
Testing 001 The '*' acts as a place holder for the width argument. ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: Of Functions, Objects, and Methods-I NEED HELP PLEASE

2011-06-08 Thread Ethan Furman
;Enter Dog Name: ").rstrip() # stupid newlines breed=input ("Enter Dog Breed: ").rstrip() if name and breed: dogs.append(Dog(name, breed)) for i, dog in enumerate(dogs): print("%2i. %s" % (i, dog)) else: print("

Re: Of Functions, Objects, and Methods-I NEED HELP PLEASE

2011-06-09 Thread Ethan Furman
but not broken out of: --> i = 5 --> while i: ... print(i) ... i -= 1 ... else: ... print("blast off!") ... 5 4 3 2 1 blast off! --> i = 5 --> while i: ... print(i) ... i -= 1 ... if i == 3: ... print('aborting') ... break ... else: ... print(

Re: Of Functions, Objects, and Methods-I NEED HELP PLEASE

2011-06-09 Thread Ethan Furman
Ethan Furman wrote: Larry Hudson wrote: On 06/08/2011 01:09 PM, Cathy James wrote: Dog Breed: ")) while not dogs: print("Goodbye!!") sys.exit() else: else does not belong with while. else works just fine with while; it is the path taken wh

Re: how to inherit docstrings?

2011-06-09 Thread Ethan Furman
successfully changed successfully changed <__main__.Test object at 0x00BFE730> Traceback (most recent call last): File "docstring.py", line 25, in obj.__doc__ = 'new docstring' AttributeError: attribute '__doc__' of 'method' objects is not writable Traceback (most recent call last): File "docstring.py", line 25, in obj.__doc__ = 'new docstring' AttributeError: attribute '__doc__' of 'type' objects is not writable successfully changed -actual output ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: What is the most efficient way to compare similar contents in two lists?

2011-06-13 Thread Ethan Furman
cluded" comment -- which batteries are missing? ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

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

2011-06-13 Thread Ethan Furman
ut 40% more for Qwerty versus Dvorak), that is. The actual physical cost of typing is more than dollars and cents. The difference for me is not typing speed, but my wrists. The Dvorak layout is much easier on me than the QWERTY one was. ~Ethan~ -- http://mail.python.org/mailman/listinfo/p

Re: Binding was Re: Function declarations ?

2011-06-13 Thread Ethan Furman
Patty wrote: So I am wondering if you learned this in Computer Science or Computer Engineering?, on the job? I learned it on this list. :) ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: break in a module

2011-06-14 Thread Ethan Furman
e, too -- too bad it doesn't work: c:\temp>\python32\python early_abort.py File "early_abort.py", line 7 return ^ SyntaxError: 'return' outside function ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

os.path and Path

2011-06-15 Thread Ethan Furman
now, the __hash__ must be the same if __eq__ is the same because __hash__ is primarily a shortcut for __eq__ -- this is important when you have containers that are relying on this behavior, such as set() and dict(). So, I suppose I shall have to let go of my dreams of --> Path('/some

Re: os.path and Path

2011-06-16 Thread Ethan Furman
Steven D'Aprano wrote: On Wed, 15 Jun 2011 19:00:07 -0700, Ethan Furman wrote: Thread 1: "objects of different types compare unequal" self: "nonsense! we have the power to say what happens in __eq__!" Thread 2: "objects that __hash__ the same *must* compar

Re: os.path and Path

2011-06-16 Thread Ethan Furman
should be converted to? Are these actual valid paths? I thought Linux used '/' and Mac used ':'. ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: os.path and Path

2011-06-16 Thread Ethan Furman
Christian Heimes wrote: Am 16.06.2011 18:16, schrieb Ethan Furman: Steven D'Aprano wrote: If Path is intended to be platform independent, then these two paths could represent the same location: 'a/b/c:d/e' # on Linux or OS X 'a:b:c/d:e' # on classic Mac pre O

Re: os.path and Path

2011-06-16 Thread Ethan Furman
Steven D'Aprano wrote: On Thu, 16 Jun 2011 09:16:22 -0700, Ethan Furman wrote: Steven D'Aprano wrote: If Path is intended to be platform independent, then these two paths could represent the same location: 'a/b/c:d/e' # on Linux or OS X 'a:b:c/d:e' # o

Re: os.path and Path

2011-06-16 Thread Ethan Furman
Chris Torek wrote: Steven D'Aprano wrote: Why do you think there's no Path object in the standard library? *wink* In article Ethan Furman wrote: Because I can't find one in either 2.7 nor 3.2, and every reference I've found has indicated that the other Path cont

Re: break in a module

2011-06-16 Thread Ethan Furman
uot;that.py", line 2, in yummy print(breakfast) NameError: global name 'breakfast' is not defined 8<--- ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: break in a module

2011-06-16 Thread Ethan Furman
part way, same as you can abort a loop part way. Look back at the context. I was actually talking about the break keyword. The Context: "It's quite consistent on which control structures you can break out of" Hmmm Nope, nothing there to suggest you were talking about the &

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

2011-06-17 Thread Ethan Furman
ng in returned rows (not just indexing); and ability to change values in returned rows (local change only). ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: How to avoid "()" when writing a decorator accepting optional arguments?

2011-06-17 Thread Ethan Furman
our replacement function is drop-in compatible, though, why bother with the whole deprecate decorator? Just drop it in! :) ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

bug in large file writes, 2.x and 3.x

2011-06-17 Thread Ethan Furman
;) --> test.write(data) Traceback (most recent call last): File "", line 1, in IOError: [Errno 22] Invalid argument Any ideas on whether this is Python or MS Windows? (Personally, I'm betting on Windows). ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: bug in large file writes, 2.x and 3.x

2011-06-17 Thread Ethan Furman
Ethan Furman wrote: Windows platform (XP Pro, SP2). This works fine on local drives, but on network (both 2003 Server, and Samba running on FreeBSD) the following produces an error: --> data = '?' * 119757831 # use b'?' if on 3.x --> test = open(r's:\junk.

Re: bug in large file writes, 2.x and 3.x

2011-06-17 Thread Ethan Furman
MRAB wrote: On 17/06/2011 20:15, Ethan Furman wrote: Ethan Furman wrote: Windows platform (XP Pro, SP2). This works fine on local drives, but on network (both 2003 Server, and Samba running on FreeBSD) the following produces an error: --> data = '?' * 119757831 # use b'?&#

Re: Best way to insert sorted in a list

2011-06-17 Thread Ethan Furman
SherjilOzair wrote: What has the community to say about this ? What is the best (fastest) way to insert sorted in a list ? Check out the bisect module. ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

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

2011-06-17 Thread Ethan Furman
opytree so that we can # continue with other files except Error, err: errors.extend(err.args[0]) if errors: raise Error(errors) 8<--- ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: Best way to insert sorted in a list

2011-06-17 Thread Ethan Furman
due to built-in append()) a.append(large_list) ^- should be a.extend(large_list) ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: Python 2.7.2 for Windows reports version as 2.7.0?

2011-06-18 Thread Ethan Furman
6,624 python.exe 06/12/2011 03:06 PM27,136 pythonw.exe Directory of C:\Python27 06/12/2011 03:09 PM26,624 python.exe 06/12/2011 03:06 PM27,136 pythonw.exe Wow -- this part matches up. Anyone else having the same experience? Not I. Given that our hex

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

2011-06-18 Thread Ethan Furman
* characters (player, non-player, monster, etc) will have the same base health and resources then this is fine -- otherwise I would use option 1. ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: Python and Lisp : car and cdr

2011-06-19 Thread Ethan Furman
def car(L): return L[0] def cdr(L): return L[1] IANAL (I am not a Lisper), but shouldn't that be 'return L[1:]' ? def length(L): if not L: return 0 return 1 + length(cdr(L)) How is this different from regular ol' 'len' ? ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: Python and Lisp : car and cdr

2011-06-19 Thread Ethan Furman
Ethan Furman wrote: IANAL (I am not a Lisper), but shouldn't that be 'return L[1:]' ? Ah, thanks all for the clarification. ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: Is there any advantage or disadvantage to using sets over list comps to ensure a list of unique entries?

2011-06-20 Thread Ethan Furman
. This probably only matters beyond a few tens of thousands of items. Depends on the complexity of the object. It only took a couple thousand dbf records to notice a *huge* slowdown using 'in' tests on regular lists. ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: Instances' __setitem__ methods

2011-06-20 Thread Ethan Furman
instance. ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: running an existing script

2011-06-21 Thread Ethan Furman
be called # in this manner and that probably won't work. What you probably want to do is execute the command "python /path/to/nfold.py --fold=5 ..." (include the nfold.py this time ). I have no idea how to do that from Matlab. Good luck! ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: Better way to iterate over indices?

2011-06-21 Thread Ethan Furman
actually need the index, then this is the way to do it. Note that in most cases, you don't need the index and can iterate directly: for v in myList: doStuff(v) From your sample code (assuming you don't need i) this does the same thing. ~Ethan~ -- http://mail.python.org/mailman/listi

Re: running an existing script

2011-06-21 Thread Ethan Furman
Adam Chapman wrote: Thanks Ethan No way could I have worked that out in my state of stress! For your second idea, would I need to type that into the python command line interface (the one that looks like a DOS window? If you are actually in a python CLI, at the top of that screen does it

Re: running an existing script

2011-06-22 Thread Ethan Furman
Adam Chapman wrote: On Jun 21, 9:12 pm, Adam Chapman wrote: On Jun 21, 8:00 pm, Ethan Furman wrote: Adam Chapman wrote: Thanks Ethan No way could I have worked that out in my state of stress! For your second idea, would I need to type that into the python command line interface

Re: running an existing script

2011-06-22 Thread Ethan Furman
Adam Chapman wrote: On Jun 22, 4:54 pm, Adam Chapman wrote: On Jun 21, 9:12 pm, Adam Chapman wrote: On Jun 21, 8:00 pm, Ethan Furman wrote: Adam Chapman wrote: Thanks Ethan No way could I have worked that out in my state of stress! For your second idea, would I need to type that

Re: running an existing script

2011-06-22 Thread Ethan Furman
sure CLASSPATH is set appropriately for your system (e.g. 'set CLASSPATH=c:\java\source'), and jboost.jar is whereever CLASSPATH points to. (I'm not a Java fan, so can't provide much help in this area.) ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: running an existing script

2011-06-22 Thread Ethan Furman
Adam Chapman wrote: Thanks again Ethan, It did begin to run nfold.py this time, after I added the environment variable "CLASSPATH" to my system. It threw back a java error, but I guess this isn;t the right place to be asking about that C:\Users\Adam\Desktop\JBOOST\jboost-2.2\jboost-2

Re: writable iterators?

2011-06-22 Thread Ethan Furman
iterator concept. Is this correct? No. e = blah will rebind the indentifier 'e' with 'blah' whatever that is. That is how python works. Now, if e is mutable, say a list, you can do e.append(blah) and, since the name 'e' is not being rebound, you would see the c

Re: Interpreting Left to right?

2011-06-24 Thread Ethan Furman
x27;huh' is set to the same dictionary. If you try that the other way 'round this happens: >>> x['huh'] = x = {} Traceback (most recent call last): File "", line 1, in NameError: name 'x' is not defined So -- the RHS (right hand side) gets evaluated first, then the LHSs from left to right. ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: unzip problem

2011-06-24 Thread Ethan Furman
fn = open(uncompressed_file, 'wb') ptr = 0 size = len(data) while ptr < size: fn.write(data[ptr:ptr+CHUNK_SIZE]) ptr += CHUNK_SIZE fn.close() ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: unzip problem

2011-06-24 Thread Ethan Furman
fn.write(name[ptr:ptr+CHUNK_SIZE]) # change name to data ptr += CHUNK_SIZE fn.close() ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: unzip problem

2011-06-24 Thread Ethan Furman
ory is empty I store a 0-length file named '__empty__' in that subdirectory (actually, it only happens in the zipfile) so that I can get the directory back later. Hope this helps. ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: Interpreting Left to right?

2011-06-24 Thread Ethan Furman
Tycho Andersen wrote: On Fri, Jun 24, 2011 at 12:14:27AM -0700, Ethan Furman wrote: The example given to me when I had this question: --> x = x['huh'] = {} --> x {'huh': {...}} As you can see, the creation of the dictionary is evaluated, and bound to the name 

Re: unzip problem - solved

2011-06-24 Thread Ethan Furman
e, 'wb') ptr = 0 data = z.read(name) size = len(name) print size print ptr while ptr < size: #fn.write(data) fn.write(data[ptr:ptr+CHUNK_SIZE]) ptr += CHUNK_SIZE fn.close() fh.close() The 'size = len(name)' sho

Re: NEED HELP-process words in a text file

2011-06-24 Thread Ethan Furman
TED UPPERCASE WORDS AS SHOUTING LOUDLY -- regardless of the poor design of programming languages in the 60s and 70s. Well said. :) ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: Significant figures calculation

2011-06-27 Thread Ethan Furman
if t[2] < 0 : return len(t[1]) else : return len(''.join(map(str,t[1])).rstrip('0')) Empirical('1200.').significance 2 Empirical('1200.0').significance 5 What about when 1200 is actually 4 significant digits? Or 3? ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: Significant figures calculation

2011-06-27 Thread Ethan Furman
Harold Fellermann wrote: Hi Ethan, Empirical('1200.').significance 2 Empirical('1200.0').significance 5 What about when 1200 is actually 4 significant digits? Or 3? Then you'd simply write 1.200e3 and 1.20e3, respectively. That's just how the rules are d

Re: Using decorators with argument in Python

2011-06-29 Thread Ethan Furman
lt;-- Output: ## Spam! ## -- Eggs! -- 8<-- ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: Using decorators with argument in Python

2011-06-29 Thread Ethan Furman
Ian Kelly wrote: On Wed, Jun 29, 2011 at 1:30 PM, Ethan Furman wrote: How about just having one bit of code that works either way? How would you adapt that code if you wanted to be able to decorate a function that takes arguments? 8

Re: Using decorators with argument in Python

2011-06-29 Thread Ethan Furman
Ian Kelly wrote: @enclose def test5(string, func): print(func(string)) test5('broken', func=str.upper) Yes, that is a limitation -- one loses the func keyword for the decorated function. If I were to actually use this, I'd probably go with '_func' as the keyw

Re: Enhanced dir() function

2011-07-01 Thread Ethan Furman
-name that gets sourced on every startup. interact.py 8<--- import os, sys sys.ps1 = '--> ' from cookbook.utils import dir # or whereever you keep your copy sys.modules['__builtin__'].dir = dir 8<--

Re: Does hashlib support a file mode?

2011-07-06 Thread Ethan Furman
t separate md5 objects, don't create just one when you create the function, create one inside the function: def file_to_hash(path, m = None): if m is None: m = hashlib.md5() You should try the Principle of Learning the Language. ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: i get different answers based on run platform

2011-07-07 Thread Ethan Furman
linda wrote: I have this simple palindrome program that yields different results depending on whether I run it from Windows or from IDLE. The answer is correct off IDLE, but why is this the case? Here's the code: def reverse(text): return text[::-1] def is_palindrome(text): return text

Re: i get different answers based on run platform

2011-07-07 Thread Ethan Furman
John Gordon wrote: By the way, I could not make your program work as you provided it; I had to replace input() with raw_input(). Does it really work for you this way? input() is the 3.x name for raw_input() ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: i get different answers based on run platform

2011-07-07 Thread Ethan Furman
ay be a trailing '\r' issue. Is there an easy fix or shall I wait for the new Python versions to be released? Thanks for helping. My apologies -- change the '\n' to '\r' and that will hopefully do the trick. ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: Enhanced dir() function

2011-07-12 Thread Ethan Furman
Ethan Furman wrote: Tim Chase wrote: If it came in as an effortless (i.e. O(1) where I do it once and never again; not an O(n) where n=the number of times I invoke Python) default replacement for dir(), I'd reach for it a lot more readily. I seem to recall there's some environm

Re: "Python Wizard," with apologies to The Who

2011-07-12 Thread Ethan Furman
! Absolutely hilarious! Thanks! ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: losing-end-of-row values when manipulating CSV input

2011-07-13 Thread Ethan Furman
32,33,33,35,34 BLS,4,19981102,34,32,33,32,34,32,33,32,34,38,40,41,44,47,43,42,39,36,35,35,36,36,35,33 8<---- Try saving in text-only format. ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: None versus MISSING sentinel -- request for design feedback

2011-07-15 Thread Ethan Furman
ated singletons (Null, NullDate, NullDateTime, NullChar -- which will all compare equal to None) the numeric values will be None... although, now that I've seen this thread, I'll add the ability to choose what the numeric Null is returned as. ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: Possible File iteration bug

2011-07-15 Thread Ethan Furman
implemented -- an exception, a sentinel, or some signal that says "nope, nothing for ya! try back later!" ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: None versus MISSING sentinel -- request for design feedback

2011-07-16 Thread Ethan Furman
Gregory Ewing wrote: Ethan Furman wrote: some of the return values (Logical, Date, DateTime, and probably Character) will have their own dedicated singletons (Null, NullDate, NullDateTime, NullChar -- which will all compare equal to None) That doesn't seem like a good idea to me. It

Re: os.path.isdir do not work for Foder named '2011-07-03'

2011-07-19 Thread Ethan Furman
.. Ah, here it is -- Sandeep Mathew, in thread 'Python Support on OpenVMS' on python-dev. ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: Saving changes to path

2011-07-19 Thread Ethan Furman
nge your prompts, etc. You might also try IPython (http://ipython.scipy.org/). ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: Pipe in the "return" statement

2011-07-25 Thread Ethan Furman
; None or 2 or 0 2 --> None or 2 or 3 2 --> None or [] or 0 0 With 'and', the first falsey item is returned, unless all the items are truthy in which case the last item is returned: --> 2 and 3 3 --> 2 and 0 and 9 0 Hope this helps. ~Ethan~ * 'truthy' = bool(so

Re: PEP 8 and extraneous whitespace

2011-07-25 Thread Ethan Furman
amples. Yours don't? ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: PEP 8 and extraneous whitespace

2011-07-25 Thread Ethan Furman
ill a write few, read many operation. ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: Is this overuse a context manager?

2011-07-26 Thread Ethan Furman
(I know, files are already automatically cleaned up -- at least in cpython; but not every managed object will be a file.) ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: How can I make a program automatically run once per day?

2011-07-26 Thread Ethan Furman
ick and go to properties... or something like that ;) . ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

NoneType and new instances

2011-07-28 Thread Ethan Furman
e that None is a singleton, but so are True and False, and bool is able to handle returning them: --> bool(0) is bool(0) True This feels like a violation of 'Special cases aren't special enough to break the rules.' ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: NoneType and new instances

2011-07-28 Thread Ethan Furman
Ian Kelly wrote: On Thu, Jul 28, 2011 at 9:39 AM, Ethan Furman wrote: Why is NoneType unable to produce a None instance? I realise that None is a singleton, but so are True and False, and bool is able to handle returning them: The bool constructor works (actually just returns one of the

Re: list comprehension to do os.path.split_all ?

2011-07-28 Thread Ethan Furman
Neil Cerutti wrote: If an elegant solution doesn't occur to me right away, then I first compose the most obvious solution I can think of. Finally, I refactor it until elegance is either achieved or imagined. +1 QOTW -- http://mail.python.org/mailman/listinfo/python-list

Re: NoneType and new instances

2011-07-28 Thread Ethan Furman
Chris Angelico wrote: On Fri, Jul 29, 2011 at 7:03 AM, Ethan Furman wrote: I'll use a lambda to get around it, but that's not very elegant. Why shouldn't NoneType be able to return the singleton None? Why a lambda? def ThisFunctionWillReturnNone(): pass Although, sinc

Re: NoneType and new instances

2011-07-28 Thread Ethan Furman
Ben Finney wrote: Ethan Furman writes: Why is NoneType unable to produce a None instance? I realise that None is a singleton That answers your question. Because None is a singleton, the job of its type is to make sure there are no other instances. Which it can do quite easily by returning

Re: Only Bytecode, No .py Files

2011-07-29 Thread Ethan Furman
lly expect someone to post a completely irrelevant trace in a thread started by someone who has a problem. The trace was showing the same results in an effort to demonstrate that the "problem" was just normal operations. This is very relevant. ~Ethan~ -- http://mail.python.org/mai

Re: What's in a name?

2011-07-30 Thread Ethan Furman
not like I'm going to have a Perl or Pascal module in my site-packages. ;) Good luck! ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Windows: setting title of console window

2011-07-30 Thread Ethan Furman
otherwise just says something like 'c:\windows\cmd.exe') is quite nice. Oh, and if you're using Python 3, change SetConsoleTitleA to SetConsoleTitleW. ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: Windows: setting title of console window

2011-07-30 Thread Ethan Furman
n able to access the real argv and set the title bar accordingly. I put the sleep in just to avoid any possible race conditions, but I'm not sure it's necessary. If you don't want to see all the command-line args, you can pre-process command any way you like. ~Ethan~ -- http

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