_standard():
return 1.0
elif self.is_hostile():
return 0.5
elif self is self.fertile:
return 1.5
elif self is self.gaia:
return 2.0
else:
raise AttributeError("Unknown growth_factor for %s" % self)
On 08/06/2013 04:46 PM, Ian Kelly wrote:
On Aug 6, 2013 5:15 PM, "Ethan Furman" mailto:et...@stoneleaf.us>> wrote:
Use the .value attribute instead. You could also substitute self for
Environment.
It feels more natural and readable to compare the enum instances rather t
ty is not equal to a tuple that is empty, much like a car that is empty is not equal to a boat that is
empty.
--
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
t block you won't see the chained
exception in Python3.
--
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
On 08/26/2013 12:37 PM, Marco Buttu wrote:
Since StopIteration is not an error, how come does it inherit directly from
Exception and not from BaseException?
Not all exceptions are errors. (Although not dealing with one can be. ;)
--
~Ethan~
--
http://mail.python.org/mailman/listinfo/python
On 09/01/2013 03:09 AM, Fabrice Pombet wrote:
So I guess that we are actually all agreeing on this one.
No, we are not.
"encapsulation" != "inaccessible except by getters/setters"
--
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
On 09/01/2013 12:13 PM, Roy Smith wrote:
In article ,
Ethan Furman wrote:
On 09/01/2013 03:09 AM, Fabrice Pombet wrote:
So I guess that we are actually all agreeing on this one.
No, we are not.
"encapsulation" != "inaccessible except by getters/setters"
Noth
o me there is a difference between an underlying generic protocol for data manipulation and "Python writing them
[getters/setters] for you".
--
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
On 09/01/2013 05:59 PM, Roy Smith wrote:
Ethan Furman wrote:
On 09/01/2013 02:54 PM, Tim Delaney wrote:
Roy Smith wrote:
Nothing is accessible in Python except via getters and setters. The
only difference between Python and, say, C++ in this regard is that the
Python compiler writes them
27;\'', but no:
--> r'\''
"\\'"
you get a backslash and a single-quote. And if you try to escape the backslash
to get only one?
--> r'\\'
''
You get two. G.
--
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
return func(*args, **kwds)
return wrapper
Then you can say:
class WhateverAccount:
@log
def transaction(self, amount, target):
...
True, you still one line, but moves the logging concern outside the function, where it doesn't r
ule2.
from module1 import method1
which would mean from that point on I could just reference it as method1 rather
than module1.method1, is there such a way I could do this with definitions??
from module1 import data1
--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list
StackOverflow[0] or OpenERP's Q&A website[1].
[0] http://stackoverflow.com
[1] http://help.openerp.com
--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list
nt 'assert len(elts) == 1' ?
--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list
))
True
This is not a trap, this is simply the wrong way to do it. The magic methods (aka dunder methods) are there for Python
to call, not you (except under special circumstances, such as when writing your own dunder methods).
--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list
On 09/12/2013 10:51 AM, Markus Rother wrote:
On 11.09.2013 23:15, Ethan Furman wrote:
On 09/11/2013 01:41 PM, Markus Rother wrote:
>>> () == []
False
But:
>>> bool(().__eq__([]))
True
This is not a trap, this is simply the wrong way to
ot;C:\Python33\lib\site-packages\scipy\interpolate\interpolate.py", line 12, in
import scipy.special as spec
File "C:\Python33\lib\site-packages\scipy\special\__init__.py", line 529, in
from ._ufuncs import *
We'll need the rest of the traceback, as it will have the actual error.
--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list
ogram.
This is partially incorrect. If the value referred to by the name is immutable, then it cannot change; perhaps you
meant to say that which object the name points to can vary over time?
--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list
On 09/30/2013 04:45 PM, Steven D'Aprano wrote:
I can't speak for others, but in my own experience, I never *quite*
understood the semantic differences between Python name bindings and
Pascal variables until I came across the meme "Python has no variables".
+1
--
https://mail.python.org/mailman
On 10/02/2013 07:46 AM, Νίκος wrote:
Στις 2/10/2013 4:58 μμ, ο/η Ned Batchelder έγραψε:
As others have said in this thread, this is not a Python topic. Find
another forum for this question. Do not ask it here again.
You've said that you can improve. Show us by not asking non-Python
questions
e
output queue (finished tasks).
Have you verified that this is a problem in Python?
Or does anyone know of a way to achieve this?
You could try subclassing.
--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list
ff by searching for previous threads discussing it,
and summarise the arguments here?
And then start a new thread. :)
--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list
l...
I change my mind, it shouldn't.
Throw in a .enable() function and call it good. :)
--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list
On 10/05/2013 05:49 AM, macker wrote:
Ugly, menial lines are a clue that a function to hide it could be useful.
Or a clue to add a trivial change elsewhere (hint for Ethan: `return self` at
the end of `Thread.start()`).
I'm aware that would solve your issue. I'm also aware t
ay, None, the some_list[0] would fail with an
error (IndexError, TypeError, etc.).
--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list
ul to me then
echo-argument and.
first_element = some_list[0]# Oops, may crash
some_list[0:1] always works, and sometimes is usable, but you still cannot
index the slice.
Not if some_list is None, False, or another non-indexable type.
--
~Ethan~
--
https://mail.python.org/mailman/lis
That would certainly explain why it's hyper. ;)
--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list
On 10/10/2013 06:41 PM, Terry Reedy wrote:
On 10/10/2013 9:33 AM, Ethan Furman wrote:
On 10/10/2013 12:43 AM, Terry Reedy wrote:
On 10/10/2013 2:45 AM, Chris Angelico wrote:
first_element = some_list[0]# Oops, may crash
some_list[0:1] always works, and sometimes is usable, but you
events because an internal bug is usually counteracted by
the rest of the system, except in some small number of cases. Directly
testing the internal piece directly for the bug can be much easier than
setting up the long and involved test.
--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list
your own stuff so you should have control of
your own decorators (okay, you may have to adapt a few others ;) .
--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list
self.x_length = x_length
self.y_length = y_length
SMALL_CICRLE = 100, 100
LARGE_ELLIPSE = 5000, 3000
=====
[1] enum34 is available on PyPI if you aren't able to move to Python3.4.
--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list
On 10/17/2013 01:57 PM, Ned Batchelder wrote:
Read and listen more. Write and say less.
Mark Janssen has no interest in learning. From a thread long-ago:
Mark Janssen wrote:
Ethan Furman wrote:
Mark Janssen wrote:
Really?
--> int="five"
--> [int(i) for i in ["1&
:D
--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list
t Savings?
Brain freeze! A quick glance told me they were the same, when they
actually are different (68400, 64800). Sorry for the needless noise.
Don't feel too bad, doesn't look like anybody else noticed either! ;)
--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list
y going to be the easiest thing to do as 2.7 has a
bunch of 3.x features.
Sadly, when I backported Enum I was targeting 2.5 - 3.x because I have systems still running 2.5. That was *not* a fun
experience. :(
--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list
On 10/23/2013 09:57 PM, Peter Cacioppi wrote:
Moreover, you get a lot of the good stuff with 2.7.
And the "good stuff" in 2.7 makes it easier to take that last step to 3.x when
the time comes to do so.
--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list
On 10/24/2013 06:41 AM, Tim Daneliuk wrote:
But now I feel bad about myself and it's all your fault.
Really?
*plonk*
--
https://mail.python.org/mailman/listinfo/python-list
ll that, we can have disagreements without name calling.
--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list
On 10/24/2013 01:37 AM, Mark Lawrence wrote:
On 24/10/2013 07:30, Ethan Furman wrote:
On 10/23/2013 09:54 PM, Steven D'Aprano wrote:
I'm looking for advice on best practices for doing so. Any suggestions
for managing bug fixes and enhancements to two separate code-bases
without them
hat's neat (being able to exclude items) is there any reason to
ever count the `if __name__ == '__main__'` clause? Are there any
circumstances where it could run under Coverage? (Apologies if this is
a dumb question, I know nothing about Coverage myself -- but I'm goi
y're more
along the lines of "power generators easily acquired". :)
--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list
On 10/30/2013 01:32 PM, Gene Heskett wrote:
Congratulations Jonas. My kill file for this list used to have only one
name, but now has 2.
You have more patience than I! Jonas just made mine seven. :)
--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list
On 10/30/2013 12:23 PM, jonas.thornv...@gmail.com wrote:
What i actually saying is that you are indeed... [insult snipped]
*plonk*
--
https://mail.python.org/mailman/listinfo/python-list
first.
Then os.path.join is probably the wrong tool for the job. Do you want
to collapse "/foo/bar" + "../quux" into "/foo/quux"? That rewrites the
first. If not, don't use a function that does that. Try simple string
concatenation instead.
Wrong mailing list. ;
On 11/04/2013 09:29 AM, random...@fastmail.us wrote:
I did, incidentally, notice a bug in macpath's *split* function;
macpath.split(':foo::bar') should return (':foo::','bar') rather than
(':foo:','bar').
Open a bug report. :)
http:/
part of the thread has made my
day. I guess trolls can (rarely) have good side effects. :)
--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list
On 11/11/2013 01:28 AM, wxjmfa...@gmail.com wrote:
* Some languages are just fundamentally bad.
The flexible string representation is a perfect exemple.
Argh! He escaped! *chase* *scuffle* *stuff* *stuff* *stuff*
Whew. Safely back in the troll bin.
Okay, back to my day.
--
~Ethan
omatically adjust
itself if DST happens?
Yes, but the scarcity of universal whitespace is preventing me from
posting it.
Boy, are you in luck! I just happen to have a whole heap of marked down ascii
white-space at bargain basement prices!
--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list
On 02/26/2015 11:54 AM, Ian Kelly wrote:
> Sometimes I wonder whether anybody reads my posts.
It's entirely possible the OP wasn't ready to understand your solution four
days ago, but two days later the OP was.
--
~Ethan~
signature.asc
Description: OpenPGP digital signat
t;> http://blog.pyston.org/2015/02/24/pyston-0-3-self-hosting-sufficiency/
From their github site [1]:
Currently, Pyston targets Python 2.7, only runs on x86_64 platforms, and only
has been tested on Ubuntu. Support for
more platforms -- along with Python 3 compatibility -- is desired bu
Sure, for the ones I use as built-ins. But I went through the color file for
vim and took out the built-ins I use
regularly as variables -- and 'id' was the first one to go.
--
~Ethan~
signature.asc
Description: OpenPGP digital signature
--
https://mail.python.org/mailman/listinfo/python-list
C#
>> 86 : C++
>>
> Does any language have more than COBOL? That has hundreds!
I think Visual FoxPro should get at least an (dis)honorable mention -- I didn't
count, but there are several page-fulls [1].
--
~Ethan~
[1] https://msdn.microsoft.com/en-us/library/xztfc506%28v=vs.80%29.aspx
signature.asc
Description: OpenPGP digital signature
--
https://mail.python.org/mailman/listinfo/python-list
s, reverse date order for
listings, auto-nosy -- nothing major.
Any clues greatly appreciated.
--
~Ethan~
signature.asc
Description: OpenPGP digital signature
--
https://mail.python.org/mailman/listinfo/python-list
On 03/04/2015 01:26 AM, Chris Angelico wrote:
> On Wed, Mar 4, 2015 at 5:33 PM, Ethan Furman wrote:
>>
>> I login to the roundup server -- I can search, create new issues, post new
>> messages via both email and the web
>> interface, and I can attach files... but
On 03/04/2015 11:14 AM, Steven D'Aprano wrote:
>
> [...]
>
>
>
Wow -- a new level of succinctness! ;)
--
~Ethan~
signature.asc
Description: OpenPGP digital signature
--
https://mail.python.org/mailman/listinfo/python-list
th a simpler harness (like a Python
> program - see, on-topic now!).
"The connection to the server was reset while the page was loading."
After mucking about with it with no results, I went on to another job -- when I
came back to this one it was working.
--
~Ethan~
signature
False
> >>> foo == bar
> False
> >>> quux = [foo, "spam"]
> >>> "spam" in quux
> True
> >>> foo in quux
> T
On 03/05/2015 07:26 PM, Ben Finney wrote:
> Ethan Furman writes:
>
>> On 03/05/2015 06:55 PM, Ben Finney wrote:
>>
>>> class NullType(object):
>>> """ A type whose value never equals any other.
>>>
>>>
in the back -- that's a grass, isn't it? Hmmm,
well, it grows fast enough that my dogs
haven't managed to eat it gone yet. :)
--
~Ethan~
signature.asc
Description: OpenPGP digital signature
--
https://mail.python.org/mailman/listinfo/python-list
nctness of the
> original! Not saying I will be able -- just that thats the claim
Good luck. :)
--
~Ethan~
signature.asc
Description: OpenPGP digital signature
--
https://mail.python.org/mailman/listinfo/python-list
de is good. The only question is if you /really/ need a singleton --
and only you can answer that (although
plenty of folks will tell you you don't ;) .
--
~Ethan~
signature.asc
Description: OpenPGP digital signature
--
https://mail.python.org/mailman/listinfo/python-list
eturn x+y
>
>
> How do you think about this idea?
It's unnecessary, just use a class instead of a function to get more
clarity.
--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list
On 04/27, Chris Angelico wrote:
> On Mon, Apr 27, 2015 at 2:24 PM, Ethan Furman wrote:
> > On 04/27, Makoto Kuwata wrote:
> >>
> >> I feel that function decorator having arguments is complicated,
> >> because three 'def' are nested:
>
gt; log.log(level, message)
> return func(*args, **kwargs)
> return wrapper
That is a cool trick, thanks for sharing!
--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list
the snippet with a given name.
NAME the name of the snippet
snippet put NAME SNIPPET
Store a snippet with an associated name.
NAME the name of the snippet
SNIPPET the snippet text
-- 8<
--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list
! ;) has a good reason to change those
values in can be done, but it is quite clear that said user is mucking about
with internals and they are on their own.
--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list
noise
for (account, staff), (item, qty, noise) in data.items():
do_stuff_with(account, staff, item, qty, noise)
At the end, data should have what you want. It won't, however, be in
the same order, so hopefully that's not an issue for you.
--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list
that in the standard library, even if it meant that
the library had feature-freeze and could gain no more functionality?
Nope.
--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list
On 05/14/2015 11:43 AM, Chris Warrick wrote:
And if you are looking for a mostly-compliant Python library/app (and
a shameless plug): https://pypi.python.org/pypi/trashman/1.5.0
The docs listed link to Package Builder. How is that related to TrashMan?
--
~Ethan~
--
https://mail.python.org
-trusted-host
in the future.
Downloading numba-0.18.2.tar.gz (507kB)
100% || 507kB 373kB/s
I particularly like how, when you specify --trusted-host, you still get
all the warnings to use --trusted-host... not.
--
~Ethan~
--
https://mail.python.org/mailman
nge(max_files, -1, -1):
if fd in keep:
continue
try:
os.close(fd)
except OSError:
exc = sys.exc_info()[1]
if exc.errno == errno.EBADF:
continue
raise
So, yeah, basically a brute-force method.
--
~Ethan~
[1]
on't know if that's the reason why it was decided to be like that,
or just a nice consequence of the choice to do it that way.
--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list
o:
- support iterating: list(SomeEnum) --> [SomeEnum.first, SomeEnum.second,
SomeEnum.third]
- support a length: len(SomeEnum) --> 3
- not allow new instances to be created: --> SomeEnum(1) is SomeEnum(1) #
True
--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list
On 05/29/2015 02:06 PM, sohcahto...@gmail.com wrote:
On Friday, May 29, 2015 at 10:18:29 AM UTC-7, Ethan Furman wrote:
Metaclasses change the way a class behaves.
For example, the new (in 3.4) Enum class uses a metaclass.
class SomeEnum(Enum):
first = 1
second = 2
On 05/29/2015 02:28 PM, Jason Swails wrote:
[...] e.g., if the person creating an Enum subclass didn't bother to correctly
implement [...] __iter__, and __len__ for their subclass
For __iter__ and __len__ to work on the Enum /class/ it must be defined in the
metaclass.
--
~Ethan~
--
raise SystemExit(attempt.returncode)
Main()
--8<--
Opinions about the usability of the above script, both as the script writer and
as the user, welcomed.
--
~Ethan~
[1] yes, everyone apparently writes their own command-line processor -- this
one is mine. ;)
--
https://mail.python.org/mailman/listinfo/python-list
On 06/03/2015 09:15 AM, Cecil Westerhof wrote:
I kept the except. I like to see the message that went wrong. ;-)
That's fine, but then add a `raise` after you print the error so you can see
the reason that message failed.
--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list
On 06/03/2015 01:37 PM, Mark Lawrence wrote:
On 03/06/2015 19:28, Ethan Furman wrote:
On 06/03/2015 09:15 AM, Cecil Westerhof wrote:
I kept the except. I like to see the message that went wrong. ;-)
That's fine, but then add a `raise` after you print the error so you can
see the reason
, and probably didn't,
import) for only one function is overkill.
edir.dunders = False # or True
is simple, elegant, easier to type, and perfectly in keeping with Python's
dynamic nature.
--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list
butes
on functions aren't normally meant to be changed by outside callers,
I find this viewpoint surprising, since function attributes are fairly rare.
it always feels wrong (they belong to the function itself).
This seems silly -- a function is just another instance of some class.
--
~Eth
have separate entry
points for filtering or not filtering the dunders. Something like:
edir(obj) = no dunders
edir_(obj) = dunders.
`edir_` ? What a horrible name. I hate trailing underscores. Too easy to
miss.
--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list
On 06/16/2015 06:56 AM, Michael Torrie wrote:
On 06/15/2015 06:19 PM, Ethan Furman wrote:
Setting a global on the module (which I may not have, and probably
didn't, import) for only one function is overkill.
What do you mean? Even if you pull in just one function from the
module
On 06/16/2015 06:01 PM, Chris Angelico wrote:
The only instance of gambler's fallacy I'm seeing here is "PointedEars
didn't understand the last dozen emails, so he's due to understand the
next one". I've given up trying to explain.
+1 QotW
--
https://mail.python.org/mailman/listinfo/python-lis
which works:
filter(phone_found, main)
# ['291.792.9000']
My attempt at a lambda function fails:
filter(lambda p: (p in c for c in contacts), main)
# ['291.792.9001', '291.792.9000']
Besides using a lambda ;) , what have I done wrong?
--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list
On 06/25/2015 05:09 PM, Mark Lawrence wrote:
On 26/06/2015 00:59, Chris Angelico wrote:
On Fri, Jun 26, 2015 at 1:59 AM, Ethan Furman wrote:
My attempt at a lambda function fails:
filter(lambda p: (p in c for c in contacts), main)
# ['291.792.9001', '291.792.9000']
Be
call to a function that is given by a term such as »cos( 0 )«
always has the /same/ value.
The input to time() is the result of datetime.datetime.now(); is it
datetime.datetime.now() that is being influenced by the world.
--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list
weak spot for me.
--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list
u fiddle with your object such that all instances hash to the same value
then you lose the O(1) lookup for the dict -- you basically have a list.
--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list
hat's changing.
Of this whole thread, though, I like the 'recurse' keyword proposal best -- I
have no issues with the programmer specifying when to ditch the stack frame,
but maybe that's my assembly roots showing. ;)
--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list
all, if a routine can't handle
a toy example, how is it going to handle real life?)
With responses like these I can understand Antoon's position that folks are not
arguing in good faith.
--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list
definitely uglier and less easy to understand than the original (even if
the original had had the error-checking).
--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list
On 07/16/2015 12:14 PM, Joonas Liik wrote:
You are giving the programmer a choice between "run out of stack and
crash" and "mutilate interpreter internals and crash or zero out the
hard drive" this is not a real choice..
+1
--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list
On 07/16/2015 12:45 PM, Terry Reedy wrote:
On 7/16/2015 2:02 PM, Ethan Furman wrote:
On 07/16/2015 06:35 AM, Antoon Pardon wrote:
Here is one way to do the odd, even example.
def even(n):
return odd_even('even', n)
def odd(n):
return odd_even('odd', n)
ot;transfer f()" is equivalent to "return f()", except that
the current function finishes before the target is entered.
Sounds cool! Code it up and let us know how it goes. :)
--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list
. Current candidates:
"transfer", "goto", "recurse", and anything else you suggest.
I propose the combination "return from".
+1
--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list
On 06/05/2014 04:30 PM, Marko Rauhamaa wrote:
What I'm afraid of is that the Python developers are reserving the right
to remove the buffer and detach attributes from the standard streams in
a future version.
Being afraid is silly. If you have a question, ask it.
--
~Ethan~
--
ASCII was, in fact, an encoding was a big paradigm
shift for me, but a necessary one.
--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list
On 06/05/2014 09:32 AM, Steven D'Aprano wrote:
But whatever the situation, and despite our differences of opinion about
Unicode, THANK YOU for having updated ReportLabs to 3.3.
+1000
--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list
t
return, some kind of error ought to be raised.
--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list
On 06/09/2014 03:21 PM, Josh English wrote:
So this quirk is coming from PyScripter, which is a shame, because I don't
think it's under development, so it won't be fixed.
The nice thing about Python code is you can at least fix your copy. :)
--
~Ethan~
--
https://mail.pyt
1101 - 1200 of 1941 matches
Mail list logo