[issue42891] segfault with gunicorn and a library made with cython bindings

2021-01-11 Thread Amirouche Boubekki


Amirouche Boubekki  added the comment:

The problem is prolly in lsm-db.

ref: https://github.com/coleifer/python-lsm-db/issues/20

Sorry for the noise.

--
resolution:  -> third party
status: open -> closed

___
Python tracker 
<https://bugs.python.org/issue42891>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42891] segfault with gunicorn and a library made with cython bindings

2021-01-11 Thread Amirouche Boubekki


Amirouche Boubekki  added the comment:

I tried to reduce the program by replacing gunicorn / uvicorn dependency with 
threading.Thread and multiprocess.Pool without success.

--

___
Python tracker 
<https://bugs.python.org/issue42891>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42891] segfault with gunicorn and a library made with cython bindings

2021-01-11 Thread Amirouche Boubekki


Amirouche Boubekki  added the comment:

> ModuleNotFoundError: No module named 'foobar'

That is not a segfault. The problem I am reporting is a segfault.

It can be reproduced with uvicorn as follow:

from lsm import LSM


db = LSM('db.sqlite')


async def app(scope, receive, send):
assert scope['type'] == 'http'
global db
for (index, (key, value)) in enumerate(db[b'\x00':b'\xFF']):
pass

await send({
'type': 'http.response.start',
'status': 200,
'headers': [
[b'content-type', b'text/plain'],
],
})
await send({
'type': 'http.response.body',
'body': b'Hello, world!',
})

db.close()


Run the above program with: python -X dev -m uvicorn bobo:app

Then in another console: curl http://localhost:8000/

Here is the output:

$ python -X dev -m uvicorn bobo:app
INFO: Started server process [3580316]
INFO: Waiting for application startup.
INFO: ASGI 'lifespan' protocol appears unsupported.
INFO: Application startup complete.
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
Fatal Python error: Segmentation fault

Current thread 0x7fbb6e49b740 (most recent call first):
  File "./bobo.py", line 10 in app
  File 
"/home/amirouche/.cache/pypoetry/virtualenvs/lsmdb-cTe2806J-py3.8/lib/python3.8/site-packages/uvicorn/middleware/proxy_headers.py",
 line 45 in __call__
  File 
"/home/amirouche/.cache/pypoetry/virtualenvs/lsmdb-cTe2806J-py3.8/lib/python3.8/site-packages/uvicorn/protocols/http/h11_impl.py",
 line 394 in run_asgi
  File "/usr/lib/python3.8/asyncio/events.py", line 81 in _run
  File "/usr/lib/python3.8/asyncio/base_events.py", line 1851 in _run_once
  File "/usr/lib/python3.8/asyncio/base_events.py", line 570 in run_forever
  File "/usr/lib/python3.8/asyncio/base_events.py", line 603 in 
run_until_complete
  File 
"/home/amirouche/.cache/pypoetry/virtualenvs/lsmdb-cTe2806J-py3.8/lib/python3.8/site-packages/uvicorn/server.py",
 line 48 in run
  File 
"/home/amirouche/.cache/pypoetry/virtualenvs/lsmdb-cTe2806J-py3.8/lib/python3.8/site-packages/uvicorn/main.py",
 line 386 in run
  File 
"/home/amirouche/.cache/pypoetry/virtualenvs/lsmdb-cTe2806J-py3.8/lib/python3.8/site-packages/uvicorn/main.py",
 line 362 in main
  File 
"/home/amirouche/.cache/pypoetry/virtualenvs/lsmdb-cTe2806J-py3.8/lib/python3.8/site-packages/click/core.py",
 line 610 in invoke
  File 
"/home/amirouche/.cache/pypoetry/virtualenvs/lsmdb-cTe2806J-py3.8/lib/python3.8/site-packages/click/core.py",
 line 1066 in invoke
  File 
"/home/amirouche/.cache/pypoetry/virtualenvs/lsmdb-cTe2806J-py3.8/lib/python3.8/site-packages/click/core.py",
 line 782 in main
  File 
"/home/amirouche/.cache/pypoetry/virtualenvs/lsmdb-cTe2806J-py3.8/lib/python3.8/site-packages/click/core.py",
 line 829 in __call__
  File 
"/home/amirouche/.cache/pypoetry/virtualenvs/lsmdb-cTe2806J-py3.8/lib/python3.8/site-packages/uvicorn/__main__.py",
 line 4 in 
  File "/usr/lib/python3.8/runpy.py", line 87 in _run_code
  File "/usr/lib/python3.8/runpy.py", line 194 in _run_module_as_main
Segmentation fault (core dumped)

--
resolution: third party -> 
status: closed -> open

___
Python tracker 
<https://bugs.python.org/issue42891>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42891] segfault with gunicorn and a library made with cython bindings

2021-01-11 Thread Amirouche Boubekki


Amirouche Boubekki  added the comment:

You need to run the program with the following:

  python -X dev -c "from gunicorn.app.wsgiapp import run; run()" --workers=1 
foobar:app

where foobar.py is the code from the previous message.

The crash happen when, the function `app` is executed, hence you need to call 
in another console:

curl http://localhost:8000

note: lsm package can be installed with pip install lsm-db
note2: lsm db can not be installed with py3.9

--

___
Python tracker 
<https://bugs.python.org/issue42891>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42891] segfault with gunicorn and a library made with cython bindings

2021-01-11 Thread Amirouche Boubekki


New submission from Amirouche Boubekki :

Here is a simple way to reproduce:


from lsm import LSM


db = LSM('db.sqlite')

def app(environ, start_response):
"""Simplest possible application object"""

for (index, (key, value)) in enumerate(db[b'\x00':b'\xFF']):
pass

start_response(b'200', {})
return b''

db.close()


In my real program, if I add 'global db' in the function `app`, it does not 
segfault.


program: https://git.sr.ht/~amirouche/segfault
trace: https://wyz.fr/0I-MO

--
messages: 384836
nosy: amirouche
priority: normal
severity: normal
status: open
title: segfault with gunicorn and a library made with cython bindings
type: crash
versions: Python 3.8

___
Python tracker 
<https://bugs.python.org/issue42891>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42436] Google use wrong "hightlight" argument

2020-11-22 Thread Amirouche Boubekki


New submission from Amirouche Boubekki :

At the moment when I search for the following:

  https://www.google.com/search?q=ast+transformer+python+3.10

I have as second result this url:

  https://docs.python.org/dev/library/ast.html?highlight=s

I do not understand the purpose in the query string of `highlight=s`

--
assignee: docs@python
components: Documentation
messages: 381613
nosy: amirouche, docs@python
priority: normal
severity: normal
status: open
title: Google use wrong "hightlight" argument
versions: Python 3.10

___
Python tracker 
<https://bugs.python.org/issue42436>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ANN] copernic v0.1.1: Versioned structured data, with change-request mechanic, at scale.

2020-02-23 Thread Amirouche Boubekki
I'm pleased to announce the release of copernic v0.1.1

This project wants to be a scalable application that support a change-request
mechanic similar to github pull-request or gitlab merge-request, on any
structured data.  That includes relational data, graph-like data and tabular
data.  Eventually, it should scale both in terms of data size and number of
contributions.

It is powered by Django and FoundationDB.

Like wikipedia or wikidata, there is a single version of truth. In other words,
every user gets the same data. There is no per-user data repositories.

Change-request work in a way that similar to git stash. That is the diff, 
additions and deletions, is stored in the database like the rest of the data.
Until the change is applied by a super user. The data part of the change-request
is invisible outside the change-request.

Once a super user applies the change, that is merely swapping a single `None`
value with a timestamp, the history is properly serialized realizing a single
branch history.

It it possible to do time traveling queries, like freebase did. It is not
exposed in the web user interface.

There is always an up-to-date image of the latest data, to speed up queries.
But the history only store the differences between successive versions.

The code is at: https://github.com/amirouche/copernic

A demo is available at: http://copernic.space/about/

The license is AGPLv3+


Enjoy!
--
Python-announce-list mailing list -- python-announce-list@python.org
To unsubscribe send an email to python-announce-list-le...@python.org
https://mail.python.org/mailman3/lists/python-announce-list.python.org/

Support the Python Software Foundation:
http://www.python.org/psf/donations/


[issue34885] asyncio documention has lost its paragraph about cancellation

2018-10-03 Thread Amirouche Boubekki


Change by Amirouche Boubekki :


--
title: asycnio documention has lost its paragraph about cancellation -> asyncio 
documention has lost its paragraph about cancellation

___
Python tracker 
<https://bugs.python.org/issue34885>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34885] asycnio documention has lost its paragraph about cancellation

2018-10-03 Thread Amirouche Boubekki


New submission from Amirouche Boubekki :

The paragraph was still there in 3.6 
https://docs.python.org/3.6/library/asyncio-dev.html#cancellation

--
assignee: docs@python
components: Documentation, asyncio
messages: 326966
nosy: abki, asvetlov, docs@python, yselivanov
priority: normal
severity: normal
status: open
title: asycnio documention has lost its paragraph about cancellation
type: enhancement
versions: Python 3.7, Python 3.8

___
Python tracker 
<https://bugs.python.org/issue34885>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Object-oriented philosophy

2018-09-09 Thread Amirouche Boubekki
Le jeu. 6 sept. 2018 à 16:05, Michael F. Stemper
 a écrit :
>
> How does one judge when it's worthwhile to do this and when it's
> not? What criteria would somebody seasoned in OO and python use
> to say "good idea" vs "don't waste your time"?
>

I may qualify as experienced with Python, that being said, "to class
or not to class?" is still an open question.
I have been working on some stuff using Scheme and no OO machinery and
it worked well. Also, mocked
some stuff in the frontend using a purely functional approach. It works.

So, I am wondering what's the purpose of OOP?

Class-based error handling with exception and inheritance is very
handy maybe perfect.

I have been burned by Django class everywhere (ORM, REST, admin UI,
data validation, etc?).

Another place where class shines is when you have the same interface
for different objects.
Like others have said, it's more "duck typing" than OOP. Again
following the "common interface"
an abstract class is helpful and in this case, inheritance makes
sense. But that doesn't require
more that one or two level deep inheritance.

So, in the end, I think that except for error handling and the
subject.verb(**complements) syntax. OOP is dubious.

Multiple inheritances outside mixin anyone? Metaclass outside ORM / ODM?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: hello from a very excited and totally blind python programmer and game player

2018-07-30 Thread Amirouche Boubekki
Of course I forgot the static page generator program read (or listen)
direct text of the link at the code follows
https://raw.githubusercontent.com/amirouche/xp-maji/master/maji.py

xp is for experience :smallsmile:

I am a recovering lisp dev, so all my new programs are small. If you want a
pure Python webdev try: git clone https://github.com/amirouche/beyondjs

Le lun. 30 juil. 2018 à 20:33, Amirouche Boubekki <
amirouche.boube...@gmail.com> a écrit :

>
>
> Le mar. 24 juil. 2018 à 22:10, Daniel Perry  a
> écrit :
>
>> Hi there everyone, my name is Daniel Perry
>
>
> Hello!
>
>
>> and I'm a totally blind new Python user.
>
>
> Ok!
>
>
>> I've only just recently started picking up python and playing with it and
>> I intend on building some unique audio computer games for the blind.
>
>
> That. Is. An. Adventure. If you plan on a multi touch experience I
> recommend you look into #kivy and #python especially on freenode IRC
> network.
>
>
>> Such things mostly as simulation games like farming, building type games
>> and even eventually a virtual world built completely with audio but
>> building it in such a way that both we as totally blind colonists can live
>> inside of it but also that our fully sighted counterparts could live here
>> as well and not need any sort of guidance from the other group. That is,
>> the blind would not need any help from our sighted counterparts and you in
>> turn would not need any guidance from us as to how to live in the world or
>> grow in it.
>
>
> Well, that reads like an real adventure here. I've listening to books and
> while it's different, you still enjoy the story, so maybe I can enjoy a
> game made of sounds.
>
>
>> Of course this virtual world idea is down the road, I've got other game
>> ideas first of all but I would eventually like to get to the point I've
>> just described above.
>
>
> At some point, you might stop at the point where it pays the bills!
>
>
>> Preferably building my own server on which to park not only my virtual
>> world and games but also my web site that I would most likely need to put
>> these items up to be downloaded.
>
>
> I attach a small program that does render jinja2 templates and markdown, I
> hope you like it.
>
>>
>> Also, When I opened up the first message that I had gotten from this
>> list, I got a prompt hat popped up asking if I wanted to make windows live
>> mail my default news client and I answered no. From that point on, I've
>> been getting an error message and the message would not open. How must I
>> fix this? or am I able to correct this situation. Have a wonderful day and
>> I look forward to hearing from you soon.
>>
>
>  That's a nast3 behavior.
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: hello from a very excited and totally blind python programmer and game player

2018-07-30 Thread Amirouche Boubekki
Le mar. 24 juil. 2018 à 22:10, Daniel Perry  a
écrit :

> Hi there everyone, my name is Daniel Perry


Hello!


> and I'm a totally blind new Python user.


Ok!


> I've only just recently started picking up python and playing with it and
> I intend on building some unique audio computer games for the blind.


That. Is. An. Adventure. If you plan on a multi touch experience I
recommend you look into #kivy and #python especially on freenode IRC
network.


> Such things mostly as simulation games like farming, building type games
> and even eventually a virtual world built completely with audio but
> building it in such a way that both we as totally blind colonists can live
> inside of it but also that our fully sighted counterparts could live here
> as well and not need any sort of guidance from the other group. That is,
> the blind would not need any help from our sighted counterparts and you in
> turn would not need any guidance from us as to how to live in the world or
> grow in it.


Well, that reads like an real adventure here. I've listening to books and
while it's different, you still enjoy the story, so maybe I can enjoy a
game made of sounds.


> Of course this virtual world idea is down the road, I've got other game
> ideas first of all but I would eventually like to get to the point I've
> just described above.


At some point, you might stop at the point where it pays the bills!


> Preferably building my own server on which to park not only my virtual
> world and games but also my web site that I would most likely need to put
> these items up to be downloaded.


I attach a small program that does render jinja2 templates and markdown, I
hope you like it.

>
> Also, When I opened up the first message that I had gotten from this list,
> I got a prompt hat popped up asking if I wanted to make windows live mail
> my default news client and I answered no. From that point on, I've been
> getting an error message and the message would not open. How must I fix
> this? or am I able to correct this situation. Have a wonderful day and I
> look forward to hearing from you soon.
>

 That's a nast3 behavior.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Which database system?

2017-09-17 Thread Amirouche Boubekki
Le 15 sept. 2017 20:05, "Stefan Ram"  a écrit :

  When one is building an in-memory database that has a single
  table that is built at the start of the program and then one
  writes some complex queries to the table, what can be expected
  to be faster:

- implementing the table as a builtins.list of builtins.tuples
  with builtins.dicts as indexes for faster lookups and
  additional sorted builtins.lists for sorted "views" on the
  table

- implementing the table as a database table in sqlite3
  (":memory:") and using SQL commands for insertion


There is other solutions like shelve mentioned previously or plyvel (easy
api) or my preferred wiredtiger. But the issue with maintenance costs is
still valid. Choose the later if nothing else works.
-- 
https://mail.python.org/mailman/listinfo/python-list


How do you do deep input data validation?

2017-07-22 Thread Amirouche Boubekki
It seems that aiohttp recommends using one of trafaret, colander or
jsonschema
.
I am not very familiar with those libraries.

I am wondering what's the rational behind this choice. Why is trafaret the
first in this list? Is it a strong recommendation to use trafaret?

I tried to ask a question on SO about deep validation
.
Basically, how do you validate data in your project? What are the best
pratices?

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


How do you use Python 3.5 and Python 3.6 in production

2017-06-14 Thread Amirouche Boubekki
Héllo,


I'd like to use Python 3.5 or Python 3.6 in production but avoid the use of
pip and virtualenv.

Is there a solution based on a popular GNU/Linux distribution that allows
to keep up with the release of Python 3.x and various other highly prolific
project but still young like aiohttp?

What I am looking for is the ability to have reproducible builds in the
form of lxc templates (or maybe somekind of docker magic) but without the
need to maintain another package repository.

I hope my question is clear.

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


Re: ANN: JavaScrypthon 0.5, now with embedded evaluation of transpiled code

2016-11-28 Thread Amirouche Boubekki
On Sat, Nov 26, 2016 at 7:21 PM Alberto Berti <
azazel+python-annou...@arstecnica.it> wrote:

> Hi all,
>

Héllo!


> i'm pleased to announce that JavaScripthon 0.5 has been released to
> PyPI. JavaScrypthon can translate a subset of Python 3.5 code to  ES6
> JavaScript producing beautiful and lean  code, while supporting some of
> the latest Python features.
>
> Changelog
> (https://github.com/azazel75/metapensiero.pj/blob/master/CHANGES.rst)


This is the best of ES6 in a Python syntax.

Impressive work.

I have a few questions:

a) Why do you choose not to use your own Javascripton class to represent
Python dict?

b) Do you do some type tracing or something to be able to convert
``foo.update(bar)`` to ``Object.assign(foo, bar)``

c) IIUC you don't implement Python type system and rely on ES6 (or ES7)
class system? Is that correct? If that's the case how do you implement
class decorators and method decorators?

d) What about Python <-> Javascript interop. It's a tremendous topic not to
be forgotten.

A few remarks:

i) I had a remark about arguments but javascripthon doesn't support
**kwargs at call site. This is implemented in Pythonium, have a look, it
has some js <-> python interop.

ii) Too bad I can't run the vanilla pystone benchmark

I created a similar project targeting ES5 [0].

Also, FWIW users are looking for a Javascript replacement that is real
Python, not another coffeescript.

Best wishes!

[0] https://github.com/amirouche/pythonium/blob/master/dodge.py
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Anyone needs a graphdb written in Python?

2016-11-25 Thread Amirouche Boubekki
Héllo again,

On Tue, Nov 22, 2016 at 9:56 PM Amirouche Boubekki <
amirouche.boube...@gmail.com> wrote:

> I am working on a graphdb written Python on top of wiredtiger.
>
> Anyone want to share about the subject about where this could be made
> useful?
>

A bit of context might be helpful.

I've been working for sometime a graph database library on top wiredtiger
called AjguDB <https://github.com/amirouche/AjguDB>.

Now I am happy with the code and would like get to the next level and show
that this tool can be helpful in situation where bigger than RAM graph data
is used.

I could simply adapt networkx algorithm to my graph API but this sound
boring instead what would like to do is solve a real problem.

Do you know such problems, if possible related to wikidata or text mining.

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


Anyone needs a graphdb written in Python?

2016-11-22 Thread Amirouche Boubekki
Héllo,


I am working on a graphdb written Python on top of wiredtiger.

Anyone want to share about the subject about where this could be made
useful?

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


Re: A question about a list and subprocess.check_call()

2015-02-16 Thread Amirouche Boubekki
On Mon Feb 16 2015 at 7:40:42 PM Peter Otten __pete...@web.de wrote:

 David Aldrich wrote:

  Hi Peter
 
  Thanks very much for your reply. I have added one more question below.
 
  The straightforward approach is to pass a list or tuple:
 
  def build(build_options=()):
  subprocess_check_call((make,) + build_options)
 
  build((flagA=true, flagB=true))
 
  This looks fine - I am trying it.
 
  I would like to display on the console the entire make command, so I have
  done this:
 
  def build(build_options=()):
  make_command = 'make '.join(map(build_options))
  print('Build command: ' + make_command)
  subprocess.check_call((make,)+build_options)
 
  but I get error:
 
  make_command = 'make '.join(map(build_options))
  TypeError: map() must have at least two arguments.
 
  What would be the correct way to concatenate and display the elements in
  the tuple please?

 Hm, what do you expect map() to achieve? And make  is not really the
 string you want as a separator...

 You can join the strings in build_options with

  build_options = foo, bar, baz
   .join(build_options)
 'foo bar baz'
  make  +  .join(build_options)
 'make foo bar baz'

 But you shouldn't do this as you have already learnt that spaces do not
 separate arguments; in fact by default check_call() doesn't even use the
 shell. An example to drive the point home:

  from subprocess import check_call
  check_call([python3, -c, import sys; print(sys.argv[1:]), foo,
 bar])
 ['foo', 'bar']
 0
  check_call([python3, -c, import sys; print(sys.argv[1:]), foo
 bar])
 ['foo bar']

 Both invocations would appear to issue the same command in your debugging
 print() call. list2cmdline() does a bit better; it resembles the command
 issued if the shell were used:

  print(subprocess.list2cmdline([make] + build_options))
 make foo bar baz


It's also possible to do it the other around using shlex.split. I prefer
that version because I can easily copy/paste the command from code to the
shell, it's also more readable IMO:

 cmd = python3 -O -c import sys; print(sys.argv[1:]) foo bar spam
egg 
 print(cmd)
 subprocess.check_call(shlex.split(cmd))

shlex.split(cmd) must be prefered to cmd.split('') which doesn't take into
account shell strings. paths with space must be wrapped in quote (talking
of path, pathlib is awesome).

https://docs.python.org/2.7/library/shlex.html?highlight=shlex#shlex.split


Regards



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

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


Re: How to write a non blocking SimpleHTTPRequestHandler ?

2015-02-03 Thread Amirouche Boubekki
 The standard library and nonblocking can't be used in the same sentence.

python 2.x stdlib has no high level support of *async* code. There is
trollius library that ports asyncio to py2 though.

I was a bit quick in my first anwser. What you want is to prevent the
socket to wait indefinetly for data (based on strace output) which is done
with socket.setblocking/settimeout [1]. asynchronous (asyncio) is something
else, and you would still need to handle blocking I think.

There is contentbrowser [2] which is somekind of web proxy.

IMO, python 2 - python 3 is not a big leap. Some things are better in
python 3.


[1] https://docs.python.org/2/library/socket.html#socket.socket.setblocking
[2] https://bitbucket.org/david/contentbrowser/src





On Tue Feb 03 2015 at 2:00:27 PM Yassine Chaouche
yacinechaou...@yahoo.com.dmarc.invalid wrote:

 On Tuesday, February 3, 2015 at 12:35:32 PM UTC+1, Marko Rauhamaa wrote:

  So far I've been happy with select.epoll(), socket.socket() and ten
  fingers.
  Marko

 There's already software written to take care of much of the HTTP stuff
 protocol stuff, the headers etc. I wouldn't rewrite it. I prefer to monkey
 patch parts of existing code rather then rewrite all of it.

 But your comment is interesting because, as I understand it, a
 non-blocking web server is simply a matter of setting timeouts on sockets,
 catch the exceptions and move on. I don't know why wouldn't that be
 possible with python stdlib ?


  The standard library and nonblocking can't be used in the same sentence.

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

-- 
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 yacinechaou...@yahoo.com.dmarc.invalid
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 = 'ul'
for name in names:
dirname = os.path.join(filepath, name)
if os.path.isdir(dirname):
dirname += '/'
path = dirname[len(self._directory):]
link = 'a href=%s%s/a' % (path, name)
output += 'li' + link + '/li'
output += '/ul'
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' 

Re: Python vs C++

2014-08-27 Thread Amirouche Boubekki
2014-08-27 8:06 GMT+02:00 Ian Kelly ian.g.ke...@gmail.com:

 On Tue, Aug 26, 2014 at 2:12 AM, Amirouche Boubekki
 amirouche.boube...@gmail.com wrote:
  2014-08-26 6:02 GMT+02:00 Ian Kelly ian.g.ke...@gmail.com:
 
  On Mon, Aug 25, 2014 at 4:52 AM, Amirouche Boubekki 
 amirouche.boube...@gmail.com wrote:
- I am a big fan of Final Fantasy games, it seems to be an easy game
 experience to code
 
  Maybe not so easy, if the horrifying number of bugs in the early games
 of the series are any indication.
 
  I started with FF VII, I don't remember any bugs.

 Ah, well, that's about when they seem to have gotten their act
 together with QA. The first and sixth games in particular had some
 rather notorious game-breaking bugs. I think it says something about
 the appeal of the series that those were two of the most beloved
 entries despite all the bugs.


Those would have been sold today as alpha and beta for good money. Things
change.


---

«The interwebs breeding lächerlich from the beginnings, and counting...»
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python vs C++

2014-08-27 Thread Amirouche Boubekki
2014-08-27 8:23 GMT+02:00 Ian Kelly ian.g.ke...@gmail.com:

 On Tue, Aug 26, 2014 at 11:43 PM, alex23 wuwe...@gmail.com wrote:
  On 26/08/2014 6:12 PM, Amirouche Boubekki wrote:
 
  2014-08-26 6:02 GMT+02:00 Ian Kelly ian.g.ke...@gmail.com
  mailto:ian.g.ke...@gmail.com:
 
  It would be just as easy or easier in Python, or one could save a
  lot more effort by just using RPG Maker like every other indie RPG
  developer seems to do.
 
  I don't think there is FLOSS equivalent.
 
 
  There is indeed:
 
  http://openrpgmaker.sourceforge.net/

 Ugh. There seems to be no public repository, and the only source to be
 found is from release-versioned tarballs, so there's apparently no
 collaboration other than some forums for reporting bugs and requesting
 features. All the work is done by one developer in his spare time, and
 he is currently on hiatus since April. Meanwhile the most recent
 release is February, so it's not like somebody could just pick it up
 and start hacking and expect to merge.

 That's only open-source under the most literal of definitions.


Screenshots look good in terms of features.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python vs C++

2014-08-26 Thread Amirouche Boubekki
2014-08-26 6:02 GMT+02:00 Ian Kelly ian.g.ke...@gmail.com:

 On Mon, Aug 25, 2014 at 4:52 AM, Amirouche Boubekki 
 amirouche.boube...@gmail.com wrote:
   - I am a big fan of Final Fantasy games, it seems to be an easy game
 experience to code

 Maybe not so easy, if the horrifying number of bugs in the early games of
 the series are any indication.


I started with FF VII, I don't remember any bugs.



 I'm not sure what makes this a C++ project in any case.


True.


 It would be just as easy or easier in Python, or one could save a lot more
 effort by just using RPG Maker like every other indie RPG developer seems
 to do.


I don't think there is FLOSS equivalent.

Anyway, I have other ideas:

- An after effect equivalent
- This might be the same thing as the above, a live processing of vidéos. I
tried using python bindings of gstreamer six months ago, I failed. Part of
the failure is that g-software suite doesn't care much about this usecase.
- port torus trooper to C++ (
http://www.asahi-net.or.jp/~cs8k-cyu/windows/tt_e.html)
- Contribute to cling, cern's C++ interpreter based on llvm
http://root.cern.ch/drupal/content/cling. I think PyPy people are
interested to use it too.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python vs C++

2014-08-25 Thread Amirouche Boubekki
Héllo,


2014-08-21 14:54 GMT+02:00 David Palao dpalao.pyt...@gmail.com:

  Why to use C++ instead of python?

 It is not ranting against C++. I was/am looking for small-medium
 projects to exercise my C++ skills. But I'm interested in a genuine
 C++ project: some task where C++ is really THE language (and where
 python is actually a bad ab initio choice).


- You can try to write a game or a game engine.
 - online book about writing game illustrated in C++
http://gameprogrammingpatterns.com/
 - voxels are all the rage, but the only framework I know that is not
minecraft-like is still closed source http://www.voxelquest.com/
 - I am a big fan of Final Fantasy games, it seems to be an easy game
experience to code

- Contribute to valve opengl debugger, becarful awesomeness ahead,
https://github.com/ValveSoftware/vogl
- Contribute to one of the C++ graphical framework: Ogre, blender, Qt
- Not rigorously a game: contribute to blender: it's written in C, C++ and
Python.
- make new graphical devices easy to use from Python, I'm thinking about
occulus rift and http://hello.vxbx.net/
- Contribute to Inkscape
- Contribute to scikit.learn I think they use Cython and C++ to improve
performance.

Regarding games I like this book: http://fabiensanglard.net/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python vs C++

2014-08-25 Thread Amirouche Boubekki
2014-08-25 12:52 GMT+02:00 Amirouche Boubekki amirouche.boube...@gmail.com
:

 Héllo,


 2014-08-21 14:54 GMT+02:00 David Palao dpalao.pyt...@gmail.com:

   Why to use C++ instead of python?

 It is not ranting against C++. I was/am looking for small-medium
 projects to exercise my C++ skills. But I'm interested in a genuine
 C++ project: some task where C++ is really THE language (and where
 python is actually a bad ab initio choice).


 - You can try to write a game or a game engine.
  - online book about writing game illustrated in C++
 http://gameprogrammingpatterns.com/
  - voxels are all the rage, but the only framework I know that is not
 minecraft-like is still closed source http://www.voxelquest.com/
  - I am a big fan of Final Fantasy games, it seems to be an easy game
 experience to code

 - Contribute to valve opengl debugger, becarful awesomeness ahead,
 https://github.com/ValveSoftware/vogl
 - Contribute to one of the C++ graphical framework: Ogre, blender, Qt
 - Not rigorously a game: contribute to blender: it's written in C, C++ and
 Python.
 - make new graphical devices easy to use from Python, I'm thinking about
 occulus rift and http://hello.vxbx.net/
 - Contribute to Inkscape
 - Contribute to scikit.learn I think they use Cython and C++ to improve
 performance.

 Regarding games I like this book: http://fabiensanglard.net/


Back in the days of my C++ I liked http://yosefk.com/c++fqa/

Also they are a few graph database written in C++ that might need some love:

- https://www.arangodb.org/
- https://github.com/google/cayley

Peace and prosperity
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: SQLAlchemy - web framework ?

2014-05-23 Thread Amirouche Boubekki
Héllo,


2014-05-13 1:34 GMT+02:00 flebber flebber.c...@gmail.com:
 If I want to use SQLAlchemy as my ORM what would be the best option for a
web framework?

I think the best option would be Pyramid but I don't know SQLAchemy or
Pyramid that much, but:

- Django doesn't support SQLAlchemy as is
- I don't recommend Flask, even if it has some «good intentions» (Jinja2 
Django Template, Web Browser Debugger)
- I don't know web.py, turbogears
- I only know that tornado is an async framework and *it seems to me *that
Python+Async is still not mainstream
- This year, I was working on non-web related stuff, so I'm not fully up to
date.

 It appears the general advice regarding Django is to do it the Django way
and use the django ORM and change it out for SQLAlchemy.

You will loose a lot of the benefits of using Django. My point of view is
that removing one thing in Django (even the template system) will lead me
to remove *a lot of things*... writing a new framework. Not necessarily
because they are coupled, but because there is kind of a lot of stuff I
dislike in Django... But I still use Django, trying to avoid land mines and
working around inefficiencies...

 That to me limited knowledge leaves flask, pyramid and turbogears 2. So
if I wanted to not build it all myself as with flask then potentially
pyramid, turbogears is the best option?

Like I said, I don't recommend flask and I know nobody using turbogears for
new projects.

 Is this true? I have completed the TG2 intro tutorial and have built
several small things with flask although I feel offput by doing anything
bigger in flask.

They are templates projects that help bootstrap bigger projects. But
anyway, last time I checked Flask has less resources (documentation,
example code, example project, coobooks, documented pratices...)

 See what I have done is got my python knowledge to a fair point where I
can do useful things, good knowledge of web HTML/CSS, built a few small
projects in flask to get an idea for python web, completed django
tutorials, turogears tutorials and now looking to design out a bigger
project I want to set myself and i am trying to compile the parts so I can
see what I will need to use and gather info to cover what othe things I
will need to know.

The thing that, again, goes in the direction of choosing Django, is that
it's a big noosphere == lot of ressources of different kind code, video,
articles, books == lot of people from different background and interests ==
lot of ideas. Getting to learn things is easier in this conditions.

If you choose another framework, you will invest extra time while referring
to documentation written for Django. Since you seem to be starting Python,
it will be easier to avoid this extra step of translation. Even if
«translation» is a very common pratice of programming, so working on that
skill is interesting.

 Do I have a false fear of flask and doing bigger projects?

Many people claim they use Flask on big projects, but AFAIK there is no big
open source projects written with Flask. So you can't be sure about what it
means to use Flask in big project anyway. Mozilla use extensively Django,
checkout mozilla@github https://github.com/mozilla.

 So at this point I know I want SQLAlchemy, will use postgres(although
mysql/maria would work fine).

SQLAlchemy is better than Django's equivalent. Like said I don't fully know
SQLAlchemy. But the SQL language mapping in Python is nicer in SQLAlchemy.
The project is dedicated to supporting RDBMS so there is better support,
tooling, I think.

Some people will say it's a matter of taste, look'n'feel and compare it to
ice cream flavors. IMO it's not comparable to ice cream flavor but
different people have different needs, background and context so favor one
library instead of another without strong engineering or scientific
grounds. Money, business, HR  marketing will have more significance.

flebber flebber.c...@gmail.com writes:

  One of the main parts that is tripping myself up is that I need to
  consistently import xml files into my database.

 XML documents represent a hierarchical tree of data. Relational
 databases are not good at representing hierarchical documents.


- It's not always hierarchical data.
- RDBMS can handle hierarchical data anyway especially PostgresSQL

When I was at Libération (a french national newspaper, kind of the french
Guardian). We ported the previous CMS based on a custom PHP framework to
Django. Basically there was 3 parts:

- Frontend: main website, mainly for reading digital articles or articles
from paper version. There is several frontends for the same backend.
- Backend: forms and whatnot for journalist to manage the content of the
website
- Automatic processing: this needs little human interventions but are still
fully part of the CMS

The CMS import stuff, many kind among which articles bundled in XML. A
django application, a python package integrated with django that creates
a mini-framework for implementing import 

Re: Moving to an OOP model from an classically imperitive one

2014-04-25 Thread Amirouche Boubekki
Héllo,

I have no definitive answer regarding the OOP/functional mismatch.

2014-04-24 18:53 GMT+02:00 tim.thel...@gmail.com:

  A reasonable compromise might be to keep the *data* assocated
 
  with a SubuserProgram in a class, maybe together with a few
 
  methods that are tightly coupled to it, but have the major
 
  pieces of functionality such as install() implemented by
 
  separate functions that operate *on* the class, rather than
 
  being inside it.
 

 I think this is sound advice.  I'm still not sure what I'll come up with.

 One of the other reasons why an OOP model might be right for me is that of
 caching.  I currently load a lot of attributes regarding programs from
 disk, and I do so multiple times, I could either pass those attributes
 around, OR, using a class, I could store those attributes in the object
 after loading them just once.


You could also use a generator with a somekind of memoization/cache.


 I have no experience with OOP except in the domain of GUIs (where it seems
 inescapable, all major toolkits use OOP)


I have some experience in GUIs with Python in a proprietary framework.

I have a bias for OOP and Python in particular. I started exploring Scheme
through Guile and other languages more or less. I am asking myself the
question what is the interest of functional programming or so called.
Scheme doesn't enforce functional code or immutability. It's actually more
open somewhat because of the macro system among other things. Outside any
performance considerations or implementations details like GIL. Scheme and
(all?) *LISP don't use the infix notation*. probably because you can work
around it but IMO not fully. The infix notations allows to write things
like: people.move_to(paris). It's easy to read, as «Subject Verb
Complement»... Class based OOP is prefered because of that, in a lot of
situations. IMO, if OOP won, it's because of readability, and in particular
Class based OOP. JavaScript OOP is useless in asynchronous context, see
http://repl.it/Rrf/2. Maybe you can work around this feature with
JavaScript descriptors easly, I did not try that.

so I'm not yet sure how this will turn out.


I skimmed through the code, but it's very superficial reading, like I
installed pycharm to ask for help...:

- CamelCase is usually for class names. That said, sometime variable
holding classes are called my_object_class or my_object_factory
- I think permissions.py would be easier to read with a class... or a
function that initialize the dictionary as intented and just use dict
methods onward.
- To I read code, I have a systematic method I call
gunshot/destructive/production rules/function inlining/develop (as the dual
of factorize).

I started with subuser.py, I got: http://dpaste.com/1797075/

def getSubuserCommands():
   Returns a list of commands that may be called by the user. 

  def isPathToSubuserCommand(path):
  directory, executableName = os.path.split(path)
  return executableName.startswith(subuser-)

  externalCommandPaths = queryPATH(isPathToSubuserCommand)

  externalCommands = []
  subuserPrefixLength=len(subuser-)

  for externalCommandPath in externalCommandPaths:
commandDir, executableName = os.path.split(externalCommandPath)
commandName = executableName[subuserPrefixLength:]
externalCommands.append(commandName)

  external_subuser_commands = list(set(externalCommands))

  return list(set(
os.listdir(paths.getSubuserCommandsDir())).difference(nonCommands)) +
external_subuser_commands


It's kind of easier to read.

Gremlin is a DSL that allows to navigate a graph. That's exactly what
happens here (and all the
timehttp://en.wikipedia.org/wiki/Transderivational_search long
nowhttp://en.wikipedia.org/wiki/Kundalini_syndrome#The_Physio-Kundalini_Syndrome_Index
).wrapped_ 
http://en.wikipedia.org/wiki/Net.artin(tesseracthttp://en.wikipedia.org/wiki/Tesseract_%28disambiguation%29).
I'd like to write the above as:

 subuser.commands = (subuser.path.directories +
subuser.user.path.directories).filter(is_command).distinct().memoize()

I think it's possible in Ruby.

I'm quite interested by the subject. Elm language (see
reactconfhttp://reactconf.com/)
and your graphical
IDEhttp://thobbs.cz/works/2013/graphical-elm/Intro.htmlis very
interesting, do you know about Domain
Specific Modeling Forum http://www.dsmforum.org/? I started to put some
thinking grouped together. Also I started proto-py to gather code ideas,
but it's still offline. My plan is to mimick subuser to see, what happens.

Can be of interest Scala @ Systems @
Twitterhttps://news.ycombinator.com/item?id=7618969

Nice project by the way, with a better see also section that I could do :)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: retrieve source code from code object as returned by compile()

2014-04-25 Thread Amirouche Boubekki
in python3, I do inspect.getsource(object)
[dochttps://docs.python.org/3/library/inspect.html#inspect.getsource],
I don't know the limitations.

On Python 2, there is meta https://pypi.python.org/pypi/meta.

My interest is different, I use to retrieve the definition of function to
submit it to a database, instead of stored procedures, but I have the
source of the code. It can also be used to retrieve the ast.


2014-04-25 4:50 GMT+02:00 Justin Ezequiel justin.ezequ...@gmail.com:

 On Thursday, April 24, 2014 1:53:38 PM UTC+8, Gregory Ewing wrote:
  Alternatively you could create a .pyc file out of the code
  object and then use Easy Python Decompiler on that. The
  following snippet of code should do that:
 
  (Taken from:
 
  http://stackoverflow.com/questions/8627835/generate-pyc-from-python-ast)

 Woohoo! Success! Thank you Greg!
 --
 https://mail.python.org/mailman/listinfo/python-list

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


Re: object().__dict__

2014-04-23 Thread Amirouche Boubekki
2014-04-23 8:11 GMT+02:00 Cameron Simpson c...@zip.com.au:

 On 23Apr2014 09:39, Pavel Volkov sai...@lists.xtsubasa.org wrote:

 There are some basics about Python objects I don't understand.
 Consider this snippet:

  class X: pass

 ...

  x = X()
 dir(x)

 ['__class__', '__delattr__', '__dict__', '__dir__', '__doc__',
 '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__',
 '__init__', '__le__', '__lt__', '__module__', '__ne__', '__new__',
 '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__',
 '__str__', '__subclasshook__', '__weakref__']

  x.foo = 11


 And now I want to make a simple object in a shorter way, without
 declaring X class:


If you don't want to go through the usual syntax that defines classes you
can use the equivalent code using type to dynamically create a class:

MyClassObject = type('MyClassObject', (object,), dict())

Mind the fact that MyClassObject is a specific kind of object: a class, a
priori, not harmful in anyway



  y = object()
 dir(y)

 ['__class__', '__delattr__', '__dir__', '__doc__', '__eq__',
 '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__',
 '__init__', '__le__', '__lt__', '__ne__', '__new__', '__reduce__',
 '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__',
 '__subclasshook__']

  y.foo = 12

 Traceback (most recent call last):
 File stdin, line 1, in module
 AttributeError: 'object' object has no attribute 'foo'

 The attribute list is different now and there's no __dict__ and the
 object does not accept new attributes.
 Please explain what's going on.


 The base object class has a fixed set of attributes; you can't add more.


Just like any other builtin type: int, float etc... which also means you
can't add method to them dynamically.

Mind the fact that an instance of object is still useful to implement
efficient SENTINEL objects



 Almost every other class lets you add attributes, but the price for that
 is that it is slightly in memory footprint and slower to access.


class defined in Python except if you define a __slots__



 Look up the __slots__ dunder var in the Python doco index:

   https://docs.python.org/3/glossary.html#term-slots

 You'll see it as a (rarely used, mostly discouraged) way to force a fixed
 set of attributes onto a class. As with object, this brings a smaller
 memory footprint and faster attribute access, but the price is flexibility.


True, still can be the only way to save few MB or... GB without falling
back to C or PyPy.

Have a look at PyPy to how to save memory (and speed things up) without
slots:
http://morepypy.blogspot.fr/2010/11/efficiently-implementing-python-objects.html

In Python 3 there is a class that is equivalent to:

class foo(object):
pass

simple object with a __dict__, I can't find it anymore and also there is
SimpleNamespacehttps://docs.python.org/3/library/types.html#types.SimpleNamespaceclass.

To sum up:

- If you want to create a sentinel value, use object()
- If you want to create an object to hold values and access them as
attributes, use something like SimpleNamespace


 Cheers,
 Cameron Simpson c...@zip.com.au

 Try being nothing but bored for 4 hours straight, and then tell me that
 there's no fear involved.   - d...@elxr.jpl.nasa.gov (Dave Hayes)
 --
 https://mail.python.org/mailman/listinfo/python-list

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


Re: object().__dict__

2014-04-23 Thread Amirouche Boubekki
2014-04-23 15:59 GMT+02:00 Phil Connell pconn...@gmail.com:

 On Wed, Apr 23, 2014 at 03:48:32PM +0200, Amirouche Boubekki wrote:
  2014-04-23 8:11 GMT+02:00 Cameron Simpson c...@zip.com.au:
   Look up the __slots__ dunder var in the Python doco index:
  
 https://docs.python.org/3/glossary.html#term-slots
  
   You'll see it as a (rarely used, mostly discouraged) way to force a
 fixed
   set of attributes onto a class. As with object, this brings a smaller
   memory footprint and faster attribute access, but the price is
 flexibility.
  
 
  True, still can be the only way to save few MB or... GB without falling
  back to C or PyPy.
 
  Have a look at PyPy to how to save memory (and speed things up) without
  slots:
 
 http://morepypy.blogspot.fr/2010/11/efficiently-implementing-python-objects.html

 Is there any analysis of how this balances increased memory usage from the
 JIT
 vs the CPython VM (with a reasonable amount of code)?

 I'd thought that one of the main disadvantages of PyPy was drastically
 increased memory usage for any decent-sized program. Would be interested to
 know if this was not the case :)


I have a similar thought, I don't how that memory consumption increase (a
constant? a factor? probably both...)

but if the program use an absurd amount of memory even in CPython then PyPy
will be able to catchup based on comment #1 of a PyPy core dev in
http://tech.oyster.com/save-ram-with-python-slots/ see also
http://pypy.readthedocs.org/en/latest/interpreter-optimizations.html#dictionary-optimizations

Still it requires more analysis. When does PyPy trigger the optimization?




 Cheers,
 Phil

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

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


[OT] Culture and Empire

2014-01-01 Thread Amirouche Boubekki
Héllo everybody,

I stumbled on Culture and Empire a few days ago and I've been reading
it since then. I'm not finished yet. It's insigthful, smart and
provocative. It bridge past, present and future. I will put it in my
armory *ahem* library between Fundation and The Cathedral and the
Bazaar until I read Present Shock. This is the book you want, need and
will read this year if any.

I quick glimpse into the very readable book:


---8-8-8-8-8-8-8-8-8

Chapter 1. Magic Machines

Far away, in a different place, a civilization called Culture had
taken seed, and was growing. It owned little except a magic spell
called Knowledge.

In this chapter, I’ll examine how the Internet is changing our
society. It’s happening quickly. The most significant changes have
occurred during just the last 10 years or so. More and more of our
knowledge about the world and other people is transmitted and stored
digitally. What we know and who we know are moving out of our minds
and into databases. These changes scare many people, whereas in fact
they contain the potential to free us, empowering us to improve
society in ways that were never before possible.

-8-8-8-8-8-8-8-8-

There is also a presentation of the content of the book that I didn't
review yet. But it seems like you don't need to read all the book to
understand what is in inside. There is also a related crowdfunding
project, but I don't know more that since I want to finish the book
first.

http://cultureandempire.com/


Happy new year (indeed),


Amirouche ~ http://hypermove.net/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Islam is the fastest growing religion in the world especially since sept. 11.

2013-12-13 Thread Amirouche Boubekki
Why is bv4bv4...@gmail.com still not banned?


2013/12/13 bv4bv4...@gmail.com

 Islam is the fastest growing religion in the world especially since sept.
 11.

 An important article shows that every child is born on the fitrah
 (natural inclination) of Islam, the spread of Islam after September
 eleventh and that it’s necessary to make an open communication between
 Muslims  Non-Muslims for presenting a right picture about Islam .

 Salam Alaykum:

 Your question about the increase in the reversion to Islam is a good
 one. You have given me the excuse to do something that I have wanted to do
 for a long time. I have wanted to write on the subject of Reverts to Islam
 in Modern Times and the message that it carries to all of us Muslims about
 Islam TODAY.
 BACK TO Islam?
 Reverts to Islam In Modern Times

 Revert As Opposed to Convert

 I like to use the word revert as opposed to the word convert as it
 more suits the occasion of a person returning back to his natural condition
 at birth. The baby is born in true surrender, submission, obedience and
 peace with his Creator. And this is the desirable position of the Muslim,
 to be in peace and submission to the Will of Allah (God in English).
 Instead of thinking in terms of converting people over to Islam, it is
 better understood that they are simply returning back to their natural
 state at birth. And this is from the teachings of our beloved prophet,
 Muhammad, peace be upon him. (Muslims should always say Peace be upon
 him/them when referring to any of the prophets).

 Like A Baby

 Prophet Muhammad, peace be upon him, said: Every child is born on the
 fitrah (natural inclination) of Islam (surrender, submission and peace
 to the Creator on His Terms). And it is their parents who raise them up to
 be Jews, Christians or fire worshippers.

 Dr. Ted Campbell who is the professor of religion at the seminary school
 in Maryland and I were both sharing the speakers platform last year in
 Maryland University. At the closing of a very nice interfaith dialog there
 came a strange question for both of us. Noah, the moderator said: This
 last question is for both speakers: Why are each of you in your religion?

 Dr. Campbell took his position in front of the microphone and then looked
 around the room as he thought about the question. I will never forget his
 words. He said: I guess I would have to say that I am a Methodist because,
 well because, my parents raised me that way. As a Methodist.

 He was right.

 That is what we know as Muslims. However, as I mentioned in my answer to
 the same question: And then some are brought back to their original state
 as a baby. They are reverted to Islam by the Mercy of Allah.

 Actual or Factual Numbers of American Muslims

 Many people are claiming that twice as many, or three times or four times,
 or even ten times as many people are coming into Islam as they did prior to
 the events of September 11. Who could possibly know the numbers? We are not
 even sure how many Muslims live here in America. I have heard the numbers
 range from around 3,000,000 all the way up to 11,000,000. I'm sure that
 only Allah Knows for sure how many Muslims there are in America.

 Rate of Reversion

 Actually, I can't give accurate statistics before or after the September
 events. I have heard from some experts that Islam was the fastest growing
 religion in the world prior to the September 11 events. I have no reason to
 doubt it either. In the many Masjids around the United States and in the
 many countries that I have been fortunate enough to visit I have found
 thousands who have entered into Islam. The Anglican Church of England
 expressed concern that if something does not change in the trend of new
 Muslims in England that the Muslims will out number the Anglicans by the
 year 2010.

 The number one name of the birth certificates for new born boys in England
 was not John, or Michael, or William. It is Muhammad. In Mexico, Sweden,
 Denmark and Canada I have witnessed so many coming into Islam that I cannot
 count them all. Everywhere I go I meet new Muslims. Prisons, universities
 and even in the military I have personally seen thousands who came to
 Islam. This is all before the events of September 11.

 More Exposure to the Message

 What I feel comfortable saying is that more and more people are being to
 exposed to Islam all over the world. Whether or not the picture they are
 receiving is painted correctly or not is not as important a factor as is
 the fact that at long last many people on this planet are looking at Islam
 as something very real. Therefore, when they ask about Islam some of the
 information is stimulating feelings inside of the people. Naturally we are
 going to see those who are stimulated to be against Islam. At the same time
 you have to understand that there are a number of people who will take the
 position that you cannot always believe everything in the news media. These
 are the ones whom Allah guides 

Re: [ANN] Pythonium Core 0.2.5

2013-11-18 Thread Amirouche Boubekki
2013/11/18 Amirouche Boubekki amirouche.boube...@gmail.com

 2013/11/17 Salvatore DI DIO salvatore.di...@gmail.com

 Are lists comprehensions are featured in Veloce ?


 Ah! Good question, I did not think about it can probably add it to Core.
 Thanks


It's done in last release, dubbed 0.3.0 just use pip to install it.

Also:

- fixed the test suite
- argument unpacking...
- generated code is now properly indented

I hope it's good enough.

Cheers,


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


[ANN] Pythonium Core 0.2.5

2013-11-17 Thread Amirouche Boubekki
Héllo Pythonistas from all over the world,


I'm very proud to announce the immediate availability of Pythonium Core
0.2.5, a Python 3 to Javascript translator (the best) that generates *fast*
*portable* code written in Python.

It use Python 3 parser and translates the code to JavaScript code.

I did not say “it's fully compliant” because it's not. That's not the point
of this flavor. Its point is to make possible to write Python code and use
it in the browsers. All the objects stay vanilla Javascript objects. There
is no builtins, no stdlib, except what is available in the wild, because
Pythonium can access Javascript objects directly, you can use *whatever*
JavaScript library you want.

There is port of the mrdoob webgl cloud demo available

watch: http://pythonium.github.io/
read: https://github.com/pythonium/pythonium.github.io/blob/master/js/app.py

The project is hosted at github: https://github.com/pythonium/pythonium

Don't hesitate to watch/star/fork/create/pr ! Like said earlier, it's the
best translator I know of, and it's written in Python.

How do you get started ?
==

If you know JavaScript it's easy you don't need guidance. Don't forget to
read the cookook
https://github.com/pythonium/pythonium/wiki/Pythonium-Core-Cookbook

If you only know backend or desktop Python development, it will be a bit
more work. What you can do is take a jQuery or Javascript course, and
translate the code on the fly to Python, compile it using the
pythonium_core and and run it in nodejs or a browser. Good luck!

What's next?
==

Now, basicly, I don't know what to do!

Except bugs in requirejs integration, I don't except to commit more on this
flavor of Pythonium, so I could work on more compliant flavors until
reaching full compliance with Python 3.

BUT, this is not very interesting, having full compliance is nice, but you
loose native javascript speed (meh!) I'd rather be working on the next
killer todo list or some Kivy-like library for the browser using Pythonium
Core.

What do you think?



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


Re: [ANN] Pythonium Core 0.2.5

2013-11-17 Thread Amirouche Boubekki
2013/11/17 Salvatore DI DIO salvatore.di...@gmail.com

 Are lists comprehensions are featured in Veloce ?


Ah! Good question, I did not think about it can probably add it to Core.
Thanks




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

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


Re: install package from github repository

2013-11-06 Thread Amirouche Boubekki
2013/11/6 C. Ng ngc...@gmail.com

 Ok, that seems to work... I modified from another package.


cool


 I don't understand how setup.py does it exactly, but got it done anyways.


as usual :-)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Compiling Python3 for BeagleBone Black (Angstrom distro)

2013-11-05 Thread Amirouche Boubekki
Use this http://hg.python.org/cpython/file/92022b45e60b/setup.py#l36

Add the list of modules you want to disable and redo make


2013/11/5 Travis Griggs travisgri...@gmail.com


 On Nov 4, 2013, at 9:22 AM, Travis Griggs travisgri...@gmail.com wrote:

  I'm playing with a BeagleBone Black running the angstrom distro. Of
 course, stock python is 2.7, I'd rather use python3. There isn't a python3
 package available for angstrom. So I downloaded the source and compiled. It
 seemed to work pretty well. I used the basic approach outlined in the
 REAMDE:
 
  ./configure
  make
  make test
  make install
 
  Now, I want to repeat the process, but be a little more judicious about
 what all is compiled. For example, I don't really need tk stuff (in fact,
 it just kept telling me it wasn't there). And there's probably a number of
 other modules/libraries in the kitchen sink known as the stock install,
 that I could forgo on a tiny little computer like this.
 
  I see, looking at ./configure --help | less, that I could provide
 --disable-FEATURE and --without-PACKAGE directives to my ./configure
 invocation. But what I don't see is how to generate a list of what
 FEATURES/PACKAGES I could put there for consideration of omission. Is there
 some magic juju that generates that?
 

 Should I have asked this question on python-dev instead? Not currently
 subscribed there… but would if that would generate more informed responses.

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

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


Re: install package from github repository

2013-11-04 Thread Amirouche Boubekki
create a setup.py and install it


2013/11/4 C. Ng ngc...@gmail.com

 Hi,

 I have cloned someone's repository on my local drive using git command:
 git clone http://github.com/xxx.git

 But I don't find any setup.py file. How do I install the package xxx? So
 that I can 'import xxx' in my python script.

 Many thanks.



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

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


Re: Compiling Python3 for BeagleBone Black (Angstrom distro)

2013-11-04 Thread Amirouche Boubekki
Hi Travis,

I see, looking at ./configure --help | less, that I could provide
 --disable-FEATURE and --without-PACKAGE directives to my ./configure
 invocation. But what I don't see is how to generate a list of what
 FEATURES/PACKAGES I could put there for consideration of omission. Is there
 some magic juju that generates that?


I don't remember correctly, I think it's a environment variable, also there
was a bug in python 2.7 regarding this...

Have a look at the setup.py of your python version there is some juju magic
mojo variable that configures the compiled extensions [1]

Also, whenever you want to compile something check gentoo ebuild aka.
compilation recipe, for instance for Python
3.3.2http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/dev-lang/python/python-3.3.2-r2.ebuild?revision=1.6view=markupor
linux
from scratch http://www.linuxfromscratch.org/lfs/.

Distcc might be helpful.


[1]
http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/dev-lang/python/python-3.2.3.ebuild?view=markup
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python and Google App intergration

2013-11-04 Thread Amirouche Boubekki
Héllo,


Look for Google Apps APIs. I'm not sure what you want to do is possible, at
least manipulating the spreadsheet is doable from Pythonl:

http://stackoverflow.com/questions/2377301/how-to-write-a-python-script-to-manipulate-google-spreadsheet-data


2013/11/4 caseyc...@google.com

 I don't know Python well.  Only recently started taking the
 Codeacademy.com class.
 Is there a way to take input from a Google Spreadsheet and use it to add
 membership to a Google Group?
 If not Python, is there another language that could perform this function?
 --
 https://mail.python.org/mailman/listinfo/python-list

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


Re: Python Practice Problems

2013-11-04 Thread Amirouche Boubekki
https://github.com/amirouche/1001-Projects


2013/11/4 Terry Reedy tjre...@udel.edu

 On 11/4/2013 12:28 AM, memilanuk wrote:

 On 11/03/2013 06:06 PM, yungwong@gmail.com wrote:

 Hi, who has some problems to practice using Python?
 Thx a lot!


 http://projecteuler.net/ is always a good bet


 Also www.checkio.org


 --
 Terry Jan Reedy

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

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


Re: pyC11 initial publication

2013-05-06 Thread Amirouche Boubekki
Héllo,

Does it support macros ? Is it possible to retrieve the list of macros and
define macro values ?

Thanks,

Amirouche


2013/5/4 Volker Birk bum...@dingens.org

 pyC11 is a grammar to parse programs in the C programming language
 following ISO/IEC 9899:2011. It is written using pyPEG, a parsing
 framework for Python. The grammar supports Python 2.7 and 3.x. The test
 bench requires py.test.

 This is the initial upload. The grammar is incomplete. Parsing C
 expressions works, but parsing complete C programs does not work yet.

 pyC11 is meant to be used for parsing, modifying and generating C
 expressions and programs. It is a real world sample how to use pyPEG.
 pyC11 is provided under the GNU GPL 2.0.

 You can find pyC11 on Bitbucket at https://bitbucket.org/fdik/pyc11.

 Yours,
 VB.
 --
 Volker Birk, Oberer Graben 4, CH-8400 Winterthur, Schweiz,
 Erde, Solar-System, Orion Arm, Milchstrasse, Lokale Gruppe,
 Virgo-Superhaufen, Coma-Virgo-Filament. mailto:ding...@bumens.org
 http://fdik.org  D-IRCNet fdik!v...@dragon.pibit.ch
 --
 http://mail.python.org/mailman/listinfo/python-announce-list

 Support the Python Software Foundation:
 http://www.python.org/psf/donations/

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


Welcome PythonScript: Python to Javascript translator in 350 lines of Python

2013-03-23 Thread Amirouche Boubekki
Héllo,

I'm happy to announce the immediate avaibility of PythonScript a Python -
Javascript translator written in Python. So far it works... Break it online
@ http://apppyjs.appspot.com


How it works ? Similarly to PyPy, it use a restricted version of Python
called PythonJS. Along side this translator there is two other components
PythonToPythonJS which translates (more) Python to PythonJS and a runtime
library written in PythonJS that creates javascript objects to emulate
classes, objects and methods. It's not compliant.

Other Python in the browser solutions are written in Javascript (skulpt,
brython) or both (pyjaco, pyjs) and are difficult to work with. This
implementation is fully written in Python with small snippets of Javascript.

Creating bindings is very easy, jQuery bindings are available. All the
thing is not much tested.

Also if you are interested in this topic, you might be interested by the
avaibility of asm.js in Firefox nightly. asm.js is a subset of JS, that can
be compiled by the browser, thus making solutions such as emscripten and
PyPy with an asm.js backend more interesting.


Cheers,

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


Re: Brython - Python in the browser

2012-12-21 Thread Amirouche Boubekki
Héllo,


  doc = 'blah blah xy: '+B('True!')


I will surely backlog latter or some crytologist from the futur will do and
he will surely agree about the fact something strange happened around
december 2012.

Sorry for that, that's me trying to be funny. Last time I checked DOM
manipulation is not the primary way for js devs to do DOM manipulation
anymore, or is it ? Javascript template engines do DOM manipulation but
this is almost invisible for the user so whatever the API, I expect this
will be minor, if not completly overlooked by users of Brython. I could
even argue more that for cross-language knowledge sharing the low level API
should be the same but no.

Brython is a very good idea. I failed at something similar except I took
the pyjs route and focused on classes (functions being callable class
objects) and bindings which is IMO more interessant than list
comprehensions, operator-overloading and plain functions. The idea was that
bindings will be even more important than in CPython because most of the
hard work for browser compatibility was already done and optimised by the
JS community. I may completly be off beat but the vision was that Python
would be for framework and application developpement and not for utility
libraries that would replace jQuery, SocketIO, Mediator.js History.js or
any template engine hence the focus on classes and meta-programming.

What is the plan regarding this issues in Brython ?

Regards,


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


Re: Pigeon Computer 0.1 Initial (BETA) release

2012-12-21 Thread Amirouche Boubekki
Héllo,


2012/12/22 Simon Forman forman.si...@gmail.com

 Pigeon Computer 0.1 Initial (BETA) release

 Summary
 

 The Pigeon Computer is a simple but sophisticated system for learning
 and exploring the fundamentals of computers and programming.

 It is written to support a course or class (as yet pending) to learn
 programming from the bit to the compiler.

 There is a DRAFT manual and a Pigeon User Interface that includes:

   * An assembler for the ATmega328P micro-controller.
   * A polymorphic meta-compiler.
   * Forth-like firmware in assembly.
   * Simple high-level language for assembly control structures.
   * A virtual computer that illustrates Functional Programming.

 Source code is released under the GPL (v3) and is hosted on Github:
   https://github.com/PhoenixBureau/PigeonComputer

 The manual is online in HTML form here:
   http://phoenixbureau.github.com/PigeonComputer/

 Mailing list:
   https://groups.google.com/d/forum/pigeoncomputer

 It has been tested on Linux with Python 2.7, YMMV.

 I'm releasing it now because it's basically done even though it needs
 polish and I'm just too excited about it.  Happy End of the World Day!


This sound fun!

Could you elaborate a bit in simple words what it is and what's the common
way to interact with the system ? What do you mean by « Forth-like firmware
in assembly » ? Is there a GUI ? Does it feels like being a hipster like in
the '50s or before and breaking the 1 billion dollar thing ?

Of course the little tutorial I stripped and read a bit gives some of the
responses.

Thanks

Amirouche




  - - -

 Whew!  If you are still reading, thank you.  There is a lot more to be
 done and I am hoping to form classes in early January 2013.  If you
 are interested please email me at forman.si...@gmail.com

 You can also participate on Github and join the mailing list.
   * https://github.com/PhoenixBureau/PigeonComputer
   * https://groups.google.com/d/forum/pigeoncomputer

 Warm regards,
 ~Simon P. Forman
 --
 http://mail.python.org/mailman/listinfo/python-announce-list

 Support the Python Software Foundation:
 http://www.python.org/psf/donations/

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


ANN: python-blueprints, printemps and printemps client

2012-10-16 Thread Amirouche Boubekki
Héllo,


I'm happy to announce about projects related to graph databases, Neo4j and
OrientDB and Python:

- python-blueprints is a Python bindings of Tinkerpop's
Blueprintshttps://github.com/tinkerpop/blueprints/wikilibrary that
allow you to access and query a graph database directly from
Python. The API is very small you can be ready to take over the world in a
matter of minutes
[documentationhttp://python-blueprints.readthedocs.org/en/latest/
][forge https://github.com/Printemps/python-blueprints]

- printemps-client with its compagnon server printemps allow you to query
remotly a graph database using only Python functions, if you know
python-blueprints, you will be up and running in less than 5 minutes!
checkout the 
documentationhttp://printemps-client.readthedocs.org/en/latest/and
the
code https://github.com/Printemps/printemps.

The intention of the announcement is (1) I thought others may find it useful,
and (2) to get feedback. So, please let me know what you think.


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


Re: [Neo4j] ANN: python-blueprints, printemps and printemps client

2012-10-16 Thread Amirouche Boubekki
Héllo Javier,

2012/10/16 Javier de la Rosa ver...@gmail.com

 Do you need Java [1] to run any of them? There is another alternative
 called pyblueprints [2] through REST interface.

 [1]
 http://pyjnius.readthedocs.org/en/latest/installation.html#installation
 [2] https://github.com/escalant3/pyblueprints


Yes it uses Java with Jnius https://github.com/kivy/pyjnius to make it
possible. Printemps makes it possible to have the a server and a client but
it's probably a better idea to use something like pyblueprints since there
is only one database thread.

Regards,

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


Re: Plumbum (Shell Combinators) hits v1.0

2012-10-08 Thread Amirouche Boubekki
2012/10/6 Tomer Filiba tomerfil...@gmail.com

 http://plumbum.readthedocs.org/en/latest/index.html

 Ever wished the wrist-handiness of shell scripts be put into a real
 programming language? Say hello to Plumbum Shell Combinators. Plumbum
 (Latin for lead, which was used to create pipes back in the day) is a small
 yet feature-rich library for shell script-like programs in Python. The
 motto of the library is “Never write shell scripts again”, and thus it
 attempts to mimic the shell syntax (shell combinators) where it makes
 sense, while keeping it all Pythonic and cross-platform.

 Apart from shell-like syntax and handy shortcuts, the library provides
 local and remote command execution (over SSH), local and remote file-system
 paths, easy working-directory and environment manipulation, and a
 programmatic Command-Line Interface (CLI) application toolkit.


Awesome, can it be used in combination with CJSH
http://jonathanscorner.com/cjsh/  ?

Regards,

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


Re: Experimental Python-based shell

2012-10-03 Thread Amirouche Boubekki
Héllo,

2012/10/3 Jonathan Hayward christos.jonathan.hayw...@gmail.com

 I've made an experimental Python-based Unix/Linux shell at:

 http://JonathansCorner.com/cjsh/

 An experimental Unix/Linux command line shell, implemented in Python 3,
 that takes advantage of some more recent concepts in terms of usability and
 searching above pinpointing files in heirarchies.


This sound like a great idea!  What are the other benefits of it except the
file lookup thing ? Does it do fuzzy match yet ?

Is there any repository on bitbucket or github ?

Thanks,

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


Re: Experimental Python-based shell

2012-10-03 Thread Amirouche Boubekki
2012/10/3 Jonathan Hayward jonathan.hayw...@pobox.com

 The chief benefit besides the searching, so far, is that you can use Py3k
 mixed with shell commands as the scripting language--so script in Python
 instead of bash.

 When using Python for scripting, Python lines are indented by an extra tab
 (or four spaces) while shell-like commands are not indented. So:

 cjsh for index in range(10):
  echo %(index)d
 
 0
 1
 2
 3
 4
 5
 6
 7
 8
 9

 Echo could (and maybe should) be a built-in, but it isn't. The output is
 os.system()'ed to bash, which echoes based on a command that includes the
 value of a Python variable. The implementation is a bit crude, but it is
 reasonably powerful.

 I have other things on the agenda, like making it able to run scripts and
 doing fuzzy matching, but for now those are the main two attractions.


Is it possible to drop completly the bash syntax and use some python
library (I saw it on github) that wraps bash commands with python functions
or the other around making it possible to call python functions with a
bash-like syntax. The syntax you are talking about seems strange.

Regards,

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


Re: [semi OT]: Smartphones and Python?

2012-02-27 Thread Amirouche Boubekki
for which I could write Python programs.


Android is good bet, kivy has official support for it
http://kivy.org/docs/guide/android.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Please verify!!

2012-02-23 Thread Amirouche Boubekki
2012/2/23 Manish Sharma manish2...@gmail.com

 Hi I am new to python language. On my first day, somebody told me that
 if any python script file is opened with any editor except python
 editor, the file is corrupted. Some spacing or indentation is changed
 and script stops working. I was opening the script file in Windows
 using Notepad++ but I didn't save anything and closed it. Still it was
 suggested to never open the python file in any other editor.

 Can anybody please verify this? Can opening a python script in any
 editor other than python editor corrupt the script? Did anybody ever
 face such type of issue or its just misunderstanding of the concept.



There is compatibility issue with line ending in Windows vs other OS that's
all I'm aware of.

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


Re: Forking simplejson

2012-02-10 Thread Amirouche Boubekki
Héllo,

I did it, it wasn't that difficult actually.

the source is available @ https://github.com/amirouche/jsonir

there is example :
https://github.com/amirouche/jsonir/blob/master/example.py

What makes the implementation of __json__ awkward is the iterencode support
of simplejson that I kept. I'm wondering if it makes
sens to have such a feature, what do you think ?

I does not support multiple json representation of an object
out-of-the-box, one solution is to __json__ hook a parameter of the
encoder.

I did not test it.

Cheers,

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


Re: Looking for PyPi 2.0...

2012-02-08 Thread Amirouche Boubekki
Héllo Nathan,

See below,

2012/2/8 Nathan Rice nathan.alexander.r...@gmail.com

 As a user:
 * Finding the right module in PyPi is a pain because there is limited,
 low quality semantic information, and there is no code indexing.
 * I have to install the module to examine it;  I don't need to look at
 docs all the time, sometimes I just want a
 package/class/function/method breakdown.
 * Given the previous point, having in-line documentation would be nice
 (for instance, just the output of .. automodule::)
 * Package usage/modification stats are not well exposed
 * No code metrics are available
 * I would like some kind of social service integration, for tagging
 and +1/likes.  I know ratings were scrapped (and they weren't that
 useful anyhow), but for example, if Armin Ronacher or Robert Kern
 thumbs up a module there is a pretty good chance I will be interested
 in it.

 As a developer:
 * I don't want to have to maintain my code repository and my package
 releases separately.  I want to let module repository know that my
 code repository exists, and that branches tagged as release should
 be made available.
 * I want to maintain one README.


 I don't like someone needs to do this now type posts but every time
 I use PyPi it infuratiates me.  I usually end up finding modules via
 Stack Overflow, which seems silly to me.


Let me do a recap with application analogies:

You want a combination of

   - github / bitbucket for source management *et ce terra*
   - http://readthedocs.org/ for documentation and search
   - http://nullege.com for code search
   - http://repos.io/ for the social features

I think it's not enough for fully integrated project management solution, I
will add this features:

   - Paragraph level and document level comments for documentation like
   http://djangobook.com/
   - Matrix comparaisons : grid feature of http://djangopackages.com/
   - Dependency tracking, library usage in a nice visual way
   - Ask for review thingy
   - Buildbot et all
   - Q/A system
   - Mailling lis
   - Bounties
   - Agenda because time lapse
   - Blogs because it's all the rage
   - CLI interface so that hipsters can hypergrep all the way
   - A big fat red button to promote good libraries into the standard lib
   - A specialized reader UI for hypernerds so that they can cope with that
   much information while still pretending to be human

And when the Python WAR-like format is done, automatic deployement of web
application on the Python.org cloud powered by machines using a pure Python
implemention of the HURD on top a green chips running PyPy.

HTH,

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


Re: SnakeScript? (CoffeeScript for Python)

2012-02-02 Thread Amirouche Boubekki
They are solution to write Python code that translates to javascript see
this thread
http://mail.python.org/pipermail/python-list/2011-November/1283110.html

2012/2/2 Michal Hantl michal.ha...@gmail.com

 Hello,
  I've been looking for something similar to CoffeeScript, but for python.

 Does anyone know of such project?


 So far I haven't found any attempt to do this, so I took few regular
 expressions and hacked this:
 https://plus.google.com/116702779841286800811/posts/56sBdwiZ4fT

 Any advice on what parses to use for the CoffeeScript-like syntaxe? I
 would like to use parser written in Python so I don't introduce
 dependencies.

 Any advice from Python gurus / language experimentators?

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

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


Re: (don't bash me too hard) Python interpreter in JavaScript

2011-11-16 Thread Amirouche Boubekki
Héllo

I am looking for a way how to bring Python interpreter to JavaScript, in
 order to provide a web-based application with python scripting
 capabilities. The app would have basic IDE for writing and debugging the
 python code, but the interpretation, of course, would be done in
 JavaScript. I'd like to avoid any client-server transactions, so all the
 interpretation should take place on the client side. The purpose of all
 this would be to create educational platform for learning the programming
 in python.


You might be looking for http://www.skulpt.org/
-- 
http://mail.python.org/mailman/listinfo/python-list


Is Python in the browser a dead-end ?

2011-10-28 Thread Amirouche Boubekki
Héllo,

There was a thread recently about the missed opportunity for Python to be a
language that could replace Javascript in the browser.

They are several attempts at doing something in this spirit here are the
ones I'm aware of:

- pyjamas aka. pyjs it is to Python what GWT is to Java : http://pyjs.org/
- py2js which compiles Python to Javascript without high level widget like
pyjamas does https://github.com/qsnake/py2js
- skulpt unlike py2js and pyjs there is no compilation phase
http://www.skulpt.org/

And SubScript [1], which I am the creator, a Python-like language [2] and
Sissi [3] which aims at being the stdlib of SubScript, currently it's
implemented with py2js. It relies heavly on Google Closure tools [4]. I'm
planning to add streamer [5] support if I can wrap my head around it.

I'm done with self advertisement.

Before starting SubScript I gave it some thoughts, and I think that it can
bring value to web development.

Here are articles that backs up my vision:

- Javascript gurus claims that Javascript is indeed the assembly of the
web [6], which means that Javascript is viable target for a compiler

- Similar projects exists with Coffescript and ClojureScript which seems to
have the lead and are gaining traction in web development community. Dart is
another example.

- The thing that makes Javascript development difficult is that it's hard to
debug, but map JS [7] is making its way into Firefox which will help greatly


Why do people think that this projects are doomed ?

I ask this question to understand other point of views before commiting
myself at finish SubScript  Sissi, I don't want to code something that will
be useless.

Thanks in advance,

Amirouche

[1] https://bitbucket.org/abki/subscript
[2] currently Subscript code is parsed by Python parsing library the exact
same syntax should be supported
[3] https://bitbucket.org/abki/sissi/overview
[4] http://code.google.com/intl/fr/closure/
[5] https://github.com/Gozala/streamer
[6]
http://www.hanselman.com/blog/JavaScriptIsAssemblyLanguageForTheWebSematicMarkupIsDeadCleanVsMachinecodedHTML.aspx
[7] https://bugzilla.mozilla.org/show_bug.cgi?id=618650
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Forking simplejson

2011-10-27 Thread Amirouche Boubekki
 +---+---+
 | Python protocol | JSON |
 | or special case | |
 +===+=**==+
 | (ø) __json__ | see (ø) |
 +---+-**--|
  | map   | object|


 I am curious what you mean by the 'map' protocol.


I mean dictionnary-like objects
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Forking simplejson

2011-10-27 Thread Amirouche Boubekki
2011/10/27 Chris Rebert c...@rebertia.com

 On Wed, Oct 26, 2011 at 2:14 AM, Amirouche Boubekki
 amirouche.boube...@gmail.com wrote:
  Héllo,
 
  I would like to fork simplejson [1] and implement serialization rules
 based
  on protocols instead of types [2], plus special cases for protocol free
  objects, that breaks compatibility. The benefit will be a better API for
  json serialization of custom classes and in the case of iterable it will
  avoid a calls like:
 
  simplejson.dumps(list(my_iterable))
 
  The serialization of custom objects is documented in the class instead of
  the ``default`` function of current simplejson implementation [3].
 
  The encoding algorithm works with a priority list that is summarized in
 the
  next table:
 
  +---+---+
  | Python protocol   | JSON  |
  |  or special case  |   |
  +===+===+
 snip
  | (§) unicode   | see (§)   |
 snip
  (§) if the algorithm arrives here, call unicode (with proper encoding
 rule)
  on the object and use the result as json serialization

 I would prefer a TypeError in such cases, for the same reason
 str.join() doesn't do an implicit str() on its operands:
 - Explicit is better than implicit.
 - (Likely) errors should never pass silently.
 - In the face of ambiguity, refuse the temptation to guess.


granted it's better.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: __dict__ attribute for built-in types

2011-10-27 Thread Amirouche Boubekki
2011/10/27 candide candide@free.invalid

 I realize that built-in types objects don't provide a __dict__ attribute
 and thereby i can't set an attribute to a such object, for instance


  a=[42,421]
  a.foo=bar
 Traceback (most recent call last):
  File stdin, line 1, in module
 AttributeError: 'list' object has no attribute 'foo'
  a.__dict__
 Traceback (most recent call last):
  File stdin, line 1, in module
 AttributeError: 'list' object has no attribute '__dict__'
 


 So, i was wondering :

 -- why this behaviour ?


performance


 -- where the official documentation refers to this point ?


it's here and there in python documentation. I did not find specific
documentation about the __dict__ property.

Have a look at :

- naming conventions in http://www.python.org/dev/peps/pep-0008/
- http://docs.python.org/library/stdtypes.html#modules

__dict__ is similar to other __*__ properties and has a function that
actually use it to do something usefull aka. dir
http://docs.python.org/library/functions.html#dir

The way I understand it is that it's for internal use but it's exposed for
debugging (and learning ?) purpose.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: __dict__ attribute for built-in types

2011-10-27 Thread Amirouche Boubekki
 But beside this, how to recognise classes whose object doesn't have a
 __dict__ attribute ?


Why do you need to access __dict__ ? maybe dir is enough see the other
message
-- 
http://mail.python.org/mailman/listinfo/python-list


Forking simplejson

2011-10-26 Thread Amirouche Boubekki
Héllo,

I would like to fork simplejson [1] and implement serialization rules based
on protocols instead of types [2], plus special cases for protocol free
objects, that breaks compatibility. The benefit will be a better API for
json serialization of custom classes and in the case of iterable it will
avoid a calls like:

 simplejson.dumps(list(my_iterable))

The serialization of custom objects is documented in the class instead of
the ``default`` function of current simplejson implementation [3].

The encoding algorithm works with a priority list that is summarized in the
next table:

+---+---+
| Python protocol   | JSON  |

|  or special case  |   |
+===+===+
| (ø) __json__  | see (ø)   |

+---+---|

| map   | object|

+---+---+
| iterable  | array |
+---+---+
| (*) float,int,long| number|

+---+---+
| (*) True  | true  |
+---+---+
| (*) False | false |

+---+---+
| (*) None  | null  |
+---+---+
| (§) unicode   | see (§)   |

+---+---+


(ø) if the object implements a __json__ method, the returned value is used
as the serialization of the object
(*) special objects which are protocol free are serialized the same way it's
done currently in simplejson
(§) if the algorithm arrives here, call unicode (with proper encoding rule)
on the object and use the result as json serialization

As soon as an object match a rule, it's serialized.

What do you think ? Do you find this API an improvement over simplejson ? Is
it worth to code ?

Where are documented the different protocols implemented by Python objects ?



Regards,

Amirouche

[1] https://github.com/simplejson/simplejson
[2]
https://github.com/simplejson/simplejson/blob/master/simplejson/encoder.py#L75
[3]
http://simplejson.readthedocs.org/en/latest/index.html#simplejson.JSONEncoder.default
-- 
http://mail.python.org/mailman/listinfo/python-list


[issue12657] Cannot override JSON encoding of basic type subclasses

2011-10-26 Thread Amirouche Boubekki

Changes by Amirouche Boubekki amirouche.boube...@gmail.com:


--
nosy: +abki

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12657
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4945] json checks True/False by identity, not boolean value

2011-10-26 Thread Amirouche Boubekki

Changes by Amirouche Boubekki amirouche.boube...@gmail.com:


--
nosy: +abki

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue4945
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com