Re: why cannot assign to function call

2009-01-09 Thread Joe Strout
Mark Wooding wrote: As an aside, I don't notice anywhere near as much confusion in Lisp and Scheme groups, which might be surprising since Lisp and Scheme have precisely the same data model, argument passing convention, and assignment semantics, as Python has. Nor is there anywhere near as muc

Re: why cannot assign to function call

2009-01-10 Thread Joe Strout
ru...@yahoo.com wrote: What is the observable difference between converting an array to a reference (pointer) to that array and passing the reference by value, and passing the array by reference? The difference is whether an assignment to the formal parameter (within the function) affects the

Re: why cannot assign to function call

2009-01-10 Thread Joe Strout
Aaron Brady wrote: Aaron Brady wrote: Possible compromise. You can think of functions as mutation-only. You pass the object, and it gets a new (additional) name. The old name doesn't go in. That's correct. The reference itself is passed in, not the variable (or expression) that held or ge

function to find the modification date of the project

2009-01-19 Thread Joe Strout
This isn't a question, but something I thought others may find useful (and if somebody can spot any errors with it, I'll be grateful). We had a case recently where the client was running an older version of our app, and didn't realize it. In other languages I've avoided this by displaying the

Re: function to find the modification date of the project

2009-01-19 Thread Joe Strout
James Mills wrote: You know you could just store a __version__ attribute in your main library (__init__.py). :) What, and update it manually? I don't trust myself to remember to do that every time! Best, - Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: function to find the modification date of the project

2009-01-19 Thread Joe Strout
James Mills wrote: Also I'd like to point out that your method is not very reliable as the modification time of those files could change at any moment. Consider unix systems for instnace where you could do: touch * And poof, you're modification times are now the current time! Yes, and presum

Re: function to find the modification date of the project

2009-01-19 Thread Joe Strout
Terry Reedy wrote: Yes, and presumably if some power user did this, then that would be the intended effect. Not sure why they'd do that, but they must have a good reason -- who am I to stop them? What if a curious user simple looks at a file with an editor and saves it without change? You

Re: English-like Python

2009-01-20 Thread Joe Strout
Aaron Brady wrote: I think it would be a good step if you could make some sensible interpretation of a typical statement without its parentheses. f "abc" 123 --> f( "abc", 123 ) It would be just the thing in a couple of situations... Such a language is possible -- take a look at REALbasic so

Re: English-like Python

2009-01-20 Thread Joe Strout
Aaron Brady wrote: Unambiguity and readability are two different things. (This should be a quasi-tangent, neither agreed, nor opposed, nor unrelated to what you said.) If you have f "abc" 123 it's unambiguous, but, if you have g f "abc" 123 "def" there's no sure way to determine where the

Re: English-like Python

2009-01-21 Thread Joe Strout
Steven D'Aprano wrote: LogError "Walk has gotten too silly", CurrentTime Here, LogError is a method call that takes two arguments, and CurrentTime is a method call that takes none. That seems ambiguous to me. As a non-RealBasic programmer, I can see at least four meanings it could have. Tr

Re: English-like Python

2009-01-21 Thread Joe Strout
Aaron Brady wrote: Where functions are first-class objects, a bare function object isn't distinguishable either from its call. That depends not on whether functions are first-class objects, but on the *syntax* of function invocation vs. function reference. It just so happens than in Python,

Re: English-like Python

2009-01-22 Thread Joe Strout
Steven D'Aprano wrote: Foo Is that legal RB syntax? You betcha! How do you know? I haven't specified what Foo does. You haven't specified whether "Foo" is a valid identifier at all, so I'm assuming that it is both valid and used correctly here. The syntax is certainly valid -- it m

Re: New to python, open source Mac OS X IDE?

2009-01-27 Thread Joe Strout
joseph.a.mar...@gmail.com wrote: Greetings! I've heard enough raving about Python, I'm going to see for myself what all the praise is for! I'm on a Mac. I use Netbeans for Java, PHP, and C if needed. Do you even use an IDE for Python? I don't -- I just use TextWrangler and a Terminal window.

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

2008-11-22 Thread Joe Strout
On Nov 21, 2008, at 7:02 PM, Steven D'Aprano wrote: I have a function that takes a reference to a class, Hmmm... how do you do that from Python code? The simplest way I can think of is to extract the name of the class, and then pass the name as a reference to the class, and hope it hasn't b

Re: Official definition of call-by-value (Re: Finding the instance reference...)

2008-11-22 Thread Joe Strout
On Nov 22, 2008, at 4:08 AM, Aaron Brady wrote: Furthermore, to apply c-b-v to Python, you have to introduce the concept of pointers, which is ostensibly non-native for human programmers. Not necessarily "pointers" per se -- any type of object references will do, and yes, Python has those in

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

2008-11-24 Thread Joe Strout
On Nov 24, 2008, at 11:10 AM, Matimus wrote: I wrote this a while ago. I sort of regret it though. Mixins could (and I will argue should) be avoided most of the time by delegating to other objects with less functionality. Utilizing many mixin classes tends to just make gigantic classes. This is

recommended __future__ imports for 2.5?

2008-11-24 Thread Joe Strout
OK, this will probably be placed into the "stupid question" category by some, but I really am in need of a bit of guidance here. I just rediscovered the "gotcha" of integer division in 2.5 and below, and found (to my delight) that this is fixed in 3.0, and fixable in older versions of Pytho

simplest way to strip a comment from the end of a line?

2008-12-04 Thread Joe Strout
I have lines in a config file which can end with a comment (delimited by # as in Python), but which may also contain string literals (delimited by double quotes). A comment delimiter within a string literal doesn't count. Is there any easy way to strip off such a comment, or do I need to

Re: Python 3.0 automatic decoding of UTF16

2008-12-05 Thread Joe Strout
On Dec 5, 2008, at 11:36 AM, Johannes Bauer wrote: I suspect that '?' after \n (\u0a00) is indicates not 'question-mark' but 'uninterpretable as a utf16 character'. The traceback below confirms that. It should be an end-of-file marker and should not be passed to Python. I strongly suspect tha

Re: how to get a beep, OS independent ?

2008-12-07 Thread Joe Strout
On Dec 7, 2008, at 6:36 AM, Duncan Booth wrote: Python is just printing the ascii bell character: some environments will interpret that as a request to make a beep, some will do things like flashing the whole screen, others just output a graphic character. Python doesn't know what your envi

Re: how to get a beep, OS independent ?

2008-12-07 Thread Joe Strout
On Dec 7, 2008, at 8:48 AM, Grant Edwards wrote: On 2008-12-07, Joe Strout <[EMAIL PROTECTED]> wrote: But invoking the standard system beep What makes you think there is such a thing as "the standard system beep"? Because OS X (the platform with which I'm most fa

Re: how to get a beep, OS independent ?

2008-12-07 Thread Joe Strout
On Dec 7, 2008, at 4:43 PM, Steven D'Aprano wrote: Of course, if you're volunteering to write such a standard system beep for Python, I for one would be grateful. I am. But where should I put it? Assuming we don't want to wait for the (understandably) lengthy and contentious process requir

Re: A question about reference in Python.

2008-12-08 Thread Joe Strout
On Dec 7, 2008, at 10:26 PM, Group wrote: Now, I want to write a Red-Black Tree, and a List structure. In C/C+ +, I can use pointers to refer to children notes (or next notes). But, in Python, how can I do it? Except the sequence, I know not any way. Any variable in Python is a reference,

Re: A question about reference in Python.

2008-12-08 Thread Joe Strout
On Dec 8, 2008, at 7:43 PM, Steven D'Aprano wrote: On Mon, 08 Dec 2008 08:18:27 -0700, Joe Strout wrote: On Dec 7, 2008, at 10:26 PM, Group wrote: Now, I want to write a Red-Black Tree, and a List structure. In C/C + +, I can use pointers to refer to children notes (or next notes)

Re: How to initialize a class variable once

2008-12-09 Thread Joe Strout
On Dec 9, 2008, at 4:31 AM, Brian Allen Vanderburg II wrote: There is one situation where a module can be imported/executed twice, if it is the __main__ module. That's an excellent point -- this is something I've run into, and it always feels a bit awkward to code around it. What's the stan

Re: var or inout parm?

2008-12-10 Thread Joe Strout
On Dec 10, 2008, at 4:29 PM, J. Clifford Dyer wrote: [EMAIL PROTECTED] wrote: How can I make a "var" parm, where the called function can modify the value of the parameter in the caller? See Also: the earlier heated debate thread over what evaluation strategy Python uses (Survey says!: call-b

Re: Call by reference in SWIG?

2008-12-11 Thread Joe Strout
On Dec 10, 2008, at 10:19 PM, Nok wrote: I can't get call-by-reference functions to work in SWIG... Python doesn't have any call-by-reference support at all [1], so I'm not surprised that a straight translation of the call-by-reference C function doesn't work. Unfortunately I don't know

Re: list organization question

2008-12-11 Thread Joe Strout
On Dec 11, 2008, at 4:12 PM, Robocop wrote: I have a list of objects, each object having two relevant attributes: date and id. I'd like not only organize by id, but also by date. I.e. i would like to parse my list into smaller lists such that each new mini-list has a unique date, but consists o

any Python developers available in the Denver area?

2008-12-11 Thread Joe Strout
My company is considering a contract job that would require some development staff on the client site in Denver. We'd like to subcontract some of that work. If you're a good Python coder in the Denver area, and would be available at least three days a week starting in January, please send

Re: concept of creating structures in python

2008-12-12 Thread Joe Strout
On Dec 11, 2008, at 10:52 PM, navneet khanna wrote: I want to create a structure within a structure i.e. nested structures in python. I tried with everything but its not working. my code is like this: class L(Structure): def __init__(self,Name='ND',Addr=0,ds_obj = D()): Change the defa

Re: concept of creating structures in python

2008-12-12 Thread Joe Strout
On Dec 12, 2008, at 9:00 AM, Steve Holden wrote: Change the default value of ds_obj here to None. Otherwise, you will certainly confuse yourself (there would be just one default object shared among all instances). Joe missed a piece out here. If you change the signature of your D.__init__() t

Re: %s place holder does not let me insert ' in an sql query with python.

2008-12-15 Thread Joe Strout
On Dec 15, 2008, at 6:46 AM, Krishnakant wrote: in this case, I get a problem when there is ' in any of the values during insert or update. That's because ' is the SQL string literal delimiter. But any SQL- compliant database allows you to "escape" an apostrophe within a string literal by

AIM client code for Python?

2008-12-16 Thread Joe Strout
I'd like to write an AIM bot in Python. I found and tried , but it doesn't work for me: Connecting... Traceback (most recent call last): File "aimbot-1.py", line 17, in bot.go() File "/Users/jstrout/Documents/Python-Dev/AIMbot/toc.py", line 62, in go

How to modify a program while it's running?

2008-12-16 Thread Joe Strout
Here's my situation: I'm making an AIM bot, but the AIM server will get annoyed if you log in too frequently (and then lock you out for a while). So my usual build-a-little, test-a-little methodology doesn't work too well. So I'd like to restructure my app so that it can stay running and s

Re: encoding problem

2008-12-19 Thread Joe Strout
Marc 'BlackJack' Rintsch wrote: The question is why the Python interpreter use the default encoding instead of "utf-8", which I explicitly declared in the source. Because the declaration is only for decoding unicode literals in that very source file. And because strings in Python, unlike in

Re: How to parsing a sequence of integers

2008-12-19 Thread Joe Strout
Peter Otten wrote: If you are using Python 2.x: ... So you better throw in a float(...): Or, add from __future__ import division at the top of the file. I put this at the top of all my Python files, whether I expect to be dividing or not. It just saves grief. Cheers, - Joe -- http://

Re: How to parsing a sequence of integers

2008-12-19 Thread Joe Strout
Mensanator wrote: from __future__ import division at the top of the file. I put this at the top of all my Python files, whether I expect to be dividing or not. It just saves grief. If you want division to be floating point. If, like me, you rarely do floating point division and want the "/" t

Re: encoding problem

2008-12-19 Thread Joe Strout
Marc 'BlackJack' Rintsch wrote: And because strings in Python, unlike in (say) REALbasic, do not know their encoding -- they're just a string of bytes. If they were a string of bytes PLUS an encoding, then every string would know what it is, and things like conversion to another encoding, or co

Re: encoding problem

2008-12-19 Thread Joe Strout
Marc 'BlackJack' Rintsch wrote: I don't see the shortcoming in Python <3.0. If you want real strings with characters instead of just a bunch of bytes simply use `unicode` objects instead of `str`. Fair enough -- that certainly is the best policy. But working with any other encoding (sometimes

Re: Python's popularity

2008-12-22 Thread Joe Strout
Alvin ONeal wrote: Also worthy of mention: I've seen python pre-installed on consumer HP desktops (I think as part of a backup/restore script, but I'm not sure) It's pre-installed on every Mac (both desktop and laptop), too. Cheers, - Joe -- http://mail.python.org/mailman/listinfo/python-lis

Re: embedding python in wxpython

2008-12-30 Thread Joe Strout
Steve Holden wrote: I'd like the console to be a bidirectional representation of what's going on in the gui, plus a general purpose evaluation environment where you can manipulate application data via some api which is automatically exposed to the console when the application opens up. I'm look

Re: why cannot assign to function call

2009-01-06 Thread Joe Strout
Mark Wooding wrote: Derek Martin wrote: I think I have though, not that it matters, since that was never really my point. Python's assignment model requires more explanation than the traditional one, simply to state what it does. That alone is evidence (but not proof). Hmm. Actually, it'

Re: python is great

2009-01-06 Thread Joe Strout
I've actually been rather frustrated by Python lately. It's great at some things, but rather poor at others. In the latter category is building a neatly packaged executable that can be shipped to users and run reliably on their machine. On the Mac in particular, if you want your app to run o

Re: If your were going to program a game...

2009-01-06 Thread Joe Strout
Kay Schluehr wrote: There is no solution to this problem from a Python perspective. Do what everyone does right now: use Flash for the game and manage your site with Python if you like the language. I know this has been discussed before, and the difficulties are many, yadda yadda etc... But

Re: python is great

2009-01-06 Thread Joe Strout
M.-A. Lemburg wrote: On the Mac in particular, if you want your app to run on any PowerPC or Intel machine runing 10.4 or later, and you're using anything not in the standard framework (such as MySQLdb), it's a bit of a nightmare. You're looking for py2app: http://undefined.org/python/py2app

Re: image recogniton?

2009-01-07 Thread Joe Strout
Li Han wrote: Sorry, I oversimplified the question because of my poor english. It is an analog compass whose value we need to read into the computer every second. We use a video camera keep shooting it, and the compass and camera are fixed. If you have any choice about it, it would be greatl

Re: why cannot assign to function call

2009-01-07 Thread Joe Strout
Dan Esch wrote: In essence, the implication of immutability for Python is that there is only one "parrot", one "spam,"in fact one anything. (This seems like it must hold for data primitives - does it hold for complex objects as well? It seems it must...) In addition there is only one 1, and on

Re: why cannot assign to function call

2009-01-08 Thread Joe Strout
Mark Wooding wrote: The `they're just objects' model is very simple, but gets tied up in knots explaining things. The `it's all references' model is only a little more complicated, but explains everything. But it *over* explains, because it implies things that "everybody knows" about reference

Re: why cannot assign to function call

2009-01-08 Thread Joe Strout
ru...@yahoo.com wrote: "the same as anyone else's" only if [Python's] "idea of assignment" does not include producing the same results. a = array (1,2,3) b = a a[1] = 4 print b C, C++, VBA, Fortran, Perl: 1, 2, 3 Python: 1, 4, 3 You are mistaken (except perhaps in the Fortran case,

Re: why cannot assign to function call

2009-01-09 Thread Joe Strout
ru...@yahoo.com wrote: a = array (1,2,3) b = a a[1] = 4 print b C, C++, VBA, Fortran, Perl: 1, 2, 3 Python: 1, 4, 3 You are mistaken I don't think so. See http://groups.google.com/group/comp.lang.python/msg/f99d5a0d8f869b96 The code I quoted there was tested. In the C/C++ case, arr

Re: why cannot assign to function call

2009-01-09 Thread Joe Strout
Aaron Brady wrote: Possible compromise. You can think of functions as mutation-only. You pass the object, and it gets a new (additional) name. The old name doesn't go in. That's correct. The reference itself is passed in, not the variable (or expression) that held or generated the refere

Re: why cannot assign to function call

2009-01-09 Thread Joe Strout
ru...@yahoo.com wrote: I never claimed that you *couldn't* have copy semantics in C; you can do almost anything you want in C (or C++). But the *normal* usage of an array is via a pointer, in which case the semantics are exactly the same as in Python, Java, REALbasic, .NET, etc. Arrays are th

type-checking support in Python?

2008-10-06 Thread Joe Strout
I'm just re-learning Python after nearly a decade away. I've learned a good healthy paranoia about my code in that time, and so one thing I'd like to add to my Python habits is a way to both (a) make intended types clear to the human reader of the code, in a uniform manner; and (b) catch a

Re: equivalent of py2exe in other os

2008-10-07 Thread Joe Strout
On Oct 7, 2008, at 8:43 AM, Benjamin Kaplan wrote: I believe that all (or nearly all) Unix variants come with Python preinstalled. Ubuntu, at least, has a lot of system programs written in Python. Even Mac OS X requires Python. Yes, but with significant differences between different Python

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

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 Joe as

template strings for matching?

2008-10-09 Thread Joe Strout
Catching up on what's new in Python since I last used it a decade ago, I've just been reading up on template strings. These are pretty cool! However, just as a template string has some advantages over % substitution for building a string, it seems like it would have advantages over manual

Re: template strings for matching?

2008-10-09 Thread Joe Strout
Wow, this was harder than I thought (at least for a rusty Pythoneer like myself). Here's my stab at an implementation. Remember, the goal is to add a "match" method to Template which works like Template.substitute, but in reverse: given a string, if that string matches the template, then

book recommendation for Python newbie?

2008-10-09 Thread Joe Strout
I'm trying to (gently) convince my business partner that we should be adding Python to our core toolset. He's never used it before, apart from poking around in the tutorial a bit at my urging. But he's got a birthday coming up, and I'd like to get him a book that will help him make the tr

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

2008-10-10 Thread Joe Strout
I would like to propose a new method for the string.Template class. What's the proper procedure for doing this? I've joined the python- ideas list, but that seems to be only for proposed language changes, and my idea doesn't require any change to the language at all. From

Re: docpicture

2008-10-13 Thread Joe Strout
On Oct 13, 2008, at 2:43 PM, Benjamin Kaplan wrote: I mean what happens when you type help() into the interactive console on the command line? You will see the docstrings, and there will be a whole bunch of random hex characters there. Good point. It might be better put in a specially-tag

recommendations for a web CMS (content management system)?

2008-10-15 Thread Joe Strout
We need to set up a content management system that allows nontechnical users to manage the content of their web site. Rather than starting from scratch, I'd prefer to start with an existing CMS that we can extend as needed. So, I'd prefer something with nice clean, easy-to- follow code ove

Python equivalent to SharePoint?

2008-10-15 Thread Joe Strout
We've got a client who has been planning to use SharePoint for managing their organization documents, but has recently dropped that idea and is looking for an alternative. Is there any Python package with similar functionality? I confess that I've never used SharePoint myself, and what I k

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

2008-10-15 Thread Joe Strout
On Oct 15, 2008, at 2:47 PM, Ben Finney wrote: Because of the inescapable central role in our craft of manipulating text files, essential in this development environment is a highly-customisable text editor with a broad *and* deep library of existing customisations, to maximise the amount of wor

Re: Finding the instance reference of an object

2008-10-16 Thread Joe Strout
On Oct 16, 2008, at 10:59 AM, Larry Bates wrote: how do i find that the name is 'bob' Short answer is that you can't. This because Python's names (bob) are bound to objects (modulename.objectname()). They are NOT variables as they are in "other" programming languages. Which other progr

Re: Finding the instance reference of an object

2008-10-16 Thread Joe Strout
On Oct 16, 2008, at 7:30 PM, Steven D'Aprano wrote: However, 'bob' here really is a variable. It's a variable whose value (at the moment) is a reference to some object. Traditionally, a "variable" is a named memory location. Agreed. The main objection I have to using "variable" to descr

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
On Oct 17, 2008, at 10:00 AM, coldpizza wrote: http://stackoverflow.com/questions/101268/hidden-features-of-python Thanks, there are a lot of useful nuggets there. However, can anybody explain the "Main messages" one? It doesn't include any explanatory text at all, just a code snippet:

Re: 'Hidden Features of Python'

2008-10-17 Thread Joe Strout
On Oct 17, 2008, at 10:35 AM, coldpizza wrote: If you are using and IDE, such as Eclipse, PyScripter, etc, then CTR +click on 'this' should do the trick. In ipython you can do 'import this' and then type 'this??' Or if you are *not* lazy, you could try locating the file in the Python tree. Oh!

Re: inserting Unicode character in dictionary - Python

2008-10-17 Thread Joe Strout
On Oct 17, 2008, at 11:24 AM, Marc 'BlackJack' Rintsch wrote: kw = 'генских' What do you mean by "does not work"? And you are aware that the above snipped doesn't involve any unicode characters!? You have a byte string there -- type `str` not `unicode`. Just checking my understanding he

Re: Finding the instance reference of an object

2008-10-17 Thread Joe Strout
On Oct 17, 2008, at 1:03 PM, Aaron Castironpi Brady wrote: I'm not fluent in Java so you'll have to be the judge. In Python: b= 0 f( b ) No matter what, b == 0. C doesn't guarantee this. It does, unless f's parameter has been declared a reference parameter. (In C++, you'd do this with '

Re: inserting Unicode character in dictionary - Python

2008-10-17 Thread Joe Strout
Thanks for the answers. That clears things up quite a bit. What if your source file is set to utf-8? 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? Well, the decode method knows how to decode t

Re: Finding the instance reference of an object

2008-10-17 Thread Joe Strout
On Oct 17, 2008, at 2:36 PM, Steve Holden wrote: No, a "by ref" parameter would mean that this: def foo(ByRef x): x = x + [42] a = [1,2,3] foo(a) ...would result in a = [1,2,3,42]. In [8]: def foo(x): ...: x += [42] ...: In [9]: a = [1, 2, 3] In [10]: foo(a) In [11]: a Out[11]:

Re: Finding the instance reference of an object

2008-10-17 Thread Joe Strout
On Oct 17, 2008, at 3:19 PM, Grant Edwards wrote: And my real point is that this is exactly the same as in every other modern language. No, it isn't. In many other languages (C, Pascal, etc.), a "variable" is commonly thought of as a fixed location in memory into which one can put values. Th

Re: inserting Unicode character in dictionary - Python

2008-10-19 Thread Joe Strout
On Oct 18, 2008, at 1:20 AM, Martin v. Löwis wrote: 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? There is (probably) no such thing as a "proper UTF-8 string" (in the sense in which you proba

Re: Unicode (UTF8) in dbhas on 2.5

2008-10-21 Thread Joe Strout
On Oct 21, 2008, at 2:39 PM, Martin v. Löwis wrote: It's not possible to "fix" this - it isn't even broken. The *db modules, by design, support storing of arbitrary bytes, not just character data. Many database engines are encoding-aware, and distinguish between 'text' columns and 'blob'

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

2008-10-22 Thread Joe Strout
On Oct 22, 2008, at 10:00 PM, Steven D'Aprano wrote: It would have been easy to avoid this: just copy the relevant bits of the / directory hierarchy in the user's home directory. Global settings go in /etc and per user settings go in ~/etc. Global temp files go into / tmp and per user temp f

Re: ANN: gui_support, a convenience library for wxPython

2008-10-23 Thread Joe Strout
On Oct 23, 2008, at 11:50 AM, Stef Mientki wrote: gui_support is library for easy creation of GUI designs in wxPython. ... Brief documentation can be found here http://oase.uci.kun.nl/~mientki/data_www/pylab_works/pw_gui_support.html That's neat -- thank you for making it available. I've jus

Re: Finding the instance reference of an object

2008-10-27 Thread Joe Strout
On Oct 27, 2008, at 12:19 PM, [EMAIL PROTECTED] wrote: I think this "uncontrived" example addresses the C/Python difference fairly directly (both were tested): That's correct, but of course, C is a decades-old language barely a step above assembler. For a fair comparison, pick any modern OO

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

2008-10-28 Thread Joe Strout
On Oct 28, 2008, at 8:41 AM, Shannon Mayne wrote: I would like to create objects with algorithmically determined names based on other object names and use object names for general algorithm input. What do you mean by the "name" of an object? Objects don't generally have names, unless you ex

Re: Finding the instance reference of an object

2008-10-28 Thread Joe Strout
On Oct 27, 2008, at 11:28 PM, Gabriel Genellina wrote: En Tue, 28 Oct 2008 00:58:10 -0200, greg <[EMAIL PROTECTED]> escribió: Let's look at the definitions of the terms: (1) Call by value: The actual parameter is an expression. It is evaluated and the result is assigned to the formal par

explanation of values, references, assignment, and method calls

2008-10-28 Thread Joe Strout
I've tried to write up this topic in a clear, step-by-step manner, with the help of diagrams and short examples from several different OOP languages. I hope it will help clear up the confusion that seems to be pervading the Python community (and which is far more rare in the other language

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

2008-10-28 Thread Joe Strout
On Oct 28, 2008, at 4:45 PM, Steven D'Aprano wrote: What do you mean by the "name" of an object? Objects don't generally have names, unless you explicitly define a .name property and assign them names. (Variables have names, of course, but a variable isn't an object -- it's just a reference

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

2008-10-28 Thread Joe Strout
On Oct 28, 2008, at 6:58 PM, Steve Holden wrote: Objects in Python *don't* have names. Period. In Python we don't normally talk about variables anyway, except when speaking loosely, we talk about binding names. But please don't let this start another round of "Python programmers don't know ho

Re: Finding the instance reference of an object

2008-10-29 Thread Joe Strout
On Oct 29, 2008, at 4:52 PM, Fuzzyman wrote: You're pretty straightforwardly wrong. In Python the 'value' of a variable is not the reference itself. That's the misconception that is leading some folks around here into tangled nots of twisty mislogic, ultimately causing them to make up new

Re: Finding the instance reference of an object

2008-10-30 Thread Joe Strout
On Oct 30, 2008, at 7:56 AM, Dale Roberts wrote: That's the misconception that is leading some folks around here into tangled nots of twisty mislogic, ultimately causing them to make up new terms for what every other modern language is perfectly happy calling Call-By-Value. Doesn't this logic

Re: Single string vs list of strings

2008-10-30 Thread Joe Strout
On Oct 30, 2008, at 8:55 AM, Grant Edwards wrote: The question you might want to asked is whether the parameter is a single string or a sequence of strings. That way your code will also work with an iterator that returns strings. type('asdf') is str True I agree with the general approach,

Re: Finding the instance reference of an object

2008-10-30 Thread Joe Strout
On Oct 30, 2008, at 6:38 PM, greg wrote: The distinction isn't about parameter passing, though, it's about the semantics of *assignment*. Once you understand how assigment works in Python, all you need to know then is that parameters are passed by assigning the actual parameter to the formal par

Re: Finding the instance reference of an object

2008-10-30 Thread Joe Strout
On Oct 30, 2008, at 6:58 PM, greg wrote: For what it's worth, I happen to agree that telling someone that Python passes parameters "by value" without being sure they understand exactly what "by value" means, is not a good idea -- not because the term isn't well-defined, but because of the widesp

Testing dictionary results with doctest

2008-10-31 Thread Joe Strout
I love doctest -- the way it combines documentation with verification seems elegant and useful, and most of the time it's simple and easy to use. But I've run into a bit of a snag trying to test a method that returns a dictionary, because (of course) the order in which the dictionary pair

Re: Finding the instance reference of an object

2008-11-03 Thread Joe Strout
On Nov 3, 2008, at 12:00 PM, Aaron Brady wrote: I think we can conclude that Python passes by reference, since a function can modify objects that were passed in to it. Then please write the Python equivalent of the "Swap" methods shown at (or at

Re: Finding the instance reference of an object

2008-11-03 Thread Joe Strout
On Nov 3, 2008, at 2:36 PM, Aaron Brady wrote: Then please write the Python equivalent of the "Swap" methods shown at (or at , for that matter). And no fair wrapping the two parameters up in an object

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 -- http://mail.

Re: Finding the instance reference of an object

2008-11-03 Thread Joe Strout
On Nov 3, 2008, at 5:27 PM, Marc 'BlackJack' Rintsch wrote: Maybe this is a surprise for you, because we haven't discussed this in much detail in this group lately, but it applies to Python which does call-by-object or call-by-sharing. ;-) There's no such thing. Those are just terms made up

locating the chorus in a MIDI song?

2008-11-03 Thread Joe Strout
We've got a need to generate short "samples" of songs that are in MIDI format, to provide a preview function in a web app. We'd like to do something more clever than just taking the middle 20 seconds (or whatever) of the song -- ideally, we'd like to find the chorus, since that's likely to

Re: Which was the best Lib of GUI for python

2008-11-04 Thread Joe Strout
On Nov 3, 2008, at 10:53 PM, 3000 billg wrote: I am a leaner. for your experience. Which GUI Lib will be the best for Python? wxpython, Tkinter or... I'm sure you'll get as many opinions on this as there are libraries. However, I recently faced the same choice, and settled on wxPython.

Re: Finding the instance reference of an object

2008-11-04 Thread Joe Strout
On Nov 4, 2008, at 7:42 AM, Craig Allen wrote: coming from C/C++ Python seemed to me call by reference, for the pragmatic reason you said, modificaitons to function arguments do affect the variable in the caller. The confusing part of this then comes when immutable objects are passed in. Yes,

Re: Python on iPhone actually rather good

2008-11-04 Thread Joe Strout
On Nov 4, 2008, at 10:33 AM, Michael Torrie wrote: Are there any good books on python and objc? I doubt you'll be able to make any decent iPhone apps without having a good working knowledge of Objective C and the python-objc bridge. In my mind that's one of the cool parts of doing cocoa deve

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 was correct.

Re: Finding the instance reference of an object

2008-11-04 Thread Joe Strout
On Nov 4, 2008, at 3:54 PM, Steven D'Aprano wrote: At the level of Python code, Python operates on *objects*. When you call a function with an argument, the argument (an object) is NOT copied, it is passed to the function. If you mutate the argument inside the function, you are changing the

  1   2   >