Re: Boss wants me to program

2005-06-29 Thread Peter Hansen
ures either present or lacking in C++. Ultimately, manageability of a project is far and away more about the people involved and the techniques used than it is about any single technology involved. -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: aligning text with space-normalized text

2005-06-30 Thread Peter Otten
(text, chunks)) == [(3, 10), (11, 22), (24, 40), (44, 47), (48, 51)] if __name__ == "__main__": main() Not tested beyond what you see. Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: POP3 and "seen" flag

2005-06-30 Thread Peter Hansen
een by using the TOP command. This sort of thing is entirely non-standard and you can't rely on it in general, AFAIK. A better approach would be to have your client software track the Message-ID header, but something tells me you are interpreting "seen" as meaning "anyone has RETR

Re: Programmers Contest: Fit pictures on a page

2005-06-30 Thread Peter Hansen
nd this would probably be an excellent way to learn more about them, even if you don't get the best solution. -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: OOP help needed incorporating existing modules in class

2005-06-30 Thread Peter Hansen
bably incorrect in the specifics of the call to ctime(), but reading the documentation for "datetime" after you've learnt the basics of Python should solve that.) -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: How to run commands in command line from a script

2005-06-30 Thread Peter Hansen
myscript.py if exist c:\temp\_mycd.bat call c:\temp\_mycd.bat somewhere inside myscript.py newDir = r'c:\Program Files' f = open(r'c:\temp\_mycd.bat', 'w') f.write('''rem This file generated by myscript.py cd = %s'''

Re: How to run commands in command line from a script

2005-06-30 Thread Peter Hansen
Peter Hansen wrote: > Ivan Shevanski wrote: >> Alright well I'm quite a noob and when I run a simple command to >> change the current directory, nothing happens. I made a little test >> script to show it: > > Generally, the only way to use an application (i

Re: Dr. Dobb's Python-URL! - weekly Python news and links (Jun 29)

2005-07-01 Thread Peter Maas
Simon Brunning schrieb: > Sibylle Koczian needs to sort part of a list. His first attempt made > the natural mistake - sorting a *copy* of part of the list: I think it was _her_ first attempt. -- --- Peter Maas

Re: python project layout

2005-07-01 Thread Peter Hansen
runner or other utilities. Running tests (always from a console) takes only a few seconds so we can do it often. Multiple projects are easily supported in other directory trees. -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: Programmers Contest: Fit pictures on a page

2005-07-01 Thread Peter Hansen
Dan Sommers wrote: > Peter Hansen <[EMAIL PROTECTED]> wrote: >>This problem is well suited to the abilities of genetic algorithms, >>and this would probably be an excellent way to learn more about them, >>even if you don't get the best solution. > > Ther

Re: Python for everything?

2005-07-01 Thread Peter Hansen
rogram "scripts", but I think that's probably just out of habit or association: calling single Python source files "scripts" is so common, even if they aren't scripts in the sense of "individually executable files written in a scripting language" any more. -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: How to run commands in command line from a script

2005-07-01 Thread Peter Hansen
to everyone who responded > I'm really getting along here. So basically "os.system" would have done exactly what you wanted if you'd tried it on "mame" instead of using "cd", for reasons we've now covered. :-) -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: is there a better way to walk a file system?

2005-07-01 Thread Peter Hansen
of doing this?" in relation to paths is always "yes, use Jason Orendorff's path module". -Peter -- http://mail.python.org/mailman/listinfo/python-list

Assigning to None (was Re: Question about Python)

2005-07-01 Thread Peter Hansen
Mike Meyer wrote: > Yes. I once grabbed an old program that did assignments to None. But > that's always been a bad idea. What was the use case!? -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: is there a better way to walk a file system?

2005-07-01 Thread Peter Otten
t;> A.value.__get__(a) 42 >>> sorted([A(42), A(2), A(4)], key=A.value.__get__) [A(2), A(4), A(42)] Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-01 Thread Peter Hansen
;computer programming > for every C-programmer". Huh? Where did that come from? Functions are objects in Python and I've not heard the least discussion about this being changed, until now. Sean, what gave you the impression this would change? -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: Accepted Summer of Code proposals

2005-07-02 Thread Peter Hansen
gt; Is it right that two Wax proposals were accepted? "Right" can mean either "correct" or "proper". Which did you mean? If you meant the first, then the above link clearly shows that there were in fact two different Wax proposals (from different people) accepted. -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: wxPython: Terminal Output -> Scrollable Panel?

2005-07-02 Thread Peter Hansen
Crust. Then find the source for PyCrust in the wxPython folder (under your lib/site-packages folder in c:\python24) and start reading. -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: What are the other options against Zope?

2005-07-02 Thread Peter Hansen
its own ZODB. What proprietary database is involved? -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: email link and foreign accent

2005-07-02 Thread Peter Hansen
characters. > [snip] > Any suggestion is welcome, It might help if you showed us the output of "repr(x)" where x is the output of the campovalore.encode('iso-8859-1') part above. -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: What are the other options against Zope?

2005-07-02 Thread Peter Hansen
Florian Lindner wrote: > Peter Hansen wrote: >>[Zope] doesn't include >>database interfaces other than to its own ZODB. > > That's not correct. Zope2 includes DB interfaces to MySQL, PostGre, ODBC and > many others. It actually *includes* them? I thought t

Re: Inheriting from object

2005-07-02 Thread Peter Hansen
lling A.__init__ recursively, giving you an eventual stack overflow). -correcting-bengt-richter-on-such-arcana-is-always-dangerously y'rs, Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: wxPython: Terminal Output -> Scrollable Panel?

2005-07-02 Thread Peter Hansen
s...' If you *don't* have the ability to change the print statements like this, then you can install a Redirector in place of sys.stdout, but that will affect all prints, including those in standard library modules and elsewhere. HTH -Peter -- http://mail.python.org/mailman/listinfo/python-list

Determining actual elapsed (wall-clock) time

2005-07-02 Thread Peter Hansen
;m not too concerned about the resolution, though better than one second would be useful. Thanks for any suggestions. -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: Determining actual elapsed (wall-clock) time

2005-07-02 Thread Peter Hansen
Roy Smith wrote: > Peter Hansen <[EMAIL PROTECTED]> wrote: > If you get the UTC time, daylight savings time doesn't enter the equation. Of course... I didn't think of that approach. I don't actually care about absolute time, so this should work fine for at least t

Re: Determining actual elapsed (wall-clock) time

2005-07-02 Thread Peter Hansen
Roy Smith wrote: > Peter Hansen <[EMAIL PROTECTED]> wrote: >>I'll have to look into how to set up Windows XP to prevent users from >>changing the time on their own, assuming that's possible. > > On a single-user system like Windows, you pretty much have

Re: Determining actual elapsed (wall-clock) time

2005-07-02 Thread Peter Hansen
Roy Smith wrote: > Peter Hansen <[EMAIL PROTECTED]> wrote: >>Using time.time() doesn't appear to be suitable, since time might jump >>forwards or backwards at the user's whim, if the system clock is reset, >>or when a daylight savings time change occurs. &

Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-02 Thread Peter Hansen
It? > > Nope, sorry, still not getting it. If you were serious, Google would be a real good friend here, since the answer is in its first search result... without even having to click on the link! Heck, it even points you to the web site: http://tmtowtdi.com :-) -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: Python, mysql, floating point values question

2005-07-02 Thread Peter Hansen
Terry Hancock wrote: > On Saturday 02 July 2005 08:53 pm, Dennis Lee Bieber wrote: > And for that matter, some of the posters here have *been* 14. Terry, almost every single one of the posters here have been 14. At some time. :-) -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: Favorite non-python language trick?

2005-07-03 Thread Peter Otten
sequence = map(float, range(10)) r = reduce(lambda x, y: x*y-1/y, sequence) s = my_reduce(lambda x, y: x*y-1/y, sequence) assert r == s :-) Peter -- http://mail.python.org/mailman/listinfo/python-list

How execute a .py in this way?

2005-07-03 Thread Peter Cai
If it's a executable file, a ".exe" file, you can launch it in this way, "xxx.exe < input.txt". The text file "input.txt" will be considered as the standard input. But when I use this trick on python, it doesn't work. The only way to do so is like this "python xxx.py < input.txt". But this method

Re: How do you program in Python?

2005-07-03 Thread Peter Hansen
Sounds pretty close to old-style BASIC and since I've come that route too (in the distant past), this may not be a coincidence. -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: How execute a .py in this way?

2005-07-03 Thread Peter Hansen
Peter Cai wrote: > Thus, you > can execute you "py" program anywhere by using the command "xxx.py", > but when you want to use an exsiting file as it's input, you have to > use something like "pythong xxx.py < input.txt". This is apparently a bug

Re: map/filter/reduce/lambda opinions and background unscientificmini-survey

2005-07-03 Thread Peter Hansen
ose who seem most concerned are actually more worried about losing the free support of a team of expert developers as those developers evolve their vision of the language, than about losing access to something as minor as reduce(). -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: Accepted Summer of Code proposals

2005-07-03 Thread Peter Decker
On 7/2/05, Reinhold Birkenfeld <[EMAIL PROTECTED]> wrote: > A.M. Kuchling wrote: > > For anyone who's interested: the Python wiki now contains a list of the > > PSF-mentored proposals that were accepted for Google's Summer of Code: > > http://wiki.python.org/moin/SummerOfCode > > Is it right

Re: need to get an index for an item in a list

2005-07-03 Thread Peter Hansen
ike so: dir([]) Note in the output the presence of the "index" method... I'll leave it up to you to read the docs to learn more about how to use it, or you can just experiment at the prompt to see how it works. -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: Accepted Summer of Code proposals

2005-07-03 Thread Peter Hansen
Peter Decker wrote: > On 7/2/05, Reinhold Birkenfeld <[EMAIL PROTECTED]> wrote: >>Is it right that two Wax proposals were accepted? > > Or that Wax is being promoted over Dabo "Promoted"? Do you know if any Dabo proposals were even made? And how good the pro

Re: need to get an index for an item in a list

2005-07-03 Thread Peter Hansen
approaches (such as Roy suggested in his other post) may well be more appropriate depending on the context. -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: Accepted Summer of Code proposals

2005-07-03 Thread Peter Decker
On 7/3/05, Robert Kern <[EMAIL PROTECTED]> wrote: > I would suggest not speculating on biased or malicious intentions. It is > possible that no one applied with a proposal to work on Dabo, or that > such a proposal was poorly written, or that the author had too little > experience, or any number o

Re: How do you program in Python?

2005-07-03 Thread Peter Hansen
James wrote: > Peter Hansen wrote: >>I edit in the Scite window, hit Alt-Tab (under Windows XP) to change >>focus to the cmd console (and instantly all my modified files are >>saved), press the Cursor Up key to retrieve the previous command (which >>is generally the name

Re: What are the other options against Zope?

2005-07-03 Thread Peter Hansen
Florian Lindner wrote: >>>Peter Hansen wrote: >>>>[Zope] doesn't include >>>>database interfaces other than to its own ZODB. > > Ok, you're right. But I don't really think it makes a difference to install > them afterwards. Probably not,

Re: looping over a big file

2005-07-03 Thread Peter Hansen
better approach to ensuring your code "does the right thing" in the future, and "file" should still be used in the rare case where you actually want to test whether something is a particular type of thing. -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: Will Guido's "Python Regrets" ever get implemented/fixed?

2005-07-04 Thread Peter Maas
George Sakkis schrieb: > Given that the latest 2.x python will be 2.9 Why not 2.13 or 2.4711? Version strings are sequences of arbitrary integers separated by dots and not decimal numbers, or are they? -- --- Peter Maas,

Re: python project layout

2005-07-04 Thread Peter Hansen
Huron wrote: > Hi Peter, > Thanks for you detailed reply. > The layout that you suggest sounds wise to me (I'm about to start a > project). I wouldn't necessarily recommend something so complex (not that it's particular complex, but it's more than just "fla

Re: python project layout

2005-07-04 Thread Peter Hansen
Huron wrote: > For instance, if you have several classes implementing the same > interface > (say, doing the same things with different strategies), how would you > organize that in terms of files (modules) and directories (packages) ? A concrete example would probably help. What are you

Re: Determining actual elapsed (wall-clock) time

2005-07-04 Thread Peter Hansen
ied about time.time(), it will be quite sufficient when used in conjunction with a threatened slap on the wrist (or a label on the side of the monitor) for any user who tries to change the clock... (Thanks, Tim! time.time() makes sense finally.) -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: curses -- getxy() error

2005-07-04 Thread Peter Hansen
roblem is. This will help you in the future, even if k33rni's answer solves your immediate problem... -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: map/filter/reduce/lambda opinions and background unscientificmini-survey

2005-07-04 Thread Peter Hansen
eration. And for most of us, English comes > easier than Computer Science jargon. And with a better choice of names than "x", that line becomes even more self-documenting. [str(parrot) for parrot in sequence], for example, tells you much more about what is going on than s

Re: Existance of of variable

2005-07-04 Thread Peter Otten
;t think of when you wrote it and that implement the same methods and attributes but are of a totally unrelated class (google for "duck type"). Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: "long int..." exception reported with strange traceback location

2005-07-04 Thread Peter Otten
in 2.3 which you were > running. But arg 2 *is* a tuple. So a least the error message is wrong, too. Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: threads and sleep?

2005-07-04 Thread Peter Hansen
s wondering is if the sleep will pause the t > thread as well as the main function or is the thread independat of the > main function sleep? Your code is very close to working already... why don't you just run it and observe how it works? In any case, the answer is "no, time.s

Re: How do you program in Python?

2005-07-05 Thread Peter Hansen
nt conflict in the two philosophies embodied by the "simple little programs" and the "emacs" approaches.) -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: threads and sleep?

2005-07-05 Thread Peter Hansen
ilable (even if they _aren't_ on the same machine!). -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-05 Thread Peter Hansen
carry on with useful work. Really, the name is such a trivial, unimportant part of this whole thing that it's hardly worth discussing. The syntax is more important, and the limitations are of definite interest. Not the name. -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: Lisp development with macros faster than Python development?..

2005-07-05 Thread Peter Hansen
n to be the fastest language to develop in, so far, but it's quite possible to imagine another language in the future which I might learn which would be -- for me -- even faster, at least for certain types of problems. (But so what? :-) ) -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: adding a character to the last string element of a list

2005-07-05 Thread Peter Hansen
of part of the list and sure enough the original has never been changed. > What am I missing ? That slicing makes copies. If you directly access the element in the first list (without using a slice) it will work. (I think I've got most of the correct...) -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: System Independent Wallpaper Changer

2005-07-05 Thread Peter Hansen
= 'W': I think you might have a problem with the above, where it seems you changed from one approach to another part way through solving the problem... should throw a NameError pretty quick when you run it though. -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: threads and sleep?

2005-07-06 Thread Peter Hansen
Jonathan Ellis wrote: > Peter Hansen wrote: >>Or investigate the use of Irmen's Pyro package and how it could let you >>almost transparently move your code to a *multi-process* architecture > > Unless you're doing anything that would require distributed locking. &

Re: adding a character to the last string element of a list

2005-07-06 Thread Peter Hansen
nly a single index as you have in l[-1] is just a reference to one element in the list. -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: Using Ghostscript DLL via ctypes in Py2.3/Win

2005-07-06 Thread Peter Hansen
a reply (though I suspect most people there read this forum as well). -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: threads and sleep?

2005-07-06 Thread Peter Hansen
ultiple interpreters"? As I understand the concept, and based on my several years' old reading of the virtual machine code, I wouldn't say there are multiple interpreters. There's a reason the GIL is the *global* interpreter lock... -Peter -- http://mail.python.org/mailman/listinfo/python-list

Use cases for del

2005-07-06 Thread Peter Hansen
del: how would I, in doing automated testing, ensure that I've returned everything to a "clean" starting point in all cases if I can't delete variables? Sometimes a global is the simplest way to do something... how do I delete a global if not with "del"? -Peter --

Re: Lisp development with macros faster than Python development?..

2005-07-06 Thread Peter Hansen
refore Assembly is clearly the fastest development language. -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: Conditionally implementing __iter__ in new style classes

2005-07-06 Thread Peter Otten
def Iterator(self): yield 42 class Beta(Base): def __getitem__(self, index): return [1, 2, 3, "ganz viele"][index] for item in Alpha(): print item for item in Beta(): print item, print Peter -- http://mail.python.org/mailman/listinfo/python-list

from date/time string to seconds since epoch

2005-07-06 Thread Peter Kleiweg
MT' seconds = time.mktime(time.strptime(s, '%a, %d %b %Y %H:%M:%S %Z')) However, I also need conversions to localtime. Setting TZ to UTC before importing the time module won't let me do this. Changing TZ after importing time has no effect. -- Peter Kleiweg L:NL,af,da,de,en,

Re: from date/time string to seconds since epoch

2005-07-06 Thread Peter Kleiweg
00 > py> > > You can use time.time() to get the UTC time, then add the offset. The offset is for this moment, not for the date and time of the string parsed. -- Peter Kleiweg L:NL,af,da,de,en,ia,nds,no,sv,(fr,it) S:NL,de,en,(da,ia) info: http://www.let.rug.nl/~kleiweg/ls.html -- http://mail.python.org/mailman/listinfo/python-list

Re: Use cases for del

2005-07-07 Thread Peter Hansen
Duncan Booth wrote: > Peter Hansen wrote: >>Tom Anderson wrote: >>>How about just getting rid of del? >> >>Arguing the case for del: how would I, in doing automated testing, >>ensure that I've returned everything to a "clean" starting point in a

Re: Determining actual elapsed (wall-clock) time

2005-07-07 Thread Peter Hansen
occur once every week or two with an NTP client running. It certainly doesn't cause the one hour jumps forwards and backwards which I and the author of that page both thought it would. -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: threads and sleep?

2005-07-07 Thread Peter Hansen
Jonathan Ellis wrote: > Peter Hansen wrote: >>I can't address the issue of whether or not "most" such projects require >>distributed locking, because I'm not familiar with more than half of >>such projects, as you appear to be. > > Your sarcasm is c

Re: threads and sleep?

2005-07-07 Thread Peter Hansen
Grant Edwards wrote: > On 2005-07-06, Peter Hansen <[EMAIL PROTECTED]> wrote: >>Maybe you should consider and explain what you mean by >>"multiple interpreters"? > > That in a multi-theraded Python program, the code that > impliments the Python VM is

Re: Calculating average time

2005-07-08 Thread Peter Tillotson
have a look at the "timeit" module aswell GregM wrote: > Hi, > I'm hoping that someone can point me in the right direction with this. > What I would like to do is calculate the average time it takes to load > a page. I've been searching the net and reading lots but I haven't > found anything that

Re: Windows Cmd.exe Window

2005-07-08 Thread Peter Herndon
Giles, you keep mentioning syntax errors as the (/a) cause of the problem. I suggest you avoid such problems, so that the import sethook approach, et al. will actually work. The easiest thing to do is to run PyChecker on your script prior to executing it. PyChecker will catch your syntax errors

Re: can't start new thread

2005-07-08 Thread Peter Hansen
ript will run for a while before > throwing this error, but sometimes it throws it right away. Often posting the actual traceback, cut and pasted without editing, is highly effective at helping us provide a useful answer... -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: why UnboundLocalError?

2005-07-08 Thread Peter Hansen
ompiler thinks it must be a local, but you access it (as the error says) before it is assigned-to locally. "A" fix would be to use a different name locally, and if you really want it to reference the externally defined "fields", just do something like "lfields = fields" at the top of cutbits() (where "lfields" means "local fields", though you can pick any name you like). -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: removing list comprehensions in Python 3.0

2005-07-09 Thread Peter Hansen
2, 3] ?? No, the discussion is about list comprehensions. [1,2,3] is not a list comprehension, as you know. -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: pyo contains absolute paths

2005-07-09 Thread Peter Hansen
.) (Hint #2: maybe explaining why you don't want this to happen would help too, since that will probably determine the "best" solution.) -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: About undisclosed recipient

2005-07-09 Thread Peter Hansen
[EMAIL PROTECTED] wrote: > Hi all, Any one got idea about how to set undisclosed recipient? I put > all recipient in BCC field while the To field don't want to leave > blank. but neither fail to place an empty email address nor i don't > want to put my own email address inside. www.bartekrr.info J

Re: Should I use "if" or "try" (as a matter of speed)?

2005-07-09 Thread Peter Hansen
onsider first whether one or the other approach is clearly more expressive (for future programmers, including yourself) in the specific case involved. -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: already written optparse callback for range and list arguments?

2005-07-09 Thread Peter Hansen
rse > these as arguments? Doesn't that depend on what you plan to do with them? Do you want them as a special Range object, or a series of integers, or a list of tuples, or what? -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Forum

2005-07-10 Thread Peter Hansen
Devan L wrote: > I see a total of 12 posts and 8 users. Which at least makes it a record so far, surpassing every other "hey, i just made a new forum, it's awesome and everyone should join!" post that has been made here in the past, by about 9 posts and 5 users... ;-

Re: Newbie Alert! Upgrading Python?

2005-07-10 Thread Peter Hansen
- even though > 2.4 is backwards compatible. Python 2.4 is most definitely not 100% backwards compatible with Python 1.5.1, so "don't upgrade!" is correct advice if Python is in use by some application that expects it to be 1.5.1... -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: Defending Python

2005-07-10 Thread Peter Hansen
containing assertions about the predicates written in LSL, the Larch Shared Language common to all. "The Larch Family of Specification Languages", J. Guttag et al, IEEE Trans Soft Eng 2(5):24-365 (Sep 1985). "Larch: Languages and Tools for Formal Specification", Guttag and Hor

Re: Tricky Dictionary Question from newbie

2005-07-11 Thread Peter Hansen
tionary and bound to the second argument, and then that second argument is returned as the value. (I always have to ignore the name to think about how it works, or it gets in the way of my understanding it. The name makes fairly little sense to me.) -Peter -- http://mail.python.org/mailm

Re: tuple.index(item)

2005-07-11 Thread Peter Hansen
ge for past patches would give an answer, since it seems likely someone has already tried. -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: Searching through a list of tuples

2005-07-11 Thread Peter Hansen
ity function that does what you want (by using the first technique, if you wish), and then calling it will be as simple as lst.index() And no, since you are basically doing a form of pattern matching, I don't think there's a shortcut. -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: Searching through a list of tuples

2005-07-11 Thread Peter Otten
quot;, 20), (3, "c", 30)] >>> class Key(object): ... def __init__(self, key): ... self.key = key ... def __eq__(self, other): ... return self.key(other) ... >>> items.index(Key(lambda x: x[2] == 20)) 1 >>> items.index(Key(lambda x: x[1] == &qu

Re: automatically assigning names to indexes

2005-07-11 Thread Peter Otten
deas on how this might be done? >>> class Vector(tuple): ... x = property(lambda self: self[0]) ... y = property(lambda self: self[1]) ... z = property(lambda self: self[2]) ... >>> Vector("abc") ('a', 'b', 'c') >>> Ve

Re: Replacing last comma in 'C1, C2, C3' with 'and' so that it reads 'C1, C2 and C3'

2005-07-12 Thread Peter Otten
and".join("C1, C2, C3".rsplit(",", 1)) 'C1, C2 and C3' Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: Should I use "if" or "try" (as a matter of speed)?

2005-07-12 Thread Peter Hansen
ammers together, and it is the responsibility of both partners to encourage^H^H^H^H^H insist that the refactor "make it right" stage must occur _now_, before we check the code in. If you skip this step, you're failing to be an agile programmer, and your code base will become a tar p

Re: Tricky Dictionary Question from newbie

2005-07-12 Thread Peter Hansen
(Fixed top-posting) James Carroll wrote: > On 7/11/05, Peter Hansen <[EMAIL PROTECTED]> wrote: >>(I always have to ignore the name to think about how it works, or it >>gets in the way of my understanding it. The name makes fairly little >>sense to me.) >

Re: breaking out of nested loop

2005-07-12 Thread Peter Hansen
print "Collision!!!" > print make_string Set the flag here, then do the break: keepGoing = False > break Tada... -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: Why does reply to messages on this list put the sender in the To

2005-07-12 Thread Peter Decker
On 7/12/05, Dark Cowherd <[EMAIL PROTECTED]> wrote: > Most lists when i hit reply it puts the list address back in the To > address and some lists allow you to configure this. > > But in this list reply sends the mail back as a private mail and there > seems to be no option to configure this. >

Re: Software needed

2005-07-12 Thread Peter Herndon
"Document Management Software" is a little vague. What do you want it to do? In general though, when someone says "content management" and "Python", the general response is Zope, usually with Plone on top. -- http://mail.python.org/mailman/listinfo/python-list

Re: Frankenstring

2005-07-13 Thread Peter Otten
ot;") ... >>> f = StringIO("0123456789") >>> for c in chariter(f): ... print c ... if c == "2": break ... 0 1 2 >>> f.tell() 3 Performance is probably not so good, but if you really want to do it in C, with cStringIO you might be /almost/ there. Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: Building a function call?

2005-07-13 Thread Peter Hansen
als() returns "module level" stuff only when executed _at_ module level (i.e. not inside a function). Otherwise it will return only the local variables of the frame its in. Better is this, since it works for the OP's requirements in either situation. globals()['dothat&

Re: **kwargs?

2005-07-13 Thread Peter Hansen
kwargs and **x are somehow magically different? -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: Building a function call?

2005-07-13 Thread Peter Hansen
erally find that more readable than the one with globals(), and I don't offhand recall any serious criticism of globals() on grounds of either readability or style, so I'm unsure why anyone would prefer the alternative. -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: reg php equivalent move_uploaded file function in python

2005-07-13 Thread Peter Hansen
d be more effective in getting useful answers. (For example, what kind of server are you talking about?) -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: Frankenstring

2005-07-13 Thread Peter Otten
Thomas Lotze wrote: > Peter Otten wrote: > >>>>> class frankenstring(StringIO): >> ... def next(self): >> ... c = self.read(1) >> ... if not c: >> ... raise StopIteration >> ... retu

Re: Searching through a list of tuples

2005-07-13 Thread Peter Otten
Scott David Daniels wrote: > iter(elem in lst if elem[3] == x).next() > > Does this look any better?  At least it stops when the answer is found. Next time you'll recommend if (a>b) == True: # ... Watch out, you're on a slippery slope here :-) Peter -- http://m

<    21   22   23   24   25   26   27   28   29   30   >