Iterate over text file, discarding some lines via context manager

2014-11-28 Thread fetchinson .
Hi all,

I have a feeling that I should solve this by a context manager but
since I've never used them I'm not sure what the optimal (in the
python sense) solution is. So basically what I do all the time is
this:

for line in open( 'myfile' ):
if not line:
# discard empty lines
continue
if line.startswith( '#' ):
# discard lines starting with #
continue
items = line.split( )
if not items:
# discard lines with only spaces, tabs, etc
continue

process( items )

You see I'd like to ignore lines which are empty, start with a #, or
are only white space. How would I write a context manager so that the
above simply becomes

with some_tricky_stuff( 'myfile' ) as items:
process( items )

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Iterate over text file, discarding some lines via context manager

2014-11-28 Thread fetchinson .
On 11/28/14, Dave Angel  wrote:
> On 11/28/2014 10:04 AM, fetchinson . wrote:
>> Hi all,
>>
>> I have a feeling that I should solve this by a context manager but
>> since I've never used them I'm not sure what the optimal (in the
>> python sense) solution is. So basically what I do all the time is
>> this:
>>
>> for line in open( 'myfile' ):
>>  if not line:
>>  # discard empty lines
>>  continue
>>  if line.startswith( '#' ):
>>  # discard lines starting with #
>>  continue
>>  items = line.split( )
>>  if not items:
>>  # discard lines with only spaces, tabs, etc
>>  continue
>>
>>  process( items )
>>
>> You see I'd like to ignore lines which are empty, start with a #, or
>> are only white space. How would I write a context manager so that the
>> above simply becomes
>>
>> with some_tricky_stuff( 'myfile' ) as items:
>>  process( items )
>>
>
> I see what you're getting at, but a context manager is the wrong
> paradigm.  What you want is a generator.   (untested)
>
> def mygenerator(filename):
>  with open(filename) as f:
>  for line in f:
>  if not line: continue
>  if line.startswith('#'): continue
>  items = line.split()
>  if not items: continue
>  yield items
>
> Now your caller simply does:
>
> for items in mygenerator(filename):
>process(items)

Great, thanks a lot!

Cheers,
Daniel


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


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Do you like the current design of python.org?

2014-12-05 Thread Fetchinson .
>> Did you ever hit the "Socialize" button?

No, but it doesn't bother me.

>> Are you eager to see the latest
>> tweets when you are reading a PEP?

No, but it doesn't bother me either. You can easily block twitter
related things by a number of ways, firewalls, /etc/hosts, etc.

>> Do you run away screaming from a page
>> where nothing moves without you hitting a button? Do you appreciate the
>> choice between ten or so links to the documentation?

No, but it doesn't bother me at all.

> I dislike the new design of python.org.

I actually love it a lot! Big improvement over the previous site I think.

> The formatting of long text essays get completely mangled towards the
> bottom
> of the page, e.g.:
>
> https://www.python.org/download/releases/2.2/descrintro

It doesn't look mangled to me (firefox 22).

> Many links are broken. When you click on the broken link, it says that it
> has been reported and will be fixed, but weeks later it remains broken,
> e.g.:
>
> https://www.python.org/doc/essays/metaclasses/Eiffel.py

What makes you think that this page is ought to return actual content?

> It requires Javascript or else basic functionality fails. With Javascript,
> basic functionality fails too, but in a much more entertaining and exciting
> way, as in "I'm trying to click a button on that menu, why does the screen
> keep refreshing and hiding the menu before I can click?".

I never encountered screen refreshings that I did not trigger myself.

> I'm not terribly impressed by the design or the colour scheme, it's way
> too "web 2.0", i.e. simultaneously pretentious and dumbed down.

I think it looks great! We agree to disagree I guess; see more below.

> But most of all, I despise the menus that pop up covering what I am trying
> to read the page just because I happened to move the mouse over a button. I
> loathe the practice of stuffing content into menus instead of using links
> to individual web pages. And I hold nothing but scorn for the fact that the
> main page has a slideshow.

And what would you estimate, how many standard deviations are you away
from the average viewer of python.org in terms of these metrics (where
the metrics are like/dislike of menus, like/dislike of mouse moving,
like/dislike of unexpected browser behavior, like/dislike of links,
like/dislike of slide shows, etc.)?

> But none of that even gets close to the spitting fury I feel when I see
> the "Socialise" links. With the possible exception of the link to
> http://irc.freenode.net/ which at least has the vague excuse that there is
> a #python channel, not that a visitor to the python.org website has any way
> to learn this.

And what would you estimate, how many standard deviations are you away
from the average viewer of python.org in terms of these metrics (where
now the metrics are like/dislike of social links, social websites,
etc.)?

> Oh, I've just discovered that when you click in the search box, a perfectly
> serviceable search box, it automatically expands by about 20%, just
> because.

And that is a problem because?

> Urge to kill rising...

I didn't see the disclaimer "No living thing was harmed while typing
this email." below your message so I'm kinda worried!

Cheers,
Daniel


>> You can probably guess my opinion -- konqueror just crashed on the PEP
>> index and for some reason I'm more annoyed about the page than about the
>> browser.
>>
>>
>> PS: Is there a twitter.com something that I can block to trade black
>> friday and cyber monkey sales for a box with a good old error message?
>
> I love konquorer as a file manager, but I've come to the conclusion that
> Firefox is the absolute worst web browser available, except for all the
> rest. Firefox has a wonderful plugin, No Script, which lets you block
> Javascript and other nonsense on a per-site basis.
>
> I love me my No Script. Browsing the web is so painful without it.
>
>
>
>
> --
> Steven
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Do you like the current design of python.org?

2014-12-09 Thread Fetchinson .
>> Lest it seem like I am agreeing with these complaints, I'd like to say:
>> Either python goes this way or the way of Fortran and Cobol.
>
> You mean if Cobol had a shiny but disfunctional website we'd be using that
> instead of Python?

Why would he mean that?

If !A implies !B, it does *not* follow that A implies B.

Here A = "shiny website" and B = "success".

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Do you like the current design of python.org?

2014-12-09 Thread Fetchinson .
>> > Many links are broken. When you click on the broken link, it says that
> it
>> > has been reported and will be fixed, but weeks later it remains broken,
>> > e.g.:
>> >
>> > https://www.python.org/doc/essays/metaclasses/Eiffel.py
>>
>> What makes you think that this page is ought to return actual content?
>
> The page at https://www.python.org/doc/essays/metaclasses/ links to it. The
> fact that something on the same site links to it is a good indication that
> there ought to be something at the other end of the link.

I see, thanks, this was the missing piece of information, I didn't
know there are links to that page.

Cheers,
Daniel


> The content that is expected to be found there can still be found at the
> legacy site: http://legacy.python.org/doc/essays/metaclasses/Eiffel.py
>


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Do you like the current design of python.org?

2014-12-09 Thread Fetchinson .
On 12/9/14, Ethan Furman  wrote:
> On 12/05/2014 03:30 AM, Fetchinson responded to
>> Steven D'Aprano's rant of:
>>>
>>> Many links are broken. When you click on the broken link, it says that
>>> it
>>> has been reported and will be fixed, but weeks later it remains broken,
>>> e.g.:
>>>
>>> https://www.python.org/doc/essays/metaclasses/Eiffel.py
>>
>> What makes you think that this page is ought to return actual content?
>
> Could you rephrase that question?  The way it's worded at the moment is like
> going to a restaurant, ordering some food,
> having the plate of food put in front of you, trying to eat the food and
> getting nothing but air, and then having the
> waiter say, "What makes you think there would be actual substance?"

As Ian pointed out in another message in this thread there is a link
on python.org that points to the above page. I did not know this. So
when I read that a link is broken, to me it sounded like, hey, there
isn't any content at https://python.org/some/bla/bla/bla/random/stuff
which made me ask why does the OP think there should be anything. If
there are no links to it, it's fine, if there is one (or more) then of
course it's not fine. Apparently the case is the latter.

Cheers,
Daniel


>
>> And what would you estimate, how many standard deviations are you away
>> from the average viewer of python.org in terms of these metrics (where
>> the metrics are like/dislike of menus, like/dislike of mouse moving,
>> like/dislike of unexpected browser behavior, like/dislike of links,
>> like/dislike of slide shows, etc.)?
>
> I am reminded of the quote by Edsger W. Dijkstra:
>
>   Simplicity and elegance are unpopular because they require
>   hard work and discipline to achieve and education to be
>   appreciated.
>
> --
> ~Ethan~
>
>


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: If One Line

2014-12-25 Thread Fetchinson .
> Is it possible in python:
>
> if ((x = a(b,c)) == 'TRUE'):
>   print x

Nope. Assignment is not allowed in a conditional.

Cheers,
Daniel


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


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
https://mail.python.org/mailman/listinfo/python-list


Future of python on android

2014-12-25 Thread Fetchinson .
Hi all,

I was using sl4a for quite some time on android and it basically
worked very well although some features are missing. It looks like
sl4a is dead, although I could be wrong. Does anyone knowledgeable
have any further info on the future of sl4a? For instance it doesn't
work with android 5 and there doesn't seem to be any activity around
it for the past couple of years.

If sl4a is out, what's the preferred way of running python on android?
Guido is still working at google, right? This makes me suspect that
python is ought to be part of the android ecosystem but can't find
anything else beyond sl4a.

So what's the future proof way of writing/deploying/installing python
programs on android?

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Future of python on android

2014-12-25 Thread Fetchinson .
On 12/25/14, Billy Earney  wrote:
> try kivy, instead of sl4a http://kivy.org/
>
> I believe in the past year or two, the python foundation gave a grant to
> kivy to add further functionality..

Thanks, I didn't know about kivy but it looks quite nice, will give it a try!
Hopefully it will be around for a while and won't evaporate like sl4a :)

Cheers,
Daniel


> According to wikipedia http://en.wikipedia.org/wiki/Guido_van_Rossum  Guido
> works for dropbox.
>
> Billy
>
> On Thu, Dec 25, 2014 at 9:31 AM, Fetchinson . 
> wrote:
>
>> Hi all,
>>
>> I was using sl4a for quite some time on android and it basically
>> worked very well although some features are missing. It looks like
>> sl4a is dead, although I could be wrong. Does anyone knowledgeable
>> have any further info on the future of sl4a? For instance it doesn't
>> work with android 5 and there doesn't seem to be any activity around
>> it for the past couple of years.
>>
>> If sl4a is out, what's the preferred way of running python on android?
>> Guido is still working at google, right? This makes me suspect that
>> python is ought to be part of the android ecosystem but can't find
>> anything else beyond sl4a.
>>
>> So what's the future proof way of writing/deploying/installing python
>> programs on android?
>>
>> Cheers,
>> Daniel
>>
>>
>> --
>> Psss, psss, put it down! - http://www.cafepress.com/putitdown
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>>
>


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Future of python on android

2014-12-26 Thread Fetchinson .
On 12/26/14, Steven D'Aprano  wrote:
> Fetchinson . wrote:
>
>> Guido is still working at google, right?
>
>
> No. Google is still using Python for lots of things, but Guido is now
> working for Dropbox.
>
> https://www.python.org/~guido/

Thanks, I missed the transition. The best would of course be if the
core developer team of python would bless an android distribution and
keep it up to date just as with the linux/windows/macos python
distribution. I don't know if that will happen though. It would make
sense because the number of android installations is growing rapidly.
By the way, is there a mobile strategy on the part of the core dev
team? Maybe not android, perhaps tizen is a better target but I'd say
it would make sense if some mobile platform would officially be
targeted.

Cheers,
Daniel



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


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Future of python on android

2014-12-26 Thread Fetchinson .
On 12/26/14, iMath  wrote:
> 在 2014年12月25日星期四UTC+8下午11时31分24秒,Fetchinson .写道:
>> Hi all,
>>
>> I was using sl4a for quite some time on android and it basically
>> worked very well although some features are missing. It looks like
>> sl4a is dead, although I could be wrong. Does anyone knowledgeable
>> have any further info on the future of sl4a? For instance it doesn't
>> work with android 5 and there doesn't seem to be any activity around
>> it for the past couple of years.
>>
>> If sl4a is out, what's the preferred way of running python on android?
>> Guido is still working at google, right? This makes me suspect that
>> python is ought to be part of the android ecosystem but can't find
>> anything else beyond sl4a.
>>
>> So what's the future proof way of writing/deploying/installing python
>> programs on android?
>>
>> Cheers,
>> Daniel
>>
>>
>> --
>> Psss, psss, put it down! - http://www.cafepress.com/putitdown
>
> According this post here,
> http://plashless.wordpress.com/2014/08/19/using-pyqtdeploy0-5-on-linux-to-cross-compile-a-pyqt-app-for-android/
>
> you can use PyQt5 for Android app development !

Nice, haven't heard about it, thanks for the pointer!

Daniel


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


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python Sanity Proposal: Type Hinting Solution

2015-01-23 Thread Fetchinson .
On 1/23/15, Steven D'Aprano  wrote:
> Terry Reedy wrote:
>
>> On 1/22/2015 10:59 PM, Chris Angelico wrote:
>>> On Fri, Jan 23, 2015 at 2:22 PM, Terry Reedy  wrote:
 This idea is so brilliant that it is already an option in mypy and is
 part
 of the new type-hint proposal.  The separate type-hint files are called
 'stub files'.
>>>
>>> It's worth pointing out, too, that the idea isn't panaceaic - it's
>>> just another tool in the box. Any time you break related things into
>>> separate places, especially separate files, the tendency for them to
>>> get out of sync grows dramatically.
>>
>> The same could be said of putting tests in a separate file.
>
> I agree!
>
> Python has doctests, which live right there with the function. It also has
> assertions, which can be considered a form of continuous testing.
>
> Eiffel has syntax for design-by-contract (testing pre-conditions,
> post-conditions and invariants) there in the body of the function or
> method:
>
> https://docs.eiffel.com/book/method/et-design-contract-tm-assertions-and-exceptions#Expressing_assertions
>
>
> Contracts are a form of testing, since they are designed to be disabled in
> production. Other languages with syntactic support for Design By Contract
> include Clojure, Cobra, D, Mercury, Perl6 and Racket.
>
> Cobra is especially close to Python-like syntax, and supports unit tests as
> well:
>
>
> def sqroot(i as int) as float
> require
>i > 0
> ensure
>result > 0
> tests
>assert sqroot(25) == 5.0
> body
> ...
>
> It would be nice to be able to include at least *some* tests right there in
> the code rather than in a separate file.

I completely agree. A cobra-style type hinting implementation would
satisfy everyone who doesn't want to make function signatures noisy
(including me) and would also satisfy those who advocate for the
actual feature (type hinting) without worrying much about the
implementation detail. These two groups are overlapping by the way :)

In any case, I'm pretty sure it was said before, but I can't really
find it anywhere, can someone tell me what the rationale is for
*function signature* type hinting?

I totally get type hinting in general, but why does it have to be in
the function signature? Any reason for that specifically?

Are there lots of folks who actually insist on the type hints being in
the function signature and definitely want to see it there and not
somewhere else?

I'd say cobra-style type hinting would be great, but also something
which is property looking:

@official_type_hinting_by_the_psf( arg1: str, arg2: int, returns: bool )
def myfunction( arg1, arg2 ):
return True

I really like the idea that in python I don't have lots of choices in
many areas, certain things are dictated. The big advantage is that
when I read other people's code I know what to expect so me being
restricted is a small price to pay that is totally worth it. So I'd
come down on the side of the complainers in this case, the type
hinting pep introduces noisy and not so readable features (I
understand these are optional) which if used will make readability
suffer. If there is a pep for it, people will use it, so the fact that
it is optional is irrelevant, it will be used, so people will be faced
with it when reading other people's code, whether they like it or not.

Cheers,
Daniel




-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python Sanity Proposal: Type Hinting Solution

2015-01-23 Thread Fetchinson .
On 1/23/15, Chris Angelico  wrote:
> On Sat, Jan 24, 2015 at 12:23 AM, Fetchinson .
>  wrote:
>> In any case, I'm pretty sure it was said before, but I can't really
>> find it anywhere, can someone tell me what the rationale is for
>> *function signature* type hinting?
>>
>> I totally get type hinting in general, but why does it have to be in
>> the function signature? Any reason for that specifically?
>
> Is there any particular reason for the number of arguments to be part
> of the function signature?

I guess this is a rhetorical question :)

> I totally get the notion of declaring how
> many arguments a function takes, but why does it have to be in the
> function signature?

Ditto :)

> Data types are just as much a part of that signature as argument count
> is.

I guess this would be true if there weren't about 5 other alternative
proposals which solve the exact same problem (type hinting) by other
means. Luckily, these will be listed in the PEP soon and the reason
for rejecting them will be there as well, and so my question will
pretty much be answered there.

https://github.com/ambv/typehinting/issues/55


> You could argue that the function's return type isn't part of
> that, but that's about it.

>> If there is a pep for it, people will use it, so the fact that
>> it is optional is irrelevant...
>
> Function annotations were introduced in 2006 (Python 3.0) with PEP 3107:
>
> https://www.python.org/dev/peps/pep-3107/
>
> They were optional then, they are still optional now. Have you been
> overrun with them for the past decade? If not, why do you expect now
> to be?
>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python Sanity Proposal: Type Hinting Solution

2015-01-24 Thread Fetchinson .
On 1/24/15, Steven D'Aprano  wrote:
> Fetchinson . wrote:
>
>> On 1/23/15, Steven D'Aprano  wrote:
> [...]
>>> Cobra is especially close to Python-like syntax, and supports unit tests
>>> as well:
>>>
>>>
>>> def sqroot(i as int) as float
>>> require
>>>i > 0
>>> ensure
>>>result > 0
>>> tests
>>>assert sqroot(25) == 5.0
>>> body
>>> ...
>>>
>>> It would be nice to be able to include at least *some* tests right there
>>> in the code rather than in a separate file.
>>
>> I completely agree. A cobra-style type hinting implementation would
>> satisfy everyone who doesn't want to make function signatures noisy
>> (including me) and would also satisfy those who advocate for the
>> actual feature (type hinting) without worrying much about the
>> implementation detail. These two groups are overlapping by the way :)
>
> I don't understand this. Cobra's type-hints are right there in the function
> signature, just like Python annotations.
>
>
> # Cobra
> def sqroot(i as int) as float
>
> # Python
> def sqroot(i:int)->float:

You are right. This aspect is pretty close, what I had in mind, but
expressed myself poorly is this idiom in cobra:

def myfunc( a, b )
require
something_about( a, b )
ensure
something_about_the_return_value

Yes, type hinting and arbitrary constraints on the function arguments
and return types are different things, but closely related. I'd say it
makes sense to combine the two.

>
> Cobra's use of "as" clashes with Python. In Python, "as" is used for
> name-binding:
>
> import module as name
> with open('file') as f
> except Exception as e
>
> but apart from that minor difference, they're virtually identical.
>
>
>> In any case, I'm pretty sure it was said before, but I can't really
>> find it anywhere, can someone tell me what the rationale is for
>> *function signature* type hinting?
>
> The basic principle is that things which are related should be found
> together. The further away they are, the worse.
>
> Bad:
> - the parameter name and the type are in different files
>
> Better:
> - the parameter name and the type are only a few lines apart
>
> Best:
> - the parameter name and type are right next to each other
>
>
> The closer they are, the easier it is to keep them in sync, and the easier
> it is to see the relevant information at a glance. Putting them together
> also means that you don't have to repeat the argument name:
>
> int n
> def spam(n): ...
>
> versus
>
> def spam(n:int): ...
>
>
> Those reasons are why decorators have the syntax which they do:
>
> @decorator
> def spam(n):
> do_this()
> do_that()
> do_something_else()
>
>
> is better than the old way of using decorators:
>
> def spam(n):
> do_this()
> do_that()
> do_something_else()
>
> spam = decorator(spam)
>
>
> The decorator is only a single line away from the signature, and you don't
> have to repeat the name.
>
>
> We can see this at work in Pascal. Pascal functions have type declarations
> in the signature, and variable declarations between the signature and the
> body:
>
>
> function sqroot(arg: Integer): Real;
>   var
> x: Integer;
> y: Real;
> z: Something_Else;
>   begin
> do_this(1, 2);
> do_that(3, 4);
> do_something_else(5, 6);
> x := some expression;  { what's the type of x again? }
>   end;
>
>
> The declarations in the signature work very well and are easy to use, but
> the "var" section, not so much. Especially in large functions, the place
> where you declare the variable and its type, and the place where you first
> use it, can be separated by many lines. This makes maintenance and reading
> of the code more difficult.
>
> Newer languages like Java let you declare the variable the first time you
> use it:
>
> int x = some expression;
>
> and you don't have to search very far to find out what sort of thing x is,
> it is right there.
>
>
>
> --
> Steven
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
https://mail.python.org/mailman/listinfo/python-list


python on mobile mailing list

2015-01-28 Thread Fetchinson .
Hi all, the mobile-sig mailing list is alive:

https://mail.python.org/pipermail/mobile-sig/2015-January/thread.html

If you are interested in python on smart phones that's the place to go!

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 2 to 3 conversion - embrace the pain

2015-03-15 Thread Fetchinson .
On 3/15/15, Mark Lawrence  wrote:
> On 15/03/2015 19:05, John Nagle wrote:
>> On 3/14/2015 1:00 AM, Marko Rauhamaa wrote:
>>> John Nagle :
I'm approaching the end of converting a large system from Python 2
 to Python 3. Here's why you don't want to do this.
>>>
>>> A nice report, thanks. Shows that the slowness of Python 3 adoption is
>>> not only social inertia.
>>> Marko
>>
>>  Thanks.
>>
>>  Some of the bugs I listed are so easy to hit that I suspect those
>> packages aren't used much.  Those bugs should have been found years
>> ago.  Fixed, even.  I shouldn't be discovering them in 2015.
>>
>>  I appreciate all the effort put in by developers in fixing these
>> problems.  Python 3 is still a long way from being ready for prime
>> time, though.
>>
>>  John Nagle
>>
>
> This https://python3wos.appspot.com/ says differently.

A "package supporting python 3" is not equivalent to a "package not
introducing new bugs in its python 3 version relative to python 2" and
is also not equivalent to a "package working without issues on python
3".

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Great Math Mystery

2015-04-17 Thread Fetchinson .
>> In an altercation with the police, complying with their orders greatly
>> increases your chances of survival.
>
> Ah, the definition of a police state: where ordinary people, whether
> breaking the law or not, are forced by fear of death to obey the police at
> all times, whether the police are acting legally or not.

I think you are grossly mischaracterizing that sentence of the OP. He
simply makes an observation: in an altercation with the police,
complying with their orders greatly increases your chances of
survival. Is this observation/statement true or false? Based on
empirical data from the past 50 years (in the US and elsewhere) I'd
say it's true by a huge margin.

The OP didn't make any value judgements on this statement whether he
advocates for compliance or not, whether he encourages the
establishment of a police state or not, whether he thinks compliance
is a good thing or not.

For all we know he might be a flaming anarchist with a keen sense of
observing empirical facts.

Cheers,
Daniel



-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
https://mail.python.org/mailman/listinfo/python-list


smart scheduling for webapp tester

2015-05-12 Thread Fetchinson .
I'm looking into a robust solution for web application testing. While
selenium is great for the actual testing, I'm thinking of a scheduler
as the final piece in the pipeline. Let's say I have 4 websites that I
need to test periodically, A, B, C, D. I'd like to be able to define
things like "run the tests for site A once a day" or "run the tests
for site B twice a day indefinitely" or "run the tests for site C
twice a week between now and 2 months from now" or "run the tests for
site C once a week between May 25 and June 21".

What would be the right scheduling tool for this? I know about the
standard tools like cron, sched, etc, and first even wrote one myself
(which became of course unmanagable after a short while :)) but was
hoping a more sophisticated tool is available.

Any ideas?
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: smart scheduling for webapp tester

2015-05-12 Thread Fetchinson .
On 5/12/15, Chris Angelico  wrote:
> On Tue, May 12, 2015 at 6:31 AM, Fetchinson . 
> wrote:
>> I'm looking into a robust solution for web application testing. While
>> selenium is great for the actual testing, I'm thinking of a scheduler
>> as the final piece in the pipeline. Let's say I have 4 websites that I
>> need to test periodically, A, B, C, D. I'd like to be able to define
>> things like "run the tests for site A once a day" or "run the tests
>> for site B twice a day indefinitely" or "run the tests for site C
>> twice a week between now and 2 months from now" or "run the tests for
>> site C once a week between May 25 and June 21".
>>
>> What would be the right scheduling tool for this? I know about the
>> standard tools like cron, sched, etc, and first even wrote one myself
>> (which became of course unmanagable after a short while :)) but was
>> hoping a more sophisticated tool is available.
>
> I'm not sure what you're testing here, so I can't advise on specifics.
> If you're testing your application code, it shouldn't need any
> periodic testing at all, but if you're verifying an active database,
> it may not be necessary to involve your application. Actually, I tend
> never to verify database structures; anything that I would consider
> testing can get coded as a constraint, so it's enforced by the
> database before anything gets committed.

I'd like to test the application code. I do frequent live updates
which are mostly tested, but sometimes things go through which are
buggy and I don't detect them before pushing the change. I know, this
is bad practice, I should do my thorough testing first before going
live, but in my setup occasional bugs are not a big deal. So I find it
convenient to just push changes live fast before complicated and time
consuming testing (I do some tests of course but quick and dirty ones
only) and I'd like to catch all remaining bugs in an automated way by
periodically testing the live web application. Again, generally I
agree that this is bad practice, but my setup is an outlier and
certainly not generic (non-critical in house app with < 10 users).

> But if you really do need things on a scheduler, I would advise using
> your OS's facilities (cron, or equivalent). No need to reinvent the
> wheel, unless you want it to do something different. I've written
> several simple task schedulers, but always because they do something
> fundamentally different from a basic one (like my "Let Me Know", which
> checks my calendar and shows me a tick-down until the next significant
> event - 27 hours until I host Office Hours, at the moment). To simply
> invoke a program every 4:00 UTC, use cron and save yourself the
> trouble.

I might do this in the end and use cron indeed.

Cheers,
Daniel


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


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
https://mail.python.org/mailman/listinfo/python-list


lambda in list comprehension acting funny

2012-07-10 Thread Daniel Fetchinson
funcs = [ lambda x: x**i for i in range( 5 ) ]
print funcs[0]( 2 )
print funcs[1]( 2 )
print funcs[2]( 2 )

This gives me

16
16
16

When I was excepting

1
2
4

Does anyone know why?

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: lambda in list comprehension acting funny

2012-07-10 Thread Daniel Fetchinson
> funcs = [ lambda x: x**i for i in range( 5 ) ]
> print funcs[0]( 2 )
> print funcs[1]( 2 )
> print funcs[2]( 2 )
>
> This gives me
>
> 16
> 16
> 16
>
> When I was excepting
>
> 1
> 2
> 4
>
> Does anyone know why?

And more importantly, what's the simplest way to achieve the latter? :)


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: lambda in list comprehension acting funny

2012-07-11 Thread Daniel Fetchinson
>>> funcs = [ lambda x: x**i for i in range( 5 ) ]
>>> print funcs[0]( 2 )
>>>
>>> This gives me
>>> 16
>>>
>>> When I was excepting
>>> 1
>>>
>>> Does anyone know why?
>
>Just the way Python lambda expressions bind their variable
> references. Inner 'i' references the outer scope's 'i' variable and not
> its value 'at the time the lambda got defined'.
>
>
>> And more importantly, what's the simplest way to achieve the latter? :)
>
>Try giving the lambda a default parameter (they get calculated and
> have their value stored at the time the lambda is defined) like this:
>funcs = [ lambda x, i=i: x**i for i in range( 5 ) ]

Thanks a lot!
I worked around it by

def p(i):
return lambda x: x**i
funcs = [ p(i) for i in range(5) ]

But your variant is nicer (matter of taste of course).

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: lambda in list comprehension acting funny

2012-07-11 Thread Daniel Fetchinson
>> You should not be using lambda in this case
>> .for x in [2, 3]:
>> .funcs = [x**ctr for ctr in range( 5 )]
>> .for p in range(5):
>> .print x, funcs[p]
>> .print
>
> If you change the requirements, it's always easy to solve problems. But
> it is the wrong problem that you have solved.
>
> The problem we have been asked to solve is to create a sequence of
> function objects, so that they can be called later, when needed, *not* to
> pre-calculate the results.
>
> In this case, the most obvious solution is to store a local variable in
> each function object with the value you want.
>
> funcs = [(lambda x, i=i: x**i) for i in range(5)]
>
> creates a list of five functions:
>
> lambda x, i=0: x**i
> lambda x, i=1: x**i
> lambda x, i=2: x**i
> and so on.
>
> In this case, each function has two local variables, x and i, with i
> having a default value. The function parameter i is bound to the value of
> i when the function was created.
>
> Because parameter defaults are calculated once, when the function is
> created, this causes the value of i to stick to the newly created
> function, and we get the result we need.
>
> What happens if you don't use a parameter with a default value?
>
> funcs = [(lambda x: x**i) for i in range(5)]
>
> In this case, each function body contains one local variable, x, and one
> non-local or global variable, i.
>
> Because i is a non-local, the function doesn't store a value for it.
> Instead, the function stores a lump of data pointing to just enough of
> the environment to fetch the current value of the non-local i when
> needed. Since all five functions are in the same environment, they all
> see the same value of i when you call them, regardless of what the value
> of i was when they were created.
>
> This is little different from doing this:
>
> i = 1
> def f1(x): return x**i
>
> i = 2
> def f2(x): return x**i
>
> i = 3
> def f3(x): return x**i
>
> Is there any surprise that all three functions return the same value?
> They all point to the same global variable i. I'm not sure what it is
> about lambda that fools people into thinking that it is different (I've
> even been fooled myself!) but it is not.

Thank you Steve!
Precise and clear, as always!

Cheers,
Daniel

-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


terminate called after throwing an instance of 'CABRTException'

2012-10-02 Thread Daniel Fetchinson
I've noticed a strange thing with python lately:



Python 2.6.2 (r262:71600, Aug 21 2009, 12:23:57)
[GCC 4.4.1 20090818 (Red Hat 4.4.1-6)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> def f(): print x
...
>>> f()
terminate called after throwing an instance of 'CABRTException'
Traceback (most recent call last):
  File "", line 1, in 
  File "", line 1, in f
NameError: global name 'x' is not defined
>>>



Clearly there is a NameError because x is not defined, but what the
hell is the "terminate . 'CABRTException'" business?

I guess it has to do with abrt but abrt is not running on my system at
all. Also, if I run python2.7 with the above code I don't get the
CABRTException stuff. What is really strange is that I have all sorts
of recent files in /var/cache/abrt/pyhook-* indicating that somehow
abrt is doing things even though it is not running, for instance
chkconfig --list | grep abrt shows it off in all run levels.

What's going on?

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: terminate called after throwing an instance of 'CABRTException'

2012-10-02 Thread Daniel Fetchinson
>> I've noticed a strange thing with python lately:
>>
>>
>>
>> Python 2.6.2 (r262:71600, Aug 21 2009, 12:23:57)
>> [GCC 4.4.1 20090818 (Red Hat 4.4.1-6)] on linux2
>> Type "help", "copyright", "credits" or "license" for more information.
> def f(): print x
>> ...
> f()
>> terminate called after throwing an instance of 'CABRTException'
>> Traceback (most recent call last):
>>   File "", line 1, in 
>>   File "", line 1, in f
>> NameError: global name 'x' is not defined
>
>>
>>
>>
>> Clearly there is a NameError because x is not defined, but what the
>> hell is the "terminate . 'CABRTException'" business?
>>
>> I guess it has to do with abrt but abrt is not running on my system at
>> all. Also, if I run python2.7 with the above code I don't get the
>> CABRTException stuff. What is really strange is that I have all sorts
>> of recent files in /var/cache/abrt/pyhook-* indicating that somehow
>> abrt is doing things even though it is not running, for instance
>> chkconfig --list | grep abrt shows it off in all run levels.
>>
>> What's going on?
>
> No idea, but I'd have a look at sys.modules, and if
>
 import sys
 [name for name in sys.modules if "abrt" in name.lower()]
> []
>
> gives a non-empty result I'd investigate where the culprit is imported --
> /usr/lib/python2.6/sitecustomize.py would be the obvious candidate.

Indeed! Thanks a lot,
/usr/lib/python2.6/site-packages/sitecustomize.py was created by the
package abrt-addon-python (at least this is the fedora name) and so it
was activated by python itself completely independently from abrt
(which was not running).

Now I removed all packages called abrt-* and the problem is gone.

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


system tray or notification area in python

2012-10-16 Thread Daniel Fetchinson
Hi folks,

I'm using a stand alone window manager without gnome or kde or any
other de. But I still would like to have a system tray or notification
area and so far used stalonetray for this. Stalonetray is written in C
and is a GTK application, works all right but sometimes it doesn't.
For instance if it is killed and restarted icons don't come back, etc,
etc, there are some quirks.

So I thought I would write a brand new stand alone system tray or
notification area in python. I guess I need to use gtk bindings or
some such but don't really know what my options are.

Where would I start something like this?
Any pointers would be greatly appreciated!

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Fwd: system tray or notification area in python

2012-10-16 Thread Daniel Fetchinson
>> Hi folks,
>>
>> I'm using a stand alone window manager without gnome or kde or any
>> other de. But I still would like to have a system tray or notification
>> area and so far used stalonetray for this. Stalonetray is written in C
>> and is a GTK application, works all right but sometimes it doesn't.
>> For instance if it is killed and restarted icons don't come back, etc,
>> etc, there are some quirks.
>>
>> So I thought I would write a brand new stand alone system tray or
>> notification area in python. I guess I need to use gtk bindings or
>> some such but don't really know what my options are.
>>
>> Where would I start something like this?
>> Any pointers would be greatly appreciated!
>>
> Why not look at the source code of the current app your using to get
> an idea how that application accomplishes said task?

I actually did that already it's using the C bindings of gtk.
You might ask you I'm not modifying the code in order to achieve what
I want, well, the answer is that I'd much rather prototype something
like this in python than work immediately with gtk from C.

But I have zero experience with gui programming in python. So any
pointers would be much appreciated how to implement a system tray in
python. Gtk is I guess just one option, one could use other stuff from
python but I wouldn't know what the simplest approach is.

Cheers,
Daniel


> You could always use raw X11 libs but leveraging something like Gtk or
> Qt/KDE would probably be much easier.



-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown



-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fwd: system tray or notification area in python

2012-10-17 Thread Daniel Fetchinson
 Hi folks,
 So I thought I would write a brand new stand alone system tray or
 notification area in python. I guess I need to use gtk bindings or
 some such but don't really know what my options are.

 Where would I start something like this?
 Any pointers would be greatly appreciated!

>>> Why not look at the source code of the current app your using to get
>>> an idea how that application accomplishes said task?
>>
>> I actually did that already it's using the C bindings of gtk.
>
> I think you are mistaken - if its this one:
>   http://stalonetray.sourceforge.net/

Yes, that's it.

> I had a quick look into the sources, it does not use gtk at all, it uses
> low level X11 calls. Programming in this way is very tedious.

Sorry, you are right. I was mixing things up, I just remembered it was
gtk, apparently it's not.

>> But I have zero experience with gui programming in python. So any
>> pointers would be much appreciated how to implement a system tray in
>> python. Gtk is I guess just one option, one could use other stuff from
>> python but I wouldn't know what the simplest approach is.
>
> I'm not sure it is even possible. "Usual" GUI applications just need to
> request certain features from their window manager such as the setting
> the program icon or requesting a certain position on the screen. That is
> what is implemented in the usual toolits like Tk, QT, and gtk.

That is my impression as well, tk, qt, etc, won't be good for this
task but I thought there are some sort of X bindings in python that
will make writing low level X applications in python possible. For
instance a system tray :)

> A window manager, on the other hand, must be able to recieve and
> interpret these messages. For a system tray, they are described here:
>
> http://standards.freedesktop.org/systemtray-spec/systemtray-spec-0.3.html
>
> I have not studied the whole interface of the aforementioned toolkits,
> but I suspect that there is no way around writing low level Xlib code in
> order to recieve these messages.

Right, but nobody wrote Xlib bindings for python?

> Don't take it wrong, but when you write that you have no experience with
> GUI programming, I'd start another projet first - I think you will have
> a tough way to succeed with this project.

I certainly wouldn't start with Xlib in C, but if python bindings
would be available that would make life much easier.

Cheers,
Daniel


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


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: system tray or notification area in python

2012-10-17 Thread Daniel Fetchinson
>> So I thought I would write a brand new stand alone system tray or
>> notification area in python. I guess I need to use gtk bindings or
>> some such but don't really know what my options are.
>>
>> Where would I start something like this?
>> Any pointers would be greatly appreciated!
>>
> Why not look at the source code of the current app your using to get
> an idea how that application accomplishes said task?

 I actually did that already it's using the C bindings of gtk.
>>>
>>> I think you are mistaken - if its this one:
>>> http://stalonetray.sourceforge.net/
>>
>> Yes, that's it.
>>
>>> I had a quick look into the sources, it does not use gtk at all, it uses
>>> low level X11 calls. Programming in this way is very tedious.
>>
>> Right, but nobody wrote Xlib bindings for python?
>
> Erm, Google is your friend: "python xlib" turns up
>
>   http://python-xlib.sourceforge.net/
>
> as well as
>
>   http://plwm.sourceforge.net/
>
> which is pretty close to what you are trying to do.

Great, thanks a lot!

>>> Don't take it wrong, but when you write that you have no experience with
>>> GUI programming, I'd start another projet first - I think you will have
>>> a tough way to succeed with this project.
>>
>> I certainly wouldn't start with Xlib in C, but if python bindings
>> would be available that would make life much easier.
>>
>
> Everything is easier in python:) because usually python libs are
> designed with OO and ease of use in mind. Beware that this will be much
> tougher than using gtk&friends.

I guess so :) But it's a good excuse to get familiar with X :)

Cheers,
Daniel


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


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: can we append a list with another list in Python ?

2012-10-23 Thread Daniel Fetchinson
> can we append a list with another list in Python ? using the normal routine
> syntax but with a for loop ??

x = [1,2,3]
y = [10,20,30]
x.extend( y )
print x

this will give you [1,2,3,10,20,30] which I guess is what you want.

Cheers,
Daniel



-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


assign only first few items of a tuple/list

2012-12-04 Thread Daniel Fetchinson
Hi folks, I swear I used to know this but can't find it anywhere.
Say I have a list x = [ 1,2,3,4,5 ] and only care about the first two items.
I'd like to assign the first two items to two variables, something like,

a, b, _ = x

but the above will not work, of course, but what is the common idiom
for this that does?

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


unpacking first few items of iterable

2012-12-13 Thread Daniel Fetchinson
Hi folks, I swear I used to know this but can't find it anywhere:

What's the standard idiom for unpacking the first few items of an
iterable whose total length is unknown?

Something like

a, b, c, _ = myiterable

where _ could eat up a variable number of items, in case I'm only
interested in the first 3 items?

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: unpacking first few items of iterable

2012-12-13 Thread Daniel Fetchinson
>>Hi folks, I swear I used to know this but can't find it anywhere:
>>
>>What's the standard idiom for unpacking the first few items of an
>>iterable whose total length is unknown?
>>
>>Something like
>>
>>a, b, c, _ = myiterable
>>
>>where _ could eat up a variable number of items, in case I'm only
>>interested in the first 3 items?
>
> If you're using python3, you can simply do:
>
> a, b, c, *rest = myiterable

Thanks, sounds great, how about python2?

-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: unpacking first few items of iterable

2012-12-13 Thread Daniel Fetchinson
 Hi folks, I swear I used to know this but can't find it anywhere:

 What's the standard idiom for unpacking the first few items of an
 iterable whose total length is unknown?

 Something like

 a, b, c, _ = myiterable

 where _ could eat up a variable number of items, in case I'm only
 interested in the first 3 items?
>>> If you're using python3, you can simply do:
>>>
>>> a, b, c, *rest = myiterable
>> Thanks, sounds great, how about python2?
>>
>
> If you know the sequence has at least n items, you
> can do a, b, c = seq[:3]

Yeah, that's probably the simplest, without all the fancy stuff :)

Cheers,
Daniel



-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


pygnomevfs get_local_path_from_uri replacement

2012-12-22 Thread Daniel Fetchinson
Hi folks, I realize this is slightly off topic and maybe belongs to a
gnome email list but it's nevertheless python:

I use an old python program that was written for gnome 2 and gtk 2 and
uses the function get_local_path_from_uri. More specifically it uses
gnomevfs.get_local_path_from_uri.

Now with gnome 3 the module pygnomevfs does not exist anymore and
after checking the source for pygnomevfs it turns out it's written in
C using all the header files and stuff from gnome 2. So I can't just
lift it from the source. I was hoping it's pure python in which case I
could have simply lifted it.

Does anyone know what a good replacement for get_local_path_from_uri
is? Is there a gtk/gnome/etc related python package that contains it
which would work with gnome 3? Or a totally gnome-independent python
implementation?

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pygnomevfs get_local_path_from_uri replacement

2012-12-22 Thread Daniel Fetchinson
>> Hi folks, I realize this is slightly off topic and maybe belongs to a
>> gnome email list but it's nevertheless python:
>>
>> I use an old python program that was written for gnome 2 and gtk 2 and
>> uses the function get_local_path_from_uri. More specifically it uses
>> gnomevfs.get_local_path_from_uri.
>>
>> Now with gnome 3 the module pygnomevfs does not exist anymore and
>> after checking the source for pygnomevfs it turns out it's written in
>> C using all the header files and stuff from gnome 2. So I can't just
>> lift it from the source. I was hoping it's pure python in which case I
>> could have simply lifted it.
>>
>> Does anyone know what a good replacement for get_local_path_from_uri
>> is? Is there a gtk/gnome/etc related python package that contains it
>> which would work with gnome 3? Or a totally gnome-independent python
>> implementation?
>
> The commit
> https://mail.gnome.org/archives/commits-list/2009-May/msg05733.html
> suggests that get_local_path_from_uri() might have been defined as
> (taking slight liberties):
> gnome_vfs_unescape_string(remove_host_from_uri(uri))
> Assuming these functions do the "obvious" things implied by their
> names (you can probably chase down the Gnome VFS source or docs to
> check; I don't care enough to bother), given a general URI
> "protocol://host/path", it presumably returns either
> "protocol:///path" (`protocol:` likely being "file:" in this case) or
> "/path", in either case with `path` having been un-percent-escaped.
> The latter transform can be done using
> http://docs.python.org/2/library/urllib.html#urllib.unquote
>
> Alternately, you might call the Gnome VFS C API directly via
> http://docs.python.org/2/library/ctypes.html

Thanks, ctypes is actually a great idea, I should have thought about that.
In the meantime I use the simple function

def get_local_path_from_uri( uri ):

return uri.split( '//' )[1]


and it seems to work. In the program the function is always called in
a try: except: block so if anything is not okay it will get caught, I
don't have to catch exceptions inside the function.

Cheers,
Daniel



-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: New to python, do I need an IDE or is vim still good enough?

2012-12-27 Thread Daniel Fetchinson
> I'm new to python, got 10-20 years perl and C experience, all gained on unix
> alike machines hacking happily in vi, and later on in vim.
>
> Now it's python, and currently mainly on my kubuntu desktop.

Welcome to the club!

> Do I really need a real IDE, as the windows guys around me say I do, or will
> vim, git, make and other standalone tools make it the next 20 years too for
> me?

Sure they will!

> Oh, by the way, after 7 days I'm completely in love with this python thing.

Again, welcome to the club!

> I should have made the switch much earlier!

Indeed..

BTW, I also use vim only,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


format a measurement result and its error in "scientific" way

2012-02-15 Thread Daniel Fetchinson
Hi folks, often times in science one expresses a value (say
1.03789291) and its error (say 0.00089) in a short way by parentheses
like so: 1.0379(9)

One can vary things a bit, but let's take the simplest case when we
only keep 1 digit of the error (and round it of course) and round the
value correspondingly. I've been searching around for a simple
function that would take 2 float arguments and would return a string
but didn't find anything although something tells me it's been done a
gazillion times.

What would be the simplest such function?

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: format a measurement result and its error in "scientific" way

2012-02-16 Thread Daniel Fetchinson
>> Hi folks, often times in science one expresses a value (say
>> 1.03789291) and its error (say 0.00089) in a short way by parentheses
>> like so: 1.0379(9)
>>
>> One can vary things a bit, but let's take the simplest case when we
>> only keep 1 digit of the error (and round it of course) and round the
>> value correspondingly. I've been searching around for a simple
>> function that would take 2 float arguments and would return a string
>> but didn't find anything although something tells me it's been done a
>> gazillion times.
>>
>> What would be the simplest such function?
>
> Well, this basically works:
>
 def format_error(value, error):
> ... precision = int(math.floor(math.log(error, 10)))
> ... format = "%%.%df(%%d)" % max(-precision, 0)
> ... return format % (round(value, -precision),
> ...  int(round(error / 10 ** precision)))
> ...
 format_error(1.03789291, 0.00089)
> '1.0379(9)'
>
> Note that "math.floor(math.log(error, 10))" may return the wrong
> decimal precision due to binary floating point rounding error, which
> could produce some strange results:
>
 format_error(10378929, 1000)
> '10378900(10)'
>
> So you'll probably want to use decimals instead:
>
> def format_error(value, error):
> value = decimal.Decimal(value)
> error = decimal.Decimal(error)
> value_scale = value.log10().to_integral(decimal.ROUND_FLOOR)
> error_scale = error.log10().to_integral(decimal.ROUND_FLOOR)
> precision = value_scale - error_scale
> if error_scale > 0:
> format = "%%.%dE" % max(precision, 0)
> else:
> format = "%%.%dG" % (max(precision, 0) + 1)
> value_str = format % value.quantize(decimal.Decimal("10") **
> error_scale)
> error_str = '(%d)' % error.scaleb(-error_scale).to_integral()
> if 'E' in value_str:
> index = value_str.index('E')
> return value_str[:index] + error_str + value_str[index:]
> else:
> return value_str + error_str
>
 format_error(1.03789291, 0.00089)
> '1.0379(9)'
 format_error(103789291, 1000)
> '1.03789(1)E+08'
>
> I haven't tested this thoroughly, so use at your own risk. :-)

Thanks a lot, this indeed mostly works, except for cases when the
error needs to be rounded up and becomes two digits:

>>> format_error( '1.34883', '0.0098' )
'1.349(10)'

But in this case I'd like to see 1.35(1)

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: format a measurement result and its error in "scientific" way

2012-02-16 Thread Daniel Fetchinson
On 2/16/12, Ian Kelly  wrote:
> On Thu, Feb 16, 2012 at 1:36 AM, Daniel Fetchinson
>  wrote:
>>>> Hi folks, often times in science one expresses a value (say
>>>> 1.03789291) and its error (say 0.00089) in a short way by parentheses
>>>> like so: 1.0379(9)
>>>>
>>>> One can vary things a bit, but let's take the simplest case when we
>>>> only keep 1 digit of the error (and round it of course) and round the
>>>> value correspondingly. I've been searching around for a simple
>>>> function that would take 2 float arguments and would return a string
>>>> but didn't find anything although something tells me it's been done a
>>>> gazillion times.
>>>>
>>>> What would be the simplest such function?
>>>
>>> Well, this basically works:
>>>
>>>>>> def format_error(value, error):
>>> ... precision = int(math.floor(math.log(error, 10)))
>>> ... format = "%%.%df(%%d)" % max(-precision, 0)
>>> ... return format % (round(value, -precision),
>>> ...  int(round(error / 10 ** precision)))
>>> ...
>>>>>> format_error(1.03789291, 0.00089)
>>> '1.0379(9)'
>>>
>>> Note that "math.floor(math.log(error, 10))" may return the wrong
>>> decimal precision due to binary floating point rounding error, which
>>> could produce some strange results:
>>>
>>>>>> format_error(10378929, 1000)
>>> '10378900(10)'
>>>
>>> So you'll probably want to use decimals instead:
>>>
>>> def format_error(value, error):
>>> value = decimal.Decimal(value)
>>> error = decimal.Decimal(error)
>>> value_scale = value.log10().to_integral(decimal.ROUND_FLOOR)
>>> error_scale = error.log10().to_integral(decimal.ROUND_FLOOR)
>>> precision = value_scale - error_scale
>>> if error_scale > 0:
>>> format = "%%.%dE" % max(precision, 0)
>>> else:
>>> format = "%%.%dG" % (max(precision, 0) + 1)
>>> value_str = format % value.quantize(decimal.Decimal("10") **
>>> error_scale)
>>> error_str = '(%d)' % error.scaleb(-error_scale).to_integral()
>>> if 'E' in value_str:
>>> index = value_str.index('E')
>>> return value_str[:index] + error_str + value_str[index:]
>>> else:
>>> return value_str + error_str
>>>
>>>>>> format_error(1.03789291, 0.00089)
>>> '1.0379(9)'
>>>>>> format_error(103789291, 1000)
>>> '1.03789(1)E+08'
>>>
>>> I haven't tested this thoroughly, so use at your own risk. :-)
>>
>> Thanks a lot, this indeed mostly works, except for cases when the
>> error needs to be rounded up and becomes two digits:
>>
>>>>> format_error( '1.34883', '0.0098' )
>> '1.349(10)'
>>
>> But in this case I'd like to see 1.35(1)
>
> A small adjustment to the scale fixes that.  Also tidied up the string
> formatting part:
>
> import decimal
>
> def format_error(value, error):
> value = decimal.Decimal(value)
> error = decimal.Decimal(error)
> error_scale = error.adjusted()
> error_scale += error.scaleb(-error_scale).to_integral().adjusted()
> value_str = str(value.quantize(decimal.Decimal("1E%d" % error_scale)))
> error_str = '(%d)' % error.scaleb(-error_scale).to_integral()
> if 'E' in value_str:
> index = value_str.index('E')
> return value_str[:index] + error_str + value_str[index:]
> else:
> return value_str + error_str
>
> Cheers,
> Ian

Thanks, it's simpler indeed, but gives me an error for value=1.267, error=0.08:

Traceback (most recent call last):
  File "/home/fetchinson/bin/format_error", line 26, in 
print format_error( sys.argv[1], sys.argv[2] )
  File "/home/fetchinson/bin/format_error", line 9, in format_error
error_scale += error.scaleb( -error_scale ).to_integral(  ).adjusted(  )
  File "/usr/lib64/python2.6/decimal.py", line 3398, in scaleb
ans = self._check_nans(other, context)
  File "/usr/lib64/python2.6/decimal.py", line 699, in _check_nans
other_is_nan = other._isnan()
AttributeError: 'int' object has no attribute '_isnan'

Which version of python are you using?

Cheers,
Daniel



-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: format a measurement result and its error in "scientific" way

2012-02-17 Thread Daniel Fetchinson
>> Thanks, it's simpler indeed, but gives me an error for value=1.267,
>> error=0.08:
>>
>> Traceback (most recent call last):
>>  File "/home/fetchinson/bin/format_error", line 26, in 
>>print format_error( sys.argv[1], sys.argv[2] )
>>  File "/home/fetchinson/bin/format_error", line 9, in format_error
>>error_scale += error.scaleb( -error_scale ).to_integral(  ).adjusted(
>>  )
>>  File "/usr/lib64/python2.6/decimal.py", line 3398, in scaleb
>>ans = self._check_nans(other, context)
>>  File "/usr/lib64/python2.6/decimal.py", line 699, in _check_nans
>>other_is_nan = other._isnan()
>> AttributeError: 'int' object has no attribute '_isnan'
>>
>> Which version of python are you using?
>
> 2.7.1.  At a guess, it's failing because scaleb() (which was new in
> 2.6) is buggily expecting a decimal argument, but adjusted() returns an int.
> Convert the results of the two adjusted() calls to decimals, and I
> think it should be fine.

Great, with python 2.7 it works indeed!

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: format a measurement result and its error in "scientific" way

2012-02-17 Thread Daniel Fetchinson
>> Hi folks, often times in science one expresses a value (say
>> 1.03789291) and its error (say 0.00089) in a short way by parentheses
>> like so: 1.0379(9)
>
> Before swallowing any Python solution, you should
> realize, the values (value, error) you are using are
> a non sense :
>
> 1.03789291 +/- 0.00089
>
> You express "more precision" in the value than
> in the error.

My impression is that you didn't understand the original problem:
given an arbitrary value to arbitrary digits and an arbitrary error,
find the relevant number of digits for the value that makes sense for
the given error. So what you call "non sense" is part of the problem
to be solved.

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fetching data from a HTML file

2012-03-23 Thread Daniel Fetchinson
On 3/23/12, Sangeet  wrote:
> Hi,
>
> I've got to fetch data from the snippet below and have been trying to match
> the digits in this to specifically to specific groups. But I can't seem to
> figure how to go about stripping the tags! :(
>
> Sum class="green">24511 align='center'>02561.496
> [min]
> 

Try beautiful soup: http://www.crummy.com/software/BeautifulSoup/

> Actually, I'm working on ROBOT Framework, and haven't been able to figure
> out how to read data from HTML tables. Reading from the source, is the best
> (read rudimentary) way I could come up with. Any suggestions are welcome!
>
> Thanks,
> Sangeet
> --
> http://mail.python.org/mailman/listinfo/python-list
>


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Open Source: you're doing it wrong - the Pyjamas hijack

2012-05-09 Thread Daniel Fetchinson
It's also quite ironic that the initial complaining started from how
the domain name www.pyjs.org is not available only pyjs.org is. At the
same time the Rebel Chief's listed domain name on github, see
https://github.com/xtfxme, gives you a server not found:
http://the.xtfx.me/ :)



On 5/9/12, anth...@xtfx.me  wrote:
> On Tuesday, May 8, 2012 4:10:13 AM UTC-5, james hedley wrote:
>> Agreed with pretty much all of that. It's third-world politics, lurching
>> from one dictator to another. Risinger seems to have banned all discussion
>> of the subject from the list too, I'm not posting anymore because I don't
>> want to give him an excuse to wield his newly found banhammer.
>
> hello James,
>
> i'm not really sure what you're referring too ... you appear to be making
> these things up.  i have not banned anything, or even alluded to it,
> whatsoever.  i asked that one specific mail not be commented upon, as a
> request; perhaps this is the dreaded bannhammer you speak of?
>
> reading your accounts strewn about is interesting, what exactly are *your*
> motives?  a simple curiosity, nothing more.
>
> your comparison to gov'ts is pretty skewed i would say, you know this as
> well as i. regardless of what you think or know of me, i have a permanent
> track record of being pretty fair and receptive to virtually anything, and
> am involved in a wide range of projects.  Luke is a talented developer,
> there is no doubt of this, but he is one of the most socially inept persons
> i have ever encountered.  leading your users to statements such as this:
>
> https://groups.google.com/forum/?fromgroups#!searchin/pyjamas-dev/credo/pyjamas-dev/xzp4CCWhJN4/nQ3-emtYFVgJ
>
> ... dozens of times on several occasions, is truly incredible.  other such
> behavior, eg. being the only person in the history of the webkit project to
> ever be *ejected* from contributing or communicating *at all*, is further
> testament to the deficiencies provoking this maneuver.
>
> however, i have no interest in comparing or being compared.  go read my
> notes again; i have a high level of respect for Luke in many capacities, and
> this has not changed.
>
> lets make one thing perfectly clear; you are not the only one who cares of
> this project or wishes it to succeed.  mistakes were made.  problems were
> had.  the decisions however, stands.
>
>> But yeah, a lot of the commentary from the pro-rebel side ( not that any
>> of them admit they had anything to do with it ) really does come across as
>> being ill-informed and childish.
>
> indeed, you have witnessed little chatter.  however, barring your belief of
> such, i had received dozens of notes thanking me and attesting to a renewed
> impetus for action.  the original goal was to purchase a domain and fork --
> i made this very clear in my notes -- `uxpy.net`.  however, the most
> respectable member of the commit IMO convinced me otherwise.  names names,
> yes you want names?  sorry :-(.  alas, he, myself, and numerous others are
> still active and moving forward.  the list is actually approaching 100 ...
> not the "4-5" you so graciously quoted.  i am simply the point man willing
> to stand the flurry.
>
> likewise, i did not "convince" the domain holder to give me the domain.  not
> only was he already aware prior to me approaching him -- list member,
> passive -- he was more that willing to assist in reinstating the projects
> foundations and direction.  he *was* the person who "left Luke in charge"
> ... why do you think he was the owner? as far as im concerned, the domain
> was already "hijacked"; this was, in good faith, intended as remedy.
>
> this was not a easy or light decision, the dissonance exists to this day.
> the idea was to retain Luke, but he decided to play legal threats as the
> first card (which i'm afraid can only backfire), before he even knew of the
> domain changes.  hge is not a victim here, nor is anyone else.  so please,
> show some cognitive capacity by realizing this is not as black-and-white as
> you's like it to be.
>
> when you decide to include yourself -- sooner, or later -- you are more than
> welcome.
>
> @alex23 ... try reading a bit further.  as a human i am subject to annoyance
> and frustration.  i probably shouldn't have started the message in that
> manner, but the absurdity and absolute inaccurate statements being made were
> rather upsetting.  you will note that i make it perfectly clear that Luke is
> a fantastic developer, and a great part of the team.  this of course has
> neither waned nor faltered.
>
> i encourage anyone willing to take the time to consult the archives,
> pyjamas' and elsewhere, as they are the only path to proper answers.  this
> will impact the project in both known and untold ways, but we have a great
> number of minds willing to push beyond.
>
> --
>
> C Anthony
> --
> http://mail.python.org/mailman/listinfo/python-list
>


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/l

Re: Open Source: you're doing it wrong - the Pyjamas hijack

2012-05-09 Thread Daniel Fetchinson
> the original goal was to purchase a domain and fork --
> i made this very clear in my notes -- `uxpy.net`.  however, the most
> respectable member of the commit IMO convinced me otherwise.

(I'm a total outsider, never used pyjs.)

Anthony, you never explained what the reasoning behind the advice of
the "most respectable member of the commit" was. Why didn't you
finally buy the new domain name, pick a new name, and fork the
project?

As it stands now the obvious answer for most people is "because it
looked easier to just take over than to build a new community, new
infrastructure, new fame, etc, and I sure as hell like to take the
easy road as opposed to the hard road".

Until you clearly explain your reasoning for taking over as opposed to
forking, the default answer is the above one.

Cheers,
Daniel

-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Open Source: you're doing it wrong - the Pyjamas hijack

2012-05-15 Thread Daniel Fetchinson
> Blatantly the pyjs ownership  change turned out to be an awkward
> operation (as reactions on that ML show it), but a fork could also have
> very harmfully "split" pyjs-interested people, so all in all I don't
> think there was a perfect solution - dictatorships never fall harmlessly.

You say "fork could also have very harmfully split", what harms are
you referring to?
In the open source world there were tons of forks of projects and it
proved to be a useful mechanism for resolving serious management
issues.  On the other hand the kind of hostile takeover that happened
with pyjs is virtually unparalleled in the open source world. What
made you think such a unique operation will be less harmful than the
other which has already been tried many times?

> 
> | Please get this absolutely clear in your head: that  |
> | you do not "understand" my reasoning is completely and utterly   |
> | irrelevant.  i understand *your* reasoning; i'm the one making the   |
> | decisions, that's my role to understand the pros and cons.  i make a |
> | decision: that's the end of it.  |
> | You present reasoning to me: i weight it up, against the other   |
> | reasoning, and i make a decision.  you don't have to understand that |
> | decision, you do not have to like that decision, you do not have to  |
> | accept that decision.|
> 

Again, if you don't like the lead developer just fork the project,
come up with a new name, new website and new infrastructure and start
building a new community. Why didn't the rebels do that?

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Namespace hack

2012-05-24 Thread Daniel Fetchinson
> >From the Zen of Python ("import this"):
>
> Namespaces are one honking great idea -- let's do more of those!
>
>
> Inspired by this, I have a decorator that abuses function closures to
> create a namespace type with the following properties:
>
> - all methods are static methods that do not take a "self" parameter;
>
> - methods can see "class variables";
>
> - external callers can see selected methods and attributes.
>
>
> An example may make this clearer.
>
> In a regular class:
>
> class C:
> x = 42
> def spam(self, y):
> return self.x + y
> def ham(self, z):
> return self.spam(z+1)
>
>
> Notice that the class attribute x is visible to the outside caller, but
> methods spam and ham cannot see it except by prefixing it with a
> reference to "self".
>
> Here's an example using my namespace hack example:
>
> @namespace
> def C():  # Abuse nested functions to make this work.
> x = 42
> def spam(y):
> return x + y
> def ham(z):
> return spam(z+1)
> return (spam, ham)  # Need an explicit return to make methods visible.
>
> However, class attribute x is not exposed. You may consider this a
> feature, rather than a bug. To expose a class attribute, define it in the
> outer function argument list:
>
> @namespace
> def C(x=42):
> def spam(y):
> return x + y
> def ham(z):
> return spam(z+1)
> return (spam, ham)
>
>
>
> And in use:
>
 C.x
> 42
 C.spam(100)
> 142
 C.ham(999)
> 1042
>
>
>
> Here's the namespace decorator:
>
> import inspect
>
> def namespace(func):
>   spec = inspect.getargspec(func)
>   ns = {'__doc__': func.__doc__}
>   for name, value in zip(spec.args, spec.defaults or ()):
>   ns[name] = value
>   function = type(lambda: None)
>   exported = func() or ()
>   try:
>   len(exported)
>   except TypeError:
>   exported = (exported,)
>   for obj in exported:
>   if isinstance(obj, function):
>   ns[obj.__name__] = staticmethod(obj)
>   else:
>   raise TypeError('bad export')
>   Namespace = type(func.__name__, (), ns)
>   return Namespace()
>
>
> Have fun!

Funny, you got to the last line of "import this" but apparently
skipped the second line:

Explicit is better than implicit.

And you didn't even post your message on April 1 so no, I can't laugh
even though I'd like to.

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Namespace hack

2012-06-05 Thread Daniel Fetchinson
>> Funny, you got to the last line of "import this" but apparently
>> skipped the second line:
>>
>> Explicit is better than implicit.
>>
>> And you didn't even post your message on April 1 so no, I can't laugh
>> even though I'd like to.
>
> Can you be less condescending?

Of course! :)

Anyway, the point I was trying to make is that Steve's example is
kinda cool but only as a funny exercise and not something for real
life. Let's toy with python kinda thing, which is always welcome but
with a big fat asterisk saying "don't try this at home kids".

Cheers,
Daniel



-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: New member intro and question

2011-06-18 Thread Daniel Fetchinson
> 
> I'm a new list member from the United States. Long time programmer,
> fairly new to Python and absolutely loving it so far! I'm 36, live in
> Oklahoma, and own a small Linux software development and consulting
> firm. Python has made my life a *lot* easier and, the more I learn,
> the easier it gets. Simply blown away.
> 
>
> Now, for my question: I'm taking on a project that will run on plug
> computers and I'm thinking about using Python to do it. It seems like
> a really attractive option over C/C++ and I think it would cut down
> the dev time immensely. I know a scaled down version of Debian can run
> on the computer but I'm wondering about Python.
>
> Has anyone ever used Python to develop for extremely limited resource
> computers like this? Specifically, I'm going to be using the DreamPlug
> (http://www.geek.com/articles/gadgets/dreamplug-puts-a-1-2ghz-arm-pc-in-a-power-outlet-2011022/)
> which isn't too shabby but I wonder if it will work.

The netbook I use with fedora linux and basically every major python
release from 2.4 to 3.2 has more limited resources :)

So yes, python would run on your gadget no problem.

Cheers,
Daniel



-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


web hosting, first hand experiences?

2011-07-03 Thread Daniel Fetchinson
Hi folks, I know this comes up regularly but the thing is that the
quality of service changes also quite regularly with many of the
hosting companies. What's currently the best option for shared hosting
of a turbogears application? I'm thinking of dreamhost and webfaction
does anyone have any recent experiences with these two? Or others?

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


Re: web hosting, first hand experiences?

2011-07-04 Thread Daniel Fetchinson
>> Hi folks, I know this comes up regularly but the thing is that the
>> quality of service changes also quite regularly with many of the
>> hosting companies. What's currently the best option for shared hosting
>> of a turbogears application? I'm thinking of dreamhost and webfaction
>> does anyone have any recent experiences with these two? Or others?
>>
>> Cheers,
>> Daniel
>>
>
> Hi Daniel,
>
> I can wholeheartedly recommend WebFaction.  I currently have an account
> running 3 different CherryPy applications (so TurboGears shouldn't pose
> any problems), and apart from initial teething problems, they have been
> running for months without interruption.  As well as an excellent
> control panel, they give you full Linux command-line access to your
> site(s).  The level of support is as good as you will get anywhere
> (short of having experts with you in the office!), and they know a huge
> amount about Python web applications.  Nothing seems to be too much
> trouble for them.  They also provide a 60-day money-back guarantee, so
> you can try-before-you-buy.
>
> Best wishes,
> Alan Harris-Reid

Thanks for all the responses, based on the feedback I'll go with
webfaction I guess.
They were my first choice anyway but wanted to double check with
people in the know about their current situation.

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


OT

2011-08-19 Thread Daniel Fetchinson
I'll be 59 in a couple of months.

-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Suggestion Reqd for Designing a Website in Python

2011-02-25 Thread Daniel Fetchinson
>> >I have developed one big Machine Learning software a Machine
>> >Translation system in Python.
>> >Now, I am thinking to make a User Interface of it and upload it in a
>> >web site.
>>
>> Do you mean you want people to download this from a web site as an
>> executable, and then run it locally on their computers?  Or do you mean
>> you
>> want people to use this as a web site, using their web browsers?  The
>> answers are very different.
>>
>> >My questions are:
>> >(i) For Designing an interface I am choosing Tkinter. Is it fine?
>> >(ii) How to connect this interface with my Tkinter based interface -
>> >should I have to recode the whole system?
>> >(iii) After designing I want to upload now how to do the server side
>> >scripting?
>>
>> Question (i) implies that you want the first option (download an
>> executable
>> and run it).  Question (iii) implies the second (that you want your app to
>> run on a web server so people use it through your browser).  Please
>> clarify.
>> --
>> Tim Roberts, t...@probo.com
>> Providenza & Boekelheide, Inc.
>
> Thank you for your kind reply.
> I want to design an interface like Google Translate. So that users can
> paste text (of any length)-or may browse files which can be uploaded,
> and one user interface for filling up form, so that attached files
> after translation may be sent back to the given e-mail id as an
> attached file(.pdf/.txt).
> Best Regards,
> Subhabrata.

In this case you are looking for a web application framework. There
are many written in python, a good place to start would be:

http://wiki.python.org/moin/WebFrameworks

My personal opinion is that the 3 top frameworks to consider are: (1)
django (2) turbogears (3) web2py. You need to decide for yourself
which one use choose, you may even choose something other than these
3, there are tons more.

Cheers,
Daniel



-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fun python 3.2 one-liner

2011-04-05 Thread Daniel Fetchinson
>> what is the character limit on a one liner :P.
>
> For PEP 8 compliance, 80 characters. :-)

Yeah, but we don't live in the 80's or 90's anymore and our screens
can support xterms (or let alone IDE widows) much wider than 80
characters. I'm using 140 for python these days. Seriously, who would
want to limit him/herself to 80 characters in 2011?

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fun python 3.2 one-liner

2011-04-05 Thread Daniel Fetchinson
 what is the character limit on a one liner :P.
>>>
>>> For PEP 8 compliance, 80 characters. :-)
>>
>> Yeah, but we don't live in the 80's or 90's anymore and our screens can
>> support xterms (or let alone IDE widows) much wider than 80 characters.
>> I'm using 140 for python these days. Seriously, who would want to limit
>> him/herself to 80 characters in 2011?
>
> Seriously, or is that a rhetorical question?

Rhetorical :)

What it intended to demonstrate is that it is possible to rationalize
ancient habits which have their origins in particular circumstances of
those ancient times but actually nothing necessitates them today other
than the momentum built around them during their lifetime (which is a
pretty strong argument for them by the way).

Cheers,
Daniel


> People who like to have two source files side-by-side on a standard
> sized monitor, or three on a wide-screen monitor.
>
> People who need to read or edit source code on a virtual terminal rather
> than in a GUI console app.
>
> People who print out source code to read later.
>
> People with poor vision who need to use a significantly larger sized
> characters, and therefore can't fit as many on a line.
>
> People who might want to email code snippets without having them
> inconveniently wrapped by the mail client.
>
> People who don't like reading really long, overly complex, lines, and
> prefer to keep lines short for readability.
>
> And most importantly... people who want to have their code accepted into
> the Python standard library.
>
>
> Personally, I find that the discipline of keeping to 80 characters is
> good for me. It reduces the temptation of writing obfuscated Python one-
> liners when two lines would be better. The *only* time it is a burden is
> when I write doc strings, and even then, only a small one.
>
>
>
> --
> Steven
> --
> http://mail.python.org/mailman/listinfo/python-list
>


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Common practice for multiple python versions sharing 3rd party modules

2011-04-09 Thread Daniel Fetchinson
Hi folks,

In order to test my own modules with various python versions I've
installed python 2.4, 2.5, 2.6, 2.7, 3.1, 3.2. The original
installation on my fedora box was 2.6 and all 3rd party modules so far
were installed under /usr/lib/python2.6/site-packages. Since now the
executable 'python' points to python 2.7 and lot of programs have
#!/usr/bin/env python at the top, these programs try to use 2.7. But
there are no 3rd party modules installed for 2.7 so programs that need
these do not run. Of course I can just replace #!/usr/bin/env python
with #!/usr/bin/env python2.6 but doing so for all programs would be a
pain.

Also, once I have a 3rd party module installed in
/usr/lib/python2.6/site-packages I wouldn't want to copy all of these
to /usr/lib/pythonX.Y/site-packages (assuming they are compatible with
pythonX.Y).

What would be the most common practice for having a single location
for 3rd party modules and all python versions could have access to
them?

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Postmortem on Unladen Swallow

2011-04-14 Thread Daniel Fetchinson
> There's a postmortem on the failure of Unladen Swallow by one of the
> developers at:
>
> http://qinsb.blogspot.com/2011/03/unladen-swallow-retrospective.html

This outcome of things is really a testament to the hard work of the pypy folks.
They, a volunteer bunch, beat google!
And that's something to be proud of, I'd think.

Cheers,
Daniel

-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SQLObject 1.2.0

2011-11-21 Thread Daniel Fetchinson
Thanks a million Oleg!

Cheers,
Daniel


On 11/20/11, Oleg Broytman  wrote:
> Hello!
>
> I'm pleased to announce version 1.2.0, the first stable release of branch
> 1.2 of SQLObject.
>
>
> What is SQLObject
> =
>
> SQLObject is an object-relational mapper.  Your database tables are
> described
> as classes, and rows are instances of those classes.  SQLObject is meant to
> be
> easy to use and quick to get started with.
>
> SQLObject supports a number of backends: MySQL, PostgreSQL, SQLite,
> Firebird, Sybase, MSSQL and MaxDB (also known as SAPDB).
>
>
> Where is SQLObject
> ==
>
> Site:
> http://sqlobject.org
>
> Development:
> http://sqlobject.org/devel/
>
> Mailing list:
> https://lists.sourceforge.net/mailman/listinfo/sqlobject-discuss
>
> Archives:
> http://news.gmane.org/gmane.comp.python.sqlobject
>
> Download:
> http://pypi.python.org/pypi/SQLObject/1.2.0
>
> News and changes:
> http://sqlobject.org/News.html
>
>
> What's New
> ==
>
> Features & Interface
> 
>
> * Strings are treated specially in Select to allow
>   Select(['id, 'name'], where='value = 42'). Update allows a string in
>   WHERE.
>
> * ForeignKey('Table', refColumn='refcol_id') to allow ForeignKey to
>   point to a non-id column; the referred column must be a unique integer
>   column.
>
> * delColumn now accepts a ForeignKey's name without 'ID'.
>
> * Support for PostgreSQL 7.* is dropped. The minimal supported version of
>   PostgreSQL is 8.1 now.
>
> * Quoting rules changed for PostgreSQL: SQLObject uses E'' escape string
>   if the string contains characters escaped with backslash.
>
> * A bug caused by psycopg2 recently added a new boolean not callable
>   autocommit attribute was fixed.
>
> * sqlobject.__doc__ and main.__doc__ no longer contain version number.
>   Use sqlobject.version or version_info.
>
> For a more complete list, please see the news:
> http://sqlobject.org/News.html
>
> Oleg.
> --
>  Oleg Broytmanhttp://phdru.name/p...@phdru.name
>Programmers don't die, they just GOSUB without RETURN.
> --
> http://mail.python.org/mailman/listinfo/python-list
>


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python module for making Quicktime or mpeg movies from images

2007-10-12 Thread Daniel Fetchinson
> My Python script makes a bunch of images that I want to use as frames
> in a movie.  I've tried searching for a module that will take these
> images and put them together in a Quicktime or mpeg movie, but haven't
> found anything.  My images are currently pdfs, but I could make them
> into just about anything if needed.
>
> Is there a module, or example of how to do this?
> Thanks,
> Jeremy

If you'll be happy with a flash movie you can try ming: ming.sf.net
which is a C library for creating flash files and there is a python
binding for it (among other languages).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Yet another comparison of Python Web Frameworks

2007-10-13 Thread Daniel Fetchinson
> Hello everybody,
>
> I just joined this mailing list. Thanks for your comments about gluon.
>
> I have posted a short video about it and I am planning to make more
> over the week-end.
>
> http://www.youtube.com/watch?v=VBjja6N6IYk
>
> About some of your comments:
> - the most complex modules (like html and sql ones) have doctests.
> - the executable versions (win and mac) come with python2.5. Running
> from source code does not require 2.5 but you probably want sqlite3.
> - so far I support sqlite3 and postgresql, not mysql (just because I
> do not use it and had no time for testing it).
> - yes, there are typos in the documentation. Please point them out to
> me so that I can fix them.
> - I am sure there are some minor bugs I am not aware of but as far I
> tested, it work.
> - If you report bugs to me I promise to fix them in 48hrs.
> - please make sure you have the latest version.
>
> I very much appreciate comments about gluon (good and bad). Please
> send me more so that I can improve it.
>
> There will be two talks in chicago about gluon next week: at DePaul
> Linux Users Group on Thursday evening and at the Chicago Linux Users
> Group on Saturday afternoon. I will try record them and post them.
>
> Massimo
>
> P.S. Michele Simionato. I have heard your name before? Is it possible
> we have met in Pisa in 1990-1996? I am also a Quantum Field Theorist
> and there is not many of us.


Hi Massimo,

In what way is gluon different from existing frameworks most notably
django and turbogears? What do you think are the advantages to using
gluon over these two?

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


Re: Yet another comparison of Python Web Frameworks

2007-10-13 Thread Daniel Fetchinson
> ... I almost forgot ...
>
> another difference between Gluon and Django,TG is that in Gluon if
> you write controllers without view you automatically get generic view
> that render and BEAUTIFY() the variables returned by the controllers.
> That means you can develop the logic of your application without
> writing one line of HTML and you have a working prototype.
>
> Massimo
>
> > Hi Daniel,
> >
> > in many respects Gluon is similar to Django and was greatly inspired
> > by Django. Some differences are:
> >
> > Gluon is easier to install - you never need to use the shell, there
> > are no configuration files.
> >
> > Gluon is a web app. You can do all development via a web interface.
> >
> > You can compile Gluon apps and distribute them in byte-code compiled
> > form.
> >
> > Each Gluon app comes with a ticketing system. If an error occurrs it
> > is logged and a ticket is issed. you can then search and retrieve
> > errors by date or client-ip.
> >
> > Making forms is easier than in Django. For example given a db table
> > called db.table you can do:
> >form=SQLForm(db.table)
> >if form.accepts(request.vars,session): pass
> > these two lines will do everything, including generating the form
> > from the table, validating input, inserting in database or modifying
> > the form with error messages. This also prevents multiple submission
> > of the same form because each form has a unique one-time key.
> >
> > The template language is pure python but without indentation
> > requirements. Django has restrictions on what can go in templates.
> >
> > The output in the views is escaped by default. In Django it is not.
> >
> > You can manage internationalization (add language and write
> > translations)  from the web interface.
> >
> > Each app has an automatically generated database administrative
> > interface. The Django one is cooler then Gluon's, but the Gluon one
> > allows complicated joins in the filter field.
> >
> > Gluon supports migrations: you just change the definition of a table
> > and it ALTERs the table accordingly (drop works in postgres only).
> > For example if you change a field from boolean to string, the
> > database is altered and the values are converted from boolean to
> > string for existing records.
> >
> > Gluon has a sql.log console to see what changes are made to the
> > database.
> >
> > In Gluon you do not need to import modules. The gluon modules you
> > need already imported for you.
> >
> > Gluon has a top-down design. This means that the Gluon APIs are not
> > under development. They are 100% stable. There may be bugs and they
> > will be fixed but the syntax and signature of functions is not
> > subject to change. This is why I started making Gluon, I am teaching
> > a class on web frameworks and the API of Django and TG are not as
> > stable as I wish they were. Moreover they have a too steep learning
> > curve when compared to Gluon.
> >
> > Please try it, it is no that time consuming, and send me you comments
> > (good or bad)!
> >
> > Massimo
> >
> >
> >>> Hello everybody,
> >>>
> >>> I just joined this mailing list. Thanks for your comments about
> >>> gluon.
> >>>
> >>> I have posted a short video about it and I am planning to make more
> >>> over the week-end.
> >>>
> >>> http://www.youtube.com/watch?v=VBjja6N6IYk
> >>>
> >>> About some of your comments:
> >>> - the most complex modules (like html and sql ones) have doctests.
> >>> - the executable versions (win and mac) come with python2.5. Running
> >>> from source code does not require 2.5 but you probably want sqlite3.
> >>> - so far I support sqlite3 and postgresql, not mysql (just because I
> >>> do not use it and had no time for testing it).
> >>> - yes, there are typos in the documentation. Please point them
> >>> out to
> >>> me so that I can fix them.
> >>> - I am sure there are some minor bugs I am not aware of but as far I
> >>> tested, it work.
> >>> - If you report bugs to me I promise to fix them in 48hrs.
> >>> - please make sure you have the latest version.
> >>>
> >>> I very much appreciate comments about gluon (good and bad). Please
> >>> send me more so that I can improve it.
> >>>
> >>> There will be two talks in chicago about gluon next week: at DePaul
> >>> Linux Users Group on Thursday evening and at the Chicago Linux Users
> >>> Group on Saturday afternoon. I will try record them and post them.
> >>>
> >>> Massimo
> >>>
> >>> P.S. Michele Simionato. I have heard your name before? Is it
> >>> possible
> >>> we have met in Pisa in 1990-1996? I am also a Quantum Field Theorist
> >>> and there is not many of us.
> >>
> >>
> >> Hi Massimo,
> >>
> >> In what way is gluon different from existing frameworks most notably
> >> django and turbogears? What do you think are the advantages to using
> >> gluon over these two?
> >>
> >> Cheers,
> >> Daniel


Massimo, thanks a lot for the reply, I'll give gluon a try. I've just
started to use TG about 3 months ago and although I like it it would
be f

Re: python project ideas

2007-10-25 Thread Daniel Fetchinson
> hi to everyone
> I wondered if this might be the right place to ask for some ideas for
> python project for university.
> I'd like it to be something useful and web-based. And the project must
> be complete in 2-3 months by 2-3 person group.
> May be something useful for open source or python community ...
> Well, just post what you think could be appropriate ...

Hi, have you tried this:

http://wiki.python.org/moin/CodingProjectIdeas

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


Re: why there is no pythonscript insine web browsers?

2007-11-12 Thread Daniel Fetchinson
> I'm an old programmer coming from a cobol background and started to
> learn python. I'm using javasript for web based applications but after I
> started to learn python, the javascript language started to seem ugly to
> me. Now I'm wondering why there is java support on web browsers but no
> python support? there is even a vbscript support inside MS-IE but there
> is no python support. it would be really nice and easy for me to use
> python instead of javascript to write those ajax scripts.
>
> Please tell me, is there a python substitude for JRE ?

Java has nothing to do with javascript. I guess you are really asking
about javascript so let's forget about java.

Having a full python runtime in a browser would be a really bad idea
because imagine a website telling your browser to "import os ;
os.unlink( 'your_secret_very_important_file' )". If you want to write
your browser client code nevertheless in python you can use pypy [1]
to translate it into javascript. This is also what I do and it works
pretty well in conjunction with MochiKit [2].

HTH,
Daniel

[1] http://codespeak.net/pypy/dist/pypy/doc/news.html
[2] http://mochikit.com
-- 
http://mail.python.org/mailman/listinfo/python-list


setters and getters in python 2.6 and 3.0

2007-11-29 Thread Daniel Fetchinson
Hi list, I've been following a discussion on a new way of defining
getters and setters on python-dev and just can't understand what the
purpose is. Everybody agreed on the dev list that this is a good idea
so I guess it must be right :)

The whole thing started with this post of Guido:

http://mail.python.org/pipermail/python-dev/2007-October/075057.html

which then continued into November. Basically, the idea is that using
the new way a setter can be added to property that was read-only
before. But if I have this already,

class C:
@property
def attr( self ): return self._attr

what prevents me using the following for adding a setter for attr:

class C:
def attr( self ): return self._attr
def set_attr( self, value ): self._attr = value
attr = property( attr, set_attr )

In other words all I needed to do is delete @property, write the
setter method and add attr = property( attr, set_attr ). What does the
new way improve on this?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: setters and getters in python 2.6 and 3.0

2007-11-29 Thread Daniel Fetchinson
> > Hi list, I've been following a discussion on a new way of defining
> > getters and setters on python-dev and just can't understand what the
> > purpose is. Everybody agreed on the dev list that this is a good idea
> > so I guess it must be right :)
> >
> > The whole thing started with this post of Guido:
> >
> > http://mail.python.org/pipermail/python-dev/2007-October/075057.html
> >
> > which then continued into November. Basically, the idea is that using
> > the new way a setter can be added to property that was read-only
> > before. But if I have this already,
> >
> > class C:
> > @property
> > def attr( self ): return self._attr
> >
> > what prevents me using the following for adding a setter for attr:
> >
> > class C:
> > def attr( self ): return self._attr
> > def set_attr( self, value ): self._attr = value
> > attr = property( attr, set_attr )
> >
> > In other words all I needed to do is delete @property, write the
> > setter method and add attr = property( attr, set_attr ). What does the
> > new way improve on this?
>
> It prevents namespace-pollution in a clever way. By first defining the
> getter, the @propset-decorator will augment the already createt property
> and return it.
>
> Thus you don't end up with a
>
> set_attr
>
> function.
>
>
> Other, more complex recipes to do the same look like this and are much
> harder to grasp:
>
>
> @apply
> def my_property()
>  def fget(self):
>  return self._value
>  def fset(self, value):
>  self._value = value
>  return property(**locals())
>
> So the proposed propset-decorator certainly makes things clearer.
>
> Diez

Aha :)
Makes sense indeed.

Thanks,
Daniel
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Announcing Apydia

2007-11-30 Thread Daniel Fetchinson
> Today, I am very excited to announce the first release of the Apydia
> API reference documentation generator for Python. It's designed as an
> instantly serviceable replacement for Pudge's API documentation
> generator. It won't generate complete websites from reST etc. like
> Pudge does, though - Apydia is only about the API.
>
> Features include:
>
> - Basic Pudge compatibility and a short and easy migration path
> - Rudimentary Trac-integration, that is links into Trac's sourcecode
> browser
> - Some fair amount of usability
> - Setuptools integration
> - Flexible, Genshi/XInclude-based themeability with theme inheritance
> - Support for various text formats like Markdown, Textile and reST
> - Other parsers can easily be plugged in on demand
> - Syntax highlighting thanks to Pygments
>
> For more information visit Apydia's web site at http://apydia.ematia.de
> and the Apydia Google Group at http://groups.google.com/group/apydia.


You might want to fix the typo in the title tag of the webpage.

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


[OT] minimalist web server

2007-12-01 Thread Daniel Fetchinson
Hi list,

This is way off topic but maybe somebody knowledgeable can help.

I'm looking for the most minimalist web server ever that does nothing
else than return a fixed static page for every request. Regardless of
what the request is, it just needs to be an HTTP request to port 80,
the web server should return always the same html document. What would
be the best choice for this? The goal is of course to minimize system
resources in terms of memory, cpu, etc, etc.

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


Re: [OT] minimalist web server

2007-12-01 Thread Daniel Fetchinson
> > I'm looking for the most minimalist web server ever that does nothing
> > else than return a fixed static page for every request. Regardless of
> > what the request is, it just needs to be an HTTP request to port 80,
> > the web server should return always the same html document. What would
> > be the best choice for this? The goal is of course to minimize system
> > resources in terms of memory, cpu, etc, etc.
>
> If you're running linux, maybe you want tux.
>
> publicfile isn't exactly what you describe, but its description might
> be of some interest:
>
> http://cr.yp.to/publicfile.html


Thanks, tux looks good, the only problem is that one needs to
recompile the kernel which I really don't want to do (so yes, I'm on
linux). Publicfile seems to "know" already too much.

The reason I need this is that my current best strategy to avoid ads
in web pages is putting all ad server names into /etc/hosts and stick
my local ip number next to them (127.0.0.1) so every ad request goes
to my machine. I run apache which has an empty page for 404 errors so
I'll just see that blank page for every ad. Now I guess apache is a
pretty heavy weight guy so I'm looking for a lightweight alternative.
Lighttpd, nginx and company are all too complex and "know" too much. I
even considered just putting netcat into an infinite loop but I'm
afraid if there is a security hole in netcat I might be screwed.

Maybe now that I outlined a little more why I need this others can
come up with more suggestions.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [OT] minimalist web server

2007-12-01 Thread Daniel Fetchinson
Maybe I found what I'm looking for: cheetah, a web server that is 600
lines of C code and that's it :)

http://freshmeat.net/projects/cheetahd/


On 12/1/07, Daniel Fetchinson <[EMAIL PROTECTED]> wrote:
> > > I'm looking for the most minimalist web server ever that does nothing
> > > else than return a fixed static page for every request. Regardless of
> > > what the request is, it just needs to be an HTTP request to port 80,
> > > the web server should return always the same html document. What would
> > > be the best choice for this? The goal is of course to minimize system
> > > resources in terms of memory, cpu, etc, etc.
> >
> > If you're running linux, maybe you want tux.
> >
> > publicfile isn't exactly what you describe, but its description might
> > be of some interest:
> >
> > http://cr.yp.to/publicfile.html
>
>
> Thanks, tux looks good, the only problem is that one needs to
> recompile the kernel which I really don't want to do (so yes, I'm on
> linux). Publicfile seems to "know" already too much.
>
> The reason I need this is that my current best strategy to avoid ads
> in web pages is putting all ad server names into /etc/hosts and stick
> my local ip number next to them (127.0.0.1) so every ad request goes
> to my machine. I run apache which has an empty page for 404 errors so
> I'll just see that blank page for every ad. Now I guess apache is a
> pretty heavy weight guy so I'm looking for a lightweight alternative.
> Lighttpd, nginx and company are all too complex and "know" too much. I
> even considered just putting netcat into an infinite loop but I'm
> afraid if there is a security hole in netcat I might be screwed.
>
> Maybe now that I outlined a little more why I need this others can
> come up with more suggestions.
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [OT] minimalist web server

2007-12-02 Thread Daniel Fetchinson
> > The reason I need this is that my current best strategy to avoid ads in
> > web pages is putting all ad server names into /etc/hosts and stick my
> > local ip number next to them (127.0.0.1) so every ad request goes to my
> > machine. I run apache which has an empty page for 404 errors so I'll
>
> In this case, do you need a webserver at all? If your browser tries to
> access a web server on 127.0.0.1 and there isn't one, won't the result,
> in most cases, be more or less the same as if the server returned a 404?

Not quite, because if the browser doesn't get a response from the
server it will keep trying for a while and will only give up after
that. And then will display a "server not found, blablablabla" message
depending on the browser, which will appear in place of every ad.
That's ugly and it's better to have an empty page.

Concerning the python solutions posted by several guys, they are too
heavyweight compared to a ~ 1-3 hundred lines of C code that one can
obtain from cheetah's source code.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python surpasses Perl in TIOBE index

2007-12-04 Thread Daniel Fetchinson
> > Well we Python folks are spoiled but for most people C++ counts as a
> > high level language
>
> Well, some parts are high-level, but it's full of very
> deep elevator shafts for you to accidentally fall
> into...
>
> A truly high-level language also *doesn't* have low
> level parts (or at least doesn't expose them unless
> you explicitly ask it to).


Anyone has an idea what the huge peak around the middle of 2004 can be
attributed to?

http://www.tiobe.com/tiobe_index/Python.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python surpasses Perl in TIOBE index

2007-12-04 Thread Daniel Fetchinson
On 12/4/07, Daniel Fetchinson <[EMAIL PROTECTED]> wrote:
> > > Well we Python folks are spoiled but for most people C++ counts as a
> > > high level language
> >
> > Well, some parts are high-level, but it's full of very
> > deep elevator shafts for you to accidentally fall
> > into...
> >
> > A truly high-level language also *doesn't* have low
> > level parts (or at least doesn't expose them unless
> > you explicitly ask it to).
>
> Anyone has an idea what the huge peak around the middle of 2004 can be
> attributed to?
>
> http://www.tiobe.com/tiobe_index/Python.html

It seems the huge peak has to do something with the huge dip in Java
at around the same period:

http://www.tiobe.com/tiobe_index/Java.html

Chicken-or-egg problem I guess :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: contributing to an open source project

2007-12-05 Thread Daniel Fetchinson
> I am looking for an open source project to contribute to, to enhance
> my python skills. I have about 6 months experience in the language. I
> have searched freshmeat.net, but as I'm pretty new, I'm not sure which
> projects I would be able to contribute to.
>
> If anyone can suggest any open source projects python projects that
> would be suitable for a beginner, and where mentoring might be an
> option, please let me know.


Hi, please look at

http://wiki.python.org/moin/CodingProjectIdeas

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


Re: [OT] minimalist web server

2007-12-31 Thread Daniel Fetchinson
> Using DSL (Damn Small Linux) try apache! Or you can try litehttpd
>
>
> > Hi list,
> >
> > This is way off topic but maybe somebody knowledgeable can help.
> >
> > I'm looking for the most minimalist web server ever that does nothing
> > else than return a fixed static page for every request. Regardless of
> > what the request is, it just needs to be an HTTP request to port 80,
> > the web server should return always the same html document. What would
> > be the best choice for this? The goal is of course to minimize system
> > resources in terms of memory, cpu, etc, etc.
> >
> > Cheers,
> > Daniel

I've written a *really* minimalistic web server that only serves blank
pages. It's not python but C, if anyone interested:
http://code.google.com/p/kwakd

Happy new year to every python lover!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python web aps - A matter of security

2008-01-05 Thread Daniel Fetchinson
On 1/5/08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I'm developing a Python-based web ap, but don't understand how to best
> organize the modules and set permissions for maximum security.
>
> Here's how the Python code for my ap is organized:
>
> 1) I have Python modules in a project directory. The path to that directory
> is in a  *.pth file  in the .*/pythonx-y/site-packages directory.
>
> Question: who should own these modules; what groups should have access, and
> how should permissions be set?
>
> 2) I have high-level modules that import the worker-bee modules in the web
> root directory tree that are called by the webserver.
>
> Questions: who should own these modules, what groups should have access, and
> how should permissions be set?
>
> 3) Is there a better way to organize my Python modules? Are there other
> security issues I should heed?
>
> Many thanks,
>
> Lloyd

Are you using any of the many available web frameworks like
turbogears, django, etc?
If so your best option is probably to use the
authentication/authorization capabilities of these frameworks and then
you won't have to worry about it too much.

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


Re: Newbie question: Classes

2008-01-08 Thread Daniel Fetchinson
> Basically, I have created a program using tkinter without using any class
> structure, simply creating widgets and functions (and finding ways around
> passing variables from function to function, using global variables etc).
> The program has become rather large ( lines?) I am trying to now put it into
> a class structure, because I hear it is easier to handle.
>
> So basically, I put all the stuff into a class, making the widgets in the
> "def __init__(self, root)" (root being my Tk() ) and then I have had to put
> a "self." in front of any instance of any variable or widget. Is this right?
> it seems like nothing is any easier (except having variables locally). Is
> this right? Should I be creating more classes for different things or what?


Use the method that works best for you. If you like the procedural
approach more then don't worry about being object oriented. The good
thing is that python is multi-paradigm so if custom objects don't make
your life easier then just forget about them :)
-- 
http://mail.python.org/mailman/listinfo/python-list


user friendly datetime features

2008-01-08 Thread Daniel Fetchinson
Many times a more user friendly date format is convenient than the
pure date and time.
For example for a date that is yesterday I would like to see
"yesterday" instead of the date itself. And for a date that was 2 days
ago I would like to see "2 days ago" but for something that was 4 days
ago I would like to see the actual date. This is often seen in web
applications, I'm sure you all know what I'm talking about.

I'm guessing this feature is needed so often in so many projects that
it has been implemented already by several people. Does anyone know of
such a stand alone module?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Natural-language datetime parsing and display (was: user friendly datetime features)

2008-01-09 Thread Daniel Fetchinson
> For PARSING see http://code-bear.com/code/parsedatetime/
>
> The OP was looking for presentation though.  I know roundup has code for
> this if an independent library can't be found.


Thanks for all the responses!
Indeed I was looking for presentation and not parsing, I'll take a
look at roundup.

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


Re: Natural-language datetime parsing and display

2008-01-09 Thread Daniel Fetchinson
> > > The OP was looking for presentation though. I know roundup has
> > > code for this if an independent library can't be found.
> >
> > Thanks for all the responses!
> > Indeed I was looking for presentation and not parsing, I'll take a
> > look at roundup.
>
> Yes, that's why I indicated that Chandler Desktop would be a good
> place to look.

I see, I thought that would only be a good place to look for parsing.
Now I downloaded Chandler and quickly found the parsing module they
use but not the one for display but it has to be there I'm sure. They
must use this all over the place.

> Roundup sounds like an equally good place to look.

Yes, roundup has a separate module for this and it does the display,
not parsing. This is exactly what I need.

> Hopefully, with a couple of options like that, you'll find something
> decent.

Yep, I already did :)

> It would be good to see a generic "natural-language datetime
> presentation" library in the Cheeseshop, since the functionality seems
> quite well-suited to a separate generic library.

Exactly, that's what I was mentioning in my original post too.
Actually it looks like the one included in roundup is a stand alone
library for display (but not parsing). It's released under the same
license as python itself maybe they can be convinced to release it as
a stand alone module to the cheeseshop.

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


Re: __init__ explanation please

2008-01-12 Thread Daniel Fetchinson
> I'm new to Python, and OOP. I've read most of Mark Lutz's book and more
> online and can write simple modules, but I still don't get when __init__
> needs to be used as opposed to creating a class instance by assignment. For
> some strange reason the literature seems to take this for granted. I'd
> appreciate any pointers or links that can help clarify this.

I'm not sure if I understand your question correctly but maybe this will help:

If you want code to be run upon creating an instance of your class you
would use __init__. Most common examples include setting attributes on
the instance and doing some checks, e.g.

class Person:
def __init__( self, first, last ):
if len( first ) > 50 or len( last ) > 50:
raise Exception( 'The names are too long.' )
self.first = first
self.last = last

And you would use your class like so,

p1 = Person( 'John', 'Smith' )
p2 = Person( "Some long fake name that you don't really want to
except, I don't know if it's really longer than 50 but let's assume it
is", "Smith" )
# This last one would raise an exception so you know that something is not okay

HTH,
Daniel
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: __init__ explanation please

2008-01-13 Thread Daniel Fetchinson
Please keep discussion on the list..

> > I'm not sure if I understand your question correctly but maybe this will
> > help:
> >
> > If you want code to be run upon creating an instance of your class you
> > would use __init__. Most common examples include setting attributes on
> > the instance and doing some checks, e.g.
> >
> > class Person:
> >def __init__( self, first, last ):
> >if len( first ) > 50 or len( last ) > 50:
> >raise Exception( 'The names are too long.' )
> >self.first = first
> >self.last = last
> >
> > And you would use your class like so,
> >
> > p1 = Person( 'John', 'Smith' )
> > p2 = Person( "Some long fake name that you don't really want to
> > except, I don't know if it's really longer than 50 but let's assume it
> > is", "Smith" )
> > # This last one would raise an exception so you know that something is not
> > okay
> >
> > HTH,
> > Daniel
>
> Is not the code run when I create an instance by assignement somewhere else?
>
> I take the point that one might want to check for potential exceptions
> immediately, but most examples in the literature aren't doing that and don't
> seem to be doing anything that would not be done when creating an instance
> by assignment later somewhere. I'm missing something basic here.

What do you mean by "create an instance by asignment somewhere else"?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why the HELL has nobody answered my question !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

2008-01-30 Thread Daniel Fetchinson
> I do not understand why no one has answered the following question:
>
> Has anybody worked with Gene Expression Programming

Hm, maybe because nobody did? Just a thought. It can also be that
everyone worked with it but everyone is part of a big conspiracy not
to answer any of your emails just to make you act weird. I'm not sure,
I'm really not sure.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Has Anyone Worked with Gene Expression Programming ???????????????????????????

2008-01-30 Thread Daniel Fetchinson
>> To Anyone,

> >
> >
> >
> > Has anyone worked with Gene Expression Programming???  Specifically, has
> > anyone out there worked with pygep software package???  I have a few
> > questions
> >
> >
> > David Blubaugh
> > --


Actually, it turns out I might say I'm a world known expert of Gene
Expression Programming.
The only thing is that some higher powers are preventing me from telling you
about it.
I'm really sorry, I hope you understand. Please don't ask questions. It's
not safe to know too much about this stuff. One day, my son, you'll
understand. You'll understand.
-- 
http://mail.python.org/mailman/listinfo/python-list

dict comprehension

2008-01-31 Thread Daniel Fetchinson
Hi folks,

There is a withdrawn PEP about a new syntax for dict comprehension:
http://www.python.org/dev/peps/pep-0274/ which says:

"Substantially all of its benefits were subsumed by generator
expressions coupled with the dict() constructor."

What does the author mean here? What's the Preferably One Way (TM) to
do something analogous to a dict comprehension?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: dict comprehension

2008-01-31 Thread Daniel Fetchinson
> > Hi folks,
> >
> > There is a withdrawn PEP about a new syntax for dict comprehension:
> > http://www.python.org/dev/peps/pep-0274/ which says:
> >
> > "Substantially all of its benefits were subsumed by generator
> > expressions coupled with the dict() constructor."
> >
> > What does the author mean here? What's the Preferably One Way (TM) to
> > do something analogous to a dict comprehension?
> >
> See about generator expressions in
> http://www.python.org/doc/2.4/whatsnew/node4.html.
>
> The dict builtin can build a dictionary from a list (or iterator or
> generator creating a list) of tuples.   Put them together and get what
> you might be tempted to call a dictionary comprehension.   For instance:
>
> >>> dict((i,i*i) for i in range(10))
> {0: 0, 1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64, 9: 81}

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


Re: Python Standardization: Wikipedia entry

2008-02-01 Thread Daniel Fetchinson
> Depends entirely on the operative meaning of standardized.  Formal
> standards body? Obviously no.
>
> Specified in a standard-setting document? Yes.  In fact, in someways,
> Python is better standardized that C, for instance, in that the Python
> standard usefully standardizes some things that the C standard leaved
> unstandardized as 'implementation defined'.

Unstandardized and undefined are two different things. If the standard
says "this is implementation defined AKA undefined" is just as clear
and unambiguous as saying "this is defined so and so". Both statement
are equally clear as to determine if a code conforms to the standard
or not. The purpose of a standard is not to define everything but
define clearly certain things and make it equality clear what is not
defined and is left as an implementation detail.


> Example 1. Order of evaluation of function arguments.  Python: left to
> right.  C: undefined (and unstandardized), I believe.
>
> Example 2: Strings for Infinity and Not-A-Number.  Python: will standardize
> in 2.6 to hide the variation in C implementations (or is Microsoft just
> non-compliant here?).
-- 
http://mail.python.org/mailman/listinfo/python-list


GUI definition for web and desktop

2008-02-02 Thread Daniel Fetchinson
Hi pythoneans,

I'm looking for a simple text based GUI definition format and
associated python modules to work with it that is capable of defining
simple GUI's for *both* the web and the desktop. I have an application
that is accessible through the web and also through desktop
applications and both clients should be presented a simple dialog GUI.
This dialog will only include text fields, radio buttons and a file
upload field. The exact list of fields might change from time to time
which implies that both clients should immediately know about it.

My idea is that if there was a lightweight GUI definition format then
I would define the current list of fields and other GUI elements in
this format, expose this file on the web, and both the web client and
the desktop client would first fetch this file and generate the
appropriate GUI from that dynamically. If the GUI changes I would only
need to modify my definition file and both type of clients would
immediately know about it since before they do anything else they grab
this definition.

I haven't yet decided on the desktop client GUI library, it depends on
which library has such a dynamically generatable interface from a text
file. But it should be cross platform between linux and windows.

What would be the best way to do this?

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


Re: GUI definition for web and desktop

2008-02-03 Thread Daniel Fetchinson
> >>  >>  > I'm looking for a simple text based GUI definition format and
> >>
> >> [...]
> >>
>  I believe Glade produces XML descriptions of its interfaces, so wxGlade
> >>  >>  would be one possible starting-point.
> >>  >>
> >>  >
> >>  > Glade does, but dont confuse it with wxGlade. wxGlade can generate
> >>  > direct python code or XRC files.
> >>  >
> >>
> >> So what are you telling me - that XRC files aren't XML?
> >>
> >
> > Im telling you to not confuse its format with Glade's format. Both are
> > xml, but are different things.
> >
> Thanks. My original advice still stands.

Thanks everyone for the advice!

It's clear to me that the logic behind a web interface and a desktop
interface are two totally different things. I don't want a magic
method to convert an html/javascript based web app to a desktop app as
this is clearly impossible.

But if both interfaces a specific component, which in the desktop case
is a dialog window, in the web app case a particular page and in both
cases the component is simply a list of text fields, radio buttons and
file selection button then it makes sense to have code that can be
used for both concerning the presentation only. So no business logic,
only the presentation, something that says "we have 3 text fields with
these labels and a radio button with such and such labels". Such a
definition makes perfect sense for both a web app and a desktop app
regardless of the fact that they work totally differently.

If I don't have such a shared widget definition then I have to update
both the web app (which is done using turbogears so essentially python
code) and the desktop app (also python) separately when new text
fields are introduced so they constantly have to be in sync. That is
error prone and will surely introduce bugs.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: GUI definition for web and desktop

2008-02-03 Thread Daniel Fetchinson
> > It's clear to me that the logic behind a web interface and a desktop
> > interface are two totally different things. I don't want a magic
> > method to convert an html/javascript based web app to a desktop app as
> > this is clearly impossible.
>
> But it is not impossible to embed a server on your desktop and make it
> render HTML on some windows.

That's true, that is why I'm looking for a format that is
html/javascript/desktop/guitoolkit agnostic. It's ideally simply a
text file listing the widgets in whatever format (xml, plain text,
json, etc). And the python web app takes this file, parses it and
spits out the right html/javascript while the desktop app takes the
same file, parses it, and spits out GUI-toolkit specific code that
renders a window with those widgets using the GUI-toolkit in question.
The web app code that spits out html and the desktop app code that
renders a dialog window are different and have to be maintained
separately but the *definition file* can be shared.

> Then you'd have to code just the web app and
> the desktop would also use it...
>
> If Internet is a requirement, you can even render the HTML from a remote
> server.

The internet is assumed to be accessible so this is an interesting
possibility what you mention. Which GUI toolkit would be able to do
this? And so it would work in a way that the desktop app grabs an html
page and renders that in a dialog window? If this was possible then
maybe this would solve all my problems.

Thanks,
Daniel
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: GUI definition for web and desktop

2008-02-03 Thread Daniel Fetchinson
> > I'm looking for a simple text based GUI definition format and
> > associated python modules to work with it that is capable of defining
> > simple GUI's for *both* the web and the desktop. I have an application
> > that is accessible through the web and also through desktop
> > applications and both clients should be presented a simple dialog GUI.
> [...]
> > I haven't yet decided on the desktop client GUI library, it depends on
> > which library has such a dynamically generatable interface from a text
> > file. But it should be cross platform between linux and windows.
>
> That sounds a lot like XUL to me. That's the language that Mozilla browsers
> use for their GUI. AFAIR, it had Python bindings through XPCOM the last time
> I looked into it.
>
> http://www.mozilla.org/why/framework.html

Thanks, I've looked into XUL but it looks too heavyweight to me.

> On the other hand, if you want pure HTML for your web app, maybe you should
> consider making the desktop app HTML-based, too?

Jorge Godoy brought that up too, sounds pretty good, but how would
that work? The desktop app would launch a mini webserver and the user
would use his/her browser that connnects to the local web server? Or
is there a GUI toolkit library for python which can render html?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: GUI definition for web and desktop

2008-02-03 Thread Daniel Fetchinson
> >> On the other hand, if you want pure HTML for your web app, maybe you
> should
> >> consider making the desktop app HTML-based, too?
> >
> > Jorge Godoy brought that up too, sounds pretty good, but how would
> > that work? The desktop app would launch a mini webserver and the user
> > would use his/her browser that connnects to the local web server?
>
> That's a common solution. There's the webbrowser module, which allows you to
> start a webbrowser in a platform independent way. The rest would be server
> driven.
>
> http://docs.python.org/lib/module-webbrowser.html
>
>
> > is there a GUI toolkit library for python which can render html?
>
> At least GTK comes with libgtkhtml, but I bet there are others, too.
>
> http://www.fcoutant.freesurf.fr/python-gtkhtml.html

Thanks a lot!

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


Re: Looking for library to estimate likeness of two strings

2008-02-06 Thread Daniel Fetchinson
> Are there any Python libraries implementing measurement of similarity
> of two strings of Latin characters?
>
> I'm writing a script to guess-merge two tables based on people's
> names, which are not necessarily spelled the same way in both tables
> (especially the given names).  I would like some function that would
> help me make the best guess.
>
> Many thanks in advance!


Hi folks, just went through this thread and a related one from 2006
and I was wondering what the best solution is for using these string
metrics in a database search. If I want to query the database for a
string or something that is close to it (close being defined by one of
the string metrics discussed above) it seems I have to select each and
every word from the database and compare it with the query word which
is very ineffective.

Very concretely if I have an sqlite db with SQLObject as the ORM what
would be the most effective way of doing such a query?

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


Re: Microsoft's challenger to Python

2008-02-07 Thread Daniel Fetchinson
> >  > I am not, however, an in depth language nutter, so would
> >  > appreciate any of our more learned readers comments.

Maybe I'm missing the obvious here, but what does Cobra have to do
with Microsoft?
(Apart from being .NET oriented.) It seems it's an open source project
of a guy who doesn't work for Microsoft.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Dear David

2008-02-08 Thread Daniel Fetchinson
> I have discontinued the use of ??  a long time ago.  Why is this
> still a problem?

Welcome to bewildering yet joyful world of usenet!
It seems you are already having quite some fun!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ROUNDING???

2008-02-18 Thread Daniel Fetchinson
> in python im doing the problem 255/494

Try this:

>>> 255.0/494.0
0.51619433198380571
>>> float(255)/float(494)
0.51619433198380571


> it keeps giving me 0 instead of .51
> what am i doing wrong?

Nothing, integer division is not wrong :)

> please help me I have been looking for hours






>
> 
> Never miss a thing.  Make Yahoo your home page.
> http://www.yahoo.com/r/hs
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: Phatch = PHoto bATCH processor and renamer based on PIL

2008-02-18 Thread Daniel Fetchinson
On 2/18/08, SPE - Stani's Python Editor <[EMAIL PROTECTED]> wrote:
> I'm pleased to announce the release of Phatch which is a
> powerful batch processor and renamer. Phatch exposes a big part of the
> Python Imaging Library through an user friendly GUI. (It is using
> python-pyexiv2 to offer more extensive EXIF and IPTC support.) Phatch
> is not targeted at manipulating individual pictures (such as with
> Gimp), but repeating the same actions on hundreds or thousands of
> images.
>
> If you know PIL and have some nice recipes laying around, it is very
> easy to write plugins as Phatch generates the corresponding GUI
> automagically just like in Django. Any existings PIL scripts can be
> added very easily. Let me know if you want to contribute or have any
> questions.
>
> Homepage: http://photobatch.stani.be (free download link below)
> Tutorials: http://photobatch.wikidot.com/tutorials
> Translations: https://translations.launchpad.net/phatch/trunk/+pots/phatch
> License: GPLv3
> Screenshot:
> http://photobatch.wikidot.com/local--files/start/Screenshot-Phatch3d.jpg
> (the perspective and reflection is produced by Phatch itself)
>
> Phatch has many features, like:
> - EXIF information inspector with thumbnail
> - limit jpeg file size when saving
> - tons of actions organized by tags (including perspective, round
> corners, shadow, reflection, ...)
> - console version (Phatch can now run without a gui on servers)
> - batch rename and copy files based on exif metadata
> - data stamping (http://photobatch.wikidot.com)
> - online documentation wiki (http://photobatch.wikidot.com)
>
> Linux only features:
> - desktop or panel droplets on which images or folders can be dropped
> (will be ported to Windows & Mac)
> - Nautilus and desktop integration (with its own mime type and
> nautilus extension)
> - manpage with examples
>
> With python-pyexiv2 the following featues are added:
> - embedding the original EXIF and IPTC tags in the image
>
> All actions mostly have a separate pil function in their source code,
> so they could be read as a recipe book for PIL:
> * Auto Contrast - Maximize image contrast
> * Background - Put colour under transparent image
> * Border - Crop or add border to all sides
> * Brightness - Adjust brightness from black to white
> * Canvas - Crop the image or enlarge canvas without resizing the image
> * Colorize - Colorize grayscale image
> * Common - Copies the most common pixel value
> * Contrast - Adjust from grey to black & white
> * Convert Mode - Convert the color mode of an image (grayscale, RGB,
> RGBA or CMYK)
> * Copy - Copy image file
> * Effect - Blur, Sharpen, Emboss, Smooth, ...
> * Equalize - Equalize the image histogram
> * Fit - Downsize and crop image with fixed ratio
> * Grayscale - Fade all colours to gray
> * Invert - Invert the colors of the image (negative)
> * Maximum - Copies the maximum pixel value
> * Mask - Apply a transparency mask
> * Median - Copies the median pixel value
> * Minimum - Copies the minimum pixel value
> * Offset - Offset by distance and wrap around
> * Posterize - Reduce the number of bits of colour channel
> * Perspective - Shear 2d or 3d
> * Rank - Copies the rank'th pixel value
> * Reflect - Drops a reflection
> * Rename - Rename image file
> * Rotate - Rotate with random angle
> * Round - Round or crossed corners with variable radius and corners
> * Saturation - Adjust saturation from grayscale to high
> * Save - Save an image with variable compression in different types
> * Scale - Scale an image with different resample filters.
> * Shadow - Drop a blurred shadow under a photo with variable position,
> blur and color
> * Solarize - Invert all pixel values above threshold
> * Text - Write text at a given position
> * Transpose - Flip or rotate an image by 90 degrees
> * Watermark - Apply a watermark image with variable placement (offset,
> scaling, tiling) and opacity
>
> I develop Phatch on Ubuntu/Linux, but I have tested and polished it
> regularly on Windows and Mac Os X. (Only the droplet functionality
> needs to be ported.) Phatch is submitted to Debian unstable and
> Ubuntu Hardy. Packagers for other platforms are welcome.
>
> Requirements:
> - PIL 1.1.5 or higher
> - wxPython 2.6 or higher
> - pyexiv2 (optional)
> - python nautilus bindings (optional)


This is pretty cool! I have one question about the equally cool
website: what tool did you use for creating this image:

http://photobatch.wikidot.com/local--files/start/Screenshot-Phatch3d.jpg


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


Re: ANN: Phatch = PHoto bATCH processor and renamer based on PIL

2008-02-19 Thread Daniel Fetchinson
> > > I'm pleased to announce the release of Phatch which is a
> > > powerful batch processor and renamer. Phatch exposes a big part of the
> > > Python Imaging Library through an user friendly GUI. (It is using
> > > python-pyexiv2 to offer more extensive EXIF and IPTC support.) Phatch
> > > is not targeted at manipulating individual pictures (such as with
> > > Gimp), but repeating the same actions on hundreds or thousands of
> > > images.
> >
> > > If you know PIL and have some nice recipes laying around, it is very
> > > easy to write plugins as Phatch generates the corresponding GUI
> > > automagically just like in Django. Any existings PIL scripts can be
> > > added very easily. Let me know if you want to contribute or have any
> > > questions.
> >
> > > Homepage:http://photobatch.stani.be(free download link below)
> > > Tutorials:http://photobatch.wikidot.com/tutorials
> > >
> Translations:https://translations.launchpad.net/phatch/trunk/+pots/phatch
> > > License: GPLv3
> > > Screenshot:
> > >http://photobatch.wikidot.com/local--files/start/Screenshot-Phatch3d.jpg
> > > (the perspective and reflection is produced by Phatch itself)
>
> > This is pretty cool! I have one question about the equally cool
> > website: what tool did you use for creating this image:
> >
> > http://photobatch.wikidot.com/local--files/start/Screenshot-Phatch3d.jpg
> This is Phatchs own dogfood. I guess you missed the tutorials link.
> There is a tutorial how you can achieve this effect:
> http://photobatch.wikidot.com/tutorial-round-3d-reflect
>
> I run Phatch on three screenshots I have to put them in perspective
> with rounded corners and perspective. I let Phatch save them as a png
> so transparency is preserved. Afterwards I opened Gimp and put the
> three together on the background of a radial gradient.
>
> Let me know if it works for you.

Yep, I indeed missed the tutorial :)
Now it's clear, thanks a lot!

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


Re: ANN: Phatch = PHoto bATCH processor and renamer based on PIL

2008-02-24 Thread Daniel Fetchinson
> I'm pleased to announce the release of Phatch which is a
> powerful batch processor and renamer. Phatch exposes a big part of the
> Python Imaging Library through an user friendly GUI. (It is using
> python-pyexiv2 to offer more extensive EXIF and IPTC support.) Phatch
> is not targeted at manipulating individual pictures (such as with
> Gimp), but repeating the same actions on hundreds or thousands of
> images.
>
> If you know PIL and have some nice recipes laying around, it is very
> easy to write plugins as Phatch generates the corresponding GUI
> automagically just like in Django. Any existings PIL scripts can be
> added very easily. Let me know if you want to contribute or have any
> questions.
>
> Homepage: http://photobatch.stani.be (free download link below)
> Tutorials: http://photobatch.wikidot.com/tutorials
> Translations: https://translations.launchpad.net/phatch/trunk/+pots/phatch
> License: GPLv3
> Screenshot:
> http://photobatch.wikidot.com/local--files/start/Screenshot-Phatch3d.jpg
> (the perspective and reflection is produced by Phatch itself)
>
> Phatch has many features, like:
> - EXIF information inspector with thumbnail
> - limit jpeg file size when saving
> - tons of actions organized by tags (including perspective, round
> corners, shadow, reflection, ...)
> - console version (Phatch can now run without a gui on servers)
> - batch rename and copy files based on exif metadata
> - data stamping (http://photobatch.wikidot.com)
> - online documentation wiki (http://photobatch.wikidot.com)
>
> Linux only features:
> - desktop or panel droplets on which images or folders can be dropped
> (will be ported to Windows & Mac)
> - Nautilus and desktop integration (with its own mime type and
> nautilus extension)
> - manpage with examples
>
> With python-pyexiv2 the following featues are added:
> - embedding the original EXIF and IPTC tags in the image
>
> All actions mostly have a separate pil function in their source code,
> so they could be read as a recipe book for PIL:
> * Auto Contrast - Maximize image contrast
> * Background - Put colour under transparent image
> * Border - Crop or add border to all sides
> * Brightness - Adjust brightness from black to white
> * Canvas - Crop the image or enlarge canvas without resizing the image
> * Colorize - Colorize grayscale image
> * Common - Copies the most common pixel value
> * Contrast - Adjust from grey to black & white
> * Convert Mode - Convert the color mode of an image (grayscale, RGB,
> RGBA or CMYK)
> * Copy - Copy image file
> * Effect - Blur, Sharpen, Emboss, Smooth, ...
> * Equalize - Equalize the image histogram
> * Fit - Downsize and crop image with fixed ratio
> * Grayscale - Fade all colours to gray
> * Invert - Invert the colors of the image (negative)
> * Maximum - Copies the maximum pixel value
> * Mask - Apply a transparency mask
> * Median - Copies the median pixel value
> * Minimum - Copies the minimum pixel value
> * Offset - Offset by distance and wrap around
> * Posterize - Reduce the number of bits of colour channel
> * Perspective - Shear 2d or 3d
> * Rank - Copies the rank'th pixel value
> * Reflect - Drops a reflection
> * Rename - Rename image file
> * Rotate - Rotate with random angle
> * Round - Round or crossed corners with variable radius and corners
> * Saturation - Adjust saturation from grayscale to high
> * Save - Save an image with variable compression in different types
> * Scale - Scale an image with different resample filters.
> * Shadow - Drop a blurred shadow under a photo with variable position,
> blur and color
> * Solarize - Invert all pixel values above threshold
> * Text - Write text at a given position
> * Transpose - Flip or rotate an image by 90 degrees
> * Watermark - Apply a watermark image with variable placement (offset,
> scaling, tiling) and opacity
>
> I develop Phatch on Ubuntu/Linux, but I have tested and polished it
> regularly on Windows and Mac Os X. (Only the droplet functionality
> needs to be ported.) Phatch is submitted to Debian unstable and
> Ubuntu Hardy. Packagers for other platforms are welcome.
>
> Requirements:
> - PIL 1.1.5 or higher
> - wxPython 2.6 or higher
> - pyexiv2 (optional)
> - python nautilus bindings (optional)


Now that we are at image manipulation does anyone know of a good,
possibly python based, image manipulation tool that can do the same as
the windows tool andrea mosaic?

http://www.andreaplanet.com/andreamosaic/samples/

Stani, if this is a good place for feature requests I would like to add it :)

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


Re: most loved template engine on python is?

2008-02-24 Thread Daniel Fetchinson
> After deciding choosing python as my future killer application language
> for writing web applications, I need from you guys still some support,
> if you apologize.
>
> Question:
> Which is the most loved template engine for python?

AFAIK, there is no single blessed template system. If you're up to web
development then your choice of framework will limit the choices for
template engines. For example if you choose Django I guess you'll have
to stick with its built-in template system (I might be wrong on this)
while if you choose turbogears you can choose between, genshi, kid,
myghty and some others.

If you don't have your own preferences the best bet is choosing the
default template system that comes with your choice of web framework.
With turbogears 1 it means kid, with turbogears 2 it means genshi.

For more info please see http://wiki.python.org/moin/Templating


> I see, that I can do more aspect oriented programming with python as
> with ruby (as comparing those languages). God thanks, I do not have to
> create an object for every small thing in python and still generate
> classes and access methods statically.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SQLLITE

2008-03-02 Thread Daniel Fetchinson
> > > I am having a minor problem when I try and do this:
> > > c.execute("insert into [tblTranscripts] (MovieID,Transcript)
> > > Values(" + movieID + ",'" + formatText + "');") (don't even bother
> > > commenting of the sql style I know its bad form but this is a simple
> > > script). Whenever I try and do the insert I get table not found,
> > > however when I perform the sql through sqlite's command line program
> > > (the sql is outputted via a print statement) it works fine. Any ideas?
> >
> > No, and without more context nobody will have. Does working with the
> > table with other statments work, how do you connect the DB, are you sure
> > you really use the same DB-file and so forth.
> >
> Beginner stuff is usually forgetting 'use moviedata'.

This is not needed for sqlite. The database is defined by the file the
sqlite executable is working on.
-- 
http://mail.python.org/mailman/listinfo/python-list


  1   2   3   4   5   >