Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #64530 > unrolled thread
| Started by | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| First post | 2014-01-22 19:23 +0000 |
| Last post | 2014-01-23 13:18 +0000 |
| Articles | 6 — 3 participants |
Back to article view | Back to comp.lang.python
awesome slugify and unicode Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-01-22 19:23 +0000
Re: awesome slugify and unicode wxjmfauth@gmail.com - 2014-01-22 23:18 -0800
Re: awesome slugify and unicode Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-01-23 09:14 +0000
Re: awesome slugify and unicode wxjmfauth@gmail.com - 2014-01-23 02:41 -0800
Re: awesome slugify and unicode Chris Angelico <rosuav@gmail.com> - 2014-01-23 21:49 +1100
Re: awesome slugify and unicode Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-01-23 13:18 +0000
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2014-01-22 19:23 +0000 |
| Subject | awesome slugify and unicode |
| Message-ID | <mailman.5850.1390418639.18130.python-list@python.org> |
I thought this blog might interest some of you http://pydanny.com/awesome-slugify-human-readable-url-slugs-from-any-string.html -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence
[toc] | [next] | [standalone]
| From | wxjmfauth@gmail.com |
|---|---|
| Date | 2014-01-22 23:18 -0800 |
| Message-ID | <59461353-d450-471f-ae28-84f686543a57@googlegroups.com> |
| In reply to | #64530 |
Le mercredi 22 janvier 2014 20:23:55 UTC+1, Mark Lawrence a écrit : > I thought this blog might interest some of you > > http://pydanny.com/awesome-slugify-human-readable-url-slugs-from-any-string.html > > > > -- > > My fellow Pythonistas, ask not what our language can do for you, ask > > what you can do for our language. > > > > This is not "unicode", only string manipulations. The same work could be done with, let say, cp1252. The difference lies in the repertoires of characters to be handled. A better way is to work with normalization() and/or with methods like .translate() with dedicated tables; the hard task being the creation of these tables. Shortly, very naive. jmf
[toc] | [prev] | [next] | [standalone]
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2014-01-23 09:14 +0000 |
| Message-ID | <mailman.5878.1390468510.18130.python-list@python.org> |
| In reply to | #64575 |
On 23/01/2014 07:18, wxjmfauth@gmail.com wrote:
> Le mercredi 22 janvier 2014 20:23:55 UTC+1, Mark Lawrence a écrit :
>> I thought this blog might interest some of you
>>
>> http://pydanny.com/awesome-slugify-human-readable-url-slugs-from-any-string.html
>>
>> My fellow Pythonistas, ask not what our language can do for you, ask
>>
>> what you can do for our language.
>>
>
> This is not "unicode", only string manipulations.
> The same work could be done with, let say, cp1252.
> The difference lies in the repertoires of characters
> to be handled.
>
> A better way is to work with normalization() and/or
> with methods like .translate() with dedicated
> tables; the hard task being the creation of these tables.
>
> Shortly, very naive.
>
> jmf
>
You'll have to excuse my ignorance of this stuff. How do I express the
following in cp1252?
def test_musical_notes():
txt = "Is ♬ ♫ ♪ ♩ a melody or just noise?"
assert slugify(txt) == "Is-a-melody-or-just-noise"
assert slugify_unicode(txt) == "Is-a-melody-or-just-noise"
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
[toc] | [prev] | [next] | [standalone]
| From | wxjmfauth@gmail.com |
|---|---|
| Date | 2014-01-23 02:41 -0800 |
| Message-ID | <1e0aeb33-23b6-4af1-8447-38dc4473d09f@googlegroups.com> |
| In reply to | #64586 |
Le jeudi 23 janvier 2014 10:14:48 UTC+1, Mark Lawrence a écrit :
> On 23/01/2014 07:18, wxjmfauth@gmail.com wrote:
>
> > Le mercredi 22 janvier 2014 20:23:55 UTC+1, Mark Lawrence a écrit :
>
> >> I thought this blog might interest some of you
>
> >>
>
> >> http://pydanny.com/awesome-slugify-human-readable-url-slugs-from-any-string.html
>
> >>
>
> >> My fellow Pythonistas, ask not what our language can do for you, ask
>
> >>
>
> >> what you can do for our language.
>
> >>
>
> >
>
> > This is not "unicode", only string manipulations.
>
> > The same work could be done with, let say, cp1252.
>
> > The difference lies in the repertoires of characters
>
> > to be handled.
>
> >
>
> > A better way is to work with normalization() and/or
>
> > with methods like .translate() with dedicated
>
> > tables; the hard task being the creation of these tables.
>
> >
>
> > Shortly, very naive.
>
> >
>
> > jmf
>
> >
>
>
>
> You'll have to excuse my ignorance of this stuff. How do I express the
>
> following in cp1252?
>
>
>
> def test_musical_notes():
>
> txt = "Is ♬ ♫ ♪ ♩ a melody or just noise?"
>
> assert slugify(txt) == "Is-a-melody-or-just-noise"
>
> assert slugify_unicode(txt) == "Is-a-melody-or-just-noise"
>
>
>
> --
>
> My fellow Pythonistas, ask not what our language can do for you, ask
>
> what you can do for our language.
>
>
I wrote: The same work could be done with, let say, cp1252.
Understand: The same work (string manipulation) ...
Would something like this not be more informative?
>>> "Is ♬ ♫ ♪ ♩ a melody or just noise?".encode('ascii', 'replace').decode('ascii')
'Is ? ? ? ? a melody or just noise?'
>>>
>>>
cp1252 analogy.
>>> 'abc€€€'.encode('cp1252').decode('ascii', 'replace').encode('ascii', 'replace').decode('ascii')
'abc???'
>>>
Again, not a "unicode" question, more "how to handle strings in a judicious way?"
jmf
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2014-01-23 21:49 +1100 |
| Message-ID | <mailman.5882.1390474152.18130.python-list@python.org> |
| In reply to | #64593 |
On Thu, Jan 23, 2014 at 9:41 PM, <wxjmfauth@gmail.com> wrote:
>>>> "Is ♬ ♫ ♪ ♩ a melody or just noise?".encode('ascii', 'replace').decode('ascii')
> 'Is ? ? ? ? a melody or just noise?'
>>>>
>>>>
>
> cp1252 analogy.
>
>>>> 'abc€€€'.encode('cp1252').decode('ascii', 'replace').encode('ascii', 'replace').decode('ascii')
> 'abc???'
>>>>
>
> Again, not a "unicode" question, more "how to handle strings in a judicious way?"
I don't want a cp1252 analogy, I want the exact same thing implemented
in cp1252. You said the same work could be done there. That work
includes dealing with musical notes. How are you going to do that?
ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2014-01-23 13:18 +0000 |
| Message-ID | <mailman.5886.1390483089.18130.python-list@python.org> |
| In reply to | #64593 |
On 23/01/2014 10:41, wxjmfauth@gmail.com wrote:
> Le jeudi 23 janvier 2014 10:14:48 UTC+1, Mark Lawrence a écrit :
>> On 23/01/2014 07:18, wxjmfauth@gmail.com wrote:
>>
>>> Le mercredi 22 janvier 2014 20:23:55 UTC+1, Mark Lawrence a écrit :
>>
>>>> I thought this blog might interest some of you
>>
>>>>
>>
>>>> http://pydanny.com/awesome-slugify-human-readable-url-slugs-from-any-string.html
>>
>>>>
>>
>>>> My fellow Pythonistas, ask not what our language can do for you, ask
>>
>>>>
>>
>>>> what you can do for our language.
>>
>>>>
>>
>>>
>>
>>> This is not "unicode", only string manipulations.
>>
>>> The same work could be done with, let say, cp1252.
>>
>>> The difference lies in the repertoires of characters
>>
>>> to be handled.
>>
>>>
>>
>>> A better way is to work with normalization() and/or
>>
>>> with methods like .translate() with dedicated
>>
>>> tables; the hard task being the creation of these tables.
>>
>>>
>>
>>> Shortly, very naive.
>>
>>>
>>
>>> jmf
>>
>>>
>>
>>
>>
>> You'll have to excuse my ignorance of this stuff. How do I express the
>>
>> following in cp1252?
>>
>>
>>
>> def test_musical_notes():
>>
>> txt = "Is ♬ ♫ ♪ ♩ a melody or just noise?"
>>
>> assert slugify(txt) == "Is-a-melody-or-just-noise"
>>
>> assert slugify_unicode(txt) == "Is-a-melody-or-just-noise"
>>
>>
>>
>> --
>>
>> My fellow Pythonistas, ask not what our language can do for you, ask
>>
>> what you can do for our language.
>>
>>
>
> I wrote: The same work could be done with, let say, cp1252.
> Understand: The same work (string manipulation) ...
> Would something like this not be more informative?
>
>>>> "Is ♬ ♫ ♪ ♩ a melody or just noise?".encode('ascii', 'replace').decode('ascii')
> 'Is ? ? ? ? a melody or just noise?'
>>>>
>>>>
>
> cp1252 analogy.
>
>>>> 'abc€€€'.encode('cp1252').decode('ascii', 'replace').encode('ascii', 'replace').decode('ascii')
> 'abc???'
>>>>
>
> Again, not a "unicode" question, more "how to handle strings in a judicious way?"
>
> jmf
>
Now I'm really confused. I thought that the musical notes I've shown
above are represented as unicode characters. So I'd like to see how you
jmf would represent them in cp1252. Instead you give me an example
showing a simple string manipulation which simply strips the characters
that I want to see, then an even simpler example, clearly not what I've
asked for.
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web