Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #26090 > unrolled thread

Re: Generating valid identifiers

Started byArnaud Delobelle <arnodel@gmail.com>
First post2012-07-26 15:21 +0100
Last post2012-07-26 15:21 +0100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Generating valid identifiers Arnaud Delobelle <arnodel@gmail.com> - 2012-07-26 15:21 +0100

#26090 — Re: Generating valid identifiers

FromArnaud Delobelle <arnodel@gmail.com>
Date2012-07-26 15:21 +0100
SubjectRe: Generating valid identifiers
Message-ID<mailman.2609.1343312496.4697.python-list@python.org>
On 26 July 2012 13:26, Laszlo Nagy <gandalf@shopzeus.com> wrote:
[...]
> I do not want this program to generate very long identifiers. It would
> increase SQL parsing time, and don't look good. Let's just say that the
> limit should be 32 characters. But I also want to recognize the identifiers
> when I look at their modified/truncated names.
[...]
> print repr(Connection.makename("group1_group2_group3_some_field_name"))
> 'group1_group2_group3_some_fiel$AyQVQUXoyf'

>>> len('group1_group2_group3_some_fiel$AyQVQUXoyf')
41

You've exceeded 32 characters!  Perhaps you could change:

            return basename[:30]+"$"+tail

to:

            return basename[:21]+"$"+tail

But then you'd get something like this for your long identifier:

    group1_group2_group3_$AyQVQUXoyf

which seems to miss out on a crucial bit: namely the field name.

Also it's hard to imagine a way to keep things readable when we don't
know what the original identifiers look like :)

-- 
Arnaud

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web