cx_Freeze:Fatal Python error: Py_Initialize: Unable to get the locale encoding ImportError: No module named 'encodings'

2015-02-02 Thread iMath
I downloaded cx_Freeze from here, installed it successfully on Ubuntu following 
this thread .

After run python3 setup.py build in cx_Freeze/samples/simple,then change the 
dir to cx_Freeze/samples/simple/build/exe.linux-i686-3.4,run the following 
command ,I got the error

?7?4  exe.linux-i686-3.4  ./hello

Fatal Python error: Py_Initialize: Unable to get the locale encoding

ImportError: No module named 'encodings'

[1]3950 abort  ./hello

?7?4  exe.linux-i686-3.4  

any idea on fixing this issue ?-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [OT] fortran lib which provide python like data type

2015-02-02 Thread Marko Rauhamaa
Steven D'Aprano :

> Steven D'Aprano wrote:
>> Of course people make grammar mistakes that they don't spot.
>
> Ironically, this is one of them. It should of course be "grammatical
> mistakes".

I don't believe you made a mistake according to your brain's grammar
engine.

Parenthetically, I don't believe you made a mistake even according to
your English teacher.


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [OT] fortran lib which provide python like data type

2015-02-02 Thread Marko Rauhamaa
Chris Angelico :

> On Mon, Feb 2, 2015 at 12:59 PM, Steven D'Aprano
>  wrote:
>> And there are underspecified rules too. What is the plural of octopus? No
>> fair looking it up in the dictionary.
>
> Standard and well-known piece of trivia, and there are several
> options. "Octopodes" is one of the most rigorously formal, but
> "octopuses" is perfectly acceptable. "Octopi" is technically
> incorrect, as the -us ending does not derive from the Latin.

Your brain's grammar engine will give you the correct answer. It may not
match your English teacher's answer, but the language we are talking
about is not standard English but the dialect you have acquired in
childhood.


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list


How to write a non blocking SimpleHTTPRequestHandler ?

2015-02-02 Thread yacinechaouche
I wrote a little script that acts like a proxy, you just give it a URL and it 
will fetch the content and display it back to you. 

For some reason, this proxy blocks sometimes and refuses to serve any new 
queries. The script still runs, but it seems like it's stuck somewhere.

When I strace it to see what it's doing, I find it hanging on this instruction 
: 
root@backup[10.10.10.21] ~/SCRIPTS/INFOMANIAK # strace -fp 6918
Process 6918 attached - interrupt to quit
recvfrom(6,
^CProcess 6918 detached
root@backup[10.10.10.21] ~/SCRIPTS/INFOMANIAK # 

I read in the SimpleHTTPServer source code that one can inherit from the 
SocketServer.TrheadingMixIn mixin to enable a threaded server to handle 
multiple requests at a time instead of just one (thinking maybe that's what was 
blocking it). However, it seems like it has nothing to do with my problem. What 
I need to do is not only handle multiple requests at a time, but more 
importantly to make the request handler non-blocking.

Any ideas ? here's come code : 

import SimpleHTTPServer
import BaseHTTPServer
import SocketServer
import requests

class 
Handler(SocketServer.ThreadingMixIn,SimpleHTTPServer.SimpleHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header('Content-Type', 'text/html')
self.end_headers()
# self.path will contain a URL to be fetched by my proxy
self.wfile.write(getFlux(self.path.lstrip("/")))

session = requests.Session()
IP,PORT = "MY_IP_HERE",8080

def getFlux(url):
response  = session.get(url)
s = response.text
return s

server = BaseHTTPServer.HTTPServer((IP,PORT),Handler)
server.serve_forever()

Thank you.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to write a non blocking SimpleHTTPRequestHandler ?

2015-02-02 Thread Amirouche Boubekki
On Mon Feb 02 2015 at 10:55:26 AM 
wrote:

> I wrote a little script that acts like a proxy, you just give it a URL and
> it will fetch the content and display it back to you.
>
> For some reason, this proxy blocks sometimes and refuses to serve any new
> queries. The script still runs, but it seems like it's stuck somewhere.
>
> When I strace it to see what it's doing, I find it hanging on this
> instruction :
> root@backup[10.10.10.21] ~/SCRIPTS/INFOMANIAK # strace -fp 6918
> Process 6918 attached - interrupt to quit
> recvfrom(6,
> ^CProcess 6918 detached
> root@backup[10.10.10.21] ~/SCRIPTS/INFOMANIAK #
>
> I read in the SimpleHTTPServer source code that one can inherit from the
> SocketServer.TrheadingMixIn mixin to enable a threaded server to handle
> multiple requests at a time instead of just one (thinking maybe that's what
> was blocking it). However, it seems like it has nothing to do with my
> problem. What I need to do is not only handle multiple requests at a time,
> but more importantly to make the request handler non-blocking.
>
> Any ideas ? here's come code :
>
> import SimpleHTTPServer
> import BaseHTTPServer
> import SocketServer
> import requests
>
> class Handler(SocketServer.ThreadingMixIn,SimpleHTTPServer.SimpleH
> TTPRequestHandler):
> def do_GET(self):
> self.send_response(200)
> self.send_header('Content-Type', 'text/html')
> self.end_headers()
> # self.path will contain a URL to be fetched by my proxy
> self.wfile.write(getFlux(self.path.lstrip("/")))
>
> session = requests.Session()
> IP,PORT = "MY_IP_HERE",8080
>
> def getFlux(url):
> response  = session.get(url)
> s = response.text
> return s
>
> server = BaseHTTPServer.HTTPServer((IP,PORT),Handler)
> server.serve_forever()
>


Your code seem perfectly fine. I had some trouble with py3's http.server
with IE10 (in a virtualbox...), I put together a small server script
similar to http.server that doesn't hang up on microsoft. It works with
ayncio. It's not ready to serve big files, but hopefully you can fix that.


HTH



> Thank you.
> --
> https://mail.python.org/mailman/listinfo/python-list
>
#!/usr/bin/env python3
import os
import mimetypes
from asyncio import coroutine
from asyncio import get_event_loop

from aiohttp.web import Application
from aiohttp.web import StaticRoute
from aiohttp.web import HTTPNotFound
from aiohttp.web import HTTPMovedPermanently
from aiohttp.web import StreamResponse


class StaticRouteWithIndex(StaticRoute):

limit = 8192

@coroutine
def handle(self, request):
resp = StreamResponse()
filename = request.match_info['filename']
filepath = os.path.join(self._directory, filename)

if '..' in filename:
print('not found %s' % filepath)
raise HTTPNotFound()
if not os.path.exists(filepath):
print('not found %s' % filepath)
raise HTTPNotFound()

if not os.path.isfile(filepath):
directory = filepath
filename = None
if not filepath.endswith('/'):
path = filepath + '/'
path = path[len(self._directory):]
raise HTTPMovedPermanently(path)
for index in ('index.html', 'index.htm'):
path = os.path.join(directory, index)
if os.path.exists(path):
filename = index
filepath = path
break

if not filename and os.path.isdir(filepath):
if not filepath.endswith('/'):
filepath += '/'
names = os.listdir(filepath)
names.sort()
output = ''
for name in names:
dirname = os.path.join(filepath, name)
if os.path.isdir(dirname):
dirname += '/'
path = dirname[len(self._directory):]
link = '%s' % (path, name)
output += '' + link + ''
output += ''
resp.content_type = 'text/html'
resp.start(request)
resp.write(output.encode('utf-8'))
return resp
elif not filename:
print('not found %s' % filepath)
raise HTTPNotFound()
else:
ct = mimetypes.guess_type(filename)[0]
if not ct:
ct = 'application/octet-stream'
resp.content_type = ct

file_size = os.stat(filepath).st_size
single_chunk = file_size < self.limit

if single_chunk:
resp.content_length = file_size
resp.start(request)

with open(filepath, 'rb') as f:
chunk = f.read(self.limit)
if single_chunk:
resp.write(chunk)
else:
while chunk:
resp.write(chunk)
chunk = f.read(self.limit)
print('ok %s' % f

Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-02 Thread Steven D'Aprano
Devin Jeanpierre wrote:

> -- Devin
> 
> On Sun, Feb 1, 2015 at 11:15 PM, Steven D'Aprano
>  wrote:
>> Gregory Ewing wrote:
>>
>>> Steven D'Aprano wrote:
 [quote]
 If the object has a method named __dir__(), this method will
 be called and must return the list of attributes.
 [end quote]

 The first inaccuracy is that like all (nearly all?) dunder methods,
 Python only looks for __dir__ on the class, not the instance itself.
>>>
>>> It says "method", not "attribute", so technically
>>> it's correct. The methods of an object are defined
>>> by what's in its class.
>>
>> Citation please. I'd like to see where that is defined.
> 
> https://docs.python.org/3/glossary.html#term-method

Run this code using any version of Python from 1.5 onwards, and you will see
that the definition is wrong:


# === cut ===

class K:
def f(self): pass

# Define a function OUTSIDE of a class body.
def g(self): pass

K.g = g
instance = K()
assert type(instance.f) is type(instance.g)
print(type(instance.f))
print(type(instance.g))

# === cut ===


Both K.f and K.g are methods, even though only one meets the definition
given in the glossary. The glossary is wrong.

Or rather, it is not so much that it is *wrong*, but that it is incomplete
and over-simplified. It describes how methods are normally (but not always)
defined, but not what they are. It is rather like defining "coffee" as the
milky drink you buy from Starbucks, then insisting that the black liquid
that you drank in an Italian restaurant cannot be coffee because you didn't
buy it from Starbucks.

Glossary entries are typically simplified, not exhaustive. It is not wise to
take a three line glossary entry as a complete, definite explanation. In
this case the glossary fails to tell you that methods are not *required* to
be defined inside a class body, that is merely the usual way to do it.



>> Even if it is so defined, the definition is wrong. You can define methods
>> on an instance. I showed an example of an instance with its own personal
>> __dir__ method, and showed that dir() ignores it if the instance belongs
>> to a new-style class but uses it if it is an old-style class.
> 
> You didn't define a method, you defined a callable attribute.

That is wrong. I defined a method:

py> from types import MethodType
py> type(instance.f) is MethodType
True


instance.f is a method by the glossary definition. Its type is identical to
types.MethodType, which is what I used to create a method by hand.

I could also call the descriptor __get__ method by hand, if you prefer:

py> def h(self): pass
...
py> method = h.__get__(K, instance)
py> assert type(method) is type(instance.f)
py> print(method)
>



-- 
Steven

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


Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-02 Thread Steven D'Aprano
Steven D'Aprano wrote:

> Both K.f and K.g are methods, even though only one meets the definition
> given in the glossary. The glossary is wrong.

Oh I'm sure somebody is going to pick me up on this... 

In Python 2, they are methods. In Python 3, they are functions, and aren't
converted into methods until you access them via the instance:

K.f returns the function f

instance.f typically retrieves the function f from K, and converts it to a
method object bound to instance



-- 
Steven

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


Re: Python is DOOMED! Again!

2015-02-02 Thread Rustom Mody
On Monday, February 2, 2015 at 1:13:30 PM UTC+5:30, Paul Rubin wrote:
> Steven D'Aprano writes:
> > No apples and no oranges aren't the same thing, but if somebody is 
> > expecting 
> > no apples, and I give them no oranges instead, it would be churlish for 
> > them 
> > to complain that none of them are the wrong kind of fruit.
> 
> https://davedevine.wordpress.com/2011/01/20/the-sartre-joke/

Actually the Sartre joke is more applicable to haskell than it might appear at 
first blush.

li = [1,2,3] : [Int] -- a monomorphic type
just as
lc = ['a','b','c'] : [Char]
lli = [[1,2],[3]] : [[Int]]

However [] is a polymorphic value ie
[] : [t]   -- t is a type variable

And now if we take
tail (tail (tail li)) 
you get []
just as if you take
tail (tail lli)

However the two '[]-s' are of different types
and so if you try to say append them you will get a Sartre error:

The list of no integers is incompatible with the list of no lists of integers
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-02 Thread Rustom Mody
On Monday, February 2, 2015 at 10:57:27 AM UTC+5:30, Vito De Tullio wrote:
> Steven D'Aprano wrote:
> 
> > Checking the REPL first would have revealed that [].__dir__ raises
> > AttributeError. In other words, lists don't have a __dir__ method.
> 
> ?
> 
> Python 3.4.2 (default, Nov 29 2014, 00:45:45) 
> [GCC 4.8.3] on linux
> Type "help", "copyright", "credits" or "license" for more information.
> >>> [].__dir__()
> ['sort', '__contains__', '__init__', '__ge__', 'count', '__class__', 
> '__format__', '__mul__', 'index', '__rmul__', '__hash__', '__iter__', 
> 'clear', '__subclasshook__', '__getitem__', 'reverse', 'append', '__ne__', 
> 'pop', '__reduce__', '__add__', 'extend', '__gt__', '__sizeof__', 
> '__setattr__', '__imul__', '__dir__', '__le__', 'insert', '__repr__', 
> '__str__', '__getattribute__', '__len__', '__lt__', 'remove', '__new__', 
> '__reduce_ex__', 'copy', '__reversed__', '__delattr__', '__eq__', 
> '__setitem__', '__iadd__', '__doc__', '__delitem__']
> >>> 

Sure
But as I said (and probably Steven checked):

$ python
Python 2.7.8 (default, Oct 20 2014, 15:05:19) 
[GCC 4.9.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> [].__dir__
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'list' object has no attribute '__dir__'

---
My point was more methodological/sociological than technical:

Are these dunder methods as 'internal' as say the register-allocation used
by a C compiler?

In which case the language implementer is entitled to tell the vanilla 
programmer: "Dunder methods (and their changingness) is none of your business"

If however they are more on the public façade of the language then some better
docs would be nice
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-02 Thread Steven D'Aprano
Rustom Mody wrote:

> My point was more methodological/sociological than technical:
> 
> Are these dunder methods as 'internal' as say the register-allocation used
> by a C compiler?


Dunder methods are implementation, not interface. If you are the class
author, then you care about the implementation, and write dunder methods.
But as the class user, you should not call dunder methods directly, instead
always go through the public interface:

# Not these.
a.__dir__()
seq.__len__()
x.__add__(y)
spam.__eq__(ham)

# Use these
dir(a)
len(seq)
x + y
spam == ham



-- 
Steven

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


Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-02 Thread Devin Jeanpierre
On Mon, Feb 2, 2015 at 4:06 AM, Steven D'Aprano
 wrote:
>> On Sun, Feb 1, 2015 at 11:15 PM, Steven D'Aprano
>>  wrote:
> Both K.f and K.g are methods, even though only one meets the definition
> given in the glossary. The glossary is wrong.

I agree, it oversimplified and has made a useless distinction here.

>>> Even if it is so defined, the definition is wrong. You can define methods
>>> on an instance. I showed an example of an instance with its own personal
>>> __dir__ method, and showed that dir() ignores it if the instance belongs
>>> to a new-style class but uses it if it is an old-style class.
>>
>> You didn't define a method, you defined a callable attribute.
>
> That is wrong. I defined a method:
>
> py> from types import MethodType
> py> type(instance.f) is MethodType
> True
>
>
> instance.f is a method by the glossary definition. Its type is identical to
> types.MethodType, which is what I used to create a method by hand.

You are assuming that they are both methods, just because they are
instances of a type called "MethodType". This is like assuming that a
Tree() object is made out of wood.

The documentation is free to define things in terms other than types
and be correct. There are many properties of functions-on-classes that
callable instance attributes that are instances of MethodType do not
have, as we've already noticed. isinstance can say one thing, and the
documentation another, and both can be right, because they are saying
different things.


For an example we can all agree on, this is not an instance of
collections.Iterable, but the docs claim it is iterable:
https://docs.python.org/2/glossary.html#term-iterable

class MyIterable(object):
def __getitem__(self, i): return i

The docs are not "wrong", they are just making a distinction for
humans that is separate from the python types involved. This is OK.

-- Devin
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-02 Thread Devin Jeanpierre
On Mon, Feb 2, 2015 at 5:00 AM, Devin Jeanpierre  wrote:
> On Mon, Feb 2, 2015 at 4:06 AM, Steven D'Aprano
>  wrote:
>>> On Sun, Feb 1, 2015 at 11:15 PM, Steven D'Aprano
>>>  wrote:
>> Both K.f and K.g are methods, even though only one meets the definition
>> given in the glossary. The glossary is wrong.
>
> I agree, it oversimplified and has made a useless distinction here.

Oops, I just realized why such a claim might be made: the
documentation probably wants to be able to say that any method can use
super(). So that's why it claims that it isn't a method unless it's
defined inside a class body.

-- Devin

 Even if it is so defined, the definition is wrong. You can define methods
 on an instance. I showed an example of an instance with its own personal
 __dir__ method, and showed that dir() ignores it if the instance belongs
 to a new-style class but uses it if it is an old-style class.
>>>
>>> You didn't define a method, you defined a callable attribute.
>>
>> That is wrong. I defined a method:
>>
>> py> from types import MethodType
>> py> type(instance.f) is MethodType
>> True
>>
>>
>> instance.f is a method by the glossary definition. Its type is identical to
>> types.MethodType, which is what I used to create a method by hand.
>
> You are assuming that they are both methods, just because they are
> instances of a type called "MethodType". This is like assuming that a
> Tree() object is made out of wood.
>
> The documentation is free to define things in terms other than types
> and be correct. There are many properties of functions-on-classes that
> callable instance attributes that are instances of MethodType do not
> have, as we've already noticed. isinstance can say one thing, and the
> documentation another, and both can be right, because they are saying
> different things.
>
>
> For an example we can all agree on, this is not an instance of
> collections.Iterable, but the docs claim it is iterable:
> https://docs.python.org/2/glossary.html#term-iterable
>
> class MyIterable(object):
> def __getitem__(self, i): return i
>
> The docs are not "wrong", they are just making a distinction for
> humans that is separate from the python types involved. This is OK.
>
> -- Devin
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [OT] fortran lib which provide python like data type

2015-02-02 Thread Paul Rudin
Marko Rauhamaa  writes:

> Chris Angelico :
>
>> On Mon, Feb 2, 2015 at 12:59 PM, Steven D'Aprano
>>  wrote:
>>> And there are underspecified rules too. What is the plural of octopus? No
>>> fair looking it up in the dictionary.
>>
>> Standard and well-known piece of trivia, and there are several
>> options. "Octopodes" is one of the most rigorously formal, but
>> "octopuses" is perfectly acceptable. "Octopi" is technically
>> incorrect, as the -us ending does not derive from the Latin.
>
> Your brain's grammar engine will give you the correct answer. It may not
> match your English teacher's answer, but the language we are talking
> about is not standard English but the dialect you have acquired in
> childhood.

Aha - the Humpty Dumpty approach to English usage: "When I use a word it
means just what I choose it to mean..."

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


Is there a cairo like surface for the screen without the window hassle

2015-02-02 Thread Antoon Pardon
I need to have a program construct a number of designs. Of course I can directly
use a pfd surface and later use a pdf viewer to check. But that becomes rather
cumbersome fast. But if I use a cairo-surface for on the screen I suddenly have
to cope with expose events and all such things I am not really interested in.

So does someone know of a package that provides a cairo like surface but that
would take care of the events in a rather straight forward matter, so that my
program could make it's design in a window on the screen just as if it is
designing it in a pdf file.

-- 
Antoon Pardon

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


Re: [OT] fortran lib which provide python like data type

2015-02-02 Thread Marko Rauhamaa
Paul Rudin :

> Marko Rauhamaa  writes:
>> Your brain's grammar engine will give you the correct answer. It may
>> not match your English teacher's answer, but the language we are
>> talking about is not standard English but the dialect you have
>> acquired in childhood.
>
> Aha - the Humpty Dumpty approach to English usage: "When I use a word
> it means just what I choose it to mean..."

Yes, and your Humpty Dumpty brain is stringent about the proper usage.
Your brain happens to be highly aligned with those of your childhood
friends. Your communal dialect has thousands of rigorous rules, only you
couldn't make a complete list of them.


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [OT] fortran lib which provide python like data type

2015-02-02 Thread beliavsky
On Friday, January 30, 2015 at 5:51:38 PM UTC-5, Gregory Ewing wrote:
> Michael Torrie wrote:
> > On 01/30/2015 10:31 AM, Rustom Mody wrote:
> > 
> >>And what about the grey area between lightweight and heavyweight?
> > 
> > That's what the smart pointers are for.
> 
> I'd say it's what higher-level languages are for. :-)
> 
> I'm completely convinced nowadays that there is
> *no* use case for C++. If you need to program the
> bare metal, use C. For anything more complicated,
> use a language that has proper memory-management
> abstractions built in.

Lots of people are using C++ to build packages for statistical programming 
language R, using the package Rcpp. It has been possible to build such packages 
for R and S using Fortran and C since the beginning, and many have done so, but 
the wide usage of Rcpp suggests that there are advantages to using C++. C++ is 
still the primary language used by financial derivatives quants.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-02 Thread Steven D'Aprano
Devin Jeanpierre wrote:

> On Mon, Feb 2, 2015 at 4:06 AM, Steven D'Aprano
>  wrote:

>> instance.f is a method by the glossary definition. Its type is identical
>> to types.MethodType, which is what I used to create a method by hand.
> 
> You are assuming that they are both methods, just because they are
> instances of a type called "MethodType". This is like assuming that a
> Tree() object is made out of wood.

No. It is "assuming" that a Tree() object is a Tree() object.

Run this code:

# === cut ===

class K(object):
def f(self): pass

def f(self): pass

instance = K()
things = [instance.f, f.__get__(instance, K)]
from random import shuffle
shuffle(things)
print(things)

# === cut ===


You allege that one of these things is a method, and the other is not. I
challenge you to find any behavioural or functional difference between the
two. (Object IDs don't count.)

If you can find any meaningful difference between the two, I will accept
that methods have to be created as functions inside a class body.

Otherwise you are reduced to claiming that there is some sort of mystical,
undetectable "essence" or "spirit" that makes one of those two objects a
real method and the other one a fake method, even though they have the same
type, the same behaviour, and there is no test that can tell you which is
which.


> The documentation is free to define things in terms other than types
> and be correct. 

If you wanted to argue that "method" is a generic term, and we have instance
methods, class methods, static methods, and any other sort of method we
care to create using the descriptor protocol, then I would agree you have a
point.

But since we're just talking about instance methods, Python doesn't care how
they came into existence. You can use def to create a function inside a
class body, inject a function into the class, call the descriptor __get__
method, or use the types.MethodType type object, it is all the same. You
can use a def statement, or a lambda, or types.FunctionType if you are
really keen. It makes no difference.

Do I expect the glossary to go into such pedantic detail? No, of course not.
But I do expect anyone with a few years of Python programming experience to
be able to understand that what makes a method be a method is its type and
behaviour, not where it came from.


> There are many properties of functions-on-classes that 
> callable instance attributes that are instances of MethodType do not
> have, as we've already noticed. isinstance can say one thing, and the
> documentation another, and both can be right, because they are saying
> different things.
> 
> 
> For an example we can all agree on, this is not an instance of
> collections.Iterable, but the docs claim it is iterable:
> https://docs.python.org/2/glossary.html#term-iterable
> 
> class MyIterable(object):
> def __getitem__(self, i): return i

"Iterable" is a generic term, not a type. Despite the existence of the
collections.Iterable ABC, "iterable" refers to any type which can be
iterated over, using either of two different protocols.

As I said above, if you wanted to argue that "method" was a general term for
any callable attached to an instance or class, then you might have a point.
But you're doing something much weirder: you are arguing that given two
objects which are *identical* save for their object ID, one might be called
a method, and the other not, due solely to where it was created. Not even
where it was retrieved from, but where it was created.

If you believe that "method or not" depends on where the function was
defined, then this will really freak you out:


py> class Q:
... def f(self): pass  # f defined inside the class
...
py> def f(self): pass  # f defined outside the class
...
py> f, Q.f = Q.f, f  # Swap the "inside" f and the "outside" f.
py> instance = Q()
py> instance.f  # Uses "outside" f, so not a real method!
>
py> MethodType(f, instance)  # Uses "inside" f, so is a real method!
>



-- 
Steven

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


Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-02 Thread Steven D'Aprano
Devin Jeanpierre wrote:

> Oops, I just realized why such a claim might be made: the
> documentation probably wants to be able to say that any method can use
> super(). So that's why it claims that it isn't a method unless it's
> defined inside a class body.


You can use super anywhere, including outside of classes. The only thing you
can't do is use the Python 3 "super hack" which automatically fills in the
arguments to super if you don't supply them. That is compiler magic which
truly does require the function to be defined inside a class body. But you
can use super outside of classes:


py> class A(list):
... pass
...
py> x = super(A)  # Unbound super object!
py> x.__get__(A).append

py> a = A()
py> x.__get__(a).append




-- 
Steven

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


Downloading videos (in flash applications) using python

2015-02-02 Thread Gabriel Ferreira
Hello, 

I need some help in downloading videos from flash applications in web using 
python. Is there any lib to deal with flash player using python?

The videos I need to download are, in fact, live streaming content.
You can see an example here:

http://vejoaovivo.com.br/sc/itapema/avenida-nereu-ramos-1029.html

Thanks
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [OT] fortran lib which provide python like data type

2015-02-02 Thread Mark Lawrence

On 02/02/2015 04:47, Chris Angelico wrote:

On Mon, Feb 2, 2015 at 3:14 PM, Roy Smith  wrote:

In article <54ceda0b$0$12977$c3e8da3$54964...@news.astraweb.com>,
  Steven D'Aprano  wrote:


What is the plural of octopus?


It's a trick question.  Octopus is already plural.  Monopus is singular.


People is already plural, too, but you can talk about all the peoples
of the world. Also, I can use "people" as the subject and "is" as the
verb, just to completely destroy any chance of a simple grammar parser
being able to cope with English.

ChrisA



I'm simple and I cope (somehow) with English.

--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: [OT] fortran lib which provide python like data type

2015-02-02 Thread Mark Lawrence

On 02/02/2015 08:52, Marko Rauhamaa wrote:

Chris Angelico :


On Mon, Feb 2, 2015 at 12:59 PM, Steven D'Aprano
 wrote:

And there are underspecified rules too. What is the plural of octopus? No
fair looking it up in the dictionary.


Standard and well-known piece of trivia, and there are several
options. "Octopodes" is one of the most rigorously formal, but
"octopuses" is perfectly acceptable. "Octopi" is technically
incorrect, as the -us ending does not derive from the Latin.


Your brain's grammar engine will give you the correct answer. It may not
match your English teacher's answer, but the language we are talking
about is not standard English but the dialect you have acquired in
childhood.


Marko



I'd love to see a formal definition for "standard English".

--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: Downloading videos (in flash applications) using python

2015-02-02 Thread Steven D'Aprano
Gabriel Ferreira wrote:

> Hello,
> 
> I need some help in downloading videos from flash applications in web
> using python. Is there any lib to deal with flash player using python?

Try Youtube-DL

http://rg3.github.io/youtube-dl


-- 
Steven

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


Re: [OT] fortran lib which provide python like data type

2015-02-02 Thread Rustom Mody
On Monday, February 2, 2015 at 9:40:35 PM UTC+5:30, Mark Lawrence wrote:
> On 02/02/2015 08:52, Marko Rauhamaa wrote:
> > Chris Angelico :
> >
> >> On Mon, Feb 2, 2015 at 12:59 PM, Steven D'Aprano wrote:
> >>> And there are underspecified rules too. What is the plural of octopus? No
> >>> fair looking it up in the dictionary.
> >>
> >> Standard and well-known piece of trivia, and there are several
> >> options. "Octopodes" is one of the most rigorously formal, but
> >> "octopuses" is perfectly acceptable. "Octopi" is technically
> >> incorrect, as the -us ending does not derive from the Latin.
> >
> > Your brain's grammar engine will give you the correct answer. It may not
> > match your English teacher's answer, but the language we are talking
> > about is not standard English but the dialect you have acquired in
> > childhood.
> >
> >
> > Marko
> >
> 
> I'd love to see a formal definition for "standard English".
> 

I'd also love to see a formal definition of 'formal'
Elsewhere someone (Marko I think) used the term 'rigorous'

Ive heard it said that formal is more rigorous than 'rigorous'.
And of course the other way round as well ;-)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Downloading videos (in flash applications) using python

2015-02-02 Thread Gabriel Ferreira
Thanks for the Hint... But it seems not to support the website i mentioned... 
Is there a way to make it possible for any kind of video player in the net? 
Flash player... Since it's not a ordinary video... I'm trying to record & 
download a live streaming video!! 

Thx
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [OT] fortran lib which provide python like data type

2015-02-02 Thread Michael Torrie
On 02/02/2015 12:39 AM, Marko Rauhamaa wrote:
> Michael Torrie :
> 
>> http://en.cppreference.com/w/cpp/utility/functional/function
>>
>> Thus if we were to shoehorn your example into C++, the result would be
>> idiomatically very similar to what you have in your Python code.
> 
> I can understand why you wouldn't write out my example in C++:

I wouldn't write it out because it's a contrived example, and why should
I waste my time? You have no intention of being impressed with C++, let
alone simply learn about it.

> 
>using std::placeholders::_1;
> 
>std::function f_add_display2 =
> std::bind( &Foo::print_add, foo, _1 );

Looks okay to me.  That's normal C++ that would be clear to any C++
programmer.  And for a statically compiled language, that's incredibly
powerful while providing for a measure of safety.  You may shudder, but
it's a really good statically compiled solution, given the constraints
of C++ and its compiler.

But like I said, idiomatically in C++, this isn't normally what you'd do
anyway.  You'd store a std::ostream object.

> vs
> 
>f_add_display2 = foo.print_add
> 
> The cherry on top: "_1"! The C++ compiler figures out template types
> heroically but can't wrap its head around the arity of the method.

std::bind is a generic function that works with undecorated function
pointers.  There's no possible way for the compiler to know the arity of
the function without you telling it (how else would you do it? I
honestly want to know.).  That you would find this fact to be
incredulous suggests that you have very little understanding of
compilers in general.  Python being a dynamic, interpreted language can
examine a function at runtime.

Python is a very expressive language compared to C++ that can do things
at runtime that C++ cannot.  It's also an interpreted, dynamically-typed
language, whereas C++ is a statically-typed language that is clearly
faster at many things than Python is.  It's a matter of different tools
for different jobs.  For most of my jobs Python is the right tool.  But
I can see why people would still want to pick a compiled language, and I
can understand why some people still use C++.  It's a very powerful
language.

I'm a little unclear as to why you're even bringing up the comparison
with C++.  What's your point?  To feel superior?


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


Re: [OT] fortran lib which provide python like data type

2015-02-02 Thread Mark Lawrence

On 02/02/2015 16:21, Rustom Mody wrote:

On Monday, February 2, 2015 at 9:40:35 PM UTC+5:30, Mark Lawrence wrote:

On 02/02/2015 08:52, Marko Rauhamaa wrote:

Chris Angelico :


On Mon, Feb 2, 2015 at 12:59 PM, Steven D'Aprano wrote:

And there are underspecified rules too. What is the plural of octopus? No
fair looking it up in the dictionary.


Standard and well-known piece of trivia, and there are several
options. "Octopodes" is one of the most rigorously formal, but
"octopuses" is perfectly acceptable. "Octopi" is technically
incorrect, as the -us ending does not derive from the Latin.


Your brain's grammar engine will give you the correct answer. It may not
match your English teacher's answer, but the language we are talking
about is not standard English but the dialect you have acquired in
childhood.


Marko



I'd love to see a formal definition for "standard English".



I'd also love to see a formal definition of 'formal'
Elsewhere someone (Marko I think) used the term 'rigorous'

Ive heard it said that formal is more rigorous than 'rigorous'.
And of course the other way round as well ;-)



I'd like to see anybody define 'a' and 'the' without using 'a' and 
'the'.  Would that be formally rigorous or rigorously formal?


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: Is there a cairo like surface for the screen without the window hassle

2015-02-02 Thread Paul Rubin
Antoon Pardon  writes:
> So does someone know of a package that provides a cairo like surface

Not sure what a cairo like surface is, but maybe you want HTML5 Canvas
that's built into recent browsers.  So you'd just embed a web server
in your application and interact with it through a browser.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [OT] fortran lib which provide python like data type

2015-02-02 Thread Chris Angelico
On Tue, Feb 3, 2015 at 3:52 AM, Mark Lawrence  wrote:
> I'd like to see anybody define 'a' and 'the' without using 'a' and 'the'.
> Would that be formally rigorous or rigorously formal?

a: Indefinite article, used to represent individual objects not
otherwise identifiable.

the: Definite article, used to represent individual objects
identifiable by context.

Near enough?

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [OT] fortran lib which provide python like data type

2015-02-02 Thread Marko Rauhamaa
Michael Torrie :

> You have no intention of being impressed with C++, let alone simply
> learn about it.

I am fully open to being impressed. I have more than a decade of C++
programming under my belt, although not much for the past few years.

> There's no possible way for the compiler to know the arity of
> the function without you telling it (how else would you do it?

Somehow, C# manages it just fine.

> I honestly want to know.).

See

  https://msdn.microsoft.com/en-us/library/aa288459%28v=vs.71%29.aspx>

> That you would find this fact to be incredulous suggests that you have
> very little understanding of compilers in general. Python being a
> dynamic, interpreted language can examine a function at runtime.

C# does it at compile-time. C++ could have and should have introduced
delegates early on. The method pointer syntax was screaming for delegate
semantics. Too bad that didn't occur to Stroustrup until it was too
late.

> I'm a little unclear as to why you're even bringing up the comparison
> with C++. What's your point? To feel superior?

I really don't understand why you are taking all of this so personally.
We are just discussing different aspects of different programming
languages.


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [OT] fortran lib which provide python like data type

2015-02-02 Thread Michael Torrie
On 02/02/2015 10:57 AM, Marko Rauhamaa wrote:
> I really don't understand why you are taking all of this so personally.
> We are just discussing different aspects of different programming
> languages.

Fair enough. You raise good points.  I am not taking it personally; your
emails, lacking emotional context, just seemed a bit unnecessarily
argumentative. For example, "The cherry on top: "_1"! The C++ compiler
figures out template types heroically but can't wrap its head around the
arity of the method".
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [OT] fortran lib which provide python like data type

2015-02-02 Thread Mark Lawrence

On 02/02/2015 17:25, Chris Angelico wrote:

On Tue, Feb 3, 2015 at 3:52 AM, Mark Lawrence  wrote:

I'd like to see anybody define 'a' and 'the' without using 'a' and 'the'.
Would that be formally rigorous or rigorously formal?


a: Indefinite article, used to represent individual objects not
otherwise identifiable.

the: Definite article, used to represent individual objects
identifiable by context.

Near enough?

ChrisA



Nope.  'article' begins with 'a' so you can't use it to define itself.

--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: Downloading videos (in flash applications) using python

2015-02-02 Thread Irmen de Jong
On 2-2-2015 17:22, Gabriel Ferreira wrote:
> Thanks for the Hint... But it seems not to support the website i mentioned... 
> Is
> there a way to make it possible for any kind of video player in the net? Flash
> player... Since it's not a ordinary video... I'm trying to record & download 
> a live
> streaming video!!
> 
> Thx
> 


Youtube-dl has a modular structure and is open-source:
https://github.com/rg3/youtube-dl/

It should be fairly easy to add a module/plugin that groks your site.

Irmen
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Create dictionary based of x items per key from two lists

2015-02-02 Thread rajanbond
On Saturday, 31 January 2015 18:39:01 UTC-8, Jason Friedman  wrote:
> > I have two lists
> >
> > l1 =  ["a","b","c","d","e","f","g","h","i","j"]
> > l2 = ["aR","bR","cR"]
> >
> > l2 will always be smaller or equal to l1
> >
> > numL1PerL2 = len(l1)/len(l2)
> >
> > I want to create a dictionary that has key from l1 and value from l2 based 
> > on numL1PerL2
> >
> > So
> >
> > {
> > a:aR,
> > b:aR,
> > c:aR,
> > d:bR,
> > e:bR,
> > f:bR,
> > g:cR,
> > h:cR,
> > i:cR,
> > j:cR
> > }
> 
> Another possibility is:
> import itertools
> my_dict = {x:y for x,y in zip(list1, itertools.cycle(list2))}

NO. Sorry if this was not very clear.

In teh above example- len(l1) = 10
len(l2) = 3

So, the dict can not have more than 3 keys from l1 with same value from l2 
except the last element from l1 .

So 
a,b,c will have one key- say aR
d,e,f - bR
g,h,i,j- cR- j has key cR because the number l1 is not completely divisible by 
l2 and leave a remainder.

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


Re: How to write a non blocking SimpleHTTPRequestHandler ?

2015-02-02 Thread Irmen de Jong
On 2-2-2015 10:54, yacinechaou...@yahoo.com wrote:
> I wrote a little script that acts like a proxy, you just give it a URL and it 
> will
> fetch the content and display it back to you.
> 
> For some reason, this proxy blocks sometimes and refuses to serve any new 
> queries.
> The script still runs, but it seems like it's stuck somewhere.
> 
> When I strace it to see what it's doing, I find it hanging on this 
> instruction : 
> root@backup[10.10.10.21] ~/SCRIPTS/INFOMANIAK # strace -fp 6918 Process 6918 
> attached
> - interrupt to quit recvfrom(6, ^CProcess 6918 detached 
> root@backup[10.10.10.21]
> ~/SCRIPTS/INFOMANIAK #
> 
> I read in the SimpleHTTPServer source code that one can inherit from the
> SocketServer.TrheadingMixIn mixin to enable a threaded server to handle 
> multiple
> requests at a time instead of just one (thinking maybe that's what was 
> blocking it).
> However, it seems like it has nothing to do with my problem. What I need to 
> do is not
> only handle multiple requests at a time, but more importantly to make the 
> request
> handler non-blocking.

Why? If you have multiple threads serving some requests at the same time, 
doesn't that
already achieve your goal? In other words, have you tried what you describe 
above?
(make sure you close the connection correctly or you'll be hogging a thread 
which may
eventually make the server non responsive)

Irmen
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [OT] fortran lib which provide python like data type

2015-02-02 Thread Marko Rauhamaa
Michael Torrie :

> Fair enough. You raise good points.  I am not taking it personally; your
> emails, lacking emotional context, just seemed a bit unnecessarily
> argumentative. For example, "The cherry on top: "_1"! The C++ compiler
> figures out template types heroically but can't wrap its head around the
> arity of the method".

I feel programming languages, being inanimate abstractions, can take my
abuse.


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Downloading videos (in flash applications) using python

2015-02-02 Thread Ben Finney
Gabriel Ferreira  writes:

> I need some help in downloading videos from flash applications in web
> using python. Is there any lib to deal with flash player using python?

Yes, the ‘youtube-dl’ application is the most likely to have the library
code you need.

> The videos I need to download are, in fact, live streaming content.
> You can see an example here:
>
> http://vejoaovivo.com.br/sc/itapema/avenida-nereu-ramos-1029.html

If ‘youtube-dl’ doesn't support a particular site, please report a bug
at its bug tracker. I'm sure they would like to have a working
implementation too.

This isn't really a question about using Python, so it may be best to
continue the discussion in a bug report against ‘youtube-dl’.

-- 
 \ “It is far better to grasp the universe as it really is than to |
  `\persist in delusion, however satisfying and reassuring.” —Carl |
_o__)Sagan |
Ben Finney

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


Re: Create dictionary based of x items per key from two lists

2015-02-02 Thread rajanbond
On Saturday, 31 January 2015 18:39:01 UTC-8, Jason Friedman  wrote:
> > I have two lists
> >
> > l1 =  ["a","b","c","d","e","f","g","h","i","j"]
> > l2 = ["aR","bR","cR"]
> >
> > l2 will always be smaller or equal to l1
> >
> > numL1PerL2 = len(l1)/len(l2)
> >
> > I want to create a dictionary that has key from l1 and value from l2 based 
> > on numL1PerL2
> >
> > So
> >
> > {
> > a:aR,
> > b:aR,
> > c:aR,
> > d:bR,
> > e:bR,
> > f:bR,
> > g:cR,
> > h:cR,
> > i:cR,
> > j:cR
> > }
> 
> Another possibility is:
> import itertools
> my_dict = {x:y for x,y in zip(list1, itertools.cycle(list2))}

Thank you Jason! Looks like this will work for my case. 

I had a solution working with count and num to keep track of the number of 
times l2 items are assigned as value but was looking for a more pythonic way.

count = 0
num = 0
map = {}
#for item in l2:
#   while count < numL1PerL2 and num <= len(l1):
#  map[l1[num]] = item
#  count += 1
#  num += 1
#   count = 0
#map[l1[num]] = l2[-1]

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


Re: Downloading videos (in flash applications) using python

2015-02-02 Thread Gabriel Ferreira
I appreciate your help. I'm just afraid that Youtube-DL doesn't allow me to 
record or download a LIVE STREAMING VIDEO. Do you guys think it is possible, 
since I make some adjustments into the code of the library?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Downloading videos (in flash applications) using python

2015-02-02 Thread Paul Rubin
Gabriel Ferreira  writes:
> I appreciate your help. I'm just afraid that Youtube-DL doesn't allow
> me to record or download a LIVE STREAMING VIDEO. Do you guys think it
> is possible, since I make some adjustments into the code of the
> library?

If the stream operator really wants stop you from downloading (and some
of them do), they can make it pretty difficult.  I haven't looked at
youtube-dl closely but those things are generally http retrievers.
Flash videos can use other sorts of streaming protocols, with Macromedia
or other DRM in some cases.  You can presumably still get around it with
enough hassle, but I decided a long time ago that I'd rather just shrink
the audience of those sorts of streams, by choosing not to watch them.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Downloading videos (in flash applications) using python

2015-02-02 Thread Gabriel Ferreira
Hi Paul, I presume the stream operator doesn't want to prevent me from 
downloading or recording the videos. I just wanna know more about some lib that 
could be used to deal with Flash Player Applications... Or possibly, anything 
that could lead me to be able to get those streaming videos.

Thx
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Downloading videos (in flash applications) using python

2015-02-02 Thread Irmen de Jong
On 2-2-2015 20:30, Gabriel Ferreira wrote:
> Hi Paul, I presume the stream operator doesn't want to prevent me from 
> downloading or recording the videos. I just wanna know more about some lib 
> that could be used to deal with Flash Player Applications... Or possibly, 
> anything that could lead me to be able to get those streaming videos.
> 
> Thx
> 


Right, have you tried VLC then? (unless you really want to do this from 
python...)
VLC can play streams, probably yours too, and convert it to another file.

Irmen

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


Re: Downloading videos (in flash applications) using python

2015-02-02 Thread Paul Rubin
Gabriel Ferreira  writes:
> Hi Paul, I presume the stream operator doesn't want to prevent me from
> downloading or recording the videos.  

It's hard to tell why anyone uses Flash anymore, but impeding (if not
preventing) downloads is probably a common reason.

> I just wanna know more about some lib that could be used to deal with
> Flash Player Applications... Or possibly, anything that could lead me
> to be able to get those streaming videos.

Gnash maybe?  https://www.gnu.org/software/gnash/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Downloading videos (in flash applications) using python

2015-02-02 Thread Michael Torrie
On 02/02/2015 12:30 PM, Gabriel Ferreira wrote:
> Hi Paul, I presume the stream operator doesn't want to prevent me
> from downloading or recording the videos. I just wanna know more
> about some lib that could be used to deal with Flash Player
> Applications... Or possibly, anything that could lead me to be able
> to get those streaming videos.

You can't do it directly with any Python library that I know of.  You
can, however, use the tools that come with rtmpdump:

https://rtmpdump.mplayerhq.hu/

It's not automatic, and requires some iptables tricks, but once you get
the stream information, you can always download it via rtmpdump.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Downloading videos (in flash applications) using python

2015-02-02 Thread Gabriel Ferreira
The original plan was doing it using python. But, anyway, I should build a 
robot program to do that task for me... Because I need to capture hundreds of 
hours of different videos... You mean that is difficult because it's Python... 
or it's difficult because it's a Flash Application?

Thx
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Downloading videos (in flash applications) using python

2015-02-02 Thread Mark Lawrence

On 02/02/2015 22:09, Gabriel Ferreira wrote:

The original plan was doing it using python. But, anyway, I should build a 
robot program to do that task for me... Because I need to capture hundreds of 
hours of different videos... You mean that is difficult because it's Python... 
or it's difficult because it's a Flash Application?

Thx



I don't actually know, but could you please provide some context and 
write in plain English, those damn ... things are extremely annoying.


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: [OT] fortran lib which provide python like data type

2015-02-02 Thread Chris Angelico
On Tue, Feb 3, 2015 at 5:34 AM, Mark Lawrence  wrote:
> On 02/02/2015 17:25, Chris Angelico wrote:
>>
>> On Tue, Feb 3, 2015 at 3:52 AM, Mark Lawrence 
>> wrote:
>>>
>>> I'd like to see anybody define 'a' and 'the' without using 'a' and 'the'.
>>> Would that be formally rigorous or rigorously formal?
>>
>>
>> a: Indefinite article, used to represent individual objects not
>> otherwise identifiable.
>>
>> Near enough?
>>
>
> Nope.  'article' begins with 'a' so you can't use it to define itself.

Hrm. This is difficult.

a: Indefinite identifier, used to represent non-specific objects.

Not a perfectly accurate definition now, but hey, I avoided the self-reference!

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Downloading videos (in flash applications) using python

2015-02-02 Thread Gabriel Ferreira
Mark Lawrence  wrote:

> I don't actually know, but could you please provide some context and 
> write in plain English, those damn ... things are extremely annoying.
> 

Hi, Mark. 

I am developing a research project, which includes video analysis (computer 
vision, big data, data mining, etc). The first part of the project is about 
building a database containing a big amount of video of urban zones. I live in 
Brazil, so the plan is collecting videos from urban areas of Brazilian big 
cities, like Sao Paulo. 

I have to make this task "automatic". in other words, I don't want to manually 
download hundreds or thousands hours of videos. So I have to develop a "robot" 
to do that assingment for me. (I wish I could do that using Python).

I have found a good website that provides me live images from several cities in 
Brazil. So that's it! That's what I need. I was expecting to develop a program 
to record & download those videos, that are being broadcasted live on that 
website. So I would be able to form my database and continue my research.

The problem is that this particular website uses a flash player application do 
broadcast the live images of the urban areas. I'm not too familiar with Flash 
Applications. I don't know how to deal with them using Python. I was wondering 
if someone could help me solve this problem. The goal is recording & 
downloading those videos, from the mentioned website. And, yes, it has to be an 
automated program (no manual work).

I wish I had been clear with you guys!

THX!

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


Re: Downloading videos (in flash applications) using python

2015-02-02 Thread Steven D'Aprano
Paul Rubin wrote:

> It's hard to tell why anyone uses Flash anymore

Masochism and/or sadism, depending on whether they get more pain from
writing the Flash code in the first place or pleasure from forcing Flash on
the viewer.



-- 
Steven

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


Re: Downloading videos (in flash applications) using python

2015-02-02 Thread Rustom Mody
On Tuesday, February 3, 2015 at 4:51:18 AM UTC+5:30, Gabriel Ferreira wrote:
> Mark Lawrence  wrote:
> 
> > I don't actually know, but could you please provide some context and 
> > write in plain English, those damn ... things are extremely annoying.
> > 
> 
> Hi, Mark. 
> 
> I am developing a research project, which includes video analysis (computer 
> vision, big data, data mining, etc). The first part of the project is about 
> building a database containing a big amount of video of urban zones. I live 
> in Brazil, so the plan is collecting videos from urban areas of Brazilian big 
> cities, like Sao Paulo. 
> 
> I have to make this task "automatic". in other words, I don't want to 
> manually download hundreds or thousands hours of videos. So I have to develop 
> a "robot" to do that assingment for me. (I wish I could do that using Python).

Develop robot -- right
Do it in python -- probably not so right

> 
> I have found a good website that provides me live images from several cities 
> in Brazil. So that's it! That's what I need. I was expecting to develop a 
> program to record & download those videos, that are being broadcasted live on 
> that website. So I would be able to form my database and continue my research.
> 
> The problem is that this particular website uses a flash player application 
> do broadcast the live images of the urban areas. I'm not too familiar with 
> Flash Applications. I don't know how to deal with them using Python. I was 
> wondering if someone could help me solve this problem. The goal is recording 
> & downloading those videos, from the mentioned website. And, yes, it has to 
> be an automated program (no manual work).

The instinct is natural but probably inaccurate:
Python is nice; JS/Flash not so much.

However to get on top of this you probably need to debug the streaming
with a modern browser using JS developer-tools/firebug etc, so that then
you can script what you have debugged.

If you do it in JS, there will be minor glitches once you have debugged the 
process.
If you do it in python, you will have to jump into (rather out of) many hoops
to go from JS to python.
And debugging the process is not an option.

[Disclaimer: I dont know what I am talking about]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Downloading videos (in flash applications) using python

2015-02-02 Thread Michael Torrie
On 02/02/2015 04:21 PM, Gabriel Ferreira wrote:
> The problem is that this particular website uses a flash player
> application do broadcast the live images of the urban areas. I'm not
> too familiar with Flash Applications. I don't know how to deal with
> them using Python. I was wondering if someone could help me solve
> this problem. The goal is recording & downloading those videos, from
> the mentioned website. And, yes, it has to be an automated program
> (no manual work).

As I said before you need to look into the RTP protocol.  There are
utilities for proxying and dumping the stream parameters.  Once they are
known you can pull them in using rtmpdump.  Sometimes the stream
parameters can be determined from the web page.  get_iplayer, for
instance, can create rtp parameters for BBC programs and then stream
them with rtmpdump, since the parameters seem to be well defined and
consistent.  But every streaming site is going to be different.  I
posted the link to the rtmpdump utilities in my other post.  You may be
to drive rtmpdump from Python.

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


Ghost vulnerability

2015-02-02 Thread Rustom Mody
How many people (actually machines) out here are vulnerable?

http://security.stackexchange.com/questions/80210/ghost-bug-is-there-a-simple-way-to-test-if-my-system-is-secure

shows a python 1-liner to check
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Ghost vulnerability

2015-02-02 Thread Chris Angelico
On Tue, Feb 3, 2015 at 2:53 PM, Rustom Mody  wrote:
> How many people (actually machines) out here are vulnerable?
>
> http://security.stackexchange.com/questions/80210/ghost-bug-is-there-a-simple-way-to-test-if-my-system-is-secure
>
> shows a python 1-liner to check

Well, I have one internal disk server that's vulnerable. It's not
accessible to the world, which is why it's still running Ubuntu 10.10,
and it's affected. I'm not too concerned about Huix coming under
attack.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list