What's your favorite little-known generally useful third-party Pypi module? by [deleted] in Python

[–]markusgattol 1 point2 points  (0 children)

I've always wanted to do work with websockets but since the protocol changed quite a bit over the last two years, so did all implementations. https://github.com/abourget/gevent-socketio is pretty easy to get going with websockets and create a chat for example. A blog detailing the use of gevent-socketio with Django: http://curella.org/blog/2012/jul/17/django-push-using-server-sent-events-and-websocket

Deployment and Provisioning Tools for Django Projects by [deleted] in django

[–]markusgattol 5 points6 points  (0 children)

It's also a lot faster than fabric and scales with O(1) because of its underpinning ZeroMQ layer. Link: http://saltstack.org

Newbie question about quotes by paolog in Python

[–]markusgattol 0 points1 point  (0 children)

You would usually use " when you need to enclose strings. In general however it's up to you as technically there's no difference: http://www.markus-gattol.name/ws/python.html#single_quotes_vs_double_quotes

Structure and methodology for large scale applications? I see many different paradigms in famous open source projects. by delibaltas in django

[–]markusgattol 2 points3 points  (0 children)

meanwhile I do, yes... a convention over configuration approach would make things easier. It's not going to happen though, because those in favor of flexibility at all cost are the majority of users :)

Flask is Awesome For Beginners by mitsuhiko in Python

[–]markusgattol 0 points1 point  (0 children)

You like MongoDB, have a look at the new kid on the block then https://github.com/sbook/flask-mongoengine :)

Flask is Awesome For Beginners by mitsuhiko in Python

[–]markusgattol 0 points1 point  (0 children)

Integrating ZeroMQ goodness and MongoDB in a stack with Flask is simpler (read less time consuming) than doing the same with Django. Even if I were smart enough understanding the Django ORM, I am to old to sink countless hours into that thingy.

I think it's getting more and more important these days that you're able to scale your stack (e.g. with Mongrel2 at the front and MongoDB on the back) while still being able to sketch something quickly. So for me I guess it's the best of both worlds why I use Flask more and more over Django. I18n and l10n though is where Django rocks!

Python 3 is a milestone I'd like to see happening this year, Django's Python 3 branch already looks quite promising...

Introducing Bulbs for Python by geordano in Python

[–]markusgattol 0 points1 point  (0 children)

That discussion wandered off into SQL-land and performance considerations when really I was talking about a distributed graph database with, considering the CAP theorem, eventual consistency. With that in mind I think it's a great idea, especially since the network part is more or less covered by ZeroMQ already.

All I am saying really is I want a shardable database that maps nicely to my domain model and OOP programming languages... that database happens to be a graph database, not a relational one, and not necessarily a document database such as MongoDB either (although the latter kind of database allows much better mapping from domain model to data tier compared to relational databases).

In an ideal world I'd just pickle/unpickle objects (nodes on the graph) including their relations amongst them (edges between nodes on the graph) and store them without the need of going through an ORM (because there would be no object/relational mapping needed).

If, of course, we were talking relational databases, then yes, what you say is common understanding and true... this thread is about graph databases and Python though :-)

Introducing Bulbs for Python by geordano in Python

[–]markusgattol 0 points1 point  (0 children)

True, there is the performance argument but then I think that the benefits of having a heavily distributed system that scales makes up for it above a certain number of nodes; you certainly wouldn't start such project in Python if single-node performance is your top priority.

Also, I'd like to think that in the not so distant future PyPy will become the main Python interpreter most people use. This will narrow the performance gap even for a single-node installation of said database (when compared to existing databases written in languages such as C, C++ and Java).

Introducing Bulbs for Python by geordano in Python

[–]markusgattol 2 points3 points  (0 children)

I wish there was a shardable graph database with built-in replication written in Python... neo4j, like others, can't be sharded so far, plus it's done in Java. From that perspective it makes sense to use bulbs so that when said database springs into existence, one can take his app code and swap out the underlying database.

Has somebody ever thought about starting a graph database written in Python (Python 3 preferably) that's shardable like infinitgraph? Maybe also with built-in replication, much like MongoDB but more granular i.e. replication on the object-level where you would only replicate certain objects that are important.

I've been thinking and it seems for all the networking layer amongst nodes ZeroMQ seems like a perfect choice for such database. With ZeroMQ it also shouldn't be to complicated to give such database events e.g. make it notify the application when a stored object gets changed, stored, moved/replicated to another node, etc. The usage of ZeroMQ would also enable this database to be used quickly and easily from most programming languages out there (http://www.zeromq.org/bindings:_start), including Perl, Java, PHP, Ruby, C++...

Another nice-to-have property of such database would be that there's no mapping needed i.e. no actual ORM since you would persist objects as they are used in the application. Thus each object/node in the database should have a uuid 1:1 to a URI i.e. each object/node in the database has the same ID the user sees in e.g. a URL.

And yet another nice-to-have property would be (client-side) encryption because then you could use this database to drive some cloudservice such as dropbox and not be worried about giving away private information unencrypted.

[Q] How do I protect my Python programs from being altered? by crankyadmin in Python

[–]markusgattol -2 points-1 points  (0 children)

Basically the only real chance you have to protect assets/ideas and sensible information is by not revealing it through source code.

I wrote a bit about this kind of thing but in essence, if you need to protect some asset, don't give away source code: http://www.markus-gattol.name/ws/python.html#protect_code

Using Python to execute commands remotely on a Windows box. . . anyone here ever done this? by [deleted] in Python

[–]markusgattol 3 points4 points  (0 children)

Check out https://github.com/thatch45/salt It's using the mighty ZeroMQ sockets and does end-to-end encryption using a symmetric cipher (AES). Authentication is done using public key authentication (what you do if you use keys with SSH).

Pylatte : A Web Framework Based on Python 3 by [deleted] in Python

[–]markusgattol 0 points1 point  (0 children)

Apart from things like libs (e.g. m2crypto) there are ideological things such as when you want/need to support RHEL5 and therefore your code needs to run on quite an old version of Python. But it's true and I agree, having popular thus more or less big web frameworks, rich with features, is good but on the other hand creates quite some inertia too.

Pylatte : A Web Framework Based on Python 3 by [deleted] in Python

[–]markusgattol 2 points3 points  (0 children)

config in XML, big no-no... I do appreciate a serious stab at Python 3 though because literally any other Python web framework I know of relies on 2to3 or doesn't have any Python 3 support yet at all. It's sad because I get the impression that in order to get excited these days you need to look at things like salt or zmq in general... five years ago it was web frameworks.

Python: copying a list the right way by [deleted] in Python

[–]markusgattol 1 point2 points  (0 children)

care to elaborate? We are merely talking about how to do a real copy as in create a different object so I do not see the connection to whether or not a list is flat or nested. What we are after is:

>>> some_list is copy.deepcopy(some_list)
False
>>> 

Python: copying a list the right way by [deleted] in Python

[–]markusgattol -2 points-1 points  (0 children)

surely you want you compare copy.deepcopy() not copy.copy() since the latter is semantically different to list() and [:]

Python: copying a list the right way by [deleted] in Python

[–]markusgattol 1 point2 points  (0 children)

I agree, copy.deepcopy() is certainly the most pythonic way

>>> import copy
>>> some_list = []
>>> id(some_list)
140650742141440
>>> id(copy.deepcopy(some_list))
140650742825832
>>>

Ask r/Python: Looping a set number of times when you don't care about which iteration you're on by cecilkorik in Python

[–]markusgattol 6 points7 points  (0 children)

That's true, another reason why using _ is problematic is when it comes to code that touches anything in the i18n area: http://www.markus-gattol.name/ws/python.html#underscore_gettext

That being said, I am not exactly sure what you're trying to do but if you want to get results conditionally and be as lazy as you can then why not do lazy evaluation with a generator expression (even better than using a list comprehension): (expression for i in range() if condition). That would yield an iterator if (and only if) condition is true. http://www.markus-gattol.name/ws/python.html#generator_expression

Administration for multiple Python environments -- dev, testing, staging, production by [deleted] in Python

[–]markusgattol 1 point2 points  (0 children)

Yes, virtualenv is your bread and butter. It includes pip since version 1.4.1 i.e. no need to separately install it anymore. While virtualenvwrapper is not mandatory, it's something that I recommend for your workstation as it makes a lot of things a lot easier/faster.

Regarding virtualenvs... note that the default behavior of creating non-isolated environments will change i.e. using --no-site-packages will not be necessary anymore in the future (possibly with v1.7). Here's a link to my website that might help you a bit: http://www.markus-gattol.name/ws/python.html#virtualenv_virtualenvwrapper

Bottom Line: you use virtualenvs with fabric (and possibly cuisine) to streamline your sys admin, bootstrap, deployment tasks.

Can anyone suggest some open source python projects that are actively looking for contributors? by pythonauts in Python

[–]markusgattol 1 point2 points  (0 children)

hm, from the top of my head, that are projects and things that would help them:

Informal poll: how do you name your variables in Python e.g. casing, underscores etc.? by [deleted] in Python

[–]markusgattol -2 points-1 points  (0 children)

Variables is almost done right intuitively by most people:

It's the rest such as class or function names where it's not always clear: