No module name tests

2011-05-31 Thread SONAL ...
Hey i have directory structure as gkwebapp/gnukhata-webapp/gnukhata/tests/functional in which we have our test files. When i run tests, get following error: Traceback (most recent call last): File "test_account.py", line 1, in from gnukhata.tests import * ImportError: No module named gnukh

Re: float("nan") in set or as key

2011-05-31 Thread Carl Banks
On Tuesday, May 31, 2011 8:57:57 PM UTC-7, Chris Angelico wrote: > On Wed, Jun 1, 2011 at 1:30 PM, Carl Banks > wrote: > > I think you misunderstood what I was saying. > > > > It's not *possible* to represent a real number abstractly in any digital > > computer.  Python couldn't have an "abstrac

Re: float("nan") in set or as key

2011-05-31 Thread Ben Finney
Chris Angelico writes: > Right. Obviously a true 'real number' representation can't be done. > But there are multiple plausible approximations thereof (the best > being rationals). Sure. But most of those are not what is most commonly meant by ‘float’ type. > Not asking for Python to be changed

Re: Updated blog post on how to use super()

2011-05-31 Thread Ben Finney
Raymond Hettinger writes: > Any further suggestions are welcome. I am impressed by your optimistic outlook: For reorderable method calls to work, the classes need to be designed cooperatively. This presents three easily solved practical issues[…] :-) It's a good document, and I'm

Re: float("nan") in set or as key

2011-05-31 Thread Chris Angelico
On Wed, Jun 1, 2011 at 1:30 PM, Carl Banks wrote: > I think you misunderstood what I was saying. > > It's not *possible* to represent a real number abstractly in any digital > computer.  Python couldn't have an "abstract real number" type even it wanted > to. True, but why should the "non-integ

Re: Alternatives to PythonPath

2011-05-31 Thread Gabriel Genellina
En Sun, 29 May 2011 18:49:28 -0300, ray escribió: I am using Win7 on a tightly locked down desktop. Is there an alternative to using PythonPath? What are the trade-offs? Usually there is no need to define the PYTHONPATH variable; I never use it. There is a per-user site-packages directory (

Re: float("nan") in set or as key

2011-05-31 Thread Roy Smith
In article Carl Banks wrote: > pretty much everyone uses IEEE format Is there *any* hardware in use today which supports floating point using a format other than IEEE? -- http://mail.python.org/mailman/listinfo/python-list

Re: float("nan") in set or as key

2011-05-31 Thread rusi
On Jun 1, 7:45 am, Carl Banks wrote: > On Sunday, May 29, 2011 8:59:49 PM UTC-7, Steven D'Aprano wrote: > > On Sun, 29 May 2011 17:55:22 -0700, Carl Banks wrote: > > > > Floating point arithmetic evolved more or less on languages like Fortran > > > where things like exceptions were unheard of, > >

Re: float("nan") in set or as key

2011-05-31 Thread Carl Banks
On Tuesday, May 31, 2011 8:05:43 PM UTC-7, Chris Angelico wrote: > On Wed, Jun 1, 2011 at 12:59 PM, Carl Banks > wrote: > > On Sunday, May 29, 2011 7:53:59 PM UTC-7, Chris Angelico wrote: > >> Okay, here's a question. The Python 'float' value - is it meant to be > >> "a Python representation of a

Re: Sanitizing filename strings across platforms

2011-05-31 Thread Jean-Paul Calderone
On May 31, 10:17 pm, Tim Chase wrote: > Scenario: a file-name from potentially untrusted sources may have > odd filenames that need to be sanitized for the underlying OS. > On *nix, this generally just means "don't use '/' or \x00 in your > string", while on Win32, there are a host of verboten cha

Re: float("nan") in set or as key

2011-05-31 Thread Chris Angelico
On Wed, Jun 1, 2011 at 12:59 PM, Carl Banks wrote: > On Sunday, May 29, 2011 7:53:59 PM UTC-7, Chris Angelico wrote: >> Okay, here's a question. The Python 'float' value - is it meant to be >> "a Python representation of an IEEE double-precision floating point >> value", or "a Python representatio

Re: float("nan") in set or as key

2011-05-31 Thread Carl Banks
On Sunday, May 29, 2011 7:53:59 PM UTC-7, Chris Angelico wrote: > Okay, here's a question. The Python 'float' value - is it meant to be > "a Python representation of an IEEE double-precision floating point > value", or "a Python representation of a real number"? The former. Unlike the case with i

Sanitizing filename strings across platforms

2011-05-31 Thread Tim Chase
Scenario: a file-name from potentially untrusted sources may have odd filenames that need to be sanitized for the underlying OS. On *nix, this generally just means "don't use '/' or \x00 in your string", while on Win32, there are a host of verboten characters and file-names. Then there's also

Re: float("nan") in set or as key

2011-05-31 Thread Carl Banks
On Sunday, May 29, 2011 8:59:49 PM UTC-7, Steven D'Aprano wrote: > On Sun, 29 May 2011 17:55:22 -0700, Carl Banks wrote: > > > Floating point arithmetic evolved more or less on languages like Fortran > > where things like exceptions were unheard of, > > I'm afraid that you are completely mistake

Updated blog post on how to use super()

2011-05-31 Thread Raymond Hettinger
I've tightened the wording a bit, made much better use of keyword arguments instead of kwds.pop(arg), and added a section on defensive programming (protecting a subclass from inadvertently missing an MRO requirement). Also, there is an entry on how to use assertions to validate search order requir

Re: returning NotImplemented

2011-05-31 Thread Eric Snow
On Tue, May 31, 2011 at 6:30 PM, Ethan Furman wrote: > Eric Snow wrote: > >> Guido indicates earlier in the thread that NotImplemented is used so that >> you know that it came from the function that you directly called, and not >> from another call inside that function. Why does it matter if it

Re: scope of function parameters (take two)

2011-05-31 Thread Ian Kelly
On Tue, May 31, 2011 at 6:04 PM, Daniel Kluev wrote: > On Wed, Jun 1, 2011 at 3:16 AM, Ian Kelly wrote: >> >> There is no "decorator" module in the standard library.  This must be >> some third-party module.  The usual way to do this would be: > > Yes, but its very useful for decorators and provi

Re: Something is rotten in Denmark...

2011-05-31 Thread Martin Manns
On Tue, 31 May 2011 15:47:33 -0600 Ian Kelly wrote: > The i variable is part of the global scope, and as you iterate over > range(10) again it coincidentally takes on the same values as in the > original list comprehension. You don't see this in Python 3 because > the scope of i is limited to th

Python hoodie

2011-05-31 Thread Christopher James
Hi all! I LOVE Python, and want to spread the word by sporting this awesome sweater shown at: http://www.freewear.org/?page=show_item&id=FW0067 which I found by looking on the merchandise page of python.org. However, I live in the United States and before checking out I noticed that on top of the

Re: returning NotImplemented

2011-05-31 Thread Ethan Furman
Eric Snow wrote: Guido indicates earlier in the thread that NotImplemented is used so that you know that it came from the function that you directly called, and not from another call inside that function. Why does it matter if it came directly from the function or not? And couldn't the NotIm

Re: Something is rotten in Denmark...

2011-05-31 Thread harrismh777
Terry Reedy wrote: This is early-binding versus late-binding. Python is a late-binding language. ok ... Are you asking about changing all function compilation or only when functions are defined with lambda expressions? At least lambda expressions, but (see below) any other built-in

Re: scope of function parameters (take two)

2011-05-31 Thread Daniel Kluev
On Wed, Jun 1, 2011 at 3:16 AM, Ian Kelly wrote: > > There is no "decorator" module in the standard library.  This must be > some third-party module.  The usual way to do this would be: Yes, but its very useful for decorators and provides some not-readily-available functionality. http://pypi.pyth

Re: Something is rotten in Denmark...

2011-05-31 Thread Terry Reedy
On 5/31/2011 4:18 PM, harrismh777 wrote: Terry Reedy wrote: You have been hypnotizeed by lambda. (lambda n: i+n) is a *constant expression*, so you get 10 'equal' functions. 'hypnotized' indeed! I say 'hypnotized' ;-) because people have posted examples almost exactly like the one you did,

hide gtk warning

2011-05-31 Thread miamia
I am getting gtkwarning: gdk_property_change: assertion window ! =Null failed gtk.main() it is gdk bug but not fixed yet.How could I simply "not show/hide" this error warning? so user should never see it. thank you -- http://mail.python.org/mailman/listinfo/python-list

Re: Something is rotten in Denmark...

2011-05-31 Thread Chris Angelico
On Wed, Jun 1, 2011 at 8:39 AM, Chris Angelico wrote: > - Issue #1713: Fix os.path.ismount(), which returned true for symbolic links >  across devices. PS. I know nothing about this particular issue, I just skimmed down the release notes and stopped when something caught my eye. Choose another ex

Re: Something is rotten in Denmark...

2011-05-31 Thread Chris Angelico
On Wed, Jun 1, 2011 at 7:53 AM, harrismh777 wrote: >     Having compared the two, someone please tell me whether the two are > incompatible, mostly compatible, completely incompatible, or different > languages... > By implication, every version of Python is incompatible with every other. The 2.7.

Re: Something is rotten in Denmark...

2011-05-31 Thread Ian Kelly
On Tue, May 31, 2011 at 2:18 PM, harrismh777 wrote: > If I'm understanding that correctly, then that means lambda is working as > designed, and that there are very subtle nuances to be aware of. In my > little case > >   (lambda n: i + n) > >   ... if the  i  goes out of scope before the anonymous

Re: returning NotImplemented

2011-05-31 Thread Eric Snow
On Tue, May 31, 2011 at 4:18 PM, Ethan Furman wrote: > Eric Snow wrote: > >> Looking at the ABC code [1], I noticed that Mapping's __eq__ method can >> return NotImplemented. This got me curious as to why you would return >> NotImplemented and not raise a TypeError or a NotImplementedError. >> >

Re: Something is rotten in Denmark...

2011-05-31 Thread harrismh777
harrismh777 wrote: PS Ian calls the second construct "working by mistake..." oops, actually he called it, "working by accident... " -- http://mail.python.org/mailman/listinfo/python-list

Re: returning NotImplemented

2011-05-31 Thread Ethan Furman
Eric Snow wrote: Looking at the ABC code [1], I noticed that Mapping's __eq__ method can return NotImplemented. This got me curious as to why you would return NotImplemented and not raise a TypeError or a NotImplementedError. My understanding is that if your object does not know how to perf

Re: Something is rotten in Denmark...

2011-05-31 Thread harrismh777
Martin Manns wrote: After being confused I figured out it is a 3.x example: Actually, it is a compatibility example between 2.x and 3.x, compare below for different behavior from two seemingly identical compatible constructs, one from 3.2, and the other from 2.6.4: Python 3.2 (r32:88445,

Re: Thanks for all responses

2011-05-31 Thread Chris Angelico
On Wed, Jun 1, 2011 at 5:52 AM, Wolfgang Meiners wrote: > Whenever i 'cross the border' of my program, i have to encode the 'list > of bytes' to an unicode string or decode the unicode string to a 'list > of bytes' which is meaningful to the world outside. Most people use "encode" and "decode" th

Re: returning NotImplemented

2011-05-31 Thread Eric Snow
On Tue, May 31, 2011 at 3:46 PM, Eric Snow wrote: > Looking at the ABC code [1], I noticed that Mapping's __eq__ method can > return NotImplemented. This got me curious as to why you would return > NotImplemented and not raise a TypeError or a NotImplementedError. > > There was an issue regarding

Re: Something is rotten in Denmark...

2011-05-31 Thread Ian Kelly
On Tue, May 31, 2011 at 3:14 PM, Martin Manns wrote: > $ python > Python 2.6.6 (r266:84292, Apr 20 2011, 11:58:30) > [GCC 4.5.2] on linux2 > Type "help", "copyright", "credits" or "license" for more information. fs=[] fs = [(lambda n: i + n) for i in range(10)] [fs[i](1) for i in ra

returning NotImplemented

2011-05-31 Thread Eric Snow
Looking at the ABC code [1], I noticed that Mapping's __eq__ method can return NotImplemented. This got me curious as to why you would return NotImplemented and not raise a TypeError or a NotImplementedError. There was an issue regarding this last year [2] that indicated the reason for Mapping's

Re: Something is rotten in Denmark...

2011-05-31 Thread Martin Manns
On Tue, 31 May 2011 01:48:05 -0500 harrismh777 wrote: > >>> fs=[] > >>> fs = [(lambda n: i + n) for i in range(10)] > >>> [fs[i](1) for i in range(10)] > [10, 10, 10, 10, 10, 10, 10, 10, 10, 10] <=== not good > > ( that was a big surprise! . . . ) > ( let's try it another way .

Re: scope of function parameters (take two)

2011-05-31 Thread Chris Kaynor
I was thinking you could do something strange like: kw = {object(): None} def test(**kw): print kw test(**kw) however, upon testing it (in Python 2.6), I found that it errors while trying to unpack the kw dict stating that they must all be strings. Perhaps making a custom class derived off ba

Re: Something is rotten in Denmark...

2011-05-31 Thread harrismh777
Terry Reedy wrote: You have been hypnotizeed by lambda. (lambda n: i+n) is a *constant expression*, so you get 10 'equal' functions. 'hypnotized' indeed! ... ok, so let me see if I get this... the lambda defers lookup|bind of its references until such time as the lambda is 'called' and not

Thanks for all responses

2011-05-31 Thread Wolfgang Meiners
I think it helped me very much to understand the problem. So if i deal with nonascii strings, i have a 'list of bytes' and need an encoding to interpret this list and transform it to a meaningful unicode string. Decoding does the opposite. Whenever i 'cross the border' of my program, i have to en

Re: scope of function parameters (take two)

2011-05-31 Thread Ethan Furman
Henry Olders wrote: Clearly, making a copy within the function eliminates the possibility of the side effects caused by passing in mutable objects. Would having the compiler/interpreter do this automatically make python so much different? It would be a different language. ~Ethan~ -- http://m

Re: scope of function parameters (take two)

2011-05-31 Thread Ethan Furman
Henry Olders wrote: [...] what I want is a function that is free of side effects [...] Shoot, that's easy! Just write your function to not have any! ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: Beginner needs advice

2011-05-31 Thread Dotan Cohen
On Tue, May 31, 2011 at 21:29, Ian Kelly wrote: > On Tue, May 31, 2011 at 11:56 AM, Dotan Cohen wrote: >>>  If you disagree, then I invite you to list one example of two >>> different things that are compatible. >>> >> >> Men and women. > > This is a slightly different sense of the word compatibl

Re: Beginner needs advice

2011-05-31 Thread Ian Kelly
On Tue, May 31, 2011 at 11:56 AM, Dotan Cohen wrote: >>  If you disagree, then I invite you to list one example of two >> different things that are compatible. >> > > Men and women. This is a slightly different sense of the word compatible than we have been discussing: able to work together to pe

Re: Beginner needs advice

2011-05-31 Thread Dotan Cohen
>  If you disagree, then I invite you to list one example of two > different things that are compatible. > Men and women. MS Office and Open Office. IE6 and HTML. -- Dotan Cohen http://gibberish.co.il http://what-is-what.com -- http://mail.python.org/mailman/listinfo/python-list

Re: scope of function parameters

2011-05-31 Thread rusi
On May 31, 9:46 pm, rusi wrote: > So you then use (something like) > > fnc2(c):  return c[0:1] + c[2:] Er sorry -- that should have been def fnc2(c): return c[0:1] + ('having',) + c[2:] -- http://mail.python.org/mailman/listinfo/python-list

Re: sqlalchemy and Unicode strings: errormessage

2011-05-31 Thread Chris Angelico
On Wed, Jun 1, 2011 at 2:31 AM, Prasad, Ramit wrote: >>line = unicode(line.strip(),'utf8') >>and now i get really utf8-strings. It does work but i dont know why it works. >>For me it looks like i change an utf8-string to an utf8-string. > > > I would like to point out that UTF-8 is not exactly "U

Re: Something is rotten in Denmark...

2011-05-31 Thread Terry Reedy
On 5/31/2011 2:48 AM, harrismh777 wrote: fs=[] Irrelevant here since you immediately rebind 'fs'. fs = [(lambda n: i + n) for i in range(10)] [fs[i](1) for i in range(10)] Same as [f(1) for f in fs] [10, 10, 10, 10, 10, 10, 10, 10, 10, 10] <=== not good ( that was a big surprise! . . . )

Re: scope of function parameters (take two)

2011-05-31 Thread Ian Kelly
On Tue, May 31, 2011 at 10:34 AM, Chris Kaynor wrote: > Is there any reason not to simplify this to: > def copy_args(f): >    @functools.wraps(f) >    def wrapper(*args, **kw): >        nargs = copy.deepcopy(args) >        nkw = copy.deepcopy(kw) >        return f(*nargs, **nkw) >    return wrappe

nosend missing in suds 0.4?

2011-05-31 Thread Mike
Looks like the nosend attribute is not available in 0.4. Any reason for this? Any plans to add it back and what is the most recent release that does have the nosend option? -- http://mail.python.org/mailman/listinfo/python-list

Re: Beginner needs advice

2011-05-31 Thread MRAB
On 31/05/2011 06:48, Ben Finney wrote: Dennis Lee Bieber writes: Well... He did say "find the bathroom", not ask for directions to whatever euphemism is in current usage (water closet, W/C, loo ?) The room which contains the bath is the bathroom. Assuming that the toilet is in the s

RE: sqlalchemy and Unicode strings: errormessage

2011-05-31 Thread Prasad, Ramit
>line = unicode(line.strip(),'utf8') >and now i get really utf8-strings. It does work but i dont know why it works. >For me it looks like i change an utf8-string to an utf8-string. I would like to point out that UTF-8 is not exactly "Unicode". From what I understand, Unicode is a standard while

Re: Load averages and Python threads on different Linux cloud provider setup

2011-05-31 Thread Mohan
On May 31, 10:22 pm, Chris Angelico wrote: > On Tue, May 31, 2011 at 9:25 PM, Mohanaraj Gopala Krishnan > > wrote: > > Any suggestion on why the load would be a lot higher or how I could > > debug this further is greatly appreciated. > > First off, an easy question: Is system load low and compara

Re: scope of function parameters

2011-05-31 Thread rusi
On May 29, 1:30 pm, Henry Olders wrote: > I just spent a considerable amount of time and effort debugging a program. > The made-up code snippet below illustrates the problem I encountered: > > def main(): >         a = ['a list','with','three elements'] >         print a >         print fnc1(a) >

Re: sqlalchemy and Unicode strings: errormessage

2011-05-31 Thread Benjamin Kaplan
On Tue, May 31, 2011 at 8:45 AM, Wolfgang Meiners wrote: > Am 31.05.11 13:32, schrieb Daniel Kluev: >> On Tue, May 31, 2011 at 8:40 AM, Wolfgang Meiners >> wrote: >>> metadata = MetaData('sqlite://') >>> a_table = Table('tf_lehrer', metadata, >>>    Column('id', Integer, primary_key=True), >>>  

Re: scope of function parameters (take two)

2011-05-31 Thread Chris Kaynor
On Tue, May 31, 2011 at 9:16 AM, Ian Kelly wrote: > On Tue, May 31, 2011 at 1:38 AM, Daniel Kluev wrote: > > @decorator.decorator > > def copy_args(f, *args, **kw): > >nargs = [] > >for arg in args: > >nargs.append(copy.deepcopy(arg)) > >nkw = {} > >for k,v in kw.iteritem

Re: sqlalchemy and Unicode strings: errormessage

2011-05-31 Thread Wolfgang Meiners
I just found a second method on http://docs.python.org/howto/unicode you can use tho module codecs and then simply write import codecs f = codecs.open('unicode.rst', encoding='utf-8') for line in f: print repr(line) Wolfgang -- http://mail.python.org/mailman/listinfo/python-list

Re: scope of function parameters (take two)

2011-05-31 Thread Ian Kelly
On Tue, May 31, 2011 at 1:38 AM, Daniel Kluev wrote: > @decorator.decorator > def copy_args(f, *args, **kw): >    nargs = [] >    for arg in args: >        nargs.append(copy.deepcopy(arg)) >    nkw = {} >    for k,v in kw.iteritems(): >        nkw[k] = copy.deepcopy(v) >    return f(*nargs, **nkw)

Re: scope of function parameters (take two)

2011-05-31 Thread Terry Reedy
On 5/31/2011 3:17 AM, Henry Olders wrote: Clearly, making a copy within the function eliminates the possibility of the side effects caused by passing in mutable objects. Mutable objects and mutating methods and functions are a *feature* of Python. If you do not like them, do not use them. >

Re: sqlalchemy and Unicode strings: errormessage

2011-05-31 Thread Wolfgang Meiners
Am 31.05.11 11:55, schrieb Chris Withers: > Hi Wolfgang, > > On 30/05/2011 22:40, Wolfgang Meiners wrote: >> I am trying to build an application using sqlalchemy. > > You're likely to get much better help here: > > http://www.sqlalchemy.org/support.html#mailinglist > > When you post there, make

Re: scope of function parameters (take two)

2011-05-31 Thread Terry Reedy
On 5/31/2011 2:37 AM, Henry Olders wrote: what I want is a function that is free of side effects back through the parameters passed in the function call. You can get that by refraining from mutating parameter objects. Simple as that. Just do not expect Python to enforce that discipline on ever

Re: sqlalchemy and Unicode strings: errormessage

2011-05-31 Thread Wolfgang Meiners
Am 31.05.11 13:32, schrieb Daniel Kluev: > On Tue, May 31, 2011 at 8:40 AM, Wolfgang Meiners > wrote: >> metadata = MetaData('sqlite://') >> a_table = Table('tf_lehrer', metadata, >>Column('id', Integer, primary_key=True), >>Column('Kuerzel', Text), >>Column('Name', Text)) > > Use Uni

Re: The worth of comments

2011-05-31 Thread Neil Cerutti
On 2011-05-28, Roy Smith wrote: > One reasonable definition of a bug is something the code > actually does which differs from the documented interface. > Unless you know what the code is supposed to do, how can you > possibly look at it and say whether it has a bug or not? For > example, take thi

Re: BadValueError: Property title is required

2011-05-31 Thread bruno.desthuilli...@gmail.com
On May 31, 10:32 am, Chris Rebert wrote: > On Tue, May 31, 2011 at 1:21 AM, michal.bulla wrote: > > Hello, > > > I'm trying to create simple method to create category. I set the model > > category: > > > class Category(db.Model): > >  title = db.StringProperty(required=True) > >  clashes_count =

Re: Load averages and Python threads on different Linux cloud provider setup

2011-05-31 Thread Chris Angelico
On Tue, May 31, 2011 at 9:25 PM, Mohanaraj Gopala Krishnan wrote: > Any suggestion on why the load would be a lot higher or how I could > debug this further is greatly appreciated. > First off, an easy question: Is system load low and comparable on both systems when this script is _not_ running?

Re: Something is rotten in Denmark...

2011-05-31 Thread Jussi Piitulainen
Thomas Rachel writes: > Am 31.05.2011 12:08 schrieb Jussi Piitulainen: > > > The same sharing-an-i thing happens here: > > > fs = [] > for i in range(4): > > ...fs.append(lambda n : i + n) > > ... > fs[0](0) > > 3 > > > > And the different private-j thing happens here: > > > >>>

Re: How to catch a line with Popen

2011-05-31 Thread TheSaint
Chris Torek wrote: > Since it is a generator that only requests another line when called, > it should be fine Is it, then, that until the new itaration, the callee is on pause? -- goto /dev/null -- http://mail.python.org/mailman/listinfo/python-list

Re: sqlalchemy and Unicode strings: errormessage

2011-05-31 Thread Daniel Kluev
On Tue, May 31, 2011 at 8:40 AM, Wolfgang Meiners wrote: > metadata = MetaData('sqlite://') > a_table = Table('tf_lehrer', metadata, >    Column('id', Integer, primary_key=True), >    Column('Kuerzel', Text), >    Column('Name', Text)) Use UnicodeText instead of Text. > A_record = A_class('BUM',

Load averages and Python threads on different Linux cloud provider setup

2011-05-31 Thread Mohanaraj Gopala Krishnan
Hello, Apologies if this post is off topic. We have a Python application that polls directories using threads and inotify watchers. We have always run this application in a cloud server provided by Voxel (http://www.voxel.net). We are currently testing a different cloud server provider StormOnDem

Re: Something is rotten in Denmark...

2011-05-31 Thread Thomas Rachel
Am 31.05.2011 12:08 schrieb Jussi Piitulainen: The same sharing-an-i thing happens here: fs = [] for i in range(4): ...fs.append(lambda n : i + n) ... fs[0](0) 3 And the different private-j thing happens here: gs = [] for i in range(4): ...gs.append((lambda j : lambda n : j + n)

Re: Something is rotten in Denmark...

2011-05-31 Thread Jussi Piitulainen
harrismh777 writes: > >>> fs=[] > >>> fs = [(lambda n: i + n) for i in range(10)] > >>> [fs[i](1) for i in range(10)] > [10, 10, 10, 10, 10, 10, 10, 10, 10, 10] <=== not good > > ( that was a big surprise! . . . ) > ( let's try it another way . . . ) The ten functions share the

Re: sqlalchemy and Unicode strings: errormessage

2011-05-31 Thread Chris Withers
Hi Wolfgang, On 30/05/2011 22:40, Wolfgang Meiners wrote: I am trying to build an application using sqlalchemy. You're likely to get much better help here: http://www.sqlalchemy.org/support.html#mailinglist When you post there, make sure you include: - what python version you're using - wha

Re: scope of function parameters (take two)

2011-05-31 Thread Wolfgang Rohdewald
On Dienstag 31 Mai 2011, Henry Olders wrote: > You're partially right - what I want is a function that is > free of side effects back through the parameters passed in > the function call. I don't know any object oriented language where it is not possible to change objects passed in as parameters.

Re: BadValueError: Property title is required

2011-05-31 Thread Chris Rebert
On Tue, May 31, 2011 at 1:21 AM, michal.bulla wrote: > Hello, > > I'm trying to create simple method to create category. I set the model > category: > > class Category(db.Model): >  title = db.StringProperty(required=True) >  clashes_count = db.IntegerProperty(default=0) > The problem is that I'm

BadValueError: Property title is required

2011-05-31 Thread michal.bulla
Hello, I'm trying to create simple method to create category. I set the model category: class Category(db.Model): title = db.StringProperty(required=True) clashes_count = db.IntegerProperty(default=0) And the class New Category as well : class NewCategoryPage(webapp.RequestHandler): def g

Re: scope of function parameters (take two)

2011-05-31 Thread Chris Angelico
On Tue, May 31, 2011 at 5:17 PM, Henry Olders wrote: > Clearly, making a copy within the function eliminates the possibility of the > side effects caused by passing in mutable objects. Would having the > compiler/interpreter do this automatically make python so much different? Yes, it would make

Re: scope of function parameters (take two)

2011-05-31 Thread Daniel Kluev
On Tue, May 31, 2011 at 6:17 PM, Henry Olders wrote: > Clearly, making a copy within the function eliminates the possibility of the > side effects caused by passing in mutable objects. Would having the > compiler/interpreter do this automatically make python so much different? As I've pointed, yo

Re: Something is rotten in Denmark...

2011-05-31 Thread Ian Kelly
On Tue, May 31, 2011 at 12:48 AM, harrismh777 wrote: >     What is going on with the binding in the first construct... this seems > to reduce the usefulness of lambda to a considerable extent? I don't see why; as you've shown there are a couple of simple ways to avoid this problem. The trick is

Re: scope of function parameters (take two)

2011-05-31 Thread Henry Olders
On 2011-05-31, at 24:35 , Dan Stromberg wrote: > > On Mon, May 30, 2011 at 5:28 PM, Henry Olders wrote: > > Be careful not to conflate global scoping or global lifetime, with mutability > or pure, side-effect-free functions (callables). It sounds like what you > want is immutability and/or

Re: Something is rotten in Denmark...

2011-05-31 Thread Chris Rebert
On Mon, May 30, 2011 at 11:48 PM, harrismh777 wrote: fs=[] fs = [(lambda n: i + n) for i in range(10)] [fs[i](1) for i in range(10)] > > [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]         <=== not good > >    ( that was a big surprise! . . . ) >     lambda?  closure?  scope?   bug? >

Re: scope of function parameters (take two)

2011-05-31 Thread Henry Olders
On 2011-05-30, at 20:52 , Benjamin Kaplan wrote: > On Mon, May 30, 2011 at 5:28 PM, Henry Olders wrote: >> >> On 2011-05-29, at 4:30 , Henry Olders wrote: >> > > Python doesn't have true globals. When we say "global" what we mean is > "module or built-in". Also, consider this code > > from ma