Robert Latest wrote:
> Paul Bryan wrote:
>> Adding to this, there should be no reason now in recent versions of
>> Python to ever use line continuation. Black goes so far as to state
>> "backslashes are bad and should never be used":
>>
>
Paul Bryan wrote:
> Adding to this, there should be no reason now in recent versions of
> Python to ever use line continuation. Black goes so far as to state
> "backslashes are bad and should never be used":
>
> https://black.readthedocs.io/en/stable/the_black_code_style/
future_style.html#using-
Edmondo Giovannozzi wrote:
> Il giorno mercoledì 22 febbraio 2023 alle 09:50:14 UTC+1 Robert Latest ha
> scritto:
>> I found myself building a complicated logical condition with many ands and
>> ors which I made more manageable by putting the various terms on individual
>>
I found myself building a complicated logical condition with many ands and ors
which I made more manageable by putting the various terms on individual lines
and breaking them with the "\" line continuation character. In this context it
would have been nice to be able to add comments to lines terms
Hi all,
the question is in the subject. I'd like the pointer to be able to be NULL
because that would make my code slightly cleaner. No big deal though.
--
https://mail.python.org/mailman/listinfo/python-list
Stefan Ram wrote:
> Robert Latest writes:
>>the question is in the subject. I'd like the pointer to be able to be NULL
>>because that would make my code slightly cleaner. No big deal though.
>
> In Usenet, it is considered good style to have all relevant
> cont
m bit stream, but if they fail that should indicate a
problem.
Robert E. Beaudoin
On Wed, 7 Dec 2022 11:05:53 -0500
David Lowry-Duda wrote:
> Inspired by the recent thread about pseudorandom number generators on
> python-ideas (where I also mistakenly first wrote this message), I
> b
Cameron Simpson wrote:
> Stefan's code implements it's own format_field and falls back to the
> original format_field(). That's standard subclassing practice, and worth
> doing reflexively more of the time - it avoids _knowing_ that
> format_field() just calls format().
>
> So I'd take Stefan's
Stefan Ram wrote:
[the solution]
thanks, right on the spot. I had already figured out that format_field() is the
one method I need, and thanks for the str.translate method. I knew that raking
seven RE's across the same string HAD to be stupid.
Have a nice weekend!
--
https://mail.python.org/ma
Hi all,
I would like to modify the standard str.format() in a way that when the
input field is of type str, there is some character replacement, and the
string gets padded or truncated to the given field width. Basically like
this:
fmt = MagicString('<{s:6}>')
print(fmt.format(s='Äußerst'))
Outp
Hi Stefan,
I have now implemented a version of this, works nicely. I have a few minor
questions / remarks:
> result += ' ' *( length - len( result ))
Nice, I didn't know that one could multiply strings by negative numbers without
error.
> def __init__( self ):
> super().__init_
Jon Ribbens wrote:
> That's because you *always* need to know the URI of the namespace,
> because that's its only meaningful identifier. If you assume that a
> particular namespace always uses the same prefix then your code will be
> completely broken. The following two pieces of XML should be unde
Hi all,
For the impatient: Below the longish text is a fully self-contained Python
example that illustrates my problem.
I'm struggling to understand xml.etree's handling of namespaces. I'm trying to
parse an Inkscape document which uses several namespaces. From etree's
documentation:
If the
wrote:
> I had another crazy thought that I AM NOT ASKING anyone to do. OK?
>
> I was wondering about a sort of catch method you could use that generates a
> pseudo-signal only when the enclosed preceding loop exits normally as a
> sort of way to handle the ELSE need without the use of a keyword
Antoon Pardon wrote:
> I would like a tool that tries to find as many syntax errors as possible
> in a python file.
I'm puzzled as to when such a tool would be needed. How many syntax errors can
you realistically put into a single Python file before compiling it for the
first time?
--
https://m
Michael F. Stemper wrote:
> How does one declare a variable in python? Sometimes it'd be nice to
> be able to have declarations and any undeclared variable be flagged.
To my knowledge, the closest to that is using __slots__ in class definitions.
Many a time have I assigned to misspelled class memb
Axy wrote:
>> Also not really a justification for "shortest block first". Wanting
>> some elaboration on that. What's the value in it?
>
> Well, the value is productivity. No need to save puzzles "what this
> hanging else belongs to?"
If you find yourself asking that question, the if-block is pro
wrote:
> Cameron,
>
> Your suggestion makes me shudder!
Me, too
> Removing all earlier lines of code is often guaranteed to generate errors as
> variables you are using are not declared or initiated, modules are not
> imported and so on.
all of which aren't syntax errors, so the method should s
Grant Edwards wrote:
> I've followed that advice for several decades. I find it much easier
> to read code that's organized that way -- particularly when the
> difference in block sizes is large (e.g. the first block is one line,
> and the second is a a hundred).
If any conditionally executed bloc
Chris Angelico wrote:
> Yes, I'm aware that code readability becomes irrelevant for
> short-duration projects. Beside the point. I'm wondering how important
> it really is to have the shortest block first.
I usually put the most expected / frequent / not negated block first if the
whole if/else st
Hi Chris and dh,
thanks for your --as usually-- thoughtful and interesting answers. Indeed, when
doing these web applications I find that there are several layers of useful,
maybe less useful, and unknown caching. Many of my requests rely on a
notoriously unreliable read-only database outside of m
Hi all,
in a (Flask) web application I often find that many equal (SQLAlchemy) queries
are executed across subsequent requests. So I tried to cache the results of
those queries on the module level like this:
@lru_cache()
def query_db(db, args):
# do the "expensive" query
r
Forwarded Message
Subject:Could not load correctly
Date: Sat, 21 May 2022 10:58:39 -0400
From: Robert Loomis
Reply-To: b...@loomisengineering.com
To: python-list@python.org
I am new to python.I tried to download it to a virtual environment since
I
Loris Bennett wrote:
> Thanks for the various suggestions. The data I need to store is just a
> dict with maybe 3 or 4 keys and short string values probably of less
> than 32 characters each per event. The traffic on the DB is going to be
> very low, creating maybe a dozen events a day, mainly tr
Albert-Jan Roskam wrote:
> The event may have arbitrary, but dict-like data associated with it,
> which I want to add in the field 'info'. This data never needs to be
> modified, once the event has been inserted into the DB.
>
> What type should the info field have? JSON, Pick
Chris Angelico wrote:
> I'm still curious as to the workload (requests per second), as it might still
> be worth going for the feeder model. But if your current system works, then
> it may be simplest to debug that rather than change.
It is by all accounts a low-traffic situation, maybe one reques
Chris Angelico wrote:
> Every language learns from every other.
Except Visual Basic, which didn't learn anything from anywhere, and all that
can be learned from it is how not to do it. Ugh.
--
https://mail.python.org/mailman/listinfo/python-list
Greg Ewing wrote:
> * If more than one thread calls get_data() during the initial
> cache filling, it looks like only one of them will wait for
> the thread -- the others will skip waiting altogether and
> immediately return None.
Right. But that needs to be dealt with somehow. No data is no data.
Chris Angelico wrote:
> Depending on your database, this might be counter-productive. A
> PostgreSQL database running on localhost, for instance, has its own
> caching, and data transfers between two apps running on the same
> computer can be pretty fast. The complexity you add in order to do
> you
I have a multi-threaded application (a web service) where several threads need
data from an external database. That data is quite a lot, but it is almost
always the same. Between incoming requests, timestamped records get added to
the DB.
So I decided to keep an in-memory cache of the DB records t
Abdur-Rahmaan Janhangeer wrote:
> I've got my answers but the 'wandering' a bit
> on this thread is at least connected to the topic ^^.
>
> Last question: If we check for wifi or ethernet cable connection?
>
> Wifi sometimes tell of connected but no internet connection.
> So it detected that there
Abdur-Rahmaan Janhangeer wrote:
> Well, nice perspective.
>
> It's a valid consideration, sound theory
> but poor practicality according to me.
On the contrary: It is absolutely the right and only way to do it.
> It you view it like this then between the moment
> we press run or enter key on the
Shaozhong SHI wrote:
> Can it be divided into several processes?
I'd do it like this:
from time import sleep
from threading import Thread
t = Thread(target=lambda: sleep(1))
t.run()
# do your work here
t.wait()
--
https://mail.python.org/mailman/listinfo/python-list
Dan Stromberg wrote:
> Perhaps try:
> https://stromberg.dnsalias.org/svn/find-sym/trunk
>
> It tries to find symbols in C libraries.
>
> In this case, I believe you'll find it in -lpythonx.ym
Thanks! Found out that ldd produces many errors also with working python
libraries. Turns out I tried to r
Hi guys,
I've written some CPython extension modules in the past without problems. Now
after moving to a new Archlinux box with Python3.10 installed, I can't build
them any more. Or rather, I can build them but not use them due to "undefined
symbols" during linking. Here's ldd's output when used o
Julius Hamilton wrote:
> dir(scrapy) shows this:
>
> ['Field', 'FormRequest', 'Item', 'Request', 'Selector', 'Spider',
> '__all__', '__builtins__', '__cached__', '__doc__', '__file__',
> '__loader__', '__name__', '__package__', '__path__', '__spec__',
> '__version__', '_txv', 'exceptions', 'http',
Hi all,
this just caused me several hours of my life until I could whittle it down to
this minimal example. Simple question: Why is the x member of object "foo"
modified by initializing "bar"?
Obviously, initializing foo with None doesn't set foo.x at all. So I guess x
stays a class property, not
Stefan Ram wrote:
> Robert Latest writes: But how can I "promote" a
>>given Opaque instance to the derived class?
>
> Sometimes, one can use containment instead of inheritance.
Nah, doesn't work in my case. I'm trying to write a wrapper around
xm
Hi all, let's assume I'm using a module that defines some class "Opaque" and
also a function that creates objects of that type. In my program I subclass
that type because I want some extra functionality. But how can I "promote" a
given Opaque instance to the derived class? Of course I could just cr
r (ORM) creates a 1:1 mapping of Python objects to
SQL table rows.
--
robert
--
https://mail.python.org/mailman/listinfo/python-list
Benjamin Schollnick wrote:
> I’m sorry, but it’s as if he’s arguing for the sake of arguing. It’s
> starting to feel very unproductive, and unnecessary.
That was never five minutes just now!
robert
--
https://mail.python.org/mailman/listinfo/python-list
Chris Angelico wrote:
> Cool thing is, nobody in Python needs to maintain anything here.
That's great because I'm actually having trouble with sending log messages over
the socket conection you helped me with, would you mind having a look?
Regards,
robert
--
https://mail.pytho
> Chris Angelico wrote:
[Helpful stuff]
I'm actually trying to implement a SocketHandler for a Python logger. However,
I can't get my handler on the client side to send anything. Do I need to
subclass logging.SocketHandler and fill the various methods with meaning? The
documentation doesn't say s
Karsten Hilbert wrote:
> and life with that wart.
Perfectly willing to as long as everybody agrees it's a wart ;-)
robert
--
https://mail.python.org/mailman/listinfo/python-list
ut Unicode is
[many things]
> The documentation sometimes shorthands things with terms like "upper
> case" and "lower case", but that's partly because being pedantically
> correct in a docstring doesn't actually help anything, and the code
> itself IS correct.
...but hard to maintain and useless. I just love to hate .title() ;-)
robert
--
https://mail.python.org/mailman/listinfo/python-list
rong type for socket
>>
>
> Not familiar with socat, but here's some simple Python code to trigger your
> server:
>
>>>> import socket sock = socket.socket(socket.AF_UNIX)
>>>> sock.connect("/tmp/test.socket") sock.send(b"Hello, world")
> 12
>>>> sock.close()
>>>>
Works perfectly, thanks! I'm probably not using socat right.
robert
--
https://mail.python.org/mailman/listinfo/python-list
and "first characters" and
"remaining characters." So a single character gets converted to uppercase,
whatever that may mean in the context of .title(). The .upper() method is
different in that it only applies to "cased" characters, so .title() may or may
not work d
516298102 +0100
Birth: -
Sadly all examples I can find on the web are for TCP sockets, not Unix domain.
Any tips?
robert
--
https://mail.python.org/mailman/listinfo/python-list
Grant Edwards wrote:
> On 2021-03-20, Robert Latest via Python-list wrote:
>> Mats Wichmann wrote:
>>> The problem is that there isn't a standard for title case,
>>
>> The problem is that we owe the very existence of the .title() method to too
>> much we
n(). That
said, I doubt that .title() would make it into Python today if it weren't there
already. I'm having fun with this.
robert
--
https://mail.python.org/mailman/listinfo/python-list
Chris Angelico wrote:
> On Sun, Mar 21, 2021 at 10:31 PM Robert Latest via Python-list
> wrote:
>> Yes, I get that. But the purpose it (improperly) serves only makes sense in
>> the English language.
>
> Why? Do titles not exist in other languages? Does no other language
&g
Benjamin Schollnick wrote:
>
> I’m sorry Robert, but just because it doesn’t meet your requirements, doesn’t
> mean it’s useless.
>
> I use .title to normalize strings for data comparison, all the time. It’s a
> perfect alternative to using .UPPER or .lower.
>
> Right
Chris Angelico wrote:
> On Sun, Mar 21, 2021 at 4:31 AM Robert Latest via Python-list
> wrote:
>>
>> Mats Wichmann wrote:
>> > The problem is that there isn't a standard for title case,
>>
>> The problem is that we owe the very existence of the .tit
uage. It doesn't get more
idiotic, frankly.
robert
--
https://mail.python.org/mailman/listinfo/python-list
I'm trying to implement a many-to-many relationship that associates Baskets
with Items via an association object called Link which holds the quantity of
each item. I've done that in SQLAlchemy in a very pedestrian way, such as when
I want to have six eggs in a basket:
1. Find ID of Item with name
ricate mechanical logic
> embodied in the machine.
I love both photography with mechanical camears (The Nikon FE2 being my
favorite) and programming. So I absolutely love your project. Also I think its
totally nuts. I won't spend a second looking at your code or get otherwise
involved, but I
Richard Damon wrote:
> On 3/8/21 4:16 AM, Robert Latest via Python-list wrote:
>> Joseph L. Casale wrote:
>>>> I couldn't find any information on how to implement logging in a library
>>>> that doesn't know the name of the application that uses it. H
ather have a
keyword ;-)
robert
--
https://mail.python.org/mailman/listinfo/python-list
le I
must import its logger, too, and decide how to deal with its messages.
> I hope that helps,
Much appreciated,
robert
--
https://mail.python.org/mailman/listinfo/python-list
Hello,
I'm trying to add logging to a module that gets imported by another module. But
I only get it to work right if the imported module knows the name of the
importing module. The example given in the "Logging Cookbook" also rely on this
fact.
https://docs.python.org/3/howto/logging-cookbook.ht
Ok this was due to an install of miniconda then choosing to unconditionally
install an older version of cryptography.
> On Feb 10, 2021, at 3:40 PM, Robert Nicholson
> wrote:
>
> Just reinstalling cryptography with pip install seems to have fixed my issue.
>
> Any pointer
Just reinstalling cryptography with pip install seems to have fixed my issue.
Any pointers on why?
> On Feb 10, 2021, at 3:21 PM, Robert Nicholson
> wrote:
>
> I’m using Python 3.7.0
>
> so I have multiple environments all on the same architecture with the same
>
I’m using Python 3.7.0
so I have multiple environments all on the same architecture with the same
python release using anonconda.
What I discovered was that if I install the cryptography module in my dev / uat
and then tried to synchronize to production server using rsync I ended up with
error
and thus not included. If you resize the window
(i.e., if you maximize it), you must call the function table.fit() from
IDLE shell.
Does anyone know where is this huge difference in performance coming from?
Can anything be done about it?
Thank you,
--
Robert Okadar
IT Consultant
Schedule an
e right, this wasn't the minimal example for my problem after all.
Turns out that the actual issue is somewhere between SQLAlchemy and
MySQL. I took a more specific questioon overt to stackoverflow.com
Thanks
robert
--
https://mail.python.org/mailman/listinfo/python-list
Hi folks,
what semmingly started out as a weird database character encoding mix-up
could be boiled down to a few lines of pure Python. The source-code
below is real utf8 (as evidenced by the UTF code point 'c3 a4' in the
third line of the hexdump). When just printed, the string "s" is
displayed cor
Dennis Lee Bieber writes:
> On Mon, 19 Nov 2018 19:05:44 -0200, Robert Girault declaimed
> the following:
>
>>I mean the fact that with 624 samples from the generator, you can
>>determine the rest of the sequence completely.
>
> Being able to predict the sequ
Chris Angelico writes:
> On Tue, Nov 20, 2018 at 7:31 AM Robert Girault wrote:
>> Nice. So Python's random.random() does indeed use mt19937. Since it's
>> been broken for years, why isn't it replaced by something newer like
>> ChaCha20? Is it due to back
Peter Otten <__pete...@web.de> writes:
> Robert Girault wrote:
>
>> Looking at its source code, it seems the PRNG behind random.random() is
>> Mersenne Twister, but I'm not sure. It also seems that random.random()
>> is using /dev/urandom. Can someo
Looking at its source code, it seems the PRNG behind random.random() is
Mersenne Twister, but I'm not sure. It also seems that random.random()
is using /dev/urandom. Can someone help me to read that source code?
I'm talking about CPython, by the way. I'm reading
https://github.com/python/cp
Ben Finney wrote:
> Robert Latest via Python-list writes:
>
>> Because the main.py script needs to import the tables.py module from
>> backend, I put this at the top if main.py:
>>
>>sys.path.append('../..')
>>import jobwatch.backend.tables a
From: Robert Latest
Hello,
I'm building an application which consists of two largely distinct parts, a
frontend and a backend. The directory layout is like this:
|-- jobwatch
| |-- backend
| | |-- backend.py
| | |-- __init__.py
| | `-- tables.py
| |-- fro
.
Any thoughts?
Thanks
robert
--
https://mail.python.org/mailman/listinfo/python-list
Steven D'Aprano wrote:
> Python function default values use *early binding*: the default parameter
> is evaluated, ONCE, when the function is defined, and that value is used
> each time it is needed.
Thanks, "early binding" was the clue I was missing.
robert
--
https:/
def __init__(self, x, a=dict()):
self.x = x
self.a = a
self.a[x] = x
c = Foo(1)
d = Foo(2)
print(c.__dict__)
print(d.__dict__)
robert
--
https://mail.python.org/mailman/listinfo/python-list
Thanks all for the links and suggestions, they are greatly appreciated. I
might be programming for a long time (relative to my age) but I haven't
touched much on compilers or interpreters. Inspired a but by Python's
interpreter I wrote a little bytecode interpreter in C (maybe should have
upgrade t
CPython source code and digesting it, I
was wondering if those of you have read and understood the source code, do
you have any tips or good starting points?
Robert
--
https://mail.python.org/mailman/listinfo/python-list
On Thursday, November 30, 2017 at 6:17:05 PM UTC-5, Robert wrote:
> Hi,
>
> I am new to Python. Now I follow a thread on mask array usage on line:
>
>
> https://stackoverflow.com/questions/31563970/fitting-a-binomial-distribution-with-pymc-raises-zeroprobability-error-f
Hi,
I am new to Python. Now I follow a thread on mask array usage on line:
https://stackoverflow.com/questions/31563970/fitting-a-binomial-distribution-with-pymc-raises-zeroprobability-error-for-certa
I understand the problem, but I don't understand the answer follow the link.
Because the 'ma
i was also of the same opinion , but docker is available on windows too
https://www.docker.com/docker-windows
On Wed, Nov 29, 2017 at 12:22 PM, Percival John Hackworth wrote:
> On 28-Nov-2017, Robert Clove wrote
> (in article):
>
> > Hi,
> >
> > what am i trying
Hi,
what am i trying to achieve is, container of windows with an application
like slack on it.
Does window container has an UI?
Has anyone worked on it, is it feasible?
--
https://mail.python.org/mailman/listinfo/python-list
Hi,
I read below code snippet on line. I am interested in the second of the last
line.
cast=float ,
I've tried it in Python. Even simply with
float
it has no error, but what use is it?
I do see a space before the comma ','. Is it a typo or not?
Thanks,
self.freqslider=forms.sli
> > I have a string which is returned by a C extension.
> >
> > mystring = '(1,2,3)'
> >
> > HOW can I read the numbers in python ?
>
> re.findall seems the safest and easiest solution:
>
> >>> re.findall(r'(\d+)', '(1, 2, 3)')
> ['1', '2', '3']
> >>> map(int, re.findall(r'(\d+)', '(1, 2, 3)'))
>
On 1/8/2017, Steven D'Aprano wrote:
> Suppose you have an expensive calculation that gets used two or
> more times in a loop. The obvious way to avoid calculating it
> twice in an ordinary loop is with a temporary variable:
>
> result = []
> for x in data:
> tmp = expensive_calculation(x)
>
On 1/18/2017, Peter Otten wrote:
> with partite.txt looking like this
>
> > 74' Kessie'
> > 90' + 4' D'alessandro
> > 51' Mchedlidze
> > 54' Banega
> > 56' Icardi
> > 65' Icardi
> > 14' Sau
>
>
> Assuming you want to perform a numerical sort on the numbers before the '
> you can just apply sor
On 3/1/2017, Sayth Renshaw wrote:
> How can I flatten just a specific sublist of each list in a list of lists?
>
> So if I had this data
>
>
> [ ['46295', 'Montauk', '3', '60', '85', ['19', '5', '1', '0 $277790.00']],
> ['46295', 'Dark Eyes', '5', '59', '83', ['6', '4', '1', '0 $105625.00
On 3/7/2017, Sayth Renshaw wrote:
> I have got this dictionary comprehension and it
> works but how can I do it better?
>
> from collections import Counter
>
> def find_it(seq):
> counts = dict(Counter(seq))
> a = [(k, v) for k,v in counts.items() if v % 3 == 0]
> return a[0][0]
>
Been meaning to give Pypy a try for a while, tonight may be the time
On Tue 21 Mar 2017, 20:32 , wrote:
> Hopefully this
> https://morepypy.blogspot.co.uk/2017/03/pypy27-and-pypy35-v57-two-in-one-release.html
> is rather more interesting for some than blatant trolling about spaces vs
> tabs.
>
>
f you fine people know some good resources of where
to start as I'm finding it hard to procure decent content. If any of you
know of any resources in the field please send them my way.
Regards,
Robert
--
https://mail.python.org/mailman/listinfo/python-list
What is the easiest way to connect to an Oracle Database using python in order
to run queries?
--
https://mail.python.org/mailman/listinfo/python-list
Thanks, Chris. That was nice and easy and very simple.
--
https://mail.python.org/mailman/listinfo/python-list
Hi All,
I'm relatively new to Python, and I am having some trouble with one of my
scripts. Basically, this script connects to a server via ssh, runs Dell's
omreport output, and then externally pipes it to a mail script in cron. The
script uses an external call to grep via subprocess, but I woul
Dear Python
I am trying to install pylab alongside python 3.6. However when I type
python -m pip install pylab
I get the message
No module named site
In the documentation [documentation for installing python modules in
python 3.6.0 documentation] it says: The above example assumes that the
opt
On Saturday, December 3, 2016 at 6:09:02 PM UTC-5, Robert wrote:
> Hi,
>
> I am trying to understand the meaning of the below code snippet. Though I have
> a Python IDLE at computer, I can't get a way to know below line:
>
> if k in [0, len(n_trials) - 1] else None
>
Hi,
I am trying to understand the meaning of the below code snippet. Though I have
a Python IDLE at computer, I can't get a way to know below line:
if k in [0, len(n_trials) - 1] else None
I feel it is strange for what returns when the 'if' condition is true?
The second part 'None' is clear to m
I would like to use pdb in an application where it isn't possible to use
sys.stdin for input. I've read in the documentation for pdb.Pdb that a file
object can be used instead of sys.stdin. Unfortunately, I'm not clear about my
options for the file object.
I've looked at rpdb on PyPI, which re
Hey all,
To clarify my title quickly, this survey is not about replacing pip, as yarn
(https://github.com/yarnpkg/yarn) did recently with npm. This is about helping
you throughout the lifespan of projects you maintain keep a handle on the
dependencies it has.
Where I work, we've already made s
--
https://mail.python.org/mailman/listinfo/python-list
Hi,
I was looking for search query in LDAP for nested group memebership.
It would be great if someone can provide the python code for the same.
Regards
--
https://mail.python.org/mailman/listinfo/python-list
Hi,
I have to find if user is the member of a group, for this i am using the
following query
(&(objectClass=user)(sAMAccountName=yourUserName)
(memberof=CN=YourGroup,OU=Users,DC=YourDomain,DC=com))
(memberof=CN=YourGroup,OU=Users,DC=YourDomain,DC=com)== values from
distinguished name of your
1 - 100 of 4293 matches
Mail list logo