Looking for people to take over some packages
I'm shifting life gears, trying to get away from the computer more during my hours away from work. As part of that, I'm looking to get out of the package authorship/maintenance business. Currently, I am officially listed as the "maintainer" (I use that term loosely - I really do very little at this time) of the following packages on PyPI (http://pypi.python.org/): bsddb185 lockfile spambayes tb Some time ago Ben Finney offered to take over lockfile. He doesn't want to horse around with Google Code and I don't want to learn how to use git/github just to make the existing code available to him. Perhaps someone with both Google Code and Github accounts can facilitate the exchange. Taking over the SpamBayes package probably implies a committment to greater involvement in the SpamBayes project (so be careful before you volunteer). It's worth poking around http://www.spambayes.org/. Bsddb185 is just a repackaging of the old bsddb185 module which got dropped from the Python core some years ago. It probably gets very little use, but last I looked, there were still some systems which used that versy of Berkeley DB. Tb provides a couple alternate traceback formatting functions. The compact_traceback function is an adaptation of the one generated by asyncore. The verbose_traceback function includes local variable values in the trace. If you have any interest in helping with any of these, let me know. -- Skip Montanaro - [email protected] - http://www.smontanaro.net/ -- http://mail.python.org/mailman/listinfo/python-list
Do you monitor your Python packages in inux distributions?
I'm one of the SpamBayes developers and in a half-assed way try to keep track of SB dribbles on the net via a saved Google search. About a month ago I got a hit on an Ubuntu bug tracker about a SpamBayes bug. As it turns out, Ubuntu distributes an outdated (read: no longer maintained) version of SpamBayes. The bug had been fixed over three years ago in the current version. Had I known this I could probably have saved them some trouble, at least by suggesting that they upgrade. I have a question for you people who develop and maintain Python-based packages. How closely, if at all, do you monitor the bug trackers of Linux distributions (or Linux-like packaging systems like MacPorts) for activity related to your packages? How do you encourage such projects to push bug reports and/or fixes upstream to you? What tools are out there to discover which Linux distributions have SpamBayes packages? (I know about rpmfind.net, but there must be other similar sites by now.) Thx, -- Skip Montanaro - [email protected] - http://www.smontanaro.net/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Sniffing Text Files
David> I realize CSV module has a sniffer but it is something that is David> limited more or less to delimited files. Sure. How about: def sniff(fname): if open(fname).read(4) == "http://www.musi-cal.com/katrina [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Find out if host is alive
Eyual> What is the fastest way to find out a host is alive should i make Eyual> a sys call and ping or is thier an easier way What is the fastest Eyual> way to find out a host is alive should i make a sys call and ping Eyual> or is thier an easier way Depends on the meaning of "host is alive". If that means "up and available to do something for me", try connecting to the port of interest using the socket module. -- Skip Montanaro Katrina Benefit Concerts: http://www.musi-cal.com/katrina [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: 1 Million users.. I can't Scale!!
Damjan> Is there some python module that provides a multi process Queue? Not as cleanly encapsulated as Queue, but writing a class that does that shouldn't be all that difficult using a socket and the pickle module. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: 1 Million users.. I can't Scale!!
Damjan> Is there some python module that provides a multi process Queue?
Skip> Not as cleanly encapsulated as Queue, but writing a class that
Skip> does that shouldn't be all that difficult using a socket and the
Skip> pickle module.
Jeremy> What about bsddb? The example code below creates a multiprocess
Jeremy> queue.
I tend to think "multiple computers" when someone says "multi-process". I
realize that's not always the case, but I think you need to consider that
case (it's the only practical way for a multi-process application to scale
beyond a few processors).
Skip
--
http://mail.python.org/mailman/listinfo/python-list
Re: 1 Million users.. I can't Scale!!
Damjan> Is there some python module that provides a multi process Queue?
Skip> Not as cleanly encapsulated as Queue, but writing a class that
Skip> does that shouldn't be all that difficult using a socket and the
Skip> pickle module.
Here's a trivial implementation of a pair of blocking queue classes:
http://orca.mojam.com/~skip/python/SocketQueue.py
Skip
--
http://mail.python.org/mailman/listinfo/python-list
Re: 1 Million users.. I can't Scale!!
Jeff> How many are more than "a few?" I don't know. What can you do today in commercial stuff, 16 processors? How many cores per die, two? Four? We're still talking < 100 processors with access to the same chunk of memory. For the OP's problem that's still 10,000 users per processor. Maybe that's small enough, but if not, he'll need multiple processes across machines that don't share memory. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: byte code generated under linux ==> bad magic number under
Fredrik> byte code is portable between platforms, but it's not portable Fredrik> between different major Python releases (2.4.2 can run 2.4.1 Fredrik> bytecodes, but not 2.3 bytecodes, etc). There is one slight problem with transporting .pyc files. The generated .pyc file records the absolute path to the .py file from which it was generated. If it is moved to a different filesystem -- even if the .py file goes along for the ride -- tracebacks display an incorrect path and fail to display the corresponding source line. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: A quick c.l.p netiquette question
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, consider what misbehaving news and mail readers are likely to do to the indentation of your script before embedding it in a message. The net being the somewhat less safe place than it used to be, many people may be hesitant to open attachments either. It might well be safer to simply toss it on a personal website and provide a link. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Will python never intend to support private, protected and public?
>> **Encapsulation** is one of the 3 basic characteristics of OOP. This isn't an encapsulation issue. From the first hit on Google for the word: In programming, the process of combining elements to create a new entity. For example, a procedure is a type of encapsulation because it combines a series of computer instructions. Likewise, a complex data type, such as a record or class, relies on encapsulation. Object- oriented programming languages rely heavily on encapsulation to create high-level objects. Encapsulation is closely related to abstraction and information hiding. Python does encapsulation just fine. Your beef is with its information hiding. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Will python never intend to support private, protected and public?
Greg> Does anyone know of academic papers that make the case against Greg> "private" in languages? Nope. I'd be interested in seeing academic papers that make the case (with data to back up the claims) that "private" is beneficial. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: python plotting with greek symbols within labels recommendations?
mike> thus far, i've found that matplotlib mike> (http://matplotlib.sourceforge.net/) can do this, albeit the mike> implementation is so poor that you cannot mix standard text with mike> symbols on the same plot element. That seems a bit harsh. Have you asked on the matplotlib mailing list to see if it can do what you want? Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: bug or feature?
beza1e1> class A: beza1e1>def __init__(self, lst=[]): beza1e1> self.lst = lst Lists are mutable and default args are only evaluated once, at function definition. If you want independent default args use: class A: def __init__(self, lst=None): if lst is None: lst = [] self.lst = lst The same scheme would work for other mutable types (dicts, sets, etc). This same question gets asked once a month or so. I'm sure this is in the Python FAQ (check the website), but it was faster to reply than to look it up... Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Force flushing buffers
Madhusudan> How do I flush the buffer and force python to write the
Madhusudan> buffers to the files ? I intend to put this inside the loop.
f = open("somefile", "w")
f.write("foo")
f.flush()
Skip
--
http://mail.python.org/mailman/listinfo/python-list
Re: Default argument to __init__
vaibhav> Here's a piece of Python code and it's output. The output that vaibhav> Python shows is not as per my expectation. Hope someone can vaibhav> explain to me this behaviour: ... Yes, your default arg is evaluated once, at method definition time and shared betwee all instances of MyClass. See the thread last week on the same thing for more detail. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Python's garbage collection was Re: Python reliability
Diez> AFAIK some LISPs do a similar trick to carry int values on Diez> cons-cells. And by this tehy reduce integer precision to 28 bit Diez> or something. Surely _not_ going to pass a regression test suite Diez> :) I'm pretty sure this was tried a few years ago w/ Python. I don't recall the results, but I'm pretty sure they weren't good enough. had they been we could just look at the source. Folks, most common GC schemes have been tried as experiments over the years. None have succeeeded, for various reasons. I think one of the main reasons is that Python has to "play nice" with external libraries, many of which weren't written with GC beyond malloc and free in mind. Here are some pointers interested readers might want to check out: Tagged integers: http://mail.python.org/pipermail/python-dev/2004-July/046139.html Boehm GC: http://mail.python.org/pipermail/python-dev/2005-January/051370.html http://www.python.org/doc/faq/general.html#how-does-python-manage-memory http://wiki.python.org/moin/CodingProjectIdeas/PythonGarbageCollected Miscellaneous: http://mail.python.org/pipermail/python-dev/2002-June/026032.html http://mail.python.org/pipermail/python-dev/2003-November/040299.html And lest anyone here think they were the first to suggest getting rid of reference counting in Python: http://www.python.org/search/hypermail/python-1993/0554.html I wouldn't be surprised if there were even earlier suggestions... Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: dis.dis question
>> I'm still looking for info on how to use disassemble_string(). How about this? >>> import dis >>> def f(): ... print "hello world" ... >>> f.func_code.co_code 'd\x01\x00GHd\x00\x00S' >>> dis.disassemble_string(f.func_code.co_code) 0 LOAD_CONST 1 (1) 3 PRINT_ITEM 4 PRINT_NEWLINE 5 LOAD_CONST 0 (0) 8 RETURN_VALUE Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: List of strings to list of floats ?
Madhusudan> Is it possible to convert a very long list of strings to a Madhusudan> list of floats in a single statement ? Madhusudan> I have tried float(x) and float(x[:]) but neither work. I Madhusudan> guess I would have to write a loop if there isn't a way. Try: >>> los = ["123.0", "2", "1e-6"] >>> map(float, los) [123.0, 2.0, 9.9995e-07] >>> [float(s) for s in los] [123.0, 2.0, 9.9995e-07] Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: python and outlook
dt> Are there any links or sites on how to read outlook mail boxes or dt> address book? Check the Outlook plugin code in SpamBayes <http://www.spambayes.org/>. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Syntax across languages
Alex> I've seen enough occurrences of "lambda x: x" in Python code with Alex> a generally functional style that I'd love to have Alex> operator.identity (and a few more trivial functions like that) for Alex> readability;-) But, but, but [Skip gets momentarily apoplectic, then recovers...] "operator.identity" is way more to type than "lambda x: x". Plus you have to remember to import the operator module. <0.5 wink> Not to mention which (from "pydoc operator"): [The operator module] exports a set of functions implemented in C corresponding to the intrinsic operators of Python. Last time I checked, Python didn't have an intrinsic "identity" operator. For which reason, I'd be -1 on the idea of an identity function, certainly in the operator module. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: more than 100 capturing groups in a regex
Joerg> Or is there a way to circumvent [capturing groups limitation]? Sure, submit a patch to SourceForge that removes the restriction. I've never come anywhere close to creating regular expressions that need to capture 100 groups even though I generate regular expressions from a higher-level representation. I suspect few will have hit that limit. Perhaps explain what motivates you to want to capture that many groups. Other people may be able to suggest alternatives. And remember: Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems. --Jamie Zawinski Skip -- http://mail.python.org/mailman/listinfo/python-list
RE: Windows vs Linux [was: p2exe using wine/cxoffice]
Tim> I am quite well aware of all of the ways you mention of recalling Tim> history etc. etc. When I've tried using them, they all seem Tim> tiresomely cumbersome ... That's not at all surprising (at least not to me). An important point to realize is that readline's command recall is by default switchable between Emacs-like key bindings and VI-like key bindings. (If you're familiar with readline's configuration file, I suspect you can make it resemble other editors as well.) If you're unfamiliar with either vi or Emacs, you're likely to find either mode combersome. For someone who regularly uses one or the other, they are quite natural. I speak as someone who has used Emacs of one variety or another for over 20 years. For me, readline's key bindings "just work". Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 2.3.4, Berkeley db 1.85, db file format not recognized
Dan> import bsddb
Dan> bsddb.hashopen("access.db")
Dan> but I get:
Dan> bsddb._db.DBInvalidArgError: (22, 'Invalid argument -- access.db:
unexpected file type or format')
Dan> Any suggestions on how to read this file?
See if the bsddb185 module is available:
% python
Python 2.5a0 (#94, Oct 8 2005, 06:49:04)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1671)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
impo>>> import bsddb
>>> import bsddb185
>>> dir(bsddb185)
['__doc__', '__file__', '__name__', 'btopen', 'error', 'hashopen', 'open',
'rnopen']
>>> dir(bsddb)
['UserDict', '_DBWithCursor', '__builtins__', '__doc__', '__file__',
'__name__', '__path__', '__version__', '_bsddb', '_checkflag', '_db',
'_iter_mixin', '_openDBEnv', 'btopen', 'db', 'error', 'hashopen', 'os',
'ref', 'rnopen', 'sys']
If the old libdb.a stuff is available, the bsddb185 module should have been
built automagically.
Skip
--
http://mail.python.org/mailman/listinfo/python-list
Re: more than 100 capturing groups in a regex
DH> It's a conflict between python's syntax for regex back references DH> and octal number literals. Probably wasn't noticed until way too DH> late, and now it will never change. I suspect it comes from Perl, since Python's regular expression engine tries pretty hard to be compatible with Perl's, at least for the basics. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: How to replace all None values with the string "Null" in a dictionary
Daniel> How can I replace all None values with the string 'Null' in a
Daniel> dictionary?
a = {'item1': 45, 'item2': None}
for key in a:
if a[key] is None:
a[key] = "Null"
Skip
--
http://mail.python.org/mailman/listinfo/python-list
Re: append to non-existing list
Yves> My question is: Is there no way to append to a non existing list? My question in return is: How is Python supposed to know that pkcolumns is supposed to be a list instead of some other type of object that happens to define an append() method? For example, my code might contain this class definition before the suspect pkcolumns.append() call: class MaxLengthList: def __init__(self, maxsize=0): self.data = [] self.maxsize = maxsize def append(self, item): if self.maxsize and len(self.data) == self.maxsize: del self.data[0] self.data.append(item) def __getattr__(self, attr): return getattr(self.data, attr) I think it would be perfectly reasonable for Python to choose to instantiate my MaxLengthList instead of a plain old list. Yves> I am lazy for declaring it first, IMHO it bloats the code, and Yves> (don't know if it's good to say that here) where I come from (php) Yves> I was used to not-needing it... I don't know php, but would also have to wonder how it knows to create a list instead of an integer (for example). Finally, from the Zen of Python (try "import this" at an interpreter prompt): In the face of ambiguity, refuse the temptation to guess. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Python obfuscation
Steven> But as a general rule, you're right. If you, the developer, Steven> don't have to think of your users as the enemy, you'd be amazed Steven> the amount of make-work you don't have to do. +1 QOTW. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Printing current time to a file
zolaris> self.log.write(time.ctime(time.time())) zolaris> But that prints nothing in the file assigned to log. Is there zolaris> something I should be doing extra? There's no newline in there. You probably need to flush the file: self.log.write(time.ctime(time.time())) self.log.flush() You might want to write a newline after the time as well. If the logfile is line-buffered that will also provoke a flush. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: modify dictionary while iterating
>> I wish to pop/del some items out of dictionary while iterating over
>> it.
Ben> Iterate over a copy.
Ben> a_orig = { 'a': 1, 'b': 2 }
Ben> a = dict(a_orig)
Ben> for k, v in a_orig.iteritems():
Ben> if v == 2:
Ben> del a[k]
Or iterate over just a copy of the keys:
for k in a_orig.keys():
if a_orig[k] == 2:
del a_orig[k]
Skip
--
http://mail.python.org/mailman/listinfo/python-list
Re: output buffering
jd> When reading a large datafile, I want to print a '.' to show the
jd> progress. This fails, I get the series of '.'s after the data has
jd> been read. Is there a trick to fix this?
As Fredrik indicated, you need to flush the output buffer. You might also
want to check out the progress module available from my Python Bits page:
http://orca.mojam.com/~skip/python/
Skip
--
http://mail.python.org/mailman/listinfo/python-list
elementtree.ElemenTree barfs on my Safari Cookies file
Safari stores its cookies in XML format. Looking to try and add support for
it to cookielib I started by first trying to parse it with Fredrik Lundh's
elementtree package. It complained about an invalid token. Looking at the
spot it indicated in the file, I found a non-ASCII, but (as far as I can
tell) perfectly valid utf-8 string.
I whittled the plist file down to what I've attached. With it I get
>>> e = elementtree.ElementTree.parse("Cookies.plist")
Traceback (most recent call last):
File "", line 1, in ?
File
"/Users/skip/local/lib/python2.5/site-packages/elementtree/ElementTree.py",
line 864, in parse
tree.parse(source, parser)
File
"/Users/skip/local/lib/python2.5/site-packages/elementtree/ElementTree.py",
line 588, in parse
parser.feed(data)
File
"/Users/skip/local/lib/python2.5/site-packages/elementtree/ElementTree.py",
line 1132, in feed
self._parser.Parse(data, 0)
xml.parsers.expat.ExpatError: not well-formed (invalid token): line 17,
column 12
I had no trouble decoding that string as unicode. Any ideas what's wrong?
Thx,
Skip
binfeFbX4goN0.bin
Description: Binary data
--
http://mail.python.org/mailman/listinfo/python-list
Re: elementtree.ElemenTree barfs on my Safari Cookies file
skip> I had no trouble decoding that string as unicode. *sigh* I need some new proofreading glasses. Should be "... string as utf-8". S -- http://mail.python.org/mailman/listinfo/python-list
Re: elementtree.ElemenTree barfs on my Safari Cookies file
Fredrik> that apple's tools are able to generate bogus XML is a known Fredrik> problem; for a discussion and some workarounds, see the "Status Fredrik> of XML 1.1 processing in Python" over at the xml-sig mailing Fredrik> list: Fredrik> http://aspn.activestate.com/ASPN/Mail/Message/xml-sig/2792071 Thanks much. Your SgmlopXMLTreeBuilder module came to the rescue. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: It looks like my mails to @python.org are all blocked
Thomas> What's wrong with this? The python-anounce tells me that my Thomas> message has a suspicious header? Nothing wrong. Just flagged by the spam filters as undecidable. A human moderator will review it. Skip -- http://mail.python.org/mailman/listinfo/python-list
Current execution frame of another thread?
I would like to try a sampling approach to profiling. My thought is to have a profiling thread that samples the execution frame of all the other started threads. I don't see any path from the threads returned by threading.enumerate() to their current frames. Am I missing something? Thx, Skip -- http://mail.python.org/mailman/listinfo/python-list
test_locale & test_pty fail for 2.4 SVN on Solaris 8/10
We are getting a couple test failures at work when building Python 2.4.2 or the 2.4 Subversion branch on Solaris 8 and Solaris 10 (both on PC hardware). test_pty fails and test_locale is unexpectedly skipped. The locale environment is LC_ALL=C LC_CTYPE=iso_8859_1 I also tried test_locale with no LC_* environment variables set. Should my LC_* settings be different? Can anyone else confirm these problems? Thx, Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Choose meaningful subjects for posts [was: Re: newb ?]
Grant> Obligatory aside: I'm completely baffled why anybody would choose Grant> the mailing list format over Usenet. I don't even read mailing Grant> lists via mailing lists. I recommend gmane.org's NNTP server for Grant> all your mailing list needs. For the same reason I don't like web forums as a means of communication. I would much rather operate in an interrupt-driven mode than have to remember to poll some external service to get my daily helping of information. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Choose meaningful subjects for posts [was: Re: newb ?]
Grant> If I allowed news posts to interrupt me, I'd never get anything Grant> done. I limit e-mail to things that really do require fairly Grant> immediate attention. Well, I do try to limit the number of things I pay attention to. However, as the "Python guy" at work, participating in this group and the python-dev mailing list overlap my daytime duties. There are a few other things I watch as well (matplotlib, pygtk, moin, scipy, etc). Running through all of them in one place simplifies my life. Last time I checked, most of Usenet was crap (overrun with spam), so on those few occasions where I need something I just use Google to search for help and post via Google or Gmane. I never have to worry about NNTP. I have no idea if my ISP (Comcast) even provides NNTP access. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: ignore specific data
pkilambi> I would like to ignore a block of lines and consider the
pkilambi> rest.. so if the block starts with
pkilambi> "start of block."
pkilambi> fjesdgsdhfgdlgjklfjdgkd
pkilambi> jhcsdfskdlgjkljgkfdjkgj
pkilambi> "end of block"
pkilambi> I want to ignore this while processing the file .This block
pkilambi> could appear anywhere in the file.It could at the start or end
pkilambi> or even middle of file content.
How about (untested):
class FilterBlock:
def __init__(self, f, start, end):
self.f = f
self.start = start
self.end = end
def __iter__(self):
return self
def next(self):
line = self.f.next()
if line == self.start:
line = self.f.next()
while line != self.end:
line = self.f.next()
return line
Then use it like
filterfile = FilterBlock(open("somefile", "r"),
"start of block..",
"end of block")
for line in filterfile:
process(line)
I'm not sure what you mean by all the dots in your start of block line. If
"start of block" can be followed by other text, just use
if line.startswith(self.start):
instead of an exact comparison.
Skip
--
http://mail.python.org/mailman/listinfo/python-list
Re: bsddb185 question
thakadu> It seems it doesnt implement ALL of the dictionary interface
thakadu> though. dir({}) yields many more methods than
thakadu> dir(bsddb185.open(f)). So bsddb185 is missing many of the
thakadu> methods that I am used to in bsddb. I mentioned some above that
thakadu> are missing, pop() in particular would be useful in my
thakadu> situation but there are others as well. From a java
thakadu> perspective I believe that its not possible to omit certain
thakadu> methods when implementing an interface, I am not sure about
thakadu> Python though.
The bsddb185 module is only there as a "rescue" module so that you can work
with old 1.85 files. You should never use it for new development, as the
1.85 version of Berkeley DB has known bugs that are only fixed in later
versions. As you noticed, those later versions will not read or write v1.85
files. Since the bsddb185 module is only there for compatibility and
emergencies, no new functionality is planned for it.
Skip
--
http://mail.python.org/mailman/listinfo/python-list
Re: bsddb185 question
thakadu> Ok but if you read my original post I already said that! Sure, I did. I was recapping what the purpose of the bsddb185 module is and why its API is not likely to change. thadaku> The issue is that I have an application that needs to share thakadu> data with an existing Berekeley db 1.85 database and thakadu> applications in perl. Sure if I was creating the database thakadu> myself I would use the newer bsddbmodule but I can't require thakadu> the perl code be rewritten, so is there any way in Python to thakadu> read and write to a legacy 1.85 Berkely db? Yup. Use the bsddb185 module and suffer with the older API. Note that part of the reason the API it exposes is so feeble is that the underlying 1.85 Berkeley DB library doesn't provide anything better. The API you've become used to with the later bsddb module is only available because the underlying library API is more complete. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Death to tuples!
Mike> Tuples have the problem that they are immutable, except when Mike> they're not (or for proper values of immutable, your Mike> choice). They're hashable, except when they're not. Or Mike> equivalently, they can be used as dictionary keys - or set Mike> elements - except when they can't. For those of us not following this thread closely, can you identify cases where tuples are mutable, not hashable or can't be used as dictionary keys? I've never encountered any such cases. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Death to tuples!
>>> For those of us not following this thread closely, can you identify >>> cases where tuples are mutable, not hashable or can't be used as >>> dictionary keys? I've never encountered any such cases. >> >> t = ([1,2], [3,4]) ... >>>> t = ([1,2], [3,4]) >>>> t[0] += [5] aahz> Traceback (most recent call last): aahz> File "", line 1, in ? aahz> TypeError: object doesn't support item assignment >>>> t aahz> ([1, 2, 5], [3, 4]) aahz> (I'm pretty sure Skip has seen this before, but I figure it's a aahz> good reminder.) Actually, no, I hadn't. I don't use tuples that way. It's rare when I have a tuple whose elements are not all floats, strings or ints, and I never put mutable containers in them. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Death to tuples!
>> Actually, no, I hadn't. I don't use tuples that way. It's rare when >> I have a tuple whose elements are not all floats, strings or ints, >> and I never put mutable containers in them. Alex> You never have a dict whose values are lists? Sorry, incomplete explanation. I never create tuples which contain mutable containers, so I never have the "can't use 'em as dict keys" and related problems. My approach to use of tuples pretty much matches Guido's intent I think: small, immutable, record-like things. immutable-all-the-way-down-ly, y'rs, Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: cheese shop registration error
>> smtplib.SMTPRecipientsRefused: {u'tgreenwoodgeer.yahoo.com': (550,
>> ': Recipient address rejected: User unknown
>> in local recipient table')}
richard> The error displayed here is complaining about the email address
richard> you supplied, 'tgreenwoodgeer.yahoo.com'. This is different
richard> from the session details you have supplied. I can't reconcile
richard> these. I suggest you try again, and be careful when typing your
richard> email address.
Just a wild-ass guess, but should the recipient should have been
'[EMAIL PROTECTED]'?
Skip
--
http://mail.python.org/mailman/listinfo/python-list
Re: FW: Python Query: How to i share variable between two processes without IPC.
Mukesh> Question: how do i share variable between two processes without
Mukesh> IPC.
...
Mukesh> A similar thing is available in perl (check the mail attached).
What makes you think the Perl code isn't using IPC?
use IPC::Shareable;
$handle = tie $buffer, 'IPC::Shareable', undef, { destroy => 1 };
Sure looks like IPC to me. From the README:
IPC::Shareable allows you to tie a variable to shared memory making it
easy to share the contents of that variable with other Perl processes.
Scalars, arrays, and hashes can be tied. The variable being tied may
contain arbitrarily complex data structures - including references to
arrays, hashes of hashes, etc.
That the variable $buffer uses Perl's tie mechanism to hide most of the
details doesn't make it not shared memory.
You might check out pyro:
http://pyro.sourceforge.net/
It's not based on shared memory, but will also work across networks.
Skip
--
http://mail.python.org/mailman/listinfo/python-list
Re: Detect character encoding
Martin> I read or heard (can't remember the origin) that MS IE has a Martin> quite good implementation of guessing the language en character Martin> encoding of web pages when there not or falsely specified. Gee, that's nice. Too bad the source isn't available... <0.5 wink> Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Dr. Dobb's Python-URL! - weekly Python news and links (Dec 2)
>>> Among the treasures available in The Wiki is the current >>> copy of "the Sorting min-howto": >>> http://www.amk.ca/python/howto/sorting/sorting.html >> >> Why is this a "treasure" when it is way out of date? Tony> Note that the updated version of this is at: Tony> http://wiki.python.org/moin/HowTo/Sorting And has been updated quite a bit in the last week by Andrew. Skip -- http://mail.python.org/mailman/listinfo/python-list
Bitching about the documentation...
>> Note that the updated version of this is at: http://wiki.python.org/
>> moin/HowTo/Sorting
rurpy> http://wiki.python.org/...
rurpy> Hmmm, lets see, how about Libraries?
rurpy> Nope, don't see anything that looks like it might be about sort
rurpy> there...
rurpy> How about Documentation?
rurpy> Nope
rurpy> Code?
rurpy> Hmm, "sort lists of dicts" doesn't sound like it...
rurpy> I see there a search box, let's try that for "sort"
rurpy> WTF?, these all look like old maillist archives...
rurpy> Maybe I should Goole python.org What was the google syntax to
rurpy> limit the search to one site? I forgot.
rurpy> Aww screw it.
rurpy> Wikis suck. Update the damn docs.
Gee, I wonder if I typed "sort" into the search box on the wiki it might
turn up something useful? Well, what do you know?
2 results of about 4571 pages. (0.19 seconds)
1. HowTo/Sorting
2. SortingListsOfDictionaries
Is it as good as Google ("site:wiki.python.org sort")? Unlikely, but it
works fairly well. Granted, wikis are a different way of organizing content
than static documentation with their nicely organized chapters, sections and
indexes, but most of us around here are software engineer types, not tech
writers, and since we're not paid to do any of this, we get to do anything
we want. Most of us choose not to write documentation in our spare time.
Go figure. If documentation's your thing, be my guest. Write new
documentation, submit patches for existing documentation, rewrite it in
Word. I don't care. Do whatever floats your boat. Just don't show up and
bitch about the documentation if you're not willing to help.
Oh, did I mention that there's an Edit link at the top of almost every page
on the wiki and that creating new pages is pretty simple? (Try searching
the wiki for "WikiCourse".) Contributing new content to the existing more
static documentation isn't all that hard either.
If you prefer the latest documentation, bookmark this page:
http://www.python.org/dev/doc/devel/index.html
That's updated every few months, more frequently as new releases approach.
Skip
--
http://mail.python.org/mailman/listinfo/python-list
Re: Bitching about the documentation...
>> Gee, I wonder if I typed "sort" into the search box on the wiki it >> might turn up something useful? Well, what do you know? >> >> 2 results of about 4571 pages. (0.19 seconds) >> >> 1. HowTo/Sorting >> 2. SortingListsOfDictionaries rurpy> Are we talking about the same Search box (at the top right of the rurpy> wiki page, and labeled "search"? Well, yes I did enter "sort" rurpy> and got (as I said) a long list of archived maillist postings. Probably. There are two search buttons, Title and Text. Always try the Title search first, as it only searches page titles. If that is unhelpful, then try the Text search. That searches the bodies of the pages. I generally never use that search, preferring instead to use Google's "site:wiki.python.org ..." restricted search which is going to apply their page rank algorithms to the hits (and be faster to boot). I don't know how hard it would be to modify the wiki's Text button so it executes the appropriate Google search. Probably not too hard. I'll look. rurpy> Well, I'm not totally sure but I think I would be willing to a rurpy> least try contributing something. A large amount of the time I rurpy> waste when writing Python programs is directly attributable to rurpy> poor documentation. (To be fair Python is not the only software rurpy> with this problem.) rurpy> But, the standard responce of "don't complain, fix it yourself" rurpy> is bogus too. There are plenty of people on this list willing to rurpy> sing python's praises, for balance, there should be people rurpy> willing to openly point out python's flaws. Documentation is rurpy> certainly one of them. And I was correcting a posting that rurpy> explicitly said there was exceptionaly good information in that rurpy> Howto. That was just plain wrong. Sure, feel free to point of flaws. Just don't let that be the only way you contribute. Over time the value of your criticism (valid or not) will be discounted. The preferred way to correct problems with the documentation is to submit a bug report to SourceForge. Many of the active developers (including those who do write most of documentation) don't necessarily track c.l.py closely, so postings here often will get lost because people can't attend to them immediately. The problem with marching in here and saying "fix the docs" is that you are an unknown quantity (I certainly don't recognize your email address and as far as I've seen you never sign your posts. I don't believe I've ever seen contributions from you either. (Can't double-check right now because SourceForget is basically unresponsive.) The combination makes you look suspiciously like a troll. I doubt that's the case. Troll detectors are notorious for generating false positives. Still, my threat assessment level got raised. Operating under the rurpy's-not-a-troll assumption, your posts suggest to me that you don't understand how Python is developed. Behind the scenes lots of documentation *does* get written. In my experience it hass generally not been written by people who whine, "fix the docs". In short, there seems to be no shortage of people willing to castigate the Python developers for poor documentation. There does appear to be a shortage of people willing to actually roll up their sleeves and help. The other thing to remember is that most of the people who wind up writing the documentation don't personally need most of the documentation they write. After all, they are generally the authors of code itself and are thus the experts in its use. It's tough to put yourself in the shoes of a novice, so it's tough to write documentation that would be helpful for new users. It's extremely helpful if new users submit documentation patches as they figure things out. It's generally unnecessary to write large tomes. Often all that's needed is a few sentences or an example or two. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Bitching about the documentation...
>> Sure, feel free to point of flaws. Just don't let that be the only >> way you contribute. Over time the value of your criticism (valid or >> not) will be discounted. bonono> That is quite interesting, if it is true. Let me rephrase. The discounting I referred to is largely subconcious. When it is concious it's a roll of the eyes or a thought like, "Oh that whiner again. I don't have time for this right now." And the 'd' key gets hit. I didn't mean to imply some sort of smoke-filled backroom where the developers decide whose inputs to listen to. Everybody applies such filters whether they think about it or not. Here are a couple of mine: Xah Lee? Hit the 'd' key. Tim Peters? Read it no matter what the subject says. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Bitching about the documentation...
>>>>> "bs" == BartlebyScrivener <[EMAIL PROTECTED]> writes: bs> I'm a professional writer and author with a keen interest in open bs> source, but the moment you look to contribute or try to help with bs> the documentation you are asked to learn LaTex or DocBook, which, bs> I'm sorry, I am not going to do. Let me repeat this for the umpteenth time: You do not have to learn LaTeX to contribute to docs. Submit plain text. One of us with some LaTeX knowledge will do the markup. Content is the hard part. Markup is nothing, so don't let it be a barrier for you. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Bitching about the documentation...
François> More than LaTeX, the main frozener is when people in charge François> tell you to use bug trackers to speak to them. Understood. I wish either a) SourceForge supported email interaction with their trackers or b) someone would finish off the Roundup issue tracker <http://roundup.sourceforge.net/> for python.org. I doubt if anyone here can do anything about the first barrier, but if you know something about Roundup (or would like to learn about it) and would like to contribute something non-documentational that would really have a direct, positive impact on the Python community, send a note to [EMAIL PROTECTED] Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Bitching about the documentation...
Paul> For example, writing a good doc patch for urllib2 would mean Paul> checking RFC 2616(?) against the urllib2 code to see what parts of Paul> the RFC got implemented and what parts didn't. It might also mean Paul> comparing urllib2 with other libraries like LWP (Perl) or whatever Paul> the equivalent is in Java. Sounds like a subject matter expert is needed here, not a garden variety tech writer or Python programmer. Documentation of esoteric stuff requires, well, esoteric knowledge. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Bitching about the documentation...
>> Are you telling us you learned C#, smalltalk, lisp, C, perl, >> whatever, from 1 website only, without looking at any books, without >> spending any money on IDEs or any software? Cause that's what you're >> asking here. rurpy> For perl and C, yes, that's (close to) what I'm telling you. rurpy> Perl I learned exclusively from the man pages, before WWW. I rurpy> used it for 10 years before I ever bought a printed book. C I rurpy> learned exclusively from the K&R book. That's about the same for me, except Perl never "stuck". rurpy> I tried to learn Python from the "official" docs but found it rurpy> impossible. I did as well, though the docs as they existed in 1993 or so (that is pre-Lutz, pre-Beasley). rurpy> I bought Beasley's book (I think this may have predated rurpy> Martelli's book but I don't remember) which I thought quite good rurpy> and which I still turn to before the Python docs in most cases. Like other free software, you can choose to figure things out yourself (use the source Luke) or pay someone to help you out. I'm not using this as an excuse for poor Python docs. rurpy> That's a very good list and I will save a copy, thanks. But what rurpy> does it have to do with Python's documentation? I'm sure you could find similar lists for Perl, C, Ruby, Tcl, Java, C++, C#, etc. Does that mean their documentation stinks? Maybe. Maybe not. It just means a lot of people have somewhat different ways of tackling the same problem. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Usenet falsehoods (was Re: Bitching about the documentation...)
>> Hmm, I though he explained it: >> >> 1) Not using your real name. >> >> 2) A yahoo, aol, or hotmail address. >> >> In the ancient and hallowed (by net standards) history of Usenet, both >> of these (particularly the first one) have been pretty good predictors >> of crankness. aahz> I've been on the Net for more than fifteen years, and while this aahz> canard about real names gets trotted out from time to time, it's aahz> quite clear that many many people have been active on the Net aahz> *and* taken seriously using names that aren't what you'd call a aahz> "real name". As the person who raised this particular flag, I will note a few things: 1. Monty Python humor aside, this is generally a serious mailing list and newsgroup. In my experience, most people deal professionally with others of like interests by using their real names. 2. While I haven't been to many PyCons, I've been to enough to have met many Python folk. Hell, maybe I've met rurpy and don't even know it. Real people have real names. Using your real name on the net makes you less virtual to the people you communicate with. 3. I'm an Internet dinosaur. I date from the time before l33t speak, the Morris worm, spam and Windows increased the need for people to hide behind virtual masks and throw away email addresses every few months. At the dawn of time, basically everyone used their real names. It's probably just my misunderstanding about how people use avatars on the net nowadays, but I still expect professional people to communicate profesionally. That includes using real names. For completeness, though I usually don't here, my full sig: -- Skip Montanaro Katrina Benefit Concerts: http://www.musi-cal.com/katrina [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Documentation suggestions
amk> The library reference has so many modules that the table of amk> contents is very large. Again, not really a problem that we can amk> fix; splitting it up into separate manuals doesn't seem like it amk> would help. I've been meaning to tackle this with a wiki macro. It would remember the most frequently requested modules (say, the 10-20 most requested) and display them in a separate alphabetical section ahead of the normal massive module index. That would then become the module index I bookmark. I just haven't had the time to implement it. amk> I suspect the Achilles' heel of the docs is the Language Reference. amk> Put aside the fact that it's not up to date with new-style classes amk> and other stuff; that would be fixable with some effort. On a day-to-day basis I don't use the Language Reference at all. Once every couple months perhaps. I think most people who have absorbed the basic syntax and semantics of the language will be in the same boat. It's the Library Reference that requires the most effort I think. amk> To some degree, the guide is trying to be very formal; it's written amk> like a specification for an implementor, not a document that people amk> would read through. But there's no other way for people to learn amk> about all the special object methods like __add__; the tutorial amk> can't cover them all, and the LibRef doesn't describe them. So the amk> newbie is stuck. I think if the newbie has outgrown the Tutorial, they should be able to approach various bits of the Language Reference. Perhaps some bits of its subject matter should be tutorialized and added to the Tutorial amk> I don't know exactly what Bray meant, but suspect that a more amk> readable reference guide would have helped him understand what was amk> going on. I think it would be difficult to produce a more readable reference manual that doesn't introduce some vagueness that will be more difficult for implementers. The Global Index has this to say about various docs: Which ManualTarget Audience --- Library Reference keep this under your pillow Language Reference for language lawyers Extending and Embedding tutorial for C/C++ programmers Python/C APIreference for C/C++ programmers I think those comments are about right. amk> One problem with such a friendly document: it might make the Ref amk> Guide even more irrelevant, if we always updated the friendly amk> document (which is easy) and left the RefGuide to drift even amk> further out of date (because it's hard to update). Somehow I think Guido would eventually put his (16-ton) foot down. ;-) amk> Dumping the RefGuide means there isn't a more formal-style amk> description of Python's semantics. I don't know if this matters. amk> In theory, the implementors of Jython or IronPython could be using amk> the RefGuide to know what they need to implement, but in practice I amk> suspect implementors use the test suite and existing library as amk> checks. Maybe we don't really need a tediously precise description amk> of Python. I think you need something precise, if for no other reason than to distinguish the language definition from the canonical CPython implementation (or in the future to arbitrate disagreements betwee CPython, PyPy, IronPython or some other newcomer). Maybe we have the cart before the horse w.r.t. documenting changes to the language. When a new feature goes into the language proper it is generally discussed on python-dev and written up in a PEP then approved by Guido. We've generally accepted the PEP as informal documentation, but PEP's aren't really part of the formal documentation set. Perhaps all we need to do is be more stringent in requiring Language Reference updates before PEP acceptance. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Documentation suggestions
Ben> Make the docs like PHP's docs. Easier said than done. There is still - I think - a project in the works to redo the python.org website, but I have no idea if it means to retain ht2html+latex2html as the page builders or move to something else. Neither ht2html nor latex2html support in inline annotation feature. It would need to be added. What was the comment here the other day? Python has more web application frameworks than keywords. PHP only has one. ;-) Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Documentation suggestions
Ian> A test suite seems far more useful to implementors than any guide, Of course, test cases can be modified or ignored. I'd agree with you if we had a test suite that was more strongly cast in stone. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Documentation suggestions
>>> A series of examples seems more concrete than a formal description,<< rd> Amen. This is why people buy the books: The good ones have lots of rd> examples. The wizards glance at them in passing and think, "Duh." rd> And the rest of us (including the intermediate folks, I'll bet) are rd> grateful for the chance to see a real live example. ISTR that comment was made in reference to the Language Reference, which as written is intended for "language lawyers". Examples there seem counterproductive. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Documentation suggestions
>> Of course, test cases can be modified or ignored. I'd agree with you >> if we had a test suite that was more strongly cast in stone. Carl> hum. a test suite like that would have to be constructed very Carl> carefully. The current CPython testsuite tests quite some things Carl> that are obviously implementation details. No disagreement there. The current CPython test suite would not cut the mustard as a test for Python specification compliance. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Calculating Elapsed Time
Jean> How do I calculate the elapsed time? Where t1_s and t2_s reference time strings in the format you describe: import datetime import time fmt = "%b %d %Y %H:%M:%S" t1 = datetime.datetime(*time.strftime(t1_s, fmt)[:6]) t2 = datetime.datetime(*time.strftime(t2_s, fmt)[:6]) dt = t2 - t1 should do the trick. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Documentation suggestions
Ian> I think it would be very useful if there was reference (not just Ian> tutorial) documentation for all the syntax, special semantics like Ian> magic methods, and all the functions and objects in builtins. It's pretty common to have a User's Guide as well as a Reference Manual for many applications. Python has always lacked a User's Guide. I find it hard to imagine any one person having the time to simply sit down and bat out such a tome though. I'm partial to using wikis as collaborative environments. (They more readily admit a group of people to the process without a formal registration process as would doing the whole thing via Python's svn repository.) Creating a UsersGuide section of the Python wiki with reST as the markup might be a good place to work on such a beast with the goal that it would be a stepping stone to a more standalone document. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Calculating Elapsed Time
Jean> I'm using an old version of python (2.1) and datetime isn't Jean> available until Python 2.3. I can't upgrade my python. There's a reference implementation of datetime written in Python: http://svn.python.org/view/sandbox/trunk/datetime/ It may or may not work in 2.1. If you decide you can live without datetime, Fredrik's strptime/mktime solution is how you do it without datetime. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Documentation suggestions
Adam> I don't expect everything to make the transition. Are discussions Adam> of "atoms" and fragments of BNF really better than calling them Adam> expressions and linking to CPython's Grammar file? Actually, yes. The actual Grammar file isn't designed for explanation (mostly it's more complex, but it also has extra productions) and is somewhat (maybe a lot) different than the BNF in the ref manual. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Bitching about the documentation...
>> This is why things need to go into public trackers, or wiki pages. François> Whatever means the maintainer wants to fill his preservation François> needs, he is free to use them. The problem arises when the François> maintainer wants imposing his own work methods on others. François, that's not it at all. It's not our fault that SF doesn't support email-based tracker interaction. It's our fault that we chose SF, but it was the best overall choice at the time (there were more considerations than just bug tracking) and now we're sort of stuck with it because for a number of reasons we've been unable to move away from it. Here's the scenario we have to use today to collect emailed requests and put them in SF: * Kind user notices a problem and posts a message somewhere, maybe to c.l.py or to another Python-related list or by direct email to a developer. * Someone - maybe nobody, but maybe more than one person - notices the request and thinks, "better add that to SF so it doesn't get lost". * That person visits SF and submits a ticket. Now, consider some of the problems this scheme is fraught with: * Maybe nobody notices it at all. It might have been buried deep in another thread that no Python developer happened to read in its entirety. Bummer. It's been lost until the next time someone notices and posts a similar request. * Maybe more than one person notices. Bummer. Now we have duplicates. Worse yet, some might have been posted as feature requests, some as bug reports. It also may not be obvious that they are duplicate without careful checking. * The multiple reports might contain different useful perspectives on the problem. Bummer. SF doesn't allow you to easily merge two requests. You have to manually transfer the information from one to the other and close the one. * Maybe the original post generates further responses in that venue that would have been useful to have with the original report. Most will probably never find their way to the tracker. Bummer. They got lost. * Maybe the original requester's email gets missed in the process (or the problem isn't addressed immediately and the user has discarded the original address because it's spammed so heavily and moved on to a new one) and the Python developers need more info but they can't contact the requester. Bummer. The problem isn't adequately addressed. * Finally, instead of one person spending a couple minutes submitting a report, several people will have spent their volunteer time, and there's a good chance that the report is not any better (perhaps even worse) than if the original requester had simply submitted the request directly to SF. I know, we have to take these steps occasion. When bug reports have to be moved from another tracker to the Python tracker some of these issues arise. We've incorportated bug reports from the Debian bug tracker that way and have migrated python-mode requests from the Python project to the python-mode project (both on SF). It can be a pain. The Python developers are not being lazy. I would love it if there was an email interaction mode with the SF trackers, but there isn't. I'll repeat what I wrote yesterday in response to an earlier message in this thread: I wish either a) SourceForge supported email interaction with their trackers or b) someone would finish off the Roundup issue tracker <http://roundup.sourceforge.net/> for python.org. I doubt if anyone here can do anything about the first barrier, but if you know something about Roundup (or would like to learn about it) and would like to contribute something non-documentational that would really have a direct, positive impact on the Python community, send a note to [EMAIL PROTECTED] Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Documentation suggestions
>> The library reference has so many modules that the table of contents >> is very large. Again, not really a problem that we can fix; >> splitting it up into separate manuals doesn't seem like it would >> help. Iain> I like the Global Module Index in general - it allows quick access Iain> to exactly what I want. I would like a minor change to it though Iain> - stop words starting with a given letter rolling over to another Iain> column (for example, os.path is at the foot of one column, while Iain> ossaudiodev is at the head of the next), and provide links to each Iain> initial letter at the top of the page. I know it's not what you asked for, but give http://staging.musi-cal.com/modindex/ a try. See if by dynamically migrating the most frequently requested modules to the front of the section it becomes more manageable. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Documentation suggestions
Iain> Well, the point of the GMI is to lookup whatever module you are Iain> currently having to use for the first time (at least it is for Iain> me). Giving easy access to the modules I've already had to look Iain> up (because they are common) doesn't really help - I've already Iain> accessed those. It'll be nice when I have to find some obscure Iain> feature I haven't used in them before, but really, all I'd like is Iain> an easy to use index :) Reorganizing the global module index isn't all that straightforward. It is generated by latex2html. To change its layout would probaly require some additional markup and mods to latex2html (not a pretty piece of code as I understand it). OTOH, I find myself returning to the same module docs over and over again to look up function arguments, regular expression syntax, that sort of thing. Having to page down past dozens and dozens of modules I don't care about to click on "sys" or "datetime" motivated me to write my little hack. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Documentation suggestions
Adam> Having a large and detailed language specification, although an Adam> admirable ideal, is a waste of time when the target audience is Adam> perhaps a few dozen people. Just because that audience is small doesn't mean they are unimportant. There are currently four actively maintained/developed implementations of Python. A common language reference manual is important for them, and indirectly for the people who use the four implementations. I'm not trying to discount the value of a good Users Guide. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Documentation suggestions
>> http://staging.musi-cal.com/modindex/ Steven> What I don't know is how it would look after thousands of people Steven> using it. I know that I probably only have 10 modules or so Steven> that I consistently need to check the docs for. Your hack above Steven> would conveniently place those all at the top if I was the only Steven> user. But are those 10 modules the same 10 modules that other Steven> folks need? I don't know... Is suspect most people need help with a fairly common module subset on a regular basis. This won't provide a cache with a 100% hit rate, but the cost of a cache miss isn't all that high. Also, you might discover some useful modules you hadn't used before simply because they are frequently referenced. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Documentation suggestions
Kent> OK I'll bite. That Beginners Guide page has bugged me for a long Kent> time. It's a wiki page but it is marked as immutable so I can't Kent> change it. That's because for some reason it is one of the top two or three most frequently defaced pages on the wiki. We got tired of having to revert changes to it every day or two. I'll take a look at incorporating your suggestions. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Bitching about the documentation...
Steven> I'm always amazed and perplexed at how hot-shot programmers who Steven> would never forget a colon or a brace can be so slap-dash about Steven> using proper punctuation and grammar in English. That's because there's no equivalent to a compiler or interpreter preventing them from speaking or writing. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Documentation suggestions
>> http://staging.musi-cal.com/modindex/ rurpy> Is this only for the online docs? Yes. I don't see that it would be helpful for static docs. Presumably they will get reorganized. I want something for the many times I return to the global module index looking for help with a particular module. rurpy> My experience with other machine systems that try to guess what I rurpy> will want, is they usually get it wrong, and become more of a rurpy> burdon than a help. This isn't guessing. It's more like voting (or like rating systems such as the Internet Movie Database). S -- http://mail.python.org/mailman/listinfo/python-list
Re: Documentation suggestions
Ian> I think the point is that there is the core language, and from a Ian> user's perspective builtins and statements and syntax are all the Ian> same thing. When you import a module, it's more-or-less obvious Ian> where you find information about the module (the module index, of Ian> course). I suspect I'd have a harder time living without the sys module than with many of the builtins. Then there's os, re, math, ... Some modules, like thread and sys, have to be linked into the interpreter. Are they "core" or "add on"? Once you start migrating stuff from the "add on" manual (Library Reference) to the "core" manual (Language Reference), where do you stop? Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: ElementTree - Why not part of the core?
>> ElementTree on the other hand provides incredibly easy access to XML >> elements and works in a more Pythonic way. Why has the API not been >> included in the Python core? Magnus> I'd really like to see that too. Sure, it's fairly trivial to Magnus> install it, but each different package that needs to be Magnus> installed from another source, built and tested on multiple Magnus> platforms etc, means more work. More work than reimplementing the functionality or living with a miserable API (I'm thinking normal DOM APIs)? Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: ElementTree - Why not part of the core?
>> ElementTree on the other hand provides incredibly easy access to XML >> elements and works in a more Pythonic way. Why has the API not been >> included in the Python core? I think the key here is ElementTree's Pythoninc API. While it's clearly possible to install it as a third-party package, I think there's a clear best-of-breed aspect here that suggests it belongs in the standard distribution simply to discourage continued use of DOM-based APIs. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Documentation suggestions
amk> I wonder if the Internet chapter should be split into "HTTP/Web
amk> Tools" (webbrowser, cgi, cgitb, httplib, urllib) and "Non-Web
amk> Protocols" (ftplib, gopherlib, smtp, all the rest).
Note that cgitb works just fine in a non-web environment. I would actually
prefer it be renamed ("fancytb"?) and then stuck wherever the traceback
module docs go.
>> \input{distutils}
amk> Distutils should probably be in Program Frameworks. Or it could just
amk> have a chapter of its own, or maybe there are enough modules for an
amk> "Application Support" chapter.
There are currently 46 module index entries for the various parts of
distutils. I think it would be helpful to reduce that number a bit...
Skip
--
http://mail.python.org/mailman/listinfo/python-list
Re: Documentation suggestions
Mike> The question is how do you keep the system that the Python code is Mike> actually running on safe? Ruby may have a real bastion mode, but Mike> Python doesn't. User Mode Linux? chroot? Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Documentation suggestions
Trent> Nah, the Try Ruby thing is mostly faking it (I believe) rather
Trent> than running an actually Ruby interactive session ("bastion'ed"
Trent> or not).
I don't think so. I tried typing some stuff at the prompt that it wasn't
asking for, like "x = [1,2,3]" followed by "x * 5" when it was asking me to
type "2 + 6". It evaluated both properly as far as I could tell. OTOH, it
hung when I entered "def fib(n)". Never got to the next prompt. Looking at
the Javascript, it appears to be some sort of Ajaxian thing...
Skip
--
http://mail.python.org/mailman/listinfo/python-list
Re: Dr. Dobb's Python-URL! - weekly Python news and links (Dec 7)
Cameron> In article <[EMAIL PROTECTED]>, Cameron> I reported: >> "Python has more web application frameworks than keywords." - Skip >> Montanaro (but probably others going back years) Cameron> Incorrect. Thanks to Fredrik Lundh ... Yeah, I wondered about that. I was only parroting what I'd seen in Harald's post. I just couldn't remember who'd said it. Skip -- http://mail.python.org/mailman/listinfo/python-list
navigating/changing directories
A simple script like the one below lets me jump through a directory
structure. However, if I run it from /this/directory and within it to go to
/a/totally/different/directory... I'm still actually going to be in
/this/directory when I exit the script. Is it possible to have a script
that can drop me off into a different directory than where I initiated it
from?
import os
process = 1
while (process):
# Display directories
for i in os.listdir(os.getcwd()):
if (os.path.isdir(os.path.join(os.getcwd(),i))):
print i
# Change directory
goto_dir = raw_input(": ")
if (goto_dir in os.listdir(os.getcwd())):
os.chdir(os.path.join(os.getcwd(),goto_dir))
else:
process = 0 # Exit
--
http://mail.python.org/mailman/listinfo/python-list
Handling fractions of seconds in strftime/strptime
I'm looking for a solution (or ideas about a solution) to the problem that strftime(3) and strptime(3) don't understand time increments of less than one second. Most operating systems can provide times with subsecond resolution and like Python I'm pretty sure Ruby, Perl and Tcl have objects or packages that can manipulate such times in a sane manner. I'm casting my net to a broader community than just Python (where I generally hang out) to see if/how others have addressed this problem. Here's my typical use case. I generate log files with subsecond resolution using Python's datetime module. By default it generates printable timestamps in an ISO format that includes fractions of seconds, e.g., "2005-01-14 18:56:54.546607". I often need to parse such times, and therein lies the rub. Python's date parsing is based on strptime(3) which can't handle fractions of seconds. I wind up worming around the problem with a little hackery, but it bothers me that given an otherwise complete solution to formatting and parsing times I can't handle this common (for me) case. I realize that other languages may not base their current time formatting and parsing on strftime(3) and strptime(3), but I suspect those two functions were at least the root of what is commonly used by most languages. In my investigation I came across a DateTime module in Perl that uses "%N" (or optionally "%nN" where n is a digit) to identify integers as nanoseconds or some other subsecond time. I belive "%3N" would cause "123" to be interpreted as 123 milliseconds, for instance. I've considered extending "%S" to accept fractional seconds or adding a new format specifier like "%F" to handle this case. I'm interested to know what solutions have been devised or considered for other languages. (Has this been addressed in some more recent version of the C or C++ standards I'm unaware of?) Rather than reinventing the wheel I'd like to adopt an existing solution if possible. At the very least I'd like to know how others have approached the problem. I think there's an opportunity to add some value that everyone can take advantage of. Thanks for your time, Skip Montanaro [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Programming Contest
Brian> I've decided that it would be be fun to host a weekly Python Brian> programming contest. The focus will be on algorithms that require Brian> a bit of thought to design but not much code to implement. For some of us that's what we do day-in, day-out at work. It's just not called a contest. To make it more challenging, we sometimes leave out the "bit of thought" part. ;-) Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Programming Contest
Brian> This contest is for people who like thinking about algorithms. Surely you must have missed the smiley... S -- http://mail.python.org/mailman/listinfo/python-list
Re: goto
>>> what is the equivalent of C languages' goto statement in python? >> You really shouldn't use goto. >> Fortunately you can't. Steven> Of course you can :-) Steven> You can write your own Python interpreter, in Python, and add a Steven> goto to it. Maybe easier would be to write a Python assembler (there's probably already one out there) and just write to Python's virtual machine... Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: gdb python C API
fraca7> derrick a écrit : >> are there any tools / methods that others have used to get what line >> of the python script is being executed while running in gdb? or if it >> would actually show me the source python script (instead of the the >> python c source) that would help. fraca7> I don't think so, but when having a memory problem I usually fraca7> find valgrind very useful. Actually, take a look in the distribution at Misc/gdbinit. In particular, check out the pystack command. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: [path-PEP] Path inherits from basestring again
Reinhold> Right, that was a concern of mine, too. Reinhold> "tobase"? Reinhold> "tostring"? Reinhold> "tobasestring"? If we're on a filesystem that understands unicode, would somepath.tostring() return a unicode object or a string object encoded with some to-be-determined encoding? Why not just add __str__ and __unicode__ methods to the class and let the user use str(somepath) or unicode(somepath) as needed? Or am I missing something fundamental about what the base() method is supposed to do? Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: how to imput usernames and passwords??
Patrick> Is there a way I can have Python tell Oracle what the username Patrick> and password is? Dunno what db adapter module is used for Oracle, but the ones I've used for Sybase, PostgreSQL and MySQL all accept username/password parameters either individually or stuffed into a DSN string. Check the docs for the module you use to talk to Oracle. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Emacs skeletons
Michael> Does anyone have any Emacs skeletons they find useful for Michael> Python? What's an "Emacs skeleton"? Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: A Module on Time & Date
>> As you can see in the datetime documentation, the module was >> introduced in Python 2.3. I recommend updating your Python >> installation. Robert> What do you mean "your"?? I don't have any Python installation Robert> of my own. All I have is what this small local ISP provides on Robert> its Unix shell machine which I share with hundreds of other Robert> users. There's no way I can install a new version of anything on Robert> the system account. Your recommendation will be disregarded as Robert> total crap. If your ISP provides you with a C compiler, you can download and install Python yourself. Just create ~/local, add ~/local/bin to your PATH, then in the expanded Python source tree execute: ./configure --prefix=$HOME/local make make test make install Skip -- http://mail.python.org/mailman/listinfo/python-list
On fighting fire with fire...
Twice today I responded to rude messages (once here, once on the SpamBayes list) whose authors didn't deserve the benefit of my time. In both cases, other people rightfully responded with some small amount of return venom (but provided useful responses nonetheless). Let me suggest that there is only one "correct" way to respond (if you are going to respond at all) to such messages. That's to focus on the substance of their message and completely ignore the rancor. I've been the chief technical guy (including user support) for Musi-Cal for over ten years and for Mojam for about seven years. During that time I've received lots of thanks from people for the service those sites provide. Every once in awhile though, I get a message out of the blue from someone who is either simply an asshole or is having the mother of all bad days. I've found there is nothing so satisfying as responding politely to such messages and then to have their authors come virtually crawling back later with an apology for having been so out-of-line. Just a thought... Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Regex for nested {}
Chris> I have a problem matching nested levels of {} ...
Regular expressions can't count, so you'd be better off sticking with
regexes to tokenize the source, then use a real parser to parse the tokens
it produces.
Skip
--
http://mail.python.org/mailman/listinfo/python-list
Re: What are modules really for?
Nick> One thing I find weird about python is the idea of a module. Why Nick> is this needed when there are already the ideas of class, file, Nick> and package? A module is a namespace object that maps one-to-one to a file (ignoring the new module's features). A file by itself is just a collection of bytes and has no features to interpret the structure of its contents as a namespace. Nick> Python seems to let you group classes together in one file and Nick> call it a module, but what for? You can define many other types of objects in modules besides classes. Nick> With Python an inherited method could be in one of many base Nick> classes and/or mixins and there seems no particular logic as to Nick> what the filename would be. I agree mixins can be troublesome. That's a problem peculiar to multiple inheritance, not strictly to Python. I'm sure you can create file/class relationships in Java or C++ that make it challenging to find the definition of a mixin. I don't view multiple inheritance as a gotta-have feature of OOP and avoid it when I can. Smalltalk has lived happily without multiple inheritance for a few decades now. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: sqlobject vs mysqldb module
yaffa> i have a python script that scrapes contents from an html file yaffa> and i would like to have the script write values to a mysql db. yaffa> do you recommend i go with the sqlobject or the mysqldb module? They are really quite different beasts. You'll have to consider your requirements to decide which to use. -- Skip Montanaro [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Recommendations for CVS systems
>> For a python newsgroup, you are required to consider mercurial. It's >> not ready for production use yet, but is making rapid progress, ... aahz> Why do you say "required" when the next sentence you say it's not aahz> ready for production? I believe "consider" != "adopt". Different people's needs are different, so the notion of how "production-ready" it has to be will vary. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Moinmoin config
Mark> I have another question, and as of yet, have not found another Mark> discussion group for moinmoin, so sorry, but here goes: Have you tried the mailing list [EMAIL PROTECTED] If you are determined to read it via Usenet, try gmane: http://dir.gmane.org/search.php?match=moin Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Light Revisted?
Ramza> The goal, build python(mainly for win32) so that the ENTIRE Ramza> install is maybe less than 5MBs and includes possibly a GUI Ramza> library, possibly TwistedMatrix, possibly install from just Ramza> unzipping an archive like applications such as Eclipse. ... Ramza> Why? For example, I don't need an XML-RPC library, or zip Ramza> library, or the other libraries. Let's suppose I decided to take your bait and build a python-lite distribution (fyi, I'm not biting). How would I know what to remove and what to retain? Some choices would be simple. If I was targeting Win32 I could clearly leave out Mac- or Unix-Specific stuff. I could probably dispense with the docs on the premise that you could read them online. How would I decide whether to keep or toss xmlrpclib or zipfile? If I keep xmlrpclib should I also keep SimpleXMLRPCServer? What about unicodedata (it's a biggie)? What about compatibility? If someone installs the python-lite distro then downloads, let's say, Tailor, a version control converter. What are the chances that it will croak with an ImportError? Put another way, are you really willing to trade off a few megs of disk space against almost certain breakage at some point in the near future? I can understand that distributions for some platforms (PalmOS, OS/2, Amiga, Jython) might contain fewer modules simply because not everything has been ported to them, but given the cost of disk space today I don't understand why a distribution for a mainstream platform should be hobbled. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Bug in string.find; was: Re: Proposed PEP: New style indexing,was Re: Bug in slice type
Paul> Steve Holden <[EMAIL PROTECTED]> writes: >> A corrected find() that returns None on failure is a five-liner. Paul> If I wanted to write five lines instead of one everywhere in a Paul> Python program, I'd use Java. +1 for QOTW. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: To the python-list moderator
Fredrik> Terry Hancock wrote: >> I got one of these too, recently. Maybe somebody is turning up the >> screws to get rid of spam that's been appearing on the list? Fredrik> I've been getting these about once a day lately. at first, I Fredrik> suspected some kind of "you're posting to quickly"-filter with Fredrik> a manual "okay, you're whitelisted for another 24 hours" setup, Fredrik> but it seems to block messages mostly by random. and some Fredrik> messages don't seem to get through at all. slightly annoying. I think it's just that the SpamBayes training database used to check the list's messages is perhaps getting a little tired. Skip -- http://mail.python.org/mailman/listinfo/python-list
