Re: Which blog tool
There's actually a very simple way to achieve this. In your blogger settings you can specify an email address to which you can email blog posts. Using this, you can simply mail the content from within your python script. I think that's probably the most hassle-free way. Blogger help article: http://help.blogger.com/bin/answer.py?answer=135 Daniel Bickett On Sat, 01 Jan 2005 13:14:23 +, Mark Carter <[EMAIL PROTECTED]> wrote: > I currently use python to automatically summarise a certain newsgroup > daily, and post the findings that it makes. Someone has suggested that > they would like a to see a blog of the posts. I wondered if there was a > python tool/library that could automate the blog postings. Any ideas? > > Some details: > * the summaries are basically just text files > * I already have a blog at www.blogger.com > (http://markcarterturriff.blogspot.com/), so I would like to use that if > possible; although any alternative free one that I can use to achieve my > objective would be OK, too. > * I do have my own hosted website, which can use perl but not python; > but I'd rather use a freebie blog site > * the whole thing must be scriptable, because it will run daily. A GUI > would therefore likely get in the way. > * generating an RSS feed would be nice > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: screen clear question
import os # windows os.system("cls") # bash ( mac, linux ) os.system("clear") That's all I can account for. Daniel Bickett -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem remotely shutting down a windows computer with python
While I have no solution for the recipe you cited, it seems like alot of trouble could be avoided by simply importing the os module and running the following command using os.system: shutdown -s Daniel Bickett On 2 Jan 2005 20:13:35 -0800, EW <[EMAIL PROTECTED]> wrote: > I have a problem when using the python script found here: > > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/360649 > > It is a script to remotely shutdown a windows computer. When I use it, > the computer shuts down, but doesn't power off like with a regular > shutdown. It stays on the "Safe to power off" screen and I have to push > the power button to actually power off. Anyone know why this happens > with this script? Thanks for any help. > > Eric > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: DOS problem (simple fix??)
I tend to run "cmd" and "cd" to the directory of the script, then run it. This way, the window doesn't close, and I can read any errors that occur without interruption. Optionally, you can run "cmd" and simply drag the script you want to run into the window. That pastes its path (in quotes) into the command line, and you can just hit enter. I wouldn't recommend this, though, because the cwd wouldn't be that of the script, and it could cause instability for some apps that use relative paths. Daniel Bickett -- http://mail.python.org/mailman/listinfo/python-list
shutil.move has a mind of its own
Hello, I'm writing an application in my pastime that moves files around to achieve various ends -- the specifics aren't particularly important. The shutil module was chosen as the means simply because that is what google and chm searches returned most often. My problem has to do with shutil.move actually putting the files where I ask it to. Citing code wouldn't serve any purpose, because I am using the function in the most straight forward manner, ex: shutil.move( "C:\omg.txt" , "C:\folder\subdir" ) In my script, rather than a file being moved to the desired location, it is, rather, moved to the current working directory (in this case, my desktop -- without any exceptions, mind you). As it happens, the desired locations are system folders (running windows xp, the folders are as follows: C:\WINDOWS, C:\WINDOWS\SYSTEM, C:\WINDOWS\SYSTEM32). To see if this factor was causing the problem, I tried it using the interpreter, and found it to be flawless. My question boils down to this: What factors could possibly cause shutil.move to fail to move a file to the desired location, choosing instead to place it in the cwd (without raising any exceptions)? Thank you for your time, Daniel Bickett P.S. I know I said I didn't need to post code, but I will anyway. You never know :) http://rafb.net/paste/results/FcwlEw86.html -- http://mail.python.org/mailman/listinfo/python-list
Re: shutil.move has a mind of its own
Oh, I'm sorry, that was my mistake. The example contained that error, but my code does not. Daniel Bickett -- http://mail.python.org/mailman/listinfo/python-list
Re: shutil.move has a mind of its own
Don wrote: > I don't know if this is the problem or, not, but: > [snip] As I said, that was simply an error when typing the example, and it is not present in my code. See below. Neil Benn wrote: > >Oh, I'm sorry, that was my mistake. The example contained that error, > >but my code does not. > > > > [snip] > > > To be fair though - I would have expected the method to throw an error > rather than default to cwd. > > Neil > Which is why I found this so strange, and also why I provided my code. The paths are user-inputed, and only referenced as variables, so this is clearly not a matter of escape sequences. Daniel Bickett -- http://mail.python.org/mailman/listinfo/python-list
Re: threading and sockets ?
http://www.twistedmatrix.com/ Daniel Bickett -- http://mail.python.org/mailman/listinfo/python-list
Re: What YAML engine do you use?
Istvan Albert wrote: > XML with elementtree is what makes me never have think about XML again. I second that. I heard about yaml and I read into it, but when I tried to use it I didn't seem to get in touch with all of the glory surrounding it. The yaml module -- when I tried to use it -- was very error prone, and simply didn't work. I didn't have the time to go through and try to tweak it because I was pressed for time and need a quick solution. As for syck, I don't know if it was just me, but when I downloaded it I got a whole lot of directories with obscure names and files with .c extensions. So, discouraged, I gave up on yaml. Elementtree, on the other hand, is wonderful :) Irmen de Jong wrote: > +1 QOTW I second that, as well. here's-to-appreciating-the-end-without-having-to-be-interested-in-the-means-ly y'rs Daniel Bickett -- http://mail.python.org/mailman/listinfo/python-list
Re: What YAML engine do you use?
Doug Holton wrote: > What do you expect? YAML is designed for humans to use, XML is not. > YAML also hasn't had the backing and huge community behind it like XML. > XML sucks for people to have to write in, but is straightforward to > parse. The consequence is hordes of invalid XML files, leading to > necessary hacks like the mark pilgrim's universal rss parser. YAML > flips the problem around, making it harder perhaps to implement a > universal parser, but better for the end-user who has to actually use > it. More people need to work on improving the YAML spec and > implementing better YAML parsers. We've got too many XML parsers as it is. However, one of the main reasons that XML is so successful is because it's roots are shared by (or, perhaps, in) a markup language that a vast majority of the Internet community knows: HTML. In it's most basic form, I don't care what anyone says, XML is VERY straight forward. Throughout the entire concept of XML (again, in its most basic form) the idea of opening and closing tags (with the exception of the standalone tags, however still very simple) is constant, for all different data types. In my (brief) experience with YAML, it seemed like there were several different ways of doing things, and I saw this as one of it's failures (since we're all comparing it to XML). However I maintain, in spite of all of that, that it can easily boil down to the fact that, for someone who knows the most minuscule amount of HTML (a very easy thing to do, not to mention most people have a tiny bit of experience to boot), the transition to XML is painless. YAML, however, is a brand new format with brand new semantics. As for the human read-and-write-ability, I don't know about you, but I have no trouble whatsoever reading and writing XML. But alas, I don't need to. Long live elementtree (once again) :-) Daniel Bickett -- http://mail.python.org/mailman/listinfo/python-list
Re: What YAML engine do you use?
Doug Holton wrote: > You might like programming in XML then: http://www.meta-language.net/ > :) http://www.meta-language.net/sample.html#class-metal I'm not so sure ;-) Daniel Bickett -- http://mail.python.org/mailman/listinfo/python-list
Re: how to write a tutorial
> Most texts in computing are written by authors to defend and showcase > their existence against their peers. When you aren't busy `showcasing' your ignorance, this is *all* i see in everything you write. > In a tutorial, nobody cares how > the language compared to x y and z, or what technicality is it all > about, or some humorous snippet of history only funny to the author > himself. You couldn't be farther from the truth. To preface a document by illustrating it's similarities to other languages is to better prepare a reader who may have experience in those languages. As for the snippet of history, few people desire to live life as cynical as you do, and one would hope even fewer take their own opinion and assume it applies to their peers, as you have just done. > Particularly for texts in a tutorial context, you want to write it as > simple as possible covering the most useful basic functionalities and > concepts, and self-contained. Not showcasing your knowledge of history > of languages or your linguistic lineage byways. You of all people are the least qualified to say this, as you are the most guilty of such a crime. > For example this chapter 9 on Objects, it is not difficult to write it > without making a show of lingoes. One simply write what is of Python, > without thinking about relation to xyz languages or the "computer > science" establishment and their ways of thinkings of namespaces and > scopes and dynamic and statics and inheritances ... fucking bags of > shit. Then please be so kind as to give us all a pleasant surprise, and take the place of the productive reformer rather than the angsty criticizer. Your vision as to the errors in the tutorial is *clearly* less clouded than ours, so only *you* are in the position to write the proper replacement. Daniel Bickett -- http://mail.python.org/mailman/listinfo/python-list
Re: compile python to binary
Fredrik Lundh wrote: > see section 6.1.2 in the tutorial: > [snip] I believe Sam was talking about "frozen" python scripts using tools such as py2exe: http://starship.python.net/crew/theller/py2exe/ As to how the actual process works, I'm not qualified to answer (having only read an article in the linux magazine,) but I hope this helps. Daniel Bickett -- http://mail.python.org/mailman/listinfo/python-list
Re: compile python to binary
Fredrik Lundh wrote: > oh, you mean that "python compiler" didn't mean "the python compiler". > [snip] I simply inferred that he was using the wrong terminology, being that he said "binary" twice ;-) sam wrote: > I have seen some software written in python and delivered as binary form. > > How does these binary code get generated by python compiler? Daniel Bickett -- http://mail.python.org/mailman/listinfo/python-list
Re: on the way to find pi!
Python 2.3.4 (#53, May 25 2004, 21:17:02) [MSC v.1200 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import math >>> math.pi 3.1415926535897931 Daniel Bickett -- http://mail.python.org/mailman/listinfo/python-list
OT: problems mirroring python-list to c.l.py?
I'm not sure if it's just me (or, indeed, just google groups), but my "python-list" folder (label, that is) in my gmail account looks less and less similar to Google Groups' comp.lang.python with each day. Not only that, c.l.py has been acting rather strange. Example that happened just now: Ali Polatel mailed[1] (I'm assuming) the python-list asking about pi. I responded, showing an interactive shell snippet[2], however on Google Groups' c.l.py it created the thread[3] as beginning with my post (undoubtedly causing confusion because mine was an answer not a question). Is there a reason that Google Groups isn't mirroring python-list exactly like it used to, or is it simply a conspiracy I'm not in on? perfectly-capable-of-conspiring-ly y'rs, Daniel Bickett NOTES: [1] http://mail.python.org/pipermail/python-list/2005-January/261966.html [2] http://mail.python.org/pipermail/python-list/2005-January/261968.html [3] http://tinyurl.com/6tsec -- http://mail.python.org/mailman/listinfo/python-list
Re: OT: problems mirroring python-list to c.l.py?
John Lenton wrote: > > On Sun, Jan 23, 2005 at 01:53:52PM -0500, Daniel Bickett wrote: > > > > > > Is there a reason that Google Groups isn't mirroring python-list > > > exactly like it used to, or is it simply a conspiracy I'm not in on? > > > > You should not ask this kind of question in a public forum, > > and *you* should know better than to go around flapping your mouth > like that. Now I'm further confused, because I don't know what you quoted, but it isn't on the mailing list and it isn't on c.l.py :) Maybe I should give up trying to figure these things out. You didn't include a name at the beginning of your citation... Who had the audacity to take my joke seriously? ;-) Daniel Bickett -- http://mail.python.org/mailman/listinfo/python-list
Re: how to write a tutorial
Lucas Raab wrote: > Daniel Bickett wrote: > >>Most texts in computing are written by authors to defend and showcase > >>their existence against their peers. > > > > > > When you aren't busy `showcasing' your ignorance, this is *all* i see > > in everything you write. > > > > Um, maybe that was his point... It was a critical comment -- meant to be derogatory. I pointed out that that is exactly what he does. Daniel Bickett -- http://mail.python.org/mailman/listinfo/python-list
Re: how to write a tutorial
Chris Mattern wrote: > alex23 wrote: > > > Having read your comments on women, > > I hadn't looked at that part of his site until now. I can only say: > gah. Haven't seen something like that since Dave Sim's infamous > "Tangent" essay. It's painfully obvious that it is all for the sole purpose of negative attention. You guys are just begging for a YHBT ;-) Daniel Bickett -- http://mail.python.org/mailman/listinfo/python-list
Re: how to write a tutorial
Daniel Bickett wrote: > [snip] > You guys are just begging for a YHBT ;-) I apologize, that should have been "we" -- I was criticizing him too. no-one-wants-to-be-a-hypocrite-ly y'rs, Daniel Bickett -- http://mail.python.org/mailman/listinfo/python-list
Help! Host is reluctant to install Python
I've been trying to convince my host to install python/mod_python on his server for a while now, however there are a number of reasons he is reluctant to do so, which I will outline here: 1. His major reason is optimization. He uses Zend's optimization of PHP as an example, and he has stated that python is rather resource consuming. 2. Another one of his points is that he is unexperienced in installing python, and he would not know how to do it securely. By 'securely', I'm assuming he means disallowing a malicious (or ignorant) user from harming the server And, in light of point #1, I suggested that if there wasn't any optimization immediately available, he could just enable it for my account (thus lessening potential resource consumption at any given time), to which he retorted "Do /you/ know how to do that?", and I must say, he has me cornered ;-) I have no experience with this sort of thing, so I'm asking a little assistance in the direction of any documents or websites (or what have you) I could show him in order to answer some of these questions, or perhaps even some unspoken ones -- anything worth noting. (all I'm really going to do is link him to this thread once it has accumulated any answers) Thank you all for your help :) Wishing-to-be-liberated-from-the-clutches-of-PHP-ly y'rs, Daniel Bickett -- http://mail.python.org/mailman/listinfo/python-list
Re: Help! Host is reluctant to install Python
On [EMAIL PROTECTED] wrote: > Daniel Bickett <[EMAIL PROTECTED]> writes: > > I've been trying to convince my host to install python/mod_python on > > his server for a while now, however there are a number of reasons he > > is reluctant to do so, which I will outline here: > > I'm surprised that you're getting such detailed answers from him. > Usually, low-cost web hosts want to offer a one-size-fits-all package > that requires minimal interaction with customers. If you're paying > $10 a month for hosting and a host admin has to spend 1 hour sending > you email, that probably wipes out at least 6 months of profits from > you as a customer. If you want custom service you usually have to pay > a lo tmore. I know him personally, which is part of my reluctance to ditch him entirely as most of you have suggested ;-) Suffice it to say I was able to gain access to a 2.2 installation that was already on the server, however for my intents and purposes I need a minimum of 2.3. Now I'm working on getting him to upgrade to 2.4 and install mod_python :) New quick question: As for the former, on the download page it states that the RPM distribution is sufficient for Fedora Core 3 *and similar*, and I'm curious to know if that applies to Red Had Enterprise as well. Thank you all for your answers and your time. P.S. As for your pricing question, I only pay $20 a year. His services are very affordable. You can see them all at the following link: http://www.snorland.com/webhosting/ -- Daniel Bickett [EMAIL PROTECTED] http://heureusement.org/ -- http://mail.python.org/mailman/listinfo/python-list
Re: gmail access with python!
Indeed, here is a detailed help document on GMail POP3 access: http://gmail.google.com/support/bin/answer.py?answer=12103 huh...look at that, they're using python :) Never noticed that before. Anyway, after that you can simply use a standard POP3 module. There's no need to get fancy and use gmail-specific libraries, really. -- Daniel Bickett dbickett at gmail.com http://heureusement.org/ -- http://mail.python.org/mailman/listinfo/python-list
Re: gmail access with python!
On Jeremy Bowers wrote: > Can you expand on that for us non-GMail users? A login is required to view > that page. I apologize, I wasn't aware :) It simply outlines all of the credentials to use gmail with pop3, I'll list it all here: Incoming server: pop.gmail.com Outgoing server: smtp.gmail.com Be sure to include @gmail.com for your username. For the incoming server (the topic at hand, if I'm not mistaken,) It instructs you to use an SSL connection and port 995, so that is sure to change some things. I believe that's all. -- Daniel Bickett dbickett at gmail.com http://heureusement.org/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Q: quoting string without escapes
On Mon, 31 Jan 2005 14:09:10 -0500, Steve Holden <[EMAIL PROTECTED]> wrote: > Use triple-quoting. An example, for the sake of examples: Python 2.3.4 (#53, May 25 2004, 21:17:02) [MSC v.1200 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> string = """ " ' " ' " ' " ' \""" """ >>> string ' " \' " \' " \' " \' """ ' >>> string = """ ... " ... " ... " ... ' ... ' ... ' ... \""" ... "\"" ... ""\" ... """ >>> string '\n"\n"\n"\n\'\n\'\n\'\n"""\n"""\n"""\n' -- Daniel Bickett dbickett at gmail.com http://heureusement.org/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Go visit Xah Lee's home page
I thought we had resolved to stop giving this troll so much negative attention. Most of us know that that only increases the problem, and yet now I see a handful of topics at the top-most of this list devoted solely to him. I think we should go with the idea of a program that tags his perl-python threads, and simply put him out of mind. As for your statement in his defense, Michael, his "views" (if one chooses to give him that much credit) are by no means profound. It happens to be somewhat of a bandwagon to criticize Bush and cite those very same "facts". Every now and then I'll get amused by what he is doing with perl-python, and how he intentionally makes those mistakes, but then when we have a real conversation it just makes me angry. -- Daniel Bickett dbickett at gmail.com http://heureusement.org/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Easy Q: dealing with object type
On Erik Johnson wrote: > # The following "works", but I don't want to keep a set of instances to > compare against > >>> obj2 = A() > >>> type(obj) == type(obj2) > 1 How about: >>> class A: pass >>> class B: pass >>> objA = A() >>> type( objA ) == type( A() ) True then again >>> objB = B() >>> type( objA ) == type( B() ) True they're both of type 'instance'. So how about this: >>> class A: pass >>> class B( object ): pass >>> objA = A() >>> objB = B() >>> type( objA ) >>> type( objB ) >>> type( objB ) == B True I believe that achieves what you were aiming for. -- Daniel Bickett dbickett at gmail.com http://heureusement.org/ -- http://mail.python.org/mailman/listinfo/python-list
Re: streaming a file object through re.finditer
The following example loads the file into memory only one line at a time, so it should suit your purposes: >>> data = file( "important.dat" , "w" ) >>> data.write("this\nis\nimportant\ndata") >>> data.close() now read it >>> import re >>> data = file( "important.dat" , "r" ) >>> line = data.readline() >>> while line: for x in re.finditer( "\w+" , line): print x.group() line = data.readline() this is important data >>> -- Daniel Bickett dbickett at gmail.com http://heureusement.org/ -- http://mail.python.org/mailman/listinfo/python-list
Re: CONTEST - What is the (best) solution?
Cappy2112 wrote: > > dictionaries can NOT contain dictionaries. > > Who told you this? > In my python, they can. > [snip] You took his reply out of context. Fuzzyman asked him if *his* dictionaries were to contain dictionaries, and the reply was no, they will not. -- Daniel Bickett dbickett at gmail.com http://heureusement.org/ -- http://mail.python.org/mailman/listinfo/python-list
Re: streaming a file object through re.finditer
Erick wrote: > True, but it doesn't work with multiline regular expressions :( If your intent is for the expression to traverse multiple lines (and possibly match *across* multiple lines,) then, as far as I know, you have no choice but to load the whole file into memory. -- Daniel Bickett dbickett at gmail.com http://heureusement.org/ -- http://mail.python.org/mailman/listinfo/python-list
Re: IDLE history, Python IDE, and Interactive Python with Vim
This is certainly a worthy topic. There are several IDEs for Python (one I like very much being Komodo) that have plenty of fancy debugging features and advanced operations, however I have yet to encounter (elsewhere) the convenience that comes with being able to press F5 and have an interactive interpreter load my code and be ready for testing. That said, that is my only reason for my ever using IDLE. Without it I would probably forget that IDLE exists, were it not for the obnoxious context menu entry. ;) -- Daniel Bickett dbickett at gmail.com http://heureusement.org/ -- http://mail.python.org/mailman/listinfo/python-list
Re: bytecode obfuscation
snacktime wrote: > How difficult is it to turn python bytecode into it's original source? > Is it that much different than java (this is what they will probably > compare it to) ? As far as I know, that depends on how much money you're willing to pour into it ;) http://www.crazy-compilers.com/decompyle/ Other than that link, which I stumbled upon at some point (at python-eggs), I'm decidedly uninformed on this subject. -- Daniel Bickett dbickett at gmail.com http://heureusement.org/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Where are list methods documented?
Simply as a general reply to the OP, I've found that some of the most definitive documentation can be found using help() at the command line: Python 2.3.4 (#53, May 25 2004, 21:17:02) [MSC v.1200 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> help(list) Help on class list in module __builtin__: [big snip] It goes into good detail about all of the methods, etcetera. -- Daniel Bickett dbickett at gmail.com http://heureusement.org/ -- http://mail.python.org/mailman/listinfo/python-list
Possible additions to the standard library? (WAS: About standard library improvement)
I was reading the thread by Frank Bello[1] about his offered addition to the xmlrpclib module, and it reminded me of a few methods I had made in the past that I considered worthy of being a part of the standard library. Rather than reiterate his question of how one gets one's patch into the standard library -- as I can simply read the answers from his thread -- I am posting here asking the opinion of the Python community as to whether *you* consider these worthy of standard library implementation. The first one is a function I made for the _winreg module[2]. The commentary, I think, explains what it does and why it had to be written very clearly, so I'll just copy and paste it:[3] |def DeleteKeyAll( key , subKey ): |""" |Since DeleteKey() can't remove keys that contain subkeys, this serves |to iterate through a key and delete every single subkey, and then the |key itself. | |Note: This function assumes that _winreg has been imported using: |from _winreg import * | It can be easily converted by simply prepending all of the | applicable statements with `_winreg.' if you have imported | it otherwise. |""" |# try to open the specified key |try: |handle = OpenKey( key , subKey ) |except EnvironmentError: |return False |# now, iterate through the subkeys and remove |# each of them (recursively) |while True: |nextKey = QueryInfoKey( handle )[0] |if not nextKey: |# if there aren't any more subkeys, delete the key at hand |try: |DeleteKey( key , subKey ) |return True |except EnvironmentError: |break |else: |# otherwise, recursively delete the subkeys |DeleteKeyAll( key , subKey + "\\" + EnumKey( handle , 0 ) ) These next two are methods that I've applied to my own version of the string object from time to time: |class newstring( str ): |def setreplace( self , set ): |""" |Do multiple replaces at once, using dictionary `set' as a legend, |where each instance of each key is to be replaced with that key's |value. |""" |if type( set ) == dict: |result = self.__str__() |for key, value in set.iteritems(): |if type( key ) == str and type( key ) == str: |result = result.replace( key , value ) |else: |raise TypeError, "All items of parameter set must be strings" |return result |else: |raise TypeError, "Parameter set must be a dictionary" | |def reverse( self ): |""" |Return a reversed copy of string. |""" |string = [ x for x in self.__str__() ] |string.reverse() |return ''.join( string ) In action: >>> string = newstring("foo bar") >>> string.reverse() 'rab oof' >>> string.setreplace( { 'f' : 'b' , 'a' : 'o' } ) 'boo bor' I actually went on to write a method that reversed an integer (inspired by an SAT question -- I had time to kill) using the newstring's reverse() method, but it's hard enough justifying having a string reverse method (though not impossible,) let alone an integer reverse method, so I left that one on my hard drive :) One more thing worth noting is that I'm not educated in the ways of standard library etiquette, so I was more or less going out on the limb doing type-checking in setreplace(). For all I know that's some sort of paradox and you're supposed to let the user feel the pain, but I did what I felt was right at the time. This is basically all about commentary and criticism, and your opinion of whether or not these deserve to be added to the library (or rather, added as a patch, I presume). Thank you all for your time :) P.S.: I have included all of the methods in this post for the sake of accessibility, and i have preceded all of the code with `|' because I am unaware of the status of google's whitespace problem. If you want to more easily copy and paste this code, I have posted it on nopaste: DeleteKeyAll:http://rafb.net/paste/results/Yh6x0598.html newstring methods: http://rafb.net/paste/results/O51kja41.html NOTES: [1] http://tinyurl.com/4dkgw [2] I'm currently unaware if _winreg is a c extension module or pure python, but I'm assuming it's C, so I don't know how possible it is to add pure python to it... [3] I made a few quick edits after I pasted it in, so please bring to my attention any errors or inconsistencies you see -- Daniel Bickett dbickett at gmail.com http://heureusement.org/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Possible additions to the standard library? (WAS: About standard library improvement)
Fredrik Lundh wrote: > your DeleteKeyAll operation would fit nicely in such an interface, but I'm not > sure it belongs in the low-level interface, and a higher-level interface > consisting > of just one helper would seem a bit odd.on the other hand, it's about time > someone wrote that "winreg" module... (hint). I wasn't aware that was even on our plate ;) Is the intent for it just to have wrappers around the _winreg functions, or were there things planned for it? -- Daniel Bickett dbickett at gmail.com http://heureusement.org/ -- http://mail.python.org/mailman/listinfo/python-list
Re: returning True, False or None
I'm seeing a consistent problem in most of these approaches. Verbalized, the logic of the OP's original code reads as such: If True is in the list *at all*, return True. Otherwise, if False is in the list *at all*, return False. Otherwise, return None. So if we used Alex Martelli's code: > for val in lst: >if val is not None: >return val > return None and the list was: [ False , False , True , None ] False would be returned upon inspection of the first index, even though True was in fact in the list. The same is true of the code of Jeremy Bowers, Steve Juranich, and Jeff Shannon. As for Raymond Hettinger, I can't even be sure ;) The original OP's code, on the other hand, inadvertently searches through the list twice where once would have sufficed, causing a needless performance pitfall. The following applies the OP's initial logic while only iterating once: >>> def boolhunt( items ): falseExists = False for item in items: if item is True: return True elif item is False and not falseExists: falseExists = True if falseExists: return False >>> l1 = [ True , None , None , False ] >>> l2 = [ None , False , False , None ] >>> l3 = [ False , True , True , True ] >>> boolhunt( l1 ) True >>> boolhunt( l2 ) False >>> boolhunt( l3 ) True It isn't elegant or clever, but it gets the job done :) -- Daniel Bickett dbickett at gmail.com http://heureusement.org/ -- http://mail.python.org/mailman/listinfo/python-list
Re: returning True, False or None
Jeremy Bowers wrote: > The defense rests, your honor. :-) I stand corrected :-) My apologies. -- Daniel Bickett dbickett at gmail.com http://heureusement.org/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Alternative to standard C "for"
[EMAIL PROTECTED] wrote: > Are there other good ways for this simple problem? Generators? Very interesting problem :) That never occured to me. To prevent python from loading that entire list into memory, one could, as you suggested, use a generator: >>> def genrange( start , stop , step = 1 ): while start < stop: yield start start += step >>> for x in range( 5 ): print "%s " % str( x ), 0 1 2 3 4 >>> for x in genrange( 0 , 5 ): print "%s " % str( x ), 0 1 2 3 4 -- Daniel Bickett dbickett at gmail.com http://heureusement.org/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Alternative to standard C "for"
Paul Rubin wrote: > use xrange instead of range. Woops ;) I wasn't aware such a function existed. apologies-for-reinventing-the-wheel-ly y'rs, -- Daniel Bickett dbickett at gmail.com http://heureusement.org/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Which IDE supports python and wxpython?
I know of two: Boa Constructor: http://boa-constructor.sourceforge.net/ wxGlade: http://wxglade.sourceforge.net/ -- Daniel Bickett dbickett at gmail.com http://heureusement.org/ -- http://mail.python.org/mailman/listinfo/python-list
Definitive documentation on newstyle classes? (WAS: Pickling and inheritance are making me hurt)
I was reading the "Pickling and inheritance are making me hurt" thread, and the latest suggestion (as of this posting) was to do with the __setstate__ and __getstate__ methods. They caught my attention because I hadn't encountered them before, and it reminded me that in the past I've never been able to very good, definitive documentation on newstyle classes. Googling for it gives little python tutorials on various sites, and even searching this newsgroup returns very specific questions, as a rule. Alas, the question: Does there exist a page that enumerates all of the features of the newstyle classes, and explains what they all do? If so, can anyone provide me with such a link? Thanks :-) -- Daniel Bickett dbickett at gmail.com http://heureusement.org/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Definitive documentation on newstyle classes? (WAS: Pickling and inheritance are making me hurt)
Bruno Desthuilliers wrote: > Well, the fact is that __[get|set]state__() have nothing to do with new > style classes, but with the Pickle protocol: > http://www.python.org/doc/2.3.4/lib/pickle-inst.html Thank you for pointing that out, but all the same ;) -- Daniel Bickett dbickett at gmail.com http://heureusement.org/ -- http://mail.python.org/mailman/listinfo/python-list
Yet Another Python Web Programming Question
This post started as an incredibly long winded essay, but halfway through I decided that was a terribly bad idea, so I've trimmed it down dramatically, and put it in the third person (for humor's sake). Once upon a time a boy named Hypothetical programmed in PHP and made many a web application. It would be a long while before he would find Python, and since that time he would have no desire to ever touch PHP again. He would, however, be compelled to write a web application again, but in Python now, of course. He would read the documentation of Nevow, Zope, and Quixote, and would find none of them to his liking because: * They had a learning curve, and he was not at all interested, being eager to fulfill his new idea for the web app. It was his opinion that web programming should feel no different from desktop programming. * They required installation (as opposed to, simply, the placement of modules), whereas the only pythonic freedom he had on his hosting was a folder in his /home/ dir that was in the python system path. * See the first point, over and over again. All he really wanted was something that managed input (i.e. get, post) and output (i.e. headers: "Content-type:"), and he would be satisfied, because he wasn't an extravagant programmer even when he used PHP. Python using CGI, for example, was enough for him until he started getting 500 errors that he wasn't sure how to fix. He is also interested in some opinions on the best/most carefree way of interfacing with MySQL databases. Thanks for your time, -- Daniel Bickett dbickett at gmail.com http://heureusement.org/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Yet Another Python Web Programming Question
I neglected to mention an important fact, and that is the fact that I am limited to Apache, which elminates several suggestions (that are appreciated none-the-less). -- Daniel Bickett dbickett at gmail.com http://heureusement.org/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Safest manner to extend search path for modules?
On 25 Jul 2005 21:50:20 -0700, Joseph Turian <[EMAIL PROTECTED]> wrote: > What is the safest manner to extend search path for modules, minimizing > the likelihood of shooting oneself in the foot? Put a .pth file in a directoy already on the system path. http://bob.pythonmac.org/archives/2005/02/06/using-pth-files-for-python-development/ -- Daniel Bickett dbickett at gmail.com http://heureusement.org/ -- http://mail.python.org/mailman/listinfo/python-list
Re: pygame.mixer.music not playing
Marian Aldenhövel wrote: > Maybe some way to remote control another player would be in order. Leave it > to software that is specialized and all. But I would want something that runs > on Windows and Linux which narrows down my options. Perhaps Zinf? http://www.zinf.org/ -- Daniel Bickett dbickett at gmail.com http://heureusement.org/ -- http://mail.python.org/mailman/listinfo/python-list
Re: [NooB] Using Escape Sesquences with Strings...
administrata wrote: > print \trock Your problem lies in this line. The escape sequence \t is not a variable, so to speak. It is just that, an escape sequence, so it must be located inside of a string: print "\t" + rock -- Daniel Bickett dbickett at gmail.com http://heureusement.org/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Safe string escaping?
There is very likely a more reasonable solution than this, but it was the first one that came to mind: IDLE 1.0.3 >>> string = "foo\\n\\0" >>> string = string.replace( "\\n" , "\n" ) >>> string = string.replace( "\\0" , "\0" ) >>> string 'foo\n\x00' >>> print string foo Hope this helps. -- Daniel Bickett dbickett at gmail.com http://heureusement.org/ -- http://mail.python.org/mailman/listinfo/python-list
Re: quick question
If you simply wanted to get rid of quotes entirely, you could use: "\"Hello!\"".replace( "\"" , "" ) However, since you only want the beginning and ending quotes removed: >>> string = "\"If thou wert my fool, nuncle...\"" >>> print string "If thou wert my fool, nuncle..." >>> if string.startswith("\""): string = string[1:] >>> print string If thou wert my fool, nuncle..." >>> if string.endswith("\""): string = string[:-1] >>> print string If thou wert my fool, nuncle... Does this suffice? -- Daniel Bickett dbickett at gmail.com http://heureusement.org/ -- http://mail.python.org/mailman/listinfo/python-list
Re: pickle and py2exe
> While looking into this, I had seen some mention of protocol option in > pickle. I > hadnt specified anything for protocol, so it defaults to 0 though I dont know > what that is. Its my first time using pickle and second with py2exe. If you think this might be your problem, then it would be best to specify your protocol using the variable HIGHEST_PROTOCOL as defined in the Pickle module. However, if this does fix your problem, keep in mind it won't fix the problem for earlier pickle versions. Bickett -- http://mail.python.org/mailman/listinfo/python-list
Re: installing wxPython on Linux and Windows
> I have no way to build it on Windows though, as I don't have Visual C++ > 7.1, for that we must wait for Robin Dunn. Would it be too difficult of a task to try getting the build working with Dev-C++? That way those without enough incentive for purchasing Visual C++ (in excess of $100, I believe) could build it. Forgive my ignorance if this has already been considered ;) Bickett -- http://mail.python.org/mailman/listinfo/python-list
Skinnable/Stylable windows in wxPython?
I'm very near finishing a medium to large scale application, so I'm getting a head start on the GUI side of things. Part of the concept is to give as much attention to presentation as functionality, and something I really wanted to do was transcend the basic window and style it to an extent, To be honest, the wxPopupWindow was basically what I was looking for, but it isn't available on Mac, eliminating that possibility. wxShapedWindow would have sufficed, but it uses a more recent version wxPython that I've chosen not to install for various dependency issues, so I really can't use that. I've combed through the demo countless times, but I really can't find any answers. So, the question: what is the best way (or is there one, rather) to achieve an end comparable to skinning my wx windows? Thanks for your help, Daniel Bickett -- http://mail.python.org/mailman/listinfo/python-list
Re: Best book on Python?
> If the focus is only on printed books and there is some experience with > programming, "programming python" by Lutz from O'Reilly might be a good > one. I saw that book today at Barnes and Noble, and found it curiously ironic that it had a very large mouse on the cover :) But maybe that's just me. Daniel Bickett -- http://mail.python.org/mailman/listinfo/python-list
Re: Skinnable/Stylable windows in wxPython?
Solution found! For the future reference of anyone searching: The wxPopupWindow can easily be achieved by creating a wxMiniFrame with absolutely no styles ('0', explicitly). The features of the wxPopupWindow in the wxPython demo don't come with it, they were manually added in the demo code, so simply adapting the code should suffice. Even as I was typing this message, I realized that this was probably exactly what wxPopupWindow was, and suddenly this clicked because I remembered seeing in the wxWindows help files that all of the styles for wxMiniFrame only worked on Windows and Motif, and it made a point to note that they didn't work on GTK. So I tried a snippet of code[1] on my Mac (until then I had been working on a windows box) and, to my surprise, it worked perfectly. This raises some questions for me, like why, if the wxPython package is going to have the wxPopupWindow feature, they don't simply inherit wxMiniFrame like I did (quite literally, it looks /exactly/ the same as a wxPopupWindow). Not only would this make it more multi-platform (I have no access to a GTK machine so I don't know if this works. Could someone please check?), but it would be more useful, considering the fact that it is in fact a frame, and wouldn't have the problems that M.E.Farmer outlined above regarding controls on wxPopupWindows. Regardless, I'm happy that I've uncovered the answer, and I hope this helps someone else in the same situation :) Daniel Bickett NOTES: [1] from wxPython.wx import wxMiniFrame, wxPySimpleApp app = wxPySimpleApp() frame = wxMiniFrame( None , -1 , '' , size = ( 300 , 150 ) , style = 0 ) frame.Show() app.MainLoop() -- http://mail.python.org/mailman/listinfo/python-list
Re: Skinnable/Stylable windows in wxPython?
> > Not only would this make it more multi-platform (I have no access to > > a GTK machine so I don't know if this works. Could someone please > > check?) > > Looks like it works (I had to change frame.Show() to frame.Show(1) > though, but that could be because it's an old version). No, I think that was a slip on my part when copying the code from one screen to the next :) > One odd thing > though: the Windows version doesn't react to clicking or dragging the > mouse, which seems to be the expected behavior. I noted in my second post that the functionality of the window (clicking and dragging et al) was, even in the wxPopupWindow demo, implemented by using the EVT macros. Copied from the demo, the code is as follows: def OnMouseLeftDown(self, evt): self.ldPos = evt.GetEventObject().ClientToScreen(evt.GetPosition()) self.wPos = self.GetPosition() self.CaptureMouse() def OnMouseMotion(self, evt): if evt.Dragging() and evt.LeftIsDown(): dPos = evt.GetEventObject().ClientToScreen(evt.GetPosition()) nPos = (self.wPos.x + (dPos.x - self.ldPos.x), self.wPos.y + (dPos.y - self.ldPos.y)) self.Move(nPos) def OnMouseLeftUp(self, evt): self.ReleaseMouse() def OnRightUp(self, evt): self.Show(False) self.Destroy() > The GTK version can be > moved by dragging the mouse; even just clicking the mouse moves the > window somewhat down and to the left. That's interesting... I wonder if using those methods would conflict at all. Also, while I'm on that note, when double clicking on the resulting window (after binding those events), double click causes a non-fatal, yet annoying, traceback saying that "the mouse could not be released because it has not yet been caught blah blah", so I just wrapped the contents of OnMouseLeftUp in a try..except..pass. Daniel Bickett -- http://mail.python.org/mailman/listinfo/python-list
Re: IDLE problem :-(
This is less of a bug and more of an inconvenience, on your part. It happens because IDLE has a tailored shell allowing your cursor to venture beyond the prompt, and across the text that the window consists of (much like a loaded file in a text editor) Thus, the beginning of each line is not limited to the beginning of the prompt, and 'home' sends you beyond it. The only 'work around', so to speak, I can think to recommend is simply using a different shell for your purposes, i.e. python.exe (on windows). Daniel Bickett On Sat, 25 Dec 2004 09:55:10 +1030, Ishwor <[EMAIL PROTECTED]> wrote: > I don't know if this has been a problem with other people using IDLE > but when i press the home key then the cursor jumps to the beginning > of the line and not after the prompt. If google prints the right > indentation then here how i want the IDLE prompt to work -> > > |>>> |(r,b,g).__class__ > ^ ^ > ^ ^-> want cursor here instead. > cursor > goes > here > > Any work around?? > Thank you. > -- > cheers, > Ishwor Gurung > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: need some help with threading module...
I found your object-oriented approach, while admirable, a little muddled. So rather than modify your code, I simply took the paragraph you wrote describing the scenario and wrote my own.[1] Instead of having the Controller query the Subject (not exactly plausible), I had it wait for a signal (threading.Event) as set by the Subject. You could also have it query a queue, as that is a generally accepted and thread-safe object to use, but for this purpose I chose an event and a global variable. (I'm aware that some would look down on this, but I didn't see a problem, as it was only modified by one thread amd printed by the other.) Daniel Bickett NOTES: [1] Google killed my whitespace (as spaces _and_ tabs...) in the previews, so I pasted it on Nopaste: http://rafb.net/paste/results/KilM6t70.html -- http://mail.python.org/mailman/listinfo/python-list
Re: Tricks to install/run Python on Windows ?
While I don't have any solutions for your problems outlined above, you certainly don't need to limit yourself to the "tools" you've been exposed to (nor should you make a generalization based on them). If PythonWin is giving you that much trouble, you could optionally use a different editor. I use DrPython[1] from time to time. Also, when you say that you had to reinstall your "machine", surely you didn't mean your operating system? I don't think it would be too difficult to find a list of registry keys that Python uses, (or, indeed, inquiring towards the values of those that 2.4 uses and manually adding them) but I seriously doubt it involves any that your system's stability balances on. Daniel Bickett NOTES: [1] http://drpython.sf.net/ On Sun, 26 Dec 2004 19:43:24 +0100, StepH <[EMAIL PROTECTED]> wrote: > Hi, > > I'm new to Python. I'm working under XP, and I've alot of prob. (not > with the langage itself, but with the tools): > > I've install Pyhton 2.4 in C:\Python24, using the .msi windows installer. > Then, I've install "PythonWin" (the last build-203). > > I'll try to summerize my prob.: > > 1./ The PythonWin IDE is not stable at all. Sometimes it exit without > reason, or don't stop on breakpoint, etc... Are some of you aware of > bugs in the last PyhtonWin IDE release ? I've to open the TaskManager. > AT some point, i'm not able to (p.e.) open a file under it !!! > > 2./ I've try to download Komode (he 3.1 personnal). I've also prob. > with it ! Also, the breakpoint seems to not always work... > > 3./ So, i've try to use the command line, but i've to manualy change the > code page od my dos box from 437 to 1252 (i'm live in belgium). And > i've not try how to do that permanently ! > > 4./ Before, I had Python23 and it seems that when unstalling it, all the > keys in the registry are not removed at all. When i've install the 2.4, > I had a mismatch which force me to complety re-install the machine (I'm > not an expert of the registry)... > > 5./ Installing komodo seems to "block" pythonwinIDE completly... > > What's wrong ? Python seems terific, but the tools... > > So... maybe i've to try BlackAdder ? > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Event-Driven Woes: making wxPython and Twisted work together
Hello, I am writing an application using two event-driven libraries: wxPython, and twisted. The first problem I encountered in the program is the confliction between the two all-consuming methods of the two libraries: app.MainLoop, and reactor.run. Additionally, the fact that wxPython was to receive requests from the twisted framework as well as the end user seemed to be simply asking for trouble. My initial solution was, naturally, the wxPython support inside of the twisted framework. However, it has been documented by the author that the support is unstable at this time, and should not be used in full-scale applications. I instinctively turned to threading, however on top of the trouble that this has caused on its own, it has repeatedly been suggested by the twisted IRC channel not to do this. After much dwelling on the issue, I have resolved to turn to c.l.py, to see if anyone had a solution to this problem. Any help would be very much appreciated, Daniel Bickett -- http://mail.python.org/mailman/listinfo/python-list
Re: System bell
Trent Mick wrote: > I suspect that you are misinterpreting failure as success here. This is > probably only resulting in a bell from the shell when it complains that > it doesn't know of any command called "\a" to run. Contrarily, \a is in fact the escape sequence for, as the OP put it, the system "bell" . I can only speak as a Windows user however; I'm unaware of the prevalence of this feature across operating systems. -- Daniel Bickett dbickett at gmail.com http://heureusement.org/ -- http://mail.python.org/mailman/listinfo/python-list
Re: very simple tkinter demo program
max(01)* wrote: > > i also used try-except for checking for invalid files. > [...] > > i'd like to hear your suggestions and comments for improving it. Without actually reading your code, if I may, I would suggest using the os module to confirm that a file exists rather than waiting for an error to be thrown. >>> userSuppliedPath = "/this/path/does/not/exist/" >>> import os.path >>> if not os.path.isfile( userSuppliedPath ): # this has the twofold purpose of: # 1) making sure the path exists, and # 2) making sure the path is a file print "Error!" Error! >>> -- Daniel Bickett dbickett at gmail.com http://heureusement.org/ -- http://mail.python.org/mailman/listinfo/python-list
Re: passing arguments
An even better way would be to use the optparse module.-- Daniel Bickettdbickett at gmail.comhttp://heureusement.org/ -- http://mail.python.org/mailman/listinfo/python-list
ANN: Concurrence 0.0.5.2 Alpha
Concurrence is a networked file editing program that enables multiple people to modify a document simultaneously. It is written entirely in python, and uses the wxPython library for the GUI and the Twisted library for networking. This marks the release of Concurrence 0.0.5.2 Alpha, and it can be found at the following link: http://sourceforge.net/projects/concurrence/ It has been in development for just under three weeks now, and for it's age it has quite a large feature set, including: * All modifications that occur in every client are sent to the server (then to the other clients) real time and on a first-come, first-serve basis * The lines on which the carets of the other users in a given file rest are highlighted * A chat feature is included in each document window to eliminate the necessity of a third party messenger client, while improving the coordination of document editing * All of the features expected of one's day-to-day text editor have been implemented * Python files are automatically detected and the syntax is highlighted (in the near future this feature may be toggled at will) The project can be discussed on the #concurrence channel at irc.freenode.net, or on the mailing list [EMAIL PROTECTED] -- Daniel Bickett dbickett at gmail.com http://heureusement.org/ -- http://mail.python.org/mailman/listinfo/python-list
Prevalent Python/Django academic software
Is anyone working on any software at present, using django or python in general, which serves various academic/course functions, or else that of student-instructor arbitration? A popular example which my university uses is the "Blackboard Academic Suite" (wpedia:Blackboard Inc.), which offers a wide range of course functionality (prof announcements, forums, content management, grades, file sharing, etc.) A preliminary search on Google didn't turn up much. I'm interested in developing this sort of application if there aren't any at large, or perhaps even if there are. I'm equally interested in looking into existing options. Thanks, dbickett -- http://mail.python.org/mailman/listinfo/python-list
Re: Prevalent Python/Django academic software
On Aug 21, 7:39 am, [EMAIL PROTECTED] (Cameron Laird) wrote: > I don't understand the question. YES, there are MANY > Python-based applications doing service in a variety > of academic contexts. No, there is no central index > of all such programs. Sorry if I was unclear. If there are many such applications, very good! I hope to use them. Certainly there seems not to be any sort of central index, which was why I hoped to hear the opinion of various c.l.py users. Tobias: No, money is not one of my objectives. Neither is paying for software, however, which is why I wondered if anyone was currently developing any relevant, open-source applications. I had not heard the name Moodle, thank you. dbickett -- http://mail.python.org/mailman/listinfo/python-list
Re: python tutorial: popular/informative Python sites ?
I read c.l.py and (the Unofficial) Planet Python (and that's it), so perhaps that's an appropriate suggestion: http://www.planetpython.org/ (From the Starship: "If you want to join the crew, we only require your PSA membership....") -- Daniel Bickett dbickett at gmail dot com http://heureusement.org/ -- http://mail.python.org/mailman/listinfo/python-list
ANN: pyISBNdb 0.1
Package: pyISBNdb Version: 0.1 Pre-Alpha Author: Daniel Bickett <[EMAIL PROTECTED]> Website: http://heureusement.org/programming/pyISBNdb/ ABOUT: pyISBNdb is a library that serves as a pythonic interface with the ISBNdb.com API, a service that provides a vast database of book information free of charge. This package is an attempt to completely abstract information retrieval from ISBNdb. USAGE: Currently pyISBNdb can retrieve books by their ISBN number, title, author, and more, in an abstract manner. DOCUMENTATION: * HOWTO document complete with annotated code snippets: http://heureusement.infogami.com/pyISBNdb_HOWTO * What pyISBNdb doesn't do yet, but should: http://heureusement.infogami.com/pyISBNdb_TODO * Pudge-generated source documentation: http://heureusement.org/programming/pyISBNdb/ DOWNLOAD: * Download, extract, and install (requires elementtree): http://heureusement.org/programming/pyISBNdb/pyISBNdb-0.1.tar.gz * If you have setuptools: easy_install pyISBNdb Try it, tell me what you think, and enjoy! -- Daniel Bickett dbickett at gmail dot com http://heureusement.org/ -- http://mail.python.org/mailman/listinfo/python-list