Re: Favorite non-python language trick?

2005-06-24 Thread Enrico
"Joseph Garvin" <[EMAIL PROTECTED]> ha scritto nel messaggio
news:[EMAIL PROTECTED]
> --This code won't run because it's in a comment block
> --[[
> print(10)
> --]]
>
> --This code will, because the first two dashes make the rest a comment,
> breaking the block
> ---[[
> print(10)
> --]]
>
> So you can change whether or not code is commented out just by adding a
> dash. This is much nicer than in C or Python having to get rid of """ or
> /* and */. Of course, the IDE can compensate. But it's still neat :)

python:

"""
print 10
"""

and

#"""
print 10
#"""

C++:

/*
print(10);
*/

and

///*
print(10);
//*/

?

Bye,
Enrico


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


Numpy ndarray to C array

2011-12-08 Thread Enrico
I am trying to pass a multi-dimensional ndarray to C as a multi-
dimensional C array for the purposes of passing it to mathematica.
They already have a wrapper for a 1-D Python list. where the list is
copied to "list". Shown below:

static PyObject * mathlink_PutIntegerList(mathlink_Link *self,
PyObject *args)
{
PyObject*   seq;
PyObject*   obj;
longi, len, result;
int*list;

len = PyObject_Length(seq);

list = PyMem_New(int, len);
for(i = 0; i < len; i++)
{
obj = PySequence_GetItem(seq, i);
list[i] = PyInt_AsLong(obj);
}

CheckForThreadsAndRunLink(self,result = MLPutIntegerList(self->lp,
list, len));

PyMem_Free(list);
CHECKNOTEQUAL(result,MLSUCCESS,self);

Py_INCREF(Py_None);
return Py_None;
}

I would like to create a similar wrapper which accepts an ndarray and
provides the array laid out in memory like a C array declared
explicitly as "int a[m][n]...".  I also need to pass the length of the
array at each level i as dim[i].  Since this is pretty much the only
function I plan to wrap, I'd like to avoid using boost, swig, etc.

Any help would be appreciated.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help with ConfigParser

2006-10-02 Thread Enrico
Hi,
from the documentation:

optionxform(option)

Transforms the option name option as found in an input file or as passed in
by client code to the form that should be used in the internal structures.
The default implementation returns a lower-case version of option;
subclasses may override this or client code can set an attribute of this
name on instances to affect this behavior. Setting this to str(), for
example, would make option names case sensitive.

Bye,
Enrico


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


Re: Calling private base methods

2007-04-12 Thread Enrico
"Jorgen Bodde" <[EMAIL PROTECTED]> ha scritto nel messaggio
news:[EMAIL PROTECTED]
> Hi All,
>
> Now that I am really diving into Python, I encounter a lot of things
> that us newbies find difficult to get right. I thought I understood
> how super() worked, but with 'private' members it does not seem to
> work. For example;
>
> >>> class A(object):
> ... def __baseMethod(self):
> ... print 'Test'
>
> Deriving from A, and doing;
>
> >>> class D(A):
> ... def someMethod(self):
> ... super(A, self).__baseMethod()
> ... print 'test3'
>
> Will not work;

if you type
>> dir(A)

you'll get a method named
_A__baseMethod

>From the documentation:
Private name mangling: When an identifier that textually occurs in a class
definition begins with two or more underscore characters and does not end in
two or more underscores, it is considered a private name of that class.
Private names are transformed to a longer form before code is generated for
them. The transformation inserts the class name in front of the name, with
leading underscores removed, and a single underscore inserted in front of
the class name. For example, the identifier __spam occurring in a class
named Ham will be transformed to _Ham__spam. This transformation is
independent of the syntactical context in which the identifier is used. If
the transformed name is extremely long (longer than 255 characters),
implementation defined truncation may happen. If the class name consists
only of underscores, no transformation is done.

Enrico


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


Re: error with wxPython2.8-win32-unicode-2.8.7.1-py25.exe

2007-12-19 Thread Enrico
"Emmanuel" <[EMAIL PROTECTED]> ha scritto nel messaggio
news:[EMAIL PROTECTED]
> I recently upgraded wxpython (and python) on XP using wxPython2.8-
> win32-unicode-2.8.7.1-py25.exe
>
> Now when I run
>
> from wxPython.wx import *
>
> It crashes :

On my win2k with 2.8.4.0 I got:

>>> from wxPython.wx import *

Warning (from warnings module):
  File "__main__", line 1
DeprecationWarning: The wxPython compatibility package is no longer
automatically generated or actively maintained.  Please switch to the wx
package as soon as possible.

I suggest you to try
>>> from wx import *
or better
>>> import wx
(I don't think that importing everything is a good choice)

Enrico


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


Re: Python, XML and XPath

2008-12-17 Thread Enrico
"Hole"  ha scritto nel messaggio
news:daf5cd00-36dc-4ab4-976e-a6d859b52...@w24g2000prd.googlegroups.com...
> Hi all,
>
> I hope this is not an "overasked" question but I find myself quite
> confused about python xml management (I have to use python for a
> project and I come from java world, you know...where frameworks,
> libraries and tools to use are standard de iure or standard de facto).
>
> I need to use XML parsing with xpath: a simple xml reader.

You can try lxml, have a look here
http://codespeak.net/lxml/xpathxslt.html

>
> I've found that the standard distribution of python doesn't include
> xpath support modules so I've decided to add libxml2.
>
> I've installed cygwin c compiler but I still have errors like the
> following:
>
> C:\Python25\Lib\libxml2-python-2.6.9>python setup.py build install

I never used  libxml2 but version 2.6.9 seems quite old, according to this
page:
http://users.skynet.be/sbi/libxml-python/

Bye, Enrico



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


multiple inheritance and __getattr__

2008-07-28 Thread Enrico
Hi there,
I have the following situation (I tryed to minimize the code to concentrate
on the issue):

>>> class A(object):
 def __getattr__(self, name):
  print 'A.__getattr__'
  if name == 'a': return 1
  raise AttributeError('%s not found in A' % name)

>>> class B(object):
 def __getattr__(self, name):
  print 'B.__getattr__'
  if name == 'b': return 1
  raise AttributeError('%s not found in B' % name)

Both classes have a __getattr__ method.
Now I want to have a class that inherits from both so I write:

>>> class C(B,A):
 pass

The problem arise when I try something like this:
>>> c=C()
>>> c.a
A.__getattr__
1
>>> c.b
A.__getattr__

Traceback (most recent call last):
  File "", line 1, in 
c.b
  File "", line 5, in __getattr__
raise AttributeError('%s not found in A' % name)
AttributeError: b not found in A

I was expecting, after a fail in A.__getattr__,  a call to the __getattr__
method of B but it seems that after A.__getattr__ fails the exception stops
the flow. So, if I did understand well, B.__getattr__ will be never called
"automatically". I don't know if this has a reason, if it is a design choice
or what else, any explanation is welcome.

Since A and B are not written by me I can only work on C. The solution that
comes to my mind is to define a __getattr__ also in C and write something
like:

>>> class C(A,B):
 def __getattr__(self, name):
  try:
   return A.__getattr__(self, name)
  except AttributeError:
   return B.__getattr__(self, name)

>>> c=C()
>>> c.a
A.__getattr__
1
>>> c.b
A.__getattr__
B.__getattr__
1

A better solution is welcome.
Many thanks, Enrico


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


Re: multiple inheritance and __getattr__

2008-07-29 Thread Enrico
"Bruno Desthuilliers" <[EMAIL PROTECTED]> ha scritto
nel messaggio news:[EMAIL PROTECTED]
> Indeed. You explicitely raise, so the lookup stops here. You'd need to
> explicitely call on superclass instead to have B.__getattr__ called, ie:
>
> class A(object):
>  def __getattr__(self, name):
>  if name == 'a':
>  return 1
>  return super(A, self).__getattr__(name)
>
> class B(object):
>  def __getattr__(self, name):
>  if name == 'b':
>  return 2
>  return super(B, self).__getattr__(name)

Hi Bruno,
this is an interisting point. Just to understand better: when I raise an
AttributeError the search stops but if I call a superclass (that for my
understanding raises an AttributeError) the search continues. At this point
I suspect that the search is doing something else, like checking if the
class is at the top of the hierarchy. Do you know where I can look for this,
probably in the core code of Python?

> > Since A and B are not written by me I can only work on C.
>
> Really ? You know, Python is a *very* dynamic language. If A and B are
> ordinary Python classes (ie: not builtin types, not C extensions, etc),
> you can monkeypatch them. But that's not necessarily the best thing to
> do (it would require more work than your actual solution).

I know that I can do whatIwant with class A and class B (monkeypatch!) but I
prefer to concentrate on my code and write a clean solution. Thanks for your
help.
Enrico


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


Re: Using an DTD not specified in XML file for validation

2008-08-07 Thread Enrico
"Brian Quinlan" <[EMAIL PROTECTED]> ha scritto nel messaggio
news:[EMAIL PROTECTED]
> Hey,
>
> I'm trying to figure out how I can validate an XML file using a DTD that
> isn't specified in the XML file.

I did it once using lxml. You can read from:
http://codespeak.net/lxml/validation.html

With this package is quite simple (code not tested):

from lxml import etree
dtd = etree.DTD('mydtd.dtd')
f = file('mydoc.xml')
xml = etree.XML(f.read())
dtd.validate(xml)

Enrico


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


Re: A beginner question about GUI use and development

2009-11-13 Thread Enrico
"uap12"  ha scritto nel messaggio
news:1a446fef-4250-4152-8c30-cfe2edb61...@j4g2000yqe.googlegroups.com...
> Hi!
> I have written som Python programs but no one with a GUI yet,
> i have look around and found a lot of diffrent gui module.
>
> I will develop program that will use a small amout of GUI part
> eg. program to show status about server etc.
>
> I have looked att wxWidget, but i like a rekommendation here
> (Will develop Windows program but somtimes OSX to)

You have a lot of option. I use wx since I need an OS native interface and
work on Windows, Linux and Mac. But your needs could be different.so maybe
QT could be a good choice for you, or Tk. I suggest to give them a try and
decide. You can find many examples and without writing to much code you can
have an idea on the library. For example for the wx you have a complete
suite of example that you can run and modify.

> When i givet the program away i like to pack it, so the enduser
> just run it, i don't like to tell the user to install Python, and/or
> som GUI package. is this possible.

This is not related to the GUI. If you don't want your user to have Python
and other packages installed you need to "build" the application. Look at
py2exe and friends (freeze, py2app,...). You can prepare an application with
everything needed to run it and install/copy it on the user machine.

Regards, Enrico


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


Re: msvcr90.dll is MIA?

2010-04-14 Thread Enrico

Il 14/04/2010 14:25, Alex Hall ha scritto:

I notice that I do not have the dll when py2exe says it cannot locate
the dll. If I need vs2008, then what good is vcredist_xxx.exe? It does
not seem to give me the dll, but the py2exe tutorial says that it
will. What am I missing?


Alex, the DLLs are in winsxs, try searching there.
For py2exe, it doesn't find the DLLs so you should provide them. In my 
setup.py (I use also the wxPython lib so something could be different) I 
added:


def isSystemDLL(pathname):
if os.path.basename(pathname).lower() in ('msvcp90.dll'):
return 0
return origIsSystemDLL(pathname)
origIsSystemDLL = py2exe.build_exe.isSystemDLL
py2exe.build_exe.isSystemDLL = isSystemDLL

Then I added to 'dll_excludes' the same 'msvcp90.dll'.

In this way py2exe is ok without this DLL and can build the excutable. 
Note that the dll that py2exe is looking for is msvcp90 in my case.


Then I added a subdirectory with the DLLs (msvcr90, msvcp90, msvcm90) to 
the distribution directory. You need a manifest too :-)


Ok, it seems complex but you can check the followings
http://www.py2exe.org/index.cgi/Tutorial
http://wiki.wxpython.org/py2exe (related to wxPython but look at the 
manifest)


An other solution is to run the vcredist on the target machine and the 
application will run. This is the suggested solution if you cannot 
distibute the DLLs.


Bye, Enrico
--
http://mail.python.org/mailman/listinfo/python-list


Re: Unbound Method Error

2009-06-09 Thread Enrico
"lczancanella"  ha scritto nel messaggio
news:32bf5ccb-5bfd-49a5-b423-9d41180a0...@l28g2000vba.googlegroups.com...
> Hi, i am brand new in Python, so sorry if this question is too basic,
> but i have tried a lot and dont have success... I have the following
> code...
>
> class Funcoes:
> def CifradorDeCesar(mensagem, chave, funcao):

A quick look to your code suggests to me to rewrite the above lines as:

class Funcoes:
@classmethod
def CifradorDeCesar(self, mensagem, chave, funcao):

@classmethod is needed since you call:
> atribdescripto = Funcoes.CifradorDeCesar (atribcripto,
3, 2)

Best regards,
Enrico


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


Re: Unbound Method Error

2009-06-09 Thread Enrico
"Piet van Oostrum"  ha scritto nel messaggio
news:m2ljo1ajnx@cs.uu.nl...
> The method doesn't need the class at all, so a staticmethod would be
> preferable:
> class Funcoes:
> @staticmethod
> def CifradorDeCesar(self, mensagem, chave, funcao):

Yes, in this case self is not needed.

>
> But as been mentioned in this thread before, there might be no reason to
> use the class anyway.

I agree but the code is not very clear about the use of this class as
ancestor of MC.
>>class MC(Funcoes, type):
?

Enrico




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


Re: Accessing windows structures through ctypes.

2009-07-02 Thread Enrico
"Rajat"  ha scritto nel messaggio
news:8c8b5cf2-bc77-4633-96ca-e3b908430...@z14g2000yqa.googlegroups.com...
>
> > > Using ctypes can I access the windows structures like:
> >
> > > PROCESS_INFORMATION_BLOCK, Process Environment Block(PEB),
> > > PEB_LDR_DATA, etc?
> >
> > ctypes.wintypes lists all of the Windows structures included with the
> > module.
> >
> > You should be able to use ctypes.Structure class to roll your own:
>
> Thanks Alex. As you suggested, I'm trying to implemenet the below
> structure, windows PEB, in Python:
>
> typedef struct _PEB {
> BYTE Reserved1[2];
> BYTE BeingDebugged;
> BYTE Reserved2[21];
> PPEB_LDR_DATA LoaderData;
> PRTL_USER_PROCESS_PARAMETERS ProcessParameters;
> BYTE Reserved3[520];
> PPS_POST_PROCESS_INIT_ROUTINE PostProcessInitRoutine;
> BYTE Reserved4[136];
> ULONG SessionId;
> } PEB;
>
> My equivalent Python structure is:
> class PEB(Structure):
> _fields_ = [("Reserved1", wintypes.BYTE * 2),
> ("BeingDebugged", wintypes.BYTE),
> ("Reserved2", wintypes.BYTE * 2),
> ("Reserved3", c_void_p),
> ("Ldr", pointer(PEB_LDR_DATA)),
> ("ProcessParameters", pointer
> (RTL_USER_PROCESS_PARAMETERS)),
> ("Reserved4", wintypes.BYTE * 104),
> ("Reserved5", c_void_p),
> (),
> ("Reserved6", wintypes.BYTE),
> ("Reserved7", c_void_p),
> ("SessionId", c_ulong)]
>
> I'm not sure what needs to go in the above empty tuple for
> "PPS_POST_PROCESS_INIT_ROUTINE PostProcessInitRoutine" (in Original
> PEB).
>
> Please suggest.

PostProcessInitRoutine should be a callback function or something similar.
It should be enough to define a type

PostProcessInitRoutine = WINFUNCTYPE(...parameters...)

and use this.

Regards,
Enrico


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


Re: Python recursive tree, linked list thingy

2012-03-08 Thread Enrico Franchi
Wanderer  wrote:

>  How
> do you handle this sort of thing in Python?

I believe that the best thing to do is a Union-Find algorithm.

Depending on the exact nature of your problem, you may also want to
check out the Hoshen-Kopelman Algorithm. Although the algorithm itself
is rather efficient, it was born in the context of percolation, that is
to say with the assumption that the "broken" (or colored) cells are much
more likely than in your context.

-- 
-riko
http://www.enrico-franchi.org/
http://rik0-techtemple.blogspot.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [newbie]Is there a module for print object in a readable format?

2005-10-17 Thread enrico . sirola_NOSPAM
>>>>> "James" == James Gan <[EMAIL PROTECTED]> writes:

James> I want the object printed in a readable format. For

[...]

James> I tried pickled, marshel. They do different work. Is there
James> another module which do this kind of job?

from pprint import pprint
pprint(object)

bye,
e.

-- 
Enrico Sirola <[EMAIL PROTECTED]>

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


Re: very large dictionary

2008-08-05 Thread Enrico Franchi
Simon Strobl <[EMAIL PROTECTED]> wrote:

> Well, as I was using Python, I did not expect to have to care about
> the language's internal affairs that much. I thought I could simply do
> always the same no matter how large my files get. In other words, I
> thought Python was really scalable.

It's not Python here. It's just how computers work. IMHO having a
gargantuan dictionary in memory is not a good idea (unless explicitly
proven otherwise): this is the kind of job databases have been created
for. 

Besides, this is not a matter of Python. If you were using C or another
language, I would have sugested to use databases in order to manipulate
GB's of data. Luckily enought, using databases in Python is far easier
than doing so in C/C++/Java. *And* there are thin abstractions over
databases so you don't even need to know how to use them (though, I
suggest that you *do* learn something about DB's and expecially
relational DB's, SQL is not *that* bad). 


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


Re: Hobbyist - Python vs. other languages

2008-08-05 Thread Enrico Franchi
<[EMAIL PROTECTED]> wrote:

> A programming language is a tool to solve problems, so first of all:
> do you have problems to solve? You can create some visualizations,
> some program with GUI, some networked code to download things and
> process them, etc.

It's surprising how hard is this part. I quite like learning new
languages, and of course this has the same kind of problem: finding
problems to solve.

Moreover, if I *need* a program, I usually need it quickly, and so it is
wise to use a well known language (e.g., Python). That means that in
order to learn the practice of new languages I have to find problems
that are interesting enough to be solved (othewise I may not finish
them) *but* not too interesting.

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


Re: python backup script

2013-05-06 Thread Enrico 'Henryx' Bianchi
MMZ wrote:

> config.read("~/my.cnf")
> username = config.get('client', 'mmz')
> password = config.get('client', 'pass1')
> hostname = config.get('client', 'localhost')

### A simple config file ###
[client]
user = mmz
password = pass1
host = localhost
### EOF ###

#!/usr/bin/env python
import ConfigParser

config = ConfigParser.ConfigParser()
config.read("~/configfile.cfg")
username = config.get('client', 'user')
password = config.get('client', 'password')
hostname = config.get('client', 'host')
[...]

> # Get a list of databases with :
> Database_list_command="mysql -u %s -p%s -h %s --silent -N -e 'show 
databases'" % (username, password, hostname)
> for database in os.popen(database_list_command).readlines():
> database = database.strip()
> if database == 'information_schema':
> continue
> if database == 'db_dev':
> continue
> filename = "/backups/mysql/%s-%s.sql" % (database, filestamp)
> os.popen("mysqldump -u %s -p%s -h %s -e --opt -c %s | gzip -c > %s.gz" 
% (username, password, hostname, database, filename))

command = subprocess.Popen(['mysql', '-u ' + username,
'-p' + password, '-h ' + hostname,
'--silent', '-N', "-e 'show databases'"],
shell=False,
stdout=subprocess.PIPE)
status = command.wait()
for line in command.stdout.readlines():
if line.strip() not in ['information_schema', 'db_dev']:
filename = "/backups/mysql/%s-%s.sql" % (database, filestamp)
cmd1  = subprocess.Popen(['mysqldump', '-u ' + username,
'-p' + password, '-h ' + hostname,
'-e', '--opt', '-c ' + database],
shell=False,
stdout=subprocess.PIPE)
cmd2 =  subprocess.Popen(['gzip' '-c'],
shell=False,
stdout=filename)


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


Re: python backup script

2013-05-06 Thread Enrico 'Henryx' Bianchi
Enrico 'Henryx' Bianchi wrote:

> cmd2 =  subprocess.Popen(['gzip' '-c'],
> shell=False,
> stdout=filename)

Doh, my fault:

cmd2 = subprocess.Popen(['gzip' '-c'],
shell=False,
stdout=filename
stdin=cmd1.stdout)

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


Re: python backup script

2013-05-07 Thread Enrico 'Henryx' Bianchi
John Gordon wrote:


> Looks like you need a comma after 'stdout=filename'.

Sigh, yesterday was a terrible day (yes, it lacks a comma)...
Anyway, when it is possible, is recommended to use the drivers for 
communicate with databases, because subprocess (or os.*open*) is more 
expensive compared to (python needs to spawn an external process to execute 
the command)

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


Re: Python 2 or 3

2011-12-09 Thread Enrico 'Henryx' Bianchi
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Tobiah wrote:

> Use the newer version and don't look back.

Interesting reply, but if I have a platform wich doesn't support Python 3 
(e.g. RHEL 5.x)? ]:)

Enrico
P.S. note that: I *don't* want to recompile Python in production environment
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (GNU/Linux)

iQEcBAEBAgAGBQJO4pbOAAoJED3SMOGZLYdYQ7sIAI3vfvOyQc5Gx205cDMS7bPK
uXxZI7ShqybyEv0NMDapxURQhz59Kc9zh8E/OKDiXohjmkE1YA78K7qSKyrtXTMy
ppcGUU5USaQhPZ+RqOEj95aTxQj3CW/8w74rNEirIMn6+yGt4QjWRuGT1K6aUM51
BXF9I22f37z/sJ7x+fZUL9R7G1HA4saRGEiQGxBgkmt6gi28nboOibdxfw9bmP5x
aHbpVYQ6yo+7nOf0XZno/pl0zkpDvhS/tNvvuH8kYQIvMLyQZ/f+xZJ6yj58S5Se
AGSGXEDRemw0Ge83HjJvmQE3JXjy1fc1gCQSnmqQifXW7h18q99L3okJds+uHnE=
=PwK5
-END PGP SIGNATURE-

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


Re: Python 2 or 3

2011-12-10 Thread Enrico 'Henryx' Bianchi
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Steven D'Aprano wrote:

> RHEL supports Python 3, it just doesn't provide Python 3.

True, but as you say later, the only method is to recompile. So, if I want 
to use Python 3 in a production environment like RHEL, I need:

 - A development environment similar to production (e.g. if I use RHEL 5 in
   production, I need at least a CentOS 5.x);
 - Compile Python 3 in a development environment;
 - Write the python app;
 - Release a *huge* package to install.

The only bright side is to freeze version of Python and the libraries, but 
every update (e.g. bug fixing on a library) is by hand

> When installing, don't use "make install", as that will replace the
> system Python, instead use "make altinstall".

Good, I didn't know this option

> Then the command "python"
> will still refer to the system Python (probably Python 2.4 or 2.5?), and
> "python3" should refer to Python 3.x.

RHEL (and CentOS) 5.x use Python 2.4

> You shouldn't be learning programming on a production server :)

Of course, but if I want to use an application written in Python 3 on a 
production environment which doesn't support it, I have to prepare at least 
a development environment similar to production (ok, ok, with a VM is 
simple, but I need to track the exception)

Enrico
P.S. an alternative may be cx_freeze, but I don't know exactly hot it works
P.P.S. I'm boring, but I would like my point of view because I've found 
precisely in this case
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (GNU/Linux)

iQEcBAEBAgAGBQJO40dHAAoJED3SMOGZLYdYIPoH/1J6OljjCJQnmR/uwjEFCrHy
TEMpfKodD40gL7lOZLMHnpJrs+Ct2Vo/1+mtAIi+vZ6rkhFG50ykBJMAlMgXkCjt
I6fkp9YLKmFX9OjRuJ9qE+2P5PliyNDPKVljyfaXMhalbrtHnn7mrL9524TzhcoG
+Ape1U9MPTu3naVULKWK0FjGa/RwhbSOdDOKX2IBmRHFEgtf3dZJ2xNYXUJnhnT8
fbfD87ykXyyVg6LS8c14PPeWnpFeeZBQappjoHg9+XZd8/Y1uH1NuP7k4cepzJB2
Car4lucChW9+llM4mz1BADQZuo4J1v71K5DR8mVXyM2usUlNWelkgR6GVWUmXE0=
=trwj
-END PGP SIGNATURE-

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


Re: why brackets & commas in func calls can't be ommited? (maybe it couldbe PEP?)

2007-03-22 Thread Enrico 'Mc Osten' Franchi
<[EMAIL PROTECTED]> wrote:

> But I think in some situations Ruby allows to omit them, solving some
> of the "impossibile" problems shown in this thread. This makes Ruby a
> bit better than Python to create application-specific mini languages,
> that are quite useful in some situations.

Yes. However, Ruby parser has to resort to heuristic in many cases:



"When Ruby sees a name such as ``a'' in an expression, it needs to
determine if it is a local variable reference or a call to a method with
no parameters. To decide which is the case, Ruby uses a heuristic."

In fact it is something I don't really like about Ruby (even though I
find it useful in some cases).

This is a 'pathological example'

def a
  print "Function 'a' called\n"
  99
end


for i in 1..2
  if i == 2
print "a=", a, "\n"
  else
a = 1
print "a=", a, "\n"
  end
end


But I have to say that omitting brackets in a language such as Python or
Ruby can make the code very hardly readable. The interpreter isn't the
only one who has to resort to heuristic: everytime you read a name with
no parenthesis you may have to go back and see whether it is a bound
variable, a method (so you may have to check documentation for various
modules) or an 'invalid' variable you forgot to initialize.

In fact, when I'm reading code from a project I'm not familiar with, it
can be quite hard in the first place. 

In fact most Rubyists advice to use parentheses (unless you want to
achieve a DSL like effect, or in very simple cases like

puts s

)

The third problem I found out is related to blocks ({} and do have
different precedence order). They are only syntax errors, but I find
them annoying.

-- 
blog:  http://www.akropolix.net/rik0/blogs | Uccidete i filosofi,
site:  http://www.akropolix.net/rik0/  | tenetevi riso e
forum: http://www.akropolix.net/forum/ | bacchette per voi.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Best Free and Open Source Python IDE

2007-02-08 Thread Enrico 'Mc Osten' Franchi
Srikanth <[EMAIL PROTECTED]> wrote:

> All I need is a good IDE, I can't find something like Eclipse (JDT).
> Eclipse has a Python IDE plug-in but it's not that great.

Have you tried the 'full' plugin (you have to pay about 30 $ IIRC or
something like that)?

My favourite Python editor is TextMate a shareware (39 $) editor for the
MacOS. Before that I used gvim and then for a short time Emacs.
In my opinion an IDE is not necessary in Python. However, this may be
dependent from the way I work.

-- 
blog:  http://www.akropolix.net/rik0/blogs | Uccidete i filosofi,
site:  http://www.akropolix.net/rik0/  | tenetevi riso e
forum: http://www.akropolix.net/forum/ | bacchette per voi.
-- 
http://mail.python.org/mailman/listinfo/python-list