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: 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: 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: 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: 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
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

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: 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

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-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-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-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

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

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

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

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-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 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

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

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

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..

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: 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

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: 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-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-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-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): "

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: 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

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

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

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

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: 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

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

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--

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: 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: 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

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
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

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: 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

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-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

Re: Emacs Python indention

2011-06-12 Thread Andrea Crotti
Bastian Ballmann writes: > Hi Emacs / Python coders, > > moving a region of python code for more than one indention in Emacs is > quite annoying, cause the python-shift-left and -right functions always > loose the mark and one has to reactivate it with \C-x \C-x or > guess how many indentions one

Re: Slice implementation bug

2011-05-12 Thread Andrea Crotti
Tambet writes: > Hello! > > Let's say slice is multidimensional now - how to interpret it? > But who said that slice is multidimensional in the first place? Since python is not matlab I don't think it will ever be done, so what's the purpose of talking about a bug in something that doesn't exis

Re: Need Assistance on this program.

2011-05-12 Thread Andrea Crotti
vijay swaminathan writes: > Hi All, > > I'm new bie to python thread programming and would like to assistance > on the attached code. > > In this, I'm calling a thread to invoke a command prompt and would > like to print the "Thread as alive" as long as the command prompt is > opened and would li

Re: Python IDE/text-editor

2011-04-18 Thread Andrea Crotti
Alec Taylor writes: > > Emacs and vim still seem like good alternatives, when I get the time. > However, currently have 3 assignments to start and finish so would > like a simple Notepad2 with python interpreter attached (and keyboard > shortcut to run script) type program. > > Please continue rec

Re: Python IDE/text-editor

2011-04-17 Thread Andrea Crotti
Ben Finney writes: > As many others in this thread have said, the learning curve pays off in > access to a powerful general-purpose tool that you can apply to an > enormous range of programming tasks. > > A reason Vim and Emacs survive while so many thousands of other options > rise and fall and

Re: ipython: Multiple commands on the same line and newlines

2011-04-17 Thread Andrea Crotti
Phil Winder writes: > Yes, that does not produce an error, but it does not "work". Please > refer to my first post. Try the first code, you will get a syntax > error. Placing things on one line makes for easy history scrollback. > In your version you will have 2 lines of history for the x = 0 ter

Re: Python IDE/text-editor

2011-04-16 Thread Andrea Crotti
rusi writes: > > It takes a day or two to learn emacs. > > It takes forever to set it up. > > [How many shots of cocaine are are needed to de-addict a cocaine > addict? ] Not to set it up, but surely to master it. There are also many people that didn't really learn elisp but still use emacs taki

Re: Python IDE/text-editor

2011-04-16 Thread Andrea Crotti
Chris Angelico writes: > Sure, that was a *slight* exaggeration :) but thanks for the advice. > I'll poke around with it some time. > > ChrisA I also suggest to take a look here, there's a quite nice environment setup for python. https://github.com/gabrielelanaro/emacs-for-python The nice thing

Re: Python IDE/text-editor

2011-04-16 Thread Andrea Crotti
Chris Angelico writes: > Based on the comments here, it seems that emacs would have to be the > editor-in-chief for programmers. I currently use SciTE at work; is it > reasonable to, effectively, bill my employer for the time it'll take > me to learn emacs? I'm using a lot of the same features th

Re: [Q] ipython: Multiple commands on the same line and newlines

2011-04-16 Thread Andrea Crotti
Phil Winder writes: > Hi, > I'm having a go at using ipython as a command prompt for data > analysis. Coming from Matlab, I'm used to typing multiple commands on > the same line then using the up arrow to go through my history. > How can I write multiple python commands on the same line? > E.g. "

Re: Can Python control Thuderbird?

2011-04-16 Thread Andrea Crotti
marceepoo writes: > I want to control Mozilla Thunderbird using Python. > Does anyone know if that is that possible? > I would like to use Python to save email attachments to a specific > directory, depending on the name of the sender, content in the email, > etc.--- and to rename the attachment

Re: Python IDE/text-editor

2011-04-16 Thread Andrea Crotti
Alec Taylor writes: > Good Afternoon, > > I'm looking for an IDE which offers syntax-highlighting, > code-completion, tabs, an embedded interpreter and which is portable > (for running from USB on Windows). > > Here's a mockup of the app I'm looking for: http://i52.tinypic.com/2uojswz.png > > Whi

Re: automated pep8 reformatter ?

2011-04-14 Thread Andrea Crotti
James Mills writes: > Does anyone know of a tool that will help with > reformatting badly written code to be pep8 compliant ? > > a 2to3 for pep8 ? > What I daily and with great happiness use is flymake-mode in emacs. Combined with pylint, pep8 and pychecker I can see while I'm programming all t

Re: split string but ignore sep inside double quotes

2011-04-13 Thread Andrea Crotti
Andrea Crotti writes: > > I'm not sure how but also this seems to work: > In[20]: s = '2,"some, text",more text' > > In [21]: re.split(r'(?<=">),', s) > Out[21]: ['2,"some, text",more text'] > > I just want

Re: split string but ignore sep inside double quotes

2011-04-13 Thread Andrea Crotti
Jonno writes: > All, > > I have the following unicode object: > u'3,"Some, text",more text' > > and I want to split it into a list like this: > [3,"Some, text", more text] > > In other words I want to split on the comma but not if it's inside a > double-quote. > > Thanks. I'm not sure how but al

Re: file deleted

2011-04-13 Thread Andrea Crotti
luca72 writes: > hello i'm working with eric, running a program eric crash and when i > try to open my project again with eric i see that myproject.py is > deleted, but my project is still running there is a way to find > myprogram.py file aving it in execution? It's more about your operating sy

Re: OOP only in modules

2011-04-12 Thread Andrea Crotti
newpyth writes: > Hi Andrea, > excuse my beeing criptic (you wrote: "I have some troubles > understanding what you mean") but I coudn't to go on too long. > Now I can conclude my speech... > When I was younger I transformed a big Clipper program in > simil-C in order to apply cflow... and I succe

Re: OOP only in modules

2011-04-10 Thread Andrea Crotti
newpyth writes: [...] > My main goal is to arrange OO in a paradigmatic manner in order to > apply to it the > procedural scheme. especially to the caller or called modules. > Bye. I have some troubles understanding what you mean. Can you write an example of code that it's for you annoying and

Re: design question

2011-04-10 Thread Andrea Crotti
Andrea Crotti writes: [...] I left the Timeline as before, but tried to rewrite some more classes. This is the abstract class for a metric, and below another class for the metric which involve only counting things. In the end an example on how to use this. I need to see synthetic values during

Re: OOP only in modules

2011-04-10 Thread Andrea Crotti
newpyth writes: > Hi all, > from the subject of my post, you can see I do not > like very much OOP... and I am not the only one... > Knowing that python is intrinsecally OO, I propose > to move all OOP stuff (classes, instances and so on) > to modules. > In this way the OOP fan can keep on using

design question

2011-04-10 Thread Andrea Crotti
I've been wondering for weeks now how to do but I still didn't get a satisfying answer, so I hope someone can give a hint... I have some logs which I extract from simulation results. These logs are in the form timestamp, nodeid, eventname, event_argument and now I have to analyze the data. I don

Re: Why aren't copy and deepcopy in __builtins__?

2011-03-28 Thread Andrea Crotti
John Ladasky writes: > Simple question. I use these functions much more frequently than many > others which are included in __builtins__. I don't know if my > programming needs are atypical, but my experience has led me to wonder > why I have to import these functions. I almost never use them

Re: why memoizing is faster

2011-03-26 Thread Andrea Crotti
Stefan Behnel writes: > > Not "restarted" in the sense that it gets cleaned up, though. The > above simply passes an explicit value for it that will be used for the > single call. Future calls won't be affected. > > Stefan About this global caching thing I thought, but isn't this a source of poss

jump to C definition

2011-03-25 Thread Andrea Crotti
While I use emacs, if it knows where the source code is, I can very easily jump to a function definition even if it's in C. I think it would be nice to have something like this also for python, at least to make it easy to explore the code and learn something new, without digging too much into the

Re: why memoizing is faster

2011-03-25 Thread Andrea Crotti
"eryksun ()" writes: > See Pep 232: http://www.python.org/dev/peps/pep-0232 > > Also, see the discussion thread on Python-Dev: > > http://mail.python.org/pipermail/python-dev/2000-April/thread.html#3282 > > I don't think self-referenced static variables (as in C's "static" > declaration) are discu

Re: why memoizing is faster

2011-03-25 Thread Andrea Crotti
"eryksun ()" writes: > > Regarding this I have question about function attributes. Is there an > equivalent of 'self' for functions? I've seen people use function > attributes as local static variables, but this seems problematic when > all you have is a global reference to the function. The orig

Re: why memoizing is faster

2011-03-25 Thread Andrea Crotti
Terry Reedy writes: > > For the reason Stefan explained and hinted above. Try the following instead: > > def fib_iter(n, _cache = [1,1]): > k = len(_cache) > if n >= k: > for i in range(k, n+1): >_cache.append(_cache[i-2] + _cache[i-1]) > return _cache[n] > > This should be sligh

why memoizing is faster

2011-03-24 Thread Andrea Crotti
I was showing a nice memoize decorator to a friend using the classic fibonacci problem. --8<---cut here---start->8--- def memoize(f, cache={}): def g(*args, **kwargs): # first must create a key to store the arguments called # it's for

Re: I am not able to open IDLE in python on Vista.

2011-03-01 Thread Andrea Crotti
Jayneil Dalal writes: > This is the error message I get when I try to run Pyhon on Vista: > > unable to create user config directory > C:\Users\Jayneil\.idlerc > Check path and permissions. > Exiting! > > So please help me out!. > > Thank you. Best solution would be to avoid Windows Vista. If th

Re: parsing a file for analysis

2011-02-26 Thread Andrea Crotti
Il giorno 26/feb/2011, alle ore 06.45, Rita ha scritto: > I have a large text (4GB) which I am parsing. > > I am reading the file to collect stats on certain items. > > My approach has been simple, > > for row in open(file): > if "INFO" in row: > line=row.split() > user=line[0] >

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: 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: 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: 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: 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

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: 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. >

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: 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

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.

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

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 [''

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

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: 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

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: 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

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-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
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: 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)

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 >

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: Archives and magic bytes

2005-03-26 Thread andrea crotti
> Perhaps this is mostly a reflection on me as a programmer :-} but I > found the job surprisingly tricky. No I think you're right... It's not very important for me retrieve exactly what kind of file it is, it could be just something more in my little program (an organizer that put files in the rig

<    1   2   3   4   >