Re: VERY BASIC HELP

2013-09-30 Thread John Gordon
use you're using a semicolon after the print statement. This code is really two completely separate statements: print "The result is : ";x/y It prints the message and then, as a separate action, it calculates the value of x/y (and then throws that value away, because it isn't ass

Re: Referrer key missing form os.environ dictionary?

2013-09-25 Thread John Gordon
eb server's environment. -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" -- https://mail.python.org/mailman/listinfo/python-list

Re: Referrer key missing form os.environ dictionary?

2013-09-25 Thread John Gordon
he problem. You can't arbitrarily break a statement into separate lines. If not, then you'll have to post more of the code; the problem isn't on this line. -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assa

Re: Referrer key missing form os.environ dictionary?

2013-09-25 Thread John Gordon
e KeyError? Something else? In any case, I'm surprised that doesn't work. That should be the correct way to do it. You could try this: try: referer = os.environ.get('HTTP_REFERER', 'UnknownRef') except KeyError: referer = None if not ref

Re: Referrer key missing form os.environ dictionary?

2013-09-25 Thread John Gordon
user types the web address directly into their browser, or clicks on a bookmark, or many other ways. Also, obviously, it's up to the browser to truthfully report HTTP_REFERER; the server itself has no idea what page you were on previously. What browser are you using? -- John Gordon

Re: Print statement not printing as it suppose to

2013-09-20 Thread John Gordon
a statement instead of a function. In other words, it is used like this: name = "Bob" print "Hello ", name Because there are parentheses around the text to be printed, your version of python is interpreting it as a tuple. Remove the parentheses and you should be ok.

Re: building an online judge to evaluate Python programs

2013-09-20 Thread John Gordon
mail access from the judge account too. Not sure how to easily do that. -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies"

Re: building an online judge to evaluate Python programs

2013-09-20 Thread John Gordon
master input file and a master output file for each exercise. If the student program's output matches the master output when run from the master input, then it is correct. -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com

Re: django admin.py error

2013-09-19 Thread John Gordon
In Gary Roach writes: > On 09/19/2013 11:15 AM, John Gordon wrote: > > Does /home/gary/ProgramFiles/mysite/mysite/models.py define an object > > named 'membership'? > Yes. The following is the top part of the models.py file: q > class Membership(models.M

Re: Why does it have red squiggly lines under it if it works perfectly fine and no errors happen when I run it?

2013-09-19 Thread John Gordon
;def'. Post the whole program. -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" -- https://mail.python.org/mailman/listinfo/python-list

Re: django admin.py error

2013-09-19 Thread John Gordon
ysite/mysite', > My admin.py file is: > #Adding this app to the admin page. > from django.contrib import admin > from mysite.models import membership, address, status, audio, video, > photos Does /home/gary/ProgramFiles/mysite/mysite/models.py define an obj

Re: Suds and Complex Sequences

2013-09-17 Thread John Gordon
he > WSDL calls for a sequence of SubscriberDataTypes (this application is used > to test an insurance companys' rating service). Contact whomever is providing this data and ask them for documentation. -- John Gordon A is for Amy, who fell down the stairs gor...@panix

Re: statsmodels.api

2013-09-16 Thread John Gordon
\interpolate\__init__.py", line > 150, in > from .interpolate import * > File "C:\Python33\lib\site-packages\scipy\interpolate\interpolate.py", line > 12, in > import scipy.special as spec > File "C:\Python33\lib\site-packages\scipy\special\__init__.

Re: Need help to sort out the below code...

2013-09-14 Thread John Gordon
hoice, ".pizza" .... elif user_choice == 2: print "You have selected", st, ".Steak" -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" -- https://mail.python.org/mailman/listinfo/python-list

Re: Help please, why doesn't it show the next input?

2013-09-13 Thread John Gordon
max_occurrences = 0 themode = None for i in mylist: thecount = mylist.count(i) if thecount > max_occurrences: max_occurrences = thecount themode = i print(themode) -- John Gordon A is for Amy, who fe

Re: Python GUI?

2013-09-13 Thread John Gordon
In <76784bad-cd6d-48f9-b358-54afb2784...@googlegroups.com> eamonn...@gmail.com writes: > they're making programming easier... by not coding as much. Oh well, > guess coding is dead :( Pressing keys on a keyboard was never the hard part of coding. -- John Gordon

Re: Another question about JSON

2013-09-13 Thread John Gordon
> to know I've got it) and I try to use the following code: > returnedJSON = json.loads('https://coinbase.com/api/v1/prices/buy') > print returnedString JSON is a notation for exchanging data; it knows nothing about URLs. It's up to you to connect to the URL and read t

Re: Expected an indented block

2013-09-12 Thread John Gordon
also be caused by using a mix of tabs and spaces on the same line. Don't do that. (And by the way, it's generally better to post errors and code as text instead of a screenshot.) -- John Gordon A is for Amy, who fell down the stairs gor...@panix

Re: Parsing an html line and pulling out only numbers that meet a certain criteria

2013-09-11 Thread John Gordon
27;t want to assign it to self.high0? That's easy; assign it to a temporary variable first, and only assign it to self.high0 if it falls in the desired range. -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" -- https://mail.python.org/mailman/listinfo/python-list

Re: Help please, why doesn't it show the next input?

2013-09-11 Thread John Gordon
= "Hello There" >>> y = x.lower() >>> print y hello there -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycr

Re: TypeError in date_parse.py

2013-09-11 Thread John Gordon
In <3d0038fd-00ec-4560-ab0d-06528f838...@googlegroups.com> pestre...@gmail.com writes: > I think it's a float, I see in the code > if request.method == "POST": > end_timestamp = request.POST.get('end_timestamp', None) > start_timestamp = request.POST.get('start_timestamp', None)

Re: TypeError in date_parse.py

2013-09-11 Thread John Gordon
e.fromtimestamp(float(start_timestamp)) > end_datetime = datetime.fromtimestamp(float(end_timestamp)) > duration = end_datetime - start_datetime > = What is the type and value of start_timestamp and end_timestamp? -- John Gordon

Re: Help please, why doesn't it show the next input?

2013-09-10 Thread John Gordon
ust have left that part out. Anyway, I think you're doing two things wrong: 1. You aren't capturing the user's input. The input() function returns the user's input, but you aren't assigning this to a variable; it's just being thrown away. You should call input() li

Re: Monitor key presses in Python?

2013-09-09 Thread John Gordon
a function that waits for the user to press a key and then returns the key that was pressed? Or are you asking for a function that detects whether a key has been pressed at all? -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Bas

Re: What does sys.stdout.flush() do?

2013-08-23 Thread John Gordon
n't necessarily get written right away. In particular, screen output often waits until it receives a newline before displaying anything. flush() makes sure it all gets written *right now*. -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is

Re: Replace blanks with letter

2013-08-21 Thread John Gordon
sly, but we don't know what it's *supposed* to do. -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" -- http://ma

Re: Getting a value that follows string.find()

2013-08-14 Thread John Gordon
In <40816fed-38d4-4baa-92cc-c80cd8feb...@googlegroups.com> englishkevin...@gmail.com writes: > I know the title doesn't make much sense, but I didnt know how to explain my > problem. > Anywho, I've opened a page's source in URLLIB > starturlsource = starturlopen.read() > string.find(starturlsou

Re: Am I not seeing the Error?

2013-08-12 Thread John Gordon
Process(write2file('./mem/ENGINE_PID', ENGINEPID); You have too many ('s this line. > write2file(SENTEMPPATH, ''); write2file(INPUTMEM, '')); And too many )'s on this one. -- John Gordon A is for Amy, who fell down the sta

Re: ImportError: No module named appengine.ext

2013-07-31 Thread John Gordon
Has the Google App Engine library been installed on your system? -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" -- http://mail.python.org/mailman/listinfo/python-list

Re: script to Login a website

2013-07-31 Thread John Gordon
e contents of each file, be aware that the newlines at the end of each line are included. If you don't want these, be sure to call the rstrip() method to remove traling whitespace. -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is f

Re: binary key in dictionary

2013-07-31 Thread John Gordon
to it. This requires that tmpgndict[binmac] already exists, which it does not. Make sure that tmpgndict[binmac] exists before you try appending to it. -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears

Re: PEP8 79 char max

2013-07-29 Thread John Gordon
screen sizes. And even if you're on a device that can display more than 80 characters, it can be convenient to have several windows display side-to-side. > Would following this recommendation improve script performance? No, but it improves human readability. -- John Gordon

Re: dump a multi dimensional dictionary

2013-07-26 Thread John Gordon
> {'3': ('1', '2')} > or should I just write my own dump function that can hanle thiS? I think you have the arguments to pickle.dump() in the wrong order. The data to be dumped should come first, then the file object. -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" -- http://mail.python.org/mailman/listinfo/python-list

Re: embedded python and threading

2013-07-26 Thread John Gordon
;", line 6, in main > 9: AttributeError: 'builtin_function_or_method' object has no attribute > 'sleep' > == You must have a file named 'time.py' in the current directory, and the import statement is getting that module instead of the

Re: Newbie: Python 3 and web applications?

2013-07-26 Thread John Gordon
o learn, but frameworks handle a ton of low-level details for you and make web development overall much easier. -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears --

Re: Find and Replace Simplification

2013-07-19 Thread John Gordon
x27;,', '', 'DATA') > DATA = re.sub('\'', '', 'DATA') > DATA = re.sub('(', '', 'DATA') > DATA = re.sub(')', '', 'DATA') If your actual use-case is this simple, you might w

Re: Python HTTP POST

2013-07-17 Thread John Gordon
the google form search input box is named 'q' data = { 'q': 'Pie' } response = urllib2.urlopen('http://google.com', urllib.urlencode(data)) print response.read() -- John Gordon A is for Amy, who fell down the stairs go

Re: What's wrong with this code? (UnboundLocalError: local variable referenced before assignment)

2013-06-24 Thread John Gordon
se global or nonlocal > declarations. Quite right. I should have verified my answer before posting. Thanks for setting me straight. :-) -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears

Re: What's wrong with this code? (UnboundLocalError: local variable referenced before assignment)

2013-06-24 Thread John Gordon
cky to explain, but I'll do my best. :-) The problem is that change() isn't being executed here; instead it's being executed from within root.mainloop(), whenever the user presses button-1. And within root.mainloop(), there is no variable called isWhite. -- John Gordon

Re: Loop Question

2013-06-24 Thread John Gordon
x27;s right, therefore I did not test it? I don't understand. If the code has a bug, please point it out. > And note that the getpass module is what you should use for that second > thing in real life, for the security of your users. I'm sure this is just an exercise for the O

Re: Loop Question

2013-06-24 Thread John Gordon
hile statement belong? while True: username = raw_input("Please enter your username: ") password = raw_input("Please enter your password: ") if username == "john doe" and password == "fopwpo": print "Login Successful&q

Re: How can i fix this?

2013-06-22 Thread John Gordon
print "Hello Master!" > > break > > > else: print "error" > this doesent help me at all Then you'll have to explain why, exactly, it doesn't help. Simply saying "this doesn't help me" is very unhelpfu

Re: n00b question on spacing

2013-06-21 Thread John Gordon
ase %s/%s" > %(settings['MONGODB_DB'], settings['MONGODB_COLLECTION']), > level=log.DEBUG, spider=spider) > Is this ok? Are there any rules in Python when it comes to breaking up > long lines of code? There are guidelines in the PEP8 document:

Re: Problem with the "for" loop syntax

2013-06-19 Thread John Gordon
you sure that's a real blank space, and not some weird character that *looks* like a space? -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The

Re: Updating a filename's counter value failed each time

2013-06-17 Thread John Gordon
eplase > if cur.rowcount: > print( " database has been affected" ) > with print cur.rowcount() rowcount isn't a method call; it's just an attribute. You don't need the parentheses. -- John Gordon A is for Amy, who fell down the st

Re: Updating a filename's counter value failed each time

2013-06-17 Thread John Gordon
thing, so you will at least know if the UPDATE statement is ever executed. Print the cur.rowcount attribute, which contains the number of rows that were affected by the update. If it's zero, that should tell you something. -- John Gordon A is for Amy, who fell down the s

Re: Updating a filename's counter value failed each time

2013-06-17 Thread John Gordon
y. There are no results to be fetched. If you want to get results, execute a query (usually a SELECT.) Also, that print statement is an obvious syntax error. Please post the actual code you're running; don't type it in from memory. -- John Gordon A is for Amy, who fell dow

Re: Natural Language Processing with Python .dispersion_plot returns nothing

2013-06-17 Thread John Gordon
last line I typed. How long did you wait for results before interrupting the command? How large is text4? It might just take a while to process. -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for B

Re: Having a hard time to 'get' bing api search results

2013-06-13 Thread John Gordon
n't matter to me. Thoughts? It looks like the code is mistakenly interpreting 'user:A' as a port specifier instead of a username and password. Can you supply the credentials another way, perhaps in a header? -- John Gordon A is for Amy, who fell down th

Re: Errin when executing a cgi script that sets a cookie in the browser

2013-06-05 Thread John Gordon
x27;No such file or directory' or 'Command not found' error if they begin with a shebang line which refers to a nonexistent program. -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears

Re: How to increment date by week?

2013-06-04 Thread John Gordon
=7) print "%d. %s" % (n, the_date) -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" -- http://mail.python.org/mailman/listinfo/python-list

Re: lstrip problem - beginner question

2013-06-04 Thread John Gordon
x27;re telling python to remove all of the characters in '>contig-100_' from the base string, which leaves nothing remaining. The reason it "worked" on your first example was that the character '1' didn't occur in your sample header string 'scaffold_

Re: @staticmethods called more than once

2013-05-21 Thread John Gordon
In John Gordon writes: > You should only call addHandler() once. ...for each intended logging output destination, of course. If you want logging output to appear in a file and on-screen, then you would call addHandler() once with a file handler and once with a screen handler. But I think

Re: @staticmethods called more than once

2013-05-21 Thread John Gordon
y what the problem is. However, I have a guess. Does MyLogger.set_logger() contain a call to addHandler()? Each call to addHandler() adds another handler to your logger, and when you call log.critical() [or any other log function] you get one line of output for each handler. You should only cal

Re: Get filename using filefialog.askfilename

2013-05-07 Thread John Gordon
ile) And it will display documentation for using objects of that type. You can also use this command: >>> dir(file) And it will display all the members and methods that the object provides. -- John Gordon A is for Amy, who fell down the stairs gor...

Re: python backup script

2013-05-06 Thread John Gordon
; > > stdin=cmd1.stdout) > Thank you Enrico. I've just tried your script and got this error: > stdin=cmd1.stdout) > ^ > SyntaxError: invalid syntax Looks like you need a comma after 'stdout=filename'. -- John Gordon

Re: First python program, syntax error in while loop

2013-05-03 Thread John Gordon
In Neil Cerutti writes: > Not quite yet. Players who guess correctly on the fifth try don't > get credit. Are you sure? tries is initialized to zero and isn't incremented for the initial guess. -- John Gordon A is for Amy, who fell down the stairs

Re: First python program, syntax error in while loop

2013-05-03 Thread John Gordon
t;, tries, "tries" else: print "Sorry, you lost!" -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" -- http://mail.python.org/mailman/listinfo/python-list

Re: First python program, syntax error in while loop

2013-05-03 Thread John Gordon
t; raw_input("\n\n Press any key to exit..") > ## it seems to stick with "higher" or "lower" after my first guess, whichever > it > ## is When the user re-enters their guess in the while loop, you're assigning the

Re: First python program, syntax error in while loop

2013-05-03 Thread John Gordon
le guess != number: ^ SyntaxError: invalid syntax -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" -- http://mail.python.org/mailman/listinfo/python-list

Re: First python program, syntax error in while loop

2013-05-03 Thread John Gordon
it..") > ## what is wrong with this script? I'm just trying to understand while loops > and ## this is not a real project :P You're missing a second closing parentheses on the line where the user inputs their guess. Also, you need to indent the 'if'

Re: Passing special characters in soap data

2013-04-30 Thread John Gordon
> Since i pass this data into my python script as a command line call, i get > the error: > /bin/sh: Syntax error: Unterminated quoted string Can you modify your python script so it accepts a filename which contains the xml? -- John Gordon A is for Amy, who fell

Re: how to: multiplayer game connecting to central server effectively?

2013-04-24 Thread John Gordon
aper). But a truly interactive game would probably require something more, like an active socket connection. -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, &quo

Re: datetime.strptime() not padding 0's

2013-04-23 Thread John Gordon
etime.strptime('Apr 9 2013', '%b %d %Y') > >>> dt.day > 9 > How can I get strptime to run 09? instead of 9 dt.day is just an integer. If you want to print it with zero padding, use a format string: >>> n = 9 >>> print n 9 >>> print

Re: How to connect to a website?

2013-04-22 Thread John Gordon
.voidspace.org.uk') response = urllib2.urlopen(request) content = response.readlines() -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" -- http://mail.python.org/mailman/listinfo/python-list

Re: unzipping a zipx file

2013-04-19 Thread John Gordon
In John Gordon writes: > In "b_erickson1" > writes: > > ozFile = open(filename,'w') > > ozFile.write(zFile.read(filename)) > > ozFile.close() > Perhaps you want to use zFile.extract() instead of zFile.rea

Re: unzipping a zipx file

2013-04-19 Thread John Gordon
In "b_erickson1" writes: > ozFile = open(filename,'w') > ozFile.write(zFile.read(filename)) > ozFile.close() Perhaps you want to use zFile.extract() instead of zFile.read()? -- John Gordon A is for Amy,

Re: How to set my gui?

2013-04-18 Thread John Gordon
In <5170648d$0$1368$4fafb...@reader2.news.tin.it> Tracubik writes: > i suppose i've to first generate the window and than populate it, but > where i've to put the "search for occurences" code? I don't think init() > is the right place.. What GUI

Re: Strange behavior for a 2D list

2013-04-18 Thread John Gordon
lecting every third element after that (and there are only two elements, so it stops after the first one): [[7, 8, 9, 10, 11, 12, 13]] Why were you expecting the other result? -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for B

Re: Novice Issue

2013-04-18 Thread John Gordon
put() while user_input != "quit" or user_input != "q": There is still a logic bug. This loop will execute forever, because no matter what the user enters, it will be unequal to "q" or unequal to "quit". Use 'and' instead of 'or'. Of

Re: Encoding NaN in JSON

2013-04-17 Thread John Gordon
string* 'N/A' for every NaN. import math x = possibly_NaN() if math.isnan(x): x = 'N/A' -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gore

Re: a couple of things I don't understand wrt lists

2013-04-16 Thread John Gordon
our example both rule[0] and rule[1] are zero, so I don't know why '1' ever got printed. Also, as far as I can tell, this code should not have worked at all: for i in range(rule): print rule[i] The range() function expects an integer, not a list. -- John Gordon

Re: Python pdb bug, followed by bug in bugs.python.org

2013-04-09 Thread John Gordon
ication email, and got some other form of= > brokenness in reply. > Suggestions? Post the 10-line program here, so others can verify whether it is a bug. -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears

Re: I hate you all

2013-04-05 Thread John Gordon
istent. You can't mix tabs and spaces for lines of code at the same indentation level. -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlyc

Re: a couple of questions: pickling objects and strict types

2013-04-05 Thread John Gordon
errors such as using a variable name before it's defined. For that, you can use an external program such as pylint or pyflakes. -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears

Re: Typing letters slowly using sys

2013-04-05 Thread John Gordon
wly Have you tried: sys.stdout.write('Loading') sys.stdout.flush() -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" -- http://mail.python.org/mailman/listinfo/python-list

Re: Typing letters slowly using sys

2013-04-05 Thread John Gordon
life of me figure out how to get the dots to appear on > the same line as "Loading". Every way that I have attempted, the word > "Loading" appears and then the dots appear on the next line. How are you printing the "Loading" text? (It would have helped a l

Re: Help

2013-04-01 Thread John Gordon
rt of implies that you want to use the program exactly as it was posted, without modifications. -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashly

Re: Help

2013-04-01 Thread John Gordon
he attached program doesn't (appear to) work with sums at all; why would you want to use it? Writing a new program from scratch would seem to be a better choice. -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for B

Re: Switching from Apche to LiteSpeed

2013-04-01 Thread John Gordon
> I see weird encoding although inside my python script i have: > #!/usr/bin/python > # -*- coding=utf-8 -* I believe the syntax is to use a colon, not an equal sign. i.e.: # -*- coding: utf-8 -*- Your example is also missing the final dash after the asterisk. -- John Gordon

Re: os.system() with imbeded quotes on centos

2013-04-01 Thread John Gordon
r in shell commands. You'll need to quote or escape it. Try this: someip = '192.168.01.01' var1 = 'lynx -dump "http://' + someip + '/cgi-bin/.log&.submit=+++Go%21+++" > junk' Note the extra pair of double-quotes around the http

Re: I need a neat way to print nothing or a number

2013-03-26 Thread John Gordon
In c...@isbd.net writes: > What's a neat way to print columns of numbers with blanks where a number > is zero or None? print number or ' ' -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basi

Re: how does the % work?

2013-03-22 Thread John Gordon
ree single-quotes, etc.) The error message also says that the print statement has a close-parenthesis after the string and before the arguments, which may be real problem. -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" -- http://mail.python.org/mailman/listinfo/python-list

Re: Test a list

2013-03-20 Thread John Gordon
[]' is wrong. 4. The way you have this code set up, you would need two loops: an outer loop for i from 1 to 25, and an inner loop for the items in t. 5. As others have said, this is a poor way to go about it. You want to use "if i in t". -- John Gordon A is f

Re: working with dict : incrementing dict dynamically

2013-03-11 Thread John Gordon
ill always evaluate true, because you're comparing region_num to itself. > num_pixel = +1 This doesn't store the value of num_pixel in the dictionary. You probably want to do this instead: segments[region_num] += 1 -- John Gordon A is for Amy, who f

Re: An error when i switched from python v2.6.6 => v3.2.3

2013-03-07 Thread John Gordon
u have the close-parentheses in the wrong place. The line should be: os.system( 'python metrites.py > %s' % htmltemp ) -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears

Re: Issue with continous incrementing of unbroken sequence for a entire working day

2013-02-28 Thread John Gordon
the file exists, you know that the program has already run today and you can read the file to obtain the previous serial number. If the file does not exist, you know the program has not yet run today and you can start the serial number at 1. -- John Gordon A is for Amy, wh

Django error tracebacks

2013-02-27 Thread John Gordon
his? (I'm using Django 1.3 instead of the current 1.4 version, but still, this seems like a pretty basic thing to get wrong.) -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears

Re: improving performance of writing into a pipe

2013-02-20 Thread John Gordon
this. If you don't know what exception is being raised, temporarily remove the try/except statements and run the code directly. You'll get the exception, and then you'll know which one it is. -- John Gordon A is for Amy, who fell down the stairs gor...

Re: New User-Need-Help

2013-02-15 Thread John Gordon
y in version 3. Change your print statement to look like this: print("Game Over") -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashly

Re: Howto parse a string using a char in python

2013-02-15 Thread John Gordon
just need the "123456" > substring.(left of the :) > I have looked at regular expressions and string functions, so far no luck. > Custom function required? Use the split() string function. -- John Gordon A is for Amy, who fell down the stai

Re: New User-Need-Help

2013-02-15 Thread John Gordon
hould be broken into two separate lines: print "Game Over" raw_input("\n\nPress Enter Key to exit") I can't believe the book put all that code on one line... -- John Gordon A is for Amy, who fell down the stairs

Re: Web Testing Frameworks

2013-02-12 Thread John Gordon
In Greg Lindstrom writes: > I'm not wanting to start anything here, but I am wanting to automate > testing of my Django-based websites. A quick search on Google turns up a Have you looked at using the built-in django test client? -- John Gordon A is for Amy, wh

Re: Parsing XML RSS feed byte stream for tag

2013-02-07 Thread John Gordon
uld be greatly appreciated. You haven't included the BeautifulSoup code which attempts to parse the XML, so it's impossible to say exactly what the error is. However, I have a guess: you said you're trying to return the first child. Based on the above output, the first child is t

Re: Please provide a better explanation of tuples and dictionaries

2013-01-29 Thread John Gordon
;> person['name'] = 'John' >>> person['age'] = 40 >>> person['occupation'] = 'Programmer' >>> print person['age'] 40 Dictionaries can also be created with some initial values, like so: >

Re: The best, friendly and easy use Python Editor.

2013-01-24 Thread John Gordon
In Sharwan Joram writes: > use vim. He said he wanted autocomplete. Does Vim have that? -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gas

Re: The best, friendly and easy use Python Editor.

2013-01-24 Thread John Gordon
> complete/auto correct. Try PyScripter. http://code.google.com/p/pyscripter/ -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashly

Re: Arent these snippets equivalent?

2013-01-23 Thread John Gordon
valent to me (in terms of control flow). But in the second example the fp.read() statement is duplicated, which is undesirable. It would be all too easy for a maintenance programmer to go into the code a year from now and change the first one but miss the second one. -- John Gordon

Re: Search log for string and display hourly/daily report

2013-01-23 Thread John Gordon
t: ", daily_instances This code assumes that log lines begin with a timestamp similar to "2013-01-23T09:27:01". If the timestamp is in a different format, or occurs elsewhere in the line, you'll have to adjust for that. -- John Gordon A is for Amy,

Re: Converting a string to a number by using INT (no hash method)

2013-01-22 Thread John Gordon
187 cursor.execute( '''INSERT INTO visitors(pin, host , hits, useros, browser, date) VALUES(%s, %s, %s, %s, %s)''', (pin, hos t, 1, useros, browser, date) ) The INSERT statement gives six column names but only five placeholders (%s) in the VALUES clause. Perhaps

<    1   2   3   4   5   >