how to add socks proxy feature to script based on requests module?

2013-02-12 Thread xliiv
Hi!

I've go a script which uses python requests 
(http://docs.python-requests.org/en/latest/).

I need to add to it socks proxy feature.

AFAIK requests doesn't support socks proxy 
(http://stackoverflow.com/questions/12601316/how-to-make-python-requests-work-via-socks-proxy)
 so i was about to switch requests module to human_curl 
(http://stackoverflow.com/questions/8482896/making-http-requests-via-python-requests-module-not-working-via-proxy-where-curl).
Then it turned out that human_curl doesn't support "requests module's" session.

Ok, what can You recommend me to do? I need the best solution for adding socks 
proxy feature to script (based on requests module).

if nothing better is recommended i'll clone "requests' module" session feature 
in human_curl.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Does python have built command for package skeleton creation?

2012-09-21 Thread xliiv
On Friday, September 21, 2012 3:04:02 PM UTC+2, Tarek Ziadé wrote:
> On 9/21/12 2:14 PM, xliiv wrote:
> 
> >
> 
> > Python Paste is probably what you are looking for - see
> 
> >
> 
> > http://lucasmanual.com/mywiki/PythonPaste for example
> 
> > It's a nice beast but:
> 
> > - it's not built in. Should it be? I think it should.
> 
> You can suggest this to python-ideas but I really doubt you will get any 
> 
> traction. The sdtlib don't get new features these days because it's a burden
> 
> to maintain high level tool on a 2 years release cycle

Why is this '2 years release cycle'?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Does python have built command for package skeleton creation?

2012-09-21 Thread xliiv
On Friday, September 21, 2012 1:08:23 PM UTC+2, Tarek Ziadé wrote:
> On 9/21/12 12:07 PM, xliiv wrote:
> 
> > Like the topic.. . I found this:
> 
> >
> 
> > http://learnpythonthehardway.org/book/ex46.html
> 
> >
> 
> > it seems fine, but shouldn't be an interactive (with CLI API) script 
> > creating that? It's a lot of effort for common work.
> 
> >
> 
> > I can contribute but i have to know that i'm not reinvent a wheel.
> 
> >
> 
> >
> 
> Python Paste is probably what you are looking for - see 
> 
> http://lucasmanual.com/mywiki/PythonPaste for example

It's a nice beast but:
- it's not built in. Should it be? I think it should.
- about readme and manifest.in:
"You could add to your template a file called readme.rst . Inside of it you can 
add the following code that will generate this:"

i dont want to add, i want it already added :).. readme is something typical, 
it's not rare habit for some geeks how wants to customize it all!! the same 
with manifest.in..

what do you think? iteractive creation is big plus..
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What's wrong with my arc tangens calculation?

2012-09-14 Thread xliiv
On Friday, September 14, 2012 12:55:06 PM UTC+2, Laszlo Nagy wrote:
> > but when i lookup tg in a paper table (last decade math book) i've got 
> > these values:
> 
> >
> 
> > tg(63'10'') = 1.9768
> 
> > tg(63'20'') = 1.9912
> 
> > tg(63'30'') = 2.0057
> 
> >
> 
> > For me python should return something more like 63'2x'' than 
> > 63'4x''(becasue 63'30'' is higher than 2.0)
> 
> >
> 
> > what's wrong?
> 
> >
> 
> 63� 30" is 63.5�. So nothing is wrong. (You know, 1� = 60 arc second!)

So the wrong part is me ;)
The python's 63.43494882292201 is degrees (according to function math.degrees)
but book's value is in minutes. Clearified Thanks, all.
-- 
http://mail.python.org/mailman/listinfo/python-list


What's wrong with my arc tangens calculation?

2012-09-14 Thread xliiv
I do some math with python:

import math as m
m.degrees(m.atan(2))
>>> 63.43494882292201

but when i lookup tg in a paper table (last decade math book) i've got these 
values:

tg(63'10'') = 1.9768
tg(63'20'') = 1.9912
tg(63'30'') = 2.0057

For me python should return something more like 63'2x'' than 63'4x''(becasue 
63'30'' is higher than 2.0)

what's wrong?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to hide console with Popen on Windows?

2012-05-22 Thread xliiv
On Tuesday, May 22, 2012 2:45:11 AM UTC+2, alex23 wrote:
> On May 22, 3:00 am, xliiv  wrote:
> > Now I know that my 'solution' is not a solution and problem still bugs me.
> > Any ideas how to deal with it?
> 
> I haven't tried it but this thread talks about being able to use a
> standard install of Python with OpenOffice:
> 
> http://user.services.openoffice.org/en/forum/viewtopic.php?t=26877

On Tuesday, May 22, 2012 2:45:11 AM UTC+2, alex23 wrote:
> On May 22, 3:00 am, xliiv  wrote:
> > Now I know that my 'solution' is not a solution and problem still bugs me.
> > Any ideas how to deal with it?
> 
> I haven't tried it but this thread talks about being able to use a
> standard install of Python with OpenOffice:
> 
> http://user.services.openoffice.org/en/forum/viewtopic.php?t=26877



On Tuesday, May 22, 2012 2:45:11 AM UTC+2, alex23 wrote:
> On May 22, 3:00 am, xliiv  wrote:
> > Now I know that my 'solution' is not a solution and problem still bugs me.
> > Any ideas how to deal with it?
> 
> I haven't tried it but this thread talks about being able to use a
> standard install of Python with OpenOffice:
> 
> http://user.services.openoffice.org/en/forum/viewtopic.php?t=26877



On Tuesday, May 22, 2012 2:45:11 AM UTC+2, alex23 wrote:
> On May 22, 3:00 am, xliiv  wrote:
> > Now I know that my 'solution' is not a solution and problem still bugs me.
> > Any ideas how to deal with it?
> 
> I haven't tried it but this thread talks about being able to use a
> standard install of Python with OpenOffice:
> 
> http://user.services.openoffice.org/en/forum/viewtopic.php?t=26877

Thx for the link
It's useful especially that:
http://user.services.openoffice.org/en/forum/viewtopic.php?f=45&t=26149
for my walkaround of the problem.


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to hide console with Popen on Windows?

2012-05-21 Thread xliiv
On Monday, May 21, 2012 6:38:34 AM UTC+2, alex23 wrote:
> On May 18, 6:22 pm, xliiv  wrote:
> > Like the topic, more details in followed links..
> > http://stackoverflow.com/questions/10637450/how-to-hide-console-with-...
> 
> Try replacing all of your code with something simple, a 'pass' op will
> do. Run the script again. Does the console still open? Then it's not
> subprocess that you're struggling with.
> 
> If I put your code into a .py file and execute it under Windows via a
> double-click, I get a console: the one in which the .py file is
> executing. Unless you're able to make the file a .pyw file - which you
> are apparently not as you're using OpenOffice - then executing the
> code that uses Popen is what is displaying a console, not the call to
> Popen itself.

Ok, thanks for explanation.
Now I know that my 'solution' is not a solution and problem still bugs me.
Any ideas how to deal with it?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is it technically possible to give Python option of naming process of running script?

2012-03-16 Thread xliiv

> > Seems like an awfully obtuse way of doing things -- I don't really
> > want to have 15 different copies of Python (or even links), and it
> > requires root privleges every time you want to run a Python program
> > with the "correct" name.
> 
> Why do you need root? Can't you copy / link into your own home directory?
> 
> I may have misunderstood something here.
> 
> ChrisA

It's nice walkaround for now and for linux. But how about my question and 
future? :)


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is it technically possible to give Python option of naming process of running script?

2012-03-15 Thread xliiv
> >> Like the topic.. .
> >> I use Python a lot, both Windows and Linux, and it's little weird to have 
> >> many python process without fast distinction which is what.
> >
> > I've no idea if it's even possible on Windows. On Linux, what you want
> > is the prctl function, which (AFAIK) isn't directly available.
> >
> > Google is your friend, though. Question's already been asked on Stack
> > Overflow and such, and has a few answers. Nothing that looks
> > cut-and-dried ready, but several that might work.
> 
> The question of how to set the application name comes up somewhat
> regularly. It would be awfully nice if there was a way for python
> applications to set their application name.  It's especially useful
> for daemons, and makes it much easier when you can kill them by name
> instead of having to look up the PID.
> 
> It seems like an excellent thing to add to the "os" module.
> 
> > Look for 'prctl' and 'PR_SET_NAME', which are the C-level function
> > and constant that do the job; a cursory examination of PyPI shows a
> > module with prctl in the name, so that may be of value.


I did google, I've played with Exemaker (it works perfect, but not py3) and 
i've seen questions on Stackoverflow. 
The thing I mean is a build feature of python to give such a name. Not 3rd part 
or etc. like Grant Edwards said. Is it possible?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is it technically possible to give Python option of naming process of running script?

2012-03-15 Thread xliiv
> >> Like the topic.. .
> >> I use Python a lot, both Windows and Linux, and it's little weird to have 
> >> many python process without fast distinction which is what.
> >
> > I've no idea if it's even possible on Windows. On Linux, what you want
> > is the prctl function, which (AFAIK) isn't directly available.
> >
> > Google is your friend, though. Question's already been asked on Stack
> > Overflow and such, and has a few answers. Nothing that looks
> > cut-and-dried ready, but several that might work.
> 
> The question of how to set the application name comes up somewhat
> regularly. It would be awfully nice if there was a way for python
> applications to set their application name.  It's especially useful
> for daemons, and makes it much easier when you can kill them by name
> instead of having to look up the PID.
> 
> It seems like an excellent thing to add to the "os" module.
> 
> > Look for 'prctl' and 'PR_SET_NAME', which are the C-level function
> > and constant that do the job; a cursory examination of PyPI shows a
> > module with prctl in the name, so that may be of value.


I did google, I've played with Exemaker (it works perfect, but not py3) and 
i've seen questions on Stackoverflow.
The thing I mean is a build feature of python to give such a name. Not 3rd part 
or etc. like Grant Edwards said. Is it possible?
-- 
http://mail.python.org/mailman/listinfo/python-list


Is it technically possible to give Python option of naming process of running script?

2012-03-14 Thread xliiv
Like the topic.. .
I use Python a lot, both Windows and Linux, and it's little weird to have many 
python process without fast distinction which is what.
-- 
http://mail.python.org/mailman/listinfo/python-list


Python packaging usabilty (distutils) - automatic downloading required packages

2012-02-25 Thread XLiIV
There is many packaging solutions for python.
I was confused about that but it's nothing. I had to pick one of them.
I picked distutils because it's part of standard python since 3.3, am
i right?
My goal is to write setup.py with this feature: 'download required
package if not installed already, like sqlalchemy'.
How can I achieve that with DISTUTILS?
I found out that  is not possible, seriously? I can't believe that.
It's basic function, I think.
Do I really switch to setuptools?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: confused by HTMLParser class

2008-05-27 Thread XLiIV
On May 28, 3:20 am, globalrev <[EMAIL PROTECTED]> wrote:
> tried all kinds of combos to get this to work.
>
> http://docs.python.org/lib/module-HTMLParser.html
>
> from HTMLParser import HTMLParser
>
> class MyHTMLParser(HTMLParser):
>
>     def handle_starttag(self, tag, attrs):
>         print "Encountered the beginning of a %s tag" % tag
>
>     def handle_endtag(self, tag):
>         print "Encountered the end of a %s tag" % tag
>
> from HTMLParser import HTMLParser
> import urllib
> import myhtmlparser
>
> x = MyHTMLParser(HTMLParser())
> site = urllib.urlopen("http://docs.python.org/lib/module-
> HTMLParser.html")
> for row in site:
>     print x.handle_starttag()

this works fine to me:


from HTMLParser import HTMLParser

class MyHTMLParser(HTMLParser):

def handle_starttag(self, tag, attrs):
print "Encountered the beginning of a %s tag" % tag

def handle_endtag(self, tag):
print "Encountered the end of a %s tag" % tag

#from HTMLParser import HTMLParser
import urllib
#import mythmlparser

site = urllib.urlopen("http://docs.python.org/lib/module-
HTMLParser.html")
x = MyHTMLParser()  #   x = MyHTMLParser(HTMLParser())
x.feed(site.read())
x.close()
for row in site:
print x.handle_starttag()
site.close()


You should also read this:
http://www.diveintopython.org/html_processing/extracting_data.html
for example
--
http://mail.python.org/mailman/listinfo/python-list


Re: Is using range() in for loops really Pythonic?

2008-05-11 Thread XLiIV
On May 11, 4:19 am, John Salerno <[EMAIL PROTECTED]> wrote:
> I know it's popular and very handy, but I'm curious if there are purists
> out there who think that using something like:
>
> for x in range(10):
>     #do something 10 times
>
> is unPythonic. The reason I ask is because the structure of the for loop
> seems to be for iterating through a sequence. It seems somewhat
> artificial to use the for loop to do something a certain number of
> times, like above.
>
> Anyone out there refuse to use it this way, or is it just impossible to
> avoid?

The range() function returns a list and list is a sequence, isn't?

--
http://mail.python.org/mailman/listinfo/python-list


Re: the lvalue curse? let's play with this crazy idea ;)

2008-05-09 Thread XLiIV
On May 9, 11:52 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
> Maybe it's also harder to read than this::
>
>   print '-'.join(map(str, time.localtime()[:3]))

I like this concept, it's so, .. ziped :)

> Of course, if you don't mind the extra padding zeroes in day and month::
>
>   print time.strftime('%Y-%m-%d')

I'll be humble, it covers my need the most :)
If you have a lack of knowladge you work harder...
One instruction (besides 'print')... . Do you believe it? :)


> You are a little bit inconsistent with the arguments.  `g` is explicitly
> mentioned in ``list(g)``.  But why the intermediate names at all?
>

That's right, because it was just a scratch of an idea..
The point of the idea was this...
I read from left to right, and because of that it's easier to me
follow this way of writing (you only follow by one direction and the
value is handing over, from left to rigght ...):

value -> do_something -> result -> action_on_the_result -> ...

than this multiline lvalues assignes

variable = value # I take a look at the left then the right
result = do_something(variable) # Here I check also left and right
side, and perhaps I (a short memory) may check the line over
action_on_the_result(result)
...

However, I've just found out, that even the more difficult method to
me isn't so scary if I read it like this
...
6 7
4 5
2 3
  1
However the 2nd:
because there is:
print '-'.join(map(str, time.localtime()[:3]))

so i'm not serious convincing anyone :)


> Maybe you should look into languages like SmallTalk or Io where everything
> is done with method calls.  Your example in Io::

I took a brief look at them, and Python is still Nr OnE :)
--
http://mail.python.org/mailman/listinfo/python-list


the lvalue curse? let's play with this crazy idea ;)

2008-05-09 Thread XLiIV
I started playing with Python and love it since the very beginning,
programming using Python is so ...human-like? but one thing returns to
me almost everytime when I see/write the code


Let's take a look at two ways of thinking...
the standard one which is well-known and loved by almost everyone :)
and that crazy concept below which suprised evan me :wacko:


import time

ftime = time.time()
localtime = time.localtime(ftime)
localtime = list(localtime[:3])
localtime = [str(i) for i in localtime]
print '-'.join(localtime)


It's harder to read than the below concept, isn't?
Maybe I didn't used to this way of thinking yet. I hope it'll change
soon or i'll quit ;)



time.time() -> ftime -> time.localtime() -> p -> p[:3] -> g -> list(g)
-> '-'.join()


My example conclusion and not-ansewered-yet question...
-it's nice to read and choosing the good names to variables aren't so
important
-what is the purpose of the variables here? :)

I realize that there is no chance to implement it, but I really want
to share it :]

Peace,
T.

PS
forgive my my english
[shall I set it as a signature? ;) ]
--
http://mail.python.org/mailman/listinfo/python-list