Using plotly and getting "This site can't be reached"
The Chrome browser on the machine shows "127.0.0.1 refused to connect" for various urls of the form 127.0.0.1:x where x are numbers like 64981, 65029,... About once in 20-40 attempts, the graphs appear. I ran the same code on a different machine and it created the plots in the Chrome browser every time. I ran a different Python plotly program on both machines with similar results. Everything else I navigate to in Chrome works as expected. No errors are reported by the plotly code shown below. I also ran the code in Visual Studio Code with the same results. I would like to see the information sent to the browser but I have not figured out how to do that yet. Any help would be appreciated. = import pandas as pd df = pd.DataFrame({ "Fruit": ["Apples", "Oranges", "Bananas", "Apples", "Oranges", "Bananas"], "Contestant": ["Alex", "Alex", "Alex", "Jordan", "Jordan", "Jordan"], "Number Eaten": [2, 1, 3, 1, 3, 2], }) import plotly.express as px fig = px.bar(df, x="Fruit", y="Number Eaten", color="Contestant", barmode= "group") #print(""PLOT 1") # fig.show() import plotly.graph_objects as go fig = go.Figure() for contestant, group in df.groupby("Contestant"): fig.add_trace(go.Bar(x=group["Fruit"], y=group["Number Eaten"], name =contestant, hovertemplate="Contestant=%sFruit=%%{x}Number Eaten=%%{y} "% contestant)) fig.update_layout(legend_title_text = "Contestant") fig.update_xaxes(title_text="Fruit") fig.update_yaxes(title_text="Number Eaten") print("PLOT 2") fig.show() -- https://mail.python.org/mailman/listinfo/python-list
Re: Sqlite3 help
Thanks a bunch Sibylle! That seems like a better approach. -- https://mail.python.org/mailman/listinfo/python-list
Sqlite3 help
I am building a simple podcast program where I download all the data from a feed with feedparser and store the data in sqlite3. I am spanking new to sqlite and database programming. Should I create the database in the __init__ method of my class, or is that a bad idea. I haven't done any designing that included databases. Thanks! Chuck -- https://mail.python.org/mailman/listinfo/python-list
Re: Most discussion on comp.lang.python is about developing with Python
On Thursday, November 14, 2013 3:35:56 AM UTC+7, bob gailer wrote: > I joined a week or so ago. > > > > The subject line was copied from the description of comp.lang.python aka > > python-list@python.org. > > > > I am very disappointed to see so much energy and bandwidth going to > > conversations that bash individuals. > > > > Is there a moderator for this list? > > > > Is there some other place for discussions that are completely OT and > > also full of flames? > > > > Or would you be willing to stop the bashing? I don't see that it helps > > anyone, and could be very offputting to other newbies. > > > > I hope and pray that there will be a few simple answers. The last thing > > I want is to start another flame war. > > > > Thanks for hearing me. > > > > -- > > Bob Gailer > > 919-636-4239 > > Chapel Hill NC I just changed my profile to turn off email updates from this list. Too many posts were in response to the blatant troll postings. If I never get another comp.lang.python post in my mailbox it will be too soon. -- https://mail.python.org/mailman/listinfo/python-list
Stop feeding the Ferrous Cranus troll
http://www.politicsforum.org/images/flame_warriors/flame_62.php why are any of you replying? -- https://mail.python.org/mailman/listinfo/python-list
Re: Generating Filenames from Feeds
> Seriously, if you don't post a minimal code example that shows the problem > and with a full traceback you are asking strangers to do magic tricks for > your pleasure. I'm asking more for a better way of generating destination filenames, not so much debugging questions. I only put my attempts there to show people that I was actually trying something, and not just relying on people to do my thinking for me. I'm trying to take a feed such as this http://www.theskepticsguide.org/feed/rss.aspx?feed=SGU and parse some useful data out of it for a destination filename. The solution should be general, and not just for this particular feed. Thanks! -- http://mail.python.org/mailman/listinfo/python-list
Generating Filenames from Feeds
HI all, I am trying to write a podcast catcher for fun, and I am trying to come up with a way to generate a destination filename to use in the function urlretrieve(url, destination). I would like the destination filename to end in a .mp3 extension. My first attempts were parsing out the and stripping the whitespace characters, and joining with os.path.join. I haven't been able to make that work for some reason. Whenever I put the .mp3 in the os.path.join I get syntax errors. I am wondering if there is a better way? I was doing something like os.path.join('C:\\Users\\Me\\Music\\Podcasts\\', pubdate.mp3), where pubdate has been parsed and stripped of whitespace. I keep getting an error around the .mp3. Any ideas? Thanks!! Chuck -- http://mail.python.org/mailman/listinfo/python-list
Re: Config & ConfigParser
I guess my question was more what is a config.file & why/how do I use one. Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: Config & ConfigParser
Thanks Tim! So much stuff I haven't thought of before. Out of curiosity, what's the benefit of caching the download, instead of downloading to the final destination? So much stuff they never teach you school.So much theory & not enough practice. :( -- http://mail.python.org/mailman/listinfo/python-list
Config & ConfigParser
I'm curious about using configuration files. Can someone tell me how they are used? I'm writing a podcast catcher and would like to set up some default configurations, e.g. directory, etcOther than default directory, what are some of the things that are put in a configuration file? They don't seem to teach you this kind of stuff in school. :( Thanks! -- http://mail.python.org/mailman/listinfo/python-list
Re: Keep getting this in PyDev "TypeError: quiz() takes exactly 1 argument (0 given)"
Yeah, I am mostly a Java guy. Just starting with Python. :) -- http://mail.python.org/mailman/listinfo/python-list
Re: Keep getting this in PyDev "TypeError: quiz() takes exactly 1 argument (0 given)"
Thanks for the help guys! I finally got it working. Shouldn't I technically call quiz() through the constructor, though? Otherwise, the constructor is pointless. I just put in pass for now. (Also, I always thought that if __name__ == '__main__': went IN the class. Why wouldn't it be apart of the class? ) Thanks again! -- http://mail.python.org/mailman/listinfo/python-list
Re: Keep getting this in PyDev "TypeError: quiz() takes exactly 1 argument (0 given)"
On Friday, August 10, 2012 2:05:36 PM UTC-5, Pedro Kroger wrote: > On Aug 10, 2012, at 3:52 PM, Chuck wrote: > > > > >if __name__ == '__main__': > > > > > >quiz() > > > > > > > > > > You need to instantiate your class: > > > > foo = ElementsQuiz() > > foo.quiz() > > > > > > Pedro > > - > > http://pedrokroger.net > > http://musicforgeeksandnerds.com That doesn't work either for some reason. I keep getting "NameError: name 'ElementsQuiz' is not defined" -- http://mail.python.org/mailman/listinfo/python-list
Keep getting this in PyDev "TypeError: quiz() takes exactly 1 argument (0 given)"
Hi all, I cannot figure why I keep getting this error. It is my understanding that all methods need a self argument when designing a class. Here is my code: import random class ElementsQuiz: elements = {'H' : 'Hydrogen', 'He' : 'Helium', 'Li' : 'Lithium', 'Be' : 'Beryllium', 'B' : 'Boron', 'C' : 'Carbon', 'N' : 'Nitrogen', 'O' : 'Oxygen', 'F' : 'Fluorine', 'Ne' : 'Neon', 'Na' : 'Sodium', 'Mg' : 'Magnesium', 'Al' : 'Aluminium', 'Si' : 'Silicon', 'P' : 'Phosphorus', 'S' : 'Sulfur', 'Cl' : 'Chlorine', 'Ar' : 'Argon', 'K' : 'Potassium', 'Ca' : 'Calcium', 'Sc' : 'Scandium', 'Ti' : 'Titanium', 'V' : 'Vanadium', 'Cr' : 'Chromium', 'Mn' : 'Manganese', 'Fe' : 'Iron', 'Co' : 'Cobalt', 'Ni' : 'Nickel', 'Cu' : 'Copper', 'Zn' : 'Zinc', 'Ga' : 'Gallium', 'Ge' : 'Germanium', 'As' : 'Arsenic', 'Se' : 'Selenium', 'Br' : 'Bromine', 'Kr' : 'Krypton', 'Rb' : 'Rubidium', 'Sr' : 'Strontium', 'Y' : 'Yttrium', 'Zr' : 'Zirconium', 'Nb' : 'Niobium', 'Mo' : 'Molybdenum', 'Tc' : 'Technetium', 'Ru' : 'Ruthenium', 'Rh' : 'Rhodium', 'Pd' : 'Palladium', 'Ag' : 'Silver', 'Cd' : 'Cadmium', 'In' : 'Indium', 'Sn' : 'Tin', 'Sb' : 'Antimony', 'Te' : 'Tellurium', 'I' : 'Iodine', 'Xe' : 'Xenon', 'Cs' : 'Caesium', 'Ba' : 'Barium', 'La' : 'Lanthanum', 'Ce' : 'Cerium', 'Pr' : 'Praseodymium', 'Nd' : 'Neodymium', 'Pm' : 'Promethium', 'Sm' : 'Samarium', 'Eu' : 'Europium', 'Gd' : 'Gadolinium', 'Tb' : 'Terbium', 'Dy' : 'Dysprosium', 'Ho' : 'Holmium', 'Er' : 'Erbium', 'Tm' : 'Thulium', 'Yb' : 'Ytterbium', 'Lu' : 'Lutetium', 'Hf' : 'Hafnium', 'Ta' : 'Tantalum', 'W' : 'Tungsten', 'Re' : 'Rhenium', 'Os' : 'Osmium', 'Ir' : 'Iridium', 'Pt' : 'Platinum', 'Au' : 'Gold', 'Hg' : 'Mercury', 'Tl' : 'Thallium', 'Pb' : 'Lead', 'Bi' : 'Bismuth', 'Po' : 'Polonium', 'At' : 'Astatine', 'Rn' : 'Radon', 'Fr' : 'Francium', 'Ra' : 'Radium', 'Ac' : 'Actinium', 'Th' : 'Thorium', 'Pa' : 'Protactinium', 'U' : 'Uranium', 'Np' : 'Neptunium', 'Pu' : 'Plutonium', 'Am' : 'Americium', 'Cm' : 'Curium', 'Bk' : 'Berkelium', 'Cf' : 'Californium', 'Es' : 'Einsteinium', 'Fm' : 'Fermium', 'Md' : 'Mendelevium', 'No' : 'Nobelium', 'Lr' : 'Lawrencium', 'Rf' : 'Rutherfordium', 'Db' : 'Dubnium', 'Sg' : 'Seaborgium', 'Bh' : 'Bohrium', 'Hs' : 'Hassium', 'Mt' : 'Meitnerium', 'Ds' : 'Darmstadtium', 'Rg' : 'Roentgenium', 'Cn' : 'Copernicium', 'Uut' : 'Ununtrium', 'Fl' : 'Flerovium', 'Uup' : 'Ununpentium', 'Lv' : 'Livermorium', 'Uus' : 'Ununseptium', 'Uuo' : 'Ununoctium' } def __init__(self): self.quiz() def quiz(self): self.reply = ('Moron', 'Dummy', 'Idiot', 'Embecile', 'Half-wit') self.numCorrect = 0 self.question = random.choice(self.elements.keys()) print self.question self.ans = raw_input('Answer: ') if self.ans == self.elements(self.question): self.numCorrect += 1 else: self.insult = random.choice(self.reply) print 'Incorrect %s' % self.insult if __name__ == '__main__': quiz() Thanks for any help! -- http://mail.python.org/mai
Re: installing modules in Enthought Python
On May 30, 10:57 am, David Fanning wrote: > Chuck writes: > > > I just downloaded Enthought Python, free version. I wanted all the > > included packages, but I can't seem to find the correct directory to > > install new Python modules. Does anybody have an idea? I am trying > > to add Universal Feed Parser to Enthought. I have tried C:\Python27, > > C:\Python27\Lib, C:\Python27\Lib\site-packages, but no success. > > I spent most of the day on this problem yesterday. You are > going to want to get *.exe files that will install in the > usual way on Windows. I found the packages I was looking > for at one or the other of these sites: > > http://code.google.com/p/pythonxy/wiki/AdditionalPlugins#Installation_no > tes > > http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml > > Cheers > > David > > -- > David Fanning, Ph.D. > Fanning Software Consulting, Inc. > Sepore ma de ni thui. ("Perhaps thou speakest truth.") Unfortunately, I couldn't find Universal Feed Parser, the package I was looking for, but thanks for the tip. -- http://mail.python.org/mailman/listinfo/python-list
installing modules in Enthought Python
I just downloaded Enthought Python, free version. I wanted all the included packages, but I can't seem to find the correct directory to install new Python modules. Does anybody have an idea? I am trying to add Universal Feed Parser to Enthought. I have tried C:\Python27, C:\Python27\Lib, C:\Python27\Lib\site-packages, but no success. TIA! -- http://mail.python.org/mailman/listinfo/python-list
ControlDesk, Python, ActiveX, TableEditor
I am trying to hook into the TableEditor on Controldesk using Python. Unfortunately there are no good examples of how to write the code anywhere I have looked. Does anyone know where to look? OR does anyone have code? Thanks Chuck -- http://mail.python.org/mailman/listinfo/python-list
Re: unable to compile Python 2.6.4 on AIX using gcc
Thanks Mark. That was indeed very helpful. Here's the current status: === 1. applied changes suggested by Bob Atkins in that thread. 2. setting env variables. export OBJECT_MODE=64 export CC="gcc" export CFLAGS="-maix64 -mcpu=power5" export LDFLAGS="-maix64 -L/usr/lib64 -L/opt/freeware/lib64 -L/opt/freeware/64/lib -L/usr/X11R6/lib -L/opt/freeware/lib" export CPPFLAGS="-I/opt/freeware/include -I/usr/lpp/X11/include/X11" 3. configuring and compiling using configure --with-gcc --enable-shared --prefix=/usr/local/Python-2.6.4 > config_264.log 2>&1 ; make > make_264.log 2>&1 === Both python (executable) and libpython2.6.a build just fine and are in the same directory as configure. However, none of the extensions build. I keep getting libpython2.6 not found error. Here's an example: building 'math' extension gcc -pthread -fno-strict-aliasing -maix64 -mcpu=power5 -DNDEBUG -O3 -Wall -Wstrict-prototypes -I. -I/usr/local/build/python/Python-2.6.4/./Include -I. - IInclude -I./Include -I/opt/freeware/include -I/usr/lpp/X11/include/X11 -I/usr/local/include -I/usr/local/build/python/Python-2.6.4/Include -I/usr/local /build/python/Python-2.6.4 -c /usr/local/build/python/Python-2.6.4/Modules/mathmodule.c -o build/temp.aix-5.3-2.6/usr/local/build/python/Python-2.6.4/Mo dules/mathmodule.o ./Modules/ld_so_aix gcc -pthread -bI:Modules/python.exp -maix64 -L/usr/lib64 -L/opt/freeware/lib64 -L/opt/freeware/64/lib -L/usr/X11R6/lib -L/opt/freewa re/lib -fno-strict-aliasing -maix64 -mcpu=power5 -DNDEBUG -O3 -Wall -Wstrict-prototypes -I. -IInclude -I./Include -I/opt/freeware/include -I/usr/lpp/X11 /include/X11 build/temp.aix-5.3-2.6/usr/local/build/python/Python-2.6.4/Modules/mathmodule.o -L/usr/lib64 -L/opt/freeware/lib64 -L/opt/freeware/64/lib - L/usr/X11R6/lib -L/opt/freeware/lib -L/usr/local/lib -lm -lpython2.6 -o build/lib.aix-5.3-2.6/math.so collect2: library libpython2.6 not found I hacked Makefile to LDFLAGS=<> -L./ I now get: ld: 0711-224 WARNING: Duplicate symbol: PyObject_Size ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information. Fatal Python error: Interpreter not initialized (version mismatch?) make: The signal code from the last command is 6. There are no other versions of python on that machine. I would appreciate any help. Do I need to set the exec_prefix as well? Thanks. Mark Dickinson wrote: On Nov 3, 10:40 pm, chuck wrote: Hello -- I am trying to compile Python 2.6.4 on a Power 5 PC with AIX 5.3. Here are the settings: Take a look at: http://bugs.python.org/issue1628484 Mark -- http://mail.python.org/mailman/listinfo/python-list
unable to compile Python 2.6.4 on AIX using gcc
Hello -- I am trying to compile Python 2.6.4 on a Power 5 PC with AIX 5.3. Here are the settings: export OBJECT_MODE=64 export AR="ar -X64" export MAKE=/usr/bin/gmake export CC="gcc" export CFLAGS="-maix64 -O2 -g -mcpu=power5" export LDFLAGS="-L/usr/lib64 -L/opt/freeware/lib64 -L/opt/freeware/64/lib -L/usr/X11R6/lib -L/opt/freeware/lib" export CPPFLAGS="-I/opt/freeware/include -I/usr/lpp/X11/include/X11" ../Python-2.6.4/configure --with-gcc --disable-ipv6 --prefix=/usr/local/Python-2.6.4 > config_264.log 2>&1 make > make_264.log 2>&1 make fails very early with the following error === gcc -pthread -c -fno-strict-aliasing -DNDEBUG -O3 -Wall -Wstrict-prototypes -I. -IInclude -I../Python-2.6.4/Includ e -I/opt/freeware/include -I/usr/lpp/X11/include/X11 -DPy_BUILD_CORE -o Modules/python.o ../Python-2.6.4/Modules/python.c In file included from ../Python-2.6.4/Include/Python.h:58, from ../Python-2.6.4/Modules/python.c:3: ../Python-2.6.4/Include/pyport.h:685:2: error: #error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config ?)." make: The error code from the last command is 1. === I would appreciate any help. Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: Podcast catcher in Python
Never mind, guys I finally got things working. Woo hoo -- http://mail.python.org/mailman/listinfo/python-list
Re: Podcast catcher in Python
On Sep 19, 7:40 am, Dave Angel wrote: > Chuck wrote: > > On Sep 12, 3:37 pm, Chuck wrote: > > >> On Sep 11, 9:54 pm, Chris Rebert wrote: > > >>> On Fri, Sep 11, 2009 at 7:43 PM, Chuck wrote: > > >>>> Does anyone know how I should read/download the mp3 file, and how I > >>>> should write/save it so that I can play it on a media player such as > >>>> Windoze media player? Excuse my ignorance, but I am a complete noob > >>>> at this. I downloaded the mp3, and I got a ton of hex, I think, but > >>>> it could've been unicode. > > >>> urllib.urlretrieve():http://docs.python.org/library/urllib.html#urllib.urlretrieve > > >>> Cheers, > >>> Chris > > >> Thanks Chris! I will play around with this. > > > I am using Python 3.1, but I can't figure out why I can't use > > xml.dom.minidom. Here is my code: > > > from xml.dom.minidom import parse, parseString > > url =http://minnesota.publicradio.org/tools/podcasts/ > > grammar_grater.xml' #just for test purposes > > > doc =arse(url) #I have also tried parseString(url), not to mention > > a million other methods from xml.Etree, xml.sax etc... all to no > > avail > > > What the heck am I doing wrong? How can I get this xml file and use > > the toprettyxml() method. Or something, so I can parse it. I don't > > have any books and the documentation for Python kind of sucks. I am a > > complete noob to Python and internet programming. (I'm sure that is > > obvious :) ) > > > Thanks! > > > Charlie > > Wrong? You didn't specify your OS environment, you didn't show the > error message (and traceback), you posted an apparently unrelated > question in the same thread (there's no XML inside a mp3 file). > > xml.dom.minidom.parse() takes a filename or a 'file' object as its first > argument. You gave it a URL, so it complained. You can fix that either > by using urllib.urlopen() or by separately copying the data to a local > file and using its filename here. > > In general, I'd recommend against testing new code live against the > internet, since errors can occur from the vagaries of the internet as > well as from bugs in your code. Sometimes it's hard to tell the > difference when the symptoms change each time you run. > > So I'd download the xml data that you want to test with to a local file, > and test out your parsing logic against that copy. In fact, first > testing will probably be against a simplified version of that copy. > > How do you download the file? Well, if you're using Firefox, you can > browse to that page, and do View->Source. Then copy/paste that text > into a text editor, and save it locally. Something similar probably > works in other browsers, maybe even IE. > > Or you can use urlretrieve, as suggested earlier in this thread. But > I'd make that a separate script, so that you can separate the bugs in > downloading from the bugs in parsing. After everything mostly works, > you can think about combining them. > > DaveA Okay, I have tried to use urllib.request.urlretrieve() to download an mp3, but my cursor just sits and blinks at me. This a small file, so it should take more that a few minutes. Hmmm? Here is my code: url = 'http://download.publicradio.org/podcast/minnesota/news/programs/ 2009/09/10/grammar_20090910_64.mp3' file = 'C:\\Documents and Settings\\Compaq_Owner\\Desktop\ \GramGrate.mp3' import urllib.request b4 = urllib.request.urlretrieve(url, file) at this point, the cursor just sits and blinks forever. Any ideas? I really appreciate this guys. -- http://mail.python.org/mailman/listinfo/python-list
Re: Podcast catcher in Python
On Sep 19, 7:40 am, Dave Angel wrote: > Chuck wrote: > > On Sep 12, 3:37 pm, Chuck wrote: > > >> On Sep 11, 9:54 pm, Chris Rebert wrote: > > >>> On Fri, Sep 11, 2009 at 7:43 PM, Chuck wrote: > > >>>> Does anyone know how I should read/download the mp3 file, and how I > >>>> should write/save it so that I can play it on a media player such as > >>>> Windoze media player? Excuse my ignorance, but I am a complete noob > >>>> at this. I downloaded the mp3, and I got a ton of hex, I think, but > >>>> it could've been unicode. > > >>> urllib.urlretrieve():http://docs.python.org/library/urllib.html#urllib.urlretrieve > > >>> Cheers, > >>> Chris > > >> Thanks Chris! I will play around with this. > > > I am using Python 3.1, but I can't figure out why I can't use > > xml.dom.minidom. Here is my code: > > > from xml.dom.minidom import parse, parseString > > url =http://minnesota.publicradio.org/tools/podcasts/ > > grammar_grater.xml' #just for test purposes > > > doc =arse(url) #I have also tried parseString(url), not to mention > > a million other methods from xml.Etree, xml.sax etc... all to no > > avail > > > What the heck am I doing wrong? How can I get this xml file and use > > the toprettyxml() method. Or something, so I can parse it. I don't > > have any books and the documentation for Python kind of sucks. I am a > > complete noob to Python and internet programming. (I'm sure that is > > obvious :) ) > > > Thanks! > > > Charlie > > Wrong? You didn't specify your OS environment, you didn't show the > error message (and traceback), you posted an apparently unrelated > question in the same thread (there's no XML inside a mp3 file). > > xml.dom.minidom.parse() takes a filename or a 'file' object as its first > argument. You gave it a URL, so it complained. You can fix that either > by using urllib.urlopen() or by separately copying the data to a local > file and using its filename here. > > In general, I'd recommend against testing new code live against the > internet, since errors can occur from the vagaries of the internet as > well as from bugs in your code. Sometimes it's hard to tell the > difference when the symptoms change each time you run. > > So I'd download the xml data that you want to test with to a local file, > and test out your parsing logic against that copy. In fact, first > testing will probably be against a simplified version of that copy. > > How do you download the file? Well, if you're using Firefox, you can > browse to that page, and do View->Source. Then copy/paste that text > into a text editor, and save it locally. Something similar probably > works in other browsers, maybe even IE. > > Or you can use urlretrieve, as suggested earlier in this thread. But > I'd make that a separate script, so that you can separate the bugs in > downloading from the bugs in parsing. After everything mostly works, > you can think about combining them. > > DaveA Oh yeah! I am using Windows XP. -- http://mail.python.org/mailman/listinfo/python-list
Re: Podcast catcher in Python
On Sep 19, 7:40 am, Dave Angel wrote: > Chuck wrote: > > On Sep 12, 3:37 pm, Chuck wrote: > > >> On Sep 11, 9:54 pm, Chris Rebert wrote: > > >>> On Fri, Sep 11, 2009 at 7:43 PM, Chuck wrote: > > >>>> Does anyone know how I should read/download the mp3 file, and how I > >>>> should write/save it so that I can play it on a media player such as > >>>> Windoze media player? Excuse my ignorance, but I am a complete noob > >>>> at this. I downloaded the mp3, and I got a ton of hex, I think, but > >>>> it could've been unicode. > > >>> urllib.urlretrieve():http://docs.python.org/library/urllib.html#urllib.urlretrieve > > >>> Cheers, > >>> Chris > > >> Thanks Chris! I will play around with this. > > > I am using Python 3.1, but I can't figure out why I can't use > > xml.dom.minidom. Here is my code: > > > from xml.dom.minidom import parse, parseString > > url =http://minnesota.publicradio.org/tools/podcasts/ > > grammar_grater.xml' #just for test purposes > > > doc =arse(url) #I have also tried parseString(url), not to mention > > a million other methods from xml.Etree, xml.sax etc... all to no > > avail > > > What the heck am I doing wrong? How can I get this xml file and use > > the toprettyxml() method. Or something, so I can parse it. I don't > > have any books and the documentation for Python kind of sucks. I am a > > complete noob to Python and internet programming. (I'm sure that is > > obvious :) ) > > > Thanks! > > > Charlie > > Wrong? You didn't specify your OS environment, you didn't show the > error message (and traceback), you posted an apparently unrelated > question in the same thread (there's no XML inside a mp3 file). > > xml.dom.minidom.parse() takes a filename or a 'file' object as its first > argument. You gave it a URL, so it complained. You can fix that either > by using urllib.urlopen() or by separately copying the data to a local > file and using its filename here. > > In general, I'd recommend against testing new code live against the > internet, since errors can occur from the vagaries of the internet as > well as from bugs in your code. Sometimes it's hard to tell the > difference when the symptoms change each time you run. > > So I'd download the xml data that you want to test with to a local file, > and test out your parsing logic against that copy. In fact, first > testing will probably be against a simplified version of that copy. > > How do you download the file? Well, if you're using Firefox, you can > browse to that page, and do View->Source. Then copy/paste that text > into a text editor, and save it locally. Something similar probably > works in other browsers, maybe even IE. > > Or you can use urlretrieve, as suggested earlier in this thread. But > I'd make that a separate script, so that you can separate the bugs in > downloading from the bugs in parsing. After everything mostly works, > you can think about combining them. > > DaveA Okay, that makes sense. I will try that. Essentially, what I am trying to learn by just reading articles on the web is how to access info on the web using Python, i.e. weather data, podcasts, etc... I have never done it before in any language. So, I am trying to do something that I've never done before with a language I barely know. Can be very frustrating. :( Thanks for all the help! -- http://mail.python.org/mailman/listinfo/python-list
Re: Podcast catcher in Python
On Sep 12, 3:37 pm, Chuck wrote: > On Sep 11, 9:54 pm, Chris Rebert wrote: > > > On Fri, Sep 11, 2009 at 7:43 PM, Chuck wrote: > > > Does anyone know how I should read/download the mp3 file, and how I > > > should write/save it so that I can play it on a media player such as > > > Windoze media player? Excuse my ignorance, but I am a complete noob > > > at this. I downloaded the mp3, and I got a ton of hex, I think, but > > > it could've been unicode. > > > urllib.urlretrieve():http://docs.python.org/library/urllib.html#urllib.urlretrieve > > > Cheers, > > Chris > > Thanks Chris! I will play around with this. I am using Python 3.1, but I can't figure out why I can't use xml.dom.minidom. Here is my code: from xml.dom.minidom import parse, parseString url = 'http://minnesota.publicradio.org/tools/podcasts/ grammar_grater.xml' #just for test purposes doc = parse(url) #I have also tried parseString(url), not to mention a million other methods from xml.Etree, xml.sax etc... all to no avail What the heck am I doing wrong? How can I get this xml file and use the toprettyxml() method. Or something, so I can parse it. I don't have any books and the documentation for Python kind of sucks. I am a complete noob to Python and internet programming. (I'm sure that is obvious :) ) Thanks! Charlie -- http://mail.python.org/mailman/listinfo/python-list
Re: Podcast catcher in Python
On Sep 11, 9:54 pm, Chris Rebert wrote: > On Fri, Sep 11, 2009 at 7:43 PM, Chuck wrote: > > Does anyone know how I should read/download the mp3 file, and how I > > should write/save it so that I can play it on a media player such as > > Windoze media player? Excuse my ignorance, but I am a complete noob > > at this. I downloaded the mp3, and I got a ton of hex, I think, but > > it could've been unicode. > > urllib.urlretrieve():http://docs.python.org/library/urllib.html#urllib.urlretrieve > > Cheers, > Chris Thanks Chris! I will play around with this. -- http://mail.python.org/mailman/listinfo/python-list
Re: Podcast catcher in Python
On Sep 11, 9:07 pm, Chuck wrote: > On Sep 11, 8:32 pm, Chris Rebert wrote: > > > > > > > On Fri, Sep 11, 2009 at 11:09 AM, Chuck wrote: > > > On Sep 11, 12:56 pm, Chuck wrote: > > >> On Sep 11, 10:30 am, Falcolas wrote: > > >> > On Sep 11, 8:20 am, Chuck wrote: > > > >> > > Hi all, > > > >> > > I would like to code a simple podcast catcher in Python merely as an > > >> > > exercise in internet programming. I am a CS student and new to > > >> > > Python, but understand Java fairly well. I understand how to connect > > >> > > to a server with urlopen, but then I don't understand how to download > > >> > > the mp3, or whatever, podcast? Do I need to somehow parse the XML > > >> > > document? I really don't know. Any ideas? > > > >> > > Thanks! > > > >> > > Chuck > > > >> > You will first have to download the RSS XML file, then parse that file > > >> > for the URL for the audio file itself. Something like eTree will help > > >> > immensely in this part. You'll also have to keep track of what you've > > >> > already downloaded. > > > >> > I'd recommend taking a look at the RSS XML yourself, so you know what > > >> > it is you have to parse out, and where to find it. From there, it > > >> > should be fairly easy to come up with the proper query to pull it > > >> > automatically out of the XML. > > > >> > As a kindness to the provider, I would recommend a fairly lengthy > > >> > sleep between GETs, particularly if you want to scrape their back > > >> > catalog. > > > >> > Unfortunately, I no longer have the script I created to do just such a > > >> > thing in the past, but the process is rather straightforward, once you > > >> > know where to look. > > > > I am not sure how eTree fits in. Is that eTree.org? > > > No, he's referring to the `xml.etree.elementtree` standard > > module:http://docs.python.org/library/xml.etree.elementtree.html#module-xml > > > Although since you're dealing with feeds, you might be able to use > > Universal Feed Parser, which is specifically for > > RSS/Atom:http://www.feedparser.org/ > > > Cheers, > > Chris > > --http://blog.rebertia.com > > Brilliant! I will give that a try. > Cheers! Does anyone know how I should read/download the mp3 file, and how I should write/save it so that I can play it on a media player such as Windoze media player? Excuse my ignorance, but I am a complete noob at this. I downloaded the mp3, and I got a ton of hex, I think, but it could've been unicode. -- http://mail.python.org/mailman/listinfo/python-list
Re: Podcast catcher in Python
On Sep 11, 8:32 pm, Chris Rebert wrote: > On Fri, Sep 11, 2009 at 11:09 AM, Chuck wrote: > > On Sep 11, 12:56 pm, Chuck wrote: > >> On Sep 11, 10:30 am, Falcolas wrote: > >> > On Sep 11, 8:20 am, Chuck wrote: > > >> > > Hi all, > > >> > > I would like to code a simple podcast catcher in Python merely as an > >> > > exercise in internet programming. I am a CS student and new to > >> > > Python, but understand Java fairly well. I understand how to connect > >> > > to a server with urlopen, but then I don't understand how to download > >> > > the mp3, or whatever, podcast? Do I need to somehow parse the XML > >> > > document? I really don't know. Any ideas? > > >> > > Thanks! > > >> > > Chuck > > >> > You will first have to download the RSS XML file, then parse that file > >> > for the URL for the audio file itself. Something like eTree will help > >> > immensely in this part. You'll also have to keep track of what you've > >> > already downloaded. > > >> > I'd recommend taking a look at the RSS XML yourself, so you know what > >> > it is you have to parse out, and where to find it. From there, it > >> > should be fairly easy to come up with the proper query to pull it > >> > automatically out of the XML. > > >> > As a kindness to the provider, I would recommend a fairly lengthy > >> > sleep between GETs, particularly if you want to scrape their back > >> > catalog. > > >> > Unfortunately, I no longer have the script I created to do just such a > >> > thing in the past, but the process is rather straightforward, once you > >> > know where to look. > > > I am not sure how eTree fits in. Is that eTree.org? > > No, he's referring to the `xml.etree.elementtree` standard > module:http://docs.python.org/library/xml.etree.elementtree.html#module-xml > > Although since you're dealing with feeds, you might be able to use > Universal Feed Parser, which is specifically for > RSS/Atom:http://www.feedparser.org/ > > Cheers, > Chris > --http://blog.rebertia.com Brilliant! I will give that a try. Cheers! -- http://mail.python.org/mailman/listinfo/python-list
Re: Podcast catcher in Python
On Sep 11, 1:09 pm, Chuck wrote: > On Sep 11, 12:56 pm, Chuck wrote: > > > > > > > On Sep 11, 10:30 am, Falcolas wrote: > > > > On Sep 11, 8:20 am, Chuck wrote: > > > > > Hi all, > > > > > I would like to code a simple podcast catcher in Python merely as an > > > > exercise in internet programming. I am a CS student and new to > > > > Python, but understand Java fairly well. I understand how to connect > > > > to a server with urlopen, but then I don't understand how to download > > > > the mp3, or whatever, podcast? Do I need to somehow parse the XML > > > > document? I really don't know. Any ideas? > > > > > Thanks! > > > > > Chuck > > > > You will first have to download the RSS XML file, then parse that file > > > for the URL for the audio file itself. Something like eTree will help > > > immensely in this part. You'll also have to keep track of what you've > > > already downloaded. > > > > I'd recommend taking a look at the RSS XML yourself, so you know what > > > it is you have to parse out, and where to find it. From there, it > > > should be fairly easy to come up with the proper query to pull it > > > automatically out of the XML. > > > > As a kindness to the provider, I would recommend a fairly lengthy > > > sleep between GETs, particularly if you want to scrape their back > > > catalog. > > > > Unfortunately, I no longer have the script I created to do just such a > > > thing in the past, but the process is rather straightforward, once you > > > know where to look. > > > > ~G > > > Thanks! I will see what I can do.- Hide quoted text - > > > - Show quoted text - > > I am not sure how eTree fits in. Is that eTree.org?- Hide quoted text - > > - Show quoted text - Can I just use x.read() to download the mp3 file and use x.write() to write it to a file? Or, do I have to worry about encoding/decoding etc...? I am under the impression that I can just read the mp3 and write to a file, then play it in a media player. Is this too simplified? -- http://mail.python.org/mailman/listinfo/python-list
Re: Podcast catcher in Python
On Sep 11, 12:56 pm, Chuck wrote: > On Sep 11, 10:30 am, Falcolas wrote: > > > > > > > On Sep 11, 8:20 am, Chuck wrote: > > > > Hi all, > > > > I would like to code a simple podcast catcher in Python merely as an > > > exercise in internet programming. I am a CS student and new to > > > Python, but understand Java fairly well. I understand how to connect > > > to a server with urlopen, but then I don't understand how to download > > > the mp3, or whatever, podcast? Do I need to somehow parse the XML > > > document? I really don't know. Any ideas? > > > > Thanks! > > > > Chuck > > > You will first have to download the RSS XML file, then parse that file > > for the URL for the audio file itself. Something like eTree will help > > immensely in this part. You'll also have to keep track of what you've > > already downloaded. > > > I'd recommend taking a look at the RSS XML yourself, so you know what > > it is you have to parse out, and where to find it. From there, it > > should be fairly easy to come up with the proper query to pull it > > automatically out of the XML. > > > As a kindness to the provider, I would recommend a fairly lengthy > > sleep between GETs, particularly if you want to scrape their back > > catalog. > > > Unfortunately, I no longer have the script I created to do just such a > > thing in the past, but the process is rather straightforward, once you > > know where to look. > > > ~G > > Thanks! I will see what I can do.- Hide quoted text - > > - Show quoted text - I am not sure how eTree fits in. Is that eTree.org? -- http://mail.python.org/mailman/listinfo/python-list
Re: Podcast catcher in Python
On Sep 11, 10:30 am, Falcolas wrote: > On Sep 11, 8:20 am, Chuck wrote: > > > Hi all, > > > I would like to code a simple podcast catcher in Python merely as an > > exercise in internet programming. I am a CS student and new to > > Python, but understand Java fairly well. I understand how to connect > > to a server with urlopen, but then I don't understand how to download > > the mp3, or whatever, podcast? Do I need to somehow parse the XML > > document? I really don't know. Any ideas? > > > Thanks! > > > Chuck > > You will first have to download the RSS XML file, then parse that file > for the URL for the audio file itself. Something like eTree will help > immensely in this part. You'll also have to keep track of what you've > already downloaded. > > I'd recommend taking a look at the RSS XML yourself, so you know what > it is you have to parse out, and where to find it. From there, it > should be fairly easy to come up with the proper query to pull it > automatically out of the XML. > > As a kindness to the provider, I would recommend a fairly lengthy > sleep between GETs, particularly if you want to scrape their back > catalog. > > Unfortunately, I no longer have the script I created to do just such a > thing in the past, but the process is rather straightforward, once you > know where to look. > > ~G Thanks! I will see what I can do. -- http://mail.python.org/mailman/listinfo/python-list
Re: Podcast catcher in Python
Also, if anyone could recommend some books that cover this type of programming, I would greatly appreciate it. Thanks! -- http://mail.python.org/mailman/listinfo/python-list
Podcast catcher in Python
Hi all, I would like to code a simple podcast catcher in Python merely as an exercise in internet programming. I am a CS student and new to Python, but understand Java fairly well. I understand how to connect to a server with urlopen, but then I don't understand how to download the mp3, or whatever, podcast? Do I need to somehow parse the XML document? I really don't know. Any ideas? Thanks! Chuck -- http://mail.python.org/mailman/listinfo/python-list
Re: Reading then sending new parts of a log file
On Jun 24, 2:48 pm, unayok wrote: > Here's a little nudge:http://code.activestate.com/recipes/157035/ > > In place of its "print" line, you'd make your call into your existing > code to send the message. Wow! Thanks for the _shove_ in the right direction. Looks perfect. -- http://mail.python.org/mailman/listinfo/python-list
Re: Reading then sending new parts of a log file
On Jun 24, 11:57 am, Scott David Daniels wrote: > What OS and version, what Python and version. Win XP, Python 2.6.2 -- http://mail.python.org/mailman/listinfo/python-list
Reading then sending new parts of a log file
Hey guys. I'm trying to work up a little program that will send any new lines written to a file (log file from my home automation software) to me via instant message. I've gotten the instant message sending part figured out using xmpppy. I've done a few things with Python in the past but I am in no means more than a beginner/hacker. Can someone tell me what commands/ modules/etc exist for monitoring and parsing a file for new information that I can then send to my IM sending function? I am not asking for anyone to write the code but merely a push in the right direction. Thanks! -- http://mail.python.org/mailman/listinfo/python-list
Re: What does self.grid() do?
On Mar 5, 3:03 am, Marc 'BlackJack' Rintsch wrote: > On Wed, 04 Mar 2009 09:04:50 -0800, chuck wrote: > > On Mar 3, 10:40 pm, Marc 'BlackJack' Rintsch wrote: > >> On Tue, 03 Mar 2009 18:06:56 -0800, chuck wrote: > >> > I am learning python right now. In the lesson on tkinter I see this > >> > piece of code > > >> > from Tkinter import * > > >> > class MyFrame(Frame): > >> > def __init__(self): > >> > Frame.__init__(self) > >> > self.grid() > > >> > My question is what does "self.grid()" do? I understand that the > >> > grid method registers widgets with the geometry manager and adds them > >> > to the frame > > >> Not "the frame" but the container widget that is the parent of the > >> widget on which you call `grid()`. In this case that would be a (maybe > >> implicitly created) `Tkinter.Tk` instance, because there is no explicit > >> parent widget set here. Which IMHO is not a good idea. > > >> And widgets that layout themselves in the `__init__()` are a code smell > >> too. No standard widget does this, and it takes away the flexibility > >> of the code using that widget to decide how and where it should be > >> placed. > > > I think I understand what you're saying! How would you recommend I go > > about this? How do I create an explicit parent? > > You create it and pass it as argument to child widgets. > > import Tkinter as tk > > class MyFrame(tk.Frame): > def __init__(self, parent): > tk.Frame.__init__(self, parent) > > > What exactly is meant by "widgets that layout themselves"- what is the > > right way to do this? > > Call one of the three layout methods on the widget instance after you > created it, and not in the `__init__()` of the widget. > > Your example above "grids" itself at its parent widget, I think at the > next free cell on a grid if you don't give the position as argument. > There is no chance to use another layout manager or to place it in > another cell. > > Ciao, > Marc 'BlackJack' Rintsch Wow- lots of good answers and directions- let me go off and digest this. Thanks Marc and "r". -- http://mail.python.org/mailman/listinfo/python-list
Re: What does self.grid() do?
On Mar 3, 10:40 pm, Marc 'BlackJack' Rintsch wrote: > On Tue, 03 Mar 2009 18:06:56 -0800, chuck wrote: > > I am learning python right now. In the lesson on tkinter I see this > > piece of code > > > from Tkinter import * > > > class MyFrame(Frame): > > def __init__(self): > > Frame.__init__(self) > > self.grid() > > > My question is what does "self.grid()" do? I understand that the grid > > method registers widgets with the geometry manager and adds them to the > > frame > > Not "the frame" but the container widget that is the parent of the widget > on which you call `grid()`. In this case that would be a (maybe > implicitly created) `Tkinter.Tk` instance, because there is no explicit > parent widget set here. Which IMHO is not a good idea. > > And widgets that layout themselves in the `__init__()` are a code smell > too. No standard widget does this, and it takes away the flexibility of > the code using that widget to decide how and where it should be placed. > > Ciao, > Marc 'BlackJack' Rintsch I think I understand what you're saying! How would you recommend I go about this? How do I create an explicit parent? What exactly is meant by "widgets that layout themselves"- what is the right way to do this? Thanks! -- http://mail.python.org/mailman/listinfo/python-list
What does self.grid() do?
I am learning python right now. In the lesson on tkinter I see this piece of code from Tkinter import * class MyFrame(Frame): def __init__(self): Frame.__init__(self) self.grid() My question is what does "self.grid()" do? I understand that the grid method registers widgets with the geometry manager and adds them to the frame But in this case am I adding the frame to the frame? Not able to understand the response from my class discussion board, hence posting here. THanks! -- http://mail.python.org/mailman/listinfo/python-list
Re: Need help converting text to csv format
Firstly, I would like to thank those that offered help. I was able to get my data into the database and also have connectivity with the mysql and can pull the data in/out at will. Hooray and thanks again. Secondly, perhaps I overstated my abilities. I have written a couple of websites from scratch that pull data in/out of databases and have formatted their outputs for user consumption. I am by no means a php expert and have never had occasion to use regular expressions for the type of data I've been manipulating. My sarcastic reply was only in response to the 'go google it' answer I received to what I thought was a fair question. It's usually easiest to google something if you know what you are looking for. At no point did I expect anyone to spend a great deal of time working out my specific problem but I am most grateful for those who did provide more than what could have been expected. -- http://mail.python.org/mailman/listinfo/python-list
Re: Need help converting text to csv format
Wow! What a change in direction from the previous post. Thank you both for the help and the explanations. This will work great! -- http://mail.python.org/mailman/listinfo/python-list
Re: Need help converting text to csv format
> I'm wondering if PHP experience precludes the ability to use a search > engine before asking for help... Thanks for the push in the right direction, friend. -- http://mail.python.org/mailman/listinfo/python-list
Need help converting text to csv format
Hey guys. I'm working on a little program to help my wife catalog her/ our coupons. I found a good resource but need help formatting the text data so that I can import it into a mysql database. Here's the data format: 40922003 Life Fitness Products $1 (12-13-08) (CVS) 546500181141 Oust Air Sanitizer, any B1G1F up to $3.49 (1-17-09) .35 each 518000159258 Pillsbury Crescent Dinner Rolls, any .25 (2-14-09) 518000550406 Pillsbury Frozen Grands Biscuits, Cinnamon Rolls, Mini Cinnamon Rolls, etc. .40 (2-14-09) The first value (large number) is the UPC, the next element is the coupon description, followed by a date in parenthesis. Those are the only three elements I am concerned with. Can someone help me in reformatting this: 40922003 Life Fitness Products $1 (12-13-08) (CVS) 546500181141 Oust Air Sanitizer, any B1G1F up to $3.49 (1-17-09) .35 each 518000159258 Pillsbury Crescent Dinner Rolls, any .25 (2-14-09) 518000550406 Pillsbury Frozen Grands Biscuits, Cinnamon Rolls, Mini Cinnamon Rolls, etc. .40 (2-14-09) into something like this: "40922003","Life Fitness Products $1","12-13-08" "546500181141","Oust Air Sanitizer, any B1G1F up to $3.49","1-17-09" "518000159258","Pillsbury Crescent Dinner Rolls, any .25","2-14-09" "518000550406","Pillsbury Frozen Grands Biscuits, Cinnamon Rolls, Mini Cinnamon Rolls, etc. .40","2-14-09" Any help, pseudo code, or whatever push in the right direction would be most appreciated. I am a novice Python programmer but I do have a good bit of PHP programming experience. Thanks for your time -- http://mail.python.org/mailman/listinfo/python-list
"Music Theory Programming" Google Group
Outstretched (Omar?) Today I answered a query you presented two years ago about programming music at VBAX, "Using Arrays and Indexes To Manipulate Variables ( A Music Project )". I don't know if you solved it but I realized that the notes and MIDI codes actually follow a base 12 (duodecimal) system. My response is at: http://www.vbaexpress.com/forum/showthread.php?t=10065 A little confusing (I confused myself) and tried to clear it with a reply to my own note. Using base 12 makes it easy to add key numbers and change the music key. Sorry it was two years too late, but I just joined VBAX today (I hope someone will answer my question but it seems no one is interested). I am not a musician (but I have a piano I want to sell). Chuck Charles L. Cronan, PhD 4239 N. Larkin St Shorewood, WI 53211-1558 414-962-1627 [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Good python equivalent to C goto
On Sun, 17 Aug 2008 09:08:35 -0500, Grant Edwards wrote: > In Python one uses try/raise/except. At the risk of introducing an anachronism and in deference to Mr. "ElementTree" Lundh, I now invoke Godwin's Law (1990): Isn't *try/except* kinda sorta like the musty, old *come from* construct proposed for *fortran*? Here there be typos (abject apologies): o Clark, R. Lawrence. "A Linguistic Contribution to GOTO-less Programming." _Datamation_ Dec. 1973. 18 Aug. 2008 <http://www.fortranlib.com/gotoless.htm>. -- .. Be Seeing You, .. Chuck Rhode, Sheboygan, WI, USA .. Weather: http://LacusVeris.com/WX .. 71° — Wind W 9 mph -- http://mail.python.org/mailman/listinfo/python-list
Re: Web Crawler - Python or Perl?
On Sun, 22 Jun 2008 10:47:59 -0700, subeen wrote: > You can avoid the problem using the following code: > import socket > timeout = 300 # seconds > socket.setdefaulttimeout(timeout) Yes, I tried that, too, but I forget what went wrong with it. Perhaps, the socket kept up the handshake even though the download stalled. -- .. Chuck Rhode, Sheboygan, WI, USA .. 1979 Honda Goldwing GL1000 (Geraldine) .. Weather: http://LacusVeris.com/WX .. 73° — Wind Calm -- http://mail.python.org/mailman/listinfo/python-list
Re: Web Crawler - Python or Perl?
On Mon, 09 Jun 2008 10:48:03 -0700, disappearedng wrote: > I know Python but not Perl, and I am interested in knowing which of > these two are a better choice. I'm partial to *Python*, but, the last time I looked, *urllib2* didn't provide a time-out mechanism that worked under all circumstances. My client-side scripts would usually hang when the server quit responding, which happened a lot. You can get around this by starting an *html* retrieval in its own thread, giving it a deadline, and killing it if it doesn't finish gracefully. A quicker and considerably grittier solution is to supply timeout parms to the *curl* command through the shell. Execute the command and retrieve its output through the *subprocess* module. -- .. Chuck Rhode, Sheboygan, WI, USA .. 1979 Honda Goldwing GL1000 (Geraldine) .. Weather: http://LacusVeris.com/WX .. 64° — Wind SE 5 mph — Sky partly cloudy. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 3000: Standard API for archives?
Tim Golden wrote this on Mon, 04 Jun 2007 15:55:30 +0100. My reply is below. > Chuck Rhode wrote: >> samwyse wrote this on Mon, 04 Jun 2007 12:02:03 +. My reply is >> below. >>> I think it would be a good thing if a standardized interface >>> existed, similar to PEP 247. This would make it easier for one >>> script to access multiple types of archives, such as RAR, 7-Zip, >>> ISO, etc. >> Gee, it would be great to be able to open an archive member for >> update I/O. This is kind of hard to do now. If it were possible, >> though, it would obscure the difference between file directories >> and archives, which would be kind of neat. Furthermore, you could >> navigate archives of archives (zips of tars and other >> abominations). > Just put something together a module called "archive" or whatever, > which exposes the kind of API you're thinking of, offering support > across zip, bz2 and whatever else you want. Put it up on the > Cheeseshop, announce it on c.l.py.ann and anywhere else which seems > apt. See if it gains traction. Take it from there. > NB This has the advantage that you can start small, say with zip and > bz2 support and maybe see if you get contributions for less common > formats, even via 3rd party libs. If you were to try to get it into > the stdlib it would need to be much more fully specified up front, I > suspect. Yeah, this is in the daydreaming stages. I'd like to maintain not-just-read-only libraries of geographic shapefiles, which are available free from governmental agencies and which are riddled with obvious errors. Typically these are published in compressed archives within which every subdirectory is likewise compressed (apparently for no other purpose than a rather vain attempt at flattening the directory structure, which must be reconstituted on the User's end anyway). Building a comprehensive index to what member name(s) the different map layers (roads, political boundaries, watercourses) have in various political districts of varying geographic resolutions is much more than merely frustrating. I've given it up. However, I believe that once I've located something usable, the thing to do is save a grand unified reference locator (GURL) for it. The GURL would specify a directory path to the highest level archive followed by a (potential cascade of) archive member name(s for enclosed archives) of the data file(s) to be operated on. Unpacking and repacking would be behind the scenes. Updates (via FTP) of non-local resources would be transparent, too. I think, though, that notes about the publication date, publisher, resolution, area covered, and format of the map or map layer ought to be kept out of the GURL. My whole appetite for this sort of thing would vanish if access to the shapefiles were more tractable to begin with. -- .. Chuck Rhode, Sheboygan, WI, USA .. 1979 Honda Goldwing GL1000 (Geraldine) .. Weather: http://LacusVeris.com/WX .. 52° — Wind N 9 mph — Sky overcast. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 3000: Standard API for archives?
samwyse wrote this on Mon, 04 Jun 2007 12:02:03 +. My reply is below. > I think it would be a good thing if a standardized interface > existed, similar to PEP 247. This would make it easier for one > script to access multiple types of archives, such as RAR, 7-Zip, > ISO, etc. Gee, it would be great to be able to open an archive member for update I/O. This is kind of hard to do now. If it were possible, though, it would obscure the difference between file directories and archives, which would be kind of neat. Furthermore, you could navigate archives of archives (zips of tars and other abominations). -- .. Chuck Rhode, Sheboygan, WI, USA .. Weather: http://LacusVeris.com/WX .. 62° — Wind N 7 mph — Sky overcast. Mist. -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP 8 style enforcing program
montyphyton wrote this on Thu, 31 May 2007 05:16:30 -0700. My reply is below. > I understand that there are a lot of code beautifiers out there, but > i haven't seen one specially tailored for Python. Consider PythonTidy: o http://lacusveris.com/PythonTidy/PythonTidy.python -- .. Chuck Rhode, Sheboygan, WI, USA .. Weather: http://LacusVeris.com/WX .. 75° — Wind SSE 9 mph — Sky haze. -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP 3131: Supporting Non-ASCII Identifiers
Grant Edwards wrote this on Mon, 14 May 2007 19:22:16 +. My reply is below. >> Of course. If they're any longer than that then you can't fit an >> entire identifier into a 36-bit CDC 6600 machine register so you >> can do a compare with a single machine instruction. While skimming this discussion, I, too, was suffering flashbacks to CDC's 6-bit Hollerith code. -- .. Chuck Rhode, Sheboygan, WI, USA .. Weather: http://LacusVeris.com/WX .. 69° — Wind NNE 6 mph — Sky partly cloudy. -- http://mail.python.org/mailman/listinfo/python-list
Re: nonstandard XML character entities?
Chuck Rhode wrote this on Sat, 14 Apr 2007 09:04:45 -0500. My reply is below. Fixed text wrap: > import xml.etree.ElementTree # or elementtree.ElementTree prior to 2.5 > ElementTree = xml.etree.ElementTree > import htmlentitydefs > class XmlFile(ElementTree.ElementTree): > def __init__(self, file=None, tag='global', **extra): > ElementTree.ElementTree.__init__(self) > parser = ElementTree.XMLTreeBuilder( > target=ElementTree.TreeBuilder(Element)) > parser.entity = htmlentitydefs.entitydefs > self.parse(source=file, parser=parser) > return -- .. Chuck Rhode, Sheboygan, WI, USA .. Weather: http://LacusVeris.com/WX .. 32° — Wind Calm -- http://mail.python.org/mailman/listinfo/python-list
Re: nonstandard XML character entities?
Martin v. Löwis wrote this on Sat, 14 Apr 2007 09:10:44 +0200. My reply is below. > Paul Rubin: >> I'm new to xml mongering so forgive me if there's an obvious >> well-known answer to this. It's not real obvious from the library >> documentation I've looked at so far. Basically I have to munch of >> a bunch of xml files which contain character entities like ú >> which are apparently nonstandard. -snip- > In ElementTree, the XMLTreeBuilder has an attribute entity which is > a dictionary used to map entity names in entity references to their > definitions. Whether you can make the parser download the DTD > itself, I don't know. What he said Try this on your piano: : import xml.etree.ElementTree # or elementtree.ElementTree prior to 2.5 : ElementTree = xml.etree.ElementTree : import htmlentitydefs : class XmlFile(ElementTree.ElementTree): : def __init__(self, file=None, tag='global', **extra): : ElementTree.ElementTree.__init__(self) : parser = ElementTree.XMLTreeBuilder( : target=ElementTree.TreeBuilder(Element)) : parser.entity = htmlentitydefs.entitydefs : self.parse(source=file, parser=parser) : return It looks goofy as can be, but it works for me. -- .. Chuck Rhode, Sheboygan, WI, USA .. Weather: http://LacusVeris.com/WX .. 32° — Wind Calm -- http://mail.python.org/mailman/listinfo/python-list
Re: [JOB] Sr. Python Developer, Northern VA
John J. Lee wrote this on Thu, 22 Mar 2007 21:16:13 +. My reply is below. > I sympathise but conventional wisdom (which surely has a lot of > truth in it) is that employers are not faced with the problem of > minimising false negatives (failing to hire when they should have > hired). They are faced with the problem of minimising false > positives (hiring when they should not have hired). That's a gross > simplification of course, but I'm sure you appreciate the point -- > if you're hiring employees, being fairly risk-averse is probably > quite rational. ... so what's this we hear of employers' (in the US) being so starved for talent that they're willing to bring in young men from overseas with 3.5 kids and 1.5 wives? -- .. Chuck Rhode, Sheboygan, WI, USA .. Weather: http://LacusVeris.com/WX .. 44° — Wind SSE 7 mph — Sky overcast. Light rain; mist. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Source Code Beautifier
Franz Steinhaeusler wrote this on Tue, 27 Feb 2007 09:45:42 +0100. My reply is below. > Hello, I did not find any reasonable pyhton source code beautifier > program (preferable gui). -snip- > Is there such a tool around? Why, yes! Yes, there is: o http://lacusveris.com/PythonTidy/PythonTidy.python It doesn't have a graphical user interface, and it doesn't do everything you want, and it isn't reasonable (It's of an unreasonable size.), but it is a beginning. For future reference, look in: o http://cheeseshop.python.org/pypi ... under "reformat." -- .. Chuck Rhode, Sheboygan, WI, USA .. Weather: http://LacusVeris.com/WX .. 26° — Wind WNW 5 mph — Sky overcast. Mist. -- http://mail.python.org/mailman/listinfo/python-list
Re: Automated resizing of JPEG image + making slices?
Michiel Sikma wrote this on Thu, 15 Feb 2007 22:21:34 +0100. My reply is below. -snip- > I initially hired someone to do it in PHP (don't bite, please :-) > but it seems that I forgot about one thing: the people updating the > site would have been able to upload a huge 30 MB JPEG image, which > PHP would then resize to various sizes and cut them into 200x200 > pieces, which would be fed to the Google Maps API. However, this > costs a lot of memory, and PHP by default only has 8 MB. -snip- > I know some Python (but not much since I've never actually written > that many things in it), and with some effort I could probably make > a simple image manipulator frontend in it, but only if I can find a > good library for doing the actual manipulation. Do any of you know > such libraries? I can't make head or tail of your project's constraints, so the following advice probably isn't worth much. IMHO, slicing and dicing is best done by stand-alone, special-purpose, image-manipulation routines that do their own I/O. Here is a library of such routines: o http://netpbm.sourceforge.net/doc/directory.html These can be chained together (piped) in shell script (or in *python* if you prefer) if they're installed on your server. There is an API (and maybe even a *python* interface), but I've never needed it. For security, the parameters passed to these routines from the wild (such as file names) need to be scrubbed clean of any delimiters that would look like executable shell script code, variable substitutions, or even spurious path names. -- .. Chuck Rhode, Sheboygan, WI, USA .. Weather: http://LacusVeris.com/WX .. 18° — Wind WNW 13 mph -- http://mail.python.org/mailman/listinfo/python-list
Re: beep or sound playing under linux
hg wrote this on Mon, Jan 22, 2007 at 04:12:50PM +0100. My reply is below. > Is there a way to do that? (Make noise.) In Gnome there is: gtk.gdk.beep() -- .. Chuck Rhode, Sheboygan, WI, USA .. Weather: http://LacusVeris.com/WX .. 28° — Wind WSW 10 mph — Sky overcast. -- http://mail.python.org/mailman/listinfo/python-list
PythonTidy 1.10
PythonTidy cleans up, regularizes, and reformats the text of Python scripts. It is released under the GNU General Public License. Python scripts are usually so good looking that no beautification is required. However, from time to time, it may be necessary to alter the style to conform to changing standards. This script converts programs in a consistent way. It abstracts the pretty presentation of the symbolic code from the humdrum process of writing it and getting it to work. This is an upgrade. There was a big problem with earlier versions: Canonical values were substituted for strings and numbers. For example, decimal integers were substituted for hexadecimal, and escaped strings for raw strings. Authors of Python scripts usually use peculiar notations for peculiar purposes, and doing away with the peculiarity negatively impacts the readability of the code. This version preserves the original constants (parsed by *tokenize*) in a literal pool indexed by the value they evaluate to. The canonical values (output by *compiler*) are then translated back (when possible) to the original constants by looking them up in the literal pool. -- http://www.lacusveris.com/PythonTidy/PythonTidy-1.10.python";>PythonTidy 1.10 - Cleans up, regularizes, and reformats the text of Python scripts. (18-Jan-07) .. Chuck Rhode, Sheboygan, WI, USA .. mailto:[EMAIL PROTECTED] .. Weather: http://LacusVeris.com/WX .. 20° — Wind WNW 13 mph -- http://mail.python.org/mailman/listinfo/python-list
Re: Conflicting needs for __init__ method
Ben Finney wrote this on Wed, Jan 17, 2007 at 08:27:54PM +1100. My reply is below. > I recommend, instead, separate factory functions for separate input > types. Uh, how 'bout separate subclasses for separate input types? -- .. Chuck Rhode, Sheboygan, WI, USA .. Weather: http://LacusVeris.com/WX .. 7° — Wind SW 10 mph -- http://mail.python.org/mailman/listinfo/python-list
Re: ReportLab - Frames - Images
Thanks for the help. I made you changes but it still puts the picture above the text, not beside the text. I also found a user group at http://news.gmane.org/gmane.comp.python.reportlab.user . It may be the same. I have now posted there. Chuck -- http://mail.python.org/mailman/listinfo/python-list
ReportLab - Frames - Images
I have been trying all day to get this to work. My complete code is below. I can get my text into the PDF, I can get my image in the PDF. What I can't get to work is frames so that the image (logo) appears to the right of the text. The image always appears first and then the text below on the next line. Please help. Chuck *** CUT *** from reportlab.pdfgen import * from reportlab.platypus import * from reportlab.lib.units import inch from reportlab.platypus import SimpleDocTemplate from reportlab.platypus import flowables from reportlab.lib.enums import TA_LEFT, TA_RIGHT, TA_CENTER, TA_JUSTIFY from reportlab.lib.pagesizes import letter #precalculate some basics top_margin = letter[1] - inch bottom_margin = inch left_margin = inch right_margin = letter[0] - inch frame_width = right_margin - left_margin def bill(canvas, doc): canvas.saveState() canvas.restoreState() def run(): doc = [] from reportlab.lib.styles import ParagraphStyle from reportlab.platypus import Image pdf = SimpleDocTemplate('bill2.pdf', pagesize = letter) #need a style normal = ParagraphStyle('normal') doc.append(Image("pic.jpg", 100, 71)) #Logo para = Paragraph("Some text1", normal) doc.append(para) para = Paragraph("Some text2", normal) doc.append(para) para = Paragraph("Some text3", normal) doc.append(para) para = Paragraph("Some text4", normal) doc.append(para) para = Paragraph(" ", normal) doc.append(para) doc.append(HRFlowable(color="black", thickness=3, width="100%")) pdf.build(doc,bill) run() *** CUT *** -- http://mail.python.org/mailman/listinfo/python-list
Re: help: code formatter?
siggi wrote this on Mon, Jan 08, 2007 at 03:33:21PM +0100. My reply is below. > Is there a simple code formatter that first removes all indentations > and then refomats correctly? Why, yes, there is: http://lacusveris.com/PythonTidy/PythonTidy.python -- .. Chuck Rhode, Sheboygan, WI, USA .. 1979 Honda Goldwing GL1000 (Geraldine) .. Weather: http://LacusVeris.com/WX .. 26° — Wind W 17 mph -- http://mail.python.org/mailman/listinfo/python-list
Re: PythonTidy
Thomas Heller wrote this on Tue, Dec 05, 2006 at 07:06:30PM +0100. My reply is below. > There is still one major issue. pythonTidy uses open(input-file, > "rb") to open the Python module to tidy up. That does not work on > Windows, at least if the file has (as it should) "\r\n" newlines. Thank you for challenging my parochial world view. I have posted yet another version of PythonTidy: http://www.lacusveris.com/PythonTidy/PythonTidy-1.5.python This one is omnivorous wrt to newlines. > For output, PythonTidy generates "\n" line endings, this should also > be changed on Windows. When OVERRIDE_NEWLINE = None, the first newline encountered on input is the one used throughout the output; otherwise, you can set it to what you want, e.g, OVERRIDE_NEWLINE = '\n'. > PythonTidy outputs strings with single quotes, while my own style is > to use double quotes (I don't think that pep8 prefers one over the > other). Is it possible to customize this? Here is a new global: DOUBLE_QUOTED_STRINGS = True. -- .. Chuck Rhode, Sheboygan, WI, USA .. Weather: http://LacusVeris.com/WX .. 30° — Wind WNW 15 mph — Sky overcast. -- http://mail.python.org/mailman/listinfo/python-list
Re: PythonTidy
Thomas Heller wrote this on Tue, Dec 05, 2006 at 07:06:30PM +0100. My reply is below. > I suggest you open the file with open(input-file, "rU"). This doesn't work so pretty good while reading from sys.stdin, so I'm still at the drawing board. -- .. Chuck Rhode, Sheboygan, WI, USA .. 1979 Honda Goldwing GL1000 (Geraldine) .. Weather: http://LacusVeris.com/WX .. 27° — Wind S 15 mph — Sky overcast. -- http://mail.python.org/mailman/listinfo/python-list
Re: PythonTidy
rzed wrote this on Tue, Dec 05, 2006 at 08:19:28PM -0500. My reply is below. > I ran PythonTidy on a wxPython sample, and found that wx.CONSTANTS > were being translated to wx.Constants, which won't do at all. Find the first line in the PythonTidy code where the following global variables are declared and change them as follows: PERSONAL = False # This eliminates case manipulation. > The idea of PythonTidy is not bad, but there should be a minimal > option that essentially reindents and nothing more. ... For example, > I don't necessarily need a shebang or coding line for my purposes, > but without going into the code and commenting out lines, I can't > readily suppress them. Yes, it's too bad that PythonTidy doesn't have an *.rc file or a *.cfg file or an *.ini file or an *.xml file or a Registry entry or a Gnome configuration or its own graphical front end or a gob of command-line options, but that's just the way it is. SHEBANG = '' # This removes the shebang line from the output. CODING_SPEC = '' # This removes the coding specification from the output. > As it stands now, I can't trust PythonTidy to do the right thing on > unfamiliar code, and I can't readily try out various options by > simply activating or deactivating them; if I could, it would be much > more useful to me. PythonTidy should be run only on code that is already familiar or that will rapidly become so in the near future. -- .. Chuck Rhode, Sheboygan, WI, USA .. Weather: http://LacusVeris.com/WX .. 25° — Wind SSW 20 mph — Sky overcast. Precipitation. -- http://mail.python.org/mailman/listinfo/python-list
PythonTidy
That went well. PythonTidy has been looked at at least 10**2 times, and I have received a couple of complaints, which I hope I have addressed satisfactorily -- plenty good enough for a beta test. The basic concept stands. PythonTidy.py cleans up, regularizes, and reformats the text of Python scripts: http://www.LacusVeris.com/PythonTidy/PythonTidy.python What next? Is it appropriately submitted to the Cheese Shop? -- .. Chuck Rhode, Sheboygan, WI, USA .. Weather: http://LacusVeris.com/WX .. 3° — Wind W 8 mph -- http://mail.python.org/mailman/listinfo/python-list
Re: PythonTidy
Thomas Heller wrote this on Fri, Dec 01, 2006 at 10:12:38PM +0100. My reply is below. > Chuck Rhode schrieb: > > o Command-line args: Please give an example of a standard command that > > I might emulate w.r.t. standard argument use. > Well, at least it would be nice if I could call > 'PythonTidy.py mymodule.py' to tidy up the mymodule.py file. I've uploaded a new version of PythonTidy: o http://www.lacusveris.com/PythonTidy/PythonTidy-1.4.python It fixes several problems. Also it allows file names as arguments. > Here is part of a diff before and after running PythonTidy on it: > > -def comptr_setitem(self, index, value): > -# We override the __setitem__ method of the > -# POINTER(POINTER(interface)) type, so that the COM > -# reference count is managed correctly. > +def comptr_setitem(self, index, value): # We override the > __setitem__ method of the > + # > POINTER(POINTER(interface)) type, so that the COM > + # reference count is > managed correctly. > Can this be customized? This problem has been fixed I think. No customization should be required to keep block comments from being rendered as in-line comments. Wolfgang Grafen reported that PythonTidy crashed in Python-2.4 because new Abstract Syntax Tree node types introduced in Python-2.5 weren't available. It was trivial to check availability, so PythonTidy should now run in Python-2.4. However, this has not been thoroughly tested and is not guaranteed. PythonTidy can now recode string literals if required, although this capability is turned off by default. See RECODE_STRINGS. Docstrings will henceforward be enclosed in double quotes when feasible. -- .. Chuck Rhode, Sheboygan, WI, USA .. Weather: http://LacusVeris.com/WX .. 30° — Wind WSW 10 mph — Sky overcast. -- http://mail.python.org/mailman/listinfo/python-list
Re: PythonTidy
Thomas Heller wrote this on Fri, Dec 01, 2006 at 10:12:38PM +0100. My reply is below. > Here is part of a diff before and after running PythonTidy on it: > > > -def comptr_setitem(self, index, value): > -# We override the __setitem__ method of the > -# POINTER(POINTER(interface)) type, so that the COM > -# reference count is managed correctly. > +def comptr_setitem(self, index, value): # We override the > __setitem__ method of the > + # > POINTER(POINTER(interface)) type, so that the COM > + # reference count is > managed correctly. > > Can this be customized? I am able to rationalize why this happens, but you are correct: This behavior is not appropriate. I am testing several changes, one of which should prevent it in all cases, obviating the need for a custom switch. -- .. Chuck Rhode, Sheboygan, WI, USA .. 1979 Honda Goldwing GL1000 (Geraldine) .. Weather: http://LacusVeris.com/WX .. 10° — Wind S 5 mph -- http://mail.python.org/mailman/listinfo/python-list
Re: PythonTidy
Thomas Heller wrote this on Thu, Nov 30, 2006 at 09:50:25PM +0100. My reply is below. > The two things that bother me at the moment are how the comments are > formatted (dunno if that can be customized or changed easily), and > it would be good if the script took command line args instead of > working as a filter only. Thank you for trying PythonTidy. o Command-line args: Please give an example of a standard command that I might emulate w.r.t. standard argument use. o Comments: Input is parsed twice: I use *tokenize.generate_tokens* to extract the comments and *compiler.parse* to generate the Abstract Syntax Tree (AST). Other applications usually use the AST to generate bytecode, so it contains no information about comments. The tokens list identifies keywords (and comments and some whitespace) but doesn't group them into statements. I need both: comments *and* functional grouping. Fortunately both the AST and the tokens list carry line numbers to reference the source. Unfortunately the AST line numbers are relative to functional groups and do not necessarily apply to the particular keywords that introduce each group. This makes fixing the position of comments relative to reconstructed code a bit of a challenge. For example, when a comment has a line number in the beginning/ending range of what would normally be considered one command, I have to assume it is an inline comment regardless of how it may have appeared in the original code. Out-of-line comments should appear pretty much as they did in the original code, however. Can you provide an example where they do not? Would you prefer that they be left justified or wrapped? >-~ Doc strings (for modules, class declarations, and functions) are another matter. PythonTidy should not mess with them (unless LEFTJUST_DOC_STRINGS is True). They should appear exactly as originally written. I was taught that code ought to be self documenting and that comments more often than not diminish readability by padding the code beyond what can be comprehended on one page (screen). I use them only minimally and am not greatly inconvenienced when they are moved around a little. -- .. Chuck Rhode, Sheboygan, WI, USA .. Weather: http://LacusVeris.com/WX .. 21° — Wind N 8 mph -- http://mail.python.org/mailman/listinfo/python-list
Re: PythonTidy
Roberto Bonvallet wrote this on Thu, Nov 30, 2006 at 01:21:55PM +. My reply is below. > About changing the shebang line: I'll take it as a bug. > About changing the encoding declaration from vim-style to > emacs-style: I'll take it as an insult :) Ooh! > Both are comments, and should be left that way. Besides, there is no > officially preferred way for each of them. BTW, in a recent thread on > this newsgroup, most people said they preferred #!/usr/bin/env python over > #!/usb/bin/python for the shebang line. See http://tinyurl.com/yngmfr . Thanks for the link. I was unaware of the /usr/bin/env technique and the controversy surrounding it. Thanks, too, for trying *PythonTidy*. As you have no doubt perceived, *PythonTidy* is *not* "table driven." It is a script after all. I decided before writing it that I didn't really need to externalize all the options; nevertheless, most are declared near the beginning where they sit just begging for end-user involvement. See: CODING_SPEC and SHEBANG. *PythonTidy* is all about consistency, consistency, and consistency. You can use it to standardize shebangs and coding across a whole library of Python scripts. -- .. Chuck Rhode, Sheboygan, WI, USA .. Weather: http://LacusVeris.com/WX .. 25° — Wind NW 13 mph -- http://mail.python.org/mailman/listinfo/python-list
PythonTidy
I couldn't find a routine to clean up, regularize, and reformat Python code, so I wrote one: http://www.lacusveris.com/PythonTidy/PythonTidy.python Now, I'm looking for beta-testers. Compensation is a bit on the low side. In fact it's limited to the satisfaction of helping out. Thanks. -- .. Chuck Rhode, Sheboygan, WI, USA -- http://mail.python.org/mailman/listinfo/python-list
Re: Finding skilled pythonistas for micro-jobs?
Paul Rubin wrote this on Sat, Nov 18, 2006 at 04:39:47PM -0800. My reply is below. > "darran" <[EMAIL PROTECTED]> writes: > > Any suggestions then for locating skilled Python/C++ programmers > > for these small (micro) jobs? > I've taken a number of these and always regretted it. They've been > far more hassle than they're worth. But maybe that's just me. I've never seen the point of trying to compete for the kind of work-at-home programming jobs you see posted on Internet clearing houses. A number of reservations have always stopped me: o The problem descriptions are nebulous or incoherent or both. o No background scope is provided. o No performance criteria are set forth. o No pay rate is specified. o No due date is mentioned. Obviously, it would take longer to draw these things together than it would to do the job itself, at least in the posters' opinions. I can't help wondering, though, if they're serious, because, if they need the job completed successfully, however trivial it may be, sooner or later somebody is going to have to do their homework, and, yes, it's going to take at least twice as long as they're willing to spend when they get around to it. I think there's a case to be made for hiring a another full-time programmer if these small jobs keep cropping up. Part of his job description can be to prepare needs assessments and impact analyses and to prioritize requests before he even thinks about beginning a task. It's difficult to outsource these things, and they are time consuming. -- .. Chuck Rhode, Sheboygan, WI, USA .. Weather: http://LacusVeris.com/WX .. 38° — Wind NNW 9 mph — Sky overcast. -- http://mail.python.org/mailman/listinfo/python-list
If you were given a mall would you take it?
http://www.telebay.com/esolutions/opp.html -- http://mail.python.org/mailman/listinfo/python-list
Re: Compile ui files from within Eclipse
I guess I could prompt for input but was hoping to find a better way. -- http://mail.python.org/mailman/listinfo/python-list
Re: Compile ui files from within Eclipse
Well, I tried that but there isnt a way to get the filename without the extension. For example, pyuic -o MyClass.py MyClass.ui Using the variables in the external tool config I dont see a way to get just the filename in order to create an output filename and pass it into the pyoic. -- http://mail.python.org/mailman/listinfo/python-list
Compile ui files from within Eclipse
Hello, I am new to the Eclipse IDE. I am using pydev plug-in to create python projects. Is there a way to create custom builders to build certain types of files? I have done this with other IDE's but can't seem to figure it out with Eclipse. I am trying to build *.ui files of a pydev project to create the corresponding py files. For example to do this the manual way I would: pyuic.exe c:\source.ui > c:\dest.py Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: logging module question
Ok, so I've figured this out (see below), mail = logging.handlers.SMTPHandler('mail.vw.com', '[EMAIL PROTECTED]', '[EMAIL PROTECTED]', 'Data Processing Error at location: %s' % "Chuck's Desk") mail.setFormatter(logging.Formatter('%(asctime)s %(message)s')) ml = logging.getLogger('mail') ml.addHandler(mail) ml.propagate = 0 ## <---do this to turn off propagation of error reporting but now I'd like to understand the design rational behind having each logger in the object hierarchy log the same output by default. Anyone? -- http://mail.python.org/mailman/listinfo/python-list
logging module question
I want to create two different loggers so that users see one output (e.g. no exception/stack traces) and others (e.g support staff) that does see stack traces via email. The code below is close but I still get console output on the email logger from the "root" logger. How do I get rid of it? import logging import logging.handlers def main(): console = logging.StreamHandler() console.setFormatter(logging.Formatter('%(asctime)s %(message)s')) console.setLevel(logging.CRITICAL) logging.getLogger('').addHandler(console) mail = logging.handlers.SMTPHandler('mail.vw.com', '[EMAIL PROTECTED]', '[EMAIL PROTECTED]', 'Data Processing Error at location: %s' % "Chuck's Desk") mail.setFormatter(logging.Formatter('%(asctime)s %(message)s')) logging.getLogger('mail').addHandler(mail) try: raise Exception("foobar") except Exception, e: logging.getLogger('').error(e) print "Done logging to console" logging.getLogger('mail').exception(e) if __name__ == "__main__": main() -- http://mail.python.org/mailman/listinfo/python-list
advanced module/import/namespace idioms
Every once in awhile I run across a python module that might have statements like: for c in sys.modules[module].__dict__.values(): or import __builtin__ __builtin__.__dict__['_'] = lambda x: x Snurf also does some strange import trickory (see http://bdash.net.nz/svn/snurf/trunk/snurf/dataStore/). While I'm sure none of this stuff is rocket science, but rather just "namespace manipulation" there is very little explanation in the python world that explains these techniques. I've googled around to try to find articles/papers that explain such techniques but cannot find any. Can anyone point out any refereces that discuss such module/import/namespace idioms. -- http://mail.python.org/mailman/listinfo/python-list
Re: PythonWin troubleshooting
Oh my gosh - thank you, thank. I must have had thousands of these entries in my registry. I've blown it away and at least at initial testing, appears to have solved the problem. I should have gone poking around the the bug database. Next time I will. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python IDE (was: PythonWin troubleshooting)
Yeah but is it 'fast'. What is Komodo written in? -- http://mail.python.org/mailman/listinfo/python-list
Re: Which Python web framework is most like Ruby on Rails?
> Let's just note that sturgeon's law applies to all programmers, and > let it go at that. I'll get back to this. fine > And thank you. you are welcome > I'm not a big fan of popularity for the sake of popularity. neither am I > "it would make Python more popular" isn't an adequate > justification for a change I disagree. The world desperately needs programming languages, frameworks, etc. that allow for the more efficient creation and maintenance of software application - web or otherwise. I happen to think that Python is something that could help. With this regard the popularity of Python seems relevant to me. >and *certainly* not for a change that is > otherwise undesirable. please explain -- http://mail.python.org/mailman/listinfo/python-list
Re: Which Python web framework is most like Ruby on Rails?
> I did a fairly thorough investigation of web frameworks that let us > write Python (we didn't care what the framework was written in; merely > that it interfaced with Python) for one of the systems I've built this > year. I wouldn't call the evaluation of web frameworks a problem - we > met our schedules, and the tool evaluation phase was by *far* the > shortest phase in the project, taking less than a week. Most of the > evaluations were easy - read the description of the framework, and > decide that we're working outside the problem space it's desinged > for. It certainly wasn't wasted time - I found a tool that I hadn't > heard of previously that was nearly perfectly suited to the job at > hand. As I read through this thread I can't say that I disagree that having more choices is a 'good thing'. However in your example here - I suspect that you are a bit sharper and have a bit more guts than your average code slinger since you appear to be an independent. You've got to remember that your average corporate programmer - which are the folks driving the popularity of programming languages - isn't that sharp/confident. (I don't mean to insult anyone but that just the facts.) They don't do things like evaluate frameworks and make smart choices. This is why there needs to be obvious and singularly popular frameworks and IDE's for Python so that people don't have to think that hard about it. Take Java for example - for the most part its Eclipse and Struts. I know there are many other choices (I've used them), but even the managers know these terms. Very, very few people I know in the IT world know of 'Python', let alone the name of any web framework or an IDE for Python. One of the great things about Python is its simplicty/clarity. Its a shame that there doesn't also exist a clarity of choice for a web framework for Python or an IDE for that matter. Both of these would go a long way in motivating people to take a look at Python and realizing what great value it has to offer the IT world in solving problems. -- http://mail.python.org/mailman/listinfo/python-list
Re: Which Python web framework is most like Ruby on Rails?
> People keep talking about Python's wealth of web frameworks as if it > were a bad thing. I disagree somewhat. While variety and choice are nice, sometimes having too many choices may inhibit people from trying the language because they don't know where to start in terms of framworks. Maybe I'm wrong but if there is an element of truth what I suggest then that would be a terrible shame since Python is such a great language. Python's popularity might improve if there were a bit more unity within the Python community with regards to (web) frameworks. -- http://mail.python.org/mailman/listinfo/python-list
Python IDE (was: PythonWin troubleshooting)
Apparently not too many people use or are interested in PythonWin. I'm giving up on it. It used to work pretty good. I'm lucky that I have found PyScripter (http://www.mmm-experts.com/) a python IDE for the windows platform which is much more stable and has more features that PythonWin. If you are doing Python development on Windows I'd recommend taking a look at it. I'm also evaluating Wing IDE. I may have another post with comments on it for anyone who might be interested. -- http://mail.python.org/mailman/listinfo/python-list
Re: Dectecting dir changes
Thanks, I am aware of it. I may pick it up, but in reviewing it on Amazon and at the bookstore I've noted that it does not touch on FTP server stuff or how to grok the framework in general. -- http://mail.python.org/mailman/listinfo/python-list
Re: PythonWin troubleshooting
Thanks for the suggestions but I have all of the MFC dll's. In fact I have Visual Studio 2003 installed on the box. However my mfc42.dll is different than the size stated on that link. In fact the download is a different size that what is stated on the link. -- http://mail.python.org/mailman/listinfo/python-list
Re: PythonWin troubleshooting
chuck wrote: > Sticking with 2.4.2 I reverted to win32 ext 204 and problems were the > same or worse. Then I uninstalled both, removed the dangling py*24.dll > and then installed "ActivePython 2.3.5.236". All the problems went > away. > > I hate to go back to 2.3 cause there are some nice updates in the 2.4 > library that I'd like to have. Time permitting I'll try other versions > of various windows distributions and let you know the outcome. I'd be > interested in hearing more from other folks who may or may not be > experiencing similar problems. After some use the problems have re-appeared with the "ActivePython 2.3.5.236" distro. I think the problem is related to some sort of shell hook as it goofs up not only PythonWin, but other windows applications and windows itself. Can't get the context menu to work in explorer, the task manager from the task bar, etc. Something is really goofed up! The problem only appears when PythonWin is running or was running and is hung in memory from a non-clean PythonWin shutdown. -- http://mail.python.org/mailman/listinfo/python-list
Re: PythonWin troubleshooting
Sticking with 2.4.2 I reverted to win32 ext 204 and problems were the same or worse. Then I uninstalled both, removed the dangling py*24.dll and then installed "ActivePython 2.3.5.236". All the problems went away. I hate to go back to 2.3 cause there are some nice updates in the 2.4 library that I'd like to have. Time permitting I'll try other versions of various windows distributions and let you know the outcome. I'd be interested in hearing more from other folks who may or may not be experiencing similar problems. -- http://mail.python.org/mailman/listinfo/python-list
Re: PythonWin troubleshooting
Build 205 for the win32 ext. -- http://mail.python.org/mailman/listinfo/python-list
PythonWin troubleshooting
Having problems with PythonWin on Windows XP SP1. Shortly after startup and trying to debug I see: LoadBarState failed - LoadBarState failed (with win32 exception!) Things go down hill quickly from there. From there I see stuff like: [Dbg]>>> Traceback (most recent call last): File "C:\Python24\Lib\site-packages\pythonwin\pywin\framework\winout.py", line 111, in OnRClick apply(menu.AppendMenu, appendParams) win32ui: ::AppendMenu failed - no error code is available >From there out none of the menus or toolbars work. This is on Windows/Python 2.4.2. Both the ActiveState or regular Windows distribution. I've cleaned up any old Py*23 DLL's. Uninstalled and re-installed several times. Suggestions please. -- http://mail.python.org/mailman/listinfo/python-list
Re: Dectecting dir changes
I do need to stick to FTP though as indicated I could run it on a different port. Limit comes more from the client side capabilities. Did some reading about twisted and I now understand that things in general are single threaded. I started working my way through the twisted finger tutorial. While it appears that it may be useful for someone writing a new protocol it doesn't seem to useful for someone just trying to hook into an existing one. While I do appreciate the suggestions but I have to say that if the twisted folks spent half the time writing documentation as they do code - twisted would probably get used a lot more Python folks. Didn't get much encouragement/assistance from the twisted irc channel either. Perhaps the fella I chatted with hadn't had his coffee yet ;) -- http://mail.python.org/mailman/listinfo/python-list
Re: Dectecting dir changes
Hmmm, that is an interesting idea. I've noticed the new book on Twisted, thinking about picking it up. I assume that this little snippet will handle multiple/concurrent incoming transfers via threading/sub-process, is scalable, secure, etc? I could even run it on a non-standard port making it a bit more (ob)secure. -- http://mail.python.org/mailman/listinfo/python-list
Re: Dectecting dir changes
ty - more useful than 'works here' -- http://mail.python.org/mailman/listinfo/python-list
Re: Dectecting dir changes
Is this on Solaris? I think you may have missed my point. I don't have fcntl.py on my Solaris box so how do I know what signals that I can used to monitor a directory for modification. In other words will the following work? fcntl.fcntl(self.fd, fcntl.F_NOTIFY, fcntl.DN_DELETE|fcntl.DN_CREATE|fcntl.DN_MULTISHOT) Without fcntl source, which the python documentation suggests that I look at, I don't know if any of these constants apply to the Solaris platform. -- http://mail.python.org/mailman/listinfo/python-list
Dectecting dir changes
I need to write a daemon for Solaris that monitors a directory for incoming FTP transfers. Under certain conditions, when the transfer is complete I need to send an email notification, and do other stuff. Win32 provides FindFirstChangeNotification(), but as best I can tell this isn't supported on Solaris. I am thinking of using the approach suggested here http://tgolden.sc.sabren.com/python/win32_how_do_i/watch_directory_for_changes.html which is: import os, time path_to_watch = "." before = dict ([(f, None) for f in os.listdir (path_to_watch)]) while 1: time.sleep (10) after = dict ([(f, None) for f in os.listdir (path_to_watch)]) added = [f for f in after if not f in before] removed = [f for f in before if not f in after] if added: print "Added: ", ", ".join (added) if removed: print "Removed: ", ", ".join (removed) before = after My concern with this is that a change may be detected before the ftp daemon process is done writing the file to disk. I don't want to take any action until the file is written and closed. I know that I could pole a new file looping to check to see if it's file size is changing but the timing of such a loop is subject to I/O buffering and is otherwise not elegant. Googling shows other solutions using fcntl (http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/217829) but it appears that this only works on Linux. While I'm at it I'm going to throw in a grump about the Python documentation of fcntl. The doco indicates to read the source for fcntl.py to lookup the constants representing the different types of events/signals that are avaiable. However fcntl on some platforms seems to be implemented as a binary leaving no way to look up the contants for the platform. Suggestions? -- http://mail.python.org/mailman/listinfo/python-list
File Upload Script
Hi, can anyone provide or point me in the direction of a simple python file upload script? I've got the HTML form part going but simply putting the file in a directory on the server is what I'm looking for. Any help would be greatly appreciated. Thanks, Chuck -- http://mail.python.org/mailman/listinfo/python-list
Re: Why doesn't IDLE editor windows have horizontal scrollbars?
Well I don't want to start yet another thread on IDE's. I've googled and all of that an am aware of most of the IDE's that are out there. I am curious if there is someplace where statistics have been captured on what IDE's most people are using. Since IDLE ships with Python I assume a lot of people use it. I've been a PythonWin user for years but it has shortcomings, isnt' being developed further and doesn't run on FreeBSD, my other platform. -- http://mail.python.org/mailman/listinfo/python-list
Why doesn't IDLE editor windows have horizontal scrollbars?
The browser windows do. Why not the editor windows? I hate to complain but is there any way to get IDLE to run in more of an MDI mode? Having the floating windows everywhere is rather confusing to me. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Database Scripts
Hi, thanks for (all) of your help. BTW, where is the DB-API docs for python? Thanks, --Chuck -- http://mail.python.org/mailman/listinfo/python-list
Python Database Scripts
Hello, Can anyone provide any kind of python database (mysql) code or point me to a link that has this? Just simple things as maybe using a driver, opening up a db, an insert and select. Any help would be greatly appreciated! Thanks, --Chuck -- http://mail.python.org/mailman/listinfo/python-list