Victor Subervi wrote:
Code snippet:
[...]
Error:
[...]
What do?
After eliminating the pieces of your post that have been copied or
quoted from elsewhere, I am left with a total of five words of your own
to ask this question, which seems to be approximately the same amount of
effort you
Victor Subervi wrote:
First I get scolded for not including enough information. Now I get
scolded for including too much. Seems I can't win. I *am* putting effort
into understanding this. I'm sorry I'm not as sharp as you are in these
matters.
I didn't scold you for including too much
Victor Subervi wrote:
Hi;
I have this line of code:
sql = 'select Name, Price from %sPackages where ID=%s;' % (store, pid)
which prints to this:
select Name, Price from productsPackages where ID=1;
which when I enter it into the MySQL interpreter gives me this:
mysql select Name, Price
Victor Subervi wrote:
I have an automatically generated HTML form from which I need to extract
data to the script which this form calls (to which the information is
sent).
Ideally, the script that receives the submitted fields should know how
the form was generated, so it knows what fields to
?
Couldn't you just use the built-in enumerate() to replace the whole thing?
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo/python-list
Victor Subervi wrote:
Hi;
I have a script that is called via the web. This script writes another
script that is also called by the web, which in turn needs to have
execution privileges. The problem is that the programmatically created
file is owned by apache.apache and thus doesn't have
, the output you expected, and the output it produced instead.
Blind guess: You're using except ProgrammingError when you should be
using except MySQLdb.ProgrammingError. If this guess is incorrect, see
above.
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman
Victor Subervi wrote:
On Tue, Dec 29, 2009 at 3:43 PM, Carsten Haese carsten.ha...@gmail.com
mailto:carsten.ha...@gmail.com wrote:
You apparently haven't followed the tutorials carefully enough. You do
know that a cookie is a piece of information that's stored in your
browser
. You're printing it where it
doesn't belong, in the middle of your HTML output. You need to
reorganize your print statements such that the Set-Cookie header is
printed in the header of your script's output.
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman
is printed as part of the
page headers. I'll give you one last hint: The page header is where
you're printing the Content-type line.
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo/python-list
, whereas you appear to be trying
to earn a living writing programs. If you can't learn to think like a
programmer, sooner or later you'll have to face the grim reality that
you'll never earn a living as a programmer. Maybe you should try to earn
a living as a poet instead.
--
Carsten Haese
http
. [Emphasis
mine.] You even copy-and-pasted a snippet containing that very sentence
into an earlier post on this thread, so how you can now claim that the
tutorial didn't mention this is quite beyond me.
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo
think you need but don't,
and lots of Python anti-idioms, all of which conspire to make it
impossible for anybody who is not paid to do this work to put in the
effort that's necessary to trace your logic and identify the bug.
Please help us help you.
--
Carsten Haese
http://informixdb.sourceforge.net
an HTML table, but I
can't tell how it differs from what you're expecting, because you didn't
describe what you're expecting.
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo/python-list
Victor Subervi wrote:
On Tue, Dec 29, 2009 at 12:54 PM, Carsten Haese carsten.ha...@gmail.com
mailto:carsten.ha...@gmail.com wrote:
Victor Subervi wrote:
Since it is difficult to send the inputs but easy to provide the
outputs, and as opposed to posting the printout, let me
it does. The
desire to find out how something works is, in my opinion, an essential
skill in a programmer, and your maybe I'll figure it out later
attitude displays a disturbing lack of this skill.
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo/python
Victor Subervi wrote:
On Tue, Dec 29, 2009 at 3:58 PM, Carsten Haese carsten.ha...@gmail.com
mailto:carsten.ha...@gmail.com wrote:
Victor Subervi wrote:
You know I did this before, substituting f for field, and it
honestly wouldn't print but threw a 500 error. Now it works. I
that a cookie is a piece of information that's stored in your
browser, don't you? So tell me, which of the above lines of code do you
suppose is responsible for informing your browser of the cookie's contents?
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo
with the cgi module.
I'll do the latter:
http://webpython.codepoint.net/cgi_file_upload
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo/python-list
, by myself and others, not to
embed values directly into the query string. Use parameter binding to
transmit the values to the database. I'm sure you'll find an old post of
mine somewhere in the archives of this list in which I showed you how to
do that.
--
Carsten Haese
http
do you have a problem with? Checking
whether no value is fetched or log the fact?
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo/python-list
Victor Subervi wrote:
On Fri, Dec 25, 2009 at 11:35 AM, Carsten Haese carsten.ha...@gmail.com
mailto:carsten.ha...@gmail.com wrote:
Victor Subervi wrote:
Well I've done that. What happens is the storeColNames registers the
Availability field naturally enough; however, as I
persistent inability or unwillingness to honor this request.
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo/python-list
Victor Subervi wrote:
On Sat, Dec 12, 2009 at 6:35 PM, Carsten Haese carsten.ha...@gmail.com
mailto:carsten.ha...@gmail.com wrote:
The traceback helpfully shows us that colValue is a 1-tuple whose zeroth
entry, colValue[0], is an actual bona-fide Python Set object. Such
objects
' in aSet
True
'Banana' in aSet
False
HTH,
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo/python-list
Set type.)
The above-mentioned article has a section called Why you shouldn't use
SET. You should read it.
HTH,
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo/python-list
other command to retrieve the result set. What command are you
using, and what are the results?
How do I
retrieve them?
In my version of MySQL, he default value is in the fifth column of the
result set.
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman
Victor Subervi wrote:
On Sat, Dec 12, 2009 at 10:54 AM, Carsten Haese carsten.ha...@gmail.com
mailto:carsten.ha...@gmail.com wrote:
Victor Subervi wrote:
Hi;
I'm using MySQLdb. If I do a
cursor.execute('describe myTable;')
it gives me all sorts of data
a string to me.
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo/python-list
is, because you're once again
not providing enough information. We'd need to see where colValue is
coming from to find out what colValue[0] is.
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo/python-list
Python Set object. Such
objects aren't indexable, because sets are unordered. That still doesn't
tell us where colValue is coming from, though, so why it is a Python Set
object when you expected it to be a string remains an unsolved mystery.
--
Carsten Haese
http://informixdb.sourceforge.net
an instance of string. How do I know if it's a set?
That's a fantastic question. Python thinks it's a string. What makes you
think it's a set?
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo/python-list
(colNamesPics, pics):
query = (update %s set %s = %%s where SKU=%%s %
(store, column_name) )
parameters = (MySQLdb.Binary(pic), sku)
cursor.execute(query, parameters)
There, that's much less cluttered.
HTH,
--
Carsten Haese
http://informixdb.sourceforge.net
--
http
is not in danger.
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo/python-list
:]))
theTree = expand(cursor.fetchall())
which is the magical code supplied by the lister that does all the heavy
lifting but that I don't understand :-}
Suggestions?
Start by understanding the code you're using.
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org
what the code does. This won't tell
you *why* it does it, but it's your code, and you put it there to serve
a particular purpose. If you don't understand its purpose, you shouldn't
be using it at all.
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo
ValueError: too many values to unpack
As far as what's causing this error, I already explained that two weeks
ago: http://groups.google.com/group/comp.lang.python/msg/b9e02a9a9b550ad3
The fact that you're still struggling with this error is deeply
disturbing to me.
--
Carsten Haese
http
Victor Subervi wrote:
Of course I knew about those indentation errors
That may be so, but you cleverly disguised this fact by saying the exact
opposite.
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo/python-list
works.
In order to help you diagnose the problem, we need to see the *exact*
code you're running, we need to see the *exact* inputs going into it,
and we need to see the *exact* output coming out of it.
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo
that the above output
helps you arrive at the correct conclusion.
No, it doesn't, because you've only provided one third of what I asked
for. I also asked for the code and the inputs that go into it.
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo/python-list
to construct the FieldStorage object once and refer to that
one object in every pass of the loop.
As you can see, and as I suspected, it's not a bug in the cgi module.
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo/python-list
' % (8,456)
' 456'
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo/python-list
the entire options module as its
own separate namespace.
2) I use getattr on that separate namespace to look up the desired
function object from the options module. I assign the local name
tablefunc to the resulting function object.
3) I call that function using the local name tablefunc.
HTH,
--
Carsten
,
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo/python-list
/tutorial/floatingpoint.html .
Then, change print t to print repr(t) to see what's going on.
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo/python-list
Victor Subervi wrote:
On Fri, Nov 27, 2009 at 12:13 PM, Carsten Haese carsten.ha...@gmail.com
mailto:carsten.ha...@gmail.com wrote:
Victor Subervi wrote:
The difficulty I am having is that for
some reason it's not inserting. The form inserts the first image
to be filled into the query by the database engine. This query needs
only one parameter, so I'm making a 1-tuple containing the picture
contents, wrapped inside a MySQLdb.Binary object to tell the database
that this is a binary object.
Hope this helps,
--
Carsten Haese
http
spend trying to figure out what that error message
is telling you? What thought processes, if any, have you followed?
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo/python-list
, and show us the exact contents
of the file you're processing.
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo/python-list
the last 3 lines with this:
cursor.execute('use %s;' % db)
but it didn't like that, either.
Do not paraphrase error messages. Copy and paste the actual error
message and traceback.
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo/python-list
Anjanesh Lekshminarayanan wrote:
As of now, there is no mysql adaptor for Python3. Hence cant use
escape_string()
Maybe it would help if you explained what you are actually trying to
accomplish.
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo
Victor Subervi wrote:
On Mon, Nov 23, 2009 at 9:17 AM, Carsten Haese carsten.ha...@gmail.com
mailto:carsten.ha...@gmail.com wrote:
You thought you did, but did you? The code snippet above doesn't show
any code that closes a database connection.
Would you be so kind as to tell me
Victor Subervi wrote:
On Mon, Nov 23, 2009 at 10:08 AM, Carsten Haese carsten.ha...@gmail.com
mailto:carsten.ha...@gmail.com wrote:
As I said, the best way we can help you is if you copy the actual error
message so that we may diagnose the actual problem and suggest a
solution
, and Apache is complaining about that.
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo/python-list
on
this thread.
(http://mail.python.org/pipermail/python-list/2009-November/1227008.html)
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo/python-list
us a copy-and-paste of your command line window contents
that result from executing python testMail.py and then executing
python -c import email; print email immediately thereafter.
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo/python-list
keys is not used anywhere in your function.
So, this would indicate that changing the offending line to for nm in
levelDict should fix this particular error.
HTH,
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo/python-list
Victor Subervi wrote:
On Fri, Nov 20, 2009 at 11:14 AM, Carsten Haese carsten.ha...@gmail.com
mailto:carsten.ha...@gmail.com wrote:
Please show us a copy-and-paste of your command line window contents
that result from executing python testMail.py and then executing
python -c
. Look at the function definition. It'll tell you
what the function does.
Could
someone please explain what this code does?
Maybe you should ask the person that wrote the code.
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo/python-list
directory or
anywhere else on Python's path outside of the standard library? If so,
it's hiding the real email module from your script and you'll need to
get rid of your email.py by renaming or moving it.
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman
. Once it
compares equal, you can print the result and you're done.
Just do a brute-force search:
for i in range(1):
if i==7919:
# Found it!
print i
;-)
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo/python-list
to
Implementing a COM Server.)
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo/python-list
in the picture number and product ID, you should have
just one static getpic script that takes parameters from the URL that
tell it which image number and product ID to use.
This will fix your problem indirectly because then your script won't
have to write out any files at all.
--
Carsten Haese
http
Victor Subervi wrote:
I will do that after I fix the problem
Doing that is the fix.
No, this doesn't fix the problem!
How do you know? You obviously haven't tried it, since you say you have
yet to do it.
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman
that it is callable. You just need to call it. Like
this: method().
HTH,
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo/python-list
Victor Subervi wrote:
That's what I initially had. My server, that I am in
the process of leaving, rejected that syntax.
What version of Python does that server use? The calendar.Calendar class
first appeared in Python 2.5. I suspect your server is using an older
version.
--
Carsten Haese
http
Nadav Chernin wrote:
Thanks, but my question is how to write the regex.
See http://www.amk.ca/python/howto/regex/ .
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo/python-list
Lawrence D'Oliveiro wrote:
In message mailman.2504.1257216390.2807.python-l...@python.org, Carsten
Haese wrote:
With all due respect, but if your experience is exclusive to
MySQL/MySQLdb, your experience means very little for database
programming practices in general.
I wonder about
a BYTE column on an Informix database. The
only way to pass a BYTE value to an Informix database is by parameter
binding.
Since parameter binding is in general much more than string
substitution, it is indeed necessary to mix the two.
--
Carsten Haese
http://informixdb.sourceforge.net
--
http
can't insert and retrieve binary data values?
You CAN insert and retrieve binary data values. You just have to use the
right tool for the job, and that is parameter binding.
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo/python-list
. As long as you
understand what you're doing, there should be no confusion. (And if you
don't understand what you're doing, you shouldn't be doing it!)
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo/python-list
Lawrence D'Oliveiro wrote:
In message mailman.2376.1257005738.2807.python-l...@python.org, Carsten
Haese wrote:
Lawrence D'Oliveiro wrote:
In message mailman.2357.1256964121.2807.python-l...@python.org, Dennis
Lee Bieber wrote:
This way regular string interpolation operations
Victor Subervi wrote:
It doesn't work. What I want is to capture winX and winY and use them in
python. How?
Since you're still not heeding the advice from this article, please
allow me to refer you to it again:
http://catb.org/~esr/faqs/smart-questions.html
--
Carsten Haese
http
Victor Subervi wrote:
Can you give me an example of this?
That depends. How much of your client's money are you offering us for
doing your work?
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo/python-list
,
then your server isn't executing the code that you think it's executing.
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo/python-list
Victor Subervi wrote:
in line...
On Sat, Oct 17, 2009 at 11:33 AM, Carsten Haese carsten.ha...@gmail.com
mailto:carsten.ha...@gmail.com wrote:
Why would turning a comment into a statement NOT make a difference?!?
You misunderstood. Leaving in the __commented__ line __commented__
Victor Subervi wrote:
[snip...]
print 'Content-type: image/jpeg'
print 'Content-Encoding: base64'
print
print pic().encode('base64')
print '/body/html'
[snip...]
Why are you printing /body/html at the end of a page that is
supposed to be a base64-encoded JPEG file?
--
Carsten Haese
http
to get helpful answers.
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo/python-list
know your server is executing, and
not just some code that somewhat resembles the code that the server
might be executing), a detailed description of the result you're
expecting, and a detailed description of the result you're getting instead.
--
Carsten Haese
http://informixdb.sourceforge.net
):
self.todo = print+arg
def printa(self):
print 'a'
def printb(self):
print 'b'
def doit(self):
func = getattr(self, self.todo)
func()
o = dummy(sys.argv[1])
o.doit()
HTH,
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo
impossible to tell what exactly the problem is if you
don't show us your code. hanoi.pl is part of your code, but you haven't
posted it. Please post it.
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo/python-list
Victor Subervi wrote:
[...]
print '''Content-Type: image/jpeg
Content-Encoding: base64
'''
[...]
You have a spurious blank line between those header lines.
HTH,
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo/python-list
in the parameters.
HTH,
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo/python-list
the code that does
this transformation.
HTH,
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo/python-list
point = points[0]
py print point.x, point.y
1 2
HTH,
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo/python-list
between server and client. You should look
into the concept called session variables.
HTH,
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo/python-list
r wrote:
Of course in python you would do...
vector.reverse -- in-place
vector.reversed -- in-place
You do know that only one of those works in-place, right?
The above example works pretty good, but this doesn't always sound
good. Take for example this...
point3d.offset -- return a
,
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo/python-list
can
simply import diomodule and refer to the module by the name diomodule.
HTH,
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo/python-list
).
You might want to check on a list dedicated to adodbapi whether there
are module-specific quirks or caveats to watch out for. Or wait for
somebody with adodbapi-specific knowledge to chime in.
HTH,
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo/python
this helps,
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo/python-list
Marco Mariani wrote:
dateutil can do this and much, much more.
Using dateutil for this is like using a sledgehammer to kill a fly. The
task at hand can (and IMHO should) be solved with the standard datetime
module.
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org
through.
You must be doing something wrong, then:
py u'Hello,\ufffd World'.encode('ascii', 'ignore')
'Hello, World'
HTH,
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo/python-list
:
If items(), keys(), values(), iteritems(), iterkeys(), and itervalues()
are called with no intervening modifications to the dictionary, the
lists will directly correspond.
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo/python-list
of iteration will not change?
Neither of those convey the above guarantee.
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo/python-list
-inefficient) replacement is to accumulate a
list and return the list. Initialize a result variable to an empty list,
and instead of yielding elements, append them to the result variable.
Then return the result variable at the end of the function.
HTH,
--
Carsten Haese
http
Astley Le Jasper wrote:
Sorry for the numpty question ...
How do you find the reference name of an object?
So if i have this
bob = modulename.objectname()
how do i find that the name is 'bob'
Why do you need to find that? You know that its name is 'bob'.
--
Carsten Haese
http
Roy Smith wrote:
Does there exist a pure Python version of a MySQL module?
A quick google search turns up this:
http://github.com/mopemope/pure-python-mysql/tree/master/pymysql
I've never used it, though, so I have no idea whether it works or how
well it works.
HTH,
--
Carsten Haese
http
, and why?
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo/python-list
/io/control.dat relative to its current working directory. That
will only work if the current working directory of the program is
C:\myprogramfolder\run. Is it?
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo/python-list
1 - 100 of 682 matches
Mail list logo