On Wednesday, April 25, 2018, Steven D'Aprano wrote:
> On Wed, Apr 25, 2018 at 11:22:24AM -0700, Julia Kim wrote:
> > Hi,
> >
> > There’s an error with the string method count().
> >
> > x = ‘AAA’
> > y = ‘AA’
> > print(x.count(y))
> >
> > The output is 1, instead of 2.
>
> Are you proposing that
On 25 April 2018 at 12:01, Serhiy Storchaka wrote:
> 25.04.18 13:15, Ivan Levkivskyi пише:
>
>> Hm, this is what I wanted to know. I think by rewriting EnumMeta in C we
>> can reduce the creation time of an Enum class
>> (almost) down to the creation time of a normal class, which may be a 4-5x
>>
On Thu, 26 Apr 2018 08:38:43 +0100
Ivan Levkivskyi
wrote:
> On 25 April 2018 at 12:01, Serhiy Storchaka
> wrote:
>
> > 25.04.18 13:15, Ivan Levkivskyi пише:
> >
> >> Hm, this is what I wanted to know. I think by rewriting EnumMeta in C we
> >> can reduce the creation time of an Enum class
> >
>> It could be great. But I afraid this may add too much complexity in C
code. Maybe try to implement a simple and fast Enum for using it in the
stdlib and extend it with a richer interface in the enum module?
> I think we can do something similar to ABCMeta, i.e. the metaclass itself
will stay d
I'm kind of curious why everyone here seems to want to use IntFlags
and other mixins. The docs themselves say that their use should be
minimized, and tbh I agree with them. Backwards compatiblity can be
maintained by allowing the old value and internally converting it to
the enum. Combinability is
or build it yourself...
def str_count(string, sub):
c = 0
for c in range(len(string)-len(sub)):
if string[c:].startswith(sub):
c += 1
return c
(probably some optimizations possible...)
Or in one line with a generator expression:
def str_count(string, sub):
return sum(string[c:]
On 26 April 2018 at 19:37, Jacco van Dorp wrote:
> I'm kind of curious why everyone here seems to want to use IntFlags
> and other mixins. The docs themselves say that their use should be
> minimized, and tbh I agree with them. Backwards compatiblity can be
> maintained by allowing the old value a
I personally would like a feature where instead of doing `from ... import
...` (which imports the specified items into the current namespace), one
could use something along the lines of `import .{ , , ...
}` such that the imported modules/attributes could be accessed as
`.`, etc.
--
Thanks,
Julian
On 26 April 2018 at 14:29, Julian DeMille via Python-ideas
wrote:
> I personally would like a feature where instead of doing `from ... import
> ...` (which imports the specified items into the current namespace), one
> could use something along the lines of `import .{ , , ...
> }` such that the im
Some library authors get pretty pissy about implicit imports at the root
On Thu, Apr 26, 2018, 09:37 Paul Moore wrote:
> On 26 April 2018 at 14:29, Julian DeMille via Python-ideas
> wrote:
> > I personally would like a feature where instead of doing `from ... import
> > ...` (which imports the
On Thu, 26 Apr 2018 at 19:10 Julian DeMille via Python-ideas <
[email protected]> wrote:
> Some library authors get pretty pissy about implicit imports at the root
>
> On Thu, Apr 26, 2018, 09:37 Paul Moore wrote:
>
>> On 26 April 2018 at 14:29, Julian DeMille via Python-ideas
>> wrote:
>>
On 26 April 2018 at 23:37, Paul Moore wrote:
> On 26 April 2018 at 14:29, Julian DeMille via Python-ideas
> wrote:
>> I personally would like a feature where instead of doing `from ... import
>> ...` (which imports the specified items into the current namespace), one
>> could use something along
That's the kind of thing I'm looking for. I've dealt with some library
authors who were highly against importing the root allowing me to access
submodules with hierarchy.
On Thu, Apr 26, 2018 at 9:51 AM Nick Coghlan wrote:
> On 26 April 2018 at 23:37, Paul Moore wrote:
> > On 26 April 2018 at 1
There are two ‘AA’ in ‘AAA’, one starting from 0 and the other starting from 1.
If ‘AA’ starting from 0 is deleted and inserted with ‘BANAN’, ‘AAA’ becomes
‘BANANA ‘.
If ‘AA’ starting from 1 is deleted and inserted with ‘PPLE’, ‘AAA’ becomes
‘APPLE’.
Depending on which one is chosen, ‘AAA’ can
The following works today:
Python 3.6.3 (default, Oct 4 2017, 06:09:15)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import os.path
>>> os
'/Users/pradyunsg/.venvwrap/venvs/pip/bin/../lib/python3.6
26.04.18 16:51, Nick Coghlan пише:
Forcing submodule imports would be the main thing, as at the moment,
you have to choose between repeating the base name multiple times
(once per submodule) or losing the hierarchical namespace.
If the base name is short, there are no problems with repeating it
On Thu, Apr 26, 2018 at 11:53 PM, Julian DeMille via Python-ideas
wrote:
> That's the kind of thing I'm looking for. I've dealt with some library
> authors who were highly against importing the root allowing me to access
> submodules with hierarchy.
With a package, having automatic imports forces
I just ran into a similar problem, how to relatively import without binding
the submodule.
Let's say you have this :
myapp/
urls.py
views/
base.py
When you're in urls.py and you want to relatively access Functions from
base.py, you must use the from syntax.
from .views import bas
If this was for a school assignment, I'd probably go to edit distance and
fuzzy string match next:
https://en.wikipedia.org/wiki/Edit_distance
https://en.wikipedia.org/wiki/String-to-string_correction_problem
- https://pypi.org/search/?q=Levenshtein
- https://pypi.org/project/textdistance/
As a
Chris Angelico wrote:
+0 for an easier way to import multiple submodules at once. It's not
something I've personally had a need for, but it's a sane and logical
thing to do.
Maybe:
import display, event, mixer in pygame
or
in pygame import display, event, mixer
--
Greg
__
27.04.18 02:12, Greg Ewing пише:
Chris Angelico wrote:
+0 for an easier way to import multiple submodules at once. It's not
something I've personally had a need for, but it's a sane and logical
thing to do.
Maybe:
import display, event, mixer in pygame
I read this as
import display
21 matches
Mail list logo