Re: a simple regex question

2006-04-01 Thread Roel Schroeven
ither, so that's no reason not to use findall(), and the pattern is simpler with findall(); I solved this challenge with findall() and this regular expression: pattern = r'[a-z][A-Z]{3}[a-z][A-Z]{3}[a-z]' -- If I have been able to see further, it was only because I stood on the shoulders of giants. -- Isaac Newton Roel Schroeven -- http://mail.python.org/mailman/listinfo/python-list

Re: what's going on here?

2006-04-04 Thread Roel Schroeven
ble to see further, it was only because I stood on the shoulders of giants. -- Isaac Newton Roel Schroeven -- http://mail.python.org/mailman/listinfo/python-list

Re: using range() in for loops

2006-04-05 Thread Roel Schroeven
index? Use for i, x in enumerate(sequence). -- If I have been able to see further, it was only because I stood on the shoulders of giants. -- Isaac Newton Roel Schroeven -- http://mail.python.org/mailman/listinfo/python-list

Re: just one more question about the python challenge

2006-04-13 Thread Roel Schroeven
images :) -- If I have been able to see further, it was only because I stood on the shoulders of giants. -- Isaac Newton Roel Schroeven -- http://mail.python.org/mailman/listinfo/python-list

Re: New Karrigel page in Wikipedia

2006-04-13 Thread Roel Schroeven
bserver. How do other people do this? Only one application on each (virtual) server? Or is there something I am missing? -- If I have been able to see further, it was only because I stood on the shoulders of giants. -- Isaac Newton Roel Schroeven -- http://mail.python.org/mailman/listinfo/python-list

Re: New Karrigel page in Wikipedia

2006-04-13 Thread Roel Schroeven
Tim Williams (gmail) schreef: > > > On 13/04/06, *Roel Schroeven* < [EMAIL PROTECTED] > <mailto:[EMAIL PROTECTED]>> wrote: > > > > There's something I don't quite get regarding the Karrigell- and > CherryPy-style frameworks. Wit

Re: New Karrigel page in Wikipedia

2006-04-13 Thread Roel Schroeven
d some URL's to Karrigell on handle some URL's itself. For example, suppose I create /var/www/karrigell1 /var/www/karrigell2 How do I configure everything so that they are accessible via http://hostname/karrigell1 http://hostname/karrigell2 -- If I have been able to see further, i

Re: New Karrigel page in Wikipedia

2006-04-13 Thread Roel Schroeven
xample (not that I like to program in PHP, by the way). -- If I have been able to see further, it was only because I stood on the shoulders of giants. -- Isaac Newton Roel Schroeven -- http://mail.python.org/mailman/listinfo/python-list

Re: Remove Whitespace

2006-04-14 Thread Roel Schroeven
gt; > yeah. but as is obvious from his examples, he really means "UTF-16", not > whitespace. Yes, that's what I was thinking. His data looks like a part of a Windows registry export, which at least on my system is in what Windows calls Unicode. -- If I have been

Re: Exception as the primary error handling mechanism?

2010-01-07 Thread Roel Schroeven
t protect me. > Anyway: in Python, assignment is not an expression, and this isn't going > to change anytime soon. To be fully clear: I'm not advocating to change the current behavior in Python, I'm just stating my experience in other languages. -- The saddest aspect of life right now is that science gathers knowledge faster than society gathers wisdom. -- Isaac Asimov Roel Schroeven -- http://mail.python.org/mailman/listinfo/python-list

Re: Exception as the primary error handling mechanism?

2010-01-07 Thread Roel Schroeven
Lie Ryan schreef: > On 1/7/2010 10:43 PM, Roel Schroeven wrote: >> - I tend to think that not following that practice trains me to be >> careful in all cases, whereas I'm afraid that following the practice >> will make me careless, which is dangerous in all the cases w

Re: please help shrink this each_with_index() implementation

2010-01-08 Thread Roel Schroeven
faster than society gathers wisdom. -- Isaac Asimov Roel Schroeven -- http://mail.python.org/mailman/listinfo/python-list

Re: iterating lists

2010-01-23 Thread Roel Schroeven
rnaud... The stable way would've been > > for w in l1[:]: #use copy of l1 for iteration > print(l1.pop()) #decomposite list I would prefer: while l1: print(l1.pop()) -- The saddest aspect of life right now is that science gathers knowledge faster than society gathers wisdom. -- Isaac Asimov Roel Schroeven -- http://mail.python.org/mailman/listinfo/python-list

Re: python os.path.exists failure

2009-11-01 Thread Roel Schroeven
inks, which Windows doesn't have. - I'm not sure what you expect the line with Popen to do. On my system, it opens the specified text file in notepad and returns an empty string. If that's what you want to do, it's easier with os.startfile(). -- The saddest aspect of life right now is that science gathers knowledge faster than society gathers wisdom. -- Isaac Asimov Roel Schroeven -- http://mail.python.org/mailman/listinfo/python-list

Re: How convert string '1e7' to an integer?

2009-11-08 Thread Roel Schroeven
gt; 119884624838656L If that is a concern, decimal can help: >>> import decimal >>> int(decimal.Decimal('1e30')) 100L -- The saddest aspect of life right now is that science gathers knowledge faster than society gathers wisdom. -- Isaac Asimov Roel Schroeven -- http://mail.python.org/mailman/listinfo/python-list

Re: python simply not scaleable enough for google?

2009-11-14 Thread Roel Schroeven
the right implementation. And once the most commonly used implementation is a fast one, we'll say that Python is fast, unless you happen to use a slow implementation for one reason or another. -- The saddest aspect of life right now is that science gathers knowledge faster than society gathers wisdom. -- Isaac Asimov Roel Schroeven -- http://mail.python.org/mailman/listinfo/python-list

Re: python simply not scaleable enough for google?

2009-11-14 Thread Roel Schroeven
t it's not here. -- The saddest aspect of life right now is that science gathers knowledge faster than society gathers wisdom. -- Isaac Asimov Roel Schroeven -- http://mail.python.org/mailman/listinfo/python-list

Re: How to guard against bugs like this one?

2010-02-02 Thread Roel Schroeven
with 0 problems of name clashes; there is IMO no reason why Python should restrict itself to any less. Generally I like the design decisions used in Python, or at least I understand the reasons; in this case though, I don't see the advantages of the current approach. -- The saddest aspect of life right now is that science gathers knowledge faster than society gathers wisdom. -- Isaac Asimov Roel Schroeven -- http://mail.python.org/mailman/listinfo/python-list

Re: python crash on windows but not on linux

2010-02-14 Thread Roel Schroeven
27;t show the virtual memory size (at least on Windows XP). -- The saddest aspect of life right now is that science gathers knowledge faster than society gathers wisdom. -- Isaac Asimov Roel Schroeven -- http://mail.python.org/mailman/listinfo/python-list

Re: String is ASCII or UTF-8?

2010-03-09 Thread Roel Schroeven
te will be zero in most characters; you could check for that (but note that the second byte might be the first one in the byte stream, depending on the byte ordering). HTH, Roel -- The saddest aspect of life right now is that science gathers knowledge faster than society gathers wisdom. -- Isaac Asimov Roel Schroeven -- http://mail.python.org/mailman/listinfo/python-list

Re: strange behavor....

2010-11-14 Thread Roel Schroeven
nceptions are wrong. -- The saddest aspect of life right now is that science gathers knowledge faster than society gathers wisdom. -- Isaac Asimov Roel Schroeven -- http://mail.python.org/mailman/listinfo/python-list

Re: setprocname

2010-06-15 Thread Roel Schroeven
window titles; not on the Processes tab which shows the actual process names (on Windows XP). -- The saddest aspect of life right now is that science gathers knowledge faster than society gathers wisdom. -- Isaac Asimov Roel Schroeven -- http://mail.python.org/mailman/listinfo/python-list

Re: Searching equivalent to C++ RAII or deterministic destructors

2009-07-02 Thread Roel Schroeven
t of scope, or because it is deleted), the resource is automatically destroyed too. The way RAII works is actually the one thing from C++ that I miss in Python. -- The saddest aspect of life right now is that science gathers knowledge faster than society gathers wisdom. -- Isaac Asimov Roel Schroeven -- http://mail.python.org/mailman/listinfo/python-list

Re: Python docs disappointing - group effort to hire writers?

2009-08-08 Thread Roel Schroeven
t of life right now is that science gathers knowledge faster than society gathers wisdom. -- Isaac Asimov Roel Schroeven -- http://mail.python.org/mailman/listinfo/python-list

Re: Temporary variables in list comprehensions

2017-04-07 Thread Roel Schroeven
Or even [(tmp, tmp + 1) for x in data with expensive_calculation(x) as tmp if tmp is not None] Perhaps this: [(tmp, tmp + 1) for tmp in (expensive_calculation(x) for x in data) if tmp is not None] A bit less elegant, but works right now. -- Roel Schroeven -- https:

Re: Namedtuples: some unexpected inconveniences

2017-04-13 Thread Roel Schroeven
faster than society gathers wisdom. -- Isaac Asimov Roel Schroeven -- https://mail.python.org/mailman/listinfo/python-list

Re: f-string syntax deficiency?

2023-06-06 Thread Roel Schroeven via Python-list
Op 6/06/2023 om 16:48 schreef Chris Angelico via Python-list: On Wed, 7 Jun 2023 at 00:42, Roel Schroeven wrote: > (Recently there has been an effort to provide clearer and more useful > error messages; this seems to be a case where there is still room for > improvement: "Syntax

Re: File system path annotations

2023-06-19 Thread Roel Schroeven via Python-list
Op 19/06/2023 om 10:43 schreef Peter Slížik via Python-list: Hello, what is the preferred way of annotating file system paths? This StackOverflow answer (and a few others) recommend using the str | os.PathLike union. However, byte arrays can be

Re: File system path annotations

2023-06-19 Thread Roel Schroeven via Python-list
Op 19/06/2023 om 11:44 schreef Peter Slížik: Thank you, Roel. You've answered all my questions. > [PEP 519]: ...as that can be represented with typing.Union[str, bytes, os.PathLike] easily enough and the hope is users > will slowly gravitate to path objects only. I read a lot on Python and, f

Re: Should NoneType be iterable?

2023-06-20 Thread Roel Schroeven via Python-list
Op 20/06/2023 om 2:50 schreef Greg Ewing via Python-list: I would question the wisdom of designing an API that can return either a sequence or None. If it normally returns a sequence, and there are no items to return, it should return an empty sequence. I guess it depends on the reason why there

Re: How to add CC and BCC while sending mails using python

2023-06-20 Thread Roel Schroeven via Python-list
sonam Kumari via Python-list schreef op 20/06/2023 om 9:49: > > I've tried the above code and the bcc address does not receive the message, on the To & CC addresses receive it. > > Here are snippets from my code, perhaps something will stand out to you? > > to = 'e...@domain.gov' > cc = 'e..

Re: Confusing behavior of PYTHONWARNINGS

2023-09-18 Thread Roel Schroeven via Python-list
Op 16/09/2023 om 10:17 schreef Meowxiik via Python-list: Hello, For the third time I am trying to work with `PYTHONWARNINGS` filter, and for the third time I am having a terrible time. I'd like to seek your assistance, I have a few questions: **Question 1:** Does the environment variable onl

Re: Why doc call `__init__` as a method rather than function?

2023-09-18 Thread Roel Schroeven via Python-list
Op 15/09/2023 om 15:05 schreef anthony.flury via Python-list: Like all of the other methods you shouldn't ever need to call them directly : these are called dunder methods and represent functions and features which are called by other operators. The only recommended way to call A.__init__

Re: How to write list of integers to file with struct.pack_into?

2023-10-03 Thread Roel Schroeven via Python-list
Jen Kris via Python-list schreef op 2/10/2023 om 17:06: My previous message just went up -- sorry for the mangled formatting.  Here it is properly formatted: I want to write a list of 64-bit integers to a binary file.  Every example I have seen in my research converts it to .txt, but I want

Re: Where I do ask for a new feature

2023-10-20 Thread Roel Schroeven via Python-list
Op 20/10/2023 om 5:16 schreef Bongo Ferno via Python-list: On Thursday, October 19, 2023 at 11:26:52 PM UTC-3, avi.e...@gmail.com wrote: > There are many ways to make transient variables that disappear at some time > and do we need yet another? Yes, you can create one of those ways but what >

Re: Running a subprocess in a venv

2023-10-21 Thread Roel Schroeven via Python-list
Larry Martell via Python-list schreef op 21/10/2023 om 15:01: I have a python script, and from that I want to run another script in a subprocess in a venv. What is the best way to do that? I could write a file that activates the venv then runs the script, then run that file, but that seems messy.

Re: Newline (NuBe Question)

2023-11-26 Thread Roel Schroeven via Python-list
Michael F. Stemper via Python-list schreef op 25/11/2023 om 15:32: On 24/11/2023 21.45,avi.e.gr...@gmail.com wrote: > Grizz[l]y, > > I think the point is not about a sorted list or sorting in general It is > about reasons why maintaining a data structure such as a list in a program > can be us

Re: A problem with str VS int.

2023-12-12 Thread Roel Schroeven via Python-list
Op 12/12/2023 om 9:22 schreef Steve GS via Python-list: With all these suggestions on how to fix it, no one seems to answer why it fails only when entering a two-digit number. One and three work fine when comparing with str values. It is interesting that the leading 0 on a two digit worked. Stil

Re: Is there a way to implement the ** operator on a custom object

2024-02-09 Thread Roel Schroeven via Python-list
Left Right via Python-list schreef op 9/02/2024 om 17:09: In order for the "splat" operator to work, the type of the object must populate slot `tp_as_mapping` with a struct of this type: https://docs.python.org/3/c-api/typeobj.html#c.PyMappingMethods and have some non-null implementations of the

Re: Variable scope inside and outside functions - global statement being overridden by assignation unless preceded by reference

2024-03-06 Thread Roel Schroeven via Python-list
Op 6/03/2024 om 13:55 schreef Jacob Kruger via Python-list: If you import the contents of that file into the python interpreter, [...] What exactly to you mean by "import the contents of that file into the python interpreter"? Other people have put your code in a script, executed it, and saw

Re: Variable scope inside and outside functions - global statement being overridden by assignation unless preceded by reference

2024-03-06 Thread Roel Schroeven via Python-list
Op 6/03/2024 om 16:39 schreef Roel Schroeven via Python-list: Op 6/03/2024 om 13:55 schreef Jacob Kruger via Python-list: If you import the contents of that file into the python interpreter, [...] What exactly to you mean by "import the contents of that file into the python interp

Re: Variable scope inside and outside functions - global statement being overridden by assignation unless preceded by reference

2024-03-06 Thread Roel Schroeven via Python-list
Op 6/03/2024 om 17:40 schreef Jacob Kruger via Python-list: >>> from scoping2 import * Ah yes, that explains what's happening. After that statement, the name dt_expiry in the current namespace is bound to the same object that the name dt_expiry in the namespace of module scoping2 is bound to. F

Re: Variable scope inside and outside functions - global statement being overridden by assignation unless preceded by reference

2024-03-06 Thread Roel Schroeven via Python-list
Grant Edwards via Python-list schreef op 6/03/2024 om 18:59: On 2024-03-06, Roel Schroeven via Python-list wrote: > Op 6/03/2024 om 17:40 schreef Jacob Kruger via Python-list: >> >>> from scoping2 import * > > [...] > > I would advice not to use 'import *&

Re: Configuring an object via a dictionary

2024-03-16 Thread Roel Schroeven via Python-list
Barry via Python-list schreef op 16/03/2024 om 9:15: > On 15 Mar 2024, at 19:51, Thomas Passin via Python-list wrote: > > I've always like writing using the "or" form and have never gotten bit I, on the other hand, had to fix a production problem that using “or” introducted. I avoid this

Re: Configuring an object via a dictionary

2024-03-20 Thread Roel Schroeven via Python-list
Op 19/03/2024 om 0:44 schreef Gilmeh Serda via Python-list: On Mon, 18 Mar 2024 10:09:27 +1300, dn wrote: > YMMV! > NB your corporate Style Guide may prefer 'the happy path'... If you only want to check for None, this works too: >>> name = None >>> dafault_value = "default" >>> name or default

Re: Terminal Emulator (Posting On Python-List Prohibited)

2024-05-19 Thread Roel Schroeven via Python-list
Skip Montanaro via Python-list schreef op 20/05/2024 om 0:08: Modern debian (ubuntu) and fedora block users installing using pip. > Even if you're telling it to install in ~/.local? I could see not allowing to run it as root. I assumed pip install --user would work, but no. I tried it (on Debi

Re: pip and venvs on Debian

2024-05-21 Thread Roel Schroeven via Python-list
Op 20/05/2024 om 23:48 schreef Akkana Peck via Python-list: Every so often I need to regenerate it (like when Debian updates the system Python version) but that's easy to do: I don't try to duplicate what's installed there, I just delete the old venv, create a new one and then pip install pack

Re: Anonymous email users

2024-06-17 Thread Roel Schroeven via Python-list
AVI GROSS via Python-list schreef op 17/06/2024 om 17:03: I simply am thinking that people who do not allow me to easily reply to them directly, should be ignored by me and not get my cooperation that way. FWIW, personally I (mostly) don't see the point of replying to people personally. To me a

Re: FileNotFoundError thrown due to file name in file, rather than file itself

2024-11-13 Thread Roel Schroeven via Python-list
Op 12/11/2024 om 20:10 schreef Left Right via Python-list: > I am not entirely convinced by NB2. I am, in fact, a sort of sysadmin > person and most of my programs write to a log file. The programs are > also moderately complex, so a single program might access a database, > query an LDAP serve

Re: Two python issues

2024-11-06 Thread Roel Schroeven via Python-list
Op 5/11/2024 om 15:48 schreef Raymond Boute via Python-list: L.S., Python seem to suffer from a few poor design decisions regarding strings and lists that affect the elegance of the language. (a) An error-prone "feature" is returning -1 if a substring is not found by "find", since -1 current

Re: super().__init__() and bytes

2024-12-03 Thread Roel Schroeven via Python-list
Op 3/12/2024 om 10:41 schreef Roel Schroeven via Python-list: [...] When I try the same with bytes as base class though, that doesn't work (at least in the Python version I'm using, which is CPython 3.11.2 64-bit on Windows 10): class MyBytes(bytes):     def __init__(

Re: super().__init__() and bytes

2024-12-03 Thread Roel Schroeven via Python-list
Op 3/12/2024 om 13:55 schreef Anders Munch via Python-list: Roel Schroeven wrote: > As a follow-up, it looks like this behavior is because bytes and int are immutable. Yes. OK. > But that doesn't tell me why using super().__init__() doesn't work for immutable classes. byt

super().__init__() and bytes

2024-12-03 Thread Roel Schroeven via Python-list
We can use super().__init__() in the __init__() method of a derived class to initialize its base class. For example: import string class MyTemplate(string.Template):     def __init__(self, template_string):     super().__init__(template_string) print(MyTemplate('Hello ${name}').substitute(na

Re: super().__init__() and bytes

2024-12-04 Thread Roel Schroeven via Python-list
Op 4/12/2024 om 0:14 schreef Greg Ewing via Python-list: On 4/12/24 3:24 am, Roel Schroeven wrote: It's not entirely clear to me though how bytes.__new__ *can* set an object's value. Isn't __new__ also a regular function? Yes, but the __new__ methods of the builtin immutable ob

Re: Tools to help with text mode (i.e. non-GUI) input

2025-01-16 Thread Roel Schroeven via Python-list
Op 11/01/2025 om 15:28 schreef Chris Green via Python-list: I'm looking for Python packages that can help with text mode input, i.e. for use with non-GUI programs that one runs from the command prompt in a terminal window running a bash shell or some such. What I'm specifically after is a way to

Re: Pip installs to unexpected place

2025-04-17 Thread Roel Schroeven via Python-list
Op 15/04/2025 om 20:31 schreef Mats Wichmann via Python-list: To be clear: you do not have to activate a virtualenv to use *Python* from it. If you just call the python by the path it's in, it figures everything out (and sets some variables you can query vi sysconfig if you have reason to actua

<    1   2   3   4   5