Re: the meaning of rユ.......ï¾

2012-07-24 Thread Ethan Furman
Ian Kelly wrote: On Tue, Jul 24, 2012 at 8:50 AM, Chris Angelico ros...@gmail.com wrote: Americans celebrate March 14th as 3.14; some Europeans celebrate July 22nd as 22/7 (which is 3.142857, fairly close to 3.14159). We claim both, and also June 28th (aka Tau Day or Two Pi Day, 6.28). Hey

Re: from future import pass_function

2012-07-25 Thread Ethan Furman
Ulrich Eckhardt wrote: I just had an idea, it occurred to me that the pass statement is pretty similar to the print statement, and similarly to the print() function, there could be a pass() function that does and returns nothing. Example: def pass(): return try:

Re: from future import pass_function

2012-07-25 Thread Ethan Furman
Ross Ridge wrote: Ross Ridge rri...@csclub.uwaterloo.ca wrote: No, they're very much alike. That's why all your arguments for print as function also apply just as well to pass a function. Your arguments had very little to do what what print actually did. Chris Angelico ros...@gmail.com

ANN: dbf.py 0.94.003

2012-07-26 Thread Ethan Furman
A few more bug fixes, and I actually included the documentation this time. :) It can be found at http://python.org/pypi/dbf, and has been tested on CPythons 2.4 - 2.7, and PyPy 1.8. dbf v0.94.003 = dbf (also known as python dbase) is a module for reading/writing dBase III, FP,

Re: dict: keys() and values() order guaranteed to be same?

2012-07-26 Thread Ethan Furman
Chris Angelico wrote: On Tue, Jul 24, 2012 at 1:20 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: (Although if you think about the implementation of dicts as hash tables, it does seem likely that it is trivial to enforce this -- one would have to work *harder* to break that

Re: dict: keys() and values() order guaranteed to be same?

2012-07-26 Thread Ethan Furman
Steven D'Aprano wrote: Python's promise is much stronger than merely deterministic: while it does not promise what order the keys will be returned, it does promise that whatever that order turns out to be, they will returned in the same order as the matching values (unless you modify the dict

Re: from future import pass_function

2012-07-26 Thread Ethan Furman
John Ladasky wrote: On Wednesday, July 25, 2012 9:32:33 PM UTC-7, Ethan Furman wrote: What code does `pass` run? When do we pass parameters to `pass`? When do we need to override `pass`? Answers: None. Never. Still waiting for a reply from the OP for a use case. When I brought up

Re: from future import pass_function

2012-07-26 Thread Ethan Furman
John Ladasky wrote: I had very similar thoughts about eight months ago, and posted them here: https://groups.google.com/forum/?fromgroups#!topic/comp.lang.python/CB_5fek2b8A I'm no computer science guru, but the idea that pass should be a function rather than a statement continues to appeal

Re: ANN: dbf.py 0.94.003

2012-07-27 Thread Ethan Furman
Simon Cropper wrote: On 27/07/12 05:31, Ethan Furman wrote: A few more bug fixes, and I actually included the documentation this time. :) It can be found at http://python.org/pypi/dbf, and has been tested on CPythons 2.4 - 2.7, and PyPy 1.8. [snip] Ethan, That's great. Can you comment

Re: [ANN] pyknon: Simple Python library to generate music in a hacker friendly way.

2012-07-30 Thread Ethan Furman
Pedro Kroger wrote: Pyknon is a simple music library for Python hackers. Sounds cool. How is 'Pyknon' pronounced? It's available on PyPI and its homepage is http://kroger.github.com/pyknon/ I would suggest you change the theme -- using Firefox 3.6 the page is very difficult to read.

Re: [ANN] pyknon: Simple Python library to generate music in a hacker friendly way.

2012-07-30 Thread Ethan Furman
Pedro Kroger wrote: On Jul 30, 2012, at 3:33 PM, Ethan Furman et...@stoneleaf.us mailto:et...@stoneleaf.us wrote: Pedro Kroger wrote: Pyknon is a simple music library for Python hackers. Sounds cool. How is 'Pyknon' pronounced? I pronounce it similarly as google translate does: So

Re: NameError vs AttributeError

2012-08-01 Thread Ethan Furman
Terry Reedy wrote: On 7/31/2012 4:49 PM, Chris Kaynor wrote: On Tue, Jul 31, 2012 at 1:21 PM, Terry Reedy wrote: Another example: KeyError and IndexError are both subscript errors, but there is no SubscriptError superclass, even though both work thru the same mechanism -- __getitem__. The

dbf.py API question

2012-08-02 Thread Ethan Furman
SQLite has a neat feature where if you give it a the file-name of ':memory:' the resulting table is in memory and not on disk. I thought it was a cool feature, but expanded it slightly: any name surrounded by colons results in an in-memory table. I'm looking at the same type of situation

Re: dbf.py API question

2012-08-03 Thread Ethan Furman
Peter Otten wrote: Ethan Furman wrote: SQLite has a neat feature where if you give it a the file-name of ':memory:' the resulting table is in memory and not on disk. I thought it was a cool feature, but expanded it slightly: any name surrounded by colons results in an in-memory table. I'm

Re: ANN: dbf.py 0.94

2012-08-03 Thread Ethan Furman
Mark Lawrence wrote: On 21/07/2012 00:59, Ethan Furman wrote: Getting closer to a stable release. Latest version has a simpler, cleaner API, and works on PyPy (and hopefully the other implementations as well ;), as well as CPython. Get your copy at http://python.org/pypi/dbf. Bug reports

Re: Calling Values

2012-08-03 Thread Ethan Furman
subhabangal...@gmail.com wrote: On Friday, August 3, 2012 5:19:46 PM UTC+5:30, Subhabrata wrote: Dear Group, I am trying to call the values of one function in the another function in the following way: def func1(): num1=10 num2=20 print The Second Number is:,num2

Re: dbf.py API question

2012-08-05 Thread Ethan Furman
Ole Martin Bjørndalen wrote: On Thu, Aug 2, 2012 at 5:55 PM, Ethan Furman et...@stoneleaf.us wrote: SQLite has a neat feature where if you give it a the file-name of ':memory:' the resulting table is in memory and not on disk. I thought it was a cool feature, but expanded it slightly: any name

Re: On-topic: alternate Python implementations

2012-08-05 Thread Ethan Furman
Mark Lawrence wrote: With arrogance like that German by any chance? Comments like that are not appropriate on this list. Please don't make them. ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: dbf.py API question

2012-08-06 Thread Ethan Furman
[redirecting back to list] Ole Martin Bjørndalen wrote: On Sun, Aug 5, 2012 at 4:09 PM, Ethan Furman et...@stoneleaf.us wrote: Ole Martin Bjørndalen wrote: You can do this by implementing either __getitem__ or __iter__, unless the streaming flag would also make your table not in memory. Cool

Re: Intermediate Python user needed help

2012-08-06 Thread Ethan Furman
John Mordecai Dildy wrote: I am currently using python 2.6 and am not going to install the newer versions of python and i am looking for people that are still using ver 2.6 in python to help with with the code line: sentence = All good things come to those who wait. then im getting this

Re: looking for a neat solution to a nested loop problem

2012-08-06 Thread Ethan Furman
Tom P wrote: consider a nested loop algorithm - for i in range(100): for j in range(100): do_something(i,j) Now, suppose I don't want to use i = 0 and j = 0 as initial values, but some other values i = N and j = M, and I want to iterate through all 10,000 values in sequence - is

Re: dbf.py API question

2012-08-08 Thread Ethan Furman
Ed Leafe wrote: When converting from paradigms in other languages, I've often been tempted to follow the accepted pattern for that language, and I've almost always regretted it. +1 When in doubt, make it as Pythonic as possible. +1 QOTW ~Ethan~ --

dbf.py API question concerning Index.index_search()

2012-08-15 Thread Ethan Furman
Indexes have a new method (rebirth of an old one, really): .index_search( match, start=None, stop=None, nearest=False, partial=False ) The defaults are to search the entire index for exact matches and raise NotFoundError if it can't find anything. match is the search

Re: dbf.py API question concerning Index.index_search()

2012-08-15 Thread Ethan Furman
Tim Chase wrote: On 08/15/12 18:26, Ethan Furman wrote: .index_search( match, start=None, stop=None, nearest=False, partial=False ) The defaults are to search the entire index for exact matches and raise NotFoundError if it can't find anything. The question

Re: dbf.py API question concerning Index.index_search()

2012-08-15 Thread Ethan Furman
Steven D'Aprano wrote: On Wed, 15 Aug 2012 16:26:09 -0700, Ethan Furman wrote: Indexes have a new method (rebirth of an old one, really): .index_search( match, start=None, stop=None, nearest=False, partial=False ) [...] Why index_search rather than just

Re: type(None)()

2012-08-16 Thread Ethan Furman
Ramchandra Apte wrote: Are they the same object Yes. -- http://mail.python.org/mailman/listinfo/python-list

Re: type(None)()

2012-08-16 Thread Ethan Furman
Hans Mulder wrote: On 8/08/12 04:14:01, Steven D'Aprano wrote: NoneType raises an error if you try to create a second instance. bool just returns one of the two singletons (doubletons?) again. py type(None)() Traceback (most recent call last): File stdin, line 1, in module TypeError: cannot

Re: dbf.py API question concerning Index.index_search()

2012-08-16 Thread Ethan Furman
MRAB wrote: On 16/08/2012 02:22, Ethan Furman wrote: Steven D'Aprano wrote: On Wed, 15 Aug 2012 16:26:09 -0700, Ethan Furman wrote: Indexes have a new method (rebirth of an old one, really): .index_search( match, start=None, stop=None, nearest=False, partial

Re: dbf.py API question concerning Index.index_search()

2012-08-16 Thread Ethan Furman
MRAB wrote: On 16/08/2012 17:13, Ethan Furman wrote: Currently there are: .index(data) -- returns index of data in Index, or raises error .query(string) -- brute force search, returns all matching records .search(match) -- binary search through table, returns all matching

Re: [ANNC] pybotwar-0.8

2012-08-16 Thread Ethan Furman
MRAB wrote: On 16/08/2012 16:40, Ramchandra Apte wrote: On 16 August 2012 21:00, Mark Lawrence wrote: and bottom reads better than top [snip] Look you are the only person complaining about top-posting. GMail uses top-posting by default. I can't help it if you feel irritated by it.

Re: Top-posting c.

2012-08-24 Thread Ethan Furman
Chris Angelico wrote: PLEASE add attribution back in. It's not about he-said/she-said, it's about honesty and clarity in reporting. It's far easier to understand the conversation when we know who said each part [. . .] +1 -- http://mail.python.org/mailman/listinfo/python-list

proper reply format [was Re: help with simple print statement!]

2012-08-24 Thread Ethan Furman
Prasad, Ramit wrote: Willem Krayenhoff Any idea why print isn't working here? I tried restarting my Command prompt. Also, print doesn't work inside a class. Ramit, The standard for attribution is something along the lines of: Prasad, Ramit wrote: or Willem Kayenhoff wrote: Just

Re: ttk styles

2011-03-17 Thread Ethan Furman
Peter wrote: Thanks for the link Malcolm, I'll have a look at it. What is particularly interesting (at first glance), is that the author has mixed Tkinter with ttk as it suited i.e. look at this line: f1 = tkinter.Frame(nb, background=red) If ttk was being used purely (from tkinter import *;

Re: email library

2011-03-18 Thread Ethan Furman
peterob wrote: Im completely confinvalided from email library. When you parse email from file it creates object Message. f = open(emailFile, 'r') msg = email.message_from_file(f) f.close() How can I access RAW header of email represented by object msg? I dont wanna access each header field by

Re: class error

2011-03-18 Thread Ethan Furman
monkeys paw wrote: I have the following file: FileInfo.py: import UserDict class FileInfo(UserDict): store file metadata def __init__(self, filename=None): UserDict.__init__(self) self[name] = filename When i import it like so: import FileInfo i get this error:

Re: Reading/Writing files

2011-03-18 Thread Ethan Furman
Jon Herman wrote: Hello all, I am pretty new to Python and am trying to write data to a file. However, I seem to be misunderstanding how to do so. For starters, I'm not even sure where Python is looking for these files or storing them. The directories I have added to my PYTHONPATH variable

Re: Reading/Writing files

2011-03-18 Thread Ethan Furman
Dan Stromberg wrote: Are you on windows? You probably should use / as your directory separator in Python, not \. In Python, and most other programming languages, \ starts an escape sequence, so to introduce a literal \, you either need to prefix your string with r (r\foo\bar) or double

Re: Problem with re module

2011-03-22 Thread Ethan Furman
John Harrington wrote: Here's a script that illustrates the problem. Any help would be appreciated!: #BEGIN SCRIPT import re outlist = [] myfile = raw.tex fin = open(myfile, r) lineList = fin.readlines() fin.close() for i in range(0,len(lineList)):

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 et...@stoneleaf.us mailto:et...@stoneleaf.us wrote: Dan Stromberg wrote: Are you on windows? You probably should use / as your directory separator in Python

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

2011-03-28 Thread Ethan Furman
John Ladasky wrote: On Mar 28, 2:25 am, Andrea Crotti andrea.crott...@gmail.com wrote: I noticed some time ago in a program that needed speed that deepcopy in particular is incredibly slow, but I guess is normal since it has to copy every bit of the data structure. That may be, but when it

Re: Python problem

2011-03-28 Thread Ethan Furman
John Parker wrote: I have written the following code so far but get an error. infile = open(scores.txt, r) lines = infile.readlines() infile.close() tokens = lines.split(,) [snip] error: Traceback (most recent call last): File Score_8.py, line 38, in module tokens = lines.split(,)

Re: Directly Executable Files in Python

2011-03-29 Thread Ethan Furman
harrismh777 wrote: Chris Rebert wrote: Yes. py2exe is a tool which generates such Windows executables: http://www.py2exe.org/ Interesting... but it can't possibly be creating .exe files (compiling)... Yes and no. The python program is not being compiled. The Python system, along with

Re: Data files for tests

2011-03-30 Thread Ethan Furman
Steven D'Aprano wrote: I have a package with some tests. The tests are not part of the package Do you mean they are not importable, as in -- from spam import tests or they are not distributed? Because it seems to me that distributing them would be worthwhile to at least some of the folks

Re: In List Query - None Case Sensitive?

2011-03-31 Thread Ethan Furman
Wehe, Marco wrote: I am doing a search through a list of files but the text the casing doesn't match. My list is all upper case but the real files are all different. Is there a smooth way of searching through the list without going full on regular expressions? path =

Re: [OT] Free software versus software idea patents

2011-04-08 Thread Ethan Furman
Westley Martínez wrote: On Fri, 2011-04-08 at 01:41 -0500, harrismh777 wrote: Freedom isn't free... you have to fight for it... always. Why should a business listen to you? You're not gonna buy any software anyways. From a thread a few months back I can say there are a couple companies

Re: Generators and propagation of exceptions

2011-04-08 Thread Ethan Furman
r wrote: The code above implements an interactive session (a REPL). Therefore, what I'd like to get is an error information printed out at the output as soon as it becomes available. Couple ideas: 1) Instead of yielding the error, call some global print function, then continue on; or 2)

Re: Argument of the bool function

2011-04-08 Thread Ethan Furman
candide wrote: Le 08/04/2011 18:43, Ian Kelly a écrit : In bool(x=5), x=5 is also not an expression. It's passing the expression 5 in as the parameter x, using a keyword argument. You are probably right but how do you deduce this brilliant interpretation from the wording given in the

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
James Mills wrote: Are we done with this discussion yet ? :) *sigh* It was a slow day yesterday and I have a funny feeling it's going to be the same today! Regardless of anyone's subjective opinions as to what was clear - I still stand by what I said. I think I see your point -- the OP said:

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) The question mark makes the programmer

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? var1.hobgle(var2) -- var3

Re: Egos, heartlessness, and limitations

2011-04-13 Thread Ethan Furman
James Mills wrote: On Thu, Apr 14, 2011 at 10:39 AM, rantingrick rantingr...@gmail.com 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
geremy condra wrote: On Wed, Apr 13, 2011 at 10:50 PM, harrismh777 harrismh...@charter.net wrote: My major professor once told me, You know you've won the argument when they start calling you names! I think your professor should have said you know you've won the argument when you can prove

Re: [OT] Free software versus software idea patents

2011-04-14 Thread Ethan Furman
Westley Martínez wrote: Also, why aren't Opera and Google criticized for their proprietary browsers (Chrome is essentially a proprietary front-end)? Is it because their browsers follow web standards, or is it because we have demonized Microsoft? My biggest gripe with Microsoft as that they

Re: Pythonic infinite for loop?

2011-04-15 Thread Ethan Furman
Chris Angelico wrote: lst=[] for i in xrange(1,1000): # arbitrary top, don't like this try: lst.append(parse_kwdlist(dct[Keyword%d%i])) except KeyError: break Possibly overkill: import dbf table = dbf.from_csv(csvfile) # fields get names f0, f1, f2, ...

Re: Namespaces in functions vs classes

2011-04-17 Thread Ethan Furman
Gerald Britton wrote: However, I would like a deeper understanding of why I cannot use foo as an unqualified variable inside the method in the class. If Python allowed such a thing, what problems would that cause? 8 script with possible

Re: Namespaces in functions vs classes

2011-04-17 Thread Ethan Furman
Gerald Britton wrote: For my final attempt, I add the prefix a. to my use of foo class a(): ... foo = 'foo' ... def g(x): ... return a.foo ... The first parameter to any method in a class* is going to be the instance of that class, and is usually named 'self'. So your

Re: Namespaces in functions vs classes

2011-04-19 Thread Ethan Furman
Gerald Britton wrote: I now understand the Python does not consider a class definition as a separate namespace as it does for function definitions. That is a helpful understanding. That is not correct. Classes are separate namespaces -- they just aren't automatically searched. The only

Re: A question about Python Classes

2011-04-21 Thread Ethan Furman
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 call foo() when I never created an instance of BaseHandler? You

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 call foo() when I

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~ --

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~ --

Re: Composition instead of inheritance

2011-04-28 Thread Ethan Furman
Carl Banks wrote: That's not what we mean by composition. Composition is when one object calls upon another object that it owns to implement some of its behavior. Often used to model a part/whole relationship, hence the name. Hmmm. Okay -- any ideas for a better term? Something that

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 et...@stoneleaf.us 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

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 et...@stoneleaf.us 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

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

2011-05-04 Thread Ethan Furman
Raymond Hettinger wrote: I'm writing-up more guidance on how to use super() and would like to point at some real-world Python examples of cooperative multiple inheritance. Don't know if you are still looking for examples, but I recently came across a thread in Python-Dev which had an example

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

2011-05-05 Thread Ethan Furman
harrismh777 wrote: Grant Edwards wrote: I give up. You don't seem to understand the C language defintion or what is commonly meant by pass by reference. ah, don't give up... here is a link that might help to clarify some of these semantics... me thinks:

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

2011-05-06 Thread Ethan Furman
Ian Kelly wrote: On Fri, May 6, 2011 at 1:57 PM, dmitrey dmitre...@gmail.com wrote: Unfortunately, it doesn't work, it turn out to be dict_items: next({1:2}.items()) Traceback (most recent call last): File stdin, line 1, in module TypeError: dict_items object is not an iterator So call

Re: checking if a list is empty

2011-05-07 Thread Ethan Furman
harrismh777 wrote: Steven D'Aprano wrote: attribution lost wrote: and implies in any case that li does not exist It does nothing of the sort. If li doesn't exist, you get a NameError. That was the point. 'not' implies something that is not logical; which is irony extreme since

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

2011-05-09 Thread Ethan Furman
Steven D'Aprano wrote: But that's wrong! Names (little boxes) can't point to *slots in a list*, any more than they can point to other names! This doesn't work: -- L = [None, 42, None] -- a = L[0] -- L[0] = 23 -- print(a) # This doesn't work! 23 Minor nitpick -- having a comment saying

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

2011-05-09 Thread Ethan Furman
James Wright wrote: Hello, Howdy! def create_report_index(report): #Here we are creating a simple index.html file from data in a text file newfile = open(report + '.html', 'w') #Create the index file using report name for each_value in D4[report]: [clean_name, _] =

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 module create_report_index(each_item) File render4.py, line 26, in create_report_index [clean_name, _] =

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 et...@stoneleaf.us 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 to show

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 D4 is being created to see where

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
Hans Georg Schaathun wrote: On 11 May 2011 13:36:02 GMT, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: : In this case, the interpretation of an arbitrary object as a boolean is : peculiar for python. : : Incorrect. It is widespread among many languages. Programmers have

Re: checking if a list is empty

2011-05-11 Thread Ethan Furman
Hans Georg Schaathun wrote: On Wed, 11 May 2011 13:50:54 -0400, Prasad, Ramit ramit.pra...@jpmchase.com wrote: : I find this argument to be flawed. Should I stop using built-in : generators instead of range/xrange for looping through lists? : Certainly for loops with loop counting are

Re: How to deal with optional argument evaluation

2011-05-11 Thread Ethan Furman
Rodrick Brown wrote: I'm having a hard time dealing with the following scenario My class takes a hash like the following: rdargs = {'env:'prod','feed':'opra','hostname':'host13dkp1','process':'delta','side':'a','zone','ny'} All the keys in this hash can be optional. I'm having a hard time

Re: checking if a list is empty

2011-05-12 Thread Ethan Furman
Chris Angelico wrote: On Thu, May 12, 2011 at 7:02 AM, Ian hobso...@gmail.com wrote: In the real world lists of zero items do not exist. You don't go shopping with a shopping list of zero items. Actually, yes you do. You maintain your shopping list between trips; whenever you need something,

Re: list equal to subclass of list?

2011-05-12 Thread Ethan Furman
Roy Smith wrote: I recently observed in the checking if a list is empty thread that a list and a subclass of list can compare equal: class MyList(list): I'm a subclass l1 = [] l2 = MyList() print type(l1), type(l2) print type(l1) == type(l2) print l1 == l2

Re: list equal to subclass of list?

2011-05-12 Thread Ethan Furman
Roy Smith wrote: On May 12, 2011, at 11:30 AM, Eric Snow wrote: That definitely makes it unclear. I don't think it's unclear at all. It's very clear. Clearly wrong :-) While it is wrong (it should have 'built-in' precede the word 'types'), it is not wrong in the way you think -- a

Re: Proper way to handle errors in a module

2011-05-12 Thread Ethan Furman
Andrew Berg wrote: On 2011.05.12 02:25 PM, MRAB wrote: You can raise an exception wherever you like! :-) If I raise an exception that isn't a built-in exception, I get something like NameError: name 'HelloError' is not defined. I don't know how to define the exception. class

Re: list equal to subclass of list?

2011-05-12 Thread Ethan Furman
Roy Smith wrote: On May 12, 2:29 pm, Ethan Furman et...@stoneleaf.us 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 list subclass

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 being

Python 3.x and bytes

2011-05-17 Thread Ethan Furman
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: -- huh b'\x00\x00\x00\x00\x00' or five null bytes. Note that this is an

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: -- huh b'\x00

Re: Python 3.x and bytes

2011-05-17 Thread Ethan Furman
Corey Richardson wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 05/17/2011 02:47 PM, 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

Re: Python 3.x and bytes

2011-05-17 Thread Ethan Furman
Ian Kelly wrote: On Tue, May 17, 2011 at 2:20 PM, Ethan Furman et...@stoneleaf.us wrote: The big question, though, is would you do it this way: some_var = bytes(23).replace(b'\x00', b'a') or this way? some_var = bytes(b'a' * 23) Actually, I would just do it this way: some_var = b'a' * 23

Re: Python 3.x and bytes

2011-05-18 Thread Ethan Furman
Ian Kelly wrote: On Tue, May 17, 2011 at 2:20 PM, Ethan Furman et...@stoneleaf.us wrote: The big question, though, is would you do it this way: some_var = bytes(23).replace(b'\x00', b'a') or this way? some_var = bytes(b'a' * 23) Actually, I would just do it this way: some_var = b'a' * 23

Re: Trying to understand html.parser.HTMLParser

2011-05-19 Thread Ethan Furman
Andrew Berg wrote: ElementTree doesn't seem to have been updated in a long time, so I'll assume it won't work with Python 3. I don't know how to use it, but you'll find ElementTree as xml.etree in Python 3. ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

hash values and equality

2011-05-19 Thread Ethan Furman
Several folk have said that objects that compare equal must hash equal, and the docs also state this http://docs.python.org/dev/reference/datamodel.html#object.__hash__ I'm hoping somebody can tell me what horrible thing will happen if this isn't the case? Here's a toy example of a class I'm

Re: hash values and equality

2011-05-20 Thread Ethan Furman
Chris Rebert wrote: On Thu, May 19, 2011 at 10:43 PM, Ethan Furman et...@stoneleaf.us wrote: Several folk have said that objects that compare equal must hash equal, and the docs also state this http://docs.python.org/dev/reference/datamodel.html#object.__hash__ I'm hoping somebody can tell me

Re: hash values and equality

2011-05-20 Thread Ethan Furman
Peter Otten wrote: Ethan Furman wrote: Several folk have said that objects that compare equal must hash equal, and the docs also state this http://docs.python.org/dev/reference/datamodel.html#object.__hash__ I'm hoping somebody can tell me what horrible thing will happen if this isn't

Re: hash values and equality

2011-05-20 Thread Ethan Furman
Ulrich Eckhardt wrote: Ethan Furman wrote: Several folk have said that objects that compare equal must hash equal, and the docs also state this http://docs.python.org/dev/reference/datamodel.html#object.__hash__ I'm hoping somebody can tell me what horrible thing will happen if this isn't

Re: hash values and equality

2011-05-20 Thread Ethan Furman
Ethan Furman wrote: Several folk have said that objects that compare equal must hash equal, and the docs also state this http://docs.python.org/dev/reference/datamodel.html#object.__hash__ Two things I didn't make clear originally: I'm using Python3. My objects (of type Wierd) obey

Re: hash values and equality

2011-05-20 Thread Ethan Furman
Peter Otten wrote: Ethan Furman wrote: Peter Otten wrote: Ethan Furman wrote: Several folk have said that objects that compare equal must hash equal, and the docs also state this http://docs.python.org/dev/reference/datamodel.html#object.__hash__ -- class Wierd(): ... def __init__(self

Re: Why did Quora choose Python for its development?

2011-05-25 Thread Ethan Furman
Terry Reedy wrote: On 5/25/2011 8:01 AM, John Bokma wrote: to. Like I already stated before: if Python is really so much better than Python readability wise, why do I have such a hard time dropping Perl and moving on? [you meant 'than Perl'] You are one of the people whose brain fits Perl

Re: Python 3.2 bug? Reading the last line of a file

2011-05-25 Thread Ethan Furman
tkp...@hotmail.com wrote: Thanks for the guidance - it was indeed an issue with reading in binary vs. text., and I do now succeed in reading the last line, except that I now seem unable to split it, as I demonstrate below. Here's what I get when I read the last line in text mode using 2.7.1 and

<    3   4   5   6   7   8   9   10   11   12   >