Chris Angelico wrote:
On Sat, Jul 30, 2011 at 7:39 PM, Ethan Furman wrote:
Well, you /could/ have followed the link and read the explanation there...
;)
I tend to avoid clicking random links in posts :)
Ah -- I understand.
How it works: since the sys.argv object does yet exist
n\tbar+=1\n\treturn 1\n"
--> bar = 9
--> foo()
1
--> bar
10
Laszlo, why do you think you can't use exec?
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
Thomas Jollans wrote:
On 30/07/11 20:39, Ethan Furman wrote:
How it works: since the sys.argv object does yet exist, I create an
object and assign it to sys.argv; then, when Python assigns the actual
argv to sys.argv, my object is tossed, and the __del__ method is called;
the __del__ method is
) used to behave, except it works with
values of arbitrary size. The latter no longer exists.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
Howdy,
I'm going to setup a few linux systems for testing (probably three) as
well as the three FreeBSD, OpenBSD, and (possibly) NetBsd. Oh, and
Windows. ;)
Any recommendations on which linuces to pick?
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
flow route, someone may have a module to put on
PyPI, etc., etc.
Hope this helps!
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
= 0x10
self.assertRaises(ValueError, bcd_to_int, msb, lsb)
unittest.main()
8<-
Hope this helps.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
wo bytes i need, but don't know
where to go from there.
thanks for any tips on this.
The value is MSB * 100 + (LSB >> 4) * 10 + (LSB & 0xF)
Not according to the docs -- msb has two digits, lsb has one and garbage.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
docstring from the integer, not for the property.
--> t.__class__.fred.__doc__
'attribute'
So if property docstrings are so hard to get to, what's the point in
having them?
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
ble via an `import *`.
History lessons, as well as ideas, welcomed!
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
encouraged so much to do so, I think I will.
Your choice, obviously -- seems a shame to me, though, to give up on
Python because of one or two ouchy areas on c.l.py. By and large it's a
very helpful and courteous community.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
c,
that make up the primary part of the dbf module can do
from dbf.api import *
but
help(dbf)
will continue to list all the other public utility stuff (defined in
dbf.__all__) normally.
Thanks to all!
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
! ;)
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
ights need to be controlled by someone who knows when the
movie's end signal should be sent. What is our ending signal if we're
watching it from media in our home, and no-one in the house knows when
the movie ends?
If it's a tape, it'll stop, or start rewinding; if it's a DVD
Gerrat Rickert wrote:
What sayest the Python community about having an explicit warning
against such un-pythonic behaviour (re-assigning builtin names)?
What makes you think this behavior is unpythonic? Python is not about
hand-holding.
~Ethan~
--
http://mail.python.org/mailman/listinfo
Seebs wrote:
On 2011-08-15, Ethan Furman wrote:
Gerrat Rickert wrote:
What sayest the Python community about having an explicit warning
against such un-pythonic behaviour (re-assigning builtin names)?
What makes you think this behavior is unpythonic? Python is not about
hand-holding.
It
sing a builtin, such as str or
int, and that they somehow manage to do this without realizing, "wait a
sec', that's one of my variables!" I don't see that as a problem that
Python needs to solve.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
Philip Semanchuk wrote:
On Aug 16, 2011, at 11:41 AM, Ethan Furman wrote:
Philip Semanchuk wrote:
If we are to eschew warnings in
cases where they might be highlighting something harmless, then we would
have no warnings at all.
>>
Sounds good to me. ;) Keep such things in the IDE&
e, however, between offering
warnings to newbie programmers (which is how this thread started), and
memory management.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
Seebs wrote:
On 2011-08-16, Ethan Furman wrote:
I think warnings should be reserved for language changes and such (like
DeprecationWarning, RuntimeWarning, and FutureWarning), not for possible
programmer mistakes.
I disagree, on the basis of the following:
The quality of C code I have to
Seebs wrote:
On 2011-08-16, Ethan Furman wrote:
What makes you think it's unintentional?
Programming experience.
People *often* do things unintentionally.
Seems to me the real issue is somebody using a builtin, such as str or
int, and that they somehow manage to do this without real
Welcome to my killfile.
*plonk*
--
http://mail.python.org/mailman/listinfo/python-list
do?
Monkey-patching built-ins would be something along the lines of
import sys
sys.modules['__builtin__'].str = my_super_string
and is what stands you in jeopardy of being fish-slapped. ;)
Merely shadowing a built-in, or stdlib, or whatever, isn't monkey-patching.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
Seebs wrote:
Pathological narcissism is scary. If you ever find yourself going longer
than usual without being wrong, start checking your work more carefully. :)
+1 QOTW
--
http://mail.python.org/mailman/listinfo/python-list
Seebs wrote:
On 2011-08-17, Ethan Furman wrote:
Seebs wrote:
On 2011-08-17, Steven D'Aprano wrote:
Ah, well you see the thing is, this is Python. As soon as you call any
function you don't control, you no longer know what your environment is
with any certainty. For all you know, th
not be the same.
Oh, and I put the trailing _ on count and object to minimize possible
conflicts with keyword arguments.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
I have WordPerfect v13 which we are currently using for letter merges.
I would like to automate this with Python instead of learning the WP
Macro language.
Does anyone have any pointers?
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
looked at.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
John Gordon wrote:
I suspect that learning how to integrate python with wordperfect will
end up being much more work than learning wordperfect macros.
Possibly... but I enjoy coding in Python. :)
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
ng is when the error is simply tossed with no record
whatsoever... what a pain to debug!
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
ams, e.code))
does anything like this exist?
%.50s
That's not working in 2.7 or 3.2.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
Seebs wrote:
On 2011-08-23, Ethan Furman wrote:
Seebs wrote:
On 2011-08-23, Roy Smith wrote:
logger.error("FAILED: '%s{50}', '%s', %s, %s" % (message,
route, params, e.code))
does anything like this exist?
%.50s
That's not working in
ave
nothing on it for another three weeks until the next podcast is ready!" ??
I vote with Terry.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
mmer looked at my code,
they'd immediately know I was missing a few things.
The best thing to do now is pick something and run with it. (Sounds
like you have.) Expect to redesign and reimplement three or four times
as you get a feel for what's pythonic. And have fun!
~Ethan~
--
http:/
user code has more than one
def/class/name assignment, you won't have ready access to the first
items, only that last one.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
Rob Williscroft wrote:
Ethan Furman wrote in news:4e5d29c8.8010...@stoneleaf.us in
gmane.comp.python.general:
Jack Trades wrote:
On Tue, Aug 30, 2011 at 2:37 AM, Rob Williscroft wrote:
If an impementation (as you say up thread) can populate globals
or locals with whatever they want, then
the docs don't say they can't.
Yet another excellent reason to have unit tests!
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
d reasons are required to make life difficult (at least with Python).
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
I asked a question a couple weeks ago about scripting WordPerfect with
Python, and a couple respondents suggested LaTeX was very good. Where
would I start if I wanted to learn about it?
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
bits
of precision than if you store after each operation.
That's a big if though. Which languages support such a thing? C doubles
are 64 bit, same as Python.
Assembly! :)
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
on.
--> import base64
--> base64.encodestring(b'another test')
b'dGhpcyBpcyBhIHRlc3Q=\n'
The deprecation warning has gone away in 3.2, but the function
remains... does anyone know if this was intentional?
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
Terry Reedy wrote:
On 2/28/2011 3:51 PM, Ethan Furman wrote:
The deprecation warning has gone away in 3.2,
No, still there:
def encodestring(s):
"""Legacy alias of encodebytes()."""
import warnings
warnings.warn("encodestring() is a
#x27;)
and then both .hdf and .hdf5 files will get matched.
Try making extensions a tuple.
Hope this helps, but if it doesn't, follow Grant's advice.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
(self, ):
super(NewClass, self).__init__(....)
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
.com/
One thing to keep in mind is that not all widgets in tkinter have been
migrated to ttk (although Frame was).
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
ontent-Type', 'text/plain;\n name="tables.py"'),
('Content-Transfer-Encoding', '7bit'),
('Content-Disposition', 'inline;\n filename="tables.py"')]
[('Content-Type', 'application/x-zip-compressed;\n name="dbf-0.88.18.zip"'),
('Content-Transfer-Encoding', 'base64'),
('Content-Disposition', 'inline;\n filename="dbf-0.88.18.zip"')]
8<-
Hope this helps!
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
r?
UserDict is a module -- you want to subclass the UserDict class inside
the module...
class FileInfo(UserDict.UserDict):
"etc etc"
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
e the current directory:
os.chdir('/some/new/path')
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
))
['c:/temp\\choose_python.pdf',
'c:/temp\\COA.pdf',
'c:/temp\\job_setup.pdf']
Visually ugly, and a pain to compare files and paths.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
quot;)
lineList = fin.readlines()
fin.close()
for line in lineList:
line = re.sub(r'(\\begin{document})(.+)', r'\1\n\n\2', line)
outlist.append(line)
fou = open(myfile, "w")
for line in outlist:
fou.write(line)
fou.close
8<---
Hope this helps!
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
On 3/18/2011 6:25 PM, Dan Stromberg wrote:
On Fri, Mar 18, 2011 at 4:00 PM, Ethan Furman mailto:et...@stoneleaf.us>> wrote:
Dan Stromberg wrote:
Are you on windows?
You probably should use / as your directory separator in Python,
not \. In Python, and most
e'll never know...
(unless you're the curious type ;).
Oh, and as for the original question, I think I've used the copy module
once.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
;, line 38, in
tokens = lines.split(",")
AttributeError: 'list' object has no attribute 'split'
Check out the line just above my snip.
Did you mean for that line to be there? It's /almost/ the same line you
have down in the for loop.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
with all the necessary libraries and support .py files,
are combined into a .exe loader. When the .exe is run it extracts the
Python interpreter, makes all the other files available, and then starts
it running.*
~Ethan~
*The details are not exact, but this is the general idea.
--
he folks downloading your
package (assuming you distribute it).
For myself, I do keep my tests in a folder in the package itself --
keeps it out of the way (any necessary files also go there).
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
.append(filePath)
return result
for filePath in FindMedia(path):
log(filePath)
Change
if iFile in media:
to
if iFile.upper() in media:
and keep media all upper-case.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
companies
with posters on this list that are successful in supporting *and
selling* open-source software.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
r
2) Collect the errors, then have the top-most consumer check for errors
and print them out before reading the next generator output.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
interpretation from the wording given in the documentation ?
Look at your original post, which contains the excerpt from the docs
that you put there:
>
> bool([x])
> Convert a value to a Boolean, using the standard truth testing
> procedure.
>
As you can see, the parameter
Mel wrote:
Python is a pragmatic language, so all the rules come pre-broken.
+1 QOTW
--
http://mail.python.org/mailman/listinfo/python-list
I see nothing there to concretely
make that point except the question mark on the return.
Hope this helps.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
Westley Martínez wrote:
On Tue, 2011-04-12 at 16:06 -0700, Ethan Furman wrote:
--> def func():
--> var1 = something()
--> var2 = something_else('this')
--> return? var1.hobgle(var2)
--> var3 = last_resort(var1)
--> return var3.wiglat(var2)
Steven D'Aprano wrote:
On Tue, 12 Apr 2011 16:48:31 -0700, Ethan Furman wrote:
Westley Martínez wrote:
On Tue, 2011-04-12 at 16:06 -0700, Ethan Furman wrote:
--> def func():
--> var1 = something()
--> var2 = something_else('this') --> return?
var
James Mills wrote:
On Thu, Apr 14, 2011 at 10:39 AM, rantingrick wrote:
[weapon of mass-snippitude]
James,
*Please* don't re-post his crap.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
ou can prove it".
If you can prove it, you know you're right. Unfortunately, being right
doesn't mean you win the argument. :(
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
they *don't* follow standards,
which makes interoperability a nightmare.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
sv file, this might
be an easier way to access them. Field names can also be specified when
opening the csv file, I didn't bother for this example since I don't
know what all your field names are. ;)
Hope this helps!
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
ript with possible name clashes"
eggs = 'scrambled eggs'
meat = 'steak'
class Breakfast():
meat = 'spam'
def serve(self):
print("Here's your %s and %s!" %
(eggs, meat))
Breakfast().serve()
8<--
usually named 'self'. So your above code
(to stick with your 'x') should be:
def g(x):
return x.foo
or to follow normal naming conventions:
def g(self):
return self.foo
~Ethan~
*It is also possible to write special methods that take the class
ever just tries:
--> if method == 'boat':
--> blah()
then you'll get a NameError because the 'd' namespace will not be
automatically searched. You would have to do:
--> if d['method'] == 'boat':
--> blah()
to find the variable in that namespace.
Hope this helps.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
of
BaseHandler?
You don't need to create an instance of BaseHandler. You have the
class, Python knows you have the class -- Python will look there if the
subclasses lack an attribute.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
Kyle T. Jones wrote:
Ethan Furman wrote:
chad wrote:
Let's say I have the following
class BaseHandler:
def foo(self):
print "Hello"
class HomeHandler(BaseHandler):
pass
Then I do the following...
test = HomeHandler()
test.foo()
How can HomeHandler ca
Hans Georg Schaathun wrote:
List comprehension is understood even by readers with no experience
with python.
There's nothing magically understandable about a list comp -- the first
time I saw one (which was in Python), I had to learn about them.
~Ethan~
--
http://mail.python.org/ma
For anybody interested in composition instead of multiple inheritance, I
have posted this recipe on ActiveState (for python 2.6/7, not 3.x):
http://code.activestate.com/recipes/577658-composition-of-classes-instead-of-multiple-inherit/
Comments welcome!
~Ethan~
--
http://mail.python.org
class inherits from unittest2.TestCase, which we
> found was not calling super.
This is the type of situation the decorator was written for (although
it's too simplistic to handle that exact case, as Ricardo goes on to say
he has a setUp in each mixin that needs to be cal
James Mills wrote:
On Fri, Apr 29, 2011 at 11:43 AM, Ethan Furman wrote:
Hmmm. Okay -- any ideas for a better term? Something that describes taking
different source classes and fusing them into a new whole, possibly using
single-inheritance... Frankenstein, maybe? ;)
I'd have to say
Carl Banks wrote:
Here is my advice on mixins:
[snip]
Cool. Thanks!
~Ethan
--
http://mail.python.org/mailman/listinfo/python-list
Ian Kelly wrote:
On Thu, Apr 28, 2011 at 11:15 AM, Ethan Furman wrote:
For anybody interested in composition instead of multiple inheritance, I
have posted this recipe on ActiveState (for python 2.6/7, not 3.x):
http://code.activestate.com/recipes/577658-composition-of-classes-instead-of
on unittest2.TestCase, which was not calling super. I understand,
however, that if the mixins were listed before TestCase that it would work.
Hope this helps.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
the article states in the next
paragraph:
"Even among languages that don't exactly support call-by-reference,
many, including C and ML, support explicit references (objects that
refer to other objects), such as pointers"
~Ethan~
PS
My thanks to those who kept explaining in variou
rst:
next(iter(myDict.items()))
Which is becoming less elegant. Seems to me that View objects should be
directly iterable, but then I don't really understand the motivation
behind them or what greatness is facilitated by having them.
Anybody care to chime in with their usage of thi
l thinking in some language that isn't Python.
Which most of us are... hate to remind you... Python is the new kid
on the block, and most of us are coming at this from multiple filters in
comp sci experience. Its just the truth.
And your point would be?
If you're goi
or nitpick -- having a comment saying "this doesn't work" then having
output showing that it does is confusing. I had to load up the
interpretor to make sure I was confused! ;)
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
u'll see a value with no '_' in it -- at that point you
can track down why.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
James Wright wrote:
Thank you Ethan,
This is what I see now:
# python render4.py
current each_value is: vsr
Traceback (most recent call last):
File "render4.py", line 115, in
create_report_index(each_item)
File "render4.py", line 26, in create_report_i
James Wright wrote:
On Mon, May 9, 2011 at 3:36 PM, Ethan Furman wrote:
Change your print line to:
print("D4[%s] = %s" % (report, each_value))
After that, you'll have to track down how D4 is being created to see where
'vsr' is coming from.
It does not appear t
James Wright wrote:
On Mon, May 9, 2011 at 4:04 PM, Ethan Furman wrote:
James Wright wrote:
On Mon, May 9, 2011 at 3:36 PM, Ethan Furman wrote:
>>>>
Change your print line to:
print("D4[%s] = %s" % (report, each_value))
After that, you'll have to track down how
Ian Kelly wrote:
On Fri, May 6, 2011 at 4:49 PM, Ethan Furman wrote:
Anybody care to chime in with their usage of this construct?
You should start with PEP 3106. The main idea is that dict.keys() and
dict.items() can be treated as frozensets, while still being more
lightweight than lists
ther anything is there. 0 apples is
nothing and a an empty list is nothing as well.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
does not do the job at all.
: I may not have made the point well, but I cannot see any advantage
: for trying to program for the lowest common denominator.
Common to what? I'd try the lowest common denominator of
legibility and effictiveness.
It is just KISS.
'if li' *is* KI
;,False)
self.status = kwargs.get('status',False)
class RD(object):
def __init__(
self,
env=False,
side=False,
zone=False,
feed=False,
hostname=False,
process=False,
status=False
):
self.env = env
l you get home and realize you
forgot something).
Um -- you contradicted Ian, then contradicted yourself -- according to
your scenario your shopping list is *not* empty when you go to the store
(otherwise known as "going shopping" ;).
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
analogous to a square (2 sets of parallel lines
joined at 90 degree angles, both sets being the same length) also being
a rectangle (2 sets of parallel lines joined at 90 degree angles).
What's the intended behavior here? Either the code is wrong or the docs
> are wrong.
The code
nt
> result for all types of obj1 and obj2.
Where do you see that? I couldn't find it.
The point of being able to write your own rich comparison methods is so
you can control what happens -- there is no "must" about it. This is
Python -- do what you want! :)
~Et
exception.
class HelloError(Exception):
"custom exception"
and that's all you need. You can override __init__ to add your own
attributes, etc, if you need to.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
Roy Smith wrote:
On May 12, 2:29 pm, Ethan Furman wrote:
While it is wrong (it should have 'built-in' precede the word 'types'),
it is not wrong in the way you think -- a subclass *is* a type of its
superclass.
Well, consider this:
class List_A(list):
"A lis
Steven D'Aprano wrote:
On Thu, 12 May 2011 09:43:23 -0700, Ethan Furman wrote:
MyList is a list -- just a more specific kind of list -- as can be seen
from its mro; this is analogous to a square (2 sets of parallel lines
joined at 90 degree angles, both sets being the same length) also be
that this is an immutable type, so you cannot
go in later and say
--> huh[3] = 9
Traceback (most recent call last):
File "", line 1, in
TypeError: 'bytes' object does not support item assignment
So, out of curiosity, does anyone actually use this, um, feature?
~E
Joe Leonardo wrote:
Totally baffled by this…maybe I need a nap. Writing a small function to
reject input that is not a list of 19 fields.
def breakLine(value):
if value.__class__() != [] and value.__len__() != 19:
print 'You must pass a list that contains 19 fields.'
else:
Felipe Bastos Nunes wrote:
2011/5/17 Ethan Furman wrote:
In Python 3 one can say
--> huh = bytes(5)
Since the bytes type is actually a list of integers, I would have
expected this to have huh being a bytestring with one element -- the
integer 5. Actually, what you get is:
-->
301 - 400 of 1941 matches
Mail list logo