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
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
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
Error: inconsistent use of tabs and spaces in indentation`.
(Python 3, of course. ;)
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
hough probably with shorter names.
Thoughts?
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
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
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
://www.python.org/dev/peps/pep-0420/]
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
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
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~
--
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
, 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
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
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'
, '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
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
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
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
"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
bad_dude}".format(
hapless_twit=solo, mega_bad_dude=jabba)
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
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
d self.h
changes in between?
Surely that would be a major headache.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
Testing 001
The '*' acts as a place holder for the width argument.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
;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("
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(
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
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
cluded" comment -- which batteries are missing?
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
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
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
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
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
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
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
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
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
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
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
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
&
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
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
;)
--> 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
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.
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'?
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
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
due to built-in append())
a.append(large_list)
^- should be a.extend(large_list)
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
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
* 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
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
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
. 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
instance.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
lt;--
Output:
##
Spam!
##
--
Eggs!
--
8<--
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
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
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
-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<--
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
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
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
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
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
!
Absolutely hilarious! Thanks!
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
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
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
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
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
..
Ah, here it is -- Sandeep Mathew, in thread 'Python Support on OpenVMS'
on python-dev.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
nge your prompts, etc.
You might also try IPython (http://ipython.scipy.org/).
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
; 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
amples. Yours don't?
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
ill a write few, read many
operation.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
(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
ick and go to properties... or
something like that ;) .
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
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
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
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
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
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
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
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
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
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
201 - 300 of 1941 matches
Mail list logo