Re: Question on difference between LambdaType and FunctionType

2018-11-27 Thread Iwo Herka
Ian Kelly wrote: > What about: > > __init__ = lambda self: setattr(self, 'foo', 'bar') That's an edge-case alright. Fortunately, I've decided to not skip lambdas. That's too problematic, it's easier to parse them as a special-case. Th

Re: Question on difference between LambdaType and FunctionType

2018-11-25 Thread Iwo Herka
Chris Angelico wrote: > look for a STORE_ATTR opcode. If there aren't any, there can't > be any "self.foo = bar". (You can't be certain of the converse, as > "other_object.foo = bar" will also show up as STORE_ATTR.) This very useful, I will look into

Re: Question on difference between LambdaType and FunctionType

2018-11-25 Thread Iwo Herka
> class Foo: >def setup(self): ... >__init__ = lambda self: self.setup() Sorry, didn't address this. This is fine too, since I'm assuming that only methods named __init__ are allowed to mutate the object. Because 'setup' is not '__init__' it's d

Re: Question on difference between LambdaType and FunctionType

2018-11-25 Thread Iwo Herka
to mutate the object from lambda. Sincerely, Iwo Herka -- https://mail.python.org/mailman/listinfo/python-list

Re: Question on difference between LambdaType and FunctionType

2018-11-25 Thread Iwo Herka
27;m treating FunctionType and LambdaType differently (I don't have to instrument lambdas, I can just return them), I have to know which one is it. Note: I know that there is a strong argument against using all this hackery, however, I'm partly experimenting in an attempt to learn s

Re: Question on difference between LambdaType and FunctionType

2018-11-25 Thread Iwo Herka
ied to use LambdaType and, to my surprise, it didn't do the job. Sincerely, Iwo Herka niedz., 25 lis 2018 o 20:41 Chris Angelico napisał(a): > > On Mon, Nov 26, 2018 at 6:06 AM Iwo Herka wrote: > > > > Hello, > > > > Can someone please provide a use-case for h

Question on difference between LambdaType and FunctionType

2018-11-25 Thread Iwo Herka
: ... What am I missing? Sincerely, Iwo Herka -- https://mail.python.org/mailman/listinfo/python-list

Re: Question about implementing immutability

2018-11-22 Thread Iwo Herka
;t work with super-classes because of recursion, i.e. I would unset the flag, call super and super would set the flag back on its way out. Sincerely, Iwo Herka -- https://mail.python.org/mailman/listinfo/python-list

Re: Question about implementing immutability

2018-11-22 Thread Iwo Herka
ng approximating generic solution for arbitrary user-defined classes. Sincerely, Iwo Herka -- https://mail.python.org/mailman/listinfo/python-list

Re: Question about implementing immutability

2018-11-22 Thread Iwo Herka
gt; This way, a "__setattr__" has an easy way to recognize the initialization > phase. The approach above, would not work for recursively called > "__init__" methods - but hopefully, such "__init__" implementations > are extremely rare. Instrumentation seems more tricky, but I didn't think of this edge-case. Thank you for pointing this out. Sincerely, Iwo Herka -- https://mail.python.org/mailman/listinfo/python-list

Question about implementing immutability

2018-11-21 Thread Iwo Herka
getframe(1).f_code.co_name == '__init__': return super().__setattr__(*args, **kwargs) raise AttributeError() What do you think of this approach? Is there a better one? Thanks. Sincerely, Iwo Herka -- https://mail.python.org/mailman/listinfo/python-list

Re: Question about the definition of the value of an object

2018-11-19 Thread Iwo Herka
27;s > value is whatever it is equal to. > Generally, Python objects have their values defined by an abstract > concept that is being represented. That confirms my intuition. Thank you for the responses. Sincerely, Iwo Herka pon., 19 lis 2018 o 20:46 Chris Angelico napisał(a): > > On

Question about the definition of the value of an object

2018-11-19 Thread Iwo Herka
e value of type "Ellipsis", which is the object accessed via built-in name "Ellipsis". 3. Value of the object "Ellipsis" is a unique value denoting the omission from speech or writing. Do I have it all backwards or am I missing something obvious here? Thank you. Sincerely, Iwo Herka -- https://mail.python.org/mailman/listinfo/python-list

Re: Checking whether type is None

2018-07-24 Thread Iwo Herka
In Python 2, you can import NoneType from types module. In Python 3, the best you can do is: NoneType = type(None) ​Iwo Herka https://github.com/IwoHerka​ ‐‐‐ Original Message ‐‐‐ On 24 July 2018 7:33 PM, Tobiah wrote: > ​​ > > Consider: > > >>> type({

Re: list of lists

2018-07-22 Thread Iwo Herka
b = pair which is equivalent to this: a = pair[0] b = pair[1] If you're not sure how many items you have in a list, you can use an asterisk operator: li = [1, 2, 3, 4] a, b, *c = li which is equivalent to: a = li[0] b = li[1] c = li[2:] ​Iwo Herka https://git

Re: list of lists

2018-07-22 Thread Iwo Herka
You can simply unpack the inner list: a, b = results[0] Iwo Herka ‐‐‐ Original Message ‐‐‐ On 22 July 2018 11:47 AM, Sharan Basappa wrote: > ​​ > > I am using a third party module that is returning list of lists. > > I am using the example below to illustrate.

Re: Unable to install latest version of a package via pip from PyPI

2018-07-20 Thread Iwo Herka
Oh. It took a while for the message to go through. In the meantime I've discovered that the source-code archive was badly formatted. Probably something with venv. I've bumped the patch version and re-uploaded. Sorry and thank you. Iwo Herka Original Message On 20 J

Unable to install latest version of a package via pip from PyPI

2018-07-20 Thread Iwo Herka
.11.0. wheel version is 0.31.1. I've tried installing with pip version 8.1.1 and 9.0.1. I'm also able to install the package directly from GitHub without problems. setup.py install works too. I'm using venv and pyenv. Am I missing something obvious? Thank you. Iwo Herka -- htt