Re: equivalent of py2exe in other os

2008-10-07 Thread Joe Strout
ython 2.5.1, for example, which is hardly the latest.) Best, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Losing curses decorations.

2008-10-07 Thread Joe Keen
I'm working on a small curses application that opens an external editor occasionally; in the current case I'm testing its running vi. Once I exit vi and return to the curses application I lose the background color, window frames, and any text I had on the screen before I opened vi. I can still see

Re: Losing curses decorations.

2008-10-08 Thread Joe Keen
On Oct 8, 1:16 am, Peter Otten <[EMAIL PROTECTED]> wrote: > Joe Keen wrote: > > I'm working on a small curses application that opens an external > > editor occasionally; in the current case I'm testing its running vi. > > Once I exit vi and return

distributing apps without the Python source?

2008-10-08 Thread Joe Strout
We have a client who's paranoid about distributing the Python source to his commercial app. Is there some way I can distribute and use just the .pyc files, so as to not give away the source? Thanks, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Apache log munging

2008-10-08 Thread Joe Python
I have a written a generator for an apache log which returns two types of information, hostname and the filename requested. The 'log' generator can be 'consumed' like this: for r in log: print r['host'], r['filename'] I want to find the top '100' hosts (sorted in descending order of total requ

Re: Apache log munging

2008-10-08 Thread Joe Riopel
On Wed, Oct 8, 2008 at 1:55 PM, Joe Python <[EMAIL PROTECTED]> wrote: > I want to find the top '100' hosts (sorted in descending order of total > requests) like follows: > Is there a fast way to this without scanning the log file many times? As you encounter a new &q

Re: Apache log munging

2008-10-08 Thread Joe Python
sorted(hosts,key=hosts.get, reverse=True): for file in filename: print host, all[host,file] print hosts[host] I was looking for a better option instead of building 'three' collections to improve performance. - Jo On Wed, Oct 8, 2008 at 2:15 PM, Joe Riopel <[EMAIL PROT

Re: template strings for matching?

2008-10-09 Thread Joe Strout
On Oct 9, 2008, at 7:05 AM, [EMAIL PROTECTED] wrote: Tino> http://docs.python.org/library/stdtypes.html#string-formatting-operations That shows how to use the template formatting as it currently exists. To my knowledge there is no support for the inverse operation, which is what

template strings for matching?

2008-10-09 Thread Joe Strout
doesn't match), or a dictionary with values for 'object', 'location', and 'subloc'. But I couldn't find anything like that in the docs. Am I overlooking something? Thanks, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: template strings for matching?

2008-10-09 Thread Joe Strout
s that have special meaning to RegEx, except for '$' (which is why I can't use re.escape). Probably the rest of the code could be improved too. I'm eager to hear your feedback. Thanks, - Joe -- http://mail.python.org/mailman/listinfo/python-list

book recommendation for Python newbie?

2008-10-09 Thread Joe Strout
primarily a Mac user, but occasionally has to dabble in Linux or Windows. If we do make this change, he'll be using Python in a professional capacity to develop commercial apps. There are a lot of Python books out there... which one would you recommend in this case? Thanks, - Joe --

Where/how to propose an addition to a standard module?

2008-10-10 Thread Joe Strout
erably as per PEP 0001. But that document also suggests first discussing it here. I'm still a newbie (or actually, oldbie-turned- nonbie-turned-newbie-again), so I could use some advice. What's the next step in advocating for this idea? Thanks, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: docpicture

2008-10-13 Thread Joe Strout
-tagged comment, rather than in the docstring. I still think it's a nifty idea though. Best, - Joe -- http://mail.python.org/mailman/listinfo/python-list

splitting a string into an array using a time value

2008-10-14 Thread Joe Python
008 4:39:55 PM Maecenas lectus libero, tincidunt sed ] Note: there is an element corresponding to each time entry in the array I tried to use the pattern but its not working: pattern = r'(\d+/\d+/\d+ \d+:\d+:\d+ .+)' pat = re.compile(pattern) result = re.split(pat,s)

recommendations for a web CMS (content management system)?

2008-10-15 Thread Joe Strout
ollow code over something that includes everything but the kitchen sink. Any suggestions? Thanks, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Python equivalent to SharePoint?

2008-10-15 Thread Joe Strout
I don't want to recommend an abandoned platform. Anything else I should consider? Thanks, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: Loosely-coupled development environment (was: IDE Question)

2008-10-15 Thread Joe Strout
ar to say that ONLY those can do the job. Best, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: Finding the instance reference of an object

2008-10-16 Thread Joe Strout
of a and b is a reference to some object that has a "foo" attribute. Not sure if all this was helpful to anyone, but I hope so! Best, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: Finding the instance reference of an object

2008-10-16 Thread Joe Strout
t it's comforting to know that you're not incurring the penalty of copying a huge data buffer every time you pass one to a function or assign it to another variable. But with mutable objects, it is ordinary and expected that what you have is a reference to the object, and you can tell this quite simply by mutating the object in any way. Every modern language I know works the same way, and I'd wager that the ones I don't know (e.g. Ruby) also work that way. Python's a beautiful language, but I'm afraid it's nothing special in this particular regard. Best, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: Finding the instance reference of an object

2008-10-17 Thread Joe Strout
On Oct 16, 2008, at 11:23 PM, Dennis Lee Bieber wrote: On Thu, 16 Oct 2008 21:19:28 -0600, Joe Strout <[EMAIL PROTECTED]> declaimed the following in comp.lang.python: Now that IS mysterious. Doesn't calling a function add a frame to a stack? And doesn't that necessitate c

Re: 'Hidden Features of Python'

2008-10-17 Thread Joe Strout
Can someone who gets this share a clue? Thanks, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: 'Hidden Features of Python'

2008-10-17 Thread Joe Strout
-- in fact all the source except the assignment to s could be replaced with the one-liner print s.encode('rot13') Though the existing source is interesting in its own way too. Thanks, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: inserting Unicode character in dictionary - Python

2008-10-17 Thread Joe Strout
? Do you then have a proper UTF-8 string, but the problem is that none of the standard Python library methods know how to properly interpret UTF-8? 4. In Python 3.0, this silliness goes away, because all strings are Unicode by default. Thanks for any answers/corrections, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: Finding the instance reference of an object

2008-10-17 Thread Joe Strout
p your value in some mutable type (like a list) and pass that instead. A little awkward, but no big deal, as there are darn few valid reasons to ever pass something by reference anyway, especially in a language with tuple packing and unpacking. Best, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: inserting Unicode character in dictionary - Python

2008-10-17 Thread Joe Strout
files or sockets or whatever, of course I'll have to think about what encoding the text should be... but internal to my own source code, I shouldn't have to. I understand the need for a transition strategy, which is what we have in 2.x, and that's working well enough. But I&#

Re: Finding the instance reference of an object

2008-10-17 Thread Joe Strout
a ByRef parameter in modern languages. And it seems that Python simply doesn't have that. People here don't describe Python as different just because they *want* it to be different. Python acknowledges intellectual debts to many languages, none of which is exactly like it. Sur

Re: Finding the instance reference of an object

2008-10-17 Thread Joe Strout
ed-up and streamlined C++. Even old-timers (like me) who learned FORTRAN and COBOL way back in the day have long since moved on. Best, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: inserting Unicode character in dictionary - Python

2008-10-19 Thread Joe Strout
hoping that the answer is "no" -- most string literals in a source file are text (which should be Unicode text, these days); a raw byte string would be the exceptional case, and I'd be happy to use the "r" prefix for those. Best, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: Unicode (UTF8) in dbhas on 2.5

2008-10-21 Thread Joe Strout
codings is currently primitive compared to some other environments, and I see that this extends to the database modules. Fine, fair enough, it is what it is, but there is no harm in asking about (or even yearning for) a more intelligent system that does more of the grunt work for us. Best, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: What's the perfect (OS independent) way of storing filepaths ?

2008-10-22 Thread Joe Strout
ompatibility with other Unices -- well-behaved Mac apps put global settings (and so on) in the appropriate subfolder under /Library, with per user data in the appropriate subfolder under ~/Library. Cheers, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: ANN: gui_support, a convenience library for wxPython

2008-10-23 Thread Joe Strout
re indentation shows containment, and with the name/type/attributes for each item on a line -- any sort of standard, or just something you guys made up? Thanks very much, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: Finding the instance reference of an object

2008-10-27 Thread Joe Strout
t, because Python arguments are ALWAYS passed by value. There is no call by reference in Python. Period, end of story, nothing to see here. Cheers, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: How to get an object's name as a string?

2008-10-28 Thread Joe Strout
them. If that's a problem, explicitly remove them from the map when you know you're done with them, or use weak references. Best, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: Finding the instance reference of an object

2008-10-28 Thread Joe Strout
s are expressions that are evaluated, and the resulting value copied into the formal parameter, pure and simple. The continued attempts to obfuscate this is pointless and wrong. Best, - Joe -- http://mail.python.org/mailman/listinfo/python-list

explanation of values, references, assignment, and method calls

2008-10-28 Thread Joe Strout
ad it yet. But I may not get another chance to work on it for a few days, so I wanted to get it out there now. I welcome your feedback. Best, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: How to get an object's name as a string?

2008-10-28 Thread Joe Strout
following: variable: "ariablevay" value: "aluvay" reference: "eferencevay" call-by-value: "allcay-ibay-aluvay" call-by-reference: (no term needed, since Python doesn't have it) There. Now we've got a simple mapping from standard terminology to

Re: How to get an object's name as a string?

2008-10-28 Thread Joe Strout
as "l"? Hey, that's a very nice little demonstration of an orphaned object. Thanks for sharing it! Best, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: Finding the instance reference of an object

2008-10-29 Thread Joe Strout
e called by value (the value itself is copied). Quite right. Now, note that "ByRef" and "ByVal" apply to both. Generalize to Python. There you go. Best, - Joe P.S. I really am trying to quit responding to this thread. Sometimes the urge is too strong. But I'll keep trying! -- http://mail.python.org/mailman/listinfo/python-list

Re: Finding the instance reference of an object

2008-10-30 Thread Joe Strout
very clearly, is call-by-value. To call it something else only clouds the issue and results in confusion. (Perhaps explaining why there appears to be far more confusion about call semantics in the Python community than in the community of other languages where the default semantics are exactly the same.) Best, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: Single string vs list of strings

2008-10-30 Thread Joe Strout
l approach, but this test will fail for Unicode strings, and so is probably bad mojo moving forward. Instead I suggest: isinstance(x, basestring) which will work whether x='asdf' or x=u'asdf'. Best, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: Finding the instance reference of an object

2008-10-30 Thread Joe Strout
There is no need for new terms. Agreed. Best, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: Finding the instance reference of an object

2008-10-30 Thread Joe Strout
d first. That's a very sensible stance. +1! Best, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Testing dictionary results with doctest

2008-10-31 Thread Joe Strout
btained results really do match the expected results, considered as a dictionary rather than as a string. But doctest doesn't see it that way. What's the standard solution for this? Should I iterate over the sorted keys and print those out instead? Is there some built-in method somewhere that will print a dictionary in a reliable order? Does doctest have some special way to tell it to consider the result as a dictionary rather than a string? Or something else? Thanks, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: Finding the instance reference of an object

2008-11-03 Thread Joe Strout
as I'm one of them.) Best, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: Finding the instance reference of an object

2008-11-03 Thread Joe Strout
he only passing methods. True or False? True, but the others are rarely used and don't apply to any of the languages we've been discussing. Best, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: Structures

2008-11-03 Thread Joe Strout
On Nov 3, 2008, at 4:38 PM, Paulo J. Matos wrote: However, I wouldn't dare to say Python needs structures to be a good language, or anything similar. My question was more directed to : if there aren't structures in Python, what do Pythonists use instead? Classes. Best, - Joe

Re: Finding the instance reference of an object

2008-11-03 Thread Joe Strout
er language calls call-by-value. But I really am trying not to continue this debate. So that's my last reply about it for tonight, I promise. :) Cheers, - Joe <http://www.strout.net/info/coding/valref/> -- http://mail.python.org/mailman/listinfo/python-list

locating the chorus in a MIDI song?

2008-11-03 Thread Joe Strout
ing this myself, but if you think you can do a better job at a reasonable rate, I'm happy to let you do so. Thanks, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: Which was the best Lib of GUI for python

2008-11-04 Thread Joe Strout
them to give you a feel for what it can do. In addition to the quality apparent to the end-user (which I think is the most important thing), I find the wx API to be quite sensible and easy to work with too. HTH, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: Finding the instance reference of an object

2008-11-04 Thread Joe Strout
as no analog in Python. Python object variables are references to objects on the heap, just like pointers in C++ to objects created with "new". So this example is a red herring. I'd be very interested in hearing whether, as a C/C++ user, the above explanation is clear and makes sense to you. Thanks, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: Python on iPhone actually rather good

2008-11-04 Thread Joe Strout
development point of view). Best, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: Finding the instance reference of an object

2008-11-04 Thread Joe Strout
On Nov 4, 2008, at 3:42 PM, Steven D'Aprano wrote: This example is also call-by-value, but the value in this case is a type that has no analog in Python. I'm disappointed to see that my prediction that Joe would, yet again, utterly ignore all the arguments against his pet theory w

Re: Finding the instance reference of an object

2008-11-04 Thread Joe Strout
e of those languages mentioned use call-by-value. In fact both of these statements are false, but we can cut our time and effort in half if you will just select the one that you believe to be true, so we can focus on that. Which is it? Thanks, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: Finding the instance reference of an object

2008-11-06 Thread Joe Strout
u can mutate an object passed to a function. As should be painfully clear by now, that argument is total bunk. You can pass an object reference by value, and use it to mutate the object it refers to just fine. To test whether you're passing by reference or by value, you need to instead assign a new value to the formal parameter, and see whether that affects the actual parameter. Cheers, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: Finding the instance reference of an object

2008-11-06 Thread Joe Strout
will do, or even what sort of arguments are valid. Answer: it's a copy of it. Assignments don't affect the actual parameter at all. This is exactly what "call by value" means. Best, - Joe [1] http://www.python.org/doc/2.5.2/ext/refcounts.html [2] http://www.strout.net/info/coding/valref/ -- http://mail.python.org/mailman/listinfo/python-list

Newbie question

2008-11-06 Thread Joe Hays
Error: shape mismatch: objects cannot be broadcast to a single shape This is supposed to be doing a matrix multply of an (m,n)(n,1). This results in an (m,1). This should then be able to be added to the 2*rand(m,1), but, its not for some reason. Ideas?

Re: Finding the instance reference of an object

2008-11-06 Thread Joe Strout
s "pass by object" means nothing (until you explain that it means the former). However, if you really think the term is that handy, and we want to agree to say "Python uses pass by object" and answer the inevitable "huh?" question with "that's shorthand for object references passed by value," then I'd be OK with that. Best, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: Finding the instance reference of an object

2008-11-06 Thread Joe Strout
r own model is valid but there is a better one which is easier to grasp for people without a background in C/C++ - like languages. Well, if by C/C++-like languages, you mean also Java, VB.NET, and so on, then maybe you're right -- perhaps my view is colored by my experience with those. But alternatively, perhaps there are enough Python users without experience in other OOP languages, that the standard terminology was unfamiliar to them, and they made up their own, resulting in the current linguistic mess. Best, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: Finding the instance reference of an object

2008-11-06 Thread Joe Strout
Val" (default) mode in RB and VB.NET 6. My own experience implementing the RB compiler (not that implementation details matter, but it forced me to think very carefully about references and parameter passing for a very long time) Not that I'm trying to argue from authority; I'm trying

Re: Finding the instance reference of an object [long and probably boring]

2008-11-07 Thread Joe Strout
. I wonder if that could be tested systematically. Perhaps we could round up 20 newbies, divide them into two groups of 10, give each one a 1-page explanation either based on passing object references by- value, or passing values sort-of-kind-of-by-reference, and then check their comprehension by predicting the output of some code snippets. That'd be very interesting. It's hard for me to believe that the glossing-over-references approach really is easier for anybody, but maybe I'm wrong. I would even argue that your confusion supports this argument. Your understanding of Python is perfectly adequate, so get with the program for Pete's sake! In my case, my understanding of Python became clear only once I stopped listening to all the confusing descriptions here, and realized that Python is no different from other OOP languages I already knew. Best, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: Finding the instance reference of an object [long and probably boring]

2008-11-07 Thread Joe Strout
hon assignment is different, since it clearly doesn't copy the value. Well, I can't vouch for all of them. But I can vouch for quite a few. But here you go again: you're forced to claim that Python's parameter passing is different, AND its assignment is different, with t

Re: Finding the instance reference of an object [long and probably boring]

2008-11-07 Thread Joe Strout
-page explanation either based on passing object references by-value, or passing values sort-of-kind-of-by-reference, and then check their comprehension by predicting the output of some code snippets. That'd be very interesting. Except for your garbling of the alternative to your version, I agree. I suspect that different people might do better with different explanations, depending on background. Could be. Maybe we could run such an experiment at PyCon, pulling in non- attendees from the hallway and getting them to take the test in exchange for a free donut or coffee. Best, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: Finding the instance reference of an object [long and probably boring]

2008-11-07 Thread Joe Strout
users of other languages, this is the same semantics used for objects in Java, RB/VB.NET, and C++ when dealing with objects." Best, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: Finding the instance reference of an object [long and probably boring]

2008-11-08 Thread Joe Strout
rtainly is sufficient. Having ANY references to it is both necessary and sufficient to exist. And isn't that the easiest way to say it? Best, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: Finding the instance reference of an object

2008-11-08 Thread Joe Strout
On Nov 8, 2008, at 2:38 PM, Terry Reedy wrote: So if you then insist that Python uses "call by object", you're actually saying it uses call by value! Both Joe and you seem to be engaging in the following bit of sophistry: "In order for code A to call code B, some

Python fish simulation?

2008-11-10 Thread Joe Strout
Is there any Python-based fish simulation project? I've tried searching google and pypi, but no luck. No burning need, just seems like it'd be fun. Thanks, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: Finding the instance reference of an object

2008-11-10 Thread Joe Strout
erence; changing the object and changing the object reference are two different things. Best, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: Finding the instance reference of an object [long and probably boring]

2008-11-10 Thread Joe Strout
On Nov 10, 2008, at 2:30 PM, Aaron Brady wrote: I agree with Terry that all calling is call-by-value, and Steven that all calling is call-by-bit-flipping. I agree with Joe that call-by- object is a special case of call-by-value. Woo! Almost sounds like approaching consensus. :) However

Re: Class v. Instance variables in Python

2008-11-10 Thread Joe Strout
ce to some shared list instance, such as one defined as a default argument to your __init__ method. HTH, - Joe -- http://mail.python.org/mailman/listinfo/python-list

How can a function know what module it's in?

2008-11-11 Thread Joe Strout
e to its own module, but I haven't been able to find it. Can someone share a clue? Thanks, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: How can a function know what module it's in?

2008-11-11 Thread Joe Strout
Some corrections, to highlight the depth of my confusion... On Nov 11, 2008, at 9:10 PM, Joe Strout wrote: doctest.testmod(mymodule) This actually works fine if I'm importing the module (with the standard name) somewhere else Actually, it does not. I noticed that a fun

Re: How can a function know what module it's in?

2008-11-12 Thread Joe Strout
le, under pdb) I can import the module and then run themodule._test(). To whom should I make the suggestion that this go into doctest docs? Cheers, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: duck-type-checking?

2008-11-12 Thread Joe Strout
ified class, and make sure that the given object has corresponding callable attributes. For case 2, we might be able to cache the result so that we don't do all that work again the next time the same type comparison is done. Anyway, I'll evolve something in our shop here and live

Re: duck-type-checking?

2008-11-12 Thread Joe Strout
o our practices ASAP. Thanks, - Joe -- http://mail.python.org/mailman/listinfo/python-list

duck-type-checking?

2008-11-12 Thread Joe Strout
fy that whatever object I have, it has the same public (non-underscore) methods as the class I'm claiming.) Are there any standard methods or idioms for doing that? Thanks, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: duck-type-checking?

2008-11-12 Thread Joe Strout
y and efficiently handle the common cases, while still being able to handle the uncommon ones. Best, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: duck-type-checking?

2008-11-13 Thread Joe Strout
if len(obj) > 0: s = obj[0] if s[0] != s: return False return True Thanks for this, too; that's the sort of method I had in mind. That last test for string-likeness is particularly clever. I'll need to think more deeply about the implications. Best, - Joe -- http://mail.python.org/mailman/listinfo/python-list

using "private" parameters as static storage?

2008-11-13 Thread Joe Strout
I have to remember to change those references too. But then, if I renamed a function, I'd have to change all the callers anyway. So maybe this is better. What do y'all think? Best, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: using "private" parameters as static storage?

2008-11-13 Thread Joe Strout
of their email: "Helpful-Answer" for helpful answers, and "Unhelpful- Preaching" for the other kind. Then those of us not interested in one sort or the other could set up an email filter. Best, - Joe P.S. I'm sorry, Chris, I don't mean to rip your head off in particula

Re: using "private" parameters as static storage?

2008-11-13 Thread Joe Strout
ftware professionally for decades, and may have a better idea than anybody else what their needs are. Hypothetically speaking, is it possible that there could be any language feature Python doesn't have, which might be useful to anyone in any situation? If so, how would you recogniz

Re: using "private" parameters as static storage?

2008-11-13 Thread Joe Strout
iable isn't THAT ugly. But it's nice to have some options. At any rate, you (and rurpy) have taken the time to consider the question I was actually asking, instead of arguing with me whether I should be asking it. I really appreciate that. Your suggestions are helpful and have taught me some new Python tricks. Thanks very much! Best, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: using "private" parameters as static storage?

2008-11-13 Thread Joe Strout
might say "don't eat omelets; pancakes are much tastier, you should eat them instead." But that doesn't tell you how to cook an omelet, does it? I hope mine was more palatable to you. Yours was tasty indeed, thanks very much! Cheers, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: using "private" parameters as static storage?

2008-11-14 Thread Joe Strout
t is clear to the reader, as well as enforced by the interpreter. Neat stuff, thank you! Best, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: using "private" parameters as static storage?

2008-11-14 Thread Joe Strout
e references too. But then, if I renamed a function, I'd have to change all the callers anyway. So maybe this is better. What do y'all think? I've used this myself, but to me it feels more icky than the semi- private argument trick above. Thanks for the feedback. Best, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: duck-type-checking?

2008-11-14 Thread Joe Strout
uld return such a thing sometimes). So, in this case, the simplest solution was to have the method that initially accepts and stores the data check to make sure that data satisfies the assumptions of the class. Best, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: duck-type-checking?

2008-11-14 Thread Joe Strout
e(intlike which asserts that foo is something dictionary-like that maps string- like things to something like a sequence of integer-like things. Most cases would not be this complex, of course, but would be closer to assert(fits(foo, strlike)) But this is still pretty ugly. Hmm. Maybe I'd better wait for ABCs. :) Cheers, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: object creation

2008-11-14 Thread Joe Strout
On Nov 14, 2008, at 4:33 PM, Jerry Hill wrote: Then add def __init__(self): a = 0 b = 0 to your box class to make a and b instance variables. Doesn't that have to be "self.a" and "self.b"? Best, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: compressed serialization module

2008-11-17 Thread Joe Strout
? Well, here's a thought: create a zip file (using the standard zipfile module), and pickle your data into that. HTH, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: Suggestions for an education programming project

2008-11-17 Thread Joe Strout
f the box (i.e., no need to install anything extra). It doesn't do the task you describe, but it does demonstrate animation and interaction with the mouse, and would be easy to extend and adapt in the direction you want. Best, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: Python-URL! - weekly Python news and links (Nov 17)

2008-11-17 Thread Joe Strout
Actually, contortions are required to make the standard definition of "call by value" NOT be applicable to Python as well as all other modern OOP languages [1]. Maybe we can discuss it further, and make this thread about the thread longer than the thread it's about? Cheers, - Jo

Re: Finding the instance reference of an object

2008-11-19 Thread Joe Strout
the case where the value is an object reference (as is always the case in Python)." I assert that anyone who does not understand all of the above, is helping to spread confusion. I agree. Best, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem with writing a long line in a text file

2008-11-19 Thread Joe Strout
s that way where? Using what tool to view it? My guess is that there is nothing wrong with the file, but that whatever you're using to view it is simply displaying it as two lines even though it is actually one. HTH, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: How to read space separated file in python?

2008-11-21 Thread Joe Strout
er was a colon.) Cheers, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: Need help converting text to csv format

2008-11-21 Thread Joe Strout
There are lots of ways to do that. Here's one: >>> qfields = ['"' + fld.strip() + '"' for fld in (num,desc,date)] >>> out = qfields.join(',') >>> out '"40922003","Life Fitness Products $1 ","12-13-08"' Cheers, - Joe P.S. Pay no attention to the grumpy graybeards who want to drive new users away from Python. There are quite a few friendly and helpful people here, too. :) -- http://mail.python.org/mailman/listinfo/python-list

Re: Using eval, or something like it...

2008-11-21 Thread Joe Strout
up: <http://www.strout.net/info/coding/valref/> I wrote this to help people in exactly your situation, so please do give me feedback and let me know how it did or didn't help. Thanks, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: How to read space separated file in python?

2008-11-21 Thread Joe Strout
On Nov 21, 2008, at 9:00 AM, Steve Holden wrote: Joe Strout wrote: On Nov 21, 2008, at 2:08 AM, Steven D'Aprano wrote: a, b = line.split() Note that in a case like this, you may want to consider using partition instead of split: a, sep, b = line.partition(' ') Thi

Re: Need help converting text to csv format

2008-11-21 Thread Joe Strout
will automatically "close" itself when it dies (and since a closed object in those cases is useless, I'd rather not have it around after it's closed anyway). Is the same true in Python, or do we need to explicitly close things? Thanks, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: Need help converting text to csv format

2008-11-21 Thread Joe Strout
that the file will be closed as soon as it loses its last reference, but I see that we shouldn't count on that in the Python world.) Best, - Joe -- http://mail.python.org/mailman/listinfo/python-list

how to dynamically instantiate an object inheriting from several classes?

2008-11-21 Thread Joe Strout
ch mixins might be used and in what combination. So I'd like to take a list of class references, and instantiate an object that derives from all of them, dynamically. Is this possible? If so, how? Thanks, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: how to dynamically instantiate an object inheriting from several classes?

2008-11-21 Thread Joe Strout
.5.2/ref/objects.html#l2h-21>, and that speaks only about the traditional use of type() to check the type of an object. help(type) does mention the form you show, though it doesn't explain what the dict is for. Where would I find documentation on this nifty function? Thanks,

<    1   2   3   4   5   6   >