PyQt: viewport vs window - how do you translate co-ordinates?

2017-09-23 Thread Veek M
pg 329, Rapid GUI Programming http://storage4.static.itmages.com/i/17/0923/h_1506165624_2588733_59fdfcd4cc.png In PyQt terminology the physical coordinate system is called the “viewport”, and confusingly, the logical coordinate system is called the “window”. In Figure 11.4, w

Re: PyQt: viewport vs window - how do you translate co-ordinates?

2017-09-24 Thread Veek M
On Saturday, September 23, 2017 at 8:44:25 PM UTC+5:30, Michael Torrie wrote: > On 09/23/2017 05:38 AM, Veek M wrote: > > I didn't understand any of that - could someone expand on that para? > > Is there a reading resource that explains the Viewport and translations? I > &

PyQt: Parenting a Widget

2017-09-25 Thread Veek M
Summary: Could someone explain widget and dialog parenting - the text book is not making sense. ## I'm trying to understand widget parenting, from the book: Rapid GUI Programming, pg 118, and thereabouts - he says: A. All PyQt classes that derive from QObjectand this includes

Re: PyQt: Parenting a Widget

2017-09-25 Thread Veek M
On Tuesday, September 26, 2017 at 11:18:54 AM UTC+5:30, Veek M wrote: > Summary: Could someone explain widget and dialog parenting - the text book is > not making sense. > ## > I'm trying to understand widget parenting, from the book: Rapid GUI > Prog

Re: PyQt: Parenting a Widget

2017-09-26 Thread Veek M
On Tuesday, September 26, 2017 at 2:23:22 PM UTC+5:30, Thomas Jollans wrote: > On 2017-09-26 08:16, Veek M wrote: > > On Tuesday, September 26, 2017 at 11:18:54 AM UTC+5:30, Veek M wrote: > >> Summary: Could someone explain widget and dialog parenting - the text book > &

Pandas: How does df.apply(lambda work to create a result

2021-05-26 Thread Veek M
t = pd.DataFrame([[4,9],]*3, columns=['a', 'b']) a b 0 4 9 1 4 9 2 4 9 t.apply(lambda x: [x]) gives a[[1, 2, 2]] b[[1, 2, 2]] How?? When you 't' within console the entire data frame is dumped but how are the individual elements passed into .apply()? I can't do lambda x,y: [x,y]

Re: Selenium script - stuck - could someone take a look?

2021-05-29 Thread Veek M
On 2021-05-29, Veek M wrote: fixed div './/' vs '//' -- https://mail.python.org/mailman/listinfo/python-list

Selenium script - stuck - could someone take a look?

2021-05-29 Thread Veek M
Script: http://paste.debian.net/1199271/ It mostly works but line 78 is supposed to extract 100 pieces / lot No matter what I try it's failed and I DON'T KNOW WHY? It's a simple div.classname match.. Could someone take a look and figure it out - I'm stuck. --

Re: Selenium script - stuck - could someone take a look?

2021-05-29 Thread Veek M
On 2021-05-29, Dennis Lee Bieber wrote: > On Sat, 29 May 2021 09:40:35 - (UTC), Veek M declaimed > the following: > ah, yeah - man that took me a while to do (save to local file and use file:///). It's working now, basically xpath mistake because I've forgotten stuff.

Tree library that allows conditions on nodes and will return the node

2021-06-14 Thread Veek M
LibreOffice has a huge class tree and I need to familiarize myself with it - trouble is, it won't fit on A4 because it has a flat hierarchy with loads of leaf nodes. I wanted to shove all the leaf nodes > x into a subgraph and style that differently using Graphviz. I tried treelib but while i can

Extend unicodedata with a name/pattern/regex search for character entity references?

2016-09-03 Thread Veek. M
https://mail.python.org/pipermail//python-ideas/2014-October/029630.htm Wanted to know if the above link idea, had been implemented and if there's a module that accepts a pattern like 'cap' and give you all the instances of unicode 'CAP' characters. ⋂ \bigcap ⊓ \sqcap ∩ \cap ♑ \capricornus

Re: Extend unicodedata with a name/pattern/regex search for character entity references?

2016-09-03 Thread Veek. M
Thomas 'PointedEars' Lahn wrote: > Veek. M wrote: > >> https://mail.python.org/pipermail//python-ideas/2014-October/029630.htm >> >> Wanted to know if the above link idea, > > … which is 404-compliant; the Internet Archive does not have it either >

Re: Extend unicodedata with a name/pattern/regex search for character entity references?

2016-09-04 Thread Veek. M
Steve D'Aprano wrote: > On Sun, 4 Sep 2016 06:53 pm, Thomas 'PointedEars' Lahn wrote: > >>> Regarding the name (From field), my name *is* Veek.M […] >> >> Liar. *plonk* > > You have crossed a line now Thomas. > > That is absolutely uncalled for. You have absolutely no legitimate > reason to b

Re: Extend unicodedata with a name/pattern/regex search for character entity references?

2016-09-05 Thread Veek. M
ne's posted identifier. > > In fact, I have recommended doing that several times to people who > only used their nickname in the “From” header field value. > >> So Veek should be able to appease P.E. by calling >> himself 'Veek "David Smith" M'. >

Pasting code into the cmdline interpreter

2016-09-21 Thread Veek M
I wanted to test this piece of code which is Kate (editor) on the cmd line python >>> prompt: tex_matches = re.findall(r'(\\\w+{.+?})|(\\\w+)', msg) for tex_word in tex_matches: repl = unicode_tex.tex_to_unicode_map.get(tex_word) if repl is None: repl = 'err' msg = re.sub(re.e

Re: Pasting code into the cmdline interpreter

2016-09-21 Thread Veek M
Ben Finney wrote: > Veek M writes: > >> 1. I had to turn on highlighting to catch mixed indent (which >> is a good thing anyways so this was resolved - not sure how tabs got >> in anyhow) > > The EditorConfig system is a growing consensus for configuring a code &

Re: Pasting code into the cmdline interpreter

2016-09-22 Thread Veek M
eryk sun wrote: > On Thu, Sep 22, 2016 at 5:12 AM, Veek M wrote: >> 2. Blank lines in my code within the editor are perfectly acceptable >> for readability but they act as a block termination on cmd line. > > You can write a simple paste() function. For example: > >

Re: Pasting code into the cmdline interpreter

2016-09-22 Thread Veek M
Ben Finney wrote: > Veek M writes: > >> Ben Finney wrote: >> >> > Since you are writing code into a module file, why not just run the >> > module from that file with the non-interactive Python interpreter? >> > >> It's part of a hexcha

h(re) for help, import re - on NameError

2016-09-22 Thread Veek M
Is there a way to use .pythonrc.py to provide a help function that autoloads whatever module name is passed like so: \>>> h(re) I tried inheriting site._Helper and overriding __init__ and __call__ but that didn't work, also I don't know how to deal/trap/catch the NameError (no quotes on h(re))

Re: Pasting code into the cmdline interpreter

2016-09-22 Thread Veek M
eryk sun wrote: > On Thu, Sep 22, 2016 at 12:40 PM, Gregory Ewing > wrote: >> eryk sun wrote: >>> >>> Actually in a Unix terminal the cursor can also be at >>> the end of a line, but a bug in Python requires pressing Ctrl+D >>> twice in that case. >> >> I wouldn't call that a bug, rather it's a c

Re: h(re) for help, import re - on NameError

2016-09-22 Thread Veek M
Chris Angelico wrote: > On Thu, Sep 22, 2016 at 8:10 PM, Veek M wrote: >> Is there a way to use .pythonrc.py to provide a help function that >> autoloads whatever module name is passed like so: >> \>>> h(re) >> >> I tried inheriting site._Helper and ov

PyQT - Signals and Slots?

2016-10-10 Thread Veek M
I'm reading Rapid GUI Programming - Mark Summerfield with Python and QT pg 131. Basically the mechanism is an event table which maps a 'signal' to a 'function/slot' -correct? self.connect(dial, SIGNAL("valueChanged(int)"), spinbox.setValue) Here, dial.valueChanged -> spinbox.setValue s.conn

Re: PyQT - Signals and Slots?

2016-10-10 Thread Veek M
Mark Summerfield wrote: > > The ZeroSpinBox is a tiny example designed to show how the signal/slot > mechanism works. It is just a QSpinBox with the addition of > remembering how many times (all the) ZeroSpinBox(es) have had a 0 > value. > > Nowadays the connections would be made with a new impr

Re: Iteration, while loop, and for loop

2016-10-27 Thread Veek M
Elizabeth Weiss wrote: > words=["hello", "world", "spam", "eggs"] > counter=0 > max_index=len(words)-1 > > while counter<=max_index: > word=words[counter] > print(word + "!") > counter=counter + 1 while 0 < 10: get 0'th element do something with element increment 0 to 1 (repeat) words[0

Re: Windows switch between python 2 and 3

2016-10-27 Thread Veek M
Daiyue Weng wrote: > Hi, I installed Python 2.7 and Python 3.5 64 bit versions on Win 10. > Under > > C:\Python35 > > C:\Python27 > > Both have been set in environment variable Path. > > When I type python in cmd, it only gives me python 2.7, I am wondering > how to switch between 2 and 3 in c

Re: problem using pickle

2016-10-27 Thread Veek M
Rustom Mody wrote: > On Saturday, July 2, 2016 at 9:17:01 AM UTC+5:30, Veek. M wrote: >> object is a keyword and you're using it as an identifier > > keyword and builtin are different > In this case though the advice remains the same > In general maybe not... >

Re: problem using pickle

2016-10-27 Thread Veek M
Ben Finney wrote: > "Veek. M" writes: > >> class Foo(object): >> pass >> >> object is a keyword and you're using it as an identifier > > Python does not have ‘object’ as a keyword. ‘and’ is a keyword. > > Here's the differenc

Re: Need help in python program

2016-10-29 Thread Veek M
id_1, clk, val = foo_function() id_2, key, units, delay = bar_function() if id_1 == id_2: print id_1, clk, val, key, units, delay -- https://mail.python.org/mailman/listinfo/python-list

Re: Web Scraping

2016-11-12 Thread Veek M
121sukha wrote: > I am new to python and I want to use web scraping to download songs > from website. how do I write code to check if the website has uploaded > a new song and have that song automatically be downloaded onto my > computer. I know how to use the requests.get() module but i am more >

Re: Web Scraping

2016-11-12 Thread Veek M
Steve D'Aprano wrote: > On Sat, 12 Nov 2016 11:07 pm, Veek M wrote: > >> 121sukha wrote: >> >>> I am new to python and I want to use web scraping to download songs >>> from website. how do I write code to check if the website has >>> uploa

__debug__ http://stackoverflow.com/questions/15305688/conditional-debug-statement-not-executed-though-debug-is-true

2016-11-15 Thread Veek M
Trying to make sense of that article. My understanding of debug was simple: 1. __debug__ is always True, unless -O or -OO 2. 'if' is optimized out when True and the expr is inlined. So what does he mean by: 1. 'If you rebind __debug__, it can cause symptoms' 2. 'During module compilation, the sa

Re: __debug__ http://stackoverflow.com/questions/15305688/conditional-debug-statement-not-executed-though-debug-is-true

2016-11-15 Thread Veek M
Veek M wrote: > Trying to make sense of that article. My understanding of debug was > simple: > 1. __debug__ is always True, unless -O or -OO > 2. 'if' is optimized out when True and the expr is inlined. > > So what does he mean by: > > 1. 'If you rebin

What exactly is a python variable?

2016-11-16 Thread Veek M
In C: int x = 10; results in storage being allocated and type and location are fixed for the life of the program. In Python, x = 10 causes an object '10' to be created but how exactly is 'x' handled? Symbol Table lookup at compile time? Is every 'x' being substituted out of existence? Becaus

What is the difference between class Foo(): and class Date(object):

2016-11-21 Thread Veek M
>>> class Foo(): ... pass ... >>> class Bar(Foo): ... pass ... >>> b = Bar() >>> type(b) >>> class Date(object): ... pass ... >>> class EuroDate(Date): ... pass ... >>> x = EuroDate() >>> type(x) What is going on here? Shouldn't x = EuroDate(); type(x) give 'instance'?? Why is 'b' an

Re: What is the difference between class Foo(): and class Date(object):

2016-11-21 Thread Veek M
Steve D'Aprano wrote: > On Mon, 21 Nov 2016 11:15 pm, Veek M wrote: > >>>>> class Foo(): >> ... pass >> ... >>>>> class Bar(Foo): >> ... pass >> ... >>>>> b = Bar() >>>>> type(b) >> >

dictionary mutability, hashability, __eq__, __hash__

2016-11-27 Thread Veek M
I was reading this: http://stackoverflow.com/questions/4418741/im-able-to-use-a-mutable-object-as-a-dictionary-key-in-python-is-this-not-disa In a User Defined Type, one can provide __hash__ that returns a integer as a key to a dictionary. so: d = { key : value } What is the significance of __

Re: dictionary mutability, hashability, __eq__, __hash__

2016-11-27 Thread Veek M
Jussi Piitulainen wrote: > Veek M writes: > > [snip] > >> Also if one can do x.a = 10 or 20 or whatever, and the class instance >> is mutable, then why do books keep stating that keys need to be >> immutable? After all, __hash__ is the guy doing all the work and

Re: dictionary mutability, hashability, __eq__, __hash__

2016-11-27 Thread Veek M
Veek M wrote: > Jussi Piitulainen wrote: > >> Veek M writes: >> >> [snip] >> >>> Also if one can do x.a = 10 or 20 or whatever, and the class >>> instance is mutable, then why do books keep stating that keys need >>> to be >>>

Re: variable argument unpacking

2016-12-04 Thread Veek M
Peter Otten wrote: > Mehrzad Irani wrote: > >> Hi All, >> >> Consider the situation >> [cti@iranim-rhel python_cti]$ cat a.py >> def a(a = 1, b = 2, c = 3, *d, **e): >> print(a, b, c) >> print(d) >> print(e) >> >> r = {'e': 7, 'f': 8, 'g': 9} >> >> >> a(**r) >> a(3, **

Re: Working around multiple files in a folder

2016-12-08 Thread Veek M
Emile van Sebille wrote: > On 11/21/2016 11:27 AM, subhabangal...@gmail.com wrote: >> I have a python script where I am trying to read from a list of files >> in a folder and trying to process something. As I try to take out the >> output I am presently appending to a list. >> >> But I am trying t

Re: Simple code and suggestion

2016-12-08 Thread Veek M
g thakuri wrote: > Dear Python friends, > > I have a simple question , need your suggestion the same > > I would want to avoid using multiple split in the below code , what > options do we have before tokenising the line?, may be validate the > first line any other ideas > > cmd = 'utility %

% string formatting - what special method is used for %d?

2016-12-09 Thread Veek M
When we do: print '%s %d' % ('hello', 10) what special method is being invoked internally within the string- format-specifier? format() invokes format__ print invokes __str__ I'm basically trying to make sense of: raise TypeError('urkle urkle %s' % list(dictionary)) <=> raise TypeError('urkle

Re: % string formatting - what special method is used for %d?

2016-12-10 Thread Veek M
Steve D'Aprano wrote: > On Sat, 10 Dec 2016 06:06 pm, Veek M wrote: > >> When we do: >> >> print '%s %d' % ('hello', 10) >> >> what special method is being invoked internally within the string- >> format-specifier? > &

Re: % string formatting - what special method is used for %d?

2016-12-11 Thread Veek M
Ian Kelly wrote: > On Sat, Dec 10, 2016 at 11:40 PM, Veek M wrote: >> Well take a look at this: >> ### >> #!/usr/bin/python >> >> class Foo(int): >> def __init__(self, value): >> self.value = value

Nested functions, how do they work (stack related)

2016-12-12 Thread Veek M
I was reading the wiki on 'Call stack' because I wanted to understand what a traceback object was. My C/C++ isn't good enough to deal with raw python source since I have no background in CS. Also, you just can't dive into the python src - it takes a good deal of reading and background.. (the ty

Re: Nested functions, how do they work (stack related)

2016-12-13 Thread Veek M
Veek M wrote: > I was reading the wiki on 'Call stack' because I wanted to understand > what a traceback object was. My C/C++ isn't good enough to deal with > raw python source since I have no background in CS. Also, you just > can't dive into the python src - it

Re: Nested functions, how do they work (stack related)

2016-12-13 Thread Veek M
http://web.archive.org/web/20111030134120/http://www.sidhe.org/~dan/blog/archives/000211.html (great tail recursion article - best i've seen! SO doesn't really explain it unless you already knew it to begin with, but here's the link:http://stackoverflow.com/questions/310974/what-is-tail-call-opti

Re: Nested functions, how do they work (stack related)

2016-12-13 Thread Veek M
Marko Rauhamaa wrote: > Veek M : > >> https://en.wikipedia.org/wiki/Call_stack >> >> 'Programming languages that support nested subroutines also have a >> field in the call frame that points to the stack frame of the latest >> activation of the pro

Is there a way to insert hooks into a native dictionary type to see when a query arrives and what's looked up?

2016-12-13 Thread Veek M
I know that with user classes one can define getattr, setattr to handle dictionary lookup. Is there a way to hook into the native dict() type and see in real time what's being queried. I wanted to check if when one does: x.sin() if the x.__dict__ was queried or if the Foo.__dict__ was queried.

Re: Is there a way to insert hooks into a native dictionary type to see when a query arrives and what's looked up?

2016-12-16 Thread Veek M
Steven D'Aprano wrote: > On Wednesday 14 December 2016 17:11, Veek M wrote: > >> I know that with user classes one can define getattr, setattr to >> handle dictionary lookup. Is there a way to hook into the native >> dict() type and see in real time what's b

super and mix-in class: how exactly is the search order altered?

2016-07-01 Thread Veek. M
I had posted this on StackOverflow - it's an excellent example of why SO sucks (don't want that happening here so please read carefully): http://stackoverflow.com/questions/38145818/super-and-mix-in-class-how-exactly-is-the-search-order-altered?noredirect=1#comment63722336_38145818 I'm reading

Re: why x is changed in the following program?

2016-07-01 Thread Veek. M
maurice.char...@telecom-paristech.fr wrote: > from numpy import random > x=random.randn(6) > y=x > y[0]=12 > print x[0] > > > random.rand returns a list. x is a label to this list (container). y=x creates another label to the same container/list. y[0[ = 12 alters the 0th position of the conta

Re: subprocess startup error

2016-07-01 Thread Veek. M
Shweta Dinnimani wrote: > hi > > hello, I'm begineer to python programming.. I had installed python > 3.5.1 version on my windows 7 system. I was fine earlier and now when > i was trying the programs on string i'm facing the subprocess startup > error. IDLE is not connecting. And python shell is

Re: problem using pickle

2016-07-01 Thread Veek. M
Nicky Mac wrote: > Dear Python team, > I have studied the excellent documentation, and attempted to make use > of pickle thus: > > filename = 'my_saved_adventure' > import pickle > class object: > def __init__(self,i,.t) : > self.id = i > . > > class world

Descriptor: class name precedence over instance name

2016-07-01 Thread Veek. M
Trying to make sense of this para: -- Also, the attribute name used by the class to hold a descriptor takes prece- dence over attributes stored on instances. In the previous example, this is why the descriptor object takes a name parameter and why

Re: Descriptor: class name precedence over instance name

2016-07-02 Thread Veek. M
Ben Finney wrote: > "Veek. M" writes: > >> Trying to make sense of this para: > > At the risk of being ruse, I am trying to make sense of some > paragraphs in the messages you write here. Could you take a little > more time to write clearly, as a way of commun

Re: Descriptor: class name precedence over instance name

2016-07-03 Thread Veek. M
Ian Kelly wrote: > On Sat, Jul 2, 2016 at 3:34 AM, Veek. M wrote: >> So essentially from what Ian said: >> data_descriptor_in_instance -> instance_attribute -> non- >> data_descriptor_in_instance -->__mro__ >> >> is how the search takes place. Co

Re: super and mix-in class: how exactly is the search order altered?

2016-07-03 Thread Veek. M
dieter wrote: > "Veek. M" writes: >> ... >> I'm reading this article: >> https://rhettinger.wordpress.com/2011/05/26/super-considered-super/ >> >> He's trying to explain the purpose of a 'mix-in class' and he says >>

subprocess: xterm -c cat, need to send data to cat and have it displayed in the xterm window

2016-07-11 Thread Veek. M
Script grabs some image data and runs imagemagick on it to extract some chinese. Then tesseract OCR to get the actual unicode. I then need to get it translated which also works and then display in XTerm using cat. I could cat << named_pipe but I was wondering if this was the only way? Could I j

Re: subprocess: xterm -c cat, need to send data to cat and have it displayed in the xterm window

2016-07-12 Thread Veek. M
Steven D'Aprano wrote: > On Tuesday 12 July 2016 13:20, Veek. M wrote: > >> Script grabs some image data and runs imagemagick on it to extract >> some chinese. Then tesseract OCR to get the actual unicode. >> >> I then need to get it translated which also

How do you guys tackle a package with poorish documentation?

2016-07-12 Thread Veek. M
I've been messing with QQ (a Chinese chat app) and started receiving a lot of shady traffic partly because I was stupid enough to install the insecure QQ=international version. Anyway, so I decided to write something to provide me with a diff for networks. Basically track my current n/w with m

Scapy: sniff(filter='icmp', iface='ppp0', prn=icmp_callback)

2016-07-14 Thread Veek. M
#!/usr/bin/python import logging logging.getLogger("scapy.runtime").setLevel(logging.ERROR) from scapy.all import TCP, IP, ICMP, sniff def ip_callback(pkt): print '--- IP--' pkt.show() print 'IP', pkt.src, pkt.sport, '--->', pkt.dst, pkt

__instancecheck__ metaclasses, how do they work: why do I get True when I tuple, why doesn't print run?

2019-11-04 Thread Veek M
1. Why do I get True whenever i tuple the isinstance(f, (Bar, Foo)) (and why don't the print's run) The docs say that you can feed it a tuple and that the results are OR'd The form using a tuple, isinstance(x, (A, B, ...)), is a shortcut for isinstance(x, A) or isinstance(x, B) or ... (etc.

Re: __instancecheck__ metaclasses, how do they work: why do I get True when I tuple, why doesn't print run?

2019-11-04 Thread Veek M
> > Aha. You're trying to fix up the metaclass after the fact, which is not > the right way to do it. If you change the class definitions to: > __metaclass__ = whatever; # is python2.x syntax > then you get the prints from MyMeta.__instancecheck__(). The > isinstance() still returns True, tho

What PEPs are worth reading after you've read a textbook/Beazley but want to understand details/innerworkings

2019-11-04 Thread Veek M
sez it all really, among the Finished PEPs, which ones should I pore through to teach Python competently! What PEPs are considered de rigueur? What PEPs do you guys consider note- worthy? https://www.python.org/dev/peps/ -- https://mail.python.org/mailman/listinfo/python-list

SSL/TLS in Python using STARTTLS and ssl/ssltelnet and telnetlib

2019-11-06 Thread Veek M
Could someone suggest some introductory reading material that will allow me to use 'telnetlib' with 'ssl' or 'ssltelnet'. (currently using Pan since Knode is dropped on Debian) I'm trying to write something that will download the NNTP headers over TLS. The idea is to 1. telnet to port 119, se

What is a backing store in the context of module io https://docs.python.org/3/library/io.html

2019-11-11 Thread Veek M
So i was making some notes and: https://i.imgur.com/UATAKXh.png I did not understand this https://docs.python.org/3/library/io.html 'Text I/O expects and produces str objects. This means that whenever the backing store is natively made of bytes (such as in the case of a file), encoding and dec

Re: What is a backing store in the context of module io https://docs.python.org/3/library/io.html

2019-11-11 Thread Veek M
On Mon, 11 Nov 2019 16:08:12 +, Veek M wrote: > So i was making some notes and: https://i.imgur.com/UATAKXh.png > > I did not understand this > > https://docs.python.org/3/library/io.html 'Text I/O expects and produces > str objects. This means that whenever the ba

multiprocessing article on PYMOTW - subclassing with 'def run' and 'logging'

2019-11-16 Thread Veek M
https://pymotw.com/2/multiprocessing/basics.html https://pymotw.com/2/threading/ I didn't follow this 1. >The logger can also be configured through the logging configuration file >API, using the name multiprocessing. and 2. >it is also possible to use a custom subclass. > import multiprocessi

Re: multiprocessing article on PYMOTW - subclassing with 'def run' and 'logging'

2019-11-16 Thread Veek M
answered here https://www.reddit.com/r/Python/comments/dxhgec/ how_does_multiprocessing_convert_a_methodrun_in/ basically starts two PVMs - the whole fork, check 'pid' trick.. one process continues as the main thread and the other calls 'run' -- https://mail.python.org/mailman/listinfo/python-li

Is there a piece of code ('inspect') that displays all/most of the attributes/methods in a frame, traceback, generator object in a readable fashion

2019-11-19 Thread Veek M
Basically I want to call a method and pretty print the object contents for some code I'm playing with. Instead of manually writing all this crud. Something like a python object explorer. def foo(a, x = 10): 2 + 2 def bar(): pass class A: pass class Foo(A, object): def __ini

Extending property using a Subclass - single method - why Super(Baz, Baz).name.__set__ ?

2019-12-03 Thread Veek M
class Foo(object): @property def name(self): if hasattr(self, '_name'): print('Foo name', self._name) return self._name else: return 'default' @name.setter def name(self, value): print('Foo', self) self._name = va

Re: Extending property using a Subclass - single method - why Super(Baz, Baz).name.__set__ ?

2019-12-03 Thread Veek M
you've misunderstood my question, let me try again: So this is a simple descriptor class and as you can see, dunder-set needs 3 args: the descriptor CONTAINER/Bar-instance is the first arg, then a reference to the using instance/Foo-instance class Bar(object): def __set__(self, instanc

Decorator as a class and Descriptor __get__ working? - cookbook, 9.9, pg 349

2019-12-08 Thread Veek M
I did not follow the grok bit.. He's creating a Descriptor within class 'Spam' by doing @Profiled def bar() because Profiled replaces 'bar' with it's instance that contains __get__ which means I have to do s.grok = 20 to trigger it? Which would imply, s.__get__(instance, instance, value) NOT wha

Why is a generator expression called a expression?

2020-04-20 Thread Veek M
The docs state that a expression is some combination of value, operator, variable and function. Also you cannot add or combine a generator expression with a value as you would do with 2 + 3 + 4. For example, someone on IRC suggested this all(a == 'a' for a in 'apple') but 1. all is a function/m

Re: Why is a generator expression called a expression?

2020-04-20 Thread Veek M
On Mon, 20 Apr 2020 19:19:31 +1000, Chris Angelico wrote: > In the case of a genexp, the expression has a value which is a generator > object. When you pass that to all(), it takes it and then iterates over but an object is NOT THE SAME as it's value! '2' is an object which happens to have a val

Re: Why is a generator expression called a expression?

2020-04-20 Thread Veek M
Also you will note, one can do: ( 2 if 3 > 2 else 4 ) + 4 so the () is just for precedence but otherwise a Conditional Expression works as expected by returning a value to be added to + 4. -- https://mail.python.org/mailman/listinfo/python-list

Re: Why is a generator expression called a expression?

2020-04-20 Thread Veek M
but one can do the following (x for x in 'apple').next() * 2 def foo(): (yield 2) foo().next() * 3 (lambda x: 2)()*4 generator expr, yield expr, lambda expression all require some modification (insertion of a .next or explicit () so it's quite confusing.. expression seems to mean anything

x=something, y=somethinelse and z=crud all likely to fail - how do i wrap them up

2016-01-30 Thread Veek. M
I'm parsing html and i'm doing: x = root.find_class(... y = root.find_class(.. z = root.find_class(.. all 3 are likely to fail so typically i'd have to stick it in a try. This is a huge pain for obvious reasons. try: except something: x = 'default_1' (repeat 3 times) Is there some other

Re: x=something, y=somethinelse and z=crud all likely to fail - how do i wrap them up

2016-01-30 Thread Veek. M
Chris Angelico wrote: > On Sun, Jan 31, 2016 at 3:58 PM, Veek. M wrote: >> I'm parsing html and i'm doing: >> >> x = root.find_class(... >> y = root.find_class(.. >> z = root.find_class(.. >> >> all 3 are likely to fail so typically i&

Re: x=something, y=somethinelse and z=crud all likely to fail - how do i wrap them up

2016-01-30 Thread Veek. M
Veek. M wrote: > Chris Angelico wrote: > >> On Sun, Jan 31, 2016 at 3:58 PM, Veek. M wrote: >>> I'm parsing html and i'm doing: >>> >>> x = root.find_class(... >>> y = root.find_class(.. >>> z = root.find_class(.. >>

Re: x=something, y=somethinelse and z=crud all likely to fail - how do i wrap them up

2016-01-31 Thread Veek. M
Thanks guys: you've given me some good ideas - I really need to re-read the lxml docs for xpath. (basically trying to scrape ebay and score a mobo - ebaysdk doesn't work) Also need to google those principles :) thanks! (i knew one shouldn't overly rely on chained attribute lookups - didn't fig

coroutine, throw, yield, call-stack and exception handling

2016-02-08 Thread Veek. M
Exceptions can be raised inside a coroutine using the throw( Exceptions raised in this manner will originate at the currently executing yield state-ment in the coroutine.A coroutine can elect to catch exceptions and handle them as appropriate. It is not safe to use

Re: coroutine, throw, yield, call-stack and exception handling

2016-02-08 Thread Veek. M
Veek. M wrote: > > Exceptions can be raised inside a coroutine using the throw( > > Exceptions raised in this manner will originate at the currently > executing yield state-ment in the coroutine.A coroutine can elect to > catch exceptions

Re: coroutine, throw, yield, call-stack and exception handling

2016-02-09 Thread Veek. M
Ian Kelly wrote: > On Mon, Feb 8, 2016 at 2:17 AM, Veek. M wrote: >> >> Exceptions can be raised inside a coroutine using the throw( >> >> Exceptions raised in this manner will originate at the currently >> executing yield state-ment

How do i instantiate a class_name passed via cmd line

2016-02-13 Thread Veek. M
I'm writing a price parser. I need to do the equivalent of perl's $$var to instantiate a class where $car is the class_name. I'm passing 'Ebay' or 'Newegg' or 'Amazon' via cmd-line. I have a module named ebay.py and a class called Ebay (price parser). I do something like: \> main.py ebay mother

Re: How do i instantiate a class_name passed via cmd line

2016-02-13 Thread Veek. M
Rick Johnson wrote: > On Saturday, February 13, 2016 at 10:41:20 PM UTC-6, Veek. M wrote: >> how do i replace the 'Ebay' bit with a variable so that I >> can load any class via cmd line. > > Is this what you're trying to do? > > (Python2.x code)

Re: How do i instantiate a class_name passed via cmd line

2016-02-13 Thread Veek. M
Gregory Ewing wrote: > Veek. M wrote: >> I'm writing a price parser. I need to do the equivalent of perl's >> $$var to instantiate a class where $car is the class_name. >> >> I'm passing 'Ebay' or 'Newegg' or 'Amazon' via c

repr( open('/etc/motd', 'rt').read() )

2016-02-15 Thread Veek. M
When I do at the interpreter prompt, repr( open('/etc/motd', 'rt').read() ) i get # 1 #: "'\\nThe programs included with the Debian GNU/Linux system are free software;\\nthe exact distribution terms for each program are described in the\\nindividual files in /usr/share/doc/*/copyright.\\n\\nDe

threading - Doug Hellman stdlib book, Timer() subclassing etc

2016-02-16 Thread Veek. M
In Doug Hellman's book on the stdlib, he does: import threading import logging logging.basicConfig(level=logging.DEBUG, format=’(%(threadName)-10s) %(message)s’, ) class MyThreadWithArgs(threading.Thread): def __init__(self, group=None, target=None, name=None, args=(), kwargs=None

Lookahead while doing: for line in fh.readlines():

2016-02-27 Thread Veek. M
I want to do something like: #!/usr/bin/env python3 fh = open('/etc/motd') for line in fh.readlines(): print(fh.tell()) why doesn't this work as expected.. fh.readlines() should return a generator object and fh.tell() ought to start at 0 first. Instead i get the final count repeated for th

Re: Lookahead while doing: for line in fh.readlines():

2016-03-04 Thread Veek. M
Terry Reedy wrote: > On 2/27/2016 4:39 AM, Veek. M wrote: >> I want to do something like: >> >> #!/usr/bin/env python3 >> >> fh = open('/etc/motd') >> for line in fh.readlines(): >> print(fh.tell()) >> >> why doesn't th

Re: Lookahead while doing: for line in fh.readlines():

2016-03-04 Thread Veek. M
MRAB wrote: > On 2016-03-04 13:04, Veek. M wrote: >> Terry Reedy wrote: >> >>> On 2/27/2016 4:39 AM, Veek. M wrote: >>>> I want to do something like: >>>> >>>> #!/usr/bin/env python3 >>>> >>>> fh = open('/etc

__del__: when to use it? What happens when you SystemExit/NameError wrt del? Method vs function calls.

2016-03-06 Thread Veek. M
1. What are the rules for using __del__ besides: 'don't use it'. 2. What happens when I SystemExit? __del__ and gc are not invoked when I SystemExit and there's a circular reference - but why? The OS is going to reclaim the memory anyways so why be finicky about circular references - why can't

Re: __del__: when to use it? What happens when you SystemExit/NameError wrt del? Method vs function calls.

2016-03-06 Thread Veek. M
Veek. M wrote: > 1. What are the rules for using __del__ besides: 'don't use it'. > > 2. What happens when I SystemExit? __del__ and gc are not invoked when > I SystemExit and there's a circular reference - but why? The OS is > going to reclaim the memory anywa

Re: __del__: when to use it? What happens when you SystemExit/NameError wrt del? Method vs function calls.

2016-03-07 Thread Veek. M
Steven D'Aprano wrote: > On Monday 07 March 2016 17:13, Veek. M wrote: > >> import foo >> class Bar(object): >> def __del__(self, foo=foo): >> foo.bar()# Use something in module foo >> >> ### Why the foo=foo? import foo, would incre

Pickle __getstate__ __setstate__ and restoring n/w - beazley pg 172

2016-03-07 Thread Veek. M
import socket class Client(object): def __init__(self,addr): self.server_addr = addr self.sock = socket.socket(socket.AF_INET,socket.SOCK_STREAM) self.sock.connect(addr) def __getstate__(self): return self.server_addr def __setstate__(self,value): self.server_addr = value self.s

exec "x = 3; print x" in a - How does it work?

2016-03-08 Thread Veek. M
What is the return value of `exec`? Would that object be then used to iterate the sequence in 'a'? I'm reading this: https://www.python.org/download/releases/2.2.3/descrintro/ -- https://mail.python.org/mailman/listinfo/python-list

Re: exec "x = 3; print x" in a - How does it work?

2016-03-08 Thread Veek. M
Ben Finney wrote: > "Veek. M" writes: > >> What is the return value of `exec`? > > You can refer to the documentation for questions like that. > https://docs.python.org/3/library/functions.html#exec> > >> Would that object be then used to iterate th

Re: exec "x = 3; print x" in a - How does it work?

2016-03-08 Thread Veek. M
Steven D'Aprano wrote: > On Wednesday 09 March 2016 16:27, Veek. M wrote: > >> What is the return value of `exec`? Would that object be then used to >> iterate the sequence in 'a'? I'm reading this: >> https://www.python.org/download/releases/2.2.3/de

  1   2   >