Re: Why doesn't collections.Counter support a "key" argument in its constructor?

2020-09-12 Thread Peter Otten
Saurav Chirania wrote: > I really like that python's sort method accepts a key function as a > parameter which can be used to specify how elements should be compared. > > Similarly, we could have a "key" argument which specifies how elements > should be counted. Let's say we have a list of a mill

Re: ValueError: arrays must all be same length

2020-10-03 Thread Peter Pearson
On Fri, 2 Oct 2020 13:34:46 +0100, Shaozhong SHI wrote: > Hello, > > I got a json response from an API and tried to use pandas to put data into > a dataframe. > > However, I kept getting this ValueError: arrays must all be same length. > > Can anyone help? > > The following is the json text. Rega

Re: Truncation error

2020-10-07 Thread Peter Pearson
On Wed, 7 Oct 2020 13:29:26 +0530, Meghna Karkera wrote: > On Wed, Oct 7, 2020, 11:24 Marco Sulla wrote: >> On Wed, 7 Oct 2020 at 05:23, Meghna Karkera wrote: >> > >> > How is PYTHON better than other software's(MATLAB) in case of >> > truncation or rounding off error. > >> [snip] > > When I use

Python's carbon guilt

2020-10-10 Thread Peter Pearson
Python advocates might want to organize their thoughts on this subject before their bosses spring the suggestion: >From >https://www.sciencemag.org/news/2020/10/we-re-part-problem-astronomers-confront-their-role-and-vulnerability-climate-change > : . . . Astronomers should also abandon popul

Re: Problem saving datetime to file and reading it back for a calculation

2020-10-10 Thread Peter Pearson
On Sat, 10 Oct 2020 18:17:26 -0400, Steve wrote: > I would like to use the line: > HoursDiff = int((d2-d1).total_seconds()/3600) > to determine the difference in hours between two timedate entries. > > The variable d2 is from datetime.now() > and d1 is read from a text file. > > I can save d2 to t

Re: Best way to determine user's screensize?

2020-11-03 Thread Peter Pearson
On Sun, 1 Nov 2020 15:31:57 - (UTC), Grant Edwards wrote: > > I have no objection to saving the most recent window size and using > that on the next startup, but I hate applications that force the > _location_ of the window. I've configured my window manager to open > windows where I want them

Re: Is there a conflict of libraries here?

2020-11-06 Thread Peter Pearson
On Fri, 6 Nov 2020 02:25:25 -0500, Steve wrote: > In my program, I have the following lines of code: > import random > import re > import time > import datetime At this point, the name "datetime" points to a module. > from datetime import timedelta > from time import gmt

Re: returning totals in functions of math

2020-11-08 Thread Peter Pearson
On Sun, 8 Nov 2020 13:50:19 -0500, Quentin Bock wrote: > Errors say that add takes 1 positional argument but 3 were given? Does this > limit how many numbers I can have or do I need other variables? > Here is what I have: > def add(numbers): >total = 1 >for x in numbers: > total

Re: EnvironmentError

2020-11-20 Thread Peter Pearson
On Thu, 19 Nov 2020 13:19:07 +0100, Usman Musa wrote: > When I try to install a package or upgrade pip, using pip install I got > this error massage. > WARNING: Retrying (Retry(total=4, connect=None, read=None, > redirect=None, status=None)) after connection broken by > 'SSLError(SSLCertVeri

Problem running Pygame Zero

2020-12-21 Thread peter walker
same result). 3. Listing of the file I am running I have tried more than one version of Python and get the same results except on Python 3.9.0 and .1 when pygame won't even install. Please give me some help, I don't know how to proceed. Thanking you in advance. Peter Walker PS

Re: 2 sample chi-square test

2020-12-29 Thread Peter Pearson
On Tue, 29 Dec 2020 02:52:15 -0800 (PST), Priya Singh wrote: [snip] > I have two spectra with wavelength, flux, and error on flux. I want to > find out the variability of these two spectra based on the 2 sample > Chi-square test. I am using following code: > > def compute_chi2_var(file1,file2,zemi

Re: How to copy the entire outlook message content in python

2020-12-29 Thread Peter Pearson
On Tue, 29 Dec 2020 05:38:53 -0800 (PST), nikhil k wrote: ...[snip]... > import win32com.client as win32 > > ### Functions > def getMailBody(msgFile): > start_text = "" > end_text = "" > with open(msgFile) as f: > data=f.read() > return data[data.find(start_text):d

Re: Funny error message

2021-01-01 Thread Peter Otten
On 31/12/2020 23:46, Bob van der Poel wrote: When I run python from the command line and generate an error I get the following: Python 3.8.5 (default, Jul 28 2020, 12:59:40) [GCC 9.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. z /home/bob/.local/lib/pyth

Re: Tkinter menu item underline syntax [RESOLVED]

2021-01-07 Thread Peter Otten
On 06/01/2021 22:03, Rich Shepard wrote: On Thu, 7 Jan 2021, Chris Angelico wrote: Are you sure that this works? It's syntactically valid, but I don't think it means what you think it does. ChrisA, I'm always open to learning. There's no error generated ... yet the application doesn' open so

Re: Tkinter menu item underline syntax [RESOLVED]

2021-01-07 Thread Peter Otten
On 06/01/2021 22:03, Grant Edwards wrote: I'm completely baffled by that. Can somebody explain how this expression is evaluated? self.callbacks['file->new', underline: 0] It appears that the dict callbacks is being accessed with the key of a tuple comprising a string and a slice. Huh? Y

Re: Class and tkinter problem

2021-01-07 Thread Peter Otten
On 07/01/2021 08:42, Christian Gollwitzer wrote: Am 07.01.21 um 08:29 schrieb Paulo da Silva: Does anybody know why cmd method isn't called when I change the button state (clicking on it) in this example? I know that this seems a weird class use. But why doesn't it work? Thanks. class C:

Re: Wrapping classes

2005-09-22 Thread Peter Hansen
): if self.obj is None: self.obj = self.class_(*args, **kwargs) return self.obj.num num = property(_getnum) Now that "should" do precisely what you've asked for above, though it is obviously very limited in supporting only a single attribute name

Re: in-memory db? gadfly?

2005-09-22 Thread Peter Hansen
to more of SQLite's features. (Both appear to have been around roughly the same length of time, though pysqlite seems better known.) -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: Alternatives to Stackless Python?

2005-09-22 Thread Peter Hansen
tors, which means you can switch contexts only at the top level, with a yield statement? I don't know what the OP wants, but I could imagine that would be a pretty fundamental difference (if I'm right about Stackless). -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: Character Sequence Generation

2005-09-22 Thread Peter Otten
6: ... return re.compile("[%s]" % a_z).findall(all_chars) ... >>> for c in char_set("a-f0-9"): print c, ... 0 1 2 3 4 5 6 7 8 9 a b c d e f >>> for c in char_set("\s"): print repr(c), ... '\t' '\n' '\x0b' '\x0c' '\r' ' ' Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: idle

2005-09-23 Thread Peter Otten
TK wrote: >>>is there no IDLE in Python2.4? > What about with Suse 9.3 und Python 2.4? You have to install the python-idle package. Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: minidom appendChild confusion

2005-09-23 Thread Peter Otten
a = list("abcde") >>> for i in a: ... a.remove(i) ... >>> a ['b', 'd'] You can avoid that by making a copy of node1.childNodes: for el in list(node1.childNodes): node2.appendChild(el) > assert 2 == len(node2.childNodes), "node2 has an unexpected number of > children" Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: File processing

2005-09-23 Thread Peter Hansen
ode where you need to "parse" it and extract the values you can just do this: import config print 'Project Id is', config.PROJECT_ID -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: batch mkdir using a file list

2005-09-23 Thread Peter Otten
hat do I need to do to remove the "\n" from the file? line.strip() removes all leading and trailing whitespace (not just "\n") from the line string. import os for line in open("list.txt").readlines(): directory = line.strip() os.mkdir(directory) Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: Productivity and economics at software development

2005-09-23 Thread Peter Hansen
oach, especially as we are doing test-driven development. An IDE just gets in our way. If you focus on IDEs, your research will have pre-selected only certain kinds of programmers and teams, and will not necessarily include the best ones. (Looking at the VB world, one might even say something m

Re: Single type for __builtins__ in Py3.0

2005-09-23 Thread Peter Hansen
k way of finding the above docs, and while doing the same search with __builtins__ admittedly finds lots of mailing list archives where people have the same misconception as you did, it doesn't take one past the second page of results before you'll be right back at a post by Fredrik pointing out the same mistake. :-) -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: Single type for __builtins__ in Py3.0

2005-09-23 Thread Peter Hansen
oo many laws and that a few core ones already cover the majority of interesting situations for which the politicians are endlessly dreaming up more and more specific laws. So far this thread seems to me a parallel sort of situation...) -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: Can I compile Python for the web?

2005-09-23 Thread Peter Hansen
include "yes, sort of, using something like Psyco", and "who cares because it wouldn't give you much better performance for a web-based application where you're probably either I/O-bound or limited by the speed of the non-Python database solution you are using in the first place?". -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: Productivity and economics at software development

2005-09-23 Thread Peter Hansen
Paul Rubin wrote: > Peter Hansen <[EMAIL PROTECTED]> writes: >>If you focus on IDEs, your research will have pre-selected only >>certain kinds of programmers and teams, and will not necessarily >>include the best ones. > > It wouldn't have occurred to m

Re: parsing a date

2005-09-24 Thread Peter Hansen
than the two step > > w = strptime(d,'%Y-%m-%d') > datetime.date( w[0], w[1], w[2] ) > > Since I'm new to many things in Python I'm trying to learn if there is a > "better" way of doing things. You're still not defining what "better&quo

Re: parsing a date

2005-09-24 Thread Peter Hansen
e around is pretty "pythonic" too. (An alternative would be to contribute a patch to add something like this to the datetime module. I don't know if it would be accepted, but at least it would be the true arbiters of "pythonicism" who would be judging the matter, not you or I. :-) ) -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: Determine type of a socket

2005-09-26 Thread Peter Hansen
; dir(t) ['__class__', '_sock', 'accept', 'bind', 'close' , 'connect', 'connect_ex', 'dup', 'fileno', 'getpeername', ...'setblocking', 'setsockopt', 'settimeout', 'shutdown'] Let's see... what looks good here? >>> u._sock >>> t._sock Maybe that type field? -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: Determine type of a socket

2005-09-26 Thread Peter Hansen
Reinhold Birkenfeld wrote: > Peter Hansen wrote: >>Tor Erik Sønvisen wrote: >>>How can I determine the type of a socket (TCP or UDP) object? >>Let's see... what looks good here? >> >> >>> u._sock >> >> >>> t._sock >> &

Re: The ^ operator

2005-09-26 Thread Peter Hansen
irst digit in the result comes from the 0 and the 1 above it, in the two input values). -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: Carrying variables over from function to function

2005-09-27 Thread Peter Otten
mpiler treats it as local to that function. Closed-over variables are therefore always read-only, much to the chagrin of Lisp-lovers. Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: @staticmethod, backward compatibility?

2005-09-27 Thread Peter Hansen
staticmethod, how can I do this? It seems to me that no matter what you do, if it's not done with an external processing tool which requires no changes in the source code, the result will be much uglier than if you just used the pre-2.4 decorator syntax: def meth(): pass me

Re: Python 2.4 under WinXP, free VC71 toolkit and VC6 libraries

2005-09-27 Thread Peter Hansen
by a DLL. I'm not sure what you were thinking of, but it probably wasn't ctypes. -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: Overhead of individual python apps

2005-09-28 Thread Peter Hansen
other programs open which are very actively allocating or freeing memory. It does seem to back up the "~1.5MB" number above, and certainly shows that the total is nowhere near 4MB per Python interpreter. -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: import problems in packages

2005-09-28 Thread Peter Hansen
unexpected to me, though perhaps it can happen in certain situations. It's a hint, anyway. Are the earlier four lines which you did show us relevant? (i.e. if that's line six, what was on lines one, two, three, and four?) -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: import problems in packages

2005-09-28 Thread Peter Otten
kage/amodule.py apackage/anothermodule.py and try to import amodule into anothermodule, there is no way to tell Python that you mean amodule.py and not apackage/anmodule.py. Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: Rollover/wraparound time of time.clock() under win32?

2005-09-28 Thread Peter Hansen
t takes the full 64-bit value and divides by the frequency, returning a double. Whether or not that works for you only you can say.) -Peter -- http://mail.python.org/mailman/listinfo/python-list

A quick c.l.p netiquette question

2005-09-29 Thread Peter Corbett
I've written a program to illustrate a few... syntactic issues with Python. It's 158 <80 character lines long. About how short should a program be to be postable to this newsgroup - in other words, at what length should you stick it on a web page and post a link? Peter -- A fright

A rather unpythonic way of doing things

2005-09-29 Thread Peter Corbett
syntactic sugar that I could use, and this is the result: http://www.pick.ucam.org/~ptc24/yvfc.html Peter -- A frightful hobgoblin is stalking throughout Europe. - The Communist Manifesto, 1st English Edition -- http://mail.python.org/mailman/listinfo/python-list

Re: A quick c.l.p netiquette question

2005-09-29 Thread Peter Corbett
[EMAIL PROTECTED] writes: > > Peter> About how short should a program be to be postable to this > Peter> newsgroup - in other words, at what length should you stick it on > Peter> a web page and post a link? > > 158 lines is probably not a killer. However

Re: A quick c.l.p netiquette question

2005-09-29 Thread Peter Hansen
Peter Corbett wrote: > I've written a program to illustrate a few... syntactic issues with > Python. It's 158 <80 character lines long. > > About how short should a program be to be postable to this newsgroup - > in other words, at what length should you stick it on

Re: converting Word to MediaWiki

2005-09-29 Thread Peter Hansen
the two necessarily in conflict? Perl can save your butt and _still_ suck! ;-) ;-) -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: A rather unpythonic way of doing things

2005-09-29 Thread Peter Corbett
Richie Hindle <[EMAIL PROTECTED]> writes: > > [Peter] > > http://www.pick.ucam.org/~ptc24/yvfc.html > > [Jeff] > > Yuma Valley Agricultural Center? > > Yaak Valley Forest Council? > > I went through the same process. My guess is "Yes, Very F'

Re: A quick c.l.p netiquette question

2005-09-29 Thread Peter Hansen
Fredrik Lundh wrote: > Peter Hansen wrote: >>Does it really have to be 158 lines to demonstrate these few issues? I >>for one almost never take the time to dig through 158 lines of someone >>else's code, partly on the assumption that almost any interesting issue >

Re: Where to find python c-sources

2005-09-29 Thread Peter Hansen
http://www.google.com/search?q=python+socketmodule.c plus one additional click on "view" once you're there... -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: Help with syntax warnings

2005-09-29 Thread Peter Hansen
tch them and ignore them if that's what you wanted to do. But did you mean SyntaxError, or something else? -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: Help with syntax warnings

2005-09-30 Thread Peter Hansen
Robert Kern wrote: > Peter Hansen wrote: >>Not sure... what's a "syntax warning"? > > In [1]: SyntaxWarning? > Type: classobj > String Form:exceptions.SyntaxWarning > Namespace: Python builtin > Docstring: > Base class for

Re: RELEASED Python 2.4.2 (final)

2005-09-30 Thread Peter Hansen
someone did an "admin" install which (I believe) puts the DLLs in the system folder, and the next time did just a non-admin install which doesn't do that? (Or am I misunderstanding the conditions under which c:\windows\system32 has files written to it?) -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: A Moronicity of Guido van Rossum

2005-09-30 Thread Peter Hansen
the foul language words used by > Xah Lee ever occurs in any spam I receive - spam is not that stupid. "Xah Lee: stupider than spam." (?) -neologism-intentional-ly y'rs, Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: Moronicity Xha Lee, Jargonizer

2005-09-30 Thread Peter Hansen
lly from Steve Holden, too, which makes the civility doubly surprising. ;-) -revenge-is-sweet-ly y'rs, Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: Duplicating Modules

2005-09-30 Thread Peter Otten
ys >>> import module as a >>> del sys.modules["module"] >>> import module as b >>> b is a False Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: Help with syntax warnings

2005-10-01 Thread Peter Otten
variant: $ python2.4 -c 'import syntaxwarning' syntaxwarning.py:1: SyntaxWarning: name 'x' is assigned to before global declaration def f(): $ python2.4 syntaxwarning.pyc Method 2: switch off the warning: $ python2.4 -Wignore::SyntaxWarning syntaxwarning.py Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: what does 0 mean in MyApp(0)

2005-10-02 Thread Peter Hansen
body seems to know what the arguments are doing (sometimes they seem to be handed down from earlier generations), keyword arguments are a real blessing. The world needs more keyword arguments. Use them everywhere! ;-) -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: struct.unpack

2005-10-02 Thread Peter Otten
g.franzkowiak wrote: > tmpList = list(dataObject)[:4]) > obj = tmpList[0]+tmpList[1]+tmpList[2]+tmpList[3]. Have you tried just obj = dataObject[:4] without the intermediate list? If that failed, can you tell us the type of the dataObject? E. g. >>> print type(data

Re: struct.unpack

2005-10-03 Thread Peter Otten
dataObject) just to help me restore my peace of mind :-) Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem with slices.

2005-10-03 Thread Peter Otten
as keys > I have a problem with what is returned since None is > a valid key and thus it shouldn't be used this way. Consider new-style classes: >>> class T(object): ... def __getitem__(self, key): ... return key ... >>> t = T() >>> t[:4] slice(None, 4, None) >>> t[0:4] slice(0, 4, None) >>> t[0:] slice(0, None, None) Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: Reply-To header

2005-10-03 Thread Peter Decker
On 10/3/05, Roel Schroeven <[EMAIL PROTECTED]> wrote: > Indeed, and that's by design: http://www.unicom.com/pw/reply-to-harmful.html Of course, that's only one side of the argument: http://www.blackgate.net/consulting/reply-to_munging_useful.html On lists like this, where everyone benefits by s

Re: Reply-To header

2005-10-03 Thread Peter Decker
On 10/3/05, Roel Schroeven <[EMAIL PROTECTED]> wrote: > The default of this list is not to make conversations private; in fact > the list doesn't have any default. It's you who chooses to send replies > to the original author, to the list, or both, by choosing which button > to press in your mail

Re: Where to find python c-sources

2005-10-03 Thread Peter Hansen
27;t equate that with being dumb - just dumb luck :-) > > Message-ID: <[EMAIL PROTECTED]> > > After all Peter Hansen suggested the search terms "python socketmodule.c" > rather than just "socketmodule.c" > > Message-ID: <[EMAIL PROTECTED]> >

Re: New project coming up...stay with Python, or go with a dot net language??? Your thoughts please!

2005-10-04 Thread Peter Decker
On 10/3/05, spiffo <[EMAIL PROTECTED]> wrote: > I am a corporate developer, working for a single company. Got a new project > coming up and wondering if I should stay with Python for this new, fairly > large project, are jump back on the 'safe' M$ bandwagon using a dot net > language? Cross platfo

Re: Python profiler

2005-10-04 Thread Peter Tillotson
look in the gc module ... Celine & Dave wrote: > Hello All, > > I am trying to find a profiler that can measure the > memory usage in a Python program. I would like to > gather some statistics about object usages. For > example, I would like to be able to see how much time > it takes to search fo

Re: email module, redirecting to stdout

2005-10-04 Thread Peter Otten
like them to go to stdout. Using > > sys.stderr = sys.stdout > > has no effect. Redirecting stderr to stdout from the shell is not an > option for me, because I need to use stderr for other messages. smtplib obtains a copy of stderr by from sys import stderr Therefore yo

Re: email module, redirecting to stdout

2005-10-04 Thread Peter Otten
"smtplib").debug an approach which is currently only taken by the cookielib module. Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: how to keep collection of existing instances and return one on instantiation

2005-10-05 Thread Peter Otten
# will be called with instances from cache hits, too. print "init", x a = Spam('foo') b = Spam('foo') print a, b, a is b Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: How to prevent logging warning?

2005-10-05 Thread Peter Otten
a 'NULL' handler in the > library, but is this really how logging is intended to be used? I would support ...err, what's the opposite of a feature request? Anyway, another hack, slightly more lightweight/intrusive: logging.root.manager.emittedNoHandlerWarning = True Peter -

Re: how to keep collection of existing instances and return one on instantiation

2005-10-05 Thread Peter Otten
cache. Do I > have to implement my own garbage collecting is or there some "magical" > way of doing this within Python? I pretty much want to get rid of the > cache as soon as there are no other references (other than the cache). Use a weakref.WeakValueDictionary as the cache instead of a normal dict. Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: Class property (was: Class methods)

2005-10-06 Thread Peter Otten
@property ... def clsprp(cls): return 42 ... >>> A.clsprp 42 Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: Weighted "random" selection from list of lists

2005-10-08 Thread Peter Otten
for item in items: sigma += item yield sigma cumulated_weights = list(isum([60, 30, 10], 0)) sigma = cumulated_weights[-1] sample = [] for _ in xrange(sample_size): pool = pools[bisect.bisect(cumulated_weights, random.random()*sigma)] sample.append(random.choice(pool)) (all code untested) Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: searching a project to contribute to

2005-10-09 Thread Peter Decker
On 9 Oct 2005 18:16:32 -0700, Clint Norton <[EMAIL PROTECTED]> wrote: > Well, > I though about it but I'm looking for something a little more > interesting then bug fixing... > Anyway, wouldn't it be to difficult to get into a huge project like > python itself? Wouldn't it be a better idea to w

Python on the Power PC

2005-10-09 Thread Peter Milliken
can't find any tkinter module. Any ideas what I have done wrong anybody? Thanks Peter import Tkinter if __name__ == '__main__': root = Tkinter.Tk() root.title('Hello World?') root.mainloop() -- http://mail.python.org/mailman/listinfo/python-list

Re: __Classes and type tests

2005-10-10 Thread Peter Otten
gt;> def __init__(self): ... if type(self) == __Two: ... print "two leading underscores" ... >>> class __Two(object): ... __init__ = __init__ ... >>> __Two() two leading underscores <__main__.__Two object at 0x4029360c> Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: Send password over TCP connection

2005-10-10 Thread Peter Tillotson
simplest approach is to 1 way hash the password ... perhaps using md5 normally with passwords the server only has to check if it is the same word, assuming the same hash algorithms the same hash value can be created at client. Its not hugely secure ... anyone sniffing can grab your hash value a

Re: convert char to byte representation

2005-10-10 Thread Peter Otten
tes[i-1] > result = bytes.tostring() Seems like the OP doesn't need what he asked for. The simpler def checksum(s): assert s[0] == "$" assert s[-1] == "*" result = 0 for c in s[1:-1]: result ^= ord(c) return result should do. Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: Python on the Power PC

2005-10-10 Thread Peter Milliken
Fred's suggestion and run Python with command line arguments set. I seem to be limited to just running a .py file from the File Explorer. In the "Program Filess\Python\Lib" path there is a _tkinter file but it is a .pyd not a .dll. Peter "Steve Holden" <[EMAIL PROTEC

Re: how do you pronounce wxpython

2005-10-10 Thread Peter Hansen
Peter wrote: > Although the wxPyWiki seems to be pronounced wix-pee-wi-kee (as it says > on the front page) so maybe it is pronounced wix-Python... you never > know... That's _definitely_ how it's pronounced. Here. Where I am. When I'm speaking. If, however, we&#

Re: Python's Performance

2005-10-10 Thread Peter Hansen
html > > maybe someone could update that??? Maybe we should add '''...for some definitions of "interpreted", "object-oriented", and perhaps even "interactive". ''' I've seen at least the first two debated endlessly here. -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: Python reliability

2005-10-10 Thread Peter Hansen
ing test-driven development and had effectively thousands of hours of run-time by the time the first system shipped, so we had great confidence in it. -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: Send password over TCP connection

2005-10-10 Thread Peter Hansen
ors should not have access to user passwords, and in addition users should not be put in the position of having to trust your server-side security to keep their passwords (which they might have used on other systems) from being grabbed by hackers. -Peter -- http://mail.python.org/mailman/list

Re: Library functions

2005-10-10 Thread Peter Hansen
asking questions which are almost certainly covered there. For example, right there near the top of the first screen in the tutorial is an example of opening a Linux .so file... -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: Why asci-only symbols?

2005-10-10 Thread Peter Hansen
nd the time Python was first released. And I can't really imagine a non-ugly alternative, which probably reveals something bad about my imagination.) -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: [Info] PEP 308 accepted - new conditional expressions

2005-10-10 Thread Peter Hansen
ement (so "this" could _not_ be accomplished with what you showed). -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: Looking for info on Python's memory allocation

2005-10-11 Thread Peter Otten
x27;iterable=range(1000)' 's = [0]*len(iterable)' 'for i, v in enumerate(iterable): s[i] = v' 1000 loops, best of 3: 269 usec per loop ~ $ python2.4 -m timeit -s'iterable=range(1000)' 'list(iterable)' 10 loops, best of 3: 7.33 usec per loop Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: Python's Performance

2005-10-11 Thread Peter Hansen
-) But I'm also not sure I ought to post that to the group, so I'll spare them and just inflict the thought on you! Cheers, -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: Send password over TCP connection

2005-10-11 Thread Peter Hansen
Laszlo Zsolt Nagy wrote: > Peter Hansen wrote: >> Ignoring all the other issues, any solution which actually requires >> the password to be stored on the server is a bad solution. >> Administrators should not have access to user passwords, and in >> addition use

Re: Python's Performance

2005-10-11 Thread Peter Hansen
Peter Hansen wrote: > But I'm also not sure I ought to post that to the group, so I'll spare > them and just inflict the thought on you! Or, maybe I'll just fail to trim the newsgroup line and accidentally post to the group anyway. Yes, that's just what I'l

Re: Very dumb question

2005-10-12 Thread Peter Otten
' ('\r') overwrites part of the string which therefore doesn't seem to grow. Try print repr(data[:51]) to see what's really in your data string. Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: can we save print msg into a file when script running ?

2005-10-12 Thread Peter Otten
u don't feel comfortable with the command line you can stick import sys sys.stdout = open("mylogfile.txt", "w") at the beginning of your file. Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: [Info] PEP 308 accepted - new conditional expressions

2005-10-12 Thread Peter Hansen
y mind is far more important than either result) comes hidden in the middle: "C then A else B" makes the conditional stand out "A if C else B" suggests that A is more important than B and hides C But I can live with whichever it is... not that I have any choice. :) -P

Re: Python reliability

2005-10-12 Thread Peter Hansen
so it wasn't stresed during > high-volume times. The two systems (one for redundancy) that run the > Python program have been running for six years. Six years? With no downtime at all for the server? That's a lot of "9s" of reliability... Must still be using Py

Re: Send password over TCP connection

2005-10-12 Thread Peter Hansen
t introduce the concept of "salt", one of the "additional things" I mentioned above. I'm not going to try to give a tutorial: I'm not nearly expert enough to be trusted for that. :-) I just wanted to warn against one of the most basic and easily avoidable problems. -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: slots? SLOTS?

2005-10-12 Thread Peter Hansen
tin gherdanarra wrote: > what is a "slot" in python? Google for "site:docs.python.org slots": http://www.google.ca/search?q=site%3Adocs.python.org+slots First hit... -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: Bad magic no. in python zipfile

2005-10-12 Thread Peter Hansen
rying to use a .pyc module, created with one > Python version, using another Python version. But in this case, I > created the zip file under Python 2.4.2 and tried to open it under > Python 2.4.2 as well. Any ideas on what to do? Maybe try posting the full traceback so we can see the "Ba

Re: Setdefault bypasses __setitem__

2005-10-13 Thread Peter Otten
rms of __set/getitem__() as def setdefault(self, key, value=None): try: return self[key] except KeyError: self[key] = value return self[key] I guess it's not done for performance reasons. Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: Setdefault bypasses __setitem__

2005-10-13 Thread Peter Otten
t()? setdefault(...) D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D There is no per-instance default value just on per call: >>> d = {} >>> d.setdefault("a", 1) 1 >>> d.setdefault("a", 42) 1 I'm sure there is a misunderstanding in our conversation, I'm just not able to nail it... Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: Well written open source Python apps

2005-10-13 Thread Peter Hansen
as being exceptionally well commented and well structured. I suspect it's pretty Pythonic, too, since Roger seems pretty brilliant from where I sit. :-) -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: 1-liner to iterate over infinite sequence of integers?

2005-10-13 Thread Peter Hansen
that shouldn't win any readability awards... -Peter -- http://mail.python.org/mailman/listinfo/python-list

<    15   16   17   18   19   20   21   22   23   24   >