Re: Windows: setting title of console window

2011-07-30 Thread Ethan Furman
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

Re: eval, exec and execfile dilemma

2011-07-30 Thread Ethan Furman
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

Re: Windows: setting title of console window

2011-07-30 Thread Ethan Furman
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

Re: What is xrange?

2011-07-30 Thread Ethan Furman
) 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

test systems

2011-08-01 Thread Ethan Furman
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

Re: Community Involvement

2011-08-04 Thread Ethan Furman
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

Re: problem with bcd and a number

2011-08-04 Thread Ethan Furman
= 0x10 self.assertRaises(ValueError, bcd_to_int, msb, lsb) unittest.main() 8<- Hope this helps. ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: problem with bcd and a number

2011-08-04 Thread Ethan Furman
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

Re: Docstrings and class Attributes

2011-08-08 Thread Ethan Furman
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

__all__

2011-08-09 Thread Ethan Furman
ble via an `import *`. History lessons, as well as ideas, welcomed! ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: allow line break at operators

2011-08-11 Thread Ethan Furman
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

Re: __all__

2011-08-12 Thread Ethan Furman
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

Re: allow line break at operators

2011-08-12 Thread Ethan Furman
! ;) ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: allow line break at operators

2011-08-14 Thread Ethan Furman
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

Re: Why no warnings when re-assigning builtin names?

2011-08-15 Thread Ethan Furman
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

Re: Why no warnings when re-assigning builtin names?

2011-08-15 Thread Ethan Furman
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

Re: Why no warnings when re-assigning builtin names?

2011-08-16 Thread Ethan Furman
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

Re: Why no warnings when re-assigning builtin names?

2011-08-16 Thread Ethan Furman
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&

Re: Why no warnings when re-assigning builtin names?

2011-08-16 Thread Ethan Furman
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

Re: Why no warnings when re-assigning builtin names?

2011-08-16 Thread Ethan Furman
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

Re: Why no warnings when re-assigning builtin names?

2011-08-16 Thread Ethan Furman
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

Re: Wait for a keypress before continuing?

2011-08-17 Thread Ethan Furman
Welcome to my killfile. *plonk* -- http://mail.python.org/mailman/listinfo/python-list

Re: Why no warnings when re-assigning builtin names?

2011-08-17 Thread Ethan Furman
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

Re: Wait for a keypress before continuing?

2011-08-17 Thread Ethan Furman
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

Re: Why no warnings when re-assigning builtin names?

2011-08-17 Thread Ethan Furman
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

Re: Syntactic sugar for assignment statements: one value to multiple targets?

2011-08-17 Thread Ethan Furman
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

Word Perfect integration

2011-08-18 Thread Ethan Furman
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

Re: Word Perfect integration

2011-08-18 Thread Ethan Furman
looked at. ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: Word Perfect integration

2011-08-18 Thread Ethan Furman
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

Re: try... except with unknown error types

2011-08-21 Thread Ethan Furman
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

Re: truncating strings

2011-08-23 Thread Ethan Furman
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

Re: truncating strings

2011-08-23 Thread Ethan Furman
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

Re: Announcing a new podcast: Radio Free Python

2011-08-24 Thread Ethan Furman
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

Re: Checking Signature of Function Parameter

2011-08-29 Thread Ethan Furman
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:/

Re: Returning a value from exec or a better solution

2011-08-30 Thread Ethan Furman
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

Re: Returning a value from exec or a better solution

2011-08-30 Thread Ethan Furman
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

Re: Returning a value from exec or a better solution

2011-08-30 Thread Ethan Furman
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

Re: Returning a value from exec or a better solution

2011-08-30 Thread Ethan Furman
d reasons are required to make life difficult (at least with Python). ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

slightly OT -- LaTeX

2011-09-01 Thread Ethan Furman
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

Re: Python fails on math

2011-02-24 Thread Ethan Furman
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

3.1 -> 3.2: base64 lost deprecation warning

2011-02-28 Thread Ethan Furman
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

Re: 3.1 -> 3.2: base64 lost deprecation warning

2011-02-28 Thread Ethan Furman
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

Re: question about endswith()

2011-03-03 Thread Ethan Furman
#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

Re: Defining class attributes + inheritance

2011-03-08 Thread Ethan Furman
(self, ): super(NewClass, self).__init__(....) ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: ttk styles

2011-03-17 Thread Ethan Furman
.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

Re: email library

2011-03-18 Thread Ethan Furman
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

Re: class error

2011-03-18 Thread Ethan Furman
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

Re: Reading/Writing files

2011-03-18 Thread Ethan Furman
e the current directory: os.chdir('/some/new/path') ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: Reading/Writing files

2011-03-18 Thread Ethan Furman
)) ['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

Re: Problem with re module

2011-03-22 Thread Ethan Furman
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

Re: Reading/Writing files

2011-03-25 Thread Ethan Furman
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

Re: Why aren't copy and deepcopy in __builtins__?

2011-03-28 Thread Ethan Furman
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

Re: Python problem

2011-03-28 Thread Ethan Furman
;, 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

Re: Directly Executable Files in Python

2011-03-29 Thread Ethan Furman
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. --

Re: Data files for tests

2011-03-30 Thread Ethan Furman
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

Re: In List Query -> None Case Sensitive?

2011-03-31 Thread Ethan Furman
.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

Re: [OT] Free software versus software idea patents

2011-04-08 Thread Ethan Furman
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

Re: Generators and propagation of exceptions

2011-04-08 Thread Ethan Furman
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

Re: Argument of the bool function

2011-04-08 Thread Ethan Furman
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

Re: Argument of the bool function

2011-04-11 Thread Ethan Furman
Mel wrote: Python is a pragmatic language, so all the rules come pre-broken. +1 QOTW -- http://mail.python.org/mailman/listinfo/python-list

Re: Feature suggestion -- return if true

2011-04-12 Thread Ethan Furman
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

Re: Feature suggestion -- return if true

2011-04-12 Thread Ethan Furman
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)

Re: Feature suggestion -- return if true

2011-04-12 Thread Ethan Furman
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

Re: Egos, heartlessness, and limitations

2011-04-13 Thread Ethan Furman
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

Re: Free software versus software idea patents

2011-04-14 Thread Ethan Furman
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

Re: [OT] Free software versus software idea patents

2011-04-14 Thread Ethan Furman
they *don't* follow standards, which makes interoperability a nightmare. ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: Pythonic infinite for loop?

2011-04-15 Thread Ethan Furman
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

Re: Namespaces in functions vs classes

2011-04-17 Thread Ethan Furman
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<--

Re: Namespaces in functions vs classes

2011-04-17 Thread Ethan Furman
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

Re: Namespaces in functions vs classes

2011-04-19 Thread Ethan Furman
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

Re: A question about Python Classes

2011-04-21 Thread Ethan Furman
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

Re: A question about Python Classes

2011-04-22 Thread Ethan Furman
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

Re: De-tupleizing a list

2011-04-26 Thread Ethan Furman
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

Composition instead of inheritance

2011-04-28 Thread Ethan Furman
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

Re: Composition instead of inheritance

2011-04-28 Thread Ethan Furman
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

Re: Composition instead of inheritance

2011-04-29 Thread Ethan Furman
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

Re: Composition instead of inheritance

2011-04-29 Thread Ethan Furman
Carl Banks wrote: Here is my advice on mixins: [snip] Cool. Thanks! ~Ethan -- http://mail.python.org/mailman/listinfo/python-list

Re: Composition instead of inheritance

2011-04-29 Thread Ethan Furman
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

Re: Needed: Real-world examples for Python's Cooperative Multiple Inheritance

2011-05-04 Thread Ethan Furman
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

Re: What other languages use the same data model as Python?

2011-05-05 Thread Ethan Furman
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

Dictionary Views -- good examples? [was Re: Python 3 dict question]

2011-05-06 Thread Ethan Furman
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

Re: checking if a list is empty

2011-05-07 Thread Ethan Furman
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

Re: What other languages use the same data model as Python?

2011-05-09 Thread Ethan Furman
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

Re: Inconsistency with split() - Script, OS, or Package Problem?

2011-05-09 Thread Ethan Furman
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

Re: Inconsistency with split() - Script, OS, or Package Problem?

2011-05-09 Thread Ethan Furman
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

Re: Inconsistency with split() - Script, OS, or Package Problem?

2011-05-09 Thread Ethan Furman
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

Re: Inconsistency with split() - Script, OS, or Package Problem?

2011-05-09 Thread Ethan Furman
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

Re: Dictionary Views -- good examples? [was Re: Python 3 dict question]

2011-05-10 Thread Ethan Furman
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

Re: checking if a list is empty

2011-05-11 Thread Ethan Furman
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

Re: checking if a list is empty

2011-05-11 Thread Ethan Furman
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

Re: How to deal with optional argument evaluation

2011-05-11 Thread Ethan Furman
;,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

Re: checking if a list is empty

2011-05-12 Thread Ethan Furman
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

Re: list equal to subclass of list?

2011-05-12 Thread Ethan Furman
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

Re: list equal to subclass of list?

2011-05-12 Thread Ethan Furman
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

Re: Proper way to handle errors in a module

2011-05-12 Thread Ethan Furman
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

Re: list equal to subclass of list?

2011-05-12 Thread Ethan Furman
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

Re: list equal to subclass of list?

2011-05-12 Thread Ethan Furman
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

Python 3.x and bytes

2011-05-17 Thread Ethan Furman
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

Re: if statement on lenght of a list

2011-05-17 Thread Ethan Furman
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:

Re: Python 3.x and bytes

2011-05-17 Thread Ethan Furman
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: -->

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