No one has voted on any posts yet. Votes from other community members are used to determine a member's reputation amongst their peers.
13 Posted Topics
Why does this make sense in 3.1? [code]>>> a = b'\x01\x02' >>> a[0] 1 >>> a[0:1] b'\x01' >>> a[0] == a[0:1] False >>> a = '\x01\x02' >>> a[0] '\x01' >>> a[0:1] '\x01' >>> a[0] == a[0:1] True[/code] Shouldn't we get True for both comparisons?
Consider: [code]>>> a = 'abcde' start = 1 end = 2 >>> b = a[:start] + 'z' + a[end:] >>> b 'azcde'[/code] We've replaced 'b' with 'z' Is that what you're looking for? You can add [code]a = b[/code] at the end if you want to keep the variable name.
Both weather.com and google have APIs for accessing weather info. Basically, you form a URL in a specified format and get and XML page with current weather and forecasts. Weather.com requires signing up in advance, at no cost. [url]http://www.weather.com/services/xmloap.html[/url] A google example: [url]http://www.google.com/ig/api?weather=New%20York[/url] There are a bunch of python examples …
I'm trying to parse xml, but am missing something. In the following, I can get the key, but not the value [code]from xml.dom import minidom xmlstring = '''<search ver="3.0"> <loc id="USAR0433" type="1">Paris, AR</loc> <loc id="USID0192" type="1">Paris, ID</loc> </search>''' dom = minidom.parseString(xmlstring) r = dom.getElementsByTagName('search')[0] res = [] for x in …
I've been having problems with email in 3.1.1. I decided to try the examples from the docs. Alas, the first I tried didn't work. I tried to send a directory whose only contents were a single zip file. [code]#!/usr/bin/env python """Send the contents of a directory as a MIME message.""" …
Does the documentation mean what it says? The 3.1 library reference says quopri.encodestring takes a string, but feeding it a string results in an error. [QUOTE]quopri.encodestring(s[, quotetabs]) Like encode(), except that it accepts a source string and returns the corresponding encoded string. [/QUOTE] However, feeding this a str results in …
The following fails with an error message about not being able to encode the euro char. It works fine without the €. I have the feeling I'm missing something simple here, but can't figure it out. A fix would be appreciated. I'd like to use this in 2.5.4 and 3.1 …
if you change the pickle statements to pickle.dump((self.name, self.function),file) and (self.name,self.function) = pickle.load(file) Then it works. You can save all of the class elements to some structure if you want and pickle that structure. HTH
I have some code which "requires python 2.5.2 or bytecode compatible." Would 2.5.4 work? 2.6.2? Any harm in installing either of these on the same machine as 3.1 (separate directories)? Windows XP if that matters.
None of 6,7,8,12,13,14 are valid python statements. Perhaps they are meant to show the output from the printschema statement? Perhaps they are meant to show new values for the list array? Line 10 seems to have a typo. Using 'list' for a variable name is bad practice, as it redefines …
Is there a way to place widgets on pixel coordinates rather than row, column coordinates in tkinter? For example, if I'm using grid, if I have a 20x10 Text box at row 0, column 0 and want to place three buttons to the right of the textbox, one button over …
I have a tkinter/python program which does something time consuming when I push a button. I'd like to give the user progress reports by updating a label field at each stage of the time consuming process. If have simple loop to the effect [code] for x in y: dosomething(x) self.label1.config(text …
The End.
foosion