http client module

2007-07-31 Thread stefano
Hello i'm looking for a http client for python i found this one call
httplib2

http://64.233.169.104/search?q=cache:0jJWNfodK6gJ:bitworking.org/projects/httplib2/+httplib2+python&hl=es&ct=clnk&cd=1&gl=cl&client=firefox-a

but is too old

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


Re: http client module

2007-08-01 Thread stefano
On 31 jul, 23:07, Steve Holden <[EMAIL PROTECTED]> wrote:
> stefano wrote:
> > Hello i'm looking for a http client for python i found this one call
> > httplib2
>
> >http://64.233.169.104/search?q=cache:0jJWNfodK6gJ:bitworking.org/proj...
>
> > but is too old
>
> Look at urllib and urllib2 in the standard library. If they don't give
> you what you want, think about using mechanize and ClientForm, or
> possible beautifulsoup, all of which Google should be able to find for you.
>
> regards
>   Steve
> --
> Steve Holden+1 571 484 6266   +1 800 494 3119
> Holden Web LLC/Ltd  http://www.holdenweb.com
> Skype: holdenweb  http://del.icio.us/steve.holden
> --- Asciimercial --
> Get on the web: Blog, lens and tag the Internet
> Many services currently offer free registration
> --- Thank You for Reading -

thanks

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


make images with python

2007-08-14 Thread stefano
I need make some images using python but i'm lost :P

i need some module to make .png (with drawline, drawcircle, drawpoint
etc etc etc )

like gd for php :P

thants :D

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


wx, qt, gtk

2009-03-05 Thread Stefano

Hello everybody

After many little programs now I must prepare a serious desktop application 
.
Without discussing about licensing but only from the technical point of view 
I have tried wx,wt,gtk graphical gui to build 'normal gui apps ' and 
everyone goes well.
In the end of all  i searched in internet and i've found that applications 
( even commercial ) written with gtk are more and more than other written 
with wx and qt (not only with python)


Any commets are appreciated

Stefano

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


script question

2009-04-17 Thread Stefano

I have a script like this

myscript.py

   def func01()
   def func02()
   def func03()
   
   def funcnn()

How can i execute my func in the code ?

import myscript
for i in range(1,n):
   myscript.func??

many thanks
stefano
--
http://mail.python.org/mailman/listinfo/python-list


SqlAlchemy and mssqlserver

2009-04-21 Thread Stefano

Using sqlalchemy with pyodbc and mssqlserver
Why sa always generate identity ?

many thanks here the sample

tb = Table('prova',meta,Column('chiave', Integer, primary_key=True))
tb.create()

CREATE TABLE prova (
chiave INTEGER NOT NULL IDENTITY(1,1), 
PRIMARY KEY (chiave)

)


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


installazione numpy

2021-10-11 Thread stefano felli
l'installazione di numpy con
pip install numpy
fornisce errore
Building wheel for numpy (PEP 517)

 ERROR: Failed building wheel for numpy
Failed to build numpy
ERROR: Could not build wheels for numpy which use PEP 517 and cannot be
installed directly


A cosa è dovuto e come devo fare per installare anche scipy che non riesce?
Grazie
-- 
https://mail.python.org/mailman/listinfo/python-list


Circular Import

2022-04-12 Thread Stefano Ovus
How can I avoid circular imports keeping separated modules ?

-- square.py

from circle import Cirle
class Square:
  def __init__(self):
...
  @classmethod
  def from_circle(cls, circle: Circle) -> Square:
...
return cls(...)


-- circle.py

from square import Square
class Circle:
  def __init__(self):
...
  @classmethod
  def from_square(cls, square: Square) -> Circle:
...
return cls(...)

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


Re: Circular Import

2022-04-12 Thread Stefano Ovus
found a solution: importing modules instead of classes, ex.

-- square.py

import circle

...
@classmethod
  def from_circle(cls, circle: circle.Circle) -> Square:
...
return cls(...)
-- 
https://mail.python.org/mailman/listinfo/python-list


Font management under win32

2005-09-28 Thread Stefano Masini
Hi,

I have a simple need, running under windows:

1) retrieve the list of installed system fonts
2) maybe install missing fonts

Surprisingly for me, there seems to be no support for such a thing in
python. I really hope I'm mistaken, so _please_ correct me if I'm
wrong.

I found out that it all boils down to a couple of win32 syscalls:
EnumFontFamiliesEx and AddFontResourceEx. Unfortunately I'm no expert
of win32 programming whatsoever. I asked Mark Hammond about this.
While I wait for him to receive my email, I thought I'd post on the
list in case someone else was interested, or had found a different
solution.

Indeed, win32gui does contain an EnumFontFamilies (without the
trailing "Ex") function, but I found no usage example, and I couldn't
figure out how to use LOGFONT handles (since such a thing is required
as the first parameter to the call). So I decided to punt on it and
ask for wiser support.

If I could get this EnumFontFamilies to work, it could already be
enough, because I found a command line tool that allows me to do font
installation. It's got to be some no-brainer 10 lines of C code simply
calling AddFontResourceEx, but it works!

So, does anybody ever had the same problem?

thanks,
stefano
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Font management under win32

2005-09-30 Thread Stefano Masini
On 9/30/05, Roger Upole <[EMAIL PROTECTED]> wrote:
> Here's an example of how to use EnumFontFamilies:

I'm trying the code you just posted, which works (thanks a lot), but I'm having
another problem now.

As I stated in my first post, the reason why I need to know the list
of installed fonts is that I have to decide whether to further install
some additional missing ones.
The problem I have now, is that I don't know before hand the name of
the missing fonts, I just have their .ttf or .otf files. So I'd have
to somehow go inside and look for their names.

Do you think that is possible with win32 extensions?

thanks,
stefano
-- 
http://mail.python.org/mailman/listinfo/python-list


Why do Pythoneers reinvent the wheel?

2005-09-09 Thread Stefano Masini
On 8 Sep 2005 08:24:50 -0700, Fuzzyman <[EMAIL PROTECTED]> wrote:
> What is pythonutils ?
> =
> ConfigObj - simple config file handling
> validate - validation and type conversion system
> listquote - string to list conversion
> StandOut - simple logging and output control object
> pathutils - for working with paths and files
> cgiutils - cgi helpers
> urlpath - functions for handling URLs
> odict - Ordered Dictionary Class

Fuzzyman, your post reminded me of something I can't stop thinking
about. Please don't take this as a critique on your work. I place
myself on the same side of yours.
I just wanted to share this thought with everybody had an opinion about it.

I wonder how many people (including myself) have implemented their own
versions of such modules, at least once in their pythonic life. I
indeed have my own odict (even same name! :). My own pathutils
(different name, but same stuff). My own validate... and so forth.

This is just too bad.
There are a few ares where everybody seems to be implementing their
own stuff over and over: logging, file handling, ordered dictionaries,
data serialization, and maybe a few more.
I don't know what's the ultimate problem, but I think there are 3 main reasons:
1) poor communication inside the community (mhm... arguable)
2) lack of a rich standard library (I heard this more than once)
3) python is such an easy language that the "I'll do it myself" evil
side lying hidden inside each one of us comes up a little too often,
and prevents from spending more time on research of what's available.

It seems to me that this tendency is hurting python, and I wonder if
there is something that could be done about it. I once followed a
discussion about placing one of the available third party modules for
file handling inside the standard library. I can't remember its name
right now, but the discussion quickly became hot with considerations
about the module not being "right" enough to fit the standard library.
The points were right, but in some sense it's a pity because by being
in the stdlib it could have had a lot more visibility and maybe people
would have stopped writing their own, and would have begun using it.
Then maybe, if it was not perfect, people would have begun improving
it, and by now we would have a solid feature available to everybody.

mhm... could it be a good idea to have two versions of the stdlib? One
stable, and one testing, where stuff could be thrown in without being
too picky, in order to let the community decide and improve?

Again, Fuzzyman, your post was just the excuse to get me started. I
understand and respect your work, also because you put the remarkable
effort to make it publicly available.

That's my two cents,
stefano
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why do Pythoneers reinvent the wheel?

2005-09-09 Thread Stefano Masini
On 9/9/05, Michael Amrhein <[EMAIL PROTECTED]> wrote:
> Did you take a look at pyPI (http://www.python.org/pypi) ?
> At least you'd find another odict ...

Oh, yeah. And another filesystem abstraction layer... and another xml
serialization methodology... :)
PyPI is actually pretty cool. If I had to vote for something going
into a "testing" stdlib, I'd vote for PyPI.

You see, that's my point, we have too many! :)

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


Re: Why do Pythoneers reinvent the wheel?

2005-09-09 Thread Stefano Masini
On 9/9/05, djw <[EMAIL PROTECTED]> wrote:
> I think, for me, this most important reason is that the stdlib version
> of a module doesn't always completely fill the requirements of the
> project being worked on. That's certainly why I wrote my own, much
> simpler, logging module. In this case, its obvious that the original
> author of the stdlib logging module had different ideas about how
> straightforward and simple a logging module should be. To me, this just
> demonstrates how difficult it is to write good library code - it has to
> try and be everything to everybody without becoming overly general,
> abstract, or bloated.

That's very true. But...
...there are languages (ahem... did I hear somebody say Java? :) that
make it so hard to write code, that one usually prefers using whatever
is already available even if this means adopting a "style" that
doesn't quite match his expectations.
To me, it is not clear which is best: a very comfortable programmer
with a longer todo list, or an unfomfortable programmer with a short
todo list.
So far, I've always struggled to be in the first category, but I'm
amazed when I look back and see how many wheels I reinvented. But
maybe it's just lack of wisdom. :)

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


Re: Why do Pythoneers reinvent the wheel?

2005-09-09 Thread Stefano Masini
On 9/9/05, Dave Brueck <[EMAIL PROTECTED]> wrote:
> shot). The cost of developing _exactly_ what you need often is (or at least
> *appears* to be) the same as or lower than bending to use what somebody else 
> has
> already built.

That's right. But as you say, this is _often_ the case, not always.
One doesn't necessarily need to "bend" too much in order to use
something that's available out there.
If we're talking about simple stuff, like ordered dictionaries, file
system management, ini files roundtripping, xml serialization (this
one maybe is not that trivial...), I don't think you would have to
come to big compromises.

I myself reinvented these wheels a few times in different projects,
because I wasn't happy with the way I reinvented the first time, then
I eventually found some code written by someone else that was
_exactly_ the same as my last attempt, my most evolved and "perfect",
my presciou :), if it wasn't even better. Separate paths of
evolution that converged to the same solution, because the problem was
simple to begin with. Under this light, it seems to me that I wasted a
lot of time. If odict was in the stdlib I wouldn't have bothered
writing it.

And yet, this code is not available in the stdlib. Sometimes it's not
even trivial to be googled for. Plus, if you think of a python
beginner, what's the chance that he's gonna say: naa, this code in the
library sucks. I'm gonna search google for another ini file round
tripper. Whatever is available there, he's gonna use, at least in the
beginning. Then he will soon figure out that it indeed sucks, and at
that point there's a chance that he'll say: man... _python_ sucks! I
cannot even round trip an ini file with the same module!

That's why I say this lack of a centralized, officially recommended
code repository maybe is hurting python.

I agree that building library code is hard because it has to be both
correct and simple. But, again, there's a lot of useful stuff not the
library, that's simple in the start so it's just a matter of writing
it correctly. If the semantics can be different, just provide a couple
of alternatives, and history will judge.

It would be great if there was a section in the Python manual like this:

"Quick and Dirty: Commonly needed tricks for real applications"

1. odict
2. file system management
3. xml (de)serialization
4. ...

Each section would describe the problem and list one or a few
recommended implementations. All available under __testing_stdlib__.
Appoint somebody as the BDFL and make the process of updating the
testing stdlib democratic enough to allow for more evolution freedom
than the stable stdlib.

If such a "quick and dirty" section existed, I think it would also
become a natural randevouz point for innovators. If one invented a new
cool, simple and useful module, rather than just publishing it in his
own public svn repository, he would feel comfortable to start a
discussion on the python-testing-stdlib mailing list suggesting to
include it in the "quick and dirty" section of the manual. The manual
is the primary resource that every python programmer makes use of,
expecially beginners. But it is so official that no one would ever
dare suggesting to include something in it. If the Vaults of Parnassus
were listed in there (maybe a bit trimmed and evaluated first ;) a
beginner would have immediate access to the most common tricks that
one soon faces when it comes to writing real applications.

I'm talking wildly here... I'm quite aware of how simplistic I made it.
Just throwing an idea.

What do you think?

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


Re: Why do Pythoneers reinvent the wheel?

2005-09-09 Thread Stefano Masini
On 10 Sep 2005 02:10:59 EDT, Tim Daneliuk <[EMAIL PROTECTED]> wrote:
> As someone who implemented their own configuration mini-language
> with validation, blah, blah, blah 
> (http://www.tundraware.com/Software/tconfpy/)

Well, a configuration mini language with validation and blahs is not
exactly what I would call _simple_... :) so maybe it doesn't even fit
into my idea of testing-stdlib, or "quick and dirty" section of the
manual (see my other post).
But certainly it would be worth mentioning in the list of available
solutions under the subsection "Configuration files handling".

> 1) The existing tool is inadequate for the task at hand and OO subclassing
> is overrated/overhyped to fix this problem.  Even when you override
> base classes with your own stuff, you're still stuck with the larger
> *architecture* of the original design.   You really can't subclass
> your way out of that, hence new tools to do old things spring into
> being.

That's true, but usually only when the original design if too simple
comparing to the complexity of the problem. Instead a very general
solution can usually be subclassed to easily handle a simpler problem.
You still have to actually understand the general and complex design
in order to be able to write subclasses, so maybe one can be tempted
to punt on it, and write its own simple solution. But in this case it
would just be enough to propose a few solutions in the testing-stdlib:
a) one simple implementation for simple problems, easy to understand,
but limited.
b) one complex implementation for complex problems, 
c) one simplified implementation for simple problems, easy to
understand, but subclassed from a complex model, that leaves room for
more understanding and extension just in case one needs more power.

I fully understand the difficulty of reusing code, as it always forces
you to a learning curve and coming to compromises. But I've also
wasted a lot of time reinventing the wheel and later found stuff I
could have happily lived with if I only had known.

> 2) It's a learning exercise.

Well, so we might as well learn a little more and rewrite os.path, the
time module and pickle. Right? :)

> 3) You don't trust the quality of the code for existing modules.
> (Not that *I* have this problem :-p  but some people might.)

That's a good point, but it really boils down to being a wise
programmer on one side, being able to discern the Good from the Bad,
and an active community on the other side, able to provide good
solutions and improve them.
If either one is missing, then a lot of bad stuff can happen, and we
can't really take community decisions basing on the assumption that
programmers won't be able to understand, or that the community won't
be able to provide. So we might as well assume that we have good
programmers and an active community.
Which I think is true, by the way!
So, let's talk about a way to more effectively present available
solutions to our good programmers! :)

cheers,
stefano
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why do Pythoneers reinvent the wheel?

2005-09-10 Thread Stefano Masini
On 10 Sep 2005 03:16:02 EDT, Tim Daneliuk <[EMAIL PROTECTED]> wrote:
> frameworks are unlikely to serve them well as written. I realize this is
> all at a level of complexity above what you had in mind, but it's easy
> to forget that a significant portion of the world likes/needs/benefits
> from things that are *not* particularly generic.  This is thus reflected
> in the software they write.

In my opinion this has got more to deal with the open source vs.
proprietary debate, that I wouldn't like to talk about, since it's
somewhat marginal.

What I was pointing out is well summarized in the subject: Why do
Pythoneers reinvent the wheel?
Reinventing the wheel (too much) is Bad for both the open source
community and industry. It's bad for development in general. I got the
feeling that in the specific case of Python the ultimate reason for
this tendency in also the same reason why this language is so much
better that others for, say, fast prototyping and exploration of new
ideas: it's simple.

So, without taking anything out of python, I'm wondering if a richer
and less formal alternative standard library would help forming a
common grounds where programmers could start from in order to build
better and reinvent less.

If such an aid to _general_ problem solving is indeed missing (I might
be wrong) from the current state of python, I don't really think the
reason is related to industry. I would look for reasons elsewhere,
like it beeing difficult to come out with effective decisional support
in an open source community, or something like this. I can certainly
see the challenge of who and how should decide what goes in the
library, and what not.

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


Convenient filtering in for cycles

2011-10-05 Thread Stefano Maggiolo
Dear all,

I would like to know if there is a (more) convenient way of doing this
structure:

===(1)===
for x in l:
if P(x):
do_stuff(x)
==

Let's say that my dream syntax would be

===(2)===
for x in l if P(x):
do_stuff(x)
==

as if it was the second part of a list comprehension. But sadly it is
not in the language. Obvious alternatives are

===(3)===
for x in (x for x in l if P(x)):
do_stuff(x)
==

===(4)===
for x in l:
if not P(x):
continue
do_stuff(x)
==

===(5)===
[do_stuff(x) for x in l if P(x)]
==

As I see it, every syntax-valid solution has its drawbacks:
(1) adds an indentation level;
(3) adds an unnatural repetition of variable names and "for";
(4) has the "masked goto" continue (even if it is quite easy to
understand what happens);
(5) is good but not usable when do_stuff is what it usually is, that
is a list of instructions.

Is there some better and valid construction I missed? If not, is there
a reason why (2) is not in the language?

Pardon my boldness, but I am asking this because there are two invalid
construct that I keep writing when I don't pay attention: one is (2),
and the other is list comprehensions as in

===(6)===
for x in (x in l if P(x)):
do_stuff(x)
==

which accidentally would be a better solution than (1), (3), (4), (5),
though not as good as (2).

Thank you for your attention,
Stefano Maggiolo
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Convenient filtering in for cycles

2011-10-05 Thread Stefano Maggiolo
Dear Ian,

thank you for you kind response. I was pretty confident the issue had
already been discussed, but I was unable to look it up.

I suppose your "filter" syntax is the best given the options (I always
forget about map and filter...) and definitely I see that the work
needed to add such a feature is hardly worth the convenience.

Still, I think it is sad that generators/list comprehensions and for
cycles do not share the same syntax. Unfortunately, this example from
one of your links convinces that anyway it is too late:

(x for x in (l1 if c else l2)) # valid
(x for x in l1 if c else l2) # SyntaxError
for x in l1 if c else l2 # valid

Cheers,
Stefano
-- 
http://mail.python.org/mailman/listinfo/python-list


New Zope Italia Association (AZI)

2005-05-04 Thread Stefano Noferi
We are pleased to announce the foundation of the Zope Italia
Association (AZI - Associazione Zope Italia).

It was created by a couple of mailing list users in the last months
(since march).

Main goals are to manage the Zope.IT community activities, to contribute
to the diffusion and to improve the visibility of Zope, Plone and Python
in Italy.

Further details can be found at http://zope.it.

-- 
Stefano Noferi
Zope Italia Association
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Asynchronous XML-RPC client library?

2007-04-29 Thread Stefano Canepa
On 29 Apr, 07:11, Jarek Zgoda <[EMAIL PROTECTED]> wrote:
> Is there anything like that? Googling yields many articles on async
> servers, but virtually nothing on clients. I have to talk to remote in
> an environment that does not allow threads...
>
> --
> Jarek Zgodahttp://jpa.berlios.de/

Why don't you try twisted (http://www.twistedmatrix.com)

Bye
Stefano



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


Re: gui application on cross platform

2007-05-28 Thread Stefano Canepa
On 28 Mag, 08:01, james_027 <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I am using delphi to develop gui application, and wish to make a shift
> to python. here are some of my question/concern...
>
> 1. is python develop gui application a cross platform? just like java
> swing?

Yes. Qt, wxwidgets and pygtk run on Linux and Windows, don't know
about Macs.

> 2. delphi makes things easy for me like coding for a specific event on
> a specific component, could it be the same for python?

Not in the Delphi way but glade/gazpacho are good GUI designer for
gtk.
I have no experience with qtdesigner or the wx equivalent app.

> 3. are there cool library of component like in delphi available for
> python that will make database application more usesable?

python has dbapi, all DBs look the same, python can also use ORM like
SQLObjects and SQLALchemy

> 4. where do I start the learning curve? I did some research and I
> don't know which one to take among wxwdiget, pygtk, and etc.

I tried wxwidgets and pygtk, then I decided to use pygtk but it
could be I'll change my mind in the future.

Bye
sc

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


Re: Python tutorials

2007-05-29 Thread Stefano Canepa
On 29 Mag, 09:08, Laurentiu <[EMAIL PROTECTED]> wrote:
> Hello!
>
> i was searching the net for some python video
> tutorials (free and payed).
>
> i found some interesting stuff atwww.showmedo.combut
> i want something more complex.
>
> can someone give me some address for python video
> tutorials or companies how made this tutorials, free
> or payed.
>
> i search at Lynda.com and vtc but i didn't find any
> python references.
>
> thanks for all answers.
>
> Laurentiu

Have you tried:
http://www.cs.luc.edu/~anh/python/hands-on/handsonHtml/handson.html
http://diveintopython.org/

Bye
sc

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


Re: gui application on cross platform

2007-05-29 Thread Stefano Canepa
On 28 Mag, 09:28, james_027 <[EMAIL PROTECTED]> wrote:
> On May 28, 3:06 pm, Stefano Canepa <[EMAIL PROTECTED]> wrote:
>
>
>
> > On 28 Mag, 08:01, james_027 <[EMAIL PROTECTED]> wrote:
>
> > > Hi,
>
> > > I am using delphi to develop gui application, and wish to make a shift
> > > to python. here are some of my question/concern...
>
> > > 1. is python develop gui application a cross platform? just like java
> > > swing?
>
> > Yes. Qt, wxwidgets and pygtk run on Linux and Windows, don't know
> > about Macs.
>
> > > 2. delphi makes things easy for me like coding for a specific event on
> > > a specific component, could it be the same for python?
>
> > Not in the Delphi way but glade/gazpacho are good GUI designer for
> > gtk.
> > I have no experience with qtdesigner or the wx equivalent app.
>
> > > 3. are there cool library of component like in delphi available for
> > > python that will make database application more usesable?
>
> > python has dbapi, all DBs look the same, python can also use ORM like
> > SQLObjects and SQLALchemy
>
> > > 4. where do I start the learning curve? I did some research and I
> > > don't know which one to take among wxwdiget, pygtk, and etc.
>
> > I tried wxwidgets and pygtk, then I decided to use pygtk but it
> > could be I'll change my mind in the future.
>
> > Bye
> > sc
>
> Thanks sc,
>
> What do you mean when you say .."all DBs look the same"

That via dbapi you can use different DBs using the same API.

> what is the difference between pygtk and wxwidgets?

pygtk uses GTK
wxwidget use a different gui toolkit on different platform. It is
probably the best crossplatform GUI.
I used pyGTK simply becouse my GUI apps runs only on gnome.

Bye
sc

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


How to assign a function to another function

2007-09-17 Thread Stefano Esposito
Hi all

what i'm trying to do is this:

>>>def foo ():
... return None
...
>>>def bar ():
... print "called bar"
...
>>>def assigner ():
... foo = bar
...
>>>assigner()
>>>foo()
called bar
>>>

This piece of code is not working and even trying with
>>>def assigner (a, b):
... a = b
...
>>>assigner(foo, bar)
>>>foo()

isn't working. How can I achieve my goal?

Thanks for your help! :)
-- 
Stefano Esposito <[EMAIL PROTECTED]>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to assign a function to another function

2007-09-17 Thread Stefano Esposito
On Mon, 17 Sep 2007 17:49:58 +0100
Paul Rudin <[EMAIL PROTECTED]> wrote:

> Stefano Esposito <[EMAIL PROTECTED]> writes:
> 
> > Hi all
> >
> > what i'm trying to do is this:
> >
> >>>>def foo ():
> > ... return None
> > ...
> >>>>def bar ():
> > ... print "called bar"
> > ...
> >>>>def assigner ():
> > ... foo = bar
> > ...
> >>>>assigner()
> >>>>foo()
> > called bar
> >>>>
> >
> > This piece of code is not working and even trying with...
> 
> 
> > ... How can I achieve my goal?
> 
> 
> By adding the line:
>global foo
> at the beginning of the body of assigner.
> 

This worked, thanks a lot :)


-- 
Stefano Esposito <[EMAIL PROTECTED]>
-- 
http://mail.python.org/mailman/listinfo/python-list


package with executable

2009-05-19 Thread Stefano Costa
Hi,
my name is Stefano Costa, I am an archaeologist and I am developing
GNUCal, a radiocarbon calibration program released under the GNU GPL.
[1][2]

Currently the program consists of a small "library", largely based on
Matplotlib and Numpy, and a command line program. My goal is to create a
distributable package, that should ideally contain both the "gnucal"
package and the command line program.

As you can see in the source code [3], I am following some sort of
standard layout for my project, but some things aren't still clear to
me, even after reading setuptools' documentation and looking to the
source of some known Python packages (like sphinx, pastescript, django):
  * where should the executable module be wrt setup.py and/or the
package directory in the source tree
  * how should I format the console_scripts entry in setup() to make
the executable module available to the system PATH after
installing
  * how should I call the "gnucal" package from inside the
executable script (currently I'm using "from gnucal import core"
but it doesn't seem to work)

I'm using virtualenv to create testing environments for the install
process, and my Python is 2.5.4 on Debian Sid.

Any suggestion is appreciated, particularly if there are some real
examples to draw from.

thanks,
steko

[1] http://gnucal.iosa.it/
[2] http://en.wikipedia.org/wiki/Radiocarbon_dating#Calibration
[3] http://bitbucket.org/steko/gnucal/

-- 
Stefano Costa
http://www.iosa.it/ Open Archaeology


signature.asc
Description: Questa è una parte del messaggio	firmata digitalmente
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: package with executable

2009-05-20 Thread Stefano Costa
Il Wed, 20 May 2009 07:01:39 +0100, A. Cavallo ha scritto:

> With the standard distutils (no need for setuptools) the config.py file
> might look like:

Right, I ended up using setuptools just because I used paster to create 
the project layout. I'll think about using plain distutils instead.

> import gnucal must work. If you're developing from the sources (eg.
> without having the package installed) you need to be in the same dir
> where the gnucal.py is or you need to set PYTHONPATH in order to find
> the directory gnucal (the one containing __init__.py).

Right now, the problem is that upon installing "import gnucal" works in 
the python interactive interpreter, but gnucal.py raises an exception 
that it's not able to import gnucal.core and friends.

> At line 101 the statement sys.exit("Please.. should be
> parser.error("Please..

Good point! Thanks,
steko

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