The documentation says[1]
> Return the approximate size of the queue. Because of
> multithreading/multiprocessing semantics, this number is not
> reliable.
Are there any circumstances under which it *is* reliable? Most
germane, if I've added a bunch of items to the Queue, but not yet
launched
On 2022-03-30 16:37, Barry wrote:
> Is logging.getLevelNamesMapping() what you are looking for?
Is this in some version newer than the 3.8 that comes stock on my
machine?
$ python3 -q
>>> import logging
>>> logging.getLevelNamesMapping()
Traceback (most recent call last):
File "",
On 2022-03-04 11:55, Chris Angelico wrote:
> In MS-DOS, it was perfectly possible to have spaces in file names
DOS didn't allow space (0x20) in filenames unless you hacked it by
hex-editing your filesystem (which I may have done a couple times).
However it did allow you to use 0xFF in filenames
On 2022-03-04 02:02, Chris Angelico wrote:
>> I want to make a little survey here.
>>
>> Do you find the for-else construct useful? Have you used it in
>> practice? Do you even know how it works, or that there is such a
>> thing in Python?
>
> Yes, yes, and yes-yes. It's extremely useful.
Just
On 2022-03-03 06:27, Grant Edwards wrote:
> On 2022-03-03, Chris Angelico wrote:
> > Awww, I was going to make a really bad joke about timezones :)
>
> As opposed to all the really good jokes about timezones... ;)
And here I thought you were just Trolling with timezones...
On 2021-10-25 22:40, anders Limpan wrote:
> i would like to create a contact book were you can keep track of
> your friends. With this contact book you will both be able to add
> friends and view which friends that you have added. anyone
> interested in helping me out with this one ?=) --
Python
On 2021-05-26 18:43, Alan Gauld via Python-list wrote:
> On 26/05/2021 14:09, Tim Chase wrote:
>>> If so, doesn't that introduce a pretty big storage overhead for
>>> large strings?
>>
>> Yes. Though such large strings tend to be more rare, largely
>>
On 2021-05-26 08:18, Alan Gauld via Python-list wrote:
> Does that mean that if I give Python a UTF8 string that is mostly
> single byte characters but contains one 4-byte character that
> Python will store the string as all 4-byte characters?
As best I understand it, yes: the cost of each
On 2021-02-24 08:12, Ethan Furman wrote:
> I'm looking for a name for a group of options that, when one is
> specified, all of them must be specified.
[snip]
> - ???: a group of options where, if one is specified, all must be
> specified (mutually inclusive)
[snip]
> Is there a name out there
On 2021-01-16 03:32, Bischoop wrote:
>> The OP didn't specify what should happen in that case, so it would
>> need some clarification.
>
> In that case maybe good solution would be to return three of them?
That's the solution I chose in my initial reply, you get a tuple back
of ([list of longest
On 2021-01-13 18:20, Dan Stromberg wrote:
> I'm kind of partial to:
>
> import collections
> import typing
>
>
> def get_longest(string: str) -> typing.Tuple[int, str]:
> """Get the longest run of a single consecutive character."""
> dict_: typing.DefaultDict[str, int] =
>
On 2021-01-13 21:20, Bischoop wrote:
> I want to to display a number or an alphabet which appears mostly
> consecutive in a given string or numbers or both
> Examples
> s= ' aabskaaabad'
> output: c
> # c appears 4 consecutive times
> 8bbakebaoa
> output: b
> #b appears 2 consecutive times
On 2020-12-20 21:00, danilob wrote:
> b = ((x[0] for x in a))
here you create a generator
> print(list(b))
> [1, 0, 7, 2, 0]
and then you consume all the things it generates here which means
that when you go to do this a second time
> print(list(b))
the generator is already empty/exhausted so
On 2020-12-14 21:21, Schachner, Joseph wrote:
> >>> r = range(10)
> So r is a list containing 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
In Python 3.x, r is *not* a list. It is a custom object/class.
> >>> 2 in r
> True
> As expected.
I'm not sure what your replies are suggesting here. I
On 2020-12-12 15:12, Bischoop wrote:
> I need to check if input number is 1-5. Whatever I try it's not
> working. Here are my aproaches to the problem: https://bpa.st/H62A
>
> What I'm doing wrong and how I should do it?
A range is similar to a list in that it contains just the numbers
listed:
On 2020-12-12 07:39, ast wrote:
> In case a function recursively calls itself many times,
> is there a way to return a data immediately without
> unstacking all functions ?
Not that I'm aware of. If you use recursion (and AFAIK, Python
doesn't support tail-recursion), you pay all the pushes &
On 2020-11-07 10:51, Tim Chase wrote:
> from string import ascii_lowercase
> text = ",".join(ascii_lowercase)
> to_throw_away = 5
[derp]
For obvious reasons, these should be s/\/to_throw_away/g
To throw away the trailing N delimited portions:
> new_string =
On 2020-11-07 13:46, Bischoop wrote:
> text = "This is string, remove text after second comma, to be
> removed."
>
> k= (text.find(",")) #find "," in a string
> m = (text.find(",", k+1)) #Find second "," in a string
> new_string = text[:m]
>
> print(new_string)
How about:
new_string =
On 2020-10-31 15:22, Grant Edwards wrote:
> > A MUA may have to display hundreds of mailboxes, and maybe tens of
> > thousands of mails in a single mailbox.
>
> No. It doesn't. It has to display a tree widget that shows N items
> and holds tens of thousands of items, or a scrolling list widget
On 2020-09-21 09:48, Stavros Macrakis wrote:
>> def fn(iterable):
>> x, = iterable
>> return x
>
> Thanks, Tim! I didn't realize that you could write (x,) on the LHS!
> Very nice, very Pythonic!
It also expands nicely for other cases, so you want the 3-and-only-3
first values with
On 2020-09-20 18:34, Stavros Macrakis wrote:
> Consider a simple function which returns the first element of an
> iterable if it has exactly one element, and throws an exception
> otherwise. It should work even if the iterable doesn't terminate.
> I've written this function in multiple ways, all
Derp, sorry about the noise. I mistook this message for a similar
dialog over on the Vim mailing list.
For Python, you want
re.sub(r"%%(.*?)%%", r"\1", s, flags=re.S)
or put the flag inline
re.sub(r"(?s)%%(.*?)%%", r"\1", s)
-tim
On 2020-09-03 09
On 2020-09-03 16:10, Termoregolato wrote:
> -- original
> This is the %%text that i must modify%%, on a line, %%but also
> on the others%% that are following
>
> I need to change to
>
> -- desidered
> This is the text that i must modify, on a line, but
> also on the others that are following
On 2020-07-22 11:54, Oscar Benjamin wrote:
>> On Wed, Jul 22, 2020 at 11:04 AM Tim Chase wrote:
>>> reading through the language specs and didn't encounter
>>> anything about booleans returned from comparisons-operators,
>>> guaranteeing that they always return T
I know for ints, cpython caches something like -127 to 255 where `is`
works by happenstance based on the implementation but not the spec
(so I don't use `is` for comparison there because it's not
guaranteed by the language spec). On the other hand, I know that None
is a single object that can (and
On 2020-07-03 10:09, Daley Okuwa via Python-list wrote:
> Write an algorithm (choose the language you prefer) that given a
> character string, for instance {‘c’,’a’,’i’,’o’,’p’,’a’}, will
> print out the list of characters appearing at least 2 times. In
> this specific example, it would return
On 2020-06-05 12:15, DL Neil via Python-list wrote:
> Finking/discussion:
>
> - how do you like to balance these three (and any other criteria)?
For most of what I do, I only ever have one such module so I'm not
trying keep multiple short-names in my head concurrently. For me,
it's usually
On 2020-05-23 14:46, Dennis Lee Bieber wrote:
> On Sat, 23 May 2020 11:03:09 -0500, Tim Chase
> >But when a string contains both, it biases towards single quotes:
> >
> > >>> "You said \"No it doesn't\""
> > 'You said "No
On 2020-05-24 01:40, Chris Angelico wrote:
> On Sat, May 23, 2020 at 10:52 PM Abdur-Rahmaan Janhangeer
> wrote:
> >
> > The interpreter prefers single-quotes
> >
> > >>> "single or double"
> > 'single or double'
> >
> >>> 'not all that strongly, it doesn\'t'
> "not all that strongly, it
On 2020-05-19 20:10, Manfred Lotz wrote:
> Hi there,
> I am asking myself if I should preferably use single or double
> quotes for strings?
I'd say your consistency matters more than which one you choose.
According to a recent observation by Raymond H.
"""
Over time, the #python world has
I know that vim lets me do things like
$ ls | vim -
where it will read the data from stdin, but then take over the screen
TUI curses-style, and interact directly with the keyboard input
without being limited to input from stdin.
I've played around with something like
import sys
import
On 2020-04-01 19:27, Peter Wiehe wrote:
> Is there a Python3 module with financial accounts?
You'd have to be more specific. For interacting with online accounts
with financial institutions? For tracking financial data locally?
There's beancount (http://furius.ca/beancount/ and written in
On 2020-02-20 13:30, David Wihl wrote:
> I believe that it would be more idiomatic in Python (and other
> languages like Ruby) to throw an exception when one of these
> partial errors occur. That way there would be the same control flow
> if a major or minor error occurred.
There are a variety
On 2020-01-30 06:44, Souvik Dutta wrote:
> Hey I was thinking how I can save a dictionary in python(obviously)
> so that the script is rerun it automatically loads the dictionary.
This is almost exactly what the "dbm" (nee "anydbm") module does, but
persisting the dictionary out to the disk:
On 2019-12-29 12:52, Greg Ewing wrote:
> On 29/12/19 11:49 am, Chris Angelico wrote:
> > "Define before use" is a broad principle that I try to follow,
> > even when the code itself doesn't mandate this.
>
> I tend to do this too, although it's probably just a habit
> carried over from
On 2019-12-22 23:34, Batuhan Taskaya wrote:
> I encounter with cases like doing a function 6 time with no
> argument, or same arguments over and over or doing some structral
> thing N times and I dont know how elegant I can express that to the
> code. I dont know why but I dont like this
>
> for _
On 2019-12-09 12:27, Musbur wrote:
> def branch1(a, b, z):
> """Inelegant, unwieldy, and pylint complains
> about too many branches"""
> if a > 4 and b == 0:
> result = "first"
> elif len(z) < 2:
> result = "second"
> elif b + a == 10:
> result =
On 2019-12-02 16:49, Michael Torrie wrote:
> On 12/1/19 7:50 PM, Tim Chase wrote:
> > After sparring with it a while, I tweaked the existing job so
> > that it chunked things into dbm-appropriate sizes to limp
> > through; for the subsequent job (where I would have used dbm
&g
> Maybe port to SQLite? I would not choose dbm these days.
After sparring with it a while, I tweaked the existing job so that it
chunked things into dbm-appropriate sizes to limp through; for the
subsequent job (where I would have used dbm again) I went ahead and
switched to sqlite and had no
Working with the dbm module (using it as a cache), I've gotten the
following error at least twice now:
HASH: Out of overflow pages. Increase page size
Traceback (most recent call last):
[snip]
File ".py", line 83, in get_data
db[key] = data
_dbm.error: cannot add item to database
On 2019-11-25 21:25, Pycode wrote:
> On Sun, 24 Nov 2019 10:41:29 +1300, DL Neil wrote:
>> Are such email addresses 'open' and honest?
>
> you are not being helpful or answer the question..
What DL Neil seems to be getting at is that there's been an uptick in
questions
1) where we don't know
On 2019-08-21 11:27, Tobiah wrote:
> In the docs for itertools.cycle() there is
> a bit of equivalent code given:
>
> def cycle(iterable):
> # cycle('ABCD') --> A B C D A B C D A B C D ...
> saved = []
> for element in iterable:
> yield element
>
On 2019-05-22 08:51, Robin Becker wrote:
> In PEP 594 t has been proposed that cgi & cgitb should be removed.
> I suspect I am not the only person in the world that likes using
> cgi and cgitb.
/me waves from the the back row as another cgi/cgitb user...
-tkc
--
On 2019-03-25 21:38, John Doe wrote:
> What is your favorite Python IDE?
Unix.
https://sanctum.geek.nz/arabesque/series/unix-as-ide/
Namely $EDITOR (for some value of ed/vi/vim), a shell (usually
bash, ksh, or /bin/sh), a VCS (usually git, subversion, rcs, or
fossil, though sometimes CVS or
On 2019-03-07 17:19, tony wrote:
> Python 3.5.3 (default, Sep 27 2018, 17:25:39)
> >>> "a\\nb".decode("string-escape")
> Traceback (most recent call last):
> File "", line 1, in
> AttributeError: 'str' object has no attribute 'decode'
Looks like bytestring.decode('unicode_escape') does what
On 2019-01-22 19:20, Grant Edwards wrote:
> > For anyone who has moved a substantial bunch of Python 2 to Python
> > 3, can you please reply with your experience?
>
> If you used bytes (or raw binary strings) at all (e.g. for doing
> things like network or serial protocols) you're in for a lot
On 2019-01-07 17:14, Bob van der Poel wrote:
> I need to see if all the items in my list are the same. I was using
> set() for this, but that doesn't work if items are themselves
> lists. So, assuming that a is a list of some things, the best I've
> been able to come up with it:
>
> if
On 2018-12-28 17:31, Abdur-Rahmaan Janhangeer wrote:
> do you have something like
>
> choice(balls)
>
> >>> red
Don't specify the "k=" (which defaults to 1 if you omit it) and use
the first element of the results:
>>> from random import choices
>>> distribution = {"green":2, "red": 2,
On 2018-12-28 16:15, Abdur-Rahmaan Janhangeer wrote:
> greetings,
>
> let us say that i have a box of 5 balls,
>
> green balls - 2 with probability 2/5
> red balls 2 - with probability 2/5
> blue balls 1 - with probability 1/5
>
> how to program the selection so that the random choices reflect
On 2018-12-08 17:54, Avi Gross wrote:
> This may be a bit awkward.
ICWYDT. "awk"ward. :wide-eyed_gaping_grin_with_finger-guns:
You seem to have your knickers in a knot.
> Your solution in AWK assumes lots of things. You assume the data
> is either on stdin or comes from automatically opening
On 2018-12-08 10:02, Musatov wrote:
> I am thinking about a program where the only user input is
> win/loss. The program let's you know if you have won more than 31%
> of the time or not. Any suggestions about how to approach authoring
> such a program? Thanks. --
Can be done with an awk
On 2018-07-17 08:37, Marko Rauhamaa wrote:
> Tim Chase :
> > Wait, but now you're talking about vendors. Much of the crux of
> > this discussion has been about personal scripts that don't need to
> > marshal Unicode strings in and out of various functions/objects.
On 2018-07-17 01:21, Steven D'Aprano wrote:
> > This doesn’t mean that UTF-32 is an awful system, just that it
> > isn’t the magical cure that some were hoping for.
>
> Nobody ever claimed it was, except for the people railing that
> since it isn't a magically system we ought to go back to the
On 2018-07-17 01:08, Steven D'Aprano wrote:
> In English, I think most people would prefer to use a different
> term for whatever "sh" and "ch" represent than "character".
The term you may be reaching for is "consonant cluster"?
https://en.wikipedia.org/wiki/Consonant_cluster
-tkc
--
On 2018-07-16 23:59, Marko Rauhamaa wrote:
> Tim Chase :
> > While the python world has moved its efforts into improving
> > Python3, Python2 hasn't suddenly stopped working.
>
> The sword of Damocles is hanging on its head. Unless a consortium is
> erected to su
On 2018-07-16 18:31, Steven D'Aprano wrote:
> You say that all you want is a switch to turn off Unicode (and
> replace it with what? Kanji strings? Cyrillic? Shift_JS? no of
> course not, I'm being absurd -- replace it with ASCII, what else
> could any right-thinking person want, right?).
But we
On 2018-07-08 13:34, Cameron Simpson wrote:
> On 07Jul2018 21:57, Tim Chase wrote:
> >On 2018-07-08 12:12, Cameron Simpson wrote:
> >> On 07Jul2018 20:11, Skip Montanaro
> >> wrote:
> >> >> Have you looked at the ptx command? Might be called "gp
On 2018-07-08 12:12, Cameron Simpson wrote:
> On 07Jul2018 20:11, Skip Montanaro wrote:
> >> Have you looked at the ptx command? Might be called "gptx"
> >
> >Thanks, Cameron. I was unaware of it. Will check it out.
>
> BTW, it well predates the GNU coreutils; I used it on V7 UNIX.
From: Tim Chase
On 2018-06-23 23:08, Jim Lee wrote:
>>> On 06/23/2018 10:03 PM, Steven D'Aprano wrote:
>>>> def test():
>>>> a = 1
>>>> b = 2
>>>> result = [value for key, value in locals().items()]
>>>>
From: Tim Chase
On 2018-06-24 05:03, Steven D'Aprano wrote:
> I'd like to run a quick survey. There is no right or wrong answer,
> since this is about your EXPECTATIONS, not what Python actually
> does.
>
> Given this function:
>
> def test():
> a = 1
>
On 2018-06-23 23:08, Jim Lee wrote:
>>> On 06/23/2018 10:03 PM, Steven D'Aprano wrote:
def test():
a = 1
b = 2
result = [value for key, value in locals().items()]
return result
what would you expect the result of calling test() to be?
On 2018-06-24 05:03, Steven D'Aprano wrote:
> I'd like to run a quick survey. There is no right or wrong answer,
> since this is about your EXPECTATIONS, not what Python actually
> does.
>
> Given this function:
>
> def test():
> a = 1
> b = 2
> result = [value for key, value in
On 2018-06-07 13:32, Steven D'Aprano wrote:
> I'm following the instructions here:
>
> https://docs.python.org/3/library/http.server.html
>
> and running this from the command line as a regular unprivileged
> user:
>
> python3.5 -m http.server 8000
>
> What I expected was a directory listing
On 2018-06-07 22:46, Chris Angelico wrote:
> On Thu, Jun 7, 2018 at 10:18 PM, Steven D'Aprano
> 3. http://localhost:8000/te%00st.html
> >>> Actually, I couldn't even get Chrome to make that request, so it
> >>> obviously was considered by the browser to be invalid.
It doesn't matter
On 2018-06-02 00:14, Steven D'Aprano wrote:
> Since /wibble doesn't exist, neither does /wibble/a\0b
>
>
> py> os.path.exists("/wibble")
> False
> py> os.path.exists("/wibble/a\0b")
> Traceback (most recent call last):
> File "", line 1, in
> File
On 2018-05-01 06:40, Chris Angelico wrote:
>>> >> https://xkcd.com/1987/
>>
>> I feel like this problem is pretty handily solved by virtual
>> environments. Also, if a single project requires all of this,
>> perhaps Python isn't the best choice for the project.
>
> Some of it is definitely
On 2018-03-29 20:42, Ganesh Pal wrote:
> I have a list of tuple say [(1, 2, 1412734464L, 280), (2, 5,
> 1582956032L, 351), (3, 4, 969216L, 425)] . I need to convert the
> above as ['1,2,1412734464:280',
> '2,5,1582956032:351', '3,4,969216:425']
>
> Here is my Solution , Any suggestion or
On 2018-03-13 10:58, Terry Reedy wrote:
> Two days later, Benjamin Peterson, the 2.7 release manager, replied
> "Sounds good to me. I've updated the PEP to say 2.7 is completely
> dead on Jan 1 2020." adding "The final release may not literally be
> on January 1st".
Am I the only one saddened by
On 2018-03-01 23:57, John Pote wrote:
> On 01/03/2018 01:35, Tim Chase wrote:
> > While inelegant, I've "solved" this with a wrapper/generator
> >
> >f = file(fname, …)
> >g = (line.replace('\0', '') for line in f)
> I wondered about somethin
On 2018-02-28 21:38, Dennis Lee Bieber wrote:
> > with open( fname, 'rt', encoding='iso-8859-1' ) as csvfile:
>
> Pardon? Has the CSV module changed in the last year or so?
>
> Last time I read the documentation, it was recommended that
> the file be opened in BINARY mode
While inelegant, I've "solved" this with a wrapper/generator
f = file(fname, …)
g = (line.replace('\0', '') for line in f)
reader = csv.reader(g, …)
for row in reader:
process(row)
My actual use at $DAYJOB cleans out a few other things
too, particularly non-breaking spaces coming
Something like the following might do the trick. As an added benefit,
it's easy to set all the defaults automatically in __init__ as well
without hand-adding "self.dopey = dopey". On the down side, in the
non-__init__ functions, you have to use kwargs["dopey"] and the like.
It also involves
Has anybody else been getting unexpected/unsolicited emails from the
Python bug-tracker?
I'm not associated with (didn't submit/lurk/follow/sign-up-for) this
bug or its notifications but somehow I'm getting messages on this
particular issue. I've now received two notifications (both on this
same
.
Thanks,
-tkc
On 2018-02-02 13:10, Tim Chase wrote:
> Under a new user account with ksh (the default) as the shell I
> issued the following:
>
> $ pip3 install --user virtualenvwrapper
> Successfully installed pbr-3.1.1 six-1.11.0 stevedore-1.28.0
> virtualenv-clone-0.2.6
Under a new user account with ksh (the default) as the shell I issued
the following:
$ pip3 install --user virtualenvwrapper
Successfully installed pbr-3.1.1 six-1.11.0 stevedore-1.28.0
virtualenv-clone-0.2.6 virtualenvwrapper-4.8.2
$ export WORKON_HOME=~/code/virtualenvs
$ mkdir -p
On 2017-12-29 08:42, Ben Finney wrote:
> Duram writes:
>
> > How to use goto in python?
>
> Step 0: what is goto in Python?
>
> Step 1: that's not something that exists in Python. So why are you
> asking how to use something that doesn't exist?
so quick to shoot down a
Playing around, I had this (happens to be Py2, but gets the same
result in Py3) code
class X(object):
ONE = "one"
TWO = "two"
_ALL = frozenset(v for k,v in locals().items() if k.isupper())
@classmethod
def __contains__(cls, v):
return v in cls._ALL
print(dir(X))
print(X._ALL)
[rearranging for easier responding]
On 2017-10-27 13:35, Robert wrote:
> self.freqslider=forms.slider(
> parent=self.GetWin( ),
> sizer=freqsizer,
> value=self.freq,
> callback= self.setfreq,
> minimum=−samprate/2,
> maximum=samprate/2,
> num_steps=100,
>
On 2017-10-22 15:26, Patrick Vrijlandt wrote:
> The version control I was referring to, is indeed users' data. I
> plan to use Mercurial for the source code. The questionnaires being
> developed will go through many revisions. The questionnaires being
> filled in, are enough work to have a
On 2017-10-22 12:24, Patrick Vrijlandt wrote:
> I would like your recommendation on the choice of a web framework.
Might depend on what skills you already bring to the table. If you
already know an ORM like SQLAlchemy or a template language like
Jinja, you might want to take the "bring the
On 2017-09-26 18:25, alister via Python-list wrote:
>>> We've been asked nicely by the list mod to stop :)
>>
>> Perhaps we could agree on a subject line tag to be used in all
>> threas arguing about what to call the Python argument passing
>> scheme? That way the other 99% of us could
On 2017-09-26 02:29, Steve D'Aprano wrote:
> x = Parrot(name="Polly")
>
> (using Python syntax for simplicity) and somebody tries to tell me
> that the value of x is anything but a Parrot instance named "Polly",
So this is a Polly-morphic constructor?
-tkc
--
On 2017-09-23 19:14, Chris Angelico wrote:
> On Sat, Sep 23, 2017 at 7:07 PM, Kryptxy
> wrote:
> > Thank you all! I opened a ticket about the same (on github).
> > I got response from most of them, and all are agreeing to the
> > change. However, one contributor did not
On 2017-09-18 01:41, INADA Naoki wrote:
> > > That said, I'm neither here nor there when it comes to
> > > using print-as-a-statement vs print-as-a-function. I like
> > > the consistency it brings to the language, but miss the
> > > simplicity that Py2 had for new users. I'd almost want to
> > >
On 2017-09-17 16:15, Rick Johnson wrote:
> > I've wanted to do all those things, and more. I love the
> > new print function. For the cost of one extra character,
> > the closing bracket,
>
> Oops, _two_ characters! What about the opening "bracket"?
>>> print(len('print "hello"'))
13
>>>
On 2017-09-17 14:16, bartc wrote:
> print() is used for its side-effects; what relevant value does it
> return?
depending on the sink, errors can be returned (at least for the
printf(3) C function). The biggest one I've encountered is writing
to a full disk. The return value is how many
On 2017-09-15 17:45, Terry Reedy wrote:
> On 9/15/2017 3:36 PM, Tim Chase wrote:
> >d = {
> > "a": 0,
> > "a": 1,
> > "a": 2,
> >}
> >
> > In my limited testing, it appears to always take the
Looking through docs, I was unable to tease out whether there's a
prescribed behavior for the results of defining a dictionary with the
same keys multiple times
d = {
"a": 0,
"a": 1,
"a": 2,
}
In my limited testing, it appears to always take the last one,
resulting in
On 2017-09-01 00:53, MRAB wrote:
> What would you expect the result would be for:
>
>>> "\N{LATIN SMALL LIGATURE FI}".case_insensitive_find("F")
0
>>> "\N{LATIN SMALL LIGATURE FI}".case_insensitive_find("I)
0.5
>>> "\N{LATIN SMALL LIGATURE FFI}".case_insensitive_find("I)
0.6
On 2017-08-31 07:10, Steven D'Aprano wrote:
> So I'd like to propose some additions to 3.7 or 3.8.
Adding my "yes, a case-insensitive equality-check would be useful"
with the following concerns:
I'd want to have an optional parameter to take locale into
consideration. E.g.
On 2017-08-31 18:17, Peter Otten wrote:
> A quick and dirty fix would be a naming convention:
>
> upcase_a = something().upper()
I tend to use a "_u" suffix as my convention:
something_u = something.upper()
which keeps the semantics of the original variable-name while hinting
at the
On 2017-08-31 23:30, Chris Angelico wrote:
> The method you proposed seems a little odd - it steps through the
> strings character by character and casefolds them separately. How is
> it superior to the two-line function? And it still doesn't solve any
> of your other cases.
It also breaks when
On 2017-08-22 08:21, Rick Johnson wrote:
> Grant Edwards wrote:
> > Abdur-Rahmaan Janhangeer wrote:
> > >
> > > Hi all, i am subscribed to different python lists and
> > > they put their names in the subject [name] subject hence
> > > i can at a glance tell which mail belongs to which list.
>
On 2017-08-14 00:36, Steve D'Aprano wrote:
> Python's comprehensions are inspired by Haskell's, but we made
> different choices than they did: we make the fact that a
> comprehension is a loop over values explicit, rather than implicit,
> and we use words instead of cryptic symbols.
I keep
On 2017-08-11 00:28, Steve D'Aprano wrote:
> What would you expect this syntax to return?
>
> [x + 1 for x in (0, 1, 2, 999, 3, 4) while x < 5]
[1, 2, 3]
I would see this "while-in-a-comprehension" as a itertools.takewhile()
sort of syntactic sugar:
>>> [x + 1 for x in takewhile(lambda m: m <
Strange. The OP's message didn't make it here, but I'm seeing
multiple replies
> On Wednesday, September 22, 2010 at 4:01:04 AM UTC+5:30, Hellmut
> Weber wrote:
> > Hi list,
> > I'm looking for a possibility to access the partiton inforamtion
> > of a hard disk of my computer from within a
On 2017-07-06 11:47, Gregory Ewing wrote:
> The only reason I can think of to want to use tsv instead
> of csv is that you can sometimes get away without having
> to quote things that would need quoting in csv. But that's
> not an issue in Python, since the csv module takes care of
> all of that
On 2017-06-16 15:53, Ben Finney wrote:
> > I must admit my initial preference would be the differently named
> > wrapper. Surely users of the codebase will be invoking stuff via
> > something opaque which sources the requisite things?
>
> That “something opaque” is the ‘$VENV/bin/activate’
On 2017-05-26 13:29, Cecil Westerhof wrote:
> To check if Firefox is running I use:
> if not 'firefox' in [i.name() for i in list(process_iter())]:
>
> It probably could be made more efficient, because it can stop when
> it finds the first instance.
>
> But know I switched to Debian and
On 2017-05-23 13:38, woo...@gmail.com wrote:
> It is very straight forward; split on "_", create a new list of
> lists that contains a sublist of [file ending as an integer, file
> name], and sort
>
> fnames=["XXX_chunk_0",
> "XXX_chunk_10",
> "XXX_chunk_1",
>
1 - 100 of 2411 matches
Mail list logo