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

2016-03-09 Thread Veek. M
dieter wrote: > "Veek. M" writes: > >> 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) >>

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

2016-03-09 Thread Veek. M
Ian Kelly wrote: > On Wed, Mar 9, 2016 at 2:14 AM, Veek. M wrote: >> what i wanted to know was, x = Client('192.168.0.1') will create an >> object 'x' with the IP inside it. When I do: >> pickle.dump(x) >> pickle doesn't know where in the

Descriptors vs Property

2016-03-11 Thread Veek. M
A property uses the @property decorator and has @foo.setter @foo.deleter. A descriptor follows the descriptor protocol and implements the __get__ __set__ __delete__ methods. But they both do essentially the same thing, allow us to do: foo = 10 del foo x = foo So why do we have two ways of doin

Re: Descriptors vs Property

2016-03-11 Thread Veek. M
Veek. M wrote: > A property uses the @property decorator and has @foo.setter > @foo.deleter. > > A descriptor follows the descriptor protocol and implements the > __get__ __set__ __delete__ methods. > > But they both do essentially the same thing, allow us to do: > foo

Re: Descriptors vs Property

2016-03-11 Thread Veek. M
Ian Kelly wrote: > On Fri, Mar 11, 2016 at 10:59 PM, Veek. M wrote: >> A property uses the @property decorator and has @foo.setter >> @foo.deleter. >> >> A descriptor follows the descriptor protocol and implements the >> __get__ __set__ __delete__ methods. >&

Re: Descriptors vs Property

2016-03-12 Thread Veek. M
Thomas 'PointedEars' Lahn wrote: >> I haven't read the descriptor protocol as yet. > > You should. You should also trim your quotations to the relevant > minimum, and post using your real name. > I don't take advice from people on USENET who DON'T have a long history of helping ME - unless I'

Re: Descriptors vs Property

2016-03-13 Thread Veek. M
Thomas 'PointedEars' Lahn wrote: > Veek. M wrote: > >> Thomas 'PointedEars' Lahn wrote: >>>> I haven't read the descriptor protocol as yet. >>> You should. You should also trim your quotations to the relevant >>> minimum, and p

Re: Descriptors vs Property

2016-03-13 Thread Veek. M
Thomas 'PointedEars' Lahn wrote: >>> Nobility lies in action, not in name. >>> —Surak Someone called Ned.B who i know elsewhere spoke on your behalf. I'm glad to say I like/trust Ned a bit so *huggles* to you, and I shall snip. Also, sorry about the 'Steve' thing - bit shady dragging in

Python extension using a C library with one 'hello' function

2014-11-04 Thread Veek M
https://github.com/Veek/Python/tree/master/junk/hello doesn't work. I have: hello.c which contains: int hello(void); hello.h To wrap that up, i have: hello.py -> _hello (c extension) -> pyhello.c -> method py_hello() People using this will do: python3.2>> import hello python3.2>> hello.hello() I

Re: generating unique variable name via loops

2014-11-04 Thread Veek M
Fatih Güven wrote: > 4 Kas?m 2014 Sal? 13:29:34 UTC+2 tarihinde Fatih Güven yazd?: >> I want to generate a unique variable name for list using python. >> >> list1=... >> list2=... for x in range(1,10): exec("list%d = []" % x) -- https://mail.python.org/mailman/listinfo/python-list

Re: generating unique variable name via loops

2014-11-04 Thread Veek M
Fatih Güven wrote: > This is okay but i can't use the method ".append" for example > list1.append("abc") works for me -- https://mail.python.org/mailman/listinfo/python-list

Re: Python extension using a C library with one 'hello' function

2014-11-04 Thread Veek M
Søren wrote: > import ctypes Hi, yeah i kind of liked it - still reading the docs though, Beazley has the Python.h solution so I though I'd try that first. -- https://mail.python.org/mailman/listinfo/python-list

Re: Python extension using a C library with one 'hello' function

2014-11-04 Thread Veek M
Jason Swails wrote: > I've submitted a PR to your github repo showing you the changes > necessary to get your module working on my computer. Segfaults :p which is an improvement :) open("./_hello.cpython-32mu.so", O_RDONLY) = 5 read(5, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\300\7\0\0\0

Re: Python extension using a C library with one 'hello' function

2014-11-04 Thread Veek M
Jason Swails wrote: > What operating system are you running this on? It works fine for me on > Linux: Wheezy Debian, Linux deathstar 3.2.0-4-amd64 #1 SMP Debian 3.2.60-1+deb7u3 x86_64 GNU/Linux gcc (Debian 4.7.2-5) 4.7.2 Python 3.2.3 I ran it through gdb - not very useful: (gdb) bt #0 0x00

Re: Python extension using a C library with one 'hello' function

2014-11-04 Thread Veek M
static PyMethodDef hellomethods[] = { {"hello", py_hello, METH_VARARGS, py_hello_doc}, {NULL, NULL, 0, NULL}, }; It's basically the METH_VARARGS field that's giving the problem. Switching it to NULL gives, SystemError: Bad call flags in PyCFunction_Call. METH_OLDARGS is no longer suppor

Re: Python extension using a C library with one 'hello' function

2014-11-04 Thread Veek M
okay got it working - thanks Jason! The 3.2 docs are slightly different. -- https://mail.python.org/mailman/listinfo/python-list

Python, VIM: namespace, scope, life of a python object stuck in a << HERE

2014-11-04 Thread Veek M
If i have two functions: function! foo() python3 << HERE import mylib pass HERE function! bar() python3 << HERE import mylib pass HERE The src says: 1. Python interpreter main program 3. Implementation of the Vim module for Python So, is the python interpreter embedded in vim AND additio

How do i reduce this to a single function - the code is largely similar, just a direction of search toggle.

2014-11-07 Thread Veek M
def jump_to_blockD(self): end = len(self.b) row, col = self.w.cursor while row <= end: try: new_col = self.b[row].index('def') self.w.cursor = row, new_col break except ValueError: pa

Re: How do i reduce this to a single function - the code is largely similar, just a direction of search toggle.

2014-11-07 Thread Veek M
Veek M wrote: > new_col = self.b[row].index('def') > self.w.cursor = row, new_col > new_col = self.b[row].rindex('def') > self.w.cursor = row, new_col There's also the different methods ind

Re: How do i reduce this to a single function - the code is largely similar, just a direction of search toggle.

2014-11-09 Thread Veek M
Ned Batchelder wrote: > On 11/7/14 9:52 AM, Veek M wrote: > and you want to end up on the "def" token, not the "def" in yep, bumped into this :) thanks! -- https://mail.python.org/mailman/listinfo/python-list

functools documentation - help with funny words

2014-11-09 Thread Veek M
https://docs.python.org/3.4/library/functools.html 1. "A key function is a callable that accepts one argument and returns another value indicating the position in the desired collation sequence." x = ['x','z','q']; sort(key=str.upper) My understanding is that, x, y, .. are passed to the key fun

Python: package root, root-node, __init__.py in the package root

2014-11-13 Thread Veek M
I have a package structured like so on the file system: PKG LIBS are stored here: /usr/lib/python3.2/ Pkg-name: foo-1.0.0 1. What is the root directory, or root-node or 'root' of my package? My understanding is that it's: /usr/lib/python3.2/foo-1.0.0/ on the file-system and this is referred to t

Python 3.x (beazley): __context__ vs __cause__ attributes in exception handling

2014-11-13 Thread Veek M
In 'Chained Exceptions' - Beazley pg:626 try: pass except ValueError as e: raise SyntaxError('foo bar') from e - Here, if ValueError is raised and SyntaxError is then raised.. 'e' contains __cause__ which points to the ValueError Traceback. He goes on to say: --

Re: Python 3.x (beazley): __context__ vs __cause__ attributes in exception handling

2014-11-14 Thread Veek M
It's been answered here: http://stackoverflow.com/questions/26924045/python-3-x-beazley-context-vs- cause-attributes-in-exception-handling?noredirect=1#comment42403467_26924045 -- https://mail.python.org/mailman/listinfo/python-list

uWSGI, nGinx, and python on Wheezy: how do you configure it?

2014-12-16 Thread Veek M
Has anyone got the thing to work? I want to run some python database scripts on nginx. Because that will have a simple web-UI, i decided to go with uWSGI. It's proving to be a massive pain. I found a decent book for nginx and got that bit working. The query gets sent to uWSGI but for some reaso

Re: uWSGI, nGinx, and python on Wheezy: how do you configure it?

2014-12-16 Thread Veek M
Chris Warrick wrote: > This is NOT how uwsgi works! You cannot use plain .py files with it, > and for good reason ? CGI should be long dead. > > What you need to do is, you must write a webapp ? in Flask, for > example. Then you must craft an .ini file that mentions this. **Hi Chris, Could you

Re: uWSGI, nGinx, and python on Wheezy: how do you configure it?

2014-12-16 Thread Veek M
Just to be very very clear about this: 1. I have never worked seriously with Javascript, frameworks, django, flask etc. 2. I can write CGI on Apache. 3. I have never worked with nginx untill 2 days ago. 4. All this started because I wanted to mess with SQL/CSS/HTML5. 5. Some frigging! *moron* on I

Re: uWSGI, nGinx, and python on Wheezy: how do you configure it?

2014-12-16 Thread Veek M
http://discuss.joelonsoftware.com/default.asp?joel.3.219431.12 -- https://mail.python.org/mailman/listinfo/python-list

Re: uWSGI, nGinx, and python on Wheezy: how do you configure it?

2014-12-17 Thread Veek M
Dumped uwsgi - the documentation is utterly ridculous!! Switched to 'Bottle' - very nice, intutive and clean - tutorial+documentation is excellent and i got 'hello world' up and running in like 10-15 minutes vs the 2 days intermittent it took to scroll through the crap that is uwsgi-server. It

Google Maps and Python: creating a map, embedding it, adding images, videos, markers, using python

2014-12-18 Thread Veek M
I'm messing with Google-Maps. Is there a way I can create a map, embed it on a page (CSS/HTML/Javascript for this bit), and add images, videos, markers - using python? Any libraries available? -- https://mail.python.org/mailman/listinfo/python-list

Javascript website scraping using WebKit and Selenium tools

2015-07-01 Thread Veek M
I tried scraping a javascript website using two tools, both didn't work. The website link is: http://xdguo.taobao.com/category-499399872.htm The relevant text I'm trying to extract is 'GY-68...': I'm trying to match the class="

Re: Javascript website scraping using WebKit and Selenium tools

2015-07-01 Thread Veek M
dieter wrote: > Once the problems to get the "final" HTML code solved, > I would use "lxml" and its "xpath" support to locate any > relevant HTML information. Hello Dieter, yes - you are correct. (though I don't think there's any auth to browse - nice that you actually tried) He's using jsonP an

lxml.xpath 'for/xpath' to get to a node and then xpath again within the loop?

2015-07-02 Thread Veek M
I travel to 'item-name', how do i quickly travel to c-price and then print both values of text. I tried: for anchor in element.xpath('//a[@class="item-name"]'): #Travel to item-name but when i getparent and then call xpath I get a whole bunch of span elements as a list - why? Shouldn't xpath sta

Re: lxml.xpath 'for/xpath' to get to a node and then xpath again within the loop?

2015-07-02 Thread Veek M
never mind fixed.. it's returning a list so whatever[0].text and relative-path for the xpath -- https://mail.python.org/mailman/listinfo/python-list

requests.Session() how do you set 'replace' on the encoding?

2015-07-02 Thread Veek M
I'm getting a Unicode error: Traceback (most recent call last): File "fooxxx.py", line 56, in parent = anchor.getparent() UnicodeEncodeError: 'gbk' codec can't encode character u'\xa0' in position 8: illegal multibyte sequence I'm doing: s = requests.Session() to suck data in, so.. how do

Re: requests.Session() how do you set 'replace' on the encoding?

2015-07-06 Thread Veek M
dieter wrote: > Veek M writes: >> UnicodeEncodeError: 'gbk' codec can't encode character u'\xa0' in >> position 8: illegal multibyte sequence > > You give us very little context. It's a longish chunk of code: basically, i'm trying t

Re: lxml.xpath 'for/xpath' to get to a node and then xpath again within the loop?

2015-07-06 Thread Veek M
Saran Ahluwalia wrote: > So what did you do to resolve this? Please provide your fix. This is an > excellent case study for others. it's provided, what part didn't you understand? Try googling relative-path, wth? -- https://mail.python.org/mailman/listinfo/python-list

Re: lxml.xpath 'for/xpath' to get to a node and then xpath again within the loop?

2015-07-09 Thread Veek M
Mark Lawrence wrote: > > If it's provided why have you snipped it this time around? May I most > humbly suggest that the next time you ask, please ensure that you tell > us what you've googled for prior to putting your question. > umm.. I can't determine what you mean by 'snipped it'. 1. I post

Re: requests.Session() how do you set 'replace' on the encoding?

2015-07-09 Thread Veek M
dieter wrote: > > It looks strange that you can set "s.encoding" after you have > called "s.get" - but, as you apparently get an error related to > the "gbk" encoding, it seems to work. Ooo! Sorry, typo - that was outside the function but before the call. Unfortunately whilst improving my functi

Re: SOAPpy: Expected to find node type 'Element' with name 'CountriesFetchingRequest'; Found node type 'Element' with name 'FetchCountries'

2014-09-23 Thread Veek M
dieter wrote: > I have no experience with "SOAPpy", but with "suds" (another Python > SAOP client). A "suds" client exposes two attributes "factory" *miaows happily* -- https://mail.python.org/mailman/listinfo/python-list

<    1   2