[issue33935] shutil.copyfile throws incorrect SameFileError on Google Drive File Stream

2019-02-17 Thread gary ruben


gary ruben  added the comment:

I wanted to add a datapoint to this. I also experience this problem in Windows 
but not with Google Drive File Stream. In my case it is also being triggered by 
Jupyter, which was where Deniz first noticed it, but I was saving the notebook 
to my Z: drive, which is a mapping of a network drive that is backed up with 
Windows' Sync Center; nothing to do with Google's file stream, but a standard 
Windows feature that triggers the same bug. For the moment, I find that Deniz's 
workaround lets me continue to use Jupyter in conjunction with that drive path.

--
nosy: +gary ruben

___
Python tracker 
<https://bugs.python.org/issue33935>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: class factory example needed (long)

2005-03-03 Thread Gary Ruben
Thanks Steven and Kent, both of your suggestions look good to me. I'll 
try both out and pick one.
Gary

Gary Ruben wrote:
OK, I've managed to get this to work with Rainer's method, but I 
realised it is not the best way to do it, since the methods are being 
added by the constructor, i.e. they are instance methods. This means 
that every time a foo object is created, a whole lot of code is being 
run. It would be better to do the same thing with class 'static' 
methods, if this is possible, so that the methods are created just once.
Is this possible?
Gary
--
http://mail.python.org/mailman/listinfo/python-list


Re: class factory example needed (long)

2005-03-01 Thread Gary Ruben
OK, I've managed to get this to work with Rainer's method, but I 
realised it is not the best way to do it, since the methods are being 
added by the constructor, i.e. they are instance methods. This means 
that every time a foo object is created, a whole lot of code is being 
run. It would be better to do the same thing with class 'static' 
methods, if this is possible, so that the methods are created just once.
Is this possible?
Gary

Rainer Mansfeld wrote:
snip
If OTOH you want your foo class to have sqrt, arccos, etc. methods 
without defining them explicitly, I think you're looking for something 
like:

. import Numeric
.
. class Foo(object):
. def __init__(self, value):
. self.value = float(value)
. for u in ['sqrt', 'cos', 'tan']:
. setattr(self, u, lambda uf=getattr(Numeric, u):
.  uf(self.value + 42.0))
  f = Foo(7)
  f.sqrt()
7.0
HTH
  Rainer
--
http://mail.python.org/mailman/listinfo/python-list


Re: class factory example needed (long)

2005-02-28 Thread Gary Ruben
Thanks for the very helpful reply Rainer,
I thought I couldn't use setattr because I need the syntactic sugar 
sqrt(f) to work, but with your example code Numeric.sqrt(f) does in fact 
work correctly. I also need to do a bit more than may be possible with a 
simple lambda function, but I should be able to sort it out from here 
with the info you provided,
thanks again,
Gary

Rainer Mansfeld wrote:
snip
Hi Gary,
you want your 'class factory' to change the methods of Numeric, so that 
they accept foo objects and return foo objects?
I've not the slightest idea how to achieve that.

If OTOH you want your foo class to have sqrt, arccos, etc. methods 
without defining them explicitly, I think you're looking for something 
like:

. import Numeric
.
. class Foo(object):
. def __init__(self, value):
. self.value = float(value)
. for u in ['sqrt', 'cos', 'tan']:
. setattr(self, u, lambda uf=getattr(Numeric, u):
.  uf(self.value + 42.0))
  f = Foo(7)
  f.sqrt()
7.0
HTH
  Rainer
--
http://mail.python.org/mailman/listinfo/python-list


class factory example needed (long)

2005-02-26 Thread Gary Ruben
I have a class factory problem. You could say that my main problem is
that I don't understand class factories.
My specific problem:
I have a class with several methods I've defined.
To this class I want to add a number of other class methods where the
method names are taken from a list.
For each list member, I want to build a method having the list member
name so that I can override another method of the same name for objects
which are instances of this class. Finally, I want my class factory
which creates the method to call the overridden method.
I'm sure my description is confusing, so I'll try to illustrate it.
import Numeric
# The Numeric module contains a whole lot of methods which operate on
certain number types
class foo:
 this is a number type class

def __init__(self, value):
self.value = float(value)
def __str__(self):
.
. other methods here
.
import string
ufuncs = string.split(
sqrt arccos arccosh arcsin arcsinh arctan arctanh cos cosh tan tanh
log10 sin sinh sqrt absolute fabs floor ceil fmod exp log conjugate
)# these are the methods from Numeric that I want to
override/wrap for my number type
for u in ufuncs:
I need something here which builds methods called sqrt(),
arccos(), etc.
An illustrative example of the class methods I want to build with
some sort of class factory is
def sqrt(self):
val = Numeric.sqrt(self.value)
return foo(Numeric.sqrt(self.value) + 42)
def arccos(self):
val = Numeric.arccos(self.value)
return foo(Numeric.arccos(self.value) + 42)
if __name__ == __main__:
a = 9
b = foo(7)
print Numeric.sqrt(a)
print Numeric.sqrt(b)
This would print
3
7
Note that the methods I want to create under program control are all
identical in form. In this example they all call the wrapped method with
an argument 42 greater than the value of the number.
Does anyone have an example where they've done something similar or
could help me out with an example?
thanks in anticipation,
Gary
--
http://mail.python.org/mailman/listinfo/python-list