Re:OT - people eaters - was: An assessment of the Unicode standard
> On Friday 18 September 2009 06:39:57 Dennis Lee Bieber wrote: > >> A one-eyed, one-horned, flying purple people eater? >> >> {Which brings up the confusing question... Is the eater purple, or does >> it eat purple people (which is why it is so rare... it only eats people >> caught in the last stages of suffocation )} > > Snap (sort of). > Does anybody know where the concept of the purple people eater comes from? > I mean is there a children's book or something? > > - Hendrik Shep Wooley ( 1958 ) http://www.youtube.com/watch?v=X9H_cI_WCnE -- Stanley C. Kitching Human Being Phoenix, Arizona -- http://mail.python.org/mailman/listinfo/python-list
Re: Please help with regular expression finding multiple floats
> I have text that looks like the following > (but all in one string with '\n' separating the lines): > > > I want to capture the two or three floating point numbers in each line > and store them in a tuple. > > I have the regular expression pattern > Jeremy For a non-regular-expression solution you might consider something simlar to the following s = '''\ 1.E-08 1.58024E-06 0.0048 1.E-07 2.98403E-05 0.0018 1.E-06 8.85470E-06 0.0026 1.E-05 6.08120E-06 0.0032 1.E-03 1.61817E-05 0.0022 1.E+00 8.34460E-05 0.0014 2.E+00 2.31616E-05 0.0017 5.E+00 2.42717E-05 0.0017 total 1.93417E-04 0.0012''' l1 = s.split( '\n' ) l2 = [ ] for this_row in l1[ : -1 ] : temp = this_row.strip().split() l2.append( [ float( x ) for x in temp ] ) last = l1[ -1 ].strip().split()[ 1 : ] l2.append( [ float( x ) for x in last ] ) print for this_row in l2 : if len( this_row ) > 2 : x , y , z = this_row print '%5.4e %5.4e %5.4e ' % ( x , y , z ) else : x , y = this_row print '%5.4e %5.4e ' % ( x , y ) -- Stanley C. Kitching Human Being Phoenix, Arizona -- http://mail.python.org/mailman/listinfo/python-list
Re: list comprehension problem
> > There are an infinite number of empty sets > that differ according to their construction: > > The set of all fire-breathing mammals. > Apparently, you have never been a witness to someone who recently ingested one of Cousin Chuy's Super-Burritos .. :-) -- Stanley C. Kitching Human Being Phoenix, Arizona -- http://mail.python.org/mailman/listinfo/python-list
Re: spring effect in Python
> > I've problem to find something that give that physical effect > ( like a spring). > > Any idea? You may find VPython useful for simulating physical effects http://www.vpython.org/ Examples including a couple that are spring-related http://matterandinteractions.org/Content/Materials/programs1.html -- Stanley C. Kitching Human Being Phoenix, Arizona -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie question about scrapy tutorial
> i have no idea what scrapy is > http://scrapy.org/ Scrapy is a fast high-level screen scraping and web crawling framework, used to crawl websites and extract structured data from their pages. It can be used for a wide range of purposes, from data mining to monitoring and automated testing. Also, previously unknown to me before google-izing -- Stanley C. Kitching Human Being Phoenix, Arizona -- http://mail.python.org/mailman/listinfo/python-list
Re: sys.stdout is not flushed
>> >> You misunderstand what "flush" means. It is not about >> clearing the screen, or the line. >> >> Try printing >> >> stdout.write('\r-->%d') >> >> Diez > > > But there is still a problem. When you use control character '\r', > you actually move to the head of the current buffer line and > overwrite it. > > So if I use this way: > for i in range(100, 0,-1) > > The tail of the buffer is not overwrote. > The following version works ok for me using python2.5 under debian linux import sys import time print for n in range( 11 ) : sys.stdout.write( '\rWorking > %d ' % n ) sys.stdout.flush() time.sleep( 1 ) else : print "\n" print "That's all, folks !" print "Adios ... " -- Stanley C. Kitching Human Being Phoenix, Arizona -- http://mail.python.org/mailman/listinfo/python-list
Re: How do I correctly download Wikipedia pages?
> I'm trying to scrape a Wikipedia page from Python. > On occasion I use a program under Debian Linux called wikipedia2text that is very handy for downloading wikipedia pages as plain text files Description: displays Wikipedia articles on the command line This script fetches Wikipedia articles (currently supports around 30 Wikipedia languages) and displays them as plain text in a pager or just sends the text to standard out. Alternatively it opens the Wikipedia article in a (possibly GUI) web browser or just shows the URL of the appropriate Wikipedia article. Example directed through the lynx browser wp2t -b lynx gorilla > gorilla.txt -- Stanley C. Kitching Human Being Phoenix, Arizona -- http://mail.python.org/mailman/listinfo/python-list
Re: Dynamic text color
> John Posner wrote > > I've posted a complete solution > > http://cl1p.net/jjp_dynamic_text_color/. John Thanks for posting your solution to Dave McCormick's query about colorizing text I was not familiar with the re.finditer method for searching strings or with using tags in Tkinter Text widgets to change text attributes Instead of binding the Text widget to events to call the colorizer on each key-stroke, I used a button callback http://cl1p.net/cs_static_text_color This provides a static one-shot colorization after all of the text is entered and should save a few cpu cycles although it's not as nifty as the dynamic process I used a dictionary instead of a list for position data and also added a { term : color } dictionary so that words other than color names can be hi-lighted -- Stanley C. Kitching Human Being Phoenix, Arizona -- http://mail.python.org/mailman/listinfo/python-list
Re: PIL show() not working for 2nd pic
> I am using PIL for image processing in ubuntu 9.04. When i give two > im.show() commands for two different images, the second image is not > displayed (eye of gnome is the display program). It says no such file > or directory. Any ideas? Suresh I also had problems with show() when using eye of gnome as the image viewer with your code but no problems using the display viewer from the imagemagick package im.show( command = 'eog' )#problems im.show( command = 'display' )# no problems # -- #!/usr/bin/python ''' NewsGroup comp.lang.python Subject .. PIL show() not working for 2nd pic Date . 2010-01-07 Post_By .. suresh.amritapuri Edit_By .. Stanley C. Kitching ''' import math import Image list_source = [ 'image/beach.tif' , 'image/colors.tif' ] list_target = [ ] def neg( x ) : return 255 - 1 - x def logtr( x ) : y = math.log( 1 + x , 10 ) print y return y * 100 for this_image in list_source : im_source = Image.open( this_image ) im_neg = im_source.point( neg ) im_logtr = im_source.point( logtr ) list_target.append( im_source ) list_target.append( im_neg ) list_target.append( im_logtr ) for this_image in list_target : this_image.show( command = 'display' ) # -- -- Stanley C. Kitching Human Being Phoenix, Arizona -- http://mail.python.org/mailman/listinfo/python-list
Re: PyGTK and skins?
> Is GTK/PyGTK able to support application-based (rather than os-based) > skins? I.e. round corners, redesigned scrollbars, arbitrarily shaped > buttons and so on? > Manu You might try the pygtk mailing list available via the news.gmane.org server gmane.comp.gnome.gtk+.python -- Stanley C. Kitching Human Being Phoenix, Arizona -- http://mail.python.org/mailman/listinfo/python-list
Re: Social problems of Python doc [was Re: Python docs disappointing]
> FWIW, I support the idea the regular docs incorporating links > to freely editable wiki pages. That will at least make it > easier for people to make changes or add notes. > > That being said, I would like to add a few thoughts about the > current process. ISTM that important corrections (when the > docs are clearly in error) tend to get made right away. What > is more interesting are the doc requests that get rejected > and why: > > In short, most doc requests that get rejected are requests > that didn't actually improve the documentation. > Raymond Thanks for your very eloquent and cohernt response that in my opinion helps to explain many of the problems, either real or perceived, with the Python documentation -- Stanley C. Kitching Human Being Phoenix, Arizona -- http://mail.python.org/mailman/listinfo/python-list
Re: Combining C and Python programs
> I want to write a program that will use ode for the physics > simulation, whose python bindings are outdated. So I'm writing > the physics engine in C and want to write the drawing code in > Python. What will be the best way of making those two programs > work together? THe physics engine won't have to run concurrently > with the drawing code. It will only return some position data so > they can be drawn. You might find VPython useful http://www.vpython.org/ A VPython example using ode http://vpython.wikidot.com/forum/t-109218 -- Stanley C. Kitching Human Being Phoenix, Arizona -- http://mail.python.org/mailman/listinfo/python-list
Re: IDLE: A cornicopia of mediocrity and obfuscation.
rantingrick wrote: > Terry (or anyone) can you give some link to info on "hg" > so i can study up on this topic ? http://mercurial.selenic.com/ -- Stanley C. Kitching Human Being Phoenix, Arizona -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem with giant font sizes in tkinter
Steven D'Aprano wrote: > I have a tkinter application under Python 2.6 which is shows text > in a giant font, about twenty(?) times larger than expected. > > The fonts are set using: > > titlefont = '-Adobe-Helvetica-Bold-R-Normal-*-180-*' > buttonfont = '-Adobe-Helvetica-Bold-R-Normal-*-140-*' > labelfont = '-Adobe-Helvetica-Bold-R-Normal-*-140-*' > Although I've been a linux user for several years, that type of font spec hurts my head :-) Will the more simplistic type of tuple spec not work in your tkinter application ? canv.create_text( 81 , 27 , text = ' NTSC Standard ' , fill = 'white' , font = ( 'Helvetica' , 12 , 'bold' ) ) -- Stanley C. Kitching Human Being Phoenix, Arizona -- http://mail.python.org/mailman/listinfo/python-list
Re: First time using an API...
Matty Sarro wrote: > > I am in charge of deploying a platform to allow people > across my company to access a variety of crunched metrics > using splunk. > For the convenience of others that may not be familar with splunk http://en.wikipedia.org/wiki/Splunk http://www.splunk.com/ -- Stanley C. Kitching Human Being Phoenix, Arizona -- http://mail.python.org/mailman/listinfo/python-list
Re: Suggested editor for wxPython on Ubuntu
usenet.digi...@spamgourmet.com wrote: > Ok, I've decided that Boa Constructor is too buggy to be useful > under Ubuntu, so what would the team recommend for developing > Python projects with wxPython? Preferably with some GUI design capability? perhaps python-wxglade GUI designer written in Python with wxPython wxGlade is a GUI designer written in Python with the popular GUI toolkit wxPython, that helps you create wxWidgets/wxPython user interfaces. At the moment it can generate Python, C++ and XRC (wxWidgets' XML resources) code. -- Stanley C. Kitching Human Being Phoenix, Arizona -- http://mail.python.org/mailman/listinfo/python-list
Re: Another nntplib Question
> > I've run into another snag with nntplib > Anthony For inspiration you might take a look at a nice news client written in python XPN (X Python Newsreader) is a graphical newsreader written in Python with the GTK+ toolkit. http://xpn.altervista.org/index-en.html -- Stanley C. Kitching Human Being Phoenix, Arizona -- http://mail.python.org/mailman/listinfo/python-list
Re: Getting pyparsing to backtrack
> I'm working on street address parsing again, > and I'm trying to deal with some of the harder cases. > For yet another test case my actual address includes ... East South Mountain Avenue Sometimes written as ... E. South Mtn Ave -- Stanley C. Kitching Human Being Phoenix, Arizona -- http://mail.python.org/mailman/listinfo/python-list
Re: python styles: why Use spaces around arithmetic operators?
> Parentheses are punctuation. Why not leave spaces around the commas as well, > to be consistent? > > myTuple = ( 1 , 2 , 3 , 4 , 5 ) Personally, I do use this particular style with commas as I find it more readable to my old and tired eyes Mandate m o r e whitespace .... :-) -- Stanley C. Kitching Human Being Phoenix, Arizona -- http://mail.python.org/mailman/listinfo/python-list
Re: palindrome iteration
> To deal with "real" palindromes such as, "Madam, I'm Adam," > you should probably strip all spaces and punctuation: > > # untested > pat = re.compile(r'[a-z]') > def is_palindrome(s): > letters = pat.findall(s.lower()) > return letters == reversed(letters) Using python 2.5 the above solution always returned False for me until the reversed( letters ) iterator was explicitly coerced into a list return letters == list( reversed( letters ) ) -- Stanley C. Kitching Human Being Phoenix, Arizona -- http://mail.python.org/mailman/listinfo/python-list
Re: problem in Gasp !
n.a.s wrote: > I want to ask about graphics using Gasp .Attached is exercise 10 > (houses at night) <http://openbookproject.net/thinkCSpy/ch04.html#exercises> > > if i call the draw_house function once it will work properly ,but more than > one call,windows and doors disappear from some houses . > > Any one can advice? A working version that runs using Python2.6 under Debian 6 Squeeze can be found at http://csphx.net/python/house.tar.bz A screenshot of the result is included in that archive http://csphx.net/image/houses_10.png -- Stanley C. Kitching Human Being Phoenix, Arizona -- http://mail.python.org/mailman/listinfo/python-list
Re: SQLite is quite SQL compliant
Ravi wrote: > The documentation of the sqlite module > at http://docs.python.org/library/sqlite3.html > says: > > "... > allows accessing the database > using a nonstandard variant of the SQL..." > > But if you see SQLite website they clearly say > at http://sqlite.org/omitted.html that only > very few of the SQL is not implemented. > > I think docs should clarify on that. > > Many users might be scared of using SQLite > just because of this. SQLite is very widely used in many different contexts You might check the related wikipedia article and scroll down to the Adoption section for a brief list of some well-known users .... http://en.wikipedia.org/wiki/Sqlite -- Stanley C. Kitching Human Being Phoenix, Arizona -- http://mail.python.org/mailman/listinfo/python-list
Re: Can a low-level programmer learn OOP?
> > 2. Must be cross-platform: Linux + Windows. > > This factor can have a big impact on whether it is necessary > to learn a new language, or stick with C. > > If my platform was only Linux I could just learn GTK > and be done with it. > Chris The Python bindings for GTK in the form of a mechanism deemed PyGTK are also available for Windows and provide a diverse set of widgets for building GUI applications http://www.pygtk.org The Applications page lists a rather large and wide variety of the types of programs that have been built using PyGTK http://www.pygtk.org/applications.html There is plenty of decent documentation available and a dedicated newsgroup for assistance if needed -- Stanley C. Kitching Human Being Phoenix, Arizona == Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups = East and West-Coast Server Farms - Total Privacy via Encryption = -- http://mail.python.org/mailman/listinfo/python-list
Re: access the name of my method inside it
>> > def my_method(): >> > >> > # do something >> >> > # how do I get the name of this method >> > # which is my_method here? >> >> Why do you need this? There are ways but those >> are not really good for production code. >> > > I am going to use this in Django. I am trying to implement > a permission here, where in the database store the methods > that the user are allowed to execute. > > for example if the method is def create_event() : > the method will look for create_event in the database > to see if it allow to be execute. james Perhaps a simple-minded hard-coded solution might work def permission_check( name ) : permission = DB.permission_check( name ) if not permission : print 'No Execute Permission for %s ' % name sys.exit( -1 ) def my_method() : permission_check( "my_method" ) -- Stanley C. Kitching Human Being Phoenix, Arizona == Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups = East and West-Coast Server Farms - Total Privacy via Encryption = -- http://mail.python.org/mailman/listinfo/python-list
Re: Efficient Rank Ordering of Nested Lists
> > "beginner"'s advice to use a dictionary is also good > and may turn out to be faster, just because dicts are > SO fast in Python -- but you need to try and measure > both alternatives. > > One way to use a dict ( warning, untested code ) : def rank_list( single_list ) : d = { } for i , item in reversed( enumerate( sorted( single_list ) ) ) : d[ item ] = i return [ d[ item ] for item in single_list ] Alex I tested it but I don't know how to fix it :-) Both Pablo's original version and Neil's version work but I get the following traceback from your version Traceback (most recent call last): File "list_nested_rank.py", line 100, in test_01( list_source ) File "list_nested_rank.py", line 87, in test_01 list_print( this_func( list_source ) ) File "list_nested_rank.py", line 62, in rank_lists_02 return map( rank_list , nested_list ) File "list_nested_rank.py", line 56, in rank_list for i , item in reversed( enumerate( sorted( single_list ) ) ) : TypeError: argument to reversed() must be a sequence -- Stanley C. Kitching Human Being Phoenix, Arizona == Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups = East and West-Coast Server Farms - Total Privacy via Encryption = -- http://mail.python.org/mailman/listinfo/python-list
Re: Efficient Rank Ordering of Nested Lists
> Cousin Stanley <[EMAIL PROTECTED]> wrote: >... >> for i , item in reversed( enumerate( sorted( single_list ) ) ) : >... >> TypeError: argument to reversed() must be a sequence > > Oops, right. Well then, > > aux_seq = list(enumerate(sorted(single_list))) > for i, item in reversed(aux_seq): ... Alex That fixed it. Thanks -- Stanley C. Kitching Human Being Phoenix, Arizona == Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups = East and West-Coast Server Farms - Total Privacy via Encryption = -- http://mail.python.org/mailman/listinfo/python-list
Re: subexpressions
> > After years of discussion, Guido has decided > to leave lambda alone for 3.0. > > It will not be neither expanded, nor removed, nor renamed. But it still will be as ugh, ugh, ugh-lee as a mule walking backwards . ;-) -- Stanley C. Kitching Human Being Phoenix, Arizona == Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups = East and West-Coast Server Farms - Total Privacy via Encryption = -- http://mail.python.org/mailman/listinfo/python-list
Re: Who uses Python?
> I mean other than sysadmins, programmers, and web-site developers? > You might try the Python Success Stories for a good source for finding a wide variety of Python users and usage http://pythonology.org/success -- Stanley C. Kitching Human Being Phoenix, Arizona == Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups = East and West-Coast Server Farms - Total Privacy via Encryption = -- http://mail.python.org/mailman/listinfo/python-list
Re: Python's "only one way to do it" philosophy isn't good?
> > In scheme, I believe you just have recursion. > Cousin TJR I'm a total scheme rookie starting only about 3 days ago and one of the mechanisms I went looking for was a technique for iteration Found in the scheme docs about iteration supplied via the reduce package "Iterate and reduce are extensions of named-let for writing loops that walk down one or more sequences such as the elements of a list or vector, the characters read from a port, or arithmetic series " The following scheme session illustrates a trivial example > , open reduce > > ( define ( list_loop this_list ) ( iterate loop ( ( list* this_item this_list ) ) ; iterate expression ( ( new_list '( ) ) ) ; state expression ( loop ( cons ( * 2 this_item ) new_list ) ) ; bodyexpression ( reverse new_list ) ) ) ; final expression ; no values returned > > ( define L '( 1 2 3 4 5 ) ) ; no values returned > ( define result_i ( list_loop L ) ) ; no values returned > > result_i '(2 4 6 8 10) > However, just as in Python the map function might be both easier to code and more readable in many cases > ( define ( x2 n ) ( * 2 n ) ) ; no values returned > > ( define result_m ( map x2 L ) ) ; no values returned > > result_m '(2 4 6 8 10) Note No lambdas in my scheme code either ;-) -- Stanley C. Kitching Human Being Phoenix, Arizona == Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups = East and West-Coast Server Farms - Total Privacy via Encryption = -- http://mail.python.org/mailman/listinfo/python-list
Re: Cretins.
> On Thu, 14 Jun 2007 09:32:10 +1000, Ben Finney wrote: > >> "Dr. Pastor" <[EMAIL PROTECTED]> writes: >> >>> Please do not do business with those cretins >>> who without authorization attaching [spam footers] >> >> Indeed. The cost of Usenet access should not be translated >> to spam on messages. > > Out of curiosity, who are these cretins ? NewsFeeds.Com I don't do business with them either But my ISP does, apparently farming out their news service I complained about the addition of spammed footers by NewsFeeds.Com to my ISP several years back but it didn't help at all My news client is configured to use my ISP's news server but it gets spun off to NewsFeeds.Com Anything below Phoenix, Arizona in my signature was not added by me but by NewsFeeds.Com -- Stanley C. Kitching Human Being Phoenix, Arizona == Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups = East and West-Coast Server Farms - Total Privacy via Encryption = -- http://mail.python.org/mailman/listinfo/python-list
Re: Python's "only one way to do it" philosophy isn't good?
> Steven D'Aprano <[EMAIL PROTECTED]> wrote: >... >> > perception that, at their roots, Scheme, C and Python share one >> > philosophical underpinning (one that's extremely rare among programming >> > languages as a whole) -- an appreciation of SIMPLICITY AND UNIFORMITY as >> > language characteristics. >> >> Out of curiosity, what do you consider some of the worst offenders as far >> as overly complex and inconsistent languages go, and why? > > I think the Original Sin in that regard was PL/I: it tried to have all > the "cool features" of the three widespread languages of the time, > Cobol, Algol _and_ Fortran (and then some), because it aimed to replace > all three and become the "one programming language". As a result, it > tended to have two or more ways to perform any given task, typically > inspired by some of the existing languages, often with the addition of > new ones made out of whole cloth. > > PL/I (mostly in various subset and "extended subset" forms) was widely > used in the implementation of Multics, and I believe that the statement > in the "Spirit of C" was at least partly inspired by that experience > (just like "Unix" was originally intended as a pun on "Multics" > underscoring the drastically simpler philosophy of the new OS). Cousin Alex With regards to PL/I a phrase from an old ( 1969 ) song named "The Night They Drove Old Dixie Down" comes to mind Ya take what you need and ya leave the rest I really liked programming in pl/1 and did a little over 3 years of Multics time in San Juan, Puerto Rico http://multicians.org/site-prha.html -- Stanley C. Kitching Human Being Phoenix, Arizona == Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups = East and West-Coast Server Farms - Total Privacy via Encryption = -- http://mail.python.org/mailman/listinfo/python-list
Re: Decorating instance methods
> > Try this: > Sesame __Street__ Version ''' NewsGroup comp.lang.python Subject .. Decorating instance methods Post_By .. Alexander Draeger Reply_By . Duncan Booth Edit_By .. Stanley C. Kitching ''' def logging( f ) : def deco( self , *args , **kw ) : print "%s in da house !" % self.name return f( self , *args , **kw ) return deco class A( object ) : def __init__( self , name ) : self.name = name @logging def hello( self ) : print 'Yo, %s \n' % self.name def test_01() : print list_names = [ 'Bert' , 'Cookie Monster' , 'Count Dracula' , 'Ernie' ] list_objects = [ A( this_name ) for this_name in list_names ] for this_object in list_objects : this_object.hello() if __name__ == '__main__' : test_01() -- Stanley C. Kitching Human Being Phoenix, Arizona == Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups = East and West-Coast Server Farms - Total Privacy via Encryption = -- http://mail.python.org/mailman/listinfo/python-list
Re: What is the preferred doc extraction tool?
> > The tool is Latex plus a lot of utilities > that help make the HTML output good looking. > I spent several hours yesterday editing some html doc files for a python module that had been generated by a tool called LaTeX2HTML That was some of the ugliest and most non-standards compliant html code I have ever seen Even thetags included rgb color value styles ! Latex apparently provides nice looking printed documents but the LaTex2HTML tool surely provides a real mess for html code .... -- Stanley C. Kitching Human Being Phoenix, Arizona == Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups = East and West-Coast Server Farms - Total Privacy via Encryption = -- http://mail.python.org/mailman/listinfo/python-list
Re: Connection problems with irclib
> Hi. I've written a bot in python, > using the irclib by Joel Rosdahl. > > Works fine from my linux box at home, > but when I upload it to my shell > at veritynet.net, can't seem to get it > to connect to an irc server. > > It doesn't report any errors. > > Anyone have any idea how I might go about > at least diagnosing the problem? > > Any suggestions might help. Dropkick P For a bit of inspiration you might take a look at Supybot which is a Python-based irc bot http://supybot.com It's designed to run from your local machine and connect to a remote irc server I ran it from home 24/7 with virtually no problems at all for several months from a very modest and old Compaq box running Debian Gnu/Linux Sarge which connected via aDSL A brief description from the Debian package manager robust and user friendly Python IRC bot Supybot is a robust (it doesn't crash), user friendly (it's easy to configure) and programmer friendly (plugins are *extremely* easy to write) Python IRC bot. It aims to be an adequate replacement for most existing IRC bots. It includes a very flexible and powerful ACL system for controlling access to commands, as well as more than 50 builtin plugins providing around 400 actual commands. -- Stanley C. Kitching Human Being Phoenix, Arizona == Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups = East and West-Coast Server Farms - Total Privacy via Encryption = -- http://mail.python.org/mailman/listinfo/python-list
SQLite3__Python2.3-SQLite__Problem
It's been almost 2 years since I've done anything with Python and SQLite and I'm having some problems that I don't recall from my last usage It seems that SQLite3 data bases created at the command line and those created using the sqlite module from within Python are no longer compatible with each other using the setup that I now have I thought I remembered that the data bases created either way were always 100% transparent with each other and that I could use an SQLite3 data base either from the command line or from within Python without any problems at all I did a fair amount of Google-izing looking for related problems but didn't have much success I did find one entry in the Debian Bug Tracking System that had some discussions about SQLite3 & Python-SQLite versioning but the original errors mentioned didn't seem to be of the same nature as what i'm seeing here === Operating System Debian GNU/Linux Sarge python2.3 ... Installed : 2.3.5-3sarge2 python2.3-sqlite Installed : 1.0.1-2 sqlite3 . Installed : 3.2.1-1 libsqlite3-0 Installed : 3.2.1-1 DateSQLite3 Data Base Created Via == = === 2005-02-20 abook_00.sql3 . sqlite3 command line 2006-11-23 abook_01.sql3 . python module SQLite3 data bases created via the command line and those created using the python2.3-sqlite package version 1.0.1-2 from within a Python program are not compatible with each other If I create an SQLite3 data base from the command line and populate it with data, then I cannot use that db from Python If I create an SQLite3 data base from within Python and populate it with data, then I cannot use that db from the command line The following console sessions illustrate the problem === # Using an SQLite3 data base created at the command line $ sqlite3 abook_00.sql3 SQLite version 3.2.1 Enter ".help" for instructions sqlite> sqlite> .schema CREATE TABLE addr( nid int , atype int , aid int , address varchar( 128 ) ); CREATE TABLE names( nid int, name varchar( 32 ) ); sqlite> sqlite> .mode column sqlite> .width 16 32 sqlite> sqlite> select names.name , addr.address ...> from names , addr ...> where names.nid = addr.nid ; Bugs BunnyRabbit Hole 0 Donald Duck Duck Pond 1 Goofy G Hut 2 Mickey Mouse Mouse Hole 3 Sylvester Cat House 4 sqlite> === # Try to query that data base from within Python $ python abook_select.py abook_00.sql3 Traceback (most recent call last): File "abook_select.py", line 18, in ? dbc = sqlite.connect( db = path_db ) File "/usr/lib/python2.3/site-packages/sqlite/__init__.py", line 61, in connect return Connection(*args, **kwargs) File "/usr/lib/python2.3/site-packages/sqlite/main.py", line 445, in __init__ self.db = _sqlite.connect(database, mode) _sqlite.DatabaseError: file is encrypted or is not a database === # Try the same query on a Python-created data base $ python abook_select.py abook_01.sql3 abook_select.py Name Address Donald Duck Duck Pond 1 Bugs Bunny Rabbit Hole 0 Mickey Mouse Mouse Hole 3 Goofy G Hut 2 Sylvester Cat House 4 === # Try to use the Python-created data base from the command line $ sqlite3 abook_01.sql3 SQLite version 3.2.1 Enter ".help" for instructions sqlite> sqlite> .schema Error: file is encrypted or is not a database sqlite> -- Stanley C. Kitching Human Being Phoenix, Arizona == Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups = East and West-Coast Server Farms - Total Privacy via Encryption = -- http://mail.python.org/mailman/listinfo/python-list
Re: SQLite3__Python2.3-SQLite__Problem
> > SQLite3 data bases created via the command line > and those created using the python2.3-sqlite package > version 1.0.1-2 from within a Python program > are not compatible with each other > > If I create an SQLite3 data base from the command line > and populate it with data, then I cannot use that db > from Python > > If I create an SQLite3 data base from within Python > and populate it with data, then I cannot use that db > from the command line > This problem is occuring under Debian GNU/Linux Sarge using Python 2.3 This morning for a sanity check on myself I installed SQLite3 and PySQLite2 on a Win2K box running ActiveState Python 2.4 The only things that I had to change in the Python code for creating tables, inserting data, and querying the db that I'm also using under Debian were the import lines from import sqlite to .. from pysqlite2 import dbapi2 as DB Using this setup under Win2K everything works as expected That is SQLite3 data bases created either via the sqlite3 command line or from within Python are 100% transparent, and no errors are produced I'm now off to look for a version of PySQLite2 that is built for Debian Sarge and Python 2.3 to see if that might help to rectify the problem -- Stanley C. Kitching Human Being Phoenix, Arizona == Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups = East and West-Coast Server Farms - Total Privacy via Encryption = -- http://mail.python.org/mailman/listinfo/python-list
Re: SQLite3__Python2.3-SQLite__Problem
>> >> I thought I remembered that the data bases created either way >> were always 100% transparent with each other and that I could >> use an SQLite3 data base either from the command line or from >> within Python without any problems at all > > My guess is that 2 years ago you were using sqlite 2, not 3. I think that is probably a very good guess >> I did a fair amount of Google-izing looking for related problems >> but didn't have much success > In that case your googler is absolutely rooted and should be > replaced immediately. > With mine, google("file is encrypted or is not a database") > produces as first hit (would you believe!?) My Googl-er is probably OK, but the Google-ee ( e.g. me ) is always in need of a tune-up :-) > Q: SQLite::Exceptions::\DatabaseException file is encrypted > or is not a database. > > A: It seems that sqlite databases created with version 2 > do not work with sqlite version 3 and vice versa I did re-build the data bases from the command line using sqlite3 instead of using the older ones from a couple of years back which I wasn't sure were sqlite2 or sqlite3 It seems that the older Debian Sarge version of the python2.3-sqlite package is the one that isn't directly compatible with sqlite3 dbs created at the command line I downloaded the PySQLite2 source package and compiled and installed it using distutils Now everything is also working fine under Debian Sarge and the dbs are OK either from the command line or from within Python Thanks a lot for taking the time to help -- Stanley C. Kitching Human Being Phoenix, Arizona == Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups = East and West-Coast Server Farms - Total Privacy via Encryption = -- http://mail.python.org/mailman/listinfo/python-list
Re: SQLite3__Python2.3-SQLite__Problem
> if you look at > http://packages.debian.org/stable/python/python2.3-sqlite, > you will see that the python2.3-sqlite package is built against > SQLite 2. This is why you have a "file is encrypted or is not a > database" message, since databases created with SQLite 2.x are not > file-compatible with SQLite 3.x file. > Jon I downloaded the PySQLite2 source package and compiled and installed it using distutils Everything is now working as expected under Debian Sarge Thanks a lot for taking the time to help out -- Stanley C. Kitching Human Being Phoenix, Arizona == Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups = East and West-Coast Server Farms - Total Privacy via Encryption = -- http://mail.python.org/mailman/listinfo/python-list
Re: Invoking Python from Cygwin problem.
> Hi all, > > Using cygwin and Python 2.5, I have the following scripts, > one bash script and the other a python script: > -- Ant Using Cygwin and Python 2.4 under Win2K the following version of your code seems to work OK here with no extraneous CR I only changed the variable names & messages just a bit for clarity I don't see any real differences in this version and what you originally posted, so I can't explain the reason for the semingly extraneous carriage return that you are seeing # #!/bin/bash TEST_1=`./test.py` TEST_2="Testing Bash Value" echo " " echo "TEST_1 : $TEST_1 OK" echo "TEST_2 : $TEST_2 OK" # #!/usr/bin/python print "Testing Python Code", # $ ./test_vars TEST_1 : Testing Python Code OK TEST_2 : Testing Bash Value OK -- Stanley C. Kitching Human Being Phoenix, Arizona == Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups = East and West-Coast Server Farms - Total Privacy via Encryption = -- http://mail.python.org/mailman/listinfo/python-list
interactive programme & pyTTS
Hi i have been making an interactive programme,i have recently tried using "pyTTS" with it. This is a small ammount of it. import pyTTS tts = pyTTS.Create()tts.Rate = -3tts.Speak('hi molly how old are you?.')s = raw_input ("how old are you?")if s=='3': print "thats great"else: print "tuttut"tts.speak('tututut') What i dont get is if i type in "4" it prints "tuttut" but it does not say it,am i overlooking something here. Thanks nige -- http://mail.python.org/mailman/listinfo/python-list
interactive programme, using pyTTS
Hi i have been making an interactive programme,i have recently tried using "pyTTS" with it. This is a small ammount of it. import pyTTS tts = pyTTS.Create() tts.Rate = -3 tts.Speak('hi molly how old are you?.') s = raw_input ("how old are you?") if s=='3': print "thats great" else: print "tuttut" tts.speak('tututut') What i dont get is if i type in "4" it prints "tuttut" but it does not say it,am i overlooking something here. allso does any one here know if there is Linux support for such,i have searched about but cannot find anything. Thanks nige -- http://mail.python.org/mailman/listinfo/python-list
Re: Getting external IP address
> I have a PC behind a firewall, and I'm trying to programmatically > determine the IP address visible from outside the firewall. > Steven Following is another alternative that might at least be worth consideration I use the lynx command shown as a command-line alias under Debian linux >>> >>> import os >>> >>> pipe_in = os.popen( 'lynx --dump http://checkip.dyndns.org' ) >>> >>> ip_addr = pipe_in.readlines() >>> >>> for this in ip_addr : ... print this ... Current IP Address: 65.39.92.38 -- Stanley C. Kitching Human Being Phoenix, Arizona == Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups = East and West-Coast Server Farms - Total Privacy via Encryption = -- http://mail.python.org/mailman/listinfo/python-list
Re: installing wxPython on Linux and Windows
| On debian, it | | apt-get install wxPython2.5.3 | | So it clearly depends on you distribution. | | That this is unfortunate is of course true... | Diez The package for wxPython2.5.3 currently is available for Debian Sid/unstable but not for Sarge/testing -- Cousin Stanley Human Being Phoenix, Arizona -- http://mail.python.org/mailman/listinfo/python-list
Re: [ANN] XPN 0.5.5 released
> XPN (X Python Newsreader) is a multi-platform newsreader > with Unicode support. > > You can find it on: > > http://xpn.altervista.org/index-en.html > > http://sf.net/projects/xpn> > > Changes in this release: > Cousin Nemesis Are the new xpn 5.5 config & data files compatible with the older xpn 5.0 files ? Can I install the newer xpn version and move the older data files into it without reconfiguring & reloading data files ? o config.txt o server_logs.dat o dats o groups_info o groups_list -- Stanley C. Kitching Human Being Phoenix, Arizona == Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups = East and West-Coast Server Farms - Total Privacy via Encryption = -- http://mail.python.org/mailman/listinfo/python-list
Re: [ANN] XPN 0.5.5 released
> I'm not 100% sure but I think that they could work. > > The only thing is changed is the outgoing articles format, > so if you have article in the oubox delete them > >> Can I install the newer xpn version >> and move the older data files into it >> without reconfiguring & reloading data files ? >> >> o config.txt >> o server_logs.dat >> o dats >> o groups_info >> o groups_list > > It should work, anyway just make a copy of these files > to be sure not to lose them. > I'll give it a try later today & let you know how it turns out Thanks -- Stanley C. Kitching Human Being Phoenix, Arizona == Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups = East and West-Coast Server Farms - Total Privacy via Encryption = -- http://mail.python.org/mailman/listinfo/python-list
Re: [ANN] XPN 0.5.5 released
>> Can I install the newer xpn version >> and move the older data files into it >> without reconfiguring & reloading data files ? Cousin Nemesis This worked OK with no problems and I'm posting this reply via xpn-0.5.5 I copied the following from the older xpn-0.5.0 version to the newer xpn-0.5.5 version dirs o dats o groups_info o outbox files o custom_headers.txt o groups_list o server_logs.dat No initial configuration, downloading newsrc file, or re-subscribing to newsgroups was required and all of my previously kept & watched messages seem to be in place Thanks for the update -- Stanley C. Kitching Human Being Phoenix, Arizona == Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups = East and West-Coast Server Farms - Total Privacy via Encryption = -- http://mail.python.org/mailman/listinfo/python-list
Re: [ANN] XPN 0.5.5 released
> I'd add also config.txt ;-) I did but failed to include it in the list I posted One small config problem that I haven't figured out how to deal with I use a dark background with white foreground text When posting a reply in the compose/edit window the cursor is NOT visible Is there an incantation I can add to the config file that might render the cursor visible on a dark background ? -- Stanley C. Kitching Human Being Phoenix, Arizona == Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups = East and West-Coast Server Farms - Total Privacy via Encryption = -- http://mail.python.org/mailman/listinfo/python-list
Re: [ANN] XPN 0.5.5 released
>> Is there an incantation I can add to the config file >> that might render the cursor visible on a dark background ? > > It's a well known issue, I haven't found a way > to change the cursor color yet :-/ > > I also posted an help request on the pygtk list, > but I had no useful replies. I use a few other GTK-based applications and will begin looking there for cursor-related config options clues I'm confident that a solution to this problem will eventually be revealed -- Stanley C. Kitching Human Being Phoenix, Arizona == Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups = East and West-Coast Server Farms - Total Privacy via Encryption = -- http://mail.python.org/mailman/listinfo/python-list
Re: strange problems with urllib2
> When I run this code on windows it runs quickly > (about a second per image) but when I run it on linux > it runs very very slowly (10+ seconds per image). > jdonnell I'm running a 1999 vintage 250 MHz Compaq with Debian Gnu/Linux & Python 2.3.5 The following version of your code worked very well here # --- #!/usr/bin/env python ''' NewsGroup comp.lang.python Date . 2005-10-26 Posted_By jdonnell Edited_By Stanley C. Kitching ''' import sys import time import urllib2 this_module = sys.argv[ 0 ] beg = time.time() f = urllib2.urlopen( 'http://site.heavenlytreasures.com/images/e6115.jpg' ) outfile = open( 'e6115.jpg' , 'wb' ) outfile.write( f.read() ) outfile.close() f.close() end = time.time() dt = end - beg print print '%s' % this_module print print 'Image saved %.4f Seconds ' % dt print # --- [EMAIL PROTECTED] : ~/python $ ./urllib2_image_get.py ./urllib2_image_get.py Image saved 0.3973 Seconds -- Stanley C. Kitching Human Being Phoenix, Arizona == Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups = East and West-Coast Server Farms - Total Privacy via Encryption = -- http://mail.python.org/mailman/listinfo/python-list
python-mysqldb__debian_to_freebsd
Greetings I'm using a commercial web host running FreeBSD that fortunately has Python and MySQL, but no python-mysqldb module Before begging the host to install it I thought I would try the Debian version that I have on the outside chance that it might fly directly under FreeBSD on the server import MySQLdb leads to the ImportError message Shared object "libpthread.so.0" not found, required by "_mysql.so" On my local Debian installation the reference to that particular library file is actually a symbolic link libpthread.so.0 -> libpthread-0.10.so I copied libpthread-0.10.so over to the server in a directory that is in the Python search path and renamed it to libpthread.so.0 I tried to make the symbolic link as above from Python since I don't have a shell account, but it failed for some reason that I don't recall at the moment After a bit of google-izing and a quick scan of the MySQL install docs, I also set the LD_LIBRARY_PATH enviroment variable to point to the dir where the supposed missing file lives Is there any at all chance that this will work with the proper configs or should I go ahead and beg the host for an installation ? Any clues would be greatly appreciated -- Stanley C. Kitching Human Being Phoenix, Arizona == Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups = East and West-Coast Server Farms - Total Privacy via Encryption = -- http://mail.python.org/mailman/listinfo/python-list
Re: python-mysqldb__debian_to_freebsd
> > For the interested, the OP (Stanley Kitching), wants to use a > python-mysqldb module on his web host running FreeBSD. They don't have > the that installed, so he tried getting the Debian binary distrubtion > of the library to work, and failed. He's wondering if this is at all > possible. > > Answer: yes, it might (key word - might) be made to work. Linux shared > libraries have been made to work with native applications on FreeBSD > before. I don't have the details, but would expect you'd have to > install large chunks of a Debian system to make this work. If you > really want to do this, let me know and I'll chase the details down > for you. > > However, that's the wrong way to do this. First step - ask your > hosting service to install databases/py-MySQLdb. That's the Python > MySQLdb port in the FreeBSD ports tree. > Mike Although I've never done it personally, I have seen a few newsgroup references that some Debian/FreeBSD packages are interchangeable so thought the minimal effort required for uploading the Debian MySQLdb package I have might be worth the long shot > However, that's the wrong way to do this. First step - ask your > hosting service to install databases/py-MySQLdb. > > That's the Python MySQLdb port in the FreeBSD ports tree. > Installing it should be trivial. > I did a bit more google-izing last night and found that a FreeBSD/MySQLdb install should indeed be a trivial matter to install via FreePorts I'll go ahead and petition the host for an install Thanks very much for taking the time to provide a detailed explanation and your kind offer for further assistance Both are greatly appreciated -- Stanley C. Kitching Human Being Phoenix, Arizona == Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups = East and West-Coast Server Farms - Total Privacy via Encryption = -- http://mail.python.org/mailman/listinfo/python-list
Re: Python-Help ( Mean,Median & Mode)
| I revised my source code. It was doing great | but I'm having problem listing all the numbers | that I'd input. | | How can I input all the numbers that I selected? Alfred As a method to list the numbers that have been input and avoid having to know in advance how many numbers are needed, you might consider a simple input mode where a character other than an integer is input as a stop-input-mode character print '\nInput an integer at the > prompt \n' print 'Enter a period . to end input mode' print 'and begin processing \n' prompt = '> ' period = '.' list_input = [ ] while True : this_str = raw_input( prompt ) if this_str == period : break try : list_input.append( int( this_str ) ) except : print '\nInput Must be an Integer' print 'or a period . to exit Input Mode \n' num_entries = len( list_input ) print 'Input List \n' for this_item in list_input : print '%s' % this_item print '\n# Entries %s \n' % num_entries -- Cousin Stanley Human Being Phoenix, Arizona -- http://mail.python.org/mailman/listinfo/python-list
python website
I am interested in doing a web site in python can any body direct me to a site that was created in python. thanks nige -- http://mail.python.org/mailman/listinfo/python-list
Re: Problems with Tkinter
> My first try fiddling around with GUIs ended disappointing, > instead of showing the window title as expected 'Demofenster' > ist still shows 'tk' instead. > > What did I do wrong? > > > #!/usr/bin/env python > > from Tkinter import * > fenster = Tk() > fenster.title = 'Demofenster' > fenster.mainloop() Steffen To set the Tk window title try fenster.title( 'Demofenster' ) -- Stanley C. Kitching Human Being Phoenix, Arizona == Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups = East and West-Coast Server Farms - Total Privacy via Encryption = -- http://mail.python.org/mailman/listinfo/python-list
Re: any Python equivalent of Math::Polynomial::Solve?
| In case you are still interested pygsl wraps the GSL solver. | | | from pygsl import poly | | pc = poly.poly_complex( 3 ) | | tmp , rs = pc.solve( ( 2 , 3 , 1 ) ) | | print rs | | | You get pygsl at http://sourceforge.net/projects/pygsl/ Pierre Thanks again for the link to the Python GNU Scientific Library I managed to build it under Debian GNU/Linux and the solution you posted above works as is The PyGSL results agree with the numarray eigenvalue solution posted by Alex Renelt and a few timing tests for small problems seem to indicate that it runs a bit quicker I'm looking forward to further use of this package in the future .... -- Stanley C. Kitching Human Being Phoenix, Arizona -- http://mail.python.org/mailman/listinfo/python-list
Re: any Python equivalent of Math::Polynomial::Solve?
| | Did you perhaps use a list (type(p) == type([])) for p? | Alex Using the coefficients in an array instead of a list was the key in the solution to my problems Your other suggestions regarding floating p and the off-by-one error that I had with the polynomial degree were also included The results agree with solutions from PyGSL as suggested by Pierre Schnizer, but seem to run just a bit slower on my machine Thanks again for your assistance The version that I tested with follows Stanley C. Kitching # - #!/usr/bin/env python ''' NewsGroup comp.lang.python Date . 2005-02-27 Subject .. any Python equivalent of Math::Polynomial::Solver Reply_By . Alex Renelt Edited_By Stanley c. Kitching I'm writing a class for polynomial manipulation. The generalization of the above code for providing eigenvalues of a polynomial is definitions 1.) p = array( [ a_0 , a_i , , a_n ] ) P( x ) = \sum _{ i = 0 } ^n a_i x^i 2.) deg( p ) is its degree 3.) monic( p ) makes P monic monic( p ) = p / p[ -1 ] ''' import sys import time from numarray import * import numarray.linear_algebra as LA print '\n ' , sys.argv[ 0 ] , '\n' def report( n , this_data ) : print 'Coefficients ..' , list_coeff[ n ] print print 'Roots .' print dt , roots = this_data for this_item in roots : print '%s' % this_item print print 'Elapsed Time %.6f Seconds' % dt print print def roots( p ) : p = p / float( p[ -1 ] ) # monic( p ) n = len( p ) - 1 # degree of polynomial z = zeros( ( n , n ) ) M = asarray( z , typecode = 'f8' )# typecode = c16, complex M[ : -1 , 1 : ] = identity( n - 1 ) M[ -1 , : ] = -p[ : -1 ] return LA.eigenvalues( M ) list_coeff = [ array( ( 2. , 3. , 1. ) ) , array( ( 1. , 3. , 5. , 7. , 9. ) ) , array( ( 10. , 8. , 6. , 4. , 2. , 1. , 2. , 4. , 6. ) ) ] list_roots = [ ] for these_coeff in list_coeff : beg = time.time() rs = roots( these_coeff ) end = time.time() dt = end - beg list_roots.append( [ dt , list( rs ) ] ) i = 0 for this_data in list_roots : report( i , this_data ) i += 1 print -- http://mail.python.org/mailman/listinfo/python-list
gnuplot -reverse
Experimenting with the gnuplot package under Debian Linux, I've found that the -reverse option when used to start gnuplot from the command-line will produce plots that are color-reversed and render with white text on a black background However, I'm too dense to see how to easily achieve the same effect when using the python-gnuplot package Any clues would be greatly appreciated -- Stanley C. Kitching Human Being Phoenix, Arizona -- http://mail.python.org/mailman/listinfo/python-list
Re: wxPython Install
| | If I can't install an operating system then put wxPython on it | without jumping through hoops, my probelm will be wxPython. | James Under Debian GNU/Linux installing Python and wxpython using the apt package manager is accomplished via the command lines # apt-get install python2.3 # apt-get install wxpython2.5.3 That's it Worked out of the box here -- Stanley C. Kitching Human Being Phoenix, Arizona -- http://mail.python.org/mailman/listinfo/python-list
Re: any Python equivalent of Math::Polynomial::Solve?
Alex Thanks for posting your generalized numarray eigenvalue solution It's been almost 30 years since I've looked at any characteristic equation, eigenvalue, eignevector type of processing and at this point I don't recall many of the particulars Not being sure about the nature of the monic( p ) function, I implemented it as an element-wise division of each of the coefficients Is this anywhere near the correct interpretation for monic( p ) ? Using the version below, Python complained about the line . M[ -1 , : ] = -p[ : -1 ] So, in view of you comments about slicing in you follow-up, I tried without the slicing on the right .. M[ -1 , : ] = -p[ -1 ] The following code will run and produce results, but I'm wondering if I've totally screwed it up since the results I obtain are different from those obtained from the specific 5th order Numeric solution previously posted here . from numarray import * . . import numarray.linear_algebra as LA . . def monic( this_list ) : . . m = [ ] . . last_item = this_list[ -1 ] . . for this_item in this_list : . . m.append( this_item / last_item ) . . return m . . . def roots( p ) : . . p = monic( p ) . . n = len( p ) # degree of polynomial . . z = zeros( ( n , n ) ) . . M = asarray( z , typecode = 'f8' ) # typecode = c16, complex . . M[ : -1 , 1 : ] = identity( n - 1 ) . . M[ -1 , : ] = -p[ -1 ]# removed : slicing on the right . . return LA.eigenvalues( M ) . . . coeff = [ 1. , 3. , 5. , 7. , 9. ] . . print 'Coefficients ..' . print . print '%s' % coeff . print . print 'Eigen Values .. ' . print . . eigen_values = roots( coeff ) . . for this_value in eigen_values : . . print '%s' % this_value . Any clues would be greatly appreciated -- Stanley C. Kitching Human Being Phoenix, Arizona -- http://mail.python.org/mailman/listinfo/python-list
Re: smtplib Segfaults Python under Debian
| localhost:~alex#python | Python 2.3.3 (#2, Feb 24 2004, 09:29:20) | [GCC 3.3.3 (Debian)] on linux2 | Type "help", "copyright", "credits" or "license" | for more information. | | >>> import smtplib | | Segmentation fault (core dumped) | | This happens under python 2.2 and 2.3 and 2.4 | Alex Using Python 2.3.5 here under Debian GNU/Linux Sarge import smtplib is OK [EMAIL PROTECTED] : ~/python $ python Python 2.3.5 (#2, Feb 9 2005, 00:38:15) [GCC 3.3.5 (Debian 1:3.3.5-8)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> >>> import smtplib >>> >>> smtplib.__file__ '/usr/lib/python2.3/smtplib.pyc' >>> [EMAIL PROTECTED] : ~/python $ apt-cache policy python2.3 python2.3: Installed: 2.3.5-1 Candidate: 2.3.5-1 Version Table: *** 2.3.5-1 0 500 http://mirrors.kernel.org sarge/main Packages 100 /var/lib/dpkg/status -- Stanley C. Kitching Human Being Phoenix, Arizona -- http://mail.python.org/mailman/listinfo/python-list
Re: any Python equivalent of Math::Polynomial::Solve?
| In case you are still interested pygsl wraps the GSL solver. | | from pygsl import poly | | pc = poly.poly_complex( 3 ) | | tmp, rs = pc.solve( ( 2 , 3 , 1 ) ) | | print rs | | | You get pygsl at http://sourceforge.net/projects/pygsl/ Pierre I am still interested and have downloaded the PyGSL source from SourceForge and will attempt to build under Debian Linux Thanks for the information -- Stanley C. Kitching Human Being Phoenix, Arizona -- http://mail.python.org/mailman/listinfo/python-list
Re: Running a python program during idle time only
| | I'm wondering if anyone knows of a way that I could make so that | the program will run at full speed only runs after the computer | has been idle for a while. Perhaps looking at some ScreenSaver code could be useful I've never considered how this is done myself, but ScreeSavers seem to know that a user hasn't done anything for a while .... -- Stanley C. Kitching Human Being Phoenix, Arizona == Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups = East and West-Coast Server Farms - Total Privacy via Encryption = -- http://mail.python.org/mailman/listinfo/python-list
Re: pysqlite - Checking the existance of a table
| I am starting to play with pysqlite, | and would like to know if there is a function | to determine if a table exists or not. rh0dium One way to get at a list of table names in an SQLite data base is to query the sqlite_master table import sys import sqlite this_db = sys.argv[ 1 ] list_sql = [ "select tbl_name" , "from sqlite_master" ] str_sql = '\n'.join( list_sql ) dbc = sqlite.connect( db = "%s" % this_db ) curs = dbc.cursor() curs.execute( str_sql ) list_tables = curs.fetchall() print '\nTable Names in SQLite DB %s \n' % ( this_db ) for table_name in list_tables : print " %s " % ( table_name ) print dbc.close() -- Stanley C. Kitching Human Being Phoenix, Arizona == Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups = East and West-Coast Server Farms - Total Privacy via Encryption = -- http://mail.python.org/mailman/listinfo/python-list
Re: Looking For Geodetic Python Software
| | 1) Given the latitude/longitude of two locations, compute the distance |between them. | | "Distance" in this case would be either the straight-line |flying distance, or the actual over-ground distance that accounts |for the earth's curvature. # --- NewsGroup alt.comp.freeware Date . 2003-12-28 Posted_By GRL Reply_By . Sascha Wostmann the formula is as follows: D = ACos((Sin(LA1)*Sin(LA2)) + (Cos(LA1)*Cos(LA2)*Cos(LO1-LO2))) * r with: LA1 / LA2 = latitude position 1 / 2 LO1 / LO2 = longitude 1 / 2 r = radius of earth (~ 6371 km = ~3958,75 miles) D = distance between locations (in km or miles depending on r) Source: somewhere below http://geoclassphp.sourceforge.net # About 18 months ago I put together a couple of small Python programs to compute great circle distances from the above formula http://fastq.com/~sckitching/Python/gcircle.py [ 2.6 kb ] http://fastq.com/~sckitching/Python/gcircle_dms.py [ 3.4 kb ] The first prompts the user for Lat/Long in fixed point degrees. The second prompts the user of Lat/Long in degrees minutes seconds. I only checked a few distances known distances at the time, but they seemed to be OK .... -- Stanley C. Kitching Human Being Phoenix, Arizona == Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups = East and West-Coast Server Farms - Total Privacy via Encryption = -- http://mail.python.org/mailman/listinfo/python-list
Re: *.python.org broken?
> Is anybody else having trouble accessing sites (including www, docs, > wiki) in the python.org tree, or is it just me? (Or just .au?) Yes, connecting to python.org sites has been problematic for me as well I don't remember when the trouble started, but it's been problematic for at least a week or longer here .... -- Stanley C. Kitching Human Being Phoenix, Arizona -- http://mail.python.org/mailman/listinfo/python-list
Re: Python advocacy ... HELP!
> > I have looked at several interesting academic papers, on doing just > this approach. I have also looked through the > python web page to get examples of industry players using python in a > non-trivial way. Yes, I know, Google, Microsoft, Sun, CIA website > running on Plone, NOAA, NASA. If anyone has any recent articles, > or if anyone on the list is at a fortune 500 company, how do I > refute the notion that Python is a "marginal" language > because according to TOBIE it only less than a 6% market share. Michael If you haven't seen it, The Python Success Stories page might provide a quick overview for those that are currently unaware of the rather diverse nature of Python usage among a wide group of well known users http://pythonology.org/success -- Stanley C. Kitching Human Being Phoenix, Arizona -- http://mail.python.org/mailman/listinfo/python-list
Re: [OT] Google Groups in bad odour
> > I will therefore have to find a suitable news client. > Any recommendations ? Frank You might try the python-based xpn news client http://xpn.altervista.org/index-en.html To thine own snake be true :-) -- Stanley C. Kitching Human Being Phoenix, Arizona -- http://mail.python.org/mailman/listinfo/python-list
Re: About PyOpenGL
> > OpenGL.error.NullFunctionError: Attempt to call an undefined function > __glutInitWithExit, check for bool(__glutInitWithExit) before calling > > Can anyone please tell me why? Your opengl program runs exactly as coded without error under Debian 5.0 Linux Lenny Perhaps a required library is missing from your opengl installation Sorry I couldn't provide more help -- Stanley C. Kitching Human Being Phoenix, Arizona -- http://mail.python.org/mailman/listinfo/python-list
Re: Mail reader & spam
> I'm hesitating to change news readers > You might try the python-based XPN news client at http://xpn.altervista.org/index-en.html I've used it for the past few years and like it very much .... -- Stanley C. Kitching Human Being Phoenix, Arizona -- http://mail.python.org/mailman/listinfo/python-list
Re: What's the perfect (OS independent) way of storing filepaths ?
> [2] And they are right to do so. Programs that dump config files and > directories, hidden or not, in the top level of the user's home directory > are incredibly rude. It may have been a Unix standard for as long as > there has been a Unix, but it's still the programming equivalent of > coming into somebody's house and throwing your tools all over their > living room floor. Personally, I feel the same way about dumping files into the python site-package directory For example, I've never understood why kde and qt packages don't use a sub-dir to house their .so libs Moving the .egg-info files into sub-dirs or their own tree would also clean up the site-packages dir -- Stanley C. Kitching Human Being Phoenix, Arizona -- http://mail.python.org/mailman/listinfo/python-list
Re: Mail reader & spam
>> >> You might try the python-based XPN news client at >> >> http://xpn.altervista.org/index-en.html >> > Hi, I tried it out. I like the layout definitely, plus the feel > of it, colors, etc. > > It doesn't do the things I named that I like though. > > It's threading is buggy and watch flags don't propagate > consistently. I've never had any problems at all with message threading using xpn Since I've always used Keep SubThread instead of Watch SubThread, I have no personal experience with the watch flags When using keep flags, new messages in a thread do have to be toggled on, so perhaps the the watch flags behave the same Such toggles are easily achieved by setting desired keystrokes in the KeyBindings.py file found in the xpn_src dir > And there isn't any less spam. Fortunately, the groups I read including this one have a very tolerable spam/content ratio although it does fluctuate from time to time in some groups Perhaps some design concepts/components from spambayes which is also open source and python-based could be integrated with xpn to help diminish spam problems -- Stanley C. Kitching Human Being Phoenix, Arizona -- http://mail.python.org/mailman/listinfo/python-list
Re: [APSW] SELECT COUNT(*) not succesfull?
> > Now I don't know what apsw is, but it's common for libraries > to provide their own wrapping of the db-api. > From the Debian GNU/Linux package manager APSW (Another Python SQLite Wrapper) is an SQLite 3 wrapper that provides the thinnest layer over SQLite 3 possible. Everything you can do from the C API to SQLite 3, you can do from Python. Although APSW's API looks vaguely similar to Python's DB-API, it is not compliant with that API and instead works the way SQLite 3 does. I've never used apsw myself -- Stanley C. Kitching Human Being Phoenix, Arizona -- http://mail.python.org/mailman/listinfo/python-list
Re: PIL + show() + Vista
> This code: > import Image > img = Image.open(r"D:\ParisNude.jpg") > img.show() > > Don't run on my Vista computer. > > I have a solution: import Image,os img = Image.open(r"D:\FLundhNoNude.jpg") os.startfile(img.filename) > Michel As an alternative you might also try passing the path to your favorite image viewer as a parameter to the command argument of the image show method iview = "/mnt/win_c/Program Files/IrfanView/i_view32.exe" im.show( command = iview ) -- Stanley C. Kitching Human Being Phoenix, Arizona -- http://mail.python.org/mailman/listinfo/python-list
Re: using inspect on pygtk
>> I recently been trying to use the inspect module >> to inspect the arguments of gtk objects, such as gtk.Button. >> > > does anybody have any idea? Chris You might try the following newsgroup on the Gmane server for Python / Gtk questions gmane.comp.gnome.gtk+.python -- Stanley C. Kitching Human Being Phoenix, Arizona == Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups = East and West-Coast Server Farms - Total Privacy via Encryption = -- http://mail.python.org/mailman/listinfo/python-list
Re: Random Problems
> Well the othe day I was making a program to make a list > of all the songs in certian directorys but I got a problem, > only one of the directorys was added to the list. > > Here's some code that illustrates yours import glob songs = glob.glob( '/path/to/somewhere/*.mp3' ) asongs = glob.glob( 'path/to/somewhere/else/*.mp3' ) songs.append( asongs ) # repeat a few times appending lists from other dirs > all goes well but pick awalys is from the first directory > but songs awalys includes all the files I want it to. songs.append( asongs ) is appending the entire asongs list as a single item to the end of the songs list, not adding each individual song as an entry For example >>> l1 = range( 0 , 5 ) >>> l2 = range( 5 , 10 ) >>> l3 = range( 11 , 15 ) >>> >>> l1 [0, 1, 2, 3, 4] >>> >>> l2 [5, 6, 7, 8, 9] >>> >>> l3 [11, 12, 13, 14] >>> >>> l1.append( l2 ) >>> >>> l1 [0, 1, 2, 3, 4, [5, 6, 7, 8, 9]] >>> >>> l1.append( l3 ) >>> >>> l1 [0, 1, 2, 3, 4, [5, 6, 7, 8, 9], [11, 12, 13, 14]] So, if you have a lot of entries in the original songs list you're only adding a few entries to it in the form of another list and most likely you didn't run enough random.choice tests to flush out a pick that turned out to be one of the entire asong lists that you added You might try something like the following where each tune gets added individually to the song pool un-tested # --- import random import glob base_dir = 'c:/Documents and Settings/Admin/My Documents' list_subdirs = [ 'LimeWire/Saved/*.mp3' , 'Downloads/*/*.mp3' , 'Downloads/*/*/*.mp3' , 'Downloads/*/*/*/*.mp3 ] song_pool = [ ] for this_dir in list_subdirs : list_songs = glob.glob( "'%s/%s'" % ( base_dir , this_dir ) if list_songs : for this_song in list_songs : song_pool.append( this_song ) npicks = 41 print for n in range( npicks ) : this_pick = random.choice( song_pool ) print ' ' , this_pick # --- -- Stanley C. Kitching Human Being Phoenix, Arizona -- http://mail.python.org/mailman/listinfo/python-list
Re: Random Problems
> list_songs = glob.glob( "'%s/%s'" % ( base_dir , this_dir ) Missed a closing paren list_songs = glob.glob( "'%s/%s'" % ( base_dir , this_dir ) ) Still NOT Tested -- Stanley C. Kitching Human Being Phoenix, Arizona -- http://mail.python.org/mailman/listinfo/python-list
Re: Random Problems
>> Well the othe day I was making a program to make a list >> of all the songs in certian directorys but I got a problem, >> only one of the directorys was added to the list. >> Heres my code: >> >> import random >> import os >> import glob >> >> songs = glob.glob('C:\Documents and Settings\Admin\My >> Documents\LimeWire\Saved\*.mp3') >> >> asongs = glob.glob('C:\Documents and Settings\Admin\My > From: [EMAIL PROTECTED] > To: "Cousin Stanley" <[EMAIL PROTECTED]>, >python-list@python.org > Date: Yesterday 07:28:18 pm > use songs.extend( asongs ) # append is for single item > # - where ever it might be. >>> l1 = range(5) >>> l2 = range(5,10) >>> l1 [0, 1, 2, 3, 4] >>> l2 [5, 6, 7, 8, 9] >>> l1.extend(l2) >>> l1 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> And Thanks to Edwin Madari for reminding me about the extend method available for lists which I had totally forgotten about -- Stanley C. Kitching Human Being Phoenix, Arizona -- http://mail.python.org/mailman/listinfo/python-list
Re: Should Python raise a warning for mutable default arguments?
> Question: what is real warning? Don't MAKE ME have to tell you AGAIN !!!! -- Stanley C. Kitching Human Being Phoenix, Arizona -- http://mail.python.org/mailman/listinfo/python-list
Re: Python cx_Oracle and Apache
> > > def generate_output(): > print '' > > generate_output() Raja You might try adding a Content-type header followed by a blank line to your generate_output() function def generate_output() : print 'Content-type: text/html' print print .... rest of your html -- Stanley C. Kitching Human Being Phoenix, Arizona -- http://mail.python.org/mailman/listinfo/python-list
Re: iterating over two arrays in parallel?
> I want to interate over two arrays in parallel, > something like this: > > a=[1,2,3] > b=[4,5,6] > > for i,j in a,b: > print i,j > > where i,j would be 1,4,2,5, 3,6 etc. > > Is this possible? > > Many TIA! > Mark >>> >>> list_1 = range( 1 , 4 ) >>> list_2 = range( 4 , 7 ) >>> >>> list12 = zip( list_1 , list_2 ) >>> >>> for this in list12 : ... print ' ' , this ... (1, 4) (2, 5) (3, 6) >>> >>> for i , j in list12 : ... print ' ' , i , j ... 1 4 2 5 3 6 -- Stanley C. Kitching Human Being Phoenix, Arizona -- http://mail.python.org/mailman/listinfo/python-list
Re: (in memory) database
> . > Yes and no. My own experience with Debian packages > is that with a standard > > apt-get install python2.5 > > an attempt to > import sqlite3 > > results in > ImportError: No module named _sqlite3 > No problems here with Debian Lenny All packages via apt-get install $ uname -a Linux em1 2.6.25-2-686 #1 SMP Fri Jul 18 17:46:56 UTC 2008 i686 GNU/Linux $ dpkg -l | grep sqlite ii libhk-classes-sqlite3 0.8.3-4 SQLite 3 driver plugin for hk_classes ii libsqlite3-0 3.5.9-3 SQLite 3 shared library ii python-pysqlite2 2.4.1-1 Python interface to SQLite 3 ii sqlite3 3.5.9-3 A command line interface for SQLite 3 $ py Python 2.5.2 (r252:60911, Aug 8 2008, 09:22:44) [GCC 4.3.1] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> >>> import sqlite3 >>> -- Stanley C. Kitching Human Being Phoenix, Arizona -- http://mail.python.org/mailman/listinfo/python-list
Re: (in memory) database
> > Yes and no. My own experience with Debian packages > is that with a standard > apt-get install python2.5 > an attempt to > import sqlite3 > results in > ImportError: No module named _sqlite3 > From Kubuntu 8.04 $ uname -a Linux em1 2.6.24-19-generic #1 SMP Wed Aug 20 22:56:21 UTC 2008 i686 GNU/Linux $ dpkg -l | grep sqlite ii libsqlite0 2.8.17-4build1 SQLite shared library ii libsqlite3-0 3.4.2-2 SQLite 3 shared library $ py25 Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52) [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> >>> import sqlite3 >>> It is now my estimation that the Force is not currently with you :-) -- Stanley C. Kitching Human Being Phoenix, Arizona -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Math libraries - How to?
> > Here is the arithmetic program I made that it worked before I added > the "import math" line. > > #volumen.py > # A program to compute the volume and surface area of a sphere > import math > > > NameError: global name 'pi' is not defined > >>> from math import * >>> >>> def surface( r ) : ... return 4 * pi * r ** 2 ... >>> def volume( r ) : ... return ( 4. / 3. ) * pi * r ** 3 ... >>> for n in range( 1 , 11 ) : ... s = surface( n ) ... v = volume( n ) ... print '%2d %9.4f %9.4f ' % ( n , s , v ) ... -- Stanley C. Kitching Human Being Phoenix, Arizona -- http://mail.python.org/mailman/listinfo/python-list
Re: [OT'ish] Is there a list as good as this for Javascript
> Occasionally I have to make forays into Javascript, > can anyone recommend a place similar to this list > where Javascript questions can be asked ? Several years back I found the newsgroup comp.lang.javascript to be helpful However, I haven't used that group for some time now so don't know the current nature of the group -- Stanley C. Kitching Human Being Phoenix, Arizona -- https://mail.python.org/mailman/listinfo/python-list
Re: Guys, can you please share me some sites where we can practice python programs for beginners and Intermediate.
DFS wrote: > Here's a fun one: scraping data off a website, > and storing it in a SQLite database file. > After testing your example code here I found that the length of the categories list was 1 less than the terms list after applying dropwords in the terms list comprehension The subsequent len comparison then failed and no data was inserted into the data base As a fix I added an extra category category.append( 'didly' ) Subsequently, data was inserted with a single extra category for the last term in terms Thanks for posting the example code -- Stanley C. Kitching Human Being Phoenix, Arizona -- https://mail.python.org/mailman/listinfo/python-list
Re: Guys, can you please share me some sites where we can practice python programs for beginners and Intermediate.
DFS wrote: > On 6/23/2016 11:11 AM, Cousin Stanley wrote: >> DFS wrote: >> >>> Here's a fun one: scraping data off a website, >>> and storing it in a SQLite database file. >>> >> >> After testing your example code here I found >> that the length of the categories list >> was 1 less than the terms list after applying >> dropwords in the terms list comprehension >> >> The subsequent len comparison then failed >> and no data was inserted into the data base >> >> As a fix I added an extra category >> >> category.append( 'didly' ) >> >> Subsequently, data was inserted >> with a single extra category >> for the last term in terms > > > Strange! After dropwords, the list lengths match > for me (both are 152). > Found 153 for terms and 152 for categories, so I appended 1 to categories ... > So in your table, is 'didly' now the category for the last term > 'Rendering'? Mine is 'Technical', as it is on the source webpage. Last 5 printed from the final loop just before the db insert Passphrase , Technical Passcode , Technical Touchpad , Hardware Rendering , Technical Terms of Use , didly > > I usually put list length tests in place, > not sure what happened here. Possibly a copy/paste difference on my end -- Stanley C. Kitching Human Being Phoenix, Arizona -- https://mail.python.org/mailman/listinfo/python-list
Re: Assignment Versus Equality
Dennis Lee Bieber wrote: > > but I'm sure we'd have a revolt > if Python comparison operators looked like: > > a .eq. b > a .ne. b > a .gt. b .or. c .lt. d > a .le. b .and. c .ge. d > As someone who learned fortran in the mid 1960s and pounded a lot of fortran code in the 1970s, the code above seems very readable -- Stanley C. Kitching Human Being Phoenix, Arizona -- https://mail.python.org/mailman/listinfo/python-list
Re: Stupid question, just need a quick and dirty fix
Jordan Bayless wrote: > > desired = Id < 10 or Id > 133 or Id in good_ids > > When I try to validate whether I passed that check, > I'm told there's a Name error and it's not defined > On the outside chance that failing to define Id produces the Name error, I defined Id in a for loop as a test for your copy/pasted code $ cat id_test.py #!/usr/bin/env python3 good_ids = { 2, 3, 4, 5, 6, 7, 8, 9, 12, 15, 24, 25, 26, 27, 28, 31, 34, 35, 36, 37, 38, 39, 40, 45, 50, 51, 53, 55, 56, 57, 59, 62, 65, 68, 71, 76, 78, 80, 82, 83, 87, 88, 89, 91, 93, 94, 96, 97, 101, 103, 105, 106, 107, 109, 110, 112, 113, 115, 122, 124, 125, 126, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151 } test_ids = [ 1 , 10 , 128 , 42 , 137 , 444 ] print( ) for Id in test_ids : desired = Id < 10 or Id > 133 or Id in good_ids print( ' Id : %4d desired : %s ' % ( Id , desired ) ) $ ./id_test.py Id : 1 desired : True Id :10 desired : False Id : 128 desired : False Id :42 desired : False Id : 137 desired : True Id : 444 desired : True -- Stanley C. Kitching Human Being Phoenix, Arizona -- https://mail.python.org/mailman/listinfo/python-list
Re: Python Dice Game/Need help with my script/looping!
Constantin Sorin wrote: > Hello,I recently started to make a dice game in python. > > Everything was nice and beautiful,until now. > > My problem is that when I try to play and I win or lost > or it's equal next time it will continue only with that. > Following is a link to a version of your code rewritten to run using python3 http://csphx.net/fire_dice.py.txt The only significant differences between python2 and python3 in your code are python2 . python3 print ... print( ) raw_input( ) ... input( ) Bob Gailer wrote: > > The proper way to handle this > is to put the entire body of game() > in a while loop. > > Since the values of e and f are not changed in the loop > he will continue to get the same thing. > These changes are the key to making the program loop as desired All other changes are mostly cosmetic * Note * I am partial to white space both horizontal and vertical ... :-) -- Stanley C. Kitching Human Being Phoenix, Arizona -- https://mail.python.org/mailman/listinfo/python-list
Re: Get min and max dates
DFS wrote: > > Not wanting to use any date parsing libraries, > If you happen reconsider date parsing libraries the strptime function from the datetime module might be useful #!/usr/bin/env python3 from datetime import datetime dates = [ '10-Mar-1998' , '20-Aug-1997' , '06-Sep-2009' , '23-Jan-2010' , '12-Feb-2010' , '05-Nov-2010' , '03-Sep-2009' , '07-Nov-2014' , '08-Mar-2013' ] dict_dates = { } print( ) for this_date in dates : dt = datetime.strptime( this_date , '%d-%b-%Y' ) sd = dt.strftime( '%Y-%m-%d' ) print( ' {0} {1}'.format( this_date , sd ) ) dict_dates[ sd ] = this_date min_date = min( dict_dates.keys() ) max_date = max( dict_dates.keys() ) print( '\n {0} {1} min'.format( dict_dates[ min_date ] , min_date ) ) print( '\n {0} {1} max'.format( dict_dates[ max_date ] , max_date ) ) -- Stanley C. Kitching Human Being Phoenix, Arizona -- https://mail.python.org/mailman/listinfo/python-list
Re: Top down Python
> > 3) Create terminal window with size 64x20 > (which, IMO, is tiny) > Maybe 64 characters x 20 lines -- Stanley C. Kitching Human Being Phoenix, Arizona -- https://mail.python.org/mailman/listinfo/python-list
Vue-Django
I extended the VueJS CLI to allow me get a *Django* project with VueJS up and running for any project or my next hackathon project with one command. https://github.com/NdagiStanley/vue-django I was impressed by the manner in which the Github stars increased in the forked repo and judging that it was of value to other devs besides myself, I'd appreciate your views in terms of possible features, other use-cases this can extend to and what I can think about doing :) Collaboration, Advice -- https://mail.python.org/mailman/listinfo/python-list
Re: enum
ast wrote: > https://docs.python.org/3.5/library/enum.html#planet > > Documentation says that the value of the enum > members will be passed to this method. > > But in that case __init__ waits for two arguments, mass > and radius, while enum member's value is a tuple. > > It seems that there is a tuple unpacking, but it is > not documented, that's not clear > I added the following code to your example to unpack planet.value into mass and radius after first importing Enum from enum import Enum def test_01() : print( '\n planet mass radius gravity \n' ) for planet in Planet : mass , radius = planet.value print( ' {:8s} {:9.4E} {:9.4E} {:9.4E} '.format( planet.name , mass , radius , planet.surface_gravity ) ) if __name__ == '__main__' : test_01() A working copy http://csphx.net/python/planets_enum.txt -- Stanley C. Kitching Human Being Phoenix, Arizona -- https://mail.python.org/mailman/listinfo/python-list
Parsing Nested List
I am trying to parse a Python nested list that is the result of the getOutlines() function of module PyPFD2 using pyparsing module. This is the result I get. what in the world are 'expandtabs' and why is that making a difference to my parse attempt? Python Code 7 import PPDF2,pyparsing from pyparsing import Word, alphas, nums pdfFileObj=open('x.pdf','rb') pdfReader=PyPDF2.PdfFileReader(pdfFileObj) List=pdfReader.getOutlines() myparser = Word( alphas ) + Word(nums, exact=2) +"of" + Word(nums, exact=2) myparser.parseString(List) This is the error I get: Traceback (most recent call last): File "", line 1, in myparser.parseString(List) File "C:\python\lib\site-packages\pyparsing.py", line 1620, in parseString instring = instring.expandtabs() AttributeError: 'list' object has no attribute 'expandtabs' Thanks so much, not getting any helpful responses from https://python-forum.io. -- https://mail.python.org/mailman/listinfo/python-list
Re: Parsing Nested List
On Sunday, February 4, 2018 at 4:26:24 PM UTC-6, Stanley Denman wrote: > I am trying to parse a Python nested list that is the result of the > getOutlines() function of module PyPFD2 using pyparsing module. This is the > result I get. what in the world are 'expandtabs' and why is that making a > difference to my parse attempt? > > Python Code > 7 > import PPDF2,pyparsing > from pyparsing import Word, alphas, nums > pdfFileObj=open('x.pdf','rb') > pdfReader=PyPDF2.PdfFileReader(pdfFileObj) > List=pdfReader.getOutlines() > myparser = Word( alphas ) + Word(nums, exact=2) +"of" + Word(nums, exact=2) > myparser.parseString(List) > > This is the error I get: > > Traceback (most recent call last): > File "", line 1, in > myparser.parseString(List) > File "C:\python\lib\site-packages\pyparsing.py", line 1620, in parseString > instring = instring.expandtabs() > AttributeError: 'list' object has no attribute 'expandtabs' > > Thanks so much, not getting any helpful responses from > https://python-forum.io. -- https://mail.python.org/mailman/listinfo/python-list
Re: Parsing Nested List
On Sunday, February 4, 2018 at 5:06:26 PM UTC-6, Steven D'Aprano wrote: > On Sun, 04 Feb 2018 14:26:10 -0800, Stanley Denman wrote: > > > I am trying to parse a Python nested list that is the result of the > > getOutlines() function of module PyPFD2 using pyparsing module. > > pyparsing parses strings, not lists. > > I fear that you have completely misunderstood what pyparsing does: it > isn't a general-purpose parser of arbitrary Python objects like lists. > Like most parsers (actually, all parsers that I know of...) it takes text > as input and produces some sort of machine representation: > > https://en.wikipedia.org/wiki/Parsing#Computer_languages > > > So your code is not working because you are calling parseString() with a > list argument: > > myparser.parseString(List) > > > The name of the function, parseString(), should have been a hint that it > requires a *string* as argument. > > You have generated an outline: > > List = pdfReader.getOutlines() > > but do you know what the format of that list is? I'm going to assume that > it looks something like this: > > ['ABCD 01 of 99', 'EFGH 02 of 99', 'IJKL 03 of 99', ...] > > since that matches the template you gave to pyparsing. Notice that: > > - words are separated by spaces; > > - the first word is any arbitrary word, made up of just letters; > > - followed by EXACTLY two digits; > > - followed by the word "of"; > > - followed by EXACTLY two digits. > > Furthermore, I'm assuming it is a simple, non-nested list. If that is not > the case, you will need to explain precisely what the format of the > outline actually is. > > To parse this list is simple and pyparsing is not required: > > for item in List: > words = item.split() > if len(words) != 4: > raise ValueError('bad input data: %r' % item) > first, number, x, total = words > number = int(number) > assert x == 'of' > total = int(total) > print(first, number, total) > > > > > Hope this helps. > > (Please keep any replies on the list.) > > > > -- > Steve Thank you so much Steve. I do seem to be barking up the wrong tree. The result of running getOutlines() is indeed a nested list: it is the pdfs bookmarks. There are 3 levels: level 1 is the section from A-F. When a section there are exhibits, so in Section A we have exhibits 1A to nA. Finally there are bookmarks for individual pages in an exhibit. So we have this for Section A: [{'/Title': 'Section A. Payment Documents/Decisions', '/Page': IndirectObject(1, 0), '/Type': '/FitB'}, [{'/Title': '1A: Disability Determination Transmittal (831) Dec. Dt.: 05/27/2016 (1 page)', '/Page': IndirectObject(1, 0), '/Type': '/FitB'}, [{'/Title': '1A (Page 1 of 1)', '/Page': IndirectObject(1, 0), '/Type': '/FitB'}], {'/Title': '2A: Disability Determination Explanation (DDE) Dec. Dt.: 05/27/2016 (10 pages)', '/Page': IndirectObject(6, 0), '/Type': '/FitB'}, [{'/Title': '2A (Page 1 of 10)', '/Page': IndirectObject(6, 0), '/Type': '/FitB'}, {'/Title': '2A (Page 2 of 10)', '/Page': IndirectObject(10, 0), '/Type': '/FitB'}, {'/Title': '2A (Page 3 of 10)', '/Page': IndirectObject(14, 0), '/Type': '/FitB'}, {'/Title': '2A (Page 4 of 10)', '/Page': IndirectObject(18, 0), '/Type': '/FitB'}, {'/Title': '2A (Page 5 of 10)', '/Page': IndirectObject(22, 0), '/Type': '/FitB'}, {'/Title': '2A (Page 6 of 10)', '/Page': IndirectObject(26, 0), '/Type': '/FitB'}, {'/Title': '2A (Page 7 of 10)', '/Page': IndirectObject(30, 0), '/Type': '/FitB'}, {'/Title': '2A (Page 8 of 10)', '/Page': IndirectObject(34, 0), '/Type': '/FitB'}, {'/Title': '2A (Page 9 of 10)', '/Page': IndirectObject(38, 0), '/Type': '/FitB'}, {'/Title': '2A (Page 10 of 10)', '/Page': IndirectObject(42, 0), '/Type': '/FitB'}], {'/Title': '3A: ALJ Hearing Decision (ALJDEC) Dec. Dt.: 12/17/2012 (22 pages)', '/Page': IndirectObject(47, 0), '/Type': '/FitB'}, [{&
Re: Parsing Nested List
On Sunday, February 4, 2018 at 5:32:51 PM UTC-6, Stanley Denman wrote: > On Sunday, February 4, 2018 at 4:26:24 PM UTC-6, Stanley Denman wrote: > > I am trying to parse a Python nested list that is the result of the > > getOutlines() function of module PyPFD2 using pyparsing module. This is the > > result I get. what in the world are 'expandtabs' and why is that making a > > difference to my parse attempt? > > > > Python Code > > 7 > > import PPDF2,pyparsing > > from pyparsing import Word, alphas, nums > > pdfFileObj=open('x.pdf','rb') > > pdfReader=PyPDF2.PdfFileReader(pdfFileObj) > > List=pdfReader.getOutlines() > > myparser = Word( alphas ) + Word(nums, exact=2) +"of" + Word(nums, exact=2) > > myparser.parseString(List) > > > > This is the error I get: > > > > Traceback (most recent call last): > > File "", line 1, in > > myparser.parseString(List) > > File "C:\python\lib\site-packages\pyparsing.py", line 1620, in parseString > > instring = instring.expandtabs() > > AttributeError: 'list' object has no attribute 'expandtabs' > > > > Thanks so much, not getting any helpful responses from > > https://python-forum.io. I have found that I can use the index values in the list to print out the section I need. So print(MyList[7]) get me to section f taht I want. print(MyList[9][1]) for example give me a string that is the bookmark entry for Exhibit 1F. But this index value would presumeably be different for each pdf file - that is there may not always be Section A-E, but there will always be a Section F. In ther words, the index values that get me to the right section would be different in each pdf file. -- https://mail.python.org/mailman/listinfo/python-list
Extracting data from ython dictionary object
I am new to Python. I am trying to extract text from the bookmarks in a PDF file that would provide the data for a Word template merge. I have gotten down to a string of text pulled out of the list object that I got from using PyPDF2 module. I am stuck on now to get the data out of the string that I need. I am calling it a string, but Python is recognizing as a dictionary object. Here is the string: {'/Title': '1F: Progress Notes Src.: MILANI, JOHN C Tmt. Dt.: 05/12/2014 - 05/28/2014 (9 pages)', '/Page': IndirectObject(465, 0), '/Type': '/FitB'} What a want is the following to end up as fields on my Word template merge: MedSourceFirstName: "John" MedSourceLastName: "Milani" MedSourceLastTreatment: "05/28/2014" If I use keys() on the dictionary I get this: ['/Title', '/Page', '/Type']I was hoping "Src" and Tmt Dt." would be treated as keys. Seems like the key/value pair of a dictionary would translate nicely to fieldname and fielddata for a Word document merge. Here is my code so far. [python]import PyPDF2 pdfFileObj=open('x.pdf','rb') pdfReader=PyPDF2.PdfFileReader(pdfFileObj) MyList=pdfReader.getOutlines() MyDict=(MyList[-1][0]) print(isinstance(MyDict,dict)) print(MyDict) print(list(MyDict.keys()))[/python] I get this output in Sublime Text: True {'/Title': '1F: Progress Notes Src.: MILANI, JOHN C Tmt. Dt.: 05/12/2014 - 05/28/2014 (9 pages)', '/Page': IndirectObject(465, 0), '/Type': '/FitB'} ['/Title', '/Page', '/Type'] [Finished in 0.4s] Thank you in advance for any suggestions. -- https://mail.python.org/mailman/listinfo/python-list
Re: Extracting data from ython dictionary object
On Friday, February 9, 2018 at 1:08:27 AM UTC-6, dieter wrote: > Stanley Denman writes: > > > I am new to Python. I am trying to extract text from the bookmarks in a PDF > > file that would provide the data for a Word template merge. I have gotten > > down to a string of text pulled out of the list object that I got from > > using PyPDF2 module. I am stuck on now to get the data out of the string > > that I need. I am calling it a string, but Python is recognizing as a > > dictionary object. > > > > Here is the string: > > > > {'/Title': '1F: Progress Notes Src.: MILANI, JOHN C Tmt. Dt.: > > 05/12/2014 - 05/28/2014 (9 pages)', '/Page': IndirectObject(465, 0), > > '/Type': '/FitB'} > > > > What a want is the following to end up as fields on my Word template merge: > > MedSourceFirstName: "John" > > MedSourceLastName: "Milani" > > MedSourceLastTreatment: "05/28/2014" > > > > If I use keys() on the dictionary I get this: > > ['/Title', '/Page', '/Type']I was hoping "Src" and Tmt Dt." would be > > treated as keys. Seems like the key/value pair of a dictionary would > > translate nicely to fieldname and fielddata for a Word document merge. > > Here is my code so far. > > A Python "dict" is a mapping of keys to values. Its "keys" method > gives you the keys (as you have used above). > The subscription syntax ("[]"; e.g. > "pdf_info['/Title']") allows you to access the value associated with > "". > > In your case, relevant information is coded inside the values themselves. > You will need to extract this information yourself. Python's "re" module > might be of help (see the "library reference", for details). Thanks for your response. Nice to know I am at least on the right path. Sounds like I am going to have to did in to Regex to get at the test I want. -- https://mail.python.org/mailman/listinfo/python-list
Re: Extracting data from ython dictionary object (Posting On Python-List Prohibited)
On Friday, February 9, 2018 at 12:20:29 AM UTC-6, Lawrence D’Oliveiro wrote: > On Friday, February 9, 2018 at 6:04:48 PM UTC+13, Stanley Denman wrote: > > {'/Title': '1F: Progress Notes Src.: MILANI, JOHN C Tmt. Dt.: > > 05/12/2014 - 05/28/2014 (9 pages)', '/Page': IndirectObject(465, 0), > > '/Type': '/FitB'} > > > > What a want is the following to end up as fields on my Word template merge: > > MedSourceFirstName: "John" > > MedSourceLastName: "Milani" > > MedSourceLastTreatment: "05/28/2014" > > > > If I use keys() on the dictionary I get this: > > ['/Title', '/Page', '/Type']I was hoping "Src" and Tmt Dt." would be treated > > as keys. Seems like the key/value pair of a dictionary would translate > > nicely to fieldname and fielddata ... > > It would, except that’s not how the information is represented in the PDF > file. Looks like what you want is all in the title string. So extracting it > will require some string manipulation. Do all the title strings follow the > same format? That should simplify the manipulations you need to do. Thanks you Lawrence for your response. Sounds like I am going to have to dig in to Regex to get at the test I want. -- https://mail.python.org/mailman/listinfo/python-list