Re: PyWart: Language missing maximum constant of numeric types!

2012-02-25 Thread Wolfgang Meiners
Am 24.02.12 14:37, schrieb Rick Johnson: > I get sick and tired of doing this!!! > > if maxlength == UNLIMITED: > allow_passage() > elif len(string) > maxlength: > deny_passage() > > What Python needs is some constant that can be compared to ANY numeric > type and that constant will ALWAY

Re: PyWart: Language missing maximum constant of numeric types!

2012-02-26 Thread Wolfgang Meiners
Am 25.02.12 18:54, schrieb MRAB: >> If there is no limit for len(string), why not simply use >> >> # get_limit() returns None if there is no limit >> maxlength = get_limit() >> if maxlength and (len(string)<= maxlength): >> allow_passage() >> else: >> deny_passage() >> > That should be: >

Re: PyWart: Language missing maximum constant of numeric types!

2012-02-26 Thread Wolfgang Meiners
Am 25.02.12 21:35, schrieb Rick Johnson: > On Feb 25, 11:54 am, MRAB wrote: >> [...] >> That should be: >> if maxlength is not None and len(string) <= maxlength: > > Using "imaginary" infinity values defiles the intuitive nature of your > code. What is more intuitive? > > def confine_length(stri

Re: PyWart: Language missing maximum constant of numeric types!

2012-02-26 Thread Wolfgang Meiners
Am 26.02.12 13:52, schrieb Chris Angelico: > On Sun, Feb 26, 2012 at 10:56 PM, Wolfgang Meiners > wrote: >> That means: >> if maxlength and (len(string) <= maxlength): >> >> is equivalent to >> if (maxlength is not None) and (len(string) <= maxlength

Re: PyWart: Language missing maximum constant of numeric types!

2012-02-26 Thread Wolfgang Meiners
Am 26.02.12 14:16, schrieb Wolfgang Meiners: > > I just had a closer look at it. It seems to be more complicated than i > thougth: You will have to write Obviously not close enough, as i just learned. > > def confine_length(string, maxlength=None): > if maxlength:

sqlalchemy: delete() on m:n-relationship

2012-05-19 Thread Wolfgang Meiners
Hi all, i dont understand, how sqlalchemy deletes from m:n relationships. Maybe, someone can explain to me, how to delete in the following program: (pyhton3, sqlalchemy 0.7.0) = > #!/usr/bin/env python3 > # -*- coding: utf-8 -*

tkinter problem with treeview

2011-06-27 Thread Wolfgang Meiners
Hi all, I have written some helper functions for the tkinter.ttk.treeview widget (using python3, version 3.2). This functions dont work as i expect: #! /usr/bin/env pyhon3 # -*- encoding: utf-8 -*- from tkinter import * from tkinter.ttk import * # now tkinter widgets get replaced by

treeviewcontrol in tkinter.ttk

2011-06-30 Thread Wolfgang Meiners
Hi all, when i type the following code under python3, version 3.2 using osx 10.6.8: ## #! /usr/bin/env python3 # -*- coding: utf-8 -*- from tkinter import * from tkinter.ttk import * from tkinter.font import Font root = Tk() tv = Treevi

Re: Validating Entry in tkinter

2011-07-25 Thread Wolfgang Meiners
Am 25.07.11 02:11, schrieb Saul Spatz: > In tcl/tk an Entry widget can be set to validate its contents with the > validate option. You have to give it a validatecommand (vcmd), which is a > tcl script that runs when some action triggers validation. Usually, the > script would use "percent subs

sqlalchemy and Unicode strings: errormessage

2011-05-30 Thread Wolfgang Meiners
Hi, I am trying to build an application using sqlalchemy. in principle i have the structure #== from sqlalchemy import * from sqlalchemy.orm import * metadata = MetaData('sqlite://') a_table = Table('tf_lehrer', metadata, Column('id', Integer, pr

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), >>C

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#mail

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

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: Thanks for all responses

2011-06-01 Thread Wolfgang Meiners
Am 31.05.11 23:56, schrieb 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 &g

recommended way to insert data into a one to many relationship using python

2010-05-01 Thread Wolfgang Meiners
Hi, one to many relationships are fairly common, i think. So there should be a recommended way to insert data into such a relation using python. Given the following programm, what is the recommended way to insert the list of NewEmployees to the database?

Re: recommended way to insert data into a one to many relationship using python

2010-05-02 Thread Wolfgang Meiners
Peter Otten schrieb: > Peter Otten wrote: > > If you create indices for floors (and rooms) > > cur.execute("""create unique index room_index on rooms (fid, number);""") > cur.execute("""create unique index floor_index on floors (floor);""") > > the addition of missing rows can be simplified to >

Re: recommended way to insert data into a one to many relationship using python

2010-05-03 Thread Wolfgang Meiners
Bryan schrieb: > Wolfgang Meiners wrote: >> one to many relationships are fairly common, i think. So there should be >> a recommended way to insert data into such a relation using python. >> >> Given the following programm, what is the recommended way to insert the >

Re: recommended way to insert data into a one to many relationship using python

2010-05-03 Thread Wolfgang Meiners
Wolfgang Meiners schrieb: [... example of a simple sql-database and relating questions ...] so after reading the hints of Peter Otten and Bryan i played around a bit and got the following solution. Of course it would be much simpler following Bryans idea of natural keys but i think, i will go

Email für Dich

2010-07-19 Thread Wolfgang Meiners
Liebe Kirsten, ich liebe dich und freue mich, dass du bald auch Ferien hast. Wolfgang -- http://mail.python.org/mailman/listinfo/python-list

User interaction with Python

2010-10-19 Thread Wolfgang Meiners
Hello all, I would like to have a function to edit values in a database. So I am reading values from the database and do something like newString = edit(oldString) and then oldString is written to the screen and can be edited in a vi-like manner for example. The function edit should return the

Re: User interaction with Python

2010-10-19 Thread Wolfgang Meiners
Am 19.10.10 11:31, schrieb Peter Otten: > Wolfgang Meiners wrote: >> >> newString = edit(oldString) >> > > When readline is available: > > http://mail.python.org/pipermail/python-list/2009-June/1209309.html Thank you for this hint. Wolfgang -- http://mail.p