Re: [Tutor] Stupid bug

2010-11-10 Thread Wayne Werner
On Wed, Nov 10, 2010 at 5:16 PM, Terry Carroll wrote: > This isn't a question, I'm just offering it as a cautionary tale and an > opportunity to laugh at my own stupidity. > > Turns out my function was working correctly all along; but with my typo, I > was printing out the value from the first c

Re: [Tutor] Data Directory under site-packages

2010-11-10 Thread Terry Carroll
On Wed, 10 Nov 2010, Greg Lindstrom wrote: I'm writing my first module that I intend to put under our company's "site-packages" directory for everyone to use in their programs. The problem I'm having is that I want to place files in a data directory under the module directory (under site-packag

[Tutor] Data Directory under site-packages

2010-11-10 Thread Greg Lindstrom
Hello, I'm writing my first module that I intend to put under our company's "site-packages" directory for everyone to use in their programs. The problem I'm having is that I want to place files in a data directory under the module directory (under site-packages) and I don't know how to set the

Re: [Tutor] put query result set into dictionary

2010-11-10 Thread Alan Gauld
"Shawn Matlock" wrote I am trying to put the results of a MySQL query into a dictionary. It fails because it includes the Unicode delimiter - "u'somevalue'". I don't think so... envsql = "select envVariable, envValue from ODS_ENV_DICT where envName = 'ST2'" csdbCursor.execute(envsql) e

Re: [Tutor] unicode nightmare

2010-11-10 Thread Alan Gauld
"danielle davout" wrote I simplify it to v = u'\u0eb4' X = (1,) gen = ((v ,v) for x in X for y in X) What can be so wrong in this line, around it to give the 1lined file ໄ:ໄ where ໄ "is" not u'\u0eb4' but u'\u0ec4' though a direct printing looks OK The code will produce a one line file wi

Re: [Tutor] put query result set into dictionary

2010-11-10 Thread Joel Goldstick
On Wed, Nov 10, 2010 at 5:18 PM, Shawn Matlock wrote: > Let’s see if I can ask the right questions the right way. I am trying to > put the results of a MySQL query into a dictionary. It fails because it > includes the Unicode delimiter - “u’somevalue’”. Can someone tell me the > right way to do t

[Tutor] Stupid bug

2010-11-10 Thread Terry Carroll
This isn't a question, I'm just offering it as a cautionary tale and an opportunity to laugh at my own stupidity. I have a small function to calculate the MD5 checksum for a file. It's nothing fancy: ### import hashlib def md5(filename, bufsize=65536): ""

Re: [Tutor] variables question.

2010-11-10 Thread Luke Paireepinart
It's pretty typical for scoping rules. If you define variables outside of your funcs you can access them inside the func. If you want to change the value in the function you need to declare the scope as global. If you make another variable with the same name inside of a function it will shadow t

[Tutor] put query result set into dictionary

2010-11-10 Thread Shawn Matlock
Let's see if I can ask the right questions the right way. I am trying to put the results of a MySQL query into a dictionary. It fails because it includes the Unicode delimiter - "u'somevalue'". Can someone tell me the right way to do this, please? Thank you, Shawn csdbConn = zxJDBC.connec

Re: [Tutor] variables question.

2010-11-10 Thread Emile van Sebille
On 11/10/2010 10:21 AM Jeff Honey said... I have a question about where variables are exposed in python. You're looking for scoping rules -- see for example http://stackoverflow.com/questions/291978/short-description-of-python-scoping-rules where they get into some detail, but the short and o

Re: [Tutor] Tutor Digest, Vol 81, Issue 39

2010-11-10 Thread Alan Gauld
"marupalli charan" wrote Thanks, but first one not working!!! First one of what? Please edit the message to pprovide some context and pay attention to the instruxctions that you so helpfully posted: When replying, please edit your Subject line so it is more specific than "Re: Contents of T

Re: [Tutor] variables question.

2010-11-10 Thread Alan Gauld
"Jeff Honey" wrote I have a question about where variables are exposed in python. Take a look at the namespaces topic in my tutor for more details but... I have a monolothic script with a number of functions defined, can those functions share variables? Yes but its usually bad practice

Re: [Tutor] List comprehension question

2010-11-10 Thread Steven D'Aprano
Richard D. Moores wrote: On Tue, Nov 9, 2010 at 12:54, Steven D'Aprano wrote: Richard D. Moores wrote: See for a speed test with n = 100,000 and 100,000 loops As a general rule, you shouldn't try to roll your own speed tests. There are various subtleti

[Tutor] unicode nightmare

2010-11-10 Thread danielle davout
Hi, I really badly need any start of explanation .. Please help me ! I have got a list of 64 generators from which I generate files. 58 give what I expected 1 is getting me mad, not the first, not the last the fifth... I simplify it to v = u'\u0eb4' X = (1,) gen = ((v ,v) for x in X for y in X)

Re: [Tutor] List comprehension question

2010-11-10 Thread Steven D'Aprano
Richard D. Moores wrote: def proper_divisors_sum(n): return sum(list(divisors(n))) - n There's no need to call list first. sum() will happily operate on any sort of iterable -- lists, sums, iterators, generators, range objects. Anything except strings, which would be pointless even if yo

[Tutor] Need help with script for finding pairs of amicable numbers

2010-11-10 Thread col speed
> > -- > > Message: 2 > Date: Tue, 09 Nov 2010 12:35:26 +0100 > From: Stefan Behnel > To: tutor@python.org > Subject: Re: [Tutor] List comprehension question > Message-ID: > Content-Type: text/plain; charset=UTF-8; format=flowed > > Richard D. Moores, 09.11.2010 12:07:

[Tutor] variables question.

2010-11-10 Thread Jeff Honey
I have a question about where variables are exposed in python. I have a monolothic script with a number of functions defined, can those functions share variables? can I instantiate them outside the function of where they are needed? do they need to be wrapped in quotes, ever? For example: blah

Re: [Tutor] Tutor Digest, Vol 81, Issue 39

2010-11-10 Thread marupalli charan
Thanks, but first one not working!!! On 11/10/10, tutor-requ...@python.org wrote: > Send Tutor mailing list submissions to > tutor@python.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://mail.python.org/mailman/listinfo/tutor > or, via email, send a message w