Re: Let's talk about debuggers!

2017-10-25 Thread Michele Simionato
pdb plus plus: https://pypi.python.org/pypi/pdbpp -- https://mail.python.org/mailman/listinfo/python-list

Re: multiprocessing shows no benefit

2017-10-20 Thread Michele Simionato
There is a trick that I use when data transfer is the performance killer. Just save your big array first (for instance on and .hdf5 file) and send to the workers the indices to retrieve the portion of the array you are interested in instead of the actual subarray. Anyway there are cases where m

Re: Users of namedtuple: do you use the _source attribute?

2017-07-17 Thread Michele Simionato
Il giorno lunedì 17 luglio 2017 19:20:04 UTC+2, Steve D'Aprano ha scritto: > collections.namedtuple generates a new class using exec, and records the > source > code for the class as a _source attribute. > > Although it has a leading underscore, it is actually a public attribute. The > leading un

Decorating coroutines

2017-07-15 Thread Michele Simionato
errors or strange behaviors. I am not aware of any issues, but one is never sure with new features. Thanks for your help, Michele Simionato -- https://mail.python.org/mailman/listinfo/python-list

Re: sqlite3 is non-transactional??

2017-06-15 Thread Michele Simionato
Thanks. I suspected the culprit was executescript, but I did not see it documented in https://docs.python.org/3/library/sqlite3.html#connection-objects. -- https://mail.python.org/mailman/listinfo/python-list

sqlite3 is non-transactional??

2017-06-15 Thread Michele Simionato
erted in script1, since they are part of the same transaction. Instead they are not removed! Can somebody share some light on this? I discover the issue while porting some code from PostgreSQL to sqlite3, with Postgres doing the right thing and sqlite failing. I am puzzled, Michele Simionato -- https://mail.python.org/mailman/listinfo/python-list

Re: argparse and subparsers

2016-06-28 Thread Michele Simionato
I did not know about docopt. It is basically the same idea of this recipe I wrote about 12 years ago: https://code.activestate.com/recipes/278844-parsing-the-command-line/?in=user-1122360 Good that it was reinvented :-) -- https://mail.python.org/mailman/listinfo/python-list

Re: Recommendation for Object-Oriented systems to study

2016-05-29 Thread Michele Simionato
On Sunday, May 29, 2016 at 4:42:17 PM UTC+2, Ankush Thakur wrote: > Hello, > > I'm a self-taught programmer who has managed to claw his way out of Python > basics and even covered the intermediate parts. But I feel I have a ton of > theory in my head and would like to see some smallish applicati

Re: XML Binding

2015-09-10 Thread Michele Simionato
On Thursday, September 3, 2015 at 6:55:06 PM UTC+2, Palpandi wrote: > Hi All, > > Is there any module available in python standard library for XML binding? If > not, any other suggestions. > > Which is good for parsing large file? > 1. XML binding > 2. Creating our own classes > > > Thanks, >

Re: Python Object Systems

2014-08-14 Thread Michele Simionato
Il giorno mercoledì 13 agosto 2014 19:13:16 UTC+2, thequie...@gmail.com ha scritto: > What is the difference between traits and roles? People keep using the same names to mean different concepts. For me traits are the things described here: http://www.iam.unibe.ch/~scg/Archive/Papers/Scha03aTra

Re: Python Object Systems

2014-08-13 Thread Michele Simionato
Years ago I wrote strait: https://pypi.python.org/pypi/strait I wonder who is using it and for what purpose, since surprisingly enough it has 50+ downloads per day. For me it was more of an experiment than a real project. -- https://mail.python.org/mailman/listinfo/python-list

Trying to understand the memory occupation of big lists

2013-05-03 Thread Michele Simionato
I have a memory leak in a program using big arrays. With the goal of debugging it I run into the memory_profiler module. Then I discovered something which is surprising to me. Please consider the following script: $ cat memtest.py import gc from memory_profiler import profile @profile def test

Re: Decorating functions without losing their signatures

2013-04-03 Thread Michele Simionato
On Wednesday, April 3, 2013 3:05:31 AM UTC+2, Rotwang wrote: > After thinking about it for a while I've come up with the following > > abomination Alas, there is actually no good way to implement this feature in pure Python without abominations. Internally the decorator module does something s

Re: Testing against multiple versions of Python

2012-10-19 Thread Michele Simionato
ShiningPanda looks really really cool. I need to investigate it. -- http://mail.python.org/mailman/listinfo/python-list

Testing against multiple versions of Python

2012-10-18 Thread Michele Simionato
dvice is welcome! Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: surprising behaviour of global dictionaries

2012-10-09 Thread Michele Simionato
On Tuesday, October 9, 2012 5:24:17 PM UTC+2, Peter Otten wrote: > Seriously, you shouldn't use the main script as a library; it is put into > > the sys.modules cache under the "__main__" key. Subsequent imports under its > > real name will not find that name in the cache and import another ins

surprising behaviour of global dictionaries

2012-10-09 Thread Michele Simionato
I have the following module implementing a registry of functions with a decorator: $ cat x.py registry = {} # global dictionary def dec(func): registry[func.__name__] = func print registry, id(registry) return func if __name__ == '__main__': import xlib print registry, id(re

Re: Style question: metaclass self vs cls?

2012-07-17 Thread Michele Simionato
The standard is to use `cls`. In the __new__ method you can use `mcl` or `meta`. -- http://mail.python.org/mailman/listinfo/python-list

A better contextlib.contextmanager

2012-05-23 Thread Michele Simionato
Python 3.2 enhanced contextlib.contextmanager so that it is possible to use a context manager as a decorator. For instance, given the contextmanager factory below @contextmanager def before_after(): print(before) yield print(after) it is possibile to use it to generate decorators: @b

Re: Instrumenting a class to see how it is used

2012-05-14 Thread Michele Simionato
This may get you started (warning: not really tested). $ echo instr.py from warnings import warn oget = object.__getattribute__ tget = type.__getattribute__ class Instr(object): class __metaclass__(type): def __getattribute__(cls, name): clsname = tget(cls, '__na

Re: Hierarchical commnd line parsing / help texts

2011-09-28 Thread Michele Simionato
plac is based on argparser and it is intended to be much easier to use. See http://plac.googlecode.com/hg/doc/plac.html Here is an example of usage. $ cat vcs.py class VCS(object): "A fictitious version control tool" commands = ['checkout', 'commit'] def checkout(self, url): r

Re: Argparse, and linking to methods in Subclasses

2011-07-18 Thread Michele Simionato
Here is an example by using my own library plac (http://pypi.python.org/pypi/plac): class Server(): def configure_logging(self, logging_file): pass def check(self): pass def deploy(self): pass def configure(self): pass def __init__(self, hostnam

Re: Class decorators might also be super too

2011-05-28 Thread Michele Simionato
He is basically showing that using mixins for implementing logging is not such a good idea, i.e. you can get the same effect in a better way by making use of other Python features. I argued the same thing many times in the past. I even wrote a module once (strait) to reimplement 99% of multiple

Re: Python's super() considered super!

2011-05-27 Thread Michele Simionato
The fact that even experienced programmers fail to see that super(type(self),self) in Python 2 is NOT equivalent to super() in Python 3 is telling something. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python's super() considered super!

2011-05-27 Thread Michele Simionato
On Friday, May 27, 2011 10:49:52 AM UTC+2, Ben Finney wrote: > The exquisite care that you describe programmers needing to maintain is IMO > just as much a deterrent as the super-is-harmful essay. Worth quoting. Also I think this article may encourage naive programmers along the dark path of coop

Re: Markdown to reStructuredText

2011-02-10 Thread Michele Simionato
Looks cool, I will have a look at it, thanks! -- http://mail.python.org/mailman/listinfo/python-list

Markdown to reStructuredText

2011-02-09 Thread Michele Simionato
Do you know if there is any converter from the Markdown syntax to the rst syntax? Googling for markdown2rst did not help. Thanks! -- http://mail.python.org/mailman/listinfo/python-list

Re: DRY and static attribute for multiple classes.

2011-02-02 Thread Michele Simionato
Notice that Peter's approach also works without inheritance: registries = {} @property def per_class(self): cls = type(self) try: return registries[cls] except KeyError: result = registries[cls] = [] return result class A(object): per_class=per_class class B(object): p

Re: Ideas for a module to process command line arguments

2011-01-13 Thread Michele Simionato
On Jan 12, 6:09 pm, Alice Bevan–McGregor wrote: > entirely sure what you mean by 'smart' options.  If your'e referring to > using a single hyphen and a list of characters to represent a long > option (which, to the rest of the world, use two leading hyphens) then > that's pretty weird.  ;) > > One

Re: Ideas for a module to process command line arguments

2011-01-11 Thread Michele Simionato
On Jan 11, 6:57 pm, Mike wrote: > On Jan 11, 11:26 am, Michele Simionato > wrote: > > In that case easy_install/pip/whatever will install the dependency > > automatically (who is installing > > dependencies by hand nowadays?). > > I do. Is this bad? :} You are

Re: Ideas for a module to process command line arguments

2011-01-11 Thread Michele Simionato
On Jan 11, 4:06 pm, Alice Bevan–McGregor wrote: > After looking into it, Plac's default help display isn't very helpful; > you need to massage your application a fair amount before generating > nice, complete-looking argument lists and such.  For example: > >         def main(verbose: ('prints mor

Re: Ideas for a module to process command line arguments

2011-01-11 Thread Michele Simionato
On Jan 11, 5:22 pm, Jean-Michel Pichavant wrote: > Michele Simionato wrote: > > On Jan 11, 4:06 pm, Alice Bevan McGregor wrote: > > >> Plac appears (from the documentation) to be written on top of argparse. > >>  :( > > > And the problem with that being wh

Re: Ideas for a module to process command line arguments

2011-01-11 Thread Michele Simionato
On Jan 11, 4:06 pm, Alice Bevan–McGregor wrote: > Plac appears (from the documentation) to be written on top of argparse. >  :( And the problem with that being what? -- http://mail.python.org/mailman/listinfo/python-list

Re: Ideas for a module to process command line arguments

2011-01-11 Thread Michele Simionato
On Jan 11, 8:25 am, Alice Bevan–McGregor wrote: explicit callbacks or typecasting functions, etc. > > I got tired of using PasteScript and OptParse.  Mostly OptParse, actually.  :/ It's a pity that the argument parsing modules in the standard library are so verbose that everybody is reinventing

decorator 3.3 is out

2011-01-01 Thread Michele Simionato
Python 3 and function annotations you may want to try out the new decorator module (easy_install decorator) and give me feedback. See http://pypi.python.org/pypi/decorator for more. Thanks for your time and Happy New Year to all fellows Pythonistas! Michele Simionato P.S. today I have

Re: How do you find out what's happening in a process?

2010-11-29 Thread Michele Simionato
On Nov 29, 7:01 am, Leo Jay wrote: > Hi all, > > I'd like to know how do you guys find out what's happening in your > code if the process seems not work. > In java, I will use jstack to check stacks of threads and lock status. > But I don't know how to do it in python. > > -- > Best Regards, > Le

Re: Needed: Real-world examples for Python's Cooperative Multiple Inheritance

2010-11-29 Thread Michele Simionato
techniques, so I am not sure how much my gut feeling is sound. Apparently here at work we are going to use Erlang in the near future and I hope to get my hand dirty and see in practice how well one can work with a language without inheritance. BTW, is there anybody here with experience on such langu

Re: Using property() to extend Tkinter classes but Tkinter classes are old-style classes?

2010-11-29 Thread Michele Simionato
you can attach properties to it. You have a good chance of not breaking anything in doing so, but you cannot know for sure unless you try. I don't know if Tkinter uses features of old-style classes which are inconsistent with new- style classes, but probably the answer is not much. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: STARTTLS extension not supported by server

2010-11-29 Thread Michele Simionato
For future googlers: it turns out in my case the call to .starttls() was not needed: I removed it and everything worked. Dunno why I was there in the first place, the original code was written by somebody else. -- http://mail.python.org/mailman/listinfo/python-list

Re: Needed: Real-world examples for Python's Cooperative Multiple Inheritance

2010-11-26 Thread Michele Simionato
now of other use cases either. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

STARTTLS extension not supported by server

2010-11-15 Thread Michele Simionato
n to be debug the issue and to figure out where the problem is? TIA, Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: How to get dynamically-created fxn's source?

2010-11-09 Thread Michele Simionato
On Nov 5, 5:55 pm, gb345 wrote: > For a project I'm working on I need a way to retrieve the source > code of dynamically generated Python functions.  (These functions > are implemented dynamically in order to simulate "partial application" > in Python.[1])  The ultimate goal is to preserve a textu

Re: Best method for a menu in a command line program?

2010-11-04 Thread Michele Simionato
On Nov 4, 2:19 am, braden faulkner wrote: > I'm using a menu for my command line app using this method. > > choice = "foobar" > while choice != "q": >     if choice == "c": >         temp = input("Celsius temperature:") >         print "Fahrenheit:",celsius_to_fahrenheit(temp) >     elif choice ==

Re: A good decorator library

2010-10-23 Thread Michele Simionato
On Oct 22, 10:42 pm, Felipe Bastos Nunes wrote: > Hi! I was looking for a good decorator library to study and make my > own decorators. I've read the Bruce Eckel's blog at artima dot com. > But I need some more examples. I'm building a WSN simulator like SHOX > is in java, but programming it in py

Re: using optparser

2010-10-16 Thread Michele Simionato
Accepting both options and positional arguments for the same purpose does not look like a good idea to me. Anyway, here is a solution using plac (http://pypi.python.org/pypi/ plac) assuming you can afford an external dependency: import plac @plac.annotations( personname=("person to be matched

Re: optparser: how to register callback to display binary's help

2010-10-13 Thread Michele Simionato
Here is a solution using plac (http://pypi.python.org/pypi/plac) and not OptionParse, in the case the Linux underlying command is grep: import subprocess import plac @plac.annotations(help=('show help', 'flag', 'h')) def main(help): if help: script_usage = plac.parser_from(main).forma

Re: Python in Linux - barrier to Python 3.x

2010-09-21 Thread Michele Simionato
Python. But the situation is not different for other languages such as Perl or Ruby. C is free from this problem because it is a very old and stable language. There is no more content in that post and everybody should already know such basic facts. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: argparse list

2010-09-02 Thread Michele Simionato
On Sep 2, 1:45 pm, Neal Becker wrote: > I'm interested in using argparse to parse a string formatted as: > > my_prog --option1=1,10,37 > > That is, a list of comma delimited values.  I guess nargs almost does it, > but expects options to be space-delimited. > > What would be the easiest approach?

Re: Structured programming with optionParser

2010-08-30 Thread Michele Simionato
Perhaps, I should give an example of using plac. For instance, here is how you could implement a SVN-like tool with two commands ``checkout`` and ``commit``. The trick is to write a class with two methods ``checkout`` and ``commit`` and an attribute ``.commands`` listing them, and to call the clas

Re: Structured programming with optionParser

2010-08-30 Thread Michele Simionato
On Aug 31, 3:45 am, NickC wrote: > I'm struggling to see how you could refactor the option parsing function. > After all, it has to process the options, so it has to do all the setup > for those options, and then process them. Perhaps plac could simplify your life, by removing most of the boilerp

Re: 79 chars or more?

2010-08-17 Thread Michele Simionato
my Emacs is set to 79 chars and longer code looks ugly, that I look at two-side diffs all the time, and that sometimes I want to print on paper the code I have to work with. OTOH, I do not see a single advantage in using long lines. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: let optionparse.Optionparser ignore unknown command line switches.

2010-08-02 Thread Michele Simionato
On Aug 1, 1:08 pm, News123 wrote: > I wondered, whether there's a simple/standard way to let > the Optionparser just ignore unknown command line switches. > > thanks in advance for any ideas I will plug in my own work on plac: http://pypi.python.org/pypi/plac Your problem would be solved as follo

Re: Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

2010-08-01 Thread Michele Simionato
On Jul 31, 5:08 am, Steven D'Aprano wrote: > I have read Michelle Simionato's articles on super in Python. One "l" please! I am a man! ;-) > > But Michelle is wrong to conclude that the problem lies with the concept > of *superclass*. The problem lies with the idea that there is ONE > superclass

Re: Multiprocessing zombie processes

2010-07-26 Thread Michele Simionato
On Jul 25, 1:11 am, Navkirat Singh wrote: > OK I wanted zombie processes and have been able to regenerate them with > multiprocessing. Now lets see how I can handle them. The multiprocessing docs say: """ Joining zombie processes On Unix when a process finishes but has not been joined it becom

Re: Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

2010-07-25 Thread Michele Simionato
Everything you ever wanted to know about super is collected here: http://micheles.googlecode.com/hg/artima/python/super.pdf M.S. -- http://mail.python.org/mailman/listinfo/python-list

Re: understanding the mro (long)

2010-07-23 Thread Michele Simionato
On Jul 24, 4:42 am, Rolando Espinoza La Fuente wrote: > Finally everything make sense. And make think about be careful when > doing multiple inheritance. > > Any thoughts? > > ~Rolando I am not fond of multiple inheritance either and I wrote at length about the dangers of it. If you do not know i

Re: linux console command line history

2010-07-20 Thread Michele Simionato
On Jul 20, 11:38 pm, "kak...@gmail.com" wrote: > Hi to all, > I 'm writing a linux console app with sockets. It's basically a client > app that fires commands in a server. > For example: > $log user 55 > $sessions list > $server list etc. > What i want is, after entering some commands, to press th

Re: Code generator and visitor pattern

2010-07-16 Thread Michele Simionato
or parsing XML data) work exactly that way. Actually one of the motivating examples for the introduction of generators in Python was their use in flattening data structure, i.e. exactly the pattern used by os.walk. The message is stop thinking like in Java and start using idiomatic Python. We are here to help. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

multiline input and readline

2010-07-14 Thread Michele Simionato
like such function is wrapped in Python: what are my options? Notice that compatibility with pyreadline (which work on Windows) would be a plus. TIA, Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: The real problem with Python 3 - no business case for conversion (was "I strongly dislike Python 3")

2010-07-07 Thread Michele Simionato
On Jul 7, 10:55 pm, Carl Banks wrote: > On Jul 7, 1:31 am, Paul McGuire wrote: > > I just > > couldn't get through on the python-dev list that I couldn't just > > upgrade my code to 2.6 and then use 2to3 to keep in step across the > > 2-3 chasm, as this would leave behind my faithful pre-2.6 user

Re: C interpreter in Lisp/scheme/python

2010-07-07 Thread Michele Simionato
an *embedded* language: then thanks to macros you could write a *compiled* sublanguage. Doing the same in Python is essentially impossible. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: I strongly dislike Python 3

2010-06-30 Thread Michele Simionato
On Jun 30, 2:52 pm, Lie Ryan wrote: > On 06/27/10 11:24, Steven D'Aprano wrote: > > >> > Producing print function takes a little bit more effort than producing a > >> > print statement. > > > (1) The main use-cases for print are quick (and usually dirty) scripts, > > interactive use, and as a debu

Re: optparse TypeError

2010-06-28 Thread Michele Simionato
On Jun 28, 11:47 pm, rantingrick wrote: > Give your *script* an > enema, and do *yourself* a favor by harnessing the simplistic elegance > of the "optphart" module instead! > > #-- Start Script --# > def optphart(args): >     d = {'args':[]} >     for arg in args: >         if arg.startswith('-'):

Re: optparse TypeError

2010-06-28 Thread Michele Simionato
On Jun 28, 9:56 pm, Ben Finney wrote: > Michele Simionato writes: > > optparse is so old-fashioned. Use plac! > > The OP should be made aware that: > > * plac is a third-party library with (TTBOMK) no prospect of inclusion >   in the standard library > > * optparse

Re: optparse TypeError

2010-06-28 Thread Michele Simionato
On Jun 28, 3:30 pm, dirknbr wrote: > I get an int object is not callable TypeError when I execute this. But > I don't understand why. > >     parser = optparse.OptionParser("usage: %lines [options] arg1") >     parser.add_option("-l", "--lines", dest="lines", >                       default=10, ty

Re: plac 0.5 is out!

2010-06-20 Thread Michele Simionato
On Jun 20, 8:26 pm, Andre Alexander Bell wrote: > On 06/20/2010 11:22 AM, Michele Simionato wrote: > > > A few weeks ago I presented on this list my most recent effort, plac. > >  http://micheles.googlecode.com/hg/plac/doc/plac_ext.html > > But this one is broken. :( Aa

Re: plac 0.5 is out!

2010-06-20 Thread Michele Simionato
On Jun 20, 12:02 pm, Andre Alexander Bell wrote: > > How about adding some support for internationalization of the generated > usage output? The usage message of plac is actually generated by the underlying argparse library. argparse use gettext internally, so I would say the support is already t

plac 0.5 is out!

2010-06-20 Thread Michele Simionato
Python 3.1, but the new features require Python 2.5. You can download it from PyPI ($ easy_install -U plac): http://pypi.python.org/pypi/plac Enjoy! Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: Overriding "__setattr__" of a module - possible?

2010-06-15 Thread Michele Simionato
On Jun 16, 7:25 am, John Nagle wrote: >     OK, working on this.  I can make a module make itself into a > fake class, but can't yet do it to other modules from outside. > >                                         John Nagle I think you can with something like import module sys.modules[module.

Re: Overriding "__setattr__" of a module - possible?

2010-06-15 Thread Michele Simionato
On Jun 16, 4:43 am, John Nagle wrote: >    Is it possible to override "__setattr__" of a module?  I > want to capture changes to global variables for debug purposes. > >    None of the following seem to have any effect. > >         modu.__setattr__ = myfn > >         setattr(modu, "__setattr__", m

Re: optparse: best way

2010-06-08 Thread Michele Simionato
On Jun 8, 10:38 am, hiral wrote: > Hi, > > I am using optparser to do following... > > Command syntax: > myscript -o[exension] other_arguments >     where; extension can be 'exe', 'txt', 'pdf', 'ppt' etc. > > Now to parse this, I am doing following... > > parser.add_option("-oexe', dest=exe_file..

Re: plac, the easiest command line arguments parser in the world

2010-06-03 Thread Michele Simionato
On Jun 2, 6:37 am, Michele Simionato wrote: > I would like to announce to the world the first public release of > plac: > >  http://pypi.python.org/pypi/plac The second release is out. I have added the recognition of keyword arguments, improved the formatting of the help message, an

Re: Python Forum

2010-06-03 Thread Michele Simionato
On Jun 3, 12:28 pm, "Martin P. Hellwig" wrote: > On the other hand it might not be so bad that you don't get questions > from users here who are unable to use a nntp reader or news to mail service. I am unable to use a nntp reader or news to mail service. I use the Google Groups interface and I a

Re: plac, the easiest command line arguments parser in the world

2010-06-02 Thread Michele Simionato
On Jun 2, 6:37 am, Michele Simionato wrote: > With blatant immodesty, plac claims to be the easiest to use command > line arguments parser module in the Python world It seems I have to take that claim back. A few hours after the announce I was pointed out to http://pypi.python.org/pypi/C

Re: functools.wraps and help()

2010-06-02 Thread Michele Simionato
On Jun 2, 2:20 pm, Ulrich Eckhardt wrote: > Hi! > > When I use help() on a function, it displays the arguments of the function, > along with the docstring. However, when wrapping the function using > functools.wraps it only displays the arguments that the (internal) wrapper > function takes, which

Re: plac, the easiest command line arguments parser in the world

2010-06-02 Thread Michele Simionato
On Jun 2, 11:01 am, Stefan Behnel wrote: > I managed to talk a Java-drilled collegue of mine into > writing a Python script for a little command line utility, but he needed a > way to organise his argument extraction code when the number of arguments > started to grow beyond two. I told him that t

Re: plac, the easiest command line arguments parser in the world

2010-06-02 Thread Michele Simionato
On Jun 2, 10:43 am, Paul Rubin wrote: > Tim Golden writes: > > pattern, which provides a minimally semi-self-documenting > > approach for positional args, but I've always found the existing > > offerings just a little too much work to bother with. > > I'll give plac a run and see how it behaves.

plac, the easiest command line arguments parser in the world

2010-06-01 Thread Michele Simionato
rg $ python example.py arg1 arg2 usage: example.py [-h] arg example.py: error: unrecognized arguments: arg2 You can find in the documentation a lot of other simple and not so simple examples: http://micheles.googlecode.com/hg/plac/doc/plac.html Enjoy! Michele Simionato P.S. answering an

Re: asyncore loop and cmdloop problem

2010-05-25 Thread Michele Simionato
On May 25, 2:56 pm, "kak...@gmail.com" wrote: > Could you please provide me with a simple example how to do this with > threads. > I don't know where to put the cmdloop(). > Please help, i' m so confused! > Thank you What are you trying to do? Do you really need to use the standard library? Likel

Re: asyncore loop and cmdloop problem

2010-05-25 Thread Michele Simionato
On May 25, 12:03 pm, Giampaolo Rodolà wrote: > Too bad cmdloop() doesn't provide an argument to return immediately. > Why don't you submit this patch on the bug tracker? > > --- Giampaolohttp://code.google.com/p/pyftpdlibhttp://code.google.com/p/psutil Because it is not a bug, cmd was designed to

Re: asyncore loop and cmdloop problem

2010-05-25 Thread Michele Simionato
On May 25, 10:42 am, "kak...@gmail.com" wrote: > Hi to all, > i'm creating a command line application using asyncore and cmd. At > > if __name__ == '__main__': >     import socket > >     args = sys.argv[1:] >     if not args: >         print "Usage: %s querystring" % sys.argv[0] >         sys.exi

Re: Generator expressions vs. comprehensions

2010-05-25 Thread Michele Simionato
On May 25, 9:08 am, Peter Otten <__pete...@web.de> wrote: > But the list comprehension is already non-equivalent to the for loop as the > loop variable isn't leaked anymore. We do have three similar constructs with > subtle differences. > > I think not turning the list-comp into syntactic sugar for

Re: help with the Python 3 version of the decorator module

2010-05-24 Thread Michele Simionato
On May 22, 10:49 am, Michele Simionato wrote: > I have finally decided to port the decorator module to Python 3. > Changing the module was zero effort (2to3 worked) but changing the > documentation was quite an effort, since I had to wait for docutils/ > pygements to support Pyt

Re: Generator expressions vs. comprehensions

2010-05-24 Thread Michele Simionato
On May 25, 12:47 am, Carl Banks wrote: > The situation here is known.  It can't be corrected, even in Python 3, > without modifying iterator protocol to tie StopIteration to a specific > iterator.  This is possible and might be worth it to avoid hard-to- > diagnose bugs but it would complicate ite

Re: Another "Go is Python-like" article.

2010-05-22 Thread Michele Simionato
quite different from Python e.g. the attitude towards exceptions. In theory Go should be akin to C, but my gut feeling is that in practice programming in it should not feel too much different from programming in Python (but I do not have first hand experience). Michele Simionato --

help with the Python 3 version of the decorator module

2010-05-22 Thread Michele Simionato
from the building process, if any. I am not sure of what will happen if you do not have distribute or if you have a previous version of the module, or if you use pip or something else (even in Python 2.X). The packaging in Python has become a real mess! TIA for you help, Michele Simionato

Re: Iterating over dict and removing some elements

2010-05-11 Thread Michele Simionato
Or you copy the whole dictionary or you just copy the keys: for k in d.keys(): ... or for k in list(d): ... -- http://mail.python.org/mailman/listinfo/python-list

Re: Is Python a functional programming language?

2010-05-11 Thread Michele Simionato
On May 10, 8:18 pm, a...@pythoncraft.com (Aahz) wrote: > saying that functional features > are "tacked on" understates the case.  Consider how frequently people > reach for list comps and gen exps.  Function dispatch through dicts is > the standard replacement for a switch statement.  Lambda callba

Re: Sphinx hosting

2010-05-10 Thread Michele Simionato
On May 5, 8:00 am, James Mills wrote: > On Wed, May 5, 2010 at 3:35 PM, Michele Simionato > > wrote: > > I am sure it has, but I was talking about just putting in the > > repository an index.html file and have it published, the wayI hear  it > > works in BitBucket and

Re: Sphinx hosting

2010-05-04 Thread Michele Simionato
On May 5, 6:39 am, James Mills wrote: > On Wed, May 5, 2010 at 2:08 PM, Michele Simionato > > wrote: > > Interesting. I tried to see if the same was true for the Wiki in > > Google code but apparently it does not work. Does anybody here know if > > it is possible

Re: Sphinx hosting

2010-05-04 Thread Michele Simionato
On May 4, 9:48 am, James Mills wrote: > On Tue, May 4, 2010 at 5:27 PM, Michele Simionato > > wrote: > > Cool, that's good to know. I am still accepting recommendations for > > non-Python projects ;) > > bitbucket (1) also provide static file hosting through th

Re: Sphinx hosting

2010-05-04 Thread Michele Simionato
On May 4, 8:37 am, "Martin v. Loewis" wrote: > > Do you know of recent improvements on the PyPI side about docs > > hosting? > > Yes; go to your package's pkg_edit page, i.e. > > http://pypi.python.org/pypi?%3Aaction=pkg_edit&name=decorator > > and provide a zip file at Upload Documentation. > > R

Re: Sphinx hosting

2010-05-03 Thread Michele Simionato
On May 4, 8:07 am, "Martin v. Loewis" wrote: > If it's a Python package that this documentation is about, you can host > it on PyPI. It must not be Python, but let's consider this case first. How does it work? When I published my decorator module (http://pypi.python.org/pypi/decorator) the suppor

Sphinx hosting

2010-05-03 Thread Michele Simionato
: it is not that annoying, but perhaps there is already some services out there publishing Sphinx pages directly. Do you know of any? Currently I am hosting my stuff on Google Code but I do not see an easy way to publish the documentation there. Any hint is appreciated. Michele Simionato -- http

doctests working both in Python 2.X and Python 3.X

2010-04-11 Thread Michele Simionato
I do not want to write two documentations for a module working both in Python 2.X and Python 3.X. To avoid that, I would need the ability to interpret doctests according to the used Python version. I mean something like that: """ Documentation of the module --

Re: function decorator-like function

2010-03-28 Thread Michele Simionato
Another option is to use my own decorator module (http:// pypi.python.org/pypi/decorator): from decorator import decorator @decorator def d(func, *args): print 3 return func(*args) @d def f(a, b): print a + b f(5, 7) -- http://mail.python.org/mailman/listinfo/python-list

Re: Advanced Python Programming Oxford Lectures [was: Re: *Advanced* Python book?]

2010-03-26 Thread Michele Simionato
On Mar 25, 2:24 pm, Michele Simionato wrote: > On Mar 25, 1:28 pm, Ethan Furman wrote: > > > > > Michele, > > > Was wondering if you'd had a chance to re-post your lectures -- just did > > a search for them and came up empty, and I would love to read them!

Re: Advanced Python Programming Oxford Lectures [was: Re: *Advanced* Python book?]

2010-03-25 Thread Michele Simionato
On Mar 25, 1:28 pm, Ethan Furman wrote: > > Michele, > > Was wondering if you'd had a chance to re-post your lectures -- just did > a search for them and came up empty, and I would love to read them! > > Many thanks in advance! Oops, I forgot! I will try to make them available soon. -- http://ma

Re: Adding methods from one class to another, dynamically

2010-02-01 Thread Michele Simionato
Wanting the same methods to be attached to different classes often is a code smell (perhaps it is not your case and then use setattr as others said). Perhaps you can just leave such methods outside any class. I would suggest you to use a testing framework not based on inheritance (i.e. use nose or

Re: Function name unchanged in error message

2010-01-29 Thread Michele Simionato
On Jan 29, 2:30 pm, andrew cooke wrote: > Is there any way to change the name of the function in an error > message?  In the example below I'd like the error to refer to bar(), > for example (the motivation is related function decorators - I'd like > the wrapper function to give the same name) Us

  1   2   3   4   5   6   7   8   9   >