a regex question

2019-10-25 Thread Maggie Q Roth
Hello

There are two primary types of lines in the log:

60.191.38.xx/
42.120.161.xx   /archives/1005

I know how to write regex to match each line, but don't get the good result
with one regex to match both lines.

Can you help?

Thanks,
Maggie
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: a regex question

2019-10-25 Thread Brian Oney via Python-list



On October 25, 2019 12:22:44 PM GMT+02:00, Maggie Q Roth  
wrote:
>Hello
>
>There are two primary types of lines in the log:
>
>60.191.38.xx/
>42.120.161.xx   /archives/1005
>
>I know how to write regex to match each line, but don't get the good
>result
>with one regex to match both lines.

What is a good result?

The is an re.MULTILINE flag. Did you try that? What does that do?

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: a regex question

2019-10-25 Thread Antoon Pardon
On 25/10/19 12:22, Maggie Q Roth wrote:
> Hello
>
> There are two primary types of lines in the log:
>
> 60.191.38.xx/
> 42.120.161.xx   /archives/1005
>
> I know how to write regex to match each line, but don't get the good result
> with one regex to match both lines.

Could you provide the regexes that you have for each line?

-- 
Antoon.
-- 
https://mail.python.org/mailman/listinfo/python-list


Fwd: python 8.0

2019-10-25 Thread Ebuka Amadi
-- Forwarded message -
From: Ebuka Amadi 
Date: Thu, 24 Oct 2019 at 22:31
Subject: python 8.0
To: 


Dear team i downloaded python 8.0 am finding it hard to install it i hope
to get a step by stem instructions to do this on my PC its a core i5
-- 
https://mail.python.org/mailman/listinfo/python-list


Multi-language programing playground

2019-10-25 Thread Vishal Rana via Python-list
Folks,

I wanted to share a multi-language programming playground that I created
recently. I hope you will find it useful.

https://code.labstack.com/program

Thanks
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python 8.0

2019-10-25 Thread Igor Korot
Hi,

On Fri, Oct 25, 2019 at 9:19 AM Ebuka Amadi  wrote:
>
> -- Forwarded message -
> From: Ebuka Amadi 
> Date: Thu, 24 Oct 2019 at 22:31
> Subject: python 8.0
> To: 
>
>
> Dear team i downloaded python 8.0 am finding it hard to install it i hope
> to get a step by stem instructions to do this on my PC its a core i5

Where did you download it from?
How are you trying it to install?
What error message do you get?

What OS do you run on you PC?

Thank you.

> --
> https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Fwd: python 8.0

2019-10-25 Thread Gene Heskett
On Friday 25 October 2019 02:35:06 Ebuka Amadi wrote:

> -- Forwarded message -
> From: Ebuka Amadi 
> Date: Thu, 24 Oct 2019 at 22:31
> Subject: python 8.0
> To: 
>
>
> Dear team i downloaded python 8.0 am finding it hard to install it i
> hope to get a step by stem instructions to do this on my PC its a core
> i5

I am just a lurker here, but python is only up to version 3.8. If that is 
python 8, I would wipe it off the system and go get the real thing from 
a genuine python site.  If you paid for it (its free), take whatever 
actions you have to, to get your money back.

Cheers, Gene Heskett
-- 
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
If we desire respect for the law, we must first make the law respectable.
 - Louis D. Brandeis
Genes Web page 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Fwd: python 8.0

2019-10-25 Thread Batuhan Taskaya
> but python is only up to version 3.8
He probably meant 3.8.0 but there was a python 8 (as an april 1 joke by
victor stinner)
https://mail.python.org/archives/list/[email protected]/thread/4P46WYJTZUKJ2EABQSASI7CD643YY5QL/

On Fri, Oct 25, 2019, 6:32 PM Gene Heskett  wrote:

> On Friday 25 October 2019 02:35:06 Ebuka Amadi wrote:
>
> > -- Forwarded message -
> > From: Ebuka Amadi 
> > Date: Thu, 24 Oct 2019 at 22:31
> > Subject: python 8.0
> > To: 
> >
> >
> > Dear team i downloaded python 8.0 am finding it hard to install it i
> > hope to get a step by stem instructions to do this on my PC its a core
> > i5
>
> I am just a lurker here, but python is only up to version 3.8. If that is
> python 8, I would wipe it off the system and go get the real thing from
> a genuine python site.  If you paid for it (its free), take whatever
> actions you have to, to get your money back.
>
> Cheers, Gene Heskett
> --
> "There are four boxes to be used in defense of liberty:
>  soap, ballot, jury, and ammo. Please use in that order."
> -Ed Howdershelt (Author)
> If we desire respect for the law, we must first make the law respectable.
>  - Louis D. Brandeis
> Genes Web page 
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to decode UTF strings?

2019-10-25 Thread Arne Vajhøj

On 10/25/2019 4:52 PM, DFS wrote:

=?iso-8859-9?b?T/B1eg==?= 
=?utf-8?Q?=EB=AF=B8?= 
=?GBK?B?0Pu66A==?= 
=?UTF-8?B?zp3Or866zr/PgiDOks6tz4HOs86/z4I=?= 


How does something like:

from email.header import decode_header

def test(s):
print(s)
s2 = decode_header(s)
print(s2[0][0])
print(s2[1][0].strip())

test('=?iso-8859-9?b?T/B1eg==?= ')
test('=?utf-8?Q?=EB=AF=B8?= ')
test('=?GBK?B?0Pu66A==?= ')
test('=?UTF-8?B?zp3Or866zr/PgiDOks6tz4HOs86/z4I=?= 
')


work?

Arne

--
https://mail.python.org/mailman/listinfo/python-list


Re: How to decode UTF strings?

2019-10-25 Thread MRAB

On 2019-10-26 03:10, Arne Vajhøj wrote:

On 10/25/2019 4:52 PM, DFS wrote:

=?iso-8859-9?b?T/B1eg==?= 
=?utf-8?Q?=EB=AF=B8?= 
=?GBK?B?0Pu66A==?= 
=?UTF-8?B?zp3Or866zr/PgiDOks6tz4HOs86/z4I=?= 


How does something like:

from email.header import decode_header

def test(s):
  print(s)
  s2 = decode_header(s)
  print(s2[0][0])
  print(s2[1][0].strip())

test('=?iso-8859-9?b?T/B1eg==?= ')
test('=?utf-8?Q?=EB=AF=B8?= ')
test('=?GBK?B?0Pu66A==?= ')
test('=?UTF-8?B?zp3Or866zr/PgiDOks6tz4HOs86/z4I=?=
')

work?

When you decode the header you get a number of parts, each with its own 
encoding.


Here's a simple example, based in your code:

from email.header import decode_header

def test(header, default_encoding='utf-8'):
 parts = []

 for data, encoding in decode_header(header):
 if isinstance(data, str):
parts.append(data)
 else:
parts.append(data.decode(encoding or default_encoding))

 print(''.join(parts))

test('=?iso-8859-9?b?T/B1eg==?= ')
test('=?utf-8?Q?=EB=AF=B8?= ')
test('=?GBK?B?0Pu66A==?= ')
test('=?UTF-8?B?zp3Or866zr/PgiDOks6tz4HOs86/z4I=?= 
')

--
https://mail.python.org/mailman/listinfo/python-list


Re: keying by identity in dict and set

2019-10-25 Thread dieter
Steve White  writes:
> Regarding my question
>  "Is there some fatal reason that this approach must never be
> used, besides the lack of documentary support for it?"
> If finally dawned on me that there is a use-case for containers that
> would preclude using object identity for keys.  That is, if the object
> is to be serialized, or otherwise stored past the run-time of the
> program.  Of course, all the identities (all the id() values) will be
> meaningless once the current run ends.

One motivation to base dict key management on equality
(rather than identity) are literals:

Consider a dict "d" with at some place
`d["my example key"] = 1` and at a different place
(maybe another function, another module) you access
`d["my example key"]`. You would expect to get `1`
as result as for your eyes the two literals are equal.
Would the key management be based on identity, then
you could get either the expected `1` or a `KeyError`.
The reason: Python does not manage (most) literals globally;
this means, if you use the same literal in different places
you may (or may not) have non-identical objects.

Basing on equality, you are also more flexibal than
with identity, because can can change the equality
rules for a class while you cannot change the identity rules.
Thus, if you need identity based key management,
define your `__eq__` accordingly.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: a regex question

2019-10-25 Thread dieter
Maggie Q Roth  writes:
> There are two primary types of lines in the log:
>
> 60.191.38.xx/
> 42.120.161.xx   /archives/1005
>
> I know how to write regex to match each line, but don't get the good result
> with one regex to match both lines.
>
> Can you help?

When I look at these lines, I see 2 fields separated by whitespace
(note that two example lines are very very few to guess the
proper pattern). I would not use a regular expression
in this case, but the `split` string method.

A regular expression for this pattern could be `(\S+)\s+(.*)` which reads
a non-empty sequences of none whitespace (assigned to group 1),
whitespace, any sequence (assigned to group 2)
(note that the regular expression above is given on the
regex level. The string in your Python code may look slightly different).

-- 
https://mail.python.org/mailman/listinfo/python-list