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
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
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
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
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
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.
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"
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
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
;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
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
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
\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__.
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
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
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
> 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
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
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
= "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
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)
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
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
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
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
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
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
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
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
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
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
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
> {'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
;", 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
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
--
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
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
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
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
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
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
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
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:
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
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
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
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
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
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
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
=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
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_
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
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
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...
;
> > 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
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
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
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
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
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'
> 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
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
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
.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
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
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,
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
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
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
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
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
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
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
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
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
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
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
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
> 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
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
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
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
[]' 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
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
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
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
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
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...
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
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
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
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
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
;> person['name'] = 'John'
>>> person['age'] = 40
>>> person['occupation'] = 'Programmer'
>>> print person['age']
40
Dictionaries can also be created with some initial values, like so:
>
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
> 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
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
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,
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
201 - 300 of 491 matches
Mail list logo