Re: create a directory structure

2011-09-16 Thread Andrea Crotti
After some research, I think that paste-script is the best choice in this case. I can define templates and I'll get my directory structure nicely populated for me. -- http://mail.python.org/mailman/listinfo/python-list

create a directory structure

2011-09-16 Thread Andrea Crotti
I would like to write a program which creates a directory structure and fills in a few templated fields some values passed in as arguments. So for example create_struct.py might create base_dir: |_ sub_dir1: |_ sub_file1 ... It's quite simple in theory, but I would also like to make it very

Re: create a directory structure

2011-09-18 Thread Andrea Crotti
On 09/17/2011 12:56 PM, Rafael Durán Castañeda wrote: I think you might want to look at Fabric or vagrant Thanks, but I don't understand how these two project would help me... I don't need to deploy on many machines via s

extending class

2011-09-23 Thread Andrea Crotti
I wanted to add a couple of parameters to a class from a given library (paste-script), but without changing the original code. So I thought, I create a wrapper class which adds what I need, and then dispatch all the calls to the super class. My following attempt gives, however, a recursion erro

Re: extending class

2011-09-23 Thread Andrea Crotti
On 09/23/2011 10:31 AM, Peter Otten wrote: Inside __getattribute__() you ask for self.first_var which triggers another __getattribute__() call that once again trys to determine the first_var attribute before it returns... Try using __getattr__() instead which is only triggered for non-existent

Develop inter-dependent eggs

2011-09-23 Thread Andrea Crotti
Develop inter-dependent eggs: On a Linux machine I have many eggs to develop, for example - egg1 - egg2 ... Now the eggs depend from each other, so running "python setup.py develop" in order, doesn't work, because if the dependency required is not already installed then easy_install tries to

Re: extending class

2011-09-23 Thread Andrea Crotti
Jean-Michel Pichavant writes: > Did you consider subclassing your Var class ? This is how you extend a > class behavior in OOP. > > class PSIVar(var): >def __init__(self, name, desc, other=None, fun=None): >var.__init__(self, name, desc) >if other is not None: >sel

Re: Replacing spreadsheets by Python and the browser

2011-10-02 Thread Andrea Crotti
On 10/02/2011 06:36 PM, markolopa wrote: Hello, Could you please recommend me a Python tool that could help me to get rid of the messy information and scripts I have in spreadsheets? Spreadsheets are great for having simple things done quickly. But as the needs grow their limitations can be qui

Re: Change import order with *.pth files

2011-10-02 Thread Andrea Crotti
On 10/02/2011 10:29 PM, Andrea Gavana wrote: Hi All, my apologies if this is a dumb question, but I couldn't find a solution - possibly because I am not sure how to state my problem in a short sentence. Let's say I am using a package called "blah", and this package is already installed

Re: eggbasket

2011-10-04 Thread Andrea Crotti
On 10/04/2011 08:34 PM, Miki Tebeka wrote: Do you have a local file/directory that is called sqlalchemy? Funny thing, I have the same problem with another machine, with sqlalchemy installed system-wide instead of locally. Strange issue, maybe a problem with python 2.7/Linux? -- http://mail.p

Re: eggbasket

2011-10-05 Thread Andrea Crotti
Well it was easy, apparently sqlalchemy.exceptions doesn't exist but sqlalchemy.exc does, and that's the correct one, maybe a version problem... I get another problem right after File "/home/andrea/PSI_refactor/test_local_pypi/lib/python2.7/site-packages/EggBasket-0.6.1b-py2.7.egg/eggbasket/c

profiling big project

2011-10-11 Thread Andrea Crotti
Hi everyone, I am in the situation that I'll have to profile huge python programs, huge because they use many external libraries like numpy / pyqt / ETS etc etc... The applications are very slow and we wanted to understand what is actually going on. I like to use normally pycallgraph, but in this

Re: shipping python

2011-10-12 Thread Andrea Crotti
On 10/12/2011 10:10 PM, Kristen J. Webb wrote: I tried experimenting with .pyc files only to end up at: RuntimeError: Bad magic number in .pyc file can't run 2.5 pyc files on 2.6 :( My main motivation to use .pyc is to keep end users from changing scripts, breaking things, and then calling u

services/daemons

2011-10-26 Thread Andrea Crotti
Running pypiserver as a service? I'm writing some scripts which in theory should be able to: - start up a local pypi server as a daemon (or well a service on Windows) - run "python setup.py develop" on a potentially very big set of eggs, possibly discovering automatically for changes. In the

locate executables for different platforms

2011-10-31 Thread Andrea Crotti
Suppose that I have a project which (should be)/is multiplatform in python, which, however, uses some executables as black-boxes. These executables are platform-dependent and at the moment they're just thrown inside the same egg, and using pkg_resources to get the path. I would like to rewrite t

Re: locate executables for different platforms

2011-10-31 Thread Andrea Crotti
On 10/31/2011 02:00 PM, Andrea Crotti wrote: Suppose that I have a project which (should be)/is multiplatform in python, which, however, uses some executables as black-boxes. These executables are platform-dependent and at the moment they're just thrown inside the same egg, and

leftover pyc files

2011-11-02 Thread Andrea Crotti
In our current setup, the script in charge to run our applications also scan all the directories and if it finds any "pyc" file without the corresponding module, it removes it. This was done because when you rename something, the old "pyc" remains there and can cause problems. Is it the only w

Re: leftover pyc files

2011-11-02 Thread Andrea Crotti
On 11/02/2011 03:03 PM, Peter Otten wrote: Switch to Python3.2 ;) Yes I saw that and it would be great, unfortunately we're stuck with Python 2.5 :O for some more time. Anyway now the code that does it is a recursive thing ilke def _clean_orphaned_pycs(self, directory, simulate=False): "

Re: leftover pyc files

2011-11-02 Thread Andrea Crotti
On 11/02/2011 04:06 PM, Chris Kaynor wrote: If you can at least upgrade to Python 2.6, another option, if you don't mind losing the byte code caching all together (it may worsen load times, however probably not significantly), you can set PYTHONDONTWRITEBYTECODE to prevent the writing of .pyc fil

Re: leftover pyc files

2011-11-03 Thread Andrea Crotti
All these ideas (shell and git hooks) are nice, but unfortunately - it's svn not git - it's windows not *nix - we have to remove only the ones without the corresponding *py... -- http://mail.python.org/mailman/listinfo/python-list

Re: leftover pyc files

2011-11-04 Thread Andrea Crotti
On 11/04/2011 09:27 AM, Jonathan Hartley wrote: I like to install a Bash shell of some kind on windows boxes I work on, specifically so I can use shell commands like this, just like on any other operating system. Cywin works just fine for this. svn also has hooks, but sadly not a checkout hook

Re: leftover pyc files

2011-11-04 Thread Andrea Crotti
On 11/04/2011 10:39 AM, Chris Angelico wrote: If you're removing them all, you don't need to use a powerful shell. Much much easier! Just recursively del *.pyc and you're done. ChrisA Discussing with the guy that did it I think it's actually a good idea instead, because removing them *all* me

Re: Design Pattern and Python: Any book recommendation? Your view?

2011-11-04 Thread Andrea Crotti
On 11/04/2011 12:33 AM, Anthony Kong wrote: Sorry to resurrect this topic. By google search the last discussion was in 2003. I would like to find out what is the current prevailing view or consensus (if any) on the use of Design Pattern in python? I am doing some 'fact-finding' in this area on

simple import hook

2011-11-10 Thread Andrea Crotti
So I would really like to accomplish the following: run a program normally and keep track of all the imports that were actually done. I studied the PEP 302, but I'm still a bit confused about how to do it. I thought that instead of implementing everything I could just record the request and

Re: simple import hook

2011-11-10 Thread Andrea Crotti
On 11/10/2011 05:02 PM, Eric Snow wrote: Yeah, I'm working on a reference for imports in Python. They're just a little too mysterious relative to the rest of the language. But it's not too helpful yet. In the meantime... Yes it's quite mysterious, and it's actually not as hard as it looks..

pymacs?

2011-11-16 Thread Andrea Crotti
After a long time, and since it was included iin python-mode, I wanted to try if I can get ropemacs working finally. I have tried many possible things, also in Emacs -Q, and I actually got it working only once, apparently by pure luck with Emacs -Q: (setq py-load-python-mode-pymacs-p nil) (se

decorators and closures

2011-11-21 Thread Andrea Crotti
With one colleague I discovered that the decorator code is always executed, every time I call a nested function: def dec(fn): print("In decorator") def _dec(): fn() return _dec def nested(): @dec def fun(): print("here") nested() nested() Will give: In dec

Re: decorators and closures

2011-11-21 Thread Andrea Crotti
On 11/21/2011 03:06 PM, Dave Angel wrote: Your function 'nested' isn't nested, 'fun' is. What you discovered is that a decorator is always executed, every time a nested decorated function is defined. You've also ust proved that it would be an incompatible change. Doesn't that answer the que

Re: What I do and do not know about installing Python on Win 7 with regard to IDLE.

2011-11-21 Thread Andrea Crotti
On 11/21/2011 04:39 PM, W. eWatson wrote: ... I'm using Win 7 Premium. So unless some brilliant idea appears, that leaves me with the choice of not using Python or this suggestion... (Let's not get off into other variations of other "Pythons" like Active..."): Someone suggested using the mai

Re: decorators and closures

2011-11-21 Thread Andrea Crotti
On 11/21/2011 05:11 PM, Dave Angel wrote: You didn't mention what version of Python you're running. With Python 2, I got very different results. So I switched to Python 3.2, and I still don't get exactly what you have. A closure is needed if there's some non-global data outside the functi

Re: What I do and do not know about installing Python on Win 7 with regard to IDLE.

2011-11-22 Thread Andrea Crotti
On 11/22/2011 04:14 PM, W. eWatson wrote: > Your joking, right, or do you just prefer 500 line threads wandering > all over the place? I would personally prefer to just not see useless discussions about Windows set up in a python mailing list, but I guess it's a price to pay for the popularity of

getting svn tag in version

2011-11-25 Thread Andrea Crotti
Given a project with many eggs, I would like to make it easy to have all the version numbers synchronized to the upper level SVN version. So for example I might have svn tags 0.1, 0.2 and a development version. The development version should get version -dev, and the others 0.1 and 0.2 I found

python 2.5 and ast

2011-11-28 Thread Andrea Crotti
I'm happily using the ast module to analyze some code, but my scripts need also to run unfortunately on python 2.5 The _ast was there already, but the ast helpers not yet. Is it ok if I just copy over the source from the ast helpers in my code base or is there a smarter way? (I don't even need al

Re: python 2.5 and ast

2011-11-29 Thread Andrea Crotti
On 11/29/2011 03:55 AM, Dave Angel wrote: But don't forget to tag it as version specific, so it gets removed when the later version of the library is available. There are various ways of doing that, but the easiest is probably to put a test in the acceptance suite that fails if this code is

Re: python 2.5 and ast

2011-11-29 Thread Andrea Crotti
On 11/29/2011 11:32 AM, Steven D'Aprano wrote: I prefer to check against sys.version. import sys if sys.version<= '2.5': from psi.devsonly.ast import parse, NodeVisitor else: from ast import parse, NodeVisitor Or even: try: from ast import parse, NodeVisitor except ImportErr

Re: python 2.5 and ast

2011-11-30 Thread Andrea Crotti
Another thing about the AST, I am having fun trying to for example list out all the unused imports. I have already a visitor which works quite nicely I think, but now I would like to get a way to find all the unused imports, so I need more visitors that find out all the used names. I didn't f

Re: python 2.5 and ast

2011-12-02 Thread Andrea Crotti
On 12/02/2011 03:18 PM, DevPlayer wrote: There was another topic in these forums recently about "un-importing" modules (and how you can not do that reliably without restarting python). There was various ways mentioned of keeping track of what was imported. And there was mentioned reasonable ways

Re: python 2.5 and ast

2011-12-02 Thread Andrea Crotti
And on a related topic, how can I actually detect other types of imports, for example __import__ Doing a dump I get this: In [113]: ast.dump(ast.parse('__import__("module")')) Out[113]: "Module(body=[Expr(value=Call(func=Name(id='__import__', ctx=Load()), args=[Str(s='module')], keywords=[], s

whitespace cleanup

2011-12-06 Thread Andrea Crotti
Now on Emacs I have a hook before every save that cleans up all the "wrong" white spaces, with the 'whitespace-cleanup' function. I would like that also for my non emacsers colleagues, and possibly with a Python script. I looked up around but I can't find anything useful, any advice? Thanks, And

Re: whitespace cleanup

2011-12-06 Thread Andrea Crotti
On 12/06/2011 11:49 AM, Pedro Henrique G. Souto wrote: On 06/12/2011 09:28, Andrea Crotti wrote: > Now on Emacs I have a hook before every save that cleans up all the > "wrong" white spaces, > with the 'whitespace-cleanup' function. > > I would like that also

Re: whitespace cleanup

2011-12-06 Thread Andrea Crotti
On 12/06/2011 12:17 PM, Pedro Henrique G. Souto wrote: Something like PythonTidy does what you want? http://pypi.python.org/pypi/PythonTidy If you like to write your own script, or if what you want is similar, but not the same, the source code is a good place to start: http://lacusveris.com

Re: whitespace cleanup

2011-12-06 Thread Andrea Crotti
So apparently PythonTidy uses the AST (the compiler module) to find out the problems, and generates new nodes with a put method to write out the code with the fix. An awful lot of code is needed to make it work apparently, not very neat. Pep8 instead uses tokenize and regular expressions only,

Re: Questions about LISP and Python.

2011-12-07 Thread Andrea Crotti
On 12/06/2011 04:36 AM, Xah Lee wrote: i don't like python, and i prefer emacs lisp. The primary reason is that python is not functional, especially with python 3. The python community is full of fanatics with their drivels. In that respect, it's not unlike Common Lisp community and Scheme lisp c

Re: Questions about LISP and Python.

2011-12-08 Thread Andrea Crotti
On 12/08/2011 04:10 AM, Rick Johnson wrote: ... Why has GvR not admonished the atrocious behavior of some people in this community? Why has GvR not admitted publicly the hideous state of IDLE and Tkinter? Where is the rally call? Where is the community spirit? The future of Pythin is in your han

Re: Misleading error message of the day

2011-12-08 Thread Andrea Crotti
On 12/08/2011 02:23 PM, Roy Smith wrote: I just spent a while beating my head against this one. # Python 2.6 a, b = 'foo' Traceback (most recent call last): File "", line 1, in ValueError: too many values to unpack The real problem is that there's too *few* values to unpack! It should hav

Re: Documentation using Sphinx

2011-12-08 Thread Andrea Crotti
On 12/08/2011 02:09 PM, sajuptpm wrote: Hi, I am trying source code documentation using Sphinx. Here i have to copy paste all modules in to *.rst file, that is painful. Have any way to create documentation (doc for all modules, classes and methods in the project directory) from project folder qui

Re: Misleading error message of the day

2011-12-08 Thread Andrea Crotti
On 12/08/2011 03:42 PM, Roy Smith wrote: Why not? Take this example: def i(): i = 0 while True: print "returning:", i yield i i += 1 a, b = i() ./iter.py returning: 0 returning: 1 returning: 2 Traceback (most recent call last): File "./iter.py", line 1

adding elements to set

2011-12-08 Thread Andrea Crotti
I've wasted way too much time for this, which is surely not a Python bug, not something that surprised me a lot. I stupidly gave for granted that adding an object to a set would first check if there are equal elements inside, and then add it. As shown below this is not clearly the case.. Is it p

Re: tracking variable value changes

2011-12-09 Thread Andrea Crotti
On 12/08/2011 08:17 PM, Catherine Moroney wrote: Hello, Is there a way to create a C-style pointer in (pure) Python so the following code will reflect the changes to the variable "a" in the dictionary "x"? For example: >>> a = 1.0 >>> b = 2.0 >>> x = {"a":a, "b":b} >>> x {'a': 1.0, 'b': 2.0}

Re: [OT] Book authoring

2011-12-09 Thread Andrea Crotti
On 12/09/2011 03:25 AM, Miki Tebeka wrote: Greetings, Any recommendations for a book authoring system that supports the following: 1. Code examples (with syntax highlighting and line numbers) 2. Output HTML, PDF, ePub ... 3. Automatic TOC and index 4. Search (in HTML) - this is a "nice to have"

Re: Confusion about decorators

2011-12-12 Thread Andrea Crotti
On 12/12/2011 01:27 PM, Henrik Faber wrote: Hi group, I'm a bit confused regarding decorators. Recently started playing with them with Python3 and wanted (as an excercise) to implement a simple type checker first: I know there are lots of them out there, this is actually one of the reasons I cho

change a file with a context manager

2011-12-13 Thread Andrea Crotti
So I have the following problem, I need something to copy a file to a certain position and restore it after. So I wrote this simple context manager: class WithCorrectEasyInstall(object): def __enter__(self): import pkg_resources from shutil import copyfile easy_insta

Re: change a file with a context manager

2011-12-13 Thread Andrea Crotti
On 12/13/2011 10:59 AM, Andrea Crotti wrote: So I have the following problem, I need something to copy a file to a certain position and restore it after. So I wrote this simple context manager: class WithCorrectEasyInstall(object): def __enter__(self): import pkg_resources

logging issues

2011-12-13 Thread Andrea Crotti
I think is simple but I can't get it to work as I wish. Suppose I have a big application, my idea is that the running script sets a global logging level and then all the imported modules would act consequently. In my codebase, however, unless I set the level for each of the loggers I don't get th

Re: logging issues

2011-12-13 Thread Andrea Crotti
On 12/13/2011 04:11 PM, Jean-Michel Pichavant wrote: Not really, if you use the classic way, your subloggers should be created an never configured. Their default behavior is to raise any log event to its parent. That way, all event logs end up being handled by the root logger. Ok thanks now

boolean from a function

2011-12-13 Thread Andrea Crotti
I'm not sure for how long I had this bug, and I could not understand the problem. I had a function which would return a boolean def func_bool(): if x: return True else: return False Now somewhere else I had if func_bool: # do something I could not quite understand why it

Re: logging issues

2011-12-13 Thread Andrea Crotti
And by the way suppose I have a script which takes as input the log level and a list of possible filters. In another file I have a couple of functions as below which are called in that order. Is that supposed to work? In theory I'm getting both times the same logger. The set_verbosity seems to do

Re: boolean from a function

2011-12-14 Thread Andrea Crotti
On 12/13/2011 11:37 PM, Steven D'Aprano wrote: x is a global? Poor design. But in any case, instead of an explicit if...else block, the canonical way to convert an arbitrary object to True/ False is with bool: def func_bool(): return bool(x) But you don't need it. See below. No no it

merging argparse parsers

2011-12-16 Thread Andrea Crotti
I would like to have something like merged_parser = LoggingParser() + OtherParser() Which should create an argument parser with all the options composed. Now for that I think I would need to subclass the argument, and something fancy with the overloading. The problem is that apparently there is

profiling code

2011-12-20 Thread Andrea Crotti
I would like to automate some kind of performance profiling, to see if the application (and possibly pieces of it) becomes slower/faster and why. So I did something like this, where the statement passed also called parse_arguments, which is nice because I can run the other script with the norma

Re: Python education survey

2011-12-20 Thread Andrea Crotti
On 12/20/2011 03:51 AM, Raymond Hettinger wrote: Do you use IDLE when teaching Python? If not, what is the tool of choice? Students may not be experienced with the command-line and may be running Windows, Linux, or Macs. Ideally, the tool or IDE will be easy to install and configure (startup di

argparse and default values

2012-01-05 Thread Andrea Crotti
There's one thing I don't understand about argparse, why doesn't --help show what is the default value?? I mean if I add an option that can be customized it would be good for the user to know what is the current value in my opinion. Is there a way to make it show it? -- http://mail.python.org/m

Re: argparse and default values

2012-01-05 Thread Andrea Crotti
On 01/05/2012 01:24 PM, Andrea Crotti wrote: There's one thing I don't understand about argparse, why doesn't --help show what is the default value?? I mean if I add an option that can be customized it would be good for the user to know what is the current value in my opinion.

multiversion flag and auto requiring import hook

2012-01-19 Thread Andrea Crotti
I'm using the multiversion flag in setuptools (-m) to be able to run many different projects, without modifying the global environment. Then thanks to pkg_resources magic and setuptools I can get automatically everything loaded. Now the problem is that we want to be able to run tests. The best

Re: multiversion flag and auto requiring import hook

2012-01-19 Thread Andrea Crotti
... Actually the main problem which I've been banging my head quite a few days alreays is this: --8<---cut here---start->8--- ERROR: Failure: AttributeError ('module' object has no attribute 'walk')

importing and nose

2012-01-19 Thread Andrea Crotti
I'm writing some code to analyse pstats statistics, and I'm trying to have some working unit tests. Suppose I have in the test directory another directory 'profiling', which contains 'x.py', and 'b.py'. Now running the following code in a script works perfectly, class TestStatParser(unittest.T

Re: Please don't use "setuptools", the "rotten .egg" install system.

2012-01-19 Thread Andrea Crotti
On 01/19/2012 05:05 PM, John Nagle wrote: I can do it, I just have better things to do than system administration. The fact that Python doesn't "just work" is part of why it's losing market share. Maybe in your home is losing market (if you're so sure post some sources). If it can be

Re: importing and nose

2012-01-19 Thread Andrea Crotti
On 01/19/2012 05:36 PM, Peter Otten wrote: I don't believe you. Quite sure it does: [andrea@precision test]$ cat simple.py import profile from os import path import sys prof_path = path.join(path.dirname(__file__), 'profiling') sys.path.append(prof_path) import x profile.run('x.f1()') [and

Is a with on open always necessary?

2012-01-20 Thread Andrea Crotti
I normally didn't bother too much when reading from files, and for example I always did a content = open(filename).readlines() But now I have the doubt that it's not a good idea, does the file handler stays open until the interpreter quits? So maybe doing a with open(filename) as f: con

while True or while 1

2012-01-21 Thread Andrea Crotti
I see sometimes in other people code "while 1" instead of "while True". I think using True is more pythonic, but I wanted to check if there is any difference in practice. So I tried to do the following, and the result is surprising. For what I can see it looks like the interpreter can optimize a

Re: while True or while 1

2012-01-21 Thread Andrea Crotti
Actually there was the same question here (sorry should have looked before) http://stackoverflow.com/questions/3815359/while-1-vs-for-whiletrue-why-is-there-a-difference And I think the main reason is that 1 is a constant while True is not such and can be reassigned. -- http://mail.python.org/mai

Re: groupby behaviour

2013-02-26 Thread andrea crotti
2013/2/26 Ian Kelly : > On Tue, Feb 26, 2013 at 9:27 AM, andrea crotti > wrote: >> So I was trying to use groupby (which I used in the past), but I >> noticed a very strange thing if using list on >> the result: > > As stated in the docs: > > ""&qu

Mixin way?

2013-04-03 Thread andrea crotti
I have some classes that have shared behaviours, for example in our scenario an object can be "visited", where something that is visitable would have some behaviour like --8<---cut here---start->8--- class Visitable(Mixin): FIELDS = { 'visits': [],

Re: Mixin way?

2013-04-03 Thread andrea crotti
2013/4/3 Steven D'Aprano > [snip] > > So, if you think of "Visitable" as a gadget that can be strapped onto > your MyObj as a component, then composition is probably a better design. > But if you think of "Visitable" as a mere collection of behaviour and > state, then a mixin is probably a better

dynamic forms generation

2013-04-16 Thread andrea crotti
We are re-designing a part of our codebase, which should in short be able to generate forms with custom fields. We use django for the frontend and bottle for the backend (using CouchDB as database), and at the moment we simply plug extra fields on normal django forms. This is not really scalable,

Re: dynamic forms generation

2013-04-19 Thread andrea crotti
Well I think since we are using django anyway (and bottle on the API side) I'm not sure why we would use flask forms for this.. Anyway the main question is probably, is it worth to try to define a DSL or not? The problem I see is that we have a lot and very complex requirements, trying to define a

global lists

2005-05-08 Thread andrea crotti
Hi everbybody again, I have a little "problem", I don't understand the reason of this: a = [10,1,2,3] def foo(): global a for el in a: el = el*2 This doesn't make any difference, if I do def foo(): global a a[0] = 4 But def foo(): global a for n in range(len(a)): a[n] = a[n]

Re: In lista infinita?

2009-12-09 Thread Andrea Crotti
On 8 Dic, 18:50, Andreas Waldenburger wrote: > Maybe. But I'm sure it.comp.lang.python might help you better. And from > the looks of it, you seem to have started a similar thread there > (called "Generatori infiniti"). > > Generally, you'll fare better with English (even broken English will be >

Re: Class or Dictionary?

2011-02-11 Thread Andrea Crotti
On Feb 11, 3:56 pm, Martin De Kauwe wrote: > Hi, > > I have a series of parameter values which i need to pass throughout my > code (>100), in C I would use a structure for example. However in > python it is not clear to me if it would be better to use a dictionary > or build a class object? Person

Re: Class or Dictionary?

2011-02-11 Thread Andrea Crotti
Il giorno 11/feb/2011, alle ore 17.01, Martin De Kauwe ha scritto: > > i have a number some are smaller, for example switch/control flags. > But the rest can be quite large. I can split them but I don't see the > advantage particularly. Currently by using them (e.g. > params.rate_of_decomp) it cl

Re: Class or Dictionary?

2011-02-11 Thread Andrea Crotti
Il giorno 11/feb/2011, alle ore 19.47, Ethan Furman ha scritto: > > I strongly disagree. Code readability is one of the most important issues. Perfectly agree with that, but obj.name = x obj.surname = y obj['name'] = x obj['surname'] = y are both quite readable in my opinion. Other things a

Re: Class or Dictionary?

2011-02-12 Thread Andrea Crotti
Il giorno 12/feb/2011, alle ore 00.45, Martin De Kauwe ha scritto: > Hi, > > yes I read a .INI file using ConfigParser, just similar sections (in > my opinion) to make one object which i can then pass to different > classes. E.G. Ok then I suggest configobj, less buggy and much more powerful th

multiprocessing & more

2011-02-13 Thread Andrea Crotti
Hi everyone, I have a few questions about my implementation, which doesn't make me totally happy. Suppose I have a very long process, which during its executiong logs something, and the logs are is in n different files in the same directory. Now in the meanwhile I want to be able to do realtime

Re: multiprocessing & more

2011-02-14 Thread Andrea Crotti
On Feb 14, 12:14 am, Adam Skutt wrote: > On Feb 13, 12:34 pm, Andrea Crotti wrote: > > > > > First of all, does it make sense to use multiprocessing and a short > > value as boolean to check if the simulation is over or not? > > Maybe, but without knowing exactly wh

lint warnings

2011-02-14 Thread Andrea Crotti
I work on emacs with flymake activated and pylint, pyflakes and pep8 running in background to notify for some style problems. Now there are at a couple of pylint warnings which I don't understand 1. Warning (W, filter_enums): Used builtin function 'map' [2 times] what is the problem with using ma

Re: lint warnings

2011-02-15 Thread Andrea Crotti
Il giorno 15/feb/2011, alle ore 04.10, Ben Finney ha scritto: > Andrea Crotti writes: > The ‘map’ builtin is deprecated; using a list comprehension is neater > and more efficient. Ok well it depends, map(int, biglist) is better than: [int(x) for x in biglist] at least for me. Effi

interleave string

2011-02-15 Thread Andrea Crotti
Just a curiosity not a real problem, I want to pass from a string like xxaabbddee to xx:aa:bb:dd:ee so every two characters insert a ":". At the moment I have this ugly inliner interleaved = ':'.join(orig[x:x+2] for x in range(0, len(orig), 2)) but also something like this would work [''

interfacing python with emacs

2011-02-16 Thread Andrea Crotti
I decided that I finally want to get auto-completion and other really cool things for my python/emacs environment. Rope also looks really great and being able to refactor easily would really be a dream :) (no more excuses from java developers then) http://rope.sourceforge.net/ Pymacs is already

2to3

2011-02-17 Thread andrea crotti
What would be an almost automated way to develop for both python 2.x and 3.x? 2to3 apparently can only output a diff or write directly on the file (with -w), but why doesn't it output the resulting file for 3.x instead? So for a single python file I tried a makefile like: Makefile: all: empathy.

Re: 2to3

2011-02-17 Thread andrea crotti
2011/2/17 Chris Rebert > > Actually, so long as you specify a bit more specific versions, e.g.: > > python2.7 empathy.py > python3.1 empathy3.py > > it should be fine on most *nixes. Windows would of course require a > separate, but analogous, batch file or similar. As for porting the > tests the

Re: interfacing python with emacs

2011-02-17 Thread andrea crotti
Not ready yet but the structure of the python and elisp files is more or less there: git://github.com/AndreaCrotti/empathy.git Feel welcome for any comments/hints. About the communication between the processes I think I'll use stdin/out too, since it comes quite natural using emacs sub-processes.

Re: First time using an API...

2011-02-17 Thread andrea crotti
2011/2/17 Matty Sarro > This may be kind of a stupid question, so please be gentle. > I've only ever used most programming in the past when shell scripting > couldn't handle what I needed done. So, I rarely dabble with things > like API's, or even python-isms. I just program to get things done. >

where to import

2011-02-17 Thread andrea crotti
Suppose I have a function which uses a few external libraries, and this function is only called once every 10 executions. Does it make sense to import these libraries for the whole module? import sys def fun(): import x, y, z Something like this is acceptable/good practice in the scenario I

Re: where to import

2011-02-17 Thread andrea crotti
2011/2/17 Chris Rebert > Yes, of course. Importing a module multiple times (as would happen if > fun() is called multiple times) is obviously slower than just > importing it once, although the 2nd and subsequent imports will be > faster as Python will just return another reference to the previous

Re: interfacing python with emacs

2011-02-17 Thread Andrea Crotti
Il giorno 17/feb/2011, alle ore 16.14, andrea crotti ha scritto: > Not ready yet but the structure of the python and elisp files is more or less > there: > git://github.com/AndreaCrotti/empathy.git > > Feel welcome for any comments/hints. > > About the communication be

Re: Python leaks in cyclic garbage collection

2011-02-19 Thread Andrea Crotti
Il giorno 19/feb/2011, alle ore 05.10, moerchendiser2k3 ha scritto: > Hi, I have some problems with Python and the garbage collection. In > the following piece of code I create a simple gargabe collection but I > am still wondering why the finalizers are never called - at least on > exit of Py th

Re: newbie question about PYTHONPATH

2011-02-19 Thread Andrea Crotti
Il giorno 19/feb/2011, alle ore 18.25, Doug Epling ha scritto: > The best way I have found is to place that definition of your PYTHONPATH in > your .bash_profile in your home directory and export it from there. > > PYTHONPATH=/home/foo/prog/learning_python > > export PYTHONPATH >

Re: Making Line Graphs

2011-02-22 Thread Andrea Crotti
On Feb 22, 4:28 pm, Paul Anton Letnes wrote: > +1, I like matplotlib a lot. Consider python(x,y) as an easy install > path. It both shows plots interactively and let you save to file. I even > use it for publications. > > Paul. +1 for matplotlib, incredibly powerful and (if you know a bit about

Re: how can I solve this erorr usr/lib/python2.6 : permisson denied

2010-08-01 Thread Andrea Crotti
Mohseniaref writes: > Dear Friend > I have this erorr after running pyhon script with header > /usr/lib/python2.6 : permisson denied > I change ownership with -hR in super user terminal Why /usr/lib... and not in bin? I guess this is the directory, of course if you put it in the header (shabang)

eggbasket

2011-10-04 Thread andrea . crotti . 0
I'm struggling trying to get a working local pypi server. Now eggbasket apparently also supports upload, which should be nice. So I: - created a virtualenv - installed all the necessary and trying to initializing the server I get: --8<---cut here---start->8--

<    1   2   3   4   >