elf.cache[key] = value
> return value
>
> Now it is easier to unit test, and the cache is not global. However, I
> cannot instantiate Lookup inside the while- or for- loops in main(),
> because the cache should be only one. I need to ensure there is only
> one instance of
On Tue, 12 Mar 2024 at 08:04, Ivan "Rambius" Ivanov
wrote:
> > A Singleton is just a global variable. Why do this? Did someone tell
> > you "global variables are bad, don't use them"?
>
> I have bad experience with global variables because it is hard to
> track what and when modifies them. I don't
(key) method
> > clumsy, because I have to clean it after each unit test. I refactored
> > it as:
> >
> > class Lookup:
> > def __init__(self):
> > self.cache = {}
> >
>
> Change "cache" to be a class-attribute (it is currentl
On Mon, Mar 11, 2024 at 5:01 PM Chris Angelico via Python-list
wrote:
>
> On Tue, 12 Mar 2024 at 07:54, Ivan "Rambius" Ivanov via Python-list
> wrote:
> > I am refactoring some code and I would like to get rid of a global
> > variable. Here is the outline:
> >
> > ...
> >
> > I have never done th
be a class-attribute (it is currently an instance.
Then, code AFTER the definition of Lookup can refer to Lookup.cache,
regardless of instantiation, and code within Lookup can refer to
self.cache as-is...
--
Regards,
=dn
--
https://mail.python.org/mailman/listinfo/python-list
On Tue, 12 Mar 2024 at 07:54, Ivan "Rambius" Ivanov via Python-list
wrote:
> I am refactoring some code and I would like to get rid of a global
> variable. Here is the outline:
>
> ...
>
> I have never done that in Python because I deliberately avoided such
> complicated situations up to now. I kn
logger.error("cmd returned error")
self.cache[key] = value
return value
Now it is easier to unit test, and the cache is not global. However, I
cannot instantiate Lookup inside the while- or for- loops in main(),
because the cache should be only one. I need to ensure there
I have a north viriginia ec2 linux instance and a windows machine at my home,
how do I connec tthem?
import paramiko
import time
def run_scripts():
# Set your local machine's SSH details
local_machine_ip = ' '
username = 'justk'
private_key_path =
Thank you.
> On 16 Nov 2023, at 21:30, Dieter Maurer wrote:
>
> Dom Grigonis wrote at 2023-11-16 21:11 +0200:
>> ...
>>> On 16 Nov 2023, at 21:00, Dieter Maurer wrote:
>>> ...
>>> Methods are not bound during instance creation, they are bound during
&g
Dom Grigonis wrote at 2023-11-16 21:11 +0200:
> ...
>> On 16 Nov 2023, at 21:00, Dieter Maurer wrote:
>> ...
>> Methods are not bound during instance creation, they are bound during
>> access.
>
>Good to know. What is the criteria for binding then? Does i
eal as there would be too much
>> overhead.
>>
>> I think what I am looking for is custom method binding.
>
> Methods are not bound during instance creation, they are bound during
> access.
Good to know. What is the criteria for binding then? Does it check if its
r is custom method binding.
Methods are not bound during instance creation, they are bound during
access.
You can use descriptors to implement "custom method binding".
Descriptors are defined on the class (and do not behave as
descriptors when defined on instances).
Thus, y
class method.
>
>I was wandering if there is an equivalent functionality of attribute to
>receive `instance` argument on instance creation.
As PEP 487 describes, `__set_name__` essentially targets descriptors.
It is there to inform a descriptor about the name it is used for
in a class (and
` argument.
>>
>> Thus, allowing simulation of bound class method.
>>
>> I was wandering if there is an equivalent functionality of attribute to
>> receive `instance` argument on instance creation.
>
> As PEP 487 describes, `__set_name__` essentially targets descriptor
of attribute to receive
`instance` argument on instance creation.
Regards,
DG
--
https://mail.python.org/mailman/listinfo/python-list
mple and Stupid (KISS)
--
Diego Souza
Wespa Intelligent Systems
Rio de Janeiro - Brasil
On Mon, Sep 19, 2022 at 1:00 PM wrote:
>
>
> From: "Weatherby,Gerard"
> Date: Mon, 19 Sep 2022 13:06:42 +
> Subject: Re: How to replace an instance method?
> Just subclass and over
On 9/19/22, 2qdxy4rzwzuui...@potatochowder.com
<2qdxy4rzwzuui...@potatochowder.com> wrote:
> On 2022-09-18 at 09:11:28 +,
> Stefan Ram wrote:
>
>> r...@zedat.fu-berlin.de (Stefan Ram) writes (abbreviated):
>> >types.MethodType( function, instance )
>> &g
On 2022-09-18 at 09:11:28 +,
Stefan Ram wrote:
> r...@zedat.fu-berlin.de (Stefan Ram) writes (abbreviated):
> >types.MethodType( function, instance )
> >functools.partial( function, instance )
> >new_method.__get__( instance )
>
> I wonder which of these th
On 9/18/22, Stefan Ram wrote:
> r...@zedat.fu-berlin.de (Stefan Ram) writes (abbreviated):
>>types.MethodType( function, instance )
>>functools.partial( function, instance )
>>new_method.__get__( instance )
>
> I wonder which of these three possibilities expresses
>
m 17.09.2022 um 00:35 schrieb Dan Stromberg:
On Fri, Sep 16, 2022 at 2:06 PM Ralf M. mailto:ral...@t-online.de>> wrote:
I would like to replace a method of an instance, but don't know how to
do it properly.
You appear to have a good answer, but... are you sure this is a good idea?
It
ivacy policy
https://www.solute.de/ger/datenschutz/grundsaetze-der-datenverarbeitung.php
Am 16.09.22 um 22:55 schrieb Ralf M.:
I would like to replace a method of an instance, but don't know how to do it
properly.
My first naive idea was
inst = SomeClass()
def new_method(self, param):
x27;s
accessed as a method of an instance of the class. In the class, that's
just a function object; it's exactly a function, not merely
fundamentally the same thing as one. It's only when accessed as an
attribute of an instance of the type that the function's descriptor
__get_
On Sun, 18 Sept 2022 at 10:29, wrote:
>
>
> From your description, Chris, it sounds like the functional programming
> technique often called currying. A factory function is created where one (or
> more) parameters are sort of frozen in so the user never sees or cares about
> them, and a modified o
ase, the
function now knows what object it is attached to as this.
-Original Message-
From: Python-list On
Behalf Of Chris Angelico
Sent: Saturday, September 17, 2022 8:21 PM
To: python-list@python.org
Subject: Re: How to replace an instance method?
On Sun, 18 Sept 2022 at 09:37, Eryk
ptor. Thus if a method object is set
> as an attribute of a type, the method does not rebind as a new method
> when accessed as an attribute of an instance of the type.
An unbound method in Python 2 was distinctly different from a
function, but in Python 3, they really truly are the same thing.
underlying function (i.e. the method's __func__), such as inspecting
the __name__ and __code__. A fundamental difference is that, unlike a
function, a method is not a descriptor. Thus if a method object is set
as an attribute of a type, the method does not rebind as a new method
when
On Sun, 18 Sept 2022 at 07:20, Ralf M. wrote:
>
> Am 16.09.2022 um 23:34 schrieb Eryk Sun:
> > On 9/16/22, Ralf M. wrote:
> >> I would like to replace a method of an instance, but don't know how to
> >> do it properly.
> >
> > A function is a descr
Am 17.09.2022 um 00:35 schrieb Dan Stromberg:
On Fri, Sep 16, 2022 at 2:06 PM Ralf M. <mailto:ral...@t-online.de>> wrote:
I would like to replace a method of an instance, but don't know how to
do it properly.
You appear to have a good answer, but... are you sure
Am 16.09.2022 um 23:34 schrieb Eryk Sun:
On 9/16/22, Ralf M. wrote:
I would like to replace a method of an instance, but don't know how to
do it properly.
A function is a descriptor that binds to any object as a method. For example:
>>> f = lambda self, x: self + x
Here is an example of probably the easiest way to add an instance method:
class Demo:
def sqr(self, x):
return x*x
# Function to turn into a instance method
def cube(self, x):
return x*x*x
d = Demo()
print(d.sqr(2))
d.cube = cube.__get__(d)
print(d.cube(3))
As for when
On Fri, Sep 16, 2022 at 2:06 PM Ralf M. wrote:
> I would like to replace a method of an instance, but don't know how to
> do it properly.
>
You appear to have a good answer, but... are you sure this is a good idea?
It'll probably be confusing to future maintainers of thi
On 9/16/22, Ralf M. wrote:
> I would like to replace a method of an instance, but don't know how to
> do it properly.
A function is a descriptor that binds to any object as a method. For example:
>>> f = lambda self, x: self + x
>>> o = 42
>&g
On Sat, 17 Sept 2022 at 07:07, Ralf M. wrote:
>
> I would like to replace a method of an instance, but don't know how to
> do it properly.
>
> My first naive idea was
>
> inst = SomeClass()
> def new_method(self, param):
> # do something
> return
I would like to replace a method of an instance, but don't know how to
do it properly.
My first naive idea was
inst = SomeClass()
def new_method(self, param):
# do something
return whatever
inst.method = new_method
however that doesn't work: self isn't passed as first p
> On 27 May 2022, at 21:17, Larry Martell wrote:
>
> I have a script that has literally been running for 10 years.
> Suddenly, for some runs it crashes with the error:
>
> terminate called after throwing an instance of
> 'boost::python::error_already_set
This is
; Suddenly, for some runs it crashes with the error:
> >
> > terminate called after throwing an instance of
> 'boost::python::error_already_set
> >
> > No stack trace. Anyone have any thoughts on what could cause this
> > and/or how
On Fri, May 27, 2022 at 5:51 PM dn wrote:
> On 28/05/2022 08.14, Larry Martell wrote:
> > I have a script that has literally been running for 10 years.
> > Suddenly, for some runs it crashes with the error:
> >
> > terminate called after throwing an i
On 28/05/2022 08.14, Larry Martell wrote:
> I have a script that has literally been running for 10 years.
> Suddenly, for some runs it crashes with the error:
>
> terminate called after throwing an instance of
> 'boost::python::error_already_set
>
> No stack trace. A
I have a script that has literally been running for 10 years.
Suddenly, for some runs it crashes with the error:
terminate called after throwing an instance of 'boost::python::error_already_set
No stack trace. Anyone have any thoughts on what could cause this
and/or how I can track it
server {
listen [::]:80;
listen 80;
server_name api.familie-liedtke.net;
location / {
return 301 https://$host$request_uri;
}
include /usr/local/etc/nginx/include/letsencrypt.conf;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name api.f
I think this is more a thing of apporach. Nginx is quite simple to
install and a config doing nothing else than redirecting https to https
and proxying requests to a service (whichever tat is, in your case
gunicorn) can become a nobrainer. That is what it became for me.
Additionally the config
req/res on Gunicorn
instance)
b) Scalability (proxy can spread traffic on several Gunicorn instances)
c) Maintenance (you can gracefully shutdown/restart Gunicorn instances one by
one)
d) Security (For example SSL certificate is configured in proxy only. There are
another useful features which
Thanks all. I was hoping to get away without something more
sophisticated like NGINX. This is just a piddly little archive of an
old mailing list running on a single-core Ubuntu VM somewhere on the
East Coast. Speed is not a real requirement. Load balancing seemed
like overkill to me. Still, I gues
I always use NGINX for this. Run Flask/Gunicorn on localhost:5000 and have
NGINX rewrite https requests to localhost requests. In nginx.conf I
automatically redirect every http request to https. Static files are
served by NGINX, not by Gunicorn, which is faster. NGINX also allows you
On Fri, Jan 07 2022 at 12:51:48 PM, Skip Montanaro
wrote:
> Hopefully some Pythonistas are also Gunicornistas. I've had little success
> finding help with a small dilemma in the docs or in other more specific
> sources.
>
> I'm testing out a new, small website. It is just Gunicorn+Flask. I'd like
Hopefully some Pythonistas are also Gunicornistas. I've had little success
finding help with a small dilemma in the docs or in other more specific
sources.
I'm testing out a new, small website. It is just Gunicorn+Flask. I'd like
to both listen for HTTP and HTTPS connections. Accordingly, in my co
t):
File "myclass.py", line 1, in
class MyClass:
ValueError: 'foo' in __slots__ conflicts with class variable
This is where the way of type declaration of instance variable comes from:
https://mypy.readthedocs.io/en/stable/cheat_sheet_py3.html
class MyClass:
# You can optiona
On 2019-07-02 3:41 PM, Adam Tauno Williams wrote:
On Tue, 2019-07-02 at 07:36 +0200, Frank Millman wrote:
On 2019-07-01 10:13 PM, Adam Tauno Williams wrote:
I am trying to connect to a Named Instance on an MS-SQL server
using pyODBC.
This is what I use -
conn = pyodbc.connect
On Tue, 2019-07-02 at 11:00 -0400, Adam Tauno Williams wrote:
> On Tue, 2019-07-02 at 09:41 -0400, Adam Tauno Williams wrote:
> > On Tue, 2019-07-02 at 07:36 +0200, Frank Millman wrote:
> > > On 2019-07-01 10:13 PM, Adam Tauno Williams wrote:
> > > > I am trying to
On Tue, 2019-07-02 at 09:41 -0400, Adam Tauno Williams wrote:
> On Tue, 2019-07-02 at 07:36 +0200, Frank Millman wrote:
> > On 2019-07-01 10:13 PM, Adam Tauno Williams wrote:
> > > I am trying to connect to a Named Instance on an MS-SQL server
> > > using pyODBC.
I
You may need to update your ODBC driver from version 13 to 17.x.
Malcolm
--
https://mail.python.org/mailman/listinfo/python-list
On Tue, 2019-07-02 at 07:36 +0200, Frank Millman wrote:
> On 2019-07-01 10:13 PM, Adam Tauno Williams wrote:
> > I am trying to connect to a Named Instance on an MS-SQL server
> > using pyODBC.
> This is what I use -
>
> conn = pyodbc.connect(
>
On 2019-07-01 10:13 PM, Adam Tauno Williams wrote:
I am trying to connect to a Named Instance on an MS-SQL server using
pyODBC.
The ODBC driver works, as I can connection without issue to a non-
named-instance SQL-Server used by another application.
What is the DSN (connection) string magick
I am trying to connect to a Named Instance on an MS-SQL server using
pyODBC.
The ODBC driver works, as I can connection without issue to a non-
named-instance SQL-Server used by another application.
What is the DSN (connection) string magick to connect to a named
instance?
I can connect from my
Chris Angelico於 2019年5月18日星期六 UTC+8下午3時09分37秒寫道:
> On Sat, May 18, 2019 at 1:51 PM wrote:
> >
> > Correct me if I am wrong, please.
> >
> > I always think that the LEGB rule (e.g. the namespace to look up for) was
> > applied at compile-time, only the binding was resolved "dynamically" at
> > ru
On Sat, May 18, 2019 at 1:51 PM wrote:
>
> Correct me if I am wrong, please.
>
> I always think that the LEGB rule (e.g. the namespace to look up for) was
> applied at compile-time, only the binding was resolved "dynamically" at
> run-time. For example:
>
> def foo():
> print(x)
>
> foo() wi
s.
>
> I have never run across this issue because I would never use the same name as
> an instance attribute and a class attribute.
I use this regularly.
Think of the "class attribute" as providing a default for
a potential "instance attribute" of the same na
ariable, or a global variable. It's more likely a class instance attribute,
and it's resolved by applying MRO rule dynamically.
--Jach
--
https://mail.python.org/mailman/listinfo/python-list
On 05/17/2019 11:37 AM, Irv Kalb wrote:
self.x = self.x + 1
I have never run across this issue because I would never use the same name as
an instance attribute and a class attribute.
So you treat your class attributes as if they were static?
--
~Ethan~
--
https://mail.python.org/mailman
lf.x can refer to different variables. I
> actually teach Python, and this would be a very difficult thing to explain to
> students.
>
> I have never run across this issue because I would never use the same name as
> an instance attribute and a class attribute. (I also know that "
> On May 15, 2019, at 5:41 PM, Ben Finney wrote:
>
> Irv Kalb writes:
>
>> I just saw some code that confused me. The confusion has to do with
>> class variables and instance variables.
>
> (Perhaps unrelated, but here's another confusion you may be suff
Irv Kalb writes:
> I just saw some code that confused me. The confusion has to do with
> class variables and instance variables.
(Perhaps unrelated, but here's another confusion you may be suffering
from: There's no such thing as a “class variable” or “instance
variabl
> On May 15, 2019, at 11:02 AM, Rob Gaddi
> wrote:
>
> On 5/15/19 10:52 AM, Irv Kalb wrote:
>> I just saw some code that confused me. The confusion has to do with class
>> variables and instance variables. In order to understand it better, I built
>> this ver
On 5/15/19 10:52 AM, Irv Kalb wrote:
I just saw some code that confused me. The confusion has to do with class
variables and instance variables. In order to understand it better, I built
this very small example:
class Test:
x = 0
def __init__(self, id):
self.id = id
I just saw some code that confused me. The confusion has to do with class
variables and instance variables. In order to understand it better, I built
this very small example:
class Test:
x = 0
def __init__(self, id):
self.id = id
self.show()
def show(self
Arup Rakshit writes:
> ...
> As you saw from documentation link, those are just words kind of spec.
> Which source you recommend to read which explains these concepts more with
> example codes.
I cannot help you much with this -- I am much turned towards
spec[ification] like documentation and ha
On 4/21/19, Arup Rakshit wrote:
>
> I am reading https://docs.python.org/3/reference/index.html now, and it
> seems like saying what Python can do, but not going deep to explain it
> to a new comers most of the time.
The guide to Python descriptors may help.
https://docs.python.org/3/howto/descr
p Rakshit writes:
>
>>> When an instance method object is created by retrieving a class method
>>> object from a class or instance, its __self__ attribute is the class
>>> itself, and its __func__ attribute is the function object underlying the
>>> class
Arup Rakshit writes:
>>When an instance method object is created by retrieving a class method
>> object from a class or instance, its __self__ attribute is the class itself,
>> and its __func__ attribute is the function object underlying the class
>> method.
>
>When an instance method object is created by retrieving a class method
> object from a class or instance, its __self__ attribute is the class itself,
> and its __func__ attribute is the function object underlying the class method.
Here I have 2 questions:
1. How do you create an
edShippingContainer._c_to_f(self.celsius)
> If I call `_c_to_f`, `_f_to_c` methods on `self` instead of
> `RefrigeratedShippingContainer` class object, still it works. So what is
> the reason behind of this calling on the class object, instead class
> instance object?
I don't know,
On 03/18/2019 07:09 PM, Ben Finney wrote:
> Arup Rakshit writes:
>
> Michael Torrie writes:
>
>> On 03/18/2019 05:55 PM, Ben Finney wrote:
If I call `_c_to_f`, `_f_to_c` methods on `self` instead of
`RefrigeratedShippingContainer` class object, still it works.
>>>
>>> That's right, an
Arup Rakshit writes:
Michael Torrie writes:
> On 03/18/2019 05:55 PM, Ben Finney wrote:
> >> If I call `_c_to_f`, `_f_to_c` methods on `self` instead of
> >> `RefrigeratedShippingContainer` class object, still it works.
> >
> > That's right, and is indeed the point of making a static method on
On 03/18/2019 05:55 PM, Ben Finney wrote:
>> If I call `_c_to_f`, `_f_to_c` methods on `self` instead of
>> `RefrigeratedShippingContainer` class object, still it works.
>
> That's right, and is indeed the point of making a static method on a
> class.
I'm confused. The methods that refer to
Refi
d function] can be called either on the
class (such as `C.f()`) or on an instance (such as `C().f()`). The
instance is ignored except for its class.
> So what is the reason behind of this calling on the class object,
> instead class instance object?
Whichever makes the most sense in th
t(self, value):
self.celsius = RefrigeratedShippingContainer._f_to_c(value)
If I call `_c_to_f`, `_f_to_c` methods on `self` instead of
`RefrigeratedShippingContainer` class object, still it works. So what is the
reason behind of this calling on the class object, instead class instance
On 2/1/19 7:15 AM, sinless...@gmail.com wrote:
Hello guys can you help me to solve problem when i compile proram got error like this
"Instance of 'dict' has no 'replace' member[no member](67;14)".
Python dicts don't have a replace method.
It looks like you&
Hello guys can you help me to solve problem when i compile proram got error
like this "Instance of 'dict' has no 'replace' member[no member](67;14)".
here you can see my code.
url = "http://mapa.um.warszawa.pl/mapviewer/foi";
querystring =
{"req
On 2018-12-17 21:57:22 +1100, Paul Baker wrote:
> class C:
> def __init__(self):
> self.__dict__['a'] = 1
>
> @property
> def a(self):
> return 2
>
> o = C()
> print(o.a) # Prints 2
What version of Python is this? I get a different res
On 2018-12-27 14:17:34 +0100, Peter J. Holzer wrote:
> On 2018-12-17 21:57:22 +1100, Paul Baker wrote:
> > class C:
> > def __init__(self):
> > self.__dict__['a'] = 1
> >
> > @property
> > def a(self):
> > return 2
> >
> > o = C()
> > pr
On Mon, Dec 17, 2018, 12:09 PM Paul Baker When Python looks up an attribute on an object (i.e. when it executes
> `o.a`), it uses an interesting priority order [1]. It looks for:
>
> 1. A class attribute that is a data-descriptor (most commonly a property)
> 2. An instance attribu
Paul Baker writes:
> When Python looks up an attribute on an object (i.e. when it executes
> `o.a`), it uses an interesting priority order [1]. It looks for:
>
> 1. A class attribute that is a data-descriptor (most commonly a property)
> 2. An instance attribute
> 3. Any oth
When Python looks up an attribute on an object (i.e. when it executes
`o.a`), it uses an interesting priority order [1]. It looks for:
1. A class attribute that is a data-descriptor (most commonly a property)
2. An instance attribute
3. Any other class attribute
We can confirm this using the
Very late to the party, but I just encountered a very similar problem and found
a solution:
```
import collections
obj = {"foo": "bar"}
isinstance(obj.values(), collections.abc.ValuesView) # => True
```
Hope that helps someone out there :)
On Thursday, November 17, 2016 at 9:09:23 AM UTC-8, Te
duncan smith wrote:
> On 02/12/2018 18:36, Peter Otten wrote:
>> class CommonMethods:
>> __add__ = add
> Ah, I could just bind them within the class,
>
> mean = mean
> max = max etc.
>
> but I'd somehow convinced myself that didn't work. As the names are the
> same I'd probably sti
On 02/12/2018 18:36, Peter Otten wrote:
> duncan smith wrote:
>
>> Hello,
>> I have a lot of functions that take an instance of a particular
>> class as the first argument. I want to create corresponding methods in
>> the class. I have tried the following, wh
On 02/12/2018 18:56, duncan smith wrote:
> Hello,
> I have a lot of functions that take an instance of a particular
> class as the first argument. I want to create corresponding methods in
> the class. I have tried the following, which (when called from __init__)
> creat
On 02/12/2018 18:26, Stefan Ram wrote:
> duncan smith writes:
>> I have tried to find examples of injecting methods into classes without
>
> Wouldn't the normal approach be to just define a
> class with your functions as instance methods?
>
> main.py
>
duncan smith wrote:
> Hello,
> I have a lot of functions that take an instance of a particular
> class as the first argument. I want to create corresponding methods in
> the class. I have tried the following, which (when called from __init__)
> creates the relevant methods
Hi Duncan.
On Sun, Dec 2, 2018 at 7:02 PM duncan smith wrote:
> Hello,
> I have a lot of functions that take an instance of a particular
> class as the first argument. I want to create corresponding methods in
> the class. I have tried the following, which (when called f
Hello,
I have a lot of functions that take an instance of a particular
class as the first argument. I want to create corresponding methods in
the class. I have tried the following, which (when called from __init__)
creates the relevant methods in an instance (Python 3.6).
def init_methods
e(A.foo) #
> > a.foo() # TypeError: foo() takes no arguments (1 given)
> > A.foo() # TypeError: unbound method foo() must be called
> > with A instance as first argument (got nothing instead)
> >
>
> There is a way in Python 2 as well, and I'm
iven)
> A.foo() # TypeError: unbound method foo() must be called
> with A instance as first argument (got nothing instead)
>
>
> Clearly, foo is an instance method. I know one should use @staticmethod for
> declaring a method static. The question here is, given the abo
foo() must be called
with A instance as first argument (got nothing instead)
Clearly, foo is an instance method.
It is either a buggy instance method, missing the required first
parameter, *or* a buggy static method, missing the decorator, making it
appear to the interpreter as an instance metho
() # TypeError: unbound method foo() must be called
> with A instance as first argument (got nothing instead)
>
>
> Clearly, foo is an instance method. I know one should use @staticmethod for
> declaring a method static. The question here is, given the above code, is
> th
class A:
def foo():
print 'Hello, world!'
a = A()print A.foo # print a.foo #
>print
type(A.foo) #
a.foo() # TypeError: foo() takes no arguments (1 given)
A.foo() # TypeError: unbound method foo() must be called
with A instance as first
On Tue, Sep 4, 2018 at 5:47 PM, Cameron Simpson wrote:
>
> The downside with mkdir, and also with pd files really, is that a program or
> OS abort can leave them lying around. Being persistent objects, some kind of
> cleanup is needed.
While the OP needs a cross-platform solution, if it's just Wi
On 03Sep2018 07:45, Malcolm Greene wrote:
>Use case: Want to prevent 2+ instances of a script from running ...
>ideally in a cross platform manner. I've been researching this topic and
>am surprised how complicated this capability appears to be and how the
>diverse the solution set is. I've seen s
On 09/04/2018 05:35 AM, Cameron Simpson wrote:
> On 03Sep2018 07:45, Malcolm Greene wrote:
>> Use case: Want to prevent 2+ instances of a script from running ...
>> ideally in a cross platform manner. I've been researching this topic and
>> am surprised how complicated this capability appears to b
What about using flock()? I don't know if it works on Windows, but it works
really well for Unix/Linux systems. I typically create a log file in a known
location using any atomic method that doesn't replace/overwrite a file, and
flock() it for the duration of the script.
Thanks,
Cem Karan
On Mon
1 - 100 of 2063 matches
Mail list logo