Re: Generating valid identifiers

Discussion in 'Python' started by Arnaud Delobelle, Jul 26, 2012.

  1. On 26 July 2012 13:26, Laszlo Nagy <> 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
    Arnaud Delobelle, Jul 26, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    1
    Views:
    351
    Roedy Green
    Apr 22, 2008
  2. Laszlo Nagy

    Generating valid identifiers

    Laszlo Nagy, Jul 26, 2012, in forum: Python
    Replies:
    8
    Views:
    275
    Laszlo Nagy
    Jul 27, 2012
  3. Terry Reedy

    Re: Generating valid identifiers

    Terry Reedy, Jul 26, 2012, in forum: Python
    Replies:
    0
    Views:
    191
    Terry Reedy
    Jul 26, 2012
  4. Peter Otten

    Re: Generating valid identifiers

    Peter Otten, Jul 26, 2012, in forum: Python
    Replies:
    0
    Views:
    145
    Peter Otten
    Jul 26, 2012
  5. Emile van Sebille

    Re: Generating valid identifiers

    Emile van Sebille, Jul 26, 2012, in forum: Python
    Replies:
    0
    Views:
    170
    Emile van Sebille
    Jul 26, 2012
Loading...

Share This Page