Re: Python IDE/Eclipse

2011-08-28 Thread flebber
On Aug 27, 6:34 pm, UncleLaz  wrote:
> On Aug 26, 5:18 pm, Dave Boland  wrote:
>
>
>
>
>
>
>
>
>
> > I'm looking for a good IDE -- easy to setup, easy to use -- for Python.
> >   Any suggestions?
>
> > I use Eclipse for other projects and have no problem with using it for
> > Python, except that I can't get PyDev to install.  It takes forever,
> > then produces an error that makes no sense.
>
> > An error occurred while installing the items
> >    session context was:(profile=PlatformProfile,
> > phase=org.eclipse.equinox.internal.provisional.p2.engine.phases.Install,
> > operand=null --> [R]org.eclipse.cvs 1.0.400.v201002111343,
> > action=org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.InstallBu 
> > ndleAction).
> >    Cannot connect to keystore.
> >    This trust engine is read only.
> >    The artifact file for
> > osgi.bundle,org.eclipse.cvs,1.0.400.v201002111343 was not found.
>
> > Any suggestions on getting this to work?
>
> > Thanks,
> > Dave
>
> I use Aptana Studio 3, it's pretty good and it's based on eclipse

Emacs with emacs-for-python makes the install and setup a breeze and
emacs does a lot for you without much learning.
http://gabrielelanaro.github.com/emacs-for-python/

geany is great I use it the most.
http://www.geany.org/

Finally this is a fairly new project, but it could be pretty good.
they are heavy in development of version 2. Ninja ide
http://ninja-ide.org/
they provide packages for Debian/ubuntu fedora mandriva & windows and
the developers are very helpful if you have any issues or questions
jump on IRC for a chat.

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


Re: Free software versus software idea patents (was: Python benefits over Cobra)

2011-04-07 Thread flebber
On Apr 7, 7:17 pm, Chris Angelico  wrote:
> On Thu, Apr 7, 2011 at 5:39 PM, Steven D'Aprano
>
>  wrote:
> > Do you want to know who scares me? Google and Apple. Google, because
> > they're turning software from something you run on your own computer to
> > something you use on a distant server you have no control over. And
> > Apple, because they're turning the computer from a general purpose
> > computing device you control, to a locked-down, restricted, controlled
> > specialist machine that only runs what they permit you to run. But I
> > digress.
>
> I agree about Apple, but Google are not "turning software... into";
> they are providing an option that involves such things. They are not
> stopping you from running software on your own computer, and they
> never can.
>
> One of my hobbies is running (and, let's face it, playing) online
> games. The MUD system is similar to what Google does, only more so;
> the server has *everything* and the client is just basic TELNET. Yes,
> some clients have some nice features, but they don't need to, and some
> of my players use extremely basic terminals. But nobody complains that
> they're playing a game they have no control over (and the only
> complaints about "a distant server" relate to ping times).
>
> Having the option to cloud things is a Good Thing. Yes, you lose
> control if you put your data on someone else's cloud, but if you want
> the functionality, you pay the price. If you don't like that price,
> you stick with your desktop software.
>
> Chris Angelico

Currently Oracle's actions seem far more concerning than anything
microsoft could cook up. Look at the "Open"jdk
http://www.theregister.co.uk/2011/02/04/openjdk_rules/

now thats a joke...

>As I see it, C# has never had more than an 8% market share. But perhaps
>you have some better data.

Jobs posted in Sydeny in the last 3 days on our major search
seek.com.au;

Jobs% of total Jobs
c#  134 17.1%
java422 53.9%
python  29  3.7%
c++ 79  10.1%
Ruby16  2.0%
asp.net 103 13.2%
scala   0   0.0%
Total   783


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


Re: Python IDE/text-editor

2011-04-16 Thread flebber
On Apr 16, 3:43 pm, Alec Taylor  wrote:
> Thanks, but non of the IDEs so far suggested have an embedded python
> interpreter AND tabs... a few of the editors (such as Editra) have
> really nice interfaces, however are missing the embedded
> interpreter... emacs having the opposite problem, missing tabs (also,
> selecting text with my mouse is something I do often).
>
> Please continue your recommendations.
>
> Thanks,
>
> Alec Taylor
>
>
>
>
>
>
>
> On Sat, Apr 16, 2011 at 3:29 PM, John Bokma  wrote:
> > Ben Finney  writes:
>
> >> Alec Taylor  writes:
>
> >>> I'm looking for an IDE which offers syntax-highlighting,
> >>> code-completion, tabs, an embedded interpreter and which is portable
> >>> (for running from USB on Windows).
>
> >> Either of Emacs http://www.gnu.org/software/emacs/> or Vim
> >> http://www.vim.org/> are excellent general-purpose editors that
> >> have strong features for programmers of any popular language or text
> >> format.
>
> > I second Emacs or vim. I currently use Emacs the most, but I think it's
> > good to learn both.
>
> > --
> > John Bokma                                                               j3b
>
> > Blog:http://johnbokma.com/   Facebook:http://www.facebook.com/j.j.j.bokma
> >    Freelance Perl & Python Development:http://castleamber.com/
> > --
> >http://mail.python.org/mailman/listinfo/python-list

Editra via shelf has an imbedded interpreter, editra is also working
towards a new python tools plugin that will allow you to change
interpreter jython/python2.7/python3.2 etc.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python IDE/text-editor

2011-04-16 Thread flebber
On Apr 16, 11:07 pm, John Bokma  wrote:
> Jorgen Grahn  writes:
> > If you cannot stand non-tabbed interfaces, you probably can't stand
> > other non-Windows-like features of these two, like their menu systems.
>
> Emacs just has a menu system. Although I rarely use it :-). One of the
> things one learns after some time with either vim or Emacs is that using
> the mouse delays things.
>
> --
> John Bokma                                                               j3b
>
> Blog:http://johnbokma.com/   Facebook:http://www.facebook.com/j.j.j.bokma
>     Freelance Perl & Python Development:http://castleamber.com/

Also Dreampie is a greater interactive shell.

http://dreampie.sourceforge.net/

Features automatic completion of attributes and file names.
Automatically displays function arguments and documentation.
Keeps your recent results in the result history, for later user.
Can automatically fold long outputs, so you can concentrate on what's
important.
Lets you save the history of the session as an HTML file, for future
reference. You can then load the history file into DreamPie, and
quickly redo previous commands.
Automatically adds parentheses and optionally quotes when you press
space after functions and methods. For example, execfile fn
automatically turns into execfile("fn").
Supports interactive plotting with matplotlib. (You have to set
"interactive: True" in the matplotlibrc file for this to work.)
Supports Python 2.5, 2.6, 2.7, Jython 2.5, IronPython 2.6 and Python
3.1.
Works on Windows, Linux and Mac. (Mac support requires MacPorts.)
Extremely fast and responsive.
Free software licensed under GPL version 3.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Make Python "portable" by default! (Re: Python IDE/text-editor)

2011-04-18 Thread flebber
On Apr 18, 6:33 pm, Chris Angelico  wrote:
> On Mon, Apr 18, 2011 at 6:15 PM, Wolfgang Keller  wrote:
> > Which part of the word "installed" don't you understand while actually
> > using it? >;->
>
> I have various programs which I distribute in zip/tgz format, and also
> as a self-extracting executable on Windows. Does this mean they need
> to be "installed" only under Windows? No. They need to be installed to
> be run, it's just that the installer is unzip or tar.
>
> (FYI, we "installed" a new minister in the church's manse a few weeks
> ago. Didn't involve anything more than a mv.)
>
> Chris Angelico

WTF
>it's just that the installer is unzip or tar.
If I take my clothes out of my luggage bag have i just installed them?
Don't think so unless your new minister is wearing them lol.

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


Re: learnpython.org - an online interactive Python tutorial

2011-04-23 Thread flebber
On Apr 23, 4:28 pm, Dennis Lee Bieber  wrote:
> On Fri, 22 Apr 2011 17:08:53 +1000, Chris Angelico 
> declaimed the following in gmane.comp.python.general:
>
> > I'm not so sure that all strings should autopromote to integer (or
> > "numeric" generally). However, adding a string and a number _should_
> > (IMHO) promote the number to string.
>
> > print "Hello, "+name+", you have "+credit+" dollars of credit with us."
>
> > Okay, that one is probably better done with the % operator, but it
> > definitely makes logical sense to concatenate numbers and strings as
> > strings, not to add them as numbers.
>
>         But what if /I/ want
>                 "A" + 1
> to return
>                 "B"
>
> 
> --
>         Wulfraed                 Dennis Lee Bieber         AF6VN
>         wlfr...@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

I like what you have done. Was it deliberate that your site teaches
python 2.x code rather than 3.x?
-- 
http://mail.python.org/mailman/listinfo/python-list


zip list, variables

2013-11-20 Thread flebber
If 

c = map(sum, zip([1, 2, 3], [4, 5, 6]))

c
Out[7]: [5, 7, 9]

why then can't I do this? 

a = ([1, 2], [3, 4])

b = ([5, 6], [7, 8])

c = map(sum, zip(a, b))
---
TypeError Traceback (most recent call last)
 in ()
> 1 c = map(sum, zip(a, b))

TypeError: unsupported operand type(s) for +: 'int' and 'list'

How can I do this legally?

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


Re: zip list, variables

2013-11-20 Thread flebber
Thank you for the replies.

Looking at the replies I am wondering which solution is more scalable. At the 
moment it is only 2 nested lists but what about 5, 10, 20 or more?

Should I start looking into numpy to handle this or will list comprehension
  >>> [ [ x + y for x, y in zip(x,y) ] for x, y in zip(a,b) ] 
Be sufficient ?

Thanks

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


Engaging, powerful - video inspriration/learning - Your best selections

2014-11-08 Thread flebber
Morning

Have you seen any python videos that were part of a series or that were from a 
conference that you found engaging and made a point click or solidify a concept 
or drive you to action to create something you wanted. That took an advanced 
topic or concept and made it clear as day to you.

I have watched some Scipy conf videos which I really appreciated though some of 
the subject matter was over my technical level.

Jessica McKellar did a great talk on the future of python.
http://pyvideo.org/video/2375/the-future-of-python-a-choose-your-own-adventur

Looking forward to see what videos engaged and drove your passion and increased 
your skills. 

Live engaged

sayth

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


Re: Leo 5.0 alpha 2 released

2014-11-08 Thread flebber
On Saturday, 8 November 2014 23:26:20 UTC+11, edre...@gmail.com  wrote:
> Leo 5.0a2 is now available at:
> http://sourceforge.net/projects/leo/files/Leo/
> 
> Leo is a PIM, an IDE and an outliner.
> Video tutorials: http://leoeditor.com/screencasts.html
> Text tutorials: http://leoeditor.com/tutorial.html
> 
> The highlights of Leo 5.0
> --
> 
> * Better compatibility with vim, Emacs, pylint and PyQt:
> - Optional native emulation of vim commands.
> - Full support for Emacs org-mode outlines.
> - Better support for pylint.
> - Support for both PyQt4 and PyQt5.
> * Better handling of nodes containing large text:
> - Idle time syntax coloring eliminates delay.
> - Optional delayed loading of large text.
> * Power features:
> - Leo available via github repository.
> - File name completion.
> - Cloned nodes expand and contract independently.
> - @data nodes can be composed from descendant nodes.
> - No need to change Leo's main style sheet:
>   it can be customized with @color and @font settings.
> - @persistence nodes save data in @auto trees.
> - A pluggable architecture for @auto nodes.
> - The style-reload command changes Leo's appearance instantly.
> * Important new plugins for tagging, display and node evaluation.
> * For beginners:
> - Leo's default workbook files contains Leo's quickstart guide.
> * Hundreds of new/improved features and bug fixes.
> 
> Links:
> --
> Leo:   http://leoeditor.com
> Docs:  http://leoeditor.com/leo_toc.html
> Tutorials: http://leoeditor.com/tutorial.html
> Videos:http://leoeditor.com/screencasts.html
> Forum: http://groups.google.com/group/leo-editor
> Download:  http://sourceforge.net/projects/leo/files/
> Github:https://github.com/leo-editor/leo-editor
> Quotes:http://leoeditor.com/testimonials.html

I tried to learn that is understand how Leo benefited me. There must be a click 
and aha moment with this editor, I never made it there. Having said that i got 
proficient with vim but not quite with that either.

I use brackets currently.

Have a great day

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


Engaging, powerful - video inspriration/learning - Your best selections

2014-11-09 Thread flebber
Not fans of videos hey(well python videos anyway) bugger.

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


Help with map python 2

2015-01-04 Thread flebber
In repsonse to this question: Write a program that prints the first 100 members 
of the sequence 2, -3, 4, -5, 6, -7, 8.

This is my solution it works but ugly.

series = range(2,100)
# answer = [(x,(y* -1)) for x, y in series[::2]]
# print(answer)
answer = []
for item in series:
if item % 2 != 0:
answer.append(item * -1)
else:
answer.append(item)

print(answer)

I know I should be better off doing this with map but cannot get it to work. I 
understand also that map returns a generator so this solution should only 
working in python2(correct me please if I am wrong).

In [6]: map?
Type:   builtin_function_or_method
String Form:
Namespace:  Python builtin
Docstring:
map(function, sequence[, sequence, ...]) -> list

Just getting something wrong
list(map((lambda x: x * -1 if (x%2 != 0)), series))
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help with map python 2

2015-01-05 Thread flebber

> You could do what mathematicians do when they deal with alternating
> signs: they raise -1 to the power of the index to get an appropriate
> multiplier.
> 
>>>> [ n * (-1) ** n for n in range(10) ]
>[0, -1, 2, -3, 4, -5, 6, -7, 8, -9]
>>>> 
> 
> Or you could do here what you attempt to do with map below. See below.
> 

> 
> You are trying to use a binary expression. There are no binary
> expressions. Add an else branch to make it ternary:
> 
>lambda x : x if x % 2 == 0 else -x
> 
> But never mind the number of branches, the serious point is that you
> didn't specify a value for when the condition is not true. It doesn't
> make sense without that.
> 
> There's nothing wrong with a list comprehension, or the corresponding
> generator expression if you want a generator. It's fine. Map's fine.

Thanks Jussi  I really like the multiplier solution.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help with map python 2

2015-01-05 Thread flebber

> In py2, map produces a list already.  In any case, above is syntax error 
> without else clause.
> 
> map(lambda x: x * -1 if x%2 else x, series)
> 
> If you do not have a function already, a list comp is better.
> 
> [(-1*k if k%2 else k) for k in range(2, N)]
> 
> Change [] to () and you have a generator expression.

Thanks Terry
[(-1*k if k%2 else k) for k in range(2, N)] 

is really short and I think pythonic being a list comprehension and works in 
py2 and py3.

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


If you were starting a project with XML datasource using python

2015-01-05 Thread flebber
Hi

I need some advice on managing data in the form of xml. I will have to 
repeatedly import a small xml file but with many complex attributes.

If I want to retain data integrity and keep the import process simple and 
querying from the stored source simple what are my best options?

There are several options for converting XML into objects such as:
http://lxml.de/objectify.html
https://pypi.python.org/pypi/pyxml2obj/
http://eulxml.readthedocs.org/en/latest/xmlmap.html

I could push this as an embedded object into mongo and search from there.

Could ignore XML by just converting to json with something like xml2json and 
pushing to many databases from there.

MySQL, Mongodb, couchdb and existdb are all viable options. Existdb is  
directly an XML db so I could directly store from there and use the REST API to 
access http://exist-db.org/exist/apps/doc/devguide_rest.xml

somewhat bamboozled by the range of options and no clear obvious solution.

If you were starting a project, it relied on XML as its datasource what would 
you use and why? And have you used it or just speculating?

Thank you for your time

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


Re: If you were starting a project with XML datasource using python

2015-01-05 Thread flebber
> 
> >If you were starting a project, it relied on XML as its datasource what 
> >would you use and why? And have you used it or just speculating?
> >
>   If I were starting a project, I'd argue furiously that XML is NOT
> something that should be used for dynamic data storage (the original GRAMPS
> not withstanding -- I see it now uses BSDdb). It may be a useful
> representation for transferring/transforming data, but not for
> persistance/updates.
> 
>   If used for data transfer, the schema should be well thought out to
> facilitate updates to the long-term storage format.

So you would convert it to json so it can then be stored? 

Note I don't control the XML at all that is a separate organisation I just have 
to deal with it?

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


Re: Best practices to overcome python's dynamic data type nature

2014-02-14 Thread flebber
Here's a great resource 
http://www.anrdoezrs.net/click-7079286-11260198?url=http%3A%2F%2Fshop.oreilly.com%2Fproduct%2F0636920029533.do%3Fcmp%3Daf-code-book-product_cj_9781449367794_%7BPID%7D&cjsku=0636920029533

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


Re: IDLE won't run after installing Python 3.3 in Windows

2014-02-20 Thread flebber
Well firstly being windows I assume that you did a restart after install.

Python.org python doesn't come with the windows extensions which can be 
installed separately. 

On windows I use winpython is totally portable and can be installed as system 
version includes all extensions as well as Numpy and matplotlib etc which can 
be a bit tricky to install otherwise. 

There is enthought and anaconda packaged python a well but my choice is 
winpython 

Give it a try and you'll definitely have a working system version. 

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


golang OO removal, benefits. over python?

2014-03-09 Thread flebber
I was wondering if a better programmer than I could explain if the removal of 
OO features in golang really does offer an great benefit over python.

An article I was reading ran through a brief overview of golang in respect of 
OO features 
http://areyoufuckingcoding.me/2012/07/25/object-desoriented-language/
.

maybe removing OO features would be a benefit to c++ users or Java users but 
python?

As I have seen an interesting reddit or two of people trying to figure out go 
today it was a ruby user, totally lost with structs.

So anecdotally is actually python and ruby users changing to Go, here is a blog 
and reddit from Rob Pike. http://www.reddit.com/comments/1mue70

Why would a Python user change to go except for new and interesting?

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


Re: golang OO removal, benefits. over python?

2014-03-10 Thread flebber

> Also, is there anything seriously lacking in Python, Java and C?
> 
> 
> Marko

>From their FAQ:

Go was born out of frustration with existing languages and environments for 
systems programming. Programming had become too difficult and the choice of 
languages was partly to blame. One had to choose either efficient compilation, 
efficient execution, or ease of programming; all three were not available in 
the same mainstream language. Programmers who could were choosing ease over 
safety and efficiency by moving to dynamically typed languages such as Python 
and JavaScript rather than C++ or, to a lesser extent, Java.

Go is an attempt to combine the ease of programming of an interpreted, 
dynamically typed language with the efficiency and safety of a statically 
typed, compiled language. It also aims to be modern, with support for networked 
and multicore computing.

>
Although Go doesn't have exception handling either which is odd. 
http://blog.golang.org/error-handling-and-go
http://uberpython.wordpress.com/2012/09/23/why-im-not-leaving-python-for-go/
Or you can use defer http://blog.golang.org/defer-panic-and-recover
func CopyFile(dstName, srcName string) (written int64, err error) {
src, err := os.Open(srcName)
if err != nil {
return
}
defer src.Close()

dst, err := os.Create(dstName)
if err != nil {
return
}
defer dst.Close()

return io.Copy(dst, src)
}

> That's a strange locution: You are suggesting that go had OOP and it was > > 
> removed 
Although Go has types and methods and allows an object-oriented style of 
programming, there is no type hierarchy. The concept of "interface" in Go 
provides a different approach that we believe is easy to use and in some ways 
more general. There are also ways to embed types in other types to provide 
something analogous--but not identical--to subclassing. 
http://golang.org/doc/faq#Is_Go_an_object-oriented_language

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


xmltodict - TypeError: list indices must be integers, not str

2014-05-10 Thread flebber
I am using xmltodict.

This is how I have accessed and loaded my file.

import xmltodict
document = open("/home/sayth/Scripts/va_benefits/20140508GOSF0.xml", "r")
read_doc = document.read()
xml_doc = xmltodict.parse(read_doc)

The start of the file I am trying to get data out of is.


  http://"; />
  


So thought I had it figured. Can access the elements of meeting and the 
elements of club such as by doing this.

In [5]: xml_doc['meeting']['club']['@abbrevname']
Out[5]: u'Gosford Race Club'

However whenever I try and access race in the same manner I get errors.

In [11]: xml_doc['meeting']['club']['race']['@id']
---
KeyError  Traceback (most recent call last)
 in ()
> 1 xml_doc['meeting']['club']['race']['@id']

KeyError: 'race'

In [12]: xml_doc['meeting']['race']['@id']
---
TypeError Traceback (most recent call last)
 in ()
> 1 xml_doc['meeting']['race']['@id']

TypeError: list indices must be integers, not str

why is accessing race @id any different to the access of club @abbrevname and 
how do I get it for race?

Thanks

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


Re: xmltodict - TypeError: list indices must be integers, not str

2014-05-10 Thread flebber
On Saturday, 10 May 2014 22:10:14 UTC+10, Peter Otten  wrote:
> flebber wrote:
> 
> 
> 
> > I am using xmltodict.
> 
> > 
> 
> > This is how I have accessed and loaded my file.
> 
> > 
> 
> > import xmltodict
> 
> > document = open("/home/sayth/Scripts/va_benefits/20140508GOSF0.xml", "r")
> 
> > read_doc = document.read()
> 
> > xml_doc = xmltodict.parse(read_doc)
> 
> > 
> 
> > The start of the file I am trying to get data out of is.
> 
> > 
> 
> >  
> > date="2014-05-08T00:00:00" gearchanges="-1" stewardsreport="-1"
> 
> > gearlist="-1" racebook="0" postracestewards="0" meetingtype="TAB"
> 
> > rail="True" weather="Fine  " trackcondition="Dead  "
> 
> > nomsdeadline="2014-05-02T11:00:00" weightsdeadline="2014-05-05T16:00:00"
> 
> > acceptdeadline="2014-05-06T09:00:00" jockeydeadline="2014-05-06T12:00:00">
> 
> >
> >   website="http://"; />
> 
> >
> >   stage="Acceptances" distance="1600" minweight="55" raisedweight="0"
> 
> >   class="MDN   " age="~ " grade="0" weightcondition="HCP  
> 
> >   " trophy="0" owner="0" trainer="0" jockey="0" strapper="0"
> 
> >   totalprize="22000" first="12250" second="4250" third="2100"
> 
> >   fourth="1000" fifth="525" time="2014-05-08T12:30:00" bonustype="BX02
> 
> >" nomsfee="0" acceptfee="0" trackcondition="  " timingmethod=" 
> 
> >   " fastesttime="  " sectionaltime="  "
> 
> >   formavailable="0" racebookprize="Of $22000. First $12250, second $4250,
> 
> >   third $2100, fourth $1000, fifth $525, sixth $375, seventh $375, eighth
> 
> >   $375, ninth $375, tenth $375">
> 
> > 
> 
> > 
> 
> > So thought I had it figured. Can access the elements of meeting and the
> 
> > elements of club such as by doing this.
> 
> > 
> 
> > In [5]: xml_doc['meeting']['club']['@abbrevname']
> 
> > Out[5]: u'Gosford Race Club'
> 
> > 
> 
> > However whenever I try and access race in the same manner I get errors.
> 
> > 
> 
> > In [11]: xml_doc['meeting']['club']['race']['@id']
> 
> > 
> 
> ---
> 
> > KeyError  Traceback (most recent call
> 
> > last)  in ()
> 
> > > 1 xml_doc['meeting']['club']['race']['@id']
> 
> > 
> 
> > KeyError: 'race'
> 
> > 
> 
> > In [12]: xml_doc['meeting']['race']['@id']
> 
> > 
> 
> ---
> 
> > TypeError Traceback (most recent call
> 
> > last)  in ()
> 
> > > 1 xml_doc['meeting']['race']['@id']
> 
> > 
> 
> > TypeError: list indices must be integers, not str
> 
> > 
> 
> > why is accessing race @id any different to the access of club @abbrevname
> 
> > and how do I get it for race?
> 
> 
> 
> If I were to guess: there are multiple races per meeting, xmltodict puts 
> 
> them into a list under the "race" key, and you have to pick one:
> 
> 
> 
> >>> doc = xmltodict.parse("""\
> 
> ... 
> 
> ......
> 
> ......
> 
> ... 
> 
> ... """)
> 
> >>> type(doc["meeting"]["race"])
> 
> 
> 
> >>> doc["meeting"]["race"][0]["@id"]
> 
> 'first race'
> 
> >>> doc["meeting"]["race"][1]["@id"]  
> >>>   
> >>>   
> 
> 'second race' 
>   
>
> 
> 
> 
> So 
> 
> 
> 
> xml_doc['meeting']['race'][0]['@id']
> 
> 
> 
> or
> 
> 
> 
> for race in xml_doc["meeting"]["race"]:
> 
>print(race["@id"])
> 
> 
> 
> might work for you.

Thanks so much Peter, yes both worked indeed. 

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


SQLAlchemy - web framework ?

2014-05-12 Thread flebber
If I want to use SQLAlchemy as my ORM what would be the best option for a web 
framework?

It appears the general advice regarding Django is to do it the Django way and 
use the django ORM and change it out for SQLAlchemy.

That to me limited knowledge leaves flask, pyramid and turbogears 2. So if I 
wanted to not build it all myself as with flask then potentially pyramid, 
turbogears is the best option?

Is this true? I have completed the TG2 intro tutorial and have built several 
small things with flask although I feel offput by doing anything bigger in 
flask.

See what I have done is got my python knowledge to a fair point where I can do 
useful things, good knowledge of web HTML/CSS, built a few small projects in 
flask to get an idea for python web, completed django tutorials, turogears 
tutorials and now looking to design out a bigger project I want to set myself 
and i am trying to compile the parts so I can see what I will need to use and 
gather info to cover what othe things I will need to know.

Do I have a false fear of flask and doing bigger projects?

So at this point I know I want SQLAlchemy, will use postgres(although 
mysql/maria would work fine). 

Any pratical advice warmly welcomed, I think I am thining too much aimlessly 
maybe.

http://turbogears.org/
http://www.pylonsproject.org/
http://flask.pocoo.org/
https://www.djangoproject.com/
http://www.tornadoweb.org/en/stable/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: SQLAlchemy - web framework ?

2014-05-12 Thread flebber
Roy.that is interesting that you can use mongoengine. 

Recent google results such as seem to assert there are a lot of inherent risk 
in swapping out components, though I may be misinterpreting it. 
http://www.slideshare.net/daikeren/tradeoffs-of-replacing-core-components

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


Re: SQLAlchemy - web framework ?

2014-05-14 Thread flebber
One of the main parts that is tripping myself up is that I need to consistently 
import xml files into my database.

Looking to find the best support and methodologies to do this, that is one of 
the reasons I am looking at SqlAlchemy. 

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


XML python to database

2013-11-01 Thread flebber
Can anyone help me overcome a terminology and jargon barrier I am having in 
fully defining what tools to use to fulfil a process.

I want to create a database 6 Related tables. Update information 1 or twice a 
week with data from an XML file that I will download, this data would update 
rows in 5 tables of the database. From there display, add, edit and view data 
in web page and produce other info based on this.

My main roadblock is the XML process, I am finding it unclear to understand 
what tools and how to manage this process. Most examples show manually 
inputting data.

What I know and have learnt.

 - can insert and update data into database using python(values I type in)
 - can query and view data with python from tables
 - can design good SQL related tables(don't know much NoSQL)
 - Use lxml to open view and find info from nodes of an XML file
 - Basic Django/Flask/Pylons haven't completed a sizable project yet but have 
completed their tutorials and have some previous web experience.

When I look for info on this process

 - Info from django leads ultimately to fixtures Django Docs, initial fixtures 
https://docs.djangoproject.com/en/dev/howto/initial-data/
 - SQLAlchemy info leads 
http://docs.sqlalchemy.org/en/latest/orm/examples.html#xml-persistence

 - Spyne RPC toolkit   http://spyne.io/#s=sql&ser=Xml&show=Schema

 Reading these I am not sure this covers what I am actually trying to do, 
reliably and repeatedly update a database with XML data. Can anyone advise of 
the correct terminology I should be searching for to learn more. What python 
tools would best help me complete 

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


Re: XML python to database

2013-11-01 Thread flebber
Yes I have done the lxml search and learnt how to open view and query the file.

But what is the next step in the process? To get it so that I can reliably push 
XML files to my database repeatedly.

Looking for a basic structure or example to use to guide me for first time.

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


PyDev 3.0 Released

2013-11-07 Thread flebber
I see the main difference between Liclipes and Eclipse+Pydev being lightweight  
and Loclipse preconfigured to a degree.

Moving forward what advantages would I get by buying Liclipes over Eclipse?

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


fixing an horrific formatted csv file.

2014-07-01 Thread flebber
What I am trying to do is to reformat a csv file into something more usable.
currently the file has no headers, multiple lines with varying columns that are 
not related.

This is a sample

Meeting,05/07/14,RHIL,Rosehill Gardens,Weights,TAB,+3m Entire Circuit,  
,
Race,1,CIVIC STAKES,CIVIC,CIVIC,1350,~ ,3U,~ ,QLT   
,54,0,0,5/07/2014,,  ,  ,  ,  ,No class 
restriction, Quality, For Three-Years-Old and Upwards, No sex restriction, 
(Listed),Of $10. First $6, second $2, third $1, fourth $5000, 
fifth $2000, sixth $1000, seventh $1000, eighth $1000
Horse,1,Bennetta,0,"Grahame Begg",Randwick,,0,0,16-3-1-3 
$390450.00,,0,0,0,,98.00,M,
Horse,2,Breakfast in Bed,0,"David Vandyke",Warwick Farm,,0,0,20-6-1-5 
$201250.00,,0,0,0,,81.00,M,
Horse,3,Capital Commander,0,"Gerald Ryan",Rosehill,,0,0,43-9-9-3 
$438625.00,,0,0,0,,85.00,M,
Horse,4,Coup Ay Tee (NZ),0,"Chris Waller",Rosehill,,0,0,35-9-6-5 
$519811.00,,0,0,0,,101.00,G,
Horse,5,Generalife,0,"John O'Shea",Warwick Farm,,0,0,19-6-1-3 
$235045.00,,0,0,0,,87.00,G,
Horse,6,He's Your Man (FR),0,"Chris Waller",Rosehill,,0,0,13-2-3-1 
$108110.00,,0,0,0,,93.00,G,
Horse,7,Hidden Kisses,0,"Chris Waller",Rosehill,,0,0,40-8-8-5 
$565750.00,,0,0,0,,96.00,M,
Horse,8,Oakfield Commands,0,"Gerald Ryan",Rosehill,,0,0,22-7-4-6 
$269530.00,,0,0,0,,94.00,G,
Horse,9,Taxmeifyoucan,0,"Gregory Hickman",Warwick Farm,,0,0,18-2-4-4 
$539730.00,,0,0,0,,91.00,G,
Horse,10,The Peak,0,"Bart & James Cummings",Randwick,,0,0,15-6-1-0 
$426732.00,,0,0,0,,95.00,G,
Horse,11,Tougher Than Ever (NZ),0,"Chris Waller",Rosehill,,0,0,17-3-2-3 
$321613.00,,0,0,0,,97.00,H,
Horse,12,TROMSO,0,"Chris Waller",Rosehill,,0,0,47-8-11-2 
$622300.00,,0,0,0,,103.00,G,
Race,2,FLYING WELTER - BENCHMARK 95 HCP,BM95,BM95,1100,BM95  ,3U,~  
   ,HCP   ,54,0,0,5/07/2014,,  ,  ,  ,  
,BenchMark 95, Handicap, For Three-Years-Old and Upwards, No sex restriction,Of 
$85000. First $48750, second $16750, third $8350, fourth $4150, fifth $2000, 
sixth $1000, seventh $1000, eighth $1000, ninth $1000, tenth $1000
Horse,1,Big Bonanza,0,"Don Robb",Wyong,,0,57.5,31-9-4-3 
$366860.00,,0,0,0,,92.00,G,
Horse,2,Casual Choice,0,"Joseph Pride",Warwick Farm,,0,54,8-2-3-0 
$105930.00,,0,0,0,

So what I am trying to so is end up with an output like this.

Meeting, Date, Race, Number, Name, Trainer, Location
Rosehill, 05/07/14, 1, 1,Bennetta,"Grahame Begg",Randwick,
Rosehill, 05/07/14, 1, 2,Breakfast in Bed,"David Vandyke",Warwick Farm,

So as a start i thought i would try inserting the Meeting and Race number 
however I am just not getting it right.

import csv

outfile = open("/home/sayth/Scripts/cleancsv.csv", "w")
with open('/home/sayth/Scripts/test.csv') as f:
f_csv = csv.reader(f)
headers = next(f_csv)
for row in f_csv:
meeting = row[3] in row[0] == 'Meeting'
new = row.insert(0, meeting)
while row[1] in row[0] == 'Race' < 9:  # pref less than next found 
row[0]

# grab row[1] as id number
id = row[1]
# from row[0] and insert it in first position
new_lines = new.insert(1, id)
outfile.write(new_lines)
outfile.close()

How should I go about this?

Thanks

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


Re: fixing an horrific formatted csv file.

2014-07-01 Thread flebber
That's a really cool solution.

I understand why providing full solutions is frowned upon, because it doesn't 
assist in learning. Which is true,  it's incredibly helpful in this case.

The python cookbook is really good and what I was using as a start for dealing 
with csv. But it doesn't even go anywhere near this. Lots of examples with 
simple inputs.

Anyway Thanks again

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


Re: fixing an horrific formatted csv file.

2014-07-02 Thread flebber
> >>> TM = TX.Table_Maker (headings = 
> ('Meeting','Date','Race','Number','Name','Trainer','Location')) 
> >>> TM (race_table (your_csv_text)).write () 

Where do I find TX? Found this mention in the list, was it available in pip by 
any name?
https://mail.python.org/pipermail/python-list/2014-February/667464.html

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


Re: fixing an horrific formatted csv file.

2014-07-03 Thread flebber
I have taken the code and gone a little further, but I need to be able to 
protect myself against commas and single quotes in names.

How is it the best to do this?

so in my file I had on line 44 this trainer name.

"Michael, Wayne & John Hawkes" 

and in line 95 this horse name.
Inz'n'out

this throws of my capturing correct item 9. How do I protect against this?

Here is current code.

import re
from sys import argv
SCRIPT, FILENAME = argv


def out_file_name(file_name):
"""take an input file and keep the name with appended _clean"""
file_parts = file_name.split(".",)
output_file = file_parts[0] + '_clean.' + file_parts[1]
return output_file


def race_table(text_file):
"""utility to reorganise poorly made csv entry"""
input_table = [[item.strip(' "') for item in record.split(',')]
   for record in text_file.splitlines()]
# At this point look at input_table to find the record indices
output_table = []
for record in input_table:
if record[0] == 'Meeting':
meeting = record[3]
elif record[0] == 'Race':
date = record[13]
race = record[1]
elif record[0] == 'Horse':
number = record[1]
name = record[2]
results = record[9]
res_split = re.split('[- ]', results)
starts = res_split[0]
wins = res_split[1]
seconds = res_split[2]
thirds = res_split[3]
prizemoney = res_split[4]
trainer = record[4]
location = record[5]
print(name, wins, seconds)
output_table.append((meeting, date, race, number, name,
 starts, wins, seconds, thirds, prizemoney,
 trainer, location))
return output_table

MY_FILE = out_file_name(FILENAME)

# with open(FILENAME, 'r') as f_in, open(MY_FILE, 'w') as f_out:
# for line in race_table(f_in.readline()):
# new_row = line
with open(FILENAME, 'r') as f_in, open(MY_FILE, 'w') as f_out:
CONTENT = f_in.read()
# print(content)
FILE_CONTENTS = race_table(CONTENT)
# print new_name
f_out.write(str(FILE_CONTENTS))


if __name__ == '__main__':
pass
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: fixing an horrific formatted csv file.

2014-07-04 Thread flebber
On Friday, 4 July 2014 14:12:15 UTC+10, flebber  wrote:
> I have taken the code and gone a little further, but I need to be able to 
> protect myself against commas and single quotes in names.
> 
> 
> 
> How is it the best to do this?
> 
> 
> 
> so in my file I had on line 44 this trainer name.
> 
> 
> 
> "Michael, Wayne & John Hawkes" 
> 
> 
> 
> and in line 95 this horse name.
> 
> Inz'n'out
> 
> 
> 
> this throws of my capturing correct item 9. How do I protect against this?
> 
> 
> 
> Here is current code.
> 
> 
> 
> import re
> 
> from sys import argv
> 
> SCRIPT, FILENAME = argv
> 
> 
> 
> 
> 
> def out_file_name(file_name):
> 
> """take an input file and keep the name with appended _clean"""
> 
> file_parts = file_name.split(".",)
> 
> output_file = file_parts[0] + '_clean.' + file_parts[1]
> 
> return output_file
> 
> 
> 
> 
> 
> def race_table(text_file):
> 
> """utility to reorganise poorly made csv entry"""
> 
> input_table = [[item.strip(' "') for item in record.split(',')]
> 
>for record in text_file.splitlines()]
> 
> # At this point look at input_table to find the record indices
> 
> output_table = []
> 
> for record in input_table:
> 
> if record[0] == 'Meeting':
> 
> meeting = record[3]
> 
> elif record[0] == 'Race':
> 
> date = record[13]
> 
> race = record[1]
> 
> elif record[0] == 'Horse':
> 
> number = record[1]
> 
> name = record[2]
> 
> results = record[9]
> 
> res_split = re.split('[- ]', results)
> 
> starts = res_split[0]
> 
> wins = res_split[1]
> 
> seconds = res_split[2]
> 
> thirds = res_split[3]
> 
> prizemoney = res_split[4]
> 
> trainer = record[4]
> 
> location = record[5]
> 
> print(name, wins, seconds)
> 
> output_table.append((meeting, date, race, number, name,
> 
>  starts, wins, seconds, thirds, prizemoney,
> 
>  trainer, location))
> 
> return output_table
> 
> 
> 
> MY_FILE = out_file_name(FILENAME)
> 
> 
> 
> # with open(FILENAME, 'r') as f_in, open(MY_FILE, 'w') as f_out:
> 
> # for line in race_table(f_in.readline()):
> 
> # new_row = line
> 
> with open(FILENAME, 'r') as f_in, open(MY_FILE, 'w') as f_out:
> 
> CONTENT = f_in.read()
> 
> # print(content)
> 
> FILE_CONTENTS = race_table(CONTENT)
> 
> # print new_name
> 
> f_out.write(str(FILE_CONTENTS))
> 
> 
> 
> 
> 
> if __name__ == '__main__':
> 
> pass

So I found this on stack overflow

In [2]: import string

In [3]: identity = string.maketrans("", "")

In [4]: x = ['+5556', '-1539', '-99', '+1500']

In [5]: x = [s.translate(identity, "+-") for s in x]

In [6]: x
Out[6]: ['5556', '1539', '99', '1500']

but it fails in my file, due to I believe mine being a list of list. Is there 
an easy way to iterate the sublists without flattening?

Current code.

input_table = [[item.strip(' "') for item in record.split(',')]
   for record in text_file.splitlines()]
# At this point look at input_table to find the record indices
identity = string.maketrans("", "")
print(input_table)
input_table = [s.translate(identity, ",'") for s
   in input_table]

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


Re: fixing an horrific formatted csv file.

2014-07-04 Thread flebber
On Friday, 4 July 2014 16:19:09 UTC+10, Gregory Ewing  wrote:
> flebber wrote:
> 
> > so in my file I had on line 44 this trainer name.
> 
> > 
> 
> > "Michael, Wayne & John Hawkes"
> 
> > 
> 
> > and in line 95 this horse name. Inz'n'out
> 
> > 
> 
> > this throws of my capturing correct item 9. How do I protect against this?
> 
> 
> 
> Use python's csv module to read the file. Don't try to
> 
> do it yourself; the rules for handling embedded commas
> 
> and quotes in csv are quite complicated. As long as
> 
> the file is a well-formed csv file, the csv module
> 
> should parse fields like that correctly.
> 
> 
> 
> -- 
> 
> Greg

True Greg worked easier

def race_table(text_file):
"""utility to reorganise poorly made csv entry"""
# input_table = [[item.strip(' "') for item in record.split(',')]
#for record in text_file.splitlines()]
# At this point look at input_table to find the record indices
# identity = string.maketrans("", "")
# print(input_table)
# input_table = [s.translate(identity, ",'") for s
#in input_table]
output_table = []
for record in text_file:
if record[0] == 'Meeting':
meeting = record[3]
elif record[0] == 'Race':
date = record[13]
race = record[1]
elif record[0] == 'Horse':
number = record[1]
name = record[2]
results = record[9]
res_split = re.split('[- ]', results)
starts = res_split[0]
wins = res_split[1]
seconds = res_split[2]
thirds = res_split[3]
try:
prizemoney = res_split[4]
finally:
prizemoney = 0
trainer = record[4]
location = record[5]
print(name, wins, seconds)
output_table.append((meeting, date, race, number, name,
 starts, wins, seconds, thirds, prizemoney,
 trainer, location))
return output_table

MY_FILE = out_file_name(FILENAME)

# with open(FILENAME, 'r') as f_in, open(MY_FILE, 'w') as f_out:
# for line in race_table(f_in.readline()):
# new_row = line
with open(FILENAME, 'r') as f_in, open(MY_FILE, 'w') as f_out:
CONTENT = csv.reader(f_in)
# print(content)
FILE_CONTENTS = race_table(CONTENT)
# print new_name
f_out.write(str(FILE_CONTENTS))


if __name__ == '__main__':
pass

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


Re: ruby instance variable in python

2014-10-07 Thread flebber
On Monday, 6 October 2014 21:07:24 UTC+11, roro codeath  wrote:
> in ruby:
> 
> 
> module M
> def ins_var
> @ins_var ||= nil
> end
> 
> 
> def m
> @ins_var = 'val'
> end
> 
> 
> def m2
> m
> ins_var # => 'val'
> end
> end
> 
> 
> in py:
> 
> 
> # m.py
> 
> 
> # how to def ins_var
> 
> 
> def m:
>     # how to set ins_var
> 
> 
> def m2:
>     m()
>     # how to get ins var

I took || to be a ternary. So I assumed your code just sets ins_var to nil and 
then  is called in module m and supplied a val. Could be wrong.

if ins_var is None:
ins_var = 'val'
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: ruby instance variable in python

2014-10-07 Thread flebber
I thought that it was a shortcut in ruby to negate the other option of 
providing another default .

I don't greatly know ruby but took a guess after reading examples here 
https://blog.neowork.com/ruby-shortcuts
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: ruby instance variable in python

2014-10-08 Thread flebber
 The end result of a confusing sentence with no
> 
> context is that I have no idea what you are trying to say. Could you try
> 
> explaining again please?
> 

> 
> Steven

No problem my reply from phone at work a little confusing.

So trying to determine what this does.
def ins_var
@ins_var ||= nil
end 

In particular I was guessing at this.

@ins_var ||= nil

Which I have now found on Rubyinside 
http://www.rubyinside.com/21-ruby-tricks-902.html

>From there

7 - Cut down on local variable definitions

Instead of defining a local variable with some initial content (often just an 
empty hash or array), you can instead define it "on the go" so you can perform 
operations on it at the same time:

(z ||= []) << 'test'

2009 Update: This is pretty rancid, to be honest. I've changed my mind; you 
shouldn't be doing this :)

So now that I know this I am still further lost to the point of the initially 
posted code so my kubuntu has ruby so I have run it, and honestly I need 
further definition on what that code was trying to acheive.

sayth@sayth-TravelMate-5740G:~/scripts$ ruby --version
ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux]
sayth@sayth-TravelMate-5740G:~/scripts$ irb
irb(main):001:0> (z ||= []) << 'test'
=> ["test"]
irb(main):002:0> @ins_var ||= nil
=> nil
irb(main):003:0> def ins_var
irb(main):004:1> @ins_var ||= nil
irb(main):005:1> end
=> nil
irb(main):006:0> def m
irb(main):007:1> @ins_var = "val"
irb(main):008:1> end
=> nil
irb(main):009:0> def m2
irb(main):010:1> ins_var #=> "val"
irb(main):011:1> end
=> nil
irb(main):012:0> m
=> "val"
irb(main):013:0> m2
=> "val"

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


Question about PANDAS

2014-10-19 Thread flebber
On Windows my advice would be to use the anaconda installer. Linux pip will 
work flawlessly. 

If you install anaconda full then you will have pandas as well as an ipython 
launcher installed. 

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


read xml file from compressed file using gzip

2007-06-07 Thread flebber
I was working at creating a simple program that would read the content
of a playlist file( in this case *.k3b") and write it out . the
compressed "*.k3b" file has two file and the one I was trying to read
was maindata.xml . I cannot however seem to use the gzip module
correctly. Have tried the program 2 ways for no success, any ideas
would be appreciated.

Attempt 1

#!/usr/bin/python

import os
import gzip
playlist_file = open('/home/flebber/oddalt.k3b')
class GzipFile([playlist_file[decompress[9, 'rb']]]);

os.system(open("/home/flebber/tmp/maindata.xml"));

for line in maindata.xml:
print line

playlist_file.close()

Attempt 2 - largely just trying to get gzip to work

#!/usr/bin/python

import gzip
fileObj = Gzipfile("/home/flebber/oddalt.k3b", 'rb');
fileContent = fileObj.read()
for line in filecontent:
print line

fileObj.close()

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


Re: read xml file from compressed file using gzip

2007-06-08 Thread flebber
On Jun 8, 9:45 pm, flebber <[EMAIL PROTECTED]> wrote:
> On Jun 8, 3:31 pm, Stefan Behnel <[EMAIL PROTECTED]> wrote:
>
> > flebber wrote:
> > > I was working at creating a simple program that would read the content
> > > of a playlist file( in this case *.k3b") and write it out . the
> > > compressed "*.k3b" file has two file and the one I was trying to read
> > > was maindata.xml.
>
> > Consider using lxml. It reads in gzip compressed XML files transparently and
> > provides loads of other nice XML goodies.
>
> >http://codespeak.net/lxml/dev/
>
> > Stefan
>
> I will, baby steps at the moment for me at the moment though as I am
> only learning and can't get gzip to work

This is my latest attempt

#!/usr/bin/python

import os
import zlib

class gzip('/home/flebber/oddalt.k3b', 'rb')

main_data = os.system(open("/home/flebber/maindata.xml"));

for line in main_data:
print line

main_data.close()





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


Re: read xml file from compressed file using gzip

2007-06-08 Thread flebber
On Jun 8, 3:31 pm, Stefan Behnel <[EMAIL PROTECTED]> wrote:
> flebber wrote:
> > I was working at creating a simple program that would read the content
> > of a playlist file( in this case *.k3b") and write it out . the
> > compressed "*.k3b" file has two file and the one I was trying to read
> > was maindata.xml.
>
> Consider using lxml. It reads in gzip compressed XML files transparently and
> provides loads of other nice XML goodies.
>
> http://codespeak.net/lxml/dev/
>
> Stefan

I will, baby steps at the moment for me at the moment though as I am
only learning and can't get gzip to work

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


Gzip - gunzip using zlib

2007-06-08 Thread flebber
Hi Can anyone show me a working example of how to use gzip to
decompress a file. I have read the docs at python.org and had many
goes at it but just can't get it to work.

Cheers

flebber

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


Re: read xml file from compressed file using gzip

2007-06-09 Thread flebber
On Jun 10, 3:45 am, Stefan Behnel <[EMAIL PROTECTED]> wrote:
> flebber wrote:
> > I was working at creating a simple program that would read the content
> > of a playlist file( in this case *.k3b") and write it out . the
> > compressed "*.k3b" file has two file and the one I was trying to read
> > was maindata.xml
>
> The k3b format is a ZIP archive. Use the zipfile library:
>
> file:///usr/share/doc/python2.5-doc/html/lib/module-zipfile.html
>
> Stefan

Thanks for all the help, have been using the docs at python.org and
the magnus t Hetland book. Is there any docs tha re a little more
practical or expressive as most of the module documentation is very
confusing for a beginner and doesn't provide much in the way of
examples on how to use the modules.

Not criticizing the docs as they are probably very good for
experienced programmers.

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


Re: read xml file from compressed file using gzip

2007-06-10 Thread flebber
On Jun 10, 7:43 pm, John Machin <[EMAIL PROTECTED]> wrote:
> On 10/06/2007 3:06 PM, flebber wrote:
>
>
>
> > On Jun 10, 3:45 am, Stefan Behnel <[EMAIL PROTECTED]> wrote:
> >> flebber wrote:
> >>> I was working at creating a simple program that would read the content
> >>> of a playlist file( in this case *.k3b") and write it out . the
> >>> compressed "*.k3b" file has two file and the one I was trying to read
> >>> was maindata.xml
> >> The k3b format is a ZIP archive. Use the zipfile library:
>
> >> file:///usr/share/doc/python2.5-doc/html/lib/module-zipfile.html
>
> >> Stefan
>
> > Thanks for all the help, have been using the docs at python.org and
> > the magnus t Hetland book. Is there any docs tha re a little more
> > practical or expressive as most of the module documentation is very
> > confusing for a beginner and doesn't provide much in the way of
> > examples on how to use the modules.
>
> > Not criticizing the docs as they are probably very good for
> > experienced programmers.
>
> Somebody else has already drawn your attention to the/a tutorial. You
> need to read, understand, and work through a *good* introductory book or
> tutorial before jumping into the deep end.
>
>  > class GzipFile([playlist_file[decompress[9, 'rb']]]);
>
> Errr, no, the [] are a documentation device used in most computer
> language documentation to denote optional elements -- you don't type
> them into your program. See below.
>
> Secondly as Stefan pointed out, your file is a ZIP file (not a gzipped
> file), they're quite different animals, so you need the zipfile module,
> not the gzip module.
>
>  > os.system(open("/home/flebber/tmp/maindata.xml"));
>
> The manuals say quite simply and clearly that:
> open() returns a file object
> os.system's arg is a string (a command, like "grep -i fubar *.pl")
> So that's guaranteed not to work.
>
>  From the docs of the zipfile module:
> """
> class ZipFile( file[, mode[, compression[, allowZip64]]])
>
> Open a ZIP file, where file can be either a path to a file (a string) or
> a file-like object. The mode parameter should be 'r' to read an existing
> file, 'w' to truncate and write a new file,
> or 'a' to append to an existing file.
> """
> ... and you don't care about the rest of the class docs in your simple
> case of reading.
>
> A class has to be called like a function to give you an object which is
> an instance of that class. You need only the first argument; the second
> has about a 99.999% chance of defaulting to 'r' if omitted, but we'll
> play it safe and explicit:
>
> import zipfile
> zf = zipfile.ZipFile('/home/flebber/oddalt.k3b', 'r')
>
> OK, some more useful docs:
> """
> namelist( )
>Return a list of archive members by name.
> printdir( )
>Print a table of contents for the archive to sys.stdout.
> read( name)
>  Return the bytes of the file in the archive. The archive must be
> open for read or append.
> """
>
> So give the following a try:
>
> print zf.namelist()
> zf.printdir()
> xml_string = zf.read('maindata.xml')
> zf.close()
>
> # xml_string will be a string which may or may not have line endings in
> it ...
> print len(xml_string)
>
> # If you can't imagine what the next two lines will do,
> # you'll have to do it once, just to see what happens:
> for line in xml_string:
> print line
>
> # Wasn't that fun? How big was that file? Now do this:
> lines = xml_text.splitlines()
> print len(lines) # number of lines
> print len(lines[0]) # length of first line
>
> # Ummm, maybe if it's only one line you don't want to do this either,
> # but what the heck:
> for line in lines:
>  print line
>
> HTH,
> John

Thanks that was so helpful to see how to do it. I have read a lot but
it wasn't sinking in, and sometimes its better to learn by doing. Some
of the books I have read just seem to go from theory to theory with
the occasional example ( which is meant to show us how good the author
is rather than help us).

For the record

>>> ## working on region in file /usr/tmp/python-F_C5sr.py...
['mimetype', 'maindata.xml']
File Name
Modified Size
mimetype   2007-05-27
20:36:20   17
maindata.xml   2007-05-27
20:36:2010795
>>> print len(xml_string)
10795
>>> for line in xml_string:
   print line
... ...
<
?
x
m
l

v
e
r
s
i.(etc ...it went for a while)

and

>>> lines = xml_string.splitlines()
>>> print len(lines)
387
>>> print len(lines[0])
38
>>> for line in lines:
... print line
  File "", line 2
print line
^
IndentationError: expected an indented block
>>> for line in lines:
print line

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


Number Sequencing, Grouping and Filtering

2009-03-10 Thread flebber
Hi

I was hoping someone would be able to point me in the direction of
some good documentation regarding sequencing, grouping and filtering
and in which order they should be done.

As a small example it is easy to create the range of numbers 1 to 20.
But if I wanted to group all possible combinations of sets of 4
numbers within this range is there already an in uilt function for
this I am searching the module docs with "number sequencing" and
"number grouping" but cannot find info.

Then if I wanted to refine this results further eg no consecutive
numbers to be contained in sets. Is it best to create all sets and
then filter the sets for things matching this criteria or to set this
condition in a creation. Creating sets and then filtering would soon
become unwieldy with a larger range I would imagine..

An ideas, pointers to docs or better search terms to help me explore
this further would be appreciated.

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


Re: Number Sequencing, Grouping and Filtering

2009-03-10 Thread flebber
On Mar 10, 8:54 pm, flebber  wrote:
> Hi
>
> I was hoping someone would be able to point me in the direction of
> some good documentation regarding sequencing, grouping and filtering
> and in which order they should be done.
>
> As a small example it is easy to create the range of numbers 1 to 20.
> But if I wanted to group all possible combinations of sets of 4
> numbers within this range is there already an in uilt function for
> this I am searching the module docs with "number sequencing" and
> "number grouping" but cannot find info.
>
> Then if I wanted to refine this results further eg no consecutive
> numbers to be contained in sets. Is it best to create all sets and
> then filter the sets for things matching this criteria or to set this
> condition in a creation. Creating sets and then filtering would soon
> become unwieldy with a larger range I would imagine..
>
> An ideas, pointers to docs or better search terms to help me explore
> this further would be appreciated.
>
> Thanks Sayth

I have just found itertools is this acheivable using combinations()
and groupby() in itertools?

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


Re: Number Sequencing, Grouping and Filtering

2009-03-10 Thread flebber
On Mar 10, 9:07 pm, Chris Rebert  wrote:
> On Tue, Mar 10, 2009 at 3:00 AM, flebber  wrote:
> > On Mar 10, 8:54 pm, flebber  wrote:
> >> Hi
>
> >> I was hoping someone would be able to point me in the direction of
> >> some good documentation regarding sequencing, grouping and filtering
> >> and in which order they should be done.
>
> >> As a small example it is easy to create the range of numbers 1 to 20.
> >> But if I wanted to group all possible combinations of sets of 4
> >> numbers within this range is there already an in uilt function for
> >> this I am searching the module docs with "number sequencing" and
> >> "number grouping" but cannot find info.
>
> >> Then if I wanted to refine this results further eg no consecutive
> >> numbers to be contained in sets. Is it best to create all sets and
> >> then filter the sets for things matching this criteria or to set this
> >> condition in a creation. Creating sets and then filtering would soon
> >> become unwieldy with a larger range I would imagine..
>
> >> An ideas, pointers to docs or better search terms to help me explore
> >> this further would be appreciated.
>
> >> Thanks Sayth
>
> > I have just found itertools is this acheivable using combinations()
> > and groupby() in itertools?
>
> Yes; indeed, those were the functions your post brought to mind and
> which led me to suggest itertools.
>
> Cheers,
> Chris
>
> --
> I have a blog:http://blog.rebertia.com

the only issue i can see is that i am using python 2.54 currently as
ifelt it more supported by other programs than 2.6 or 3.0. After
searching it seems that itertools has had a upgrade in 2.61
--
http://mail.python.org/mailman/listinfo/python-list


Re: ActivePython 3.1.1.2 vs Python 3.1.1 for OSX?

2009-10-01 Thread flebber
On Oct 1, 11:28 am, srid  wrote:
> On Sep 30, 4:51 pm, Robert Hicks  wrote:
>
> > I am just curious which I should use. I am going to start learning
> > Python soon. Are they comparable and I just do a "eenie meenie minie
> > moe"?
>
> ActivePython is essentially same as the installers from python.org -
> but it also comes with additional documentation and tutorials, such
> as:
>
> Python FAQs
> A snapshot of the Python Enhancement Proposals (PEPs) (For the most
> recent version, refer to the PEPs on python.org .)
> Dive Into Python (A tutorial for programmers)
> Non-Programmers Tutorial For Python
>
> http://docs.activestate.com/activepython/3.1/whatsincluded.html
>
> Also note that 2.6.x is probably the best bet if you are going to use
> some 3rd party libraries (after you learn the basics of Python) ..
> because 3.x does not have many of those libraries ported yet.
>
>  http://www.activestate.com/activepython/
>
> Further, early next week - a new release of ActivePython-2.6 will be
> made available that will include, for the first time, a new Python
> package manager (PyPM) from ActiveState that makes it easier to
> install packages from pypi.python.org(without having to compile them
> yourself). This is similar to PPM from ActivePerl.
>
> -srid

Thats awesome news.
-- 
http://mail.python.org/mailman/listinfo/python-list


Delete all list entries of length unknown

2009-10-04 Thread flebber
Hi

Can someone clear up how I can remove all entries of a list when I am
unsure how many entries there will be. I have been using sandbox to
play essentially I am creating two lists a and b I then want to add a
to b and remove all b entries. This will loop and b will receive new
entries add it to a and delete again.

I am going wrong with slice and list deletion, I assign x = len(b) and
then attempting to delete based on this. Here is my sandbox session.
What part am I getting wrong?

#>>>
a = (1, 2, 3, 4)
b = (5, 6, 7, 8)
#>>>
a
#---
(1, 2, 3, 4)
#>>>
b
#---
(5, 6, 7, 8)
#>>>
a + b
#---
(1, 2, 3, 4, 5, 6, 7, 8)
#>>>
b
#---
(5, 6, 7, 8)
#>>>
len(b)
#---
4
#>>>
x = len(b)
#>>>
del b[0:x]
Traceback (most recent call last):
Error:   File "", line 1, in 
Error: TypeError: 'tuple' object does not support item deletion
#>>>
b[0:x] = d
Traceback (most recent call last):
Error:   File "", line 1, in 
Error: NameError: name 'd' is not defined
#>>>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Delete all list entries of length unknown

2009-10-05 Thread flebber
On Oct 5, 3:05 pm, "Mark Tolonen"  wrote:
> "Chris Rebert"  wrote in message
>
> news:50697b2c0910042047i1cf2c1a3mc388bc74bab95...@mail.gmail.com...
>
> > Tuples are immutable (i.e. they cannot be modified after creation) and
> > are created using parentheses.
>
> Slight correction: tuples are created using commas.  Parentheses are only
> needed to disambiguate from other uses of comma:
>
> Python 2.6.2 (r262:71605, Apr 14 2009, 22:40:02) [MSC v.1500 32 bit (Intel)]
> on win32
> Type "help", "copyright", "credits" or "license" for more information.>>> a=1,
> >>> a
> (1,)
> >>> a=1,2,3
> >>> a
>
> (1, 2, 3)
>
> -Mark

Awesome that has cleared it up for me, plus a bit more thanks.
-- 
http://mail.python.org/mailman/listinfo/python-list


Frameworks

2009-10-18 Thread flebber
Hi

I have been searching through the vast array of python frameworks
http://wiki.python.org/moin/WebFrameworks and its quite astounding the
choice available.

I am looking at using a web framework for my personal project which
isn't actually aimed at developing a website as such. However I deduce
that rather than creating a gui application and screen input for data,
I can use a web browser for this and have a great array of tools to
format input screens and output display formats.

Since I will be retreiving information from several websites (usually
csv files) formatting them and submitting them to a database and
creating queries and printouts based on them most frameworks seem to
handle this basically with ease and for any complex queries most
support SqlAlchemy.

Is it simply a case of just picking one and starting and I would find
it hard to be dissapointed or is there a few special considerations to
make, though I am unsure what they are?

Most obvious ones I am considering are Django (Of course), Pylons
includes SqlAlchemy, Sql Object and templating and I here turbogears
plans to sit on top of this platform. Zope I am considering but I am a
little confused by this. The are heaps of others but not sure how to
narrow the selection criteria.

How/Why woul you split Django and Pylons let alone the others?

Database likely to be MySQl
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Frameworks

2009-10-18 Thread flebber
On Oct 19, 10:01 am, flebber  wrote:
> Hi
>
> I have been searching through the vast array of python 
> frameworkshttp://wiki.python.org/moin/WebFrameworksand its quite astounding 
> the
> choice available.
>
> I am looking at using a web framework for my personal project which
> isn't actually aimed at developing a website as such. However I deduce
> that rather than creating a gui application and screen input for data,
> I can use a web browser for this and have a great array of tools to
> format input screens and output display formats.
>
> Since I will be retreiving information from several websites (usually
> csv files) formatting them and submitting them to a database and
> creating queries and printouts based on them most frameworks seem to
> handle this basically with ease and for any complex queries most
> support SqlAlchemy.
>
> Is it simply a case of just picking one and starting and I would find
> it hard to be dissapointed or is there a few special considerations to
> make, though I am unsure what they are?
>
> Most obvious ones I am considering are Django (Of course), Pylons
> includes SqlAlchemy, Sql Object and templating and I here turbogears
> plans to sit on top of this platform. Zope I am considering but I am a
> little confused by this. The are heaps of others but not sure how to
> narrow the selection criteria.
>
> How/Why woul you split Django and Pylons let alone the others?
>
> Database likely to be MySQl

I guess what makes it so interesting is that there appear to be so man
high quality options. Its astounding.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Frameworks

2009-10-19 Thread flebber
On Oct 19, 7:40 pm, Javier Santana  wrote:
> junohttp://github.com/breily/juno
>
> it's very easy, uses sqlalchemy as ORM and jinja2 (others can be used
> if you want) for templates.
>
> On Mon, Oct 19, 2009 at 10:24 AM, Bruno Desthuilliers
>
>  wrote:
> > flebber a écrit :
>
> >> Hi
>
> >> I have been searching through the vast array of python frameworks
> >>http://wiki.python.org/moin/WebFrameworksand its quite astounding the
> >> choice available.
>
> >> I am looking at using a web framework for my personal project which
> >> isn't actually aimed at developing a website as such. However I deduce
> >> that rather than creating a gui application and screen input for data,
> >> I can use a web browser for this and have a great array of tools to
> >> format input screens and output display formats.
>
> > Yeps - but remember that a web app will have a couple limitations /
> > drawbacks, specially wrt/ handling complex UI.
>
> >> Since I will be retreiving information from several websites (usually
> >> csv files) formatting them and submitting them to a database and
> >> creating queries and printouts based on them most frameworks seem to
> >> handle this basically with ease and for any complex queries most
> >> support SqlAlchemy.
>
> >> Is it simply a case of just picking one and starting and I would find
> >> it hard to be dissapointed or is there a few special considerations to
> >> make, though I am unsure what they are?
>
> > Given your "specs", forget about monstruosities like Zope, Twisted etc, that
> > will mostly get in the way. You have simple needs, use a simple tool !-)
>
> >> Most obvious ones I am considering are Django (Of course),
>
> > A pretty good framework, but you'll loose some of it's nice features if you
> > ever want to use an alternate DB layer or templating system. OTHO, most
> > other more "flexible" frameworks just don't offer this level of integration,
> > so it's may not be such a big deal.
>
> > Note that Django's ORM, while already pretty good and constently improving,
> > is not as powerful as SLQAlchemy (now nothing prevents you from going down
> > to raw SQL for the more complex queries - and this might be better anyway,
> > since complex queries usually requires to be very fine tuned and tend to not
> > be really portable). The Forms API OTHO is a real winner IMHO.
>
> >> Pylons
> >> includes SqlAlchemy, Sql Object and templating and I here turbogears
> >> plans to sit on top of this platform.
>
> > I admit I fail to see what TG brings except for more indirection levels.
>
> >> Zope I am considering but I am a
> >> little confused by this.
>
> > Friendly advice (based on years of working experience): don't waste your
> > time with Zope.
>
> >> The are heaps of others but not sure how to
> >> narrow the selection criteria.
>
> >> How/Why woul you split Django and Pylons let alone the others?
>
> > Django : very strong integration, excellent documentation and support, huge
> > community, really easy to get started with. And possibly a bit more mature
> > and stable...
>
> > Pylons : more loosely coupled (imply: less integration), based on "standard"
> > components - which is both a blessing and a curse, specially wrt/
> > documentation -, requires a good knowledge of Python and the HTTP protocol
> > to get started with. Very powerful and flexible but this comes with a
> > price...
>
> > Now both are written by talented programmers, and both are pretty good
> > tools. I guess it's more a matter of personal preferences and/or external
> > constraints (PHB etc...) than anything else.
>
> > A couple other "lightweight" candidates you migh want to consider are
> > werkzeug and web.py:
>
> >http://werkzeug.pocoo.org/
> >http://webpy.org/
>
> >> Database likely to be MySQl
>
> > Mmmm If your application is "write-heavy", PostgreSQL might be a better
> > choice. Anyway, both Django's ORM and SQLAlchemy work fine with MySQL
> > AFAICT.
> > --
> >http://mail.python.org/mailman/listinfo/python-list
>
>

After further reading Django does indeed cover a lot of bases. When
looking at jinja2 and werkzueg, first thing I noticed is that they are
by the same group called pocoo. Second it shows that I must be
misunderstanding something, can I really use jinja2 and sqlAlchemy by
itself? The werkzeug documentation shows a screencast 
http://werkzeug.pocoo.org/wiki30/
of making a wiki and uses werkzueg, jinja2 and sqlAlchemy, why
werkzueg and jinja2 in combination?

And pylons advises use of SqlAlchemy and Mako or choices of Genshi and
Jinja2, so what is pylons adding? Might have to do a bit more reading
and watch a few more screencasts :-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Frameworks

2009-10-19 Thread flebber
On Oct 19, 10:51 pm, flebber  wrote:
> On Oct 19, 7:40 pm, Javier Santana  wrote:
>
>
>
> > junohttp://github.com/breily/juno
>
> > it's very easy, uses sqlalchemy as ORM and jinja2 (others can be used
> > if you want) for templates.
>
> > On Mon, Oct 19, 2009 at 10:24 AM, Bruno Desthuilliers
>
> >  wrote:
> > > flebber a écrit :
>
> > >> Hi
>
> > >> I have been searching through the vast array of python frameworks
> > >>http://wiki.python.org/moin/WebFrameworksandits quite astounding the
> > >> choice available.
>
> > >> I am looking at using a web framework for my personal project which
> > >> isn't actually aimed at developing a website as such. However I deduce
> > >> that rather than creating a gui application and screen input for data,
> > >> I can use a web browser for this and have a great array of tools to
> > >> format input screens and output display formats.
>
> > > Yeps - but remember that a web app will have a couple limitations /
> > > drawbacks, specially wrt/ handling complex UI.
>
> > >> Since I will be retreiving information from several websites (usually
> > >> csv files) formatting them and submitting them to a database and
> > >> creating queries and printouts based on them most frameworks seem to
> > >> handle this basically with ease and for any complex queries most
> > >> support SqlAlchemy.
>
> > >> Is it simply a case of just picking one and starting and I would find
> > >> it hard to be dissapointed or is there a few special considerations to
> > >> make, though I am unsure what they are?
>
> > > Given your "specs", forget about monstruosities like Zope, Twisted etc, 
> > > that
> > > will mostly get in the way. You have simple needs, use a simple tool !-)
>
> > >> Most obvious ones I am considering are Django (Of course),
>
> > > A pretty good framework, but you'll loose some of it's nice features if 
> > > you
> > > ever want to use an alternate DB layer or templating system. OTHO, most
> > > other more "flexible" frameworks just don't offer this level of 
> > > integration,
> > > so it's may not be such a big deal.
>
> > > Note that Django's ORM, while already pretty good and constently 
> > > improving,
> > > is not as powerful as SLQAlchemy (now nothing prevents you from going down
> > > to raw SQL for the more complex queries - and this might be better anyway,
> > > since complex queries usually requires to be very fine tuned and tend to 
> > > not
> > > be really portable). The Forms API OTHO is a real winner IMHO.
>
> > >> Pylons
> > >> includes SqlAlchemy, Sql Object and templating and I here turbogears
> > >> plans to sit on top of this platform.
>
> > > I admit I fail to see what TG brings except for more indirection levels.
>
> > >> Zope I am considering but I am a
> > >> little confused by this.
>
> > > Friendly advice (based on years of working experience): don't waste your
> > > time with Zope.
>
> > >> The are heaps of others but not sure how to
> > >> narrow the selection criteria.
>
> > >> How/Why woul you split Django and Pylons let alone the others?
>
> > > Django : very strong integration, excellent documentation and support, 
> > > huge
> > > community, really easy to get started with. And possibly a bit more mature
> > > and stable...
>
> > > Pylons : more loosely coupled (imply: less integration), based on 
> > > "standard"
> > > components - which is both a blessing and a curse, specially wrt/
> > > documentation -, requires a good knowledge of Python and the HTTP protocol
> > > to get started with. Very powerful and flexible but this comes with a
> > > price...
>
> > > Now both are written by talented programmers, and both are pretty good
> > > tools. I guess it's more a matter of personal preferences and/or external
> > > constraints (PHB etc...) than anything else.
>
> > > A couple other "lightweight" candidates you migh want to consider are
> > > werkzeug and web.py:
>
> > >http://werkzeug.pocoo.org/
> > >http://webpy.org/
>
> > >> Database likely to be MySQl
>
> > > Mmmm If your application is "write-heavy", PostgreSQL might be a 
> > > better
> > 

Re: Frameworks

2009-10-19 Thread flebber
On Oct 20, 12:32 am, "Diez B. Roggisch"  wrote:
> > web2py is interesting the author appears to be implying(I could be
> > misunderstanding this) that the web2py db ORM is equal to if not
> > superior to SQLAlchemy - From
> >http://www.web2py.com/AlterEgo/default/show/150
>
> I don't read that out of the post, and it almost certainly is wrong, at
> least on a general level. There isn't much above SQLAlchemy regarding
> flexibility & power, so while simple cases might be simpler with other
> ORMs, they often make more complicated ones impossible.
>
> But again, I don't think that's the claim there.
>
> Diez

That sounds fair.

Bruno posted earlier

> >Django : very strong integration, excellent documentation and support,
>huge community, really easy to get started with. And possibly a bit more
>mature and stable...

>Pylons : more loosely coupled (imply: less integration), based on
>"standard" components - which is both a blessing and a curse, specially
>wrt/ documentation -, requires a good knowledge of Python and the HTTP
>protocol to get started with. Very powerful and flexible but this comes
>with a price...

>Now both are written by talented programmers, and both are pretty good
>tools. I guess it's more a matter of personal preferences and/or
>external constraints (PHB etc...) than anything else.

>A couple other "lightweight" candidates you migh want to consider are
>werkzeug and web.py:

>http://werkzeug.pocoo.org/
>http://webpy.org/

In short it seems to me that Django and Web2py include more "magic" in
assisting oneself to create you web/application, whilst Pylons and
Werkzueg leave more control in the users hands hopefully leading to
greater expression and power.

Pylons recommends SQLALchemy and Mako (offers Genshi and Jinja2) and
Werkzueg SQLAlchemy and Jinja2. As I don't have the experience to tell
the pro's cons of these two apart, would choosing Pylons based on
Documentation be a fair call?

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


Re: Frameworks

2009-10-19 Thread flebber
On Oct 20, 3:31 am, Massimo Di Pierro  wrote:
> Hello,
>
> Just to clarify. I did not make any statement about "web2py is  
> superior to SQLAlchemy" since that is somewhat subjective.
> SQLALchemy for example does a much better job at accessing legacy  
> databases. web2py is more limited in that respect and we are working  
> on removing those limitations.
>
> I do believe web2py is easier to use than SQLAlchemy, is faster (but  
> yet I do not know SQLAchemy to optimize it properly) and has many  
> features in common with sqlaclhemy including connection pools, joins,  
> left joins, aggregates, nested selects (I do not know SQLAlchemy well  
> enough to know about advanced features that web2py may be missing).  
> The web2py DAL works on Google App Engine while none of the other ORMs  
> do.
>
> Massimo

So does web2py allow for raw sql if there is an advanced procedure or
query that needs to be performed that is outside the scope of the
web2pr orm
-- 
http://mail.python.org/mailman/listinfo/python-list


Design Ideals Goals Python 3 - Forest for the trees

2010-12-25 Thread flebber
Hi

I was hoping someone could shed some (articles, links) in regards
python 3 design ideals. I was searching guido's blog which has his
overarching view of Python from an early development perspective
http://python-history.blogspot.com/2009/01/pythons-design-philosophy.html
.

I was interested in what the design goals/philosphy was of Python 3
from a birds eye view, forest for the trees approach.

i can safely assume one goal was speed improvement as in the blog he
noted "Don’t fret too much about performance--plan to optimize later
when needed." So I assume that means that Python had developed to a
point where that was needed.

But performance wouldn't be the over-arching criteria for the change.
Just curious.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Design Ideals Goals Python 3 - Forest for the trees

2010-12-25 Thread flebber
On Dec 26, 4:56 pm, Alice Bevan–McGregor  wrote:
> > I was interested in what the design goals/philosphy was of Python 3
> > from a birds eye view, forest for the trees approach.
>
> I think I can safely point to the Zen of Python[1] as many of the
> points therein directly apply to the simplifiation, clarification, and
> goals of Python 3.  Most notably:
>
> :: Beautiful is better than ugly.
>
> E.g. dict.iteritems, dict.iterkeys, dict.itervalues?  Strip 'iter' and
> it's fixed.
>
> :: Special cases aren't special enough to break the rules.
>
> Ever get hung up on core Python modules with title caps?  Yeah, those
> are fixed.
>
> :: There should be one-- and preferably only one --obvious way to do it.
>
> E.g. urllib, urllib2, urllibX… yeah, that's been fixed, too.  :)
>
> :: Namespaces are one honking great idea -- let's do more of those!
>
> Numerous modules have been merged, or moved into more manageable (and
> logical) namespaces.
>
> > I can safely assume one goal was speed improvement as in the blog he
> > noted "Don’t fret too much about performance--plan to optimize later
> > when needed." So I assume that means that Python had developed to a
> > point where that was needed.
>
> The Python GIL (Global Interpreter Lock) has been getting a lot of
> negative attention over the last little while, and was recently fixed
> to be far more intelligent (and efficient) in Python 3.2.  There are
> numerous other performance improvements, for which yo ucan examine the
> change logs.
>
> > But performance wouldn't be the over-arching criteria for the change.
> > Just curious.
>
> Clarification, simplification, specivity, efficiency, … just be more
> "Pythonic".
>
> Note that I'm not a core Python contributor or have ever communicated
> with the BDFL: this is just the viewpoint of somoene doing her
> darnd'est to encourage Python 3 support.  ;)  All of the new projects I
> work on are Python 2.6+ and Python 3.1+ compatible.  (Arguments against
> dual-compatible polygot code can go to /dev/null for the purposes of
> this thread.)
>
>         - Alice
>
> [1]http://www.python.org/dev/peps/pep-0020/

So do the new changes(to the GIL) nullify concerns raised by David
Beazely here http://dabeaz.com/python/UnderstandingGIL.pdf

Some projects have been using and requiring psyco to gain speed
improvements in python http://psyco.sourceforge.net/introduction.html
however it seems that the developer is not active on this project
anymore and is more active on PyPy http://codespeak.net/pypy/dist/pypy/doc/

A program such as AVSP http://avisynth.org/qwerpoi/ which relies on
psyco what would be a good proposition to use when taking the project
to python 3.0 if psyco will remain unavailable?

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


User input masks - Access Style

2010-12-26 Thread flebber
Is there anyay to use input masks in python? Similar to the function
found in access where a users input is limited to a type, length and
format.

So in my case I want to ensure that numbers are saved in a basic
format.
1) Currency so input limited to 000.00 eg 1.00, 2.50, 13.80 etc

For sports times that is time duration not a system or date times
should I assume that I would need to calculate a user input to a
decimal number and then recalculate it to present it to user?

So an example, sorry.

import time #not sure if this is any use
minute = input("How many minutes: ")
seconds = input("How many seconds: ")
Hundredths = input("how many Hundredths: ")

# convert user input
MyTime = (minute/60)+(seconds)+(Hundredths/1800)
#Display to user assuming i had written a name and user
# had retrieved it
print("[User], your time was"), (MyTime/60:MyTime(MyTime-((MyTime/
60)*60).(MyTime-(MyTime>0))) )



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


Re: User input masks - Access Style

2010-12-26 Thread flebber
On Dec 27, 6:01 pm, Tim Harig  wrote:
> On 2010-12-27, flebber  wrote:
>
> > Is there anyay to use input masks in python? Similar to the function
> > found in access where a users input is limited to a type, length and
> > format.
>
> > So in my case I want to ensure that numbers are saved in a basic
> > format.
> > 1) Currency so input limited to 000.00 eg 1.00, 2.50, 13.80 etc
>
> Some GUIs provide this functionality or provide callbacks for validation
> functions that can determine the validity of the input.  I don't know of
> any modules that provide "formatted input" in a terminal.  Most terminal
> input functions just read from stdin (in this case a buffered line)
> and output that as a string.  It is easy enough to validate whether
> terminal input is in the proper.
>
> Your example time code might look like:
>
> ... import re
> ... import sys
> ...
> ... # get the input
> ... print("Please enter time in the format 'MM:SS:HH': ", end="")
> ... timeInput = input()
> ...
> ... # validate the input is in the correct format (usually this would be in
> ... # loop that continues until the user enters acceptable data)
> ... if re.match(r'''^[0-9]{2}:[0-9]{2}:[0-9]{2}$''', timeInput) == None:
> ...     print("I'm sorry, your input is improperly formated.")
> ...     sys.exit(1)
> ...
> ... # break the input into its componets
> ... componets = timeInput.split(":")
> ... minutes = int(componets[0])
> ... seconds = int(componets[1])
> ... microseconds = int(componets[2])
> ...
> ... # output the time
> ... print("Your time is: " + "%02d" % minutes + ":" + "%02d" % seconds + ":" +
> ...     "%02d" % microseconds)
>
> Currency works the same way using validating it against:
> r'''[0-9]+\.[0-9]{2}'''
>
> > For sports times that is time duration not a system or date times
> > should I assume that I would need to calculate a user input to a
> > decimal number and then recalculate it to present it to user?
>
> I am not sure what you are trying to do or asking.  Python provides time,
> date, datetime, and timedelta objects that can be used for date/time
> calculations, locale based formatting, etc.  What you use, if any, will
> depend on what you are actually tring to accomplish.  Your example doesn't
> really show you doing much with the time so it is difficult giving you any
> concrete recommendations.

yes you are right I should have clarified. The time is a duration over
distance, so its a speed measure.  Ultimately I will need to store the
times so I may need to use something likw sqlAlchemy but I am nowehere
near the advanced but I know that most Db's mysql, postgre etc don't
support time as a duration as such and i will probably need to store
it as a decimal and convert it back for the user.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fw: Re: User input masks - Access Style

2010-12-27 Thread flebber
On Dec 27, 7:57 pm, linmq  wrote:
> > On 2010-12-27, flebber   wrote:
>
> >  > Is there anyay to use input masks in python? Similar to the function
> >  > found in access where a users input is limited to a type, length and
> >  > format.
>
> >  > So in my case I want to ensure that numbers are saved in a basic
> >  > format.
> >  > 1) Currency so input limited to 000.00 eg 1.00, 2.50, 13.80 etc
>
> > Some GUIs provide this functionality or provide callbacks for validation
> > functions that can determine the validity of the input. ? don't know of
> > any modules that provide "formatted input" in a terminal. ?ost terminal
> > input functions just read from stdin (in this case a buffered line)
> > and output that as a string. ?t is easy enough to validate whether
> > terminal input is in the proper.
>
> > Your example time code might look like:
>
> > ... import re
> > ... import sys
> > ...
> > ... # get the input
> > ... print("Please enter time in the format 'MM:SS:HH': ", end="")
> > ... timeInput = input()
> > ...
> > ... # validate the input is in the correct format (usually this would be in
> > ... # loop that continues until the user enters acceptable data)
> > ... if re.match(r'''^[0-9]{2}:[0-9]{2}:[0-9]{2}$''', timeInput) == None:
> > ... ??print("I'm sorry, your input is improperly formated.")
> > ... ??sys.exit(1)
> > ...
> > ... # break the input into its componets
> > ... componets = timeInput.split(":")
> > ... minutes = int(componets[0])
> > ... seconds = int(componets[1])
> > ... microseconds = int(componets[2])
> > ...
> > ... # output the time
> > ... print("Your time is: " + "%02d" % minutes + ":" + "%02d" % seconds + 
> > ":" +
> > ... ??"%02d" % microseconds)
>
> > Currency works the same way using validating it against:
> > r'''[0-9]+\.[0-9]{2}'''
>
> >  > For sports times that is time duration not a system or date times
> >  > should I assume that I would need to calculate a user input to a
> >  > decimal number and then recalculate it to present it to user?
>
> > I am not sure what you are trying to do or asking. ?ython provides time,
> > date, datetime, and timedelta objects that can be used for date/time
> > calculations, locale based formatting, etc. ?hat you use, if any, will
> > depend on what you are actually tring to accomplish. ?our example doesn't
> > really show you doing much with the time so it is difficult giving you any
> > concrete recommendations.
>
> > yes you are right I should have clarified. The time is a duration over
> > distance, so its a speed measure.  Ultimately I will need to store the
> > times so I may need to use something likw sqlAlchemy but I am nowehere
> > near the advanced but I know that most Db's mysql, postgre etc don't
> > support time as a duration as such and i will probably need to store
> > it as a decimal and convert it back for the user.
> > --
> >http://mail.python.org/mailman/listinfo/python-list
>
> You can let a user to separately input the days, hours, minutes, etc.
> And use the type timedelta to store the time duration:
>
> datetime.timedelta([days[, seconds[, microseconds[, milliseconds[, minutes[, 
> hours[, weeks]]])
>
> Beyond 2.7, you can use timedelta.total_seconds() to convert the time
> duration to a number for database using. And later restore the number
> back to timedelta by timedelta(seconds=?).
>
> Refer 
> to:http://docs.python.org/library/datetime.html?highlight=timedelta#time...
>
> --
>
> ---
> Confidentiality Notice: The information contained in this e-mail and any 
> accompanying attachment(s)
> is intended only for the use of the intended recipient and may be 
> confidential and/or privileged of
> Neusoft Corporation, its subsidiaries and/or its affiliates. If any reader of 
> this communication is
> not the intended recipient, unauthorized use, forwarding, printing,  storing, 
> disclosure or copying
> is strictly prohibited, and may be unlawful.If you have received this 
> communication in error,please
> immediately notify the sender by return e-mail, and delete the original 
> message and all copies from
> your system. Thank you.
> ---

Very helpful thanks
-- 
http://mail.python.org/mailman/listinfo/python-list


Python - NAWIT / Community

2010-12-28 Thread flebber
I just wanted to put out a question about IDE's but this is NAWIT -
not another which ide thread.

My question relates to community contribution. My concern arose when
recently installing the pydev.org extensions in Eclipse. Now as far as
my understanding goes the licensing on both is open source GPL.
However Pydev became open source as part of aptana's acquistion, and
for the moment pydev can be installed as part of the Aptana studio 2/3
releases individually as a plugin, but moving on if you vist the
aptana site there is sweet little about python on their site, their
site is dominated by Radrails.

Can't help thinking they open sourced Pydev so they could bench it. So
I started thinking that the only consistent env each python person has
is idle as it ships in the install.

Sometimes we can contribute with money and sometimes with time, if I
was to contribute money to ensure that I and all new coming python
programmers could have a first class development environment to use
what would I donate to? At the moment no particular group seems
applicable.

Is pydev actively being developed and for who? SPE is a great idea but
is Stan still developing? Pyscripter is good but not 64 capable. Plus
none of these projects seem community centric.

Maybe its just my wish, maybe something already exists, but to my mind
why is there not a central python community ide or plugin setup like
pydev or using pydev(since currently it is very good - to me), which I
know or at least could confidently donate time or money to further
python.

This could apply to many python area's does python use easy_install or
pypm, well if you want camelot or zope (unless you have business
edition) its easy_install, but you wont find an ide with built in egg
or pypm support? Why every Ruby ide has gems manager, and for that
fact look at netbeans, the ide is good but support for python is
mentioned on a far flung community page where some developers are
trying to maintain good python support. PS they seem to be doing a
good job, but a review of the mailing list archives shows little
activity.

One could say that activestate puts in good support but then they do
not provide an ide within the means of the average part time person
retailing its main edition at over $300, Pycharm a good ide at $99 but
then where is my money going.

I think a community plugin architecture which contained components
like pydev, pyscripter, eclipse and eggs/pypm packages would give a
place I can contribute time as my skills grow and confidently donate
money knowing I am assisting the development of community tools and
packages we all can use. No need to reinvent the wheel most things
already exist, for example apt-get & rpm style package management time
tested and could be easily used to manage python eggs for example.

Anyway I have had my 2 cents, if someone is contributing more than I
know, and this wasn't intended to dimnish anyone's effort, just
wanting to look to growing and fostering a stronger python community.

Sayth



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


Re: Python - NAWIT / Community

2010-12-28 Thread flebber
On Dec 28, 10:16 pm, Adam Tauno Williams 
wrote:
> On Tue, 2010-12-28 at 02:26 -0800, flebber wrote:
> > Can't help thinking they open sourced Pydev so they could bench it.
>
> So?  That isn't uncommon at all;  to Open Source when you've moved on.
>
> > I started thinking that the only consistent env each python person has
> > is idle as it ships in the install.
>
> There is a plethora of Python IDE's [personally I use Monodevelop, which
> supports Python, and is fast and stable].
>
> > Sometimes we can contribute with money and sometimes with time, if I
> > was to contribute money to ensure that I and all new coming python
> > programmers could have a first class development environment to use
> > what would I donate to? At the moment no particular group seems
> > applicable.
>
> Many projects accept donations via PayPal.  Sourceforge supports this.
>
> > Is pydev actively being developed and for who? SPE is a great idea but
> > is Stan still developing? Pyscripter is good but not 64 capable. Plus
> > none of these projects seem community centric.
>
> Why not just check the repo and see the real answer for yourself?  It is
> Open Source after all.
> <https://github.com/aptana/Pydev/commits/master>
>
> > Maybe its just my wish, maybe something already exists, but to my mind
> > why is there not a central python community ide or plugin setup like
> > pydev or using pydev(since currently it is very good - to me), which I
> > know or at least could confidently donate time or money to further
> > python.
>
> You could checkout the code of any Python IDE and hack on it.
>
> > I think a community plugin architecture which contained components
> > like pydev, pyscripter, eclipse and eggs/pypm packages would give a
> > place I can contribute time as my skills grow and confidently donate
> > money knowing I am assisting the development of community tools and
> > packages we all can use.
>
> So just do it.

Yes you can answer questions, but have you really? Your answer seems
to be things are open source so who cares about community.

> Many projects accept donations via PayPal.  Sourceforge supports this.

Of course any fool can throw his/her money away thats no challenge why
even use Paypal, I could have fun and by 10 bottles of vino and hand
them out to recovering alcoholics.

Don't answer things just for the sake of it, if you have nothing
producive to say about furthering python and its community then say
that.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python - NAWIT / Community

2010-12-28 Thread flebber
On Dec 28, 10:24 pm, flebber  wrote:
> On Dec 28, 10:16 pm, Adam Tauno Williams 
> wrote:
>
>
>
> > On Tue, 2010-12-28 at 02:26 -0800, flebber wrote:
> > > Can't help thinking they open sourced Pydev so they could bench it.
>
> > So?  That isn't uncommon at all;  to Open Source when you've moved on.
>
> > > I started thinking that the only consistent env each python person has
> > > is idle as it ships in the install.
>
> > There is a plethora of Python IDE's [personally I use Monodevelop, which
> > supports Python, and is fast and stable].
>
> > > Sometimes we can contribute with money and sometimes with time, if I
> > > was to contribute money to ensure that I and all new coming python
> > > programmers could have a first class development environment to use
> > > what would I donate to? At the moment no particular group seems
> > > applicable.
>
> > Many projects accept donations via PayPal.  Sourceforge supports this.
>
> > > Is pydev actively being developed and for who? SPE is a great idea but
> > > is Stan still developing? Pyscripter is good but not 64 capable. Plus
> > > none of these projects seem community centric.
>
> > Why not just check the repo and see the real answer for yourself?  It is
> > Open Source after all.
> > <https://github.com/aptana/Pydev/commits/master>
>
> > > Maybe its just my wish, maybe something already exists, but to my mind
> > > why is there not a central python community ide or plugin setup like
> > > pydev or using pydev(since currently it is very good - to me), which I
> > > know or at least could confidently donate time or money to further
> > > python.
>
> > You could checkout the code of any Python IDE and hack on it.
>
> > > I think a community plugin architecture which contained components
> > > like pydev, pyscripter, eclipse and eggs/pypm packages would give a
> > > place I can contribute time as my skills grow and confidently donate
> > > money knowing I am assisting the development of community tools and
> > > packages we all can use.
>
> > So just do it.
>
> Yes you can answer questions, but have you really? Your answer seems
> to be things are open source so who cares about community.
>
> > Many projects accept donations via PayPal.  Sourceforge supports this.
>
> Of course any fool can throw his/her money away thats no challenge why
> even use Paypal, I could have fun and by 10 bottles of vino and hand
> them out to recovering alcoholics.
>
> Don't answer things just for the sake of it, if you have nothing
> producive to say about furthering python and its community then say
> that.

My apologise I didn't mean to be that aggressive.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python - NAWIT / Community

2010-12-28 Thread flebber
On Dec 28, 10:37 pm, Adam Tauno Williams 
wrote:
> On Tue, 2010-12-28 at 03:24 -0800, flebber wrote:
> > On Dec 28, 10:16 pm, Adam Tauno Williams 
> > wrote:
> > > On Tue, 2010-12-28 at 02:26 -0800, flebber wrote:
> > > > Is pydev actively being developed and for who? SPE is a great idea but
> > > > is Stan still developing? Pyscripter is good but not 64 capable. Plus
> > > > none of these projects seem community centric.
> > > Why not just check the repo and see the real answer for yourself?  It is
> > > Open Source after all.
> > > <https://github.com/aptana/Pydev/commits/master>
> > Yes you can answer questions, but have you really? Your answer seems
> > to be things are open source so who cares about community.
> > > Many projects accept donations via PayPal.  Sourceforge supports this.
> > Of course any fool can throw his/her money away thats no challenge why
> > even use Paypal, I could have fun and by 10 bottles of vino and hand
> > them out to recovering alcoholics.
> > Don't answer things just for the sake of it, if you have nothing
> > producive to say about furthering python and its community then say
> > that.
>
> I provided two concrete points, thank you:
>
> (1) Is a project actively developed?  Look at the repo. That is the
> answer to the question [this isn't necessarily obvious to those new to
> Open Source].
> (1.1.) "Is PyDev a potential unifying force amoung IDEs?"  Which is the
> implied question - that is up to the OP and others who do/do-not
> contribute to it.
> (2) How can I donate cash? There is a fairly standard mechanism for
> that.
>
> Otherwise I think the OP's thoughts on "community" and how Open Source
> works are somewhat flawed.  "Community" is a manifestation of people
> *doing* things; it does *not* arise out of people being concerned about
> things [since "doing" is quite apparently not a natural result of
> "concern". Concern is like watching TV.  Doing is getting out of the
> chair.]

Fair point.

You have mistaken somewhat what I intended, partly my fault due to the
verbosity. I wanted gaugue feedback on others perception of the
current status quo. I am happy personally currently, currently being
the main word.

"Community" is a manifestation of people
> *doing* things; it does *not* arise out of people being concerned about
> things

But concern is derived from interaction and observation and like fear
and joy tells us we need to take an action. If someone chooses to sir
idly by good for them I haven't the time or inclination personally.

Tony Robbins "Acheiving a goal is simple, decide what your goal is,
set out towards it and consistently review whether you are getting
closer or further from your goal and take action immediately."

>From a language perspective going to python 3 this definitely seems to
be occurring well and strongly lead.

Sometimes the fault in open source is the lack of a crystalized and
shared goal and proper infrastructure.Gentoo as an example. Could
get to they were going because they didn't share the same vision of
what it was.

I meant no attack by reviewing, just a somewhat newbies observations
of python.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python - NAWIT / Community

2010-12-28 Thread flebber
On Dec 28, 11:10 pm, flebber  wrote:
> On Dec 28, 10:37 pm, Adam Tauno Williams 
> wrote:
>
>
>
> > On Tue, 2010-12-28 at 03:24 -0800, flebber wrote:
> > > On Dec 28, 10:16 pm, Adam Tauno Williams 
> > > wrote:
> > > > On Tue, 2010-12-28 at 02:26 -0800, flebber wrote:
> > > > > Is pydev actively being developed and for who? SPE is a great idea but
> > > > > is Stan still developing? Pyscripter is good but not 64 capable. Plus
> > > > > none of these projects seem community centric.
> > > > Why not just check the repo and see the real answer for yourself?  It is
> > > > Open Source after all.
> > > > <https://github.com/aptana/Pydev/commits/master>
> > > Yes you can answer questions, but have you really? Your answer seems
> > > to be things are open source so who cares about community.
> > > > Many projects accept donations via PayPal.  Sourceforge supports this.
> > > Of course any fool can throw his/her money away thats no challenge why
> > > even use Paypal, I could have fun and by 10 bottles of vino and hand
> > > them out to recovering alcoholics.
> > > Don't answer things just for the sake of it, if you have nothing
> > > producive to say about furthering python and its community then say
> > > that.
>
> > I provided two concrete points, thank you:
>
> > (1) Is a project actively developed?  Look at the repo. That is the
> > answer to the question [this isn't necessarily obvious to those new to
> > Open Source].
> > (1.1.) "Is PyDev a potential unifying force amoung IDEs?"  Which is the
> > implied question - that is up to the OP and others who do/do-not
> > contribute to it.
> > (2) How can I donate cash? There is a fairly standard mechanism for
> > that.
>
> > Otherwise I think the OP's thoughts on "community" and how Open Source
> > works are somewhat flawed.  "Community" is a manifestation of people
> > *doing* things; it does *not* arise out of people being concerned about
> > things [since "doing" is quite apparently not a natural result of
> > "concern". Concern is like watching TV.  Doing is getting out of the
> > chair.]
>
> Fair point.
>
> You have mistaken somewhat what I intended, partly my fault due to the
> verbosity. I wanted gaugue feedback on others perception of the
> current status quo. I am happy personally currently, currently being
> the main word.
>
> "Community" is a manifestation of people
>
> > *doing* things; it does *not* arise out of people being concerned about
> > things
>
> But concern is derived from interaction and observation and like fear
> and joy tells us we need to take an action. If someone chooses to sir
> idly by good for them I haven't the time or inclination personally.
>
> Tony Robbins "Acheiving a goal is simple, decide what your goal is,
> set out towards it and consistently review whether you are getting
> closer or further from your goal and take action immediately."
>
> From a language perspective going to python 3 this definitely seems to
> be occurring well and strongly lead.
>
> Sometimes the fault in open source is the lack of a crystalized and
> shared goal and proper infrastructure.Gentoo as an example. Could
> get to they were going because they didn't share the same vision of
> what it was.
>
> I meant no attack by reviewing, just a somewhat newbies observations
> of python.

Edit Gentoo couldn't get to where they were going because of lack of
vision and a shared goal.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tkinter: The good, the bad, and the ugly!

2010-12-31 Thread flebber
On Dec 31, 3:04 pm, Robert  wrote:
> On 2010-12-30 22:28:39 -0500, rantingrick said:
>
> >  On Dec 30, 8:41�pm, Robert  wrote:
> >> On 2010-12-30 19:46:24 -0500, rantingrick said:
> >> Just to clarify...I like Python. I am learning it at the moment.
>
> > Glad to have you aboard Robert!
>
> Thanks!
>
>
>
> >>> 3. What is your opinion of Tkinter as to it's usefulness within the
> >>> stdlib?
>
> >> No, I really don't see the need for it to be in the stdlib but that
> >> isn't my call.
>
> > But it is your call Robert. Anyone who writes Python code --whether
> > they be a beginner with no prior programming experience or a fire
> > breathing Python Guru-- has a right to inject their opinion into th
> > community. We really need input from first time users as they carry
> > the very perspective that we have completely lost!
>
> I speak up.  :-)
>
>
>
>
>
> >>> 5. Should Python even have a GUI in the stdlib?
>
> >> I would say "no" but that is my opinion only and it doesn't matter.
> >> Python's domain isn't GUI programming so having it readily available on
> >> the sidelines would be fine for me.
>
> > I agree that Python's domain is not "specifically" GUI programming
> > however to understand why Tkinter and IDLE exists you need to
> > understand what Guido's dream was in the beginning. GvR wanted to
> > bring Programming to everyone (just one of his many heroic goals!). He
> > believed (i think) that GUI programming is very important , and that
> > was 20 years ago!!. So he included Tkinter mainly so new Python
> > programmers could hack away at GUI's with little or no effort. He also
> > created a wonderful IDE for beginners called IDLE. His idea was
> > perfect, however his faith in TclTk was flawed and so we find
> > ourselves in the current situation we have today. With the decay of
> > Tkinter the dream has faded. However we can revive this dream and
> > truly bring Python into the 21st century!
>
> I don't think Tkinter was in there for "large" programming. Tkinter is
> crufty and probably should be moved out. For whipping up quick gui
> things to scratch an itch it is good.
>
> I lurk more on the Tcl side of things. When the mention of "separating"
> Tcl and Tk development, I fall on the side of separating them. Tcl,
> like Python should stand on its own. Widget frameworks are extras to
> me. One way the Tcl community has "stagnated" has been its insistence
> on Tk. There was a wxTcl project...it died. That would have been good
> for the Tcl community. Luckily there is a GTk framework (Gnocl) that is
> really good. But it still doesn't get the props that it deserves. The
> second way the Tcl community irks me is the "not invented here"
> attitude. I like the syntax of Tcl and I like the community. They are
> some good folks. Try asking "I want to build a Nagios clone in Tcl"
> type question and invariably you get "Why? There is already Nagios?".
> That stems from the "glue" language roots I think but to me that is the
> wrong attitude. You want people to take a look at a language (any
> language), you build stuff with it that people want to use. Ruby would
> not be as big as it is if Rails hadn't come along.
>
> Nuff of that...  ;-)
>
>
>
>
>
> >>> 6. If Python should have a GUI, then what traits would serve our
> >>> community best?
>
> >> This is a good one.
>
> >> It should be:
>
> >> - cross platform
> >> - Pythonic
> >> - as "native" as possible
>
> >> Cross platform and native are hard. Just look at all the work with
> >> PyQt/PySide and wxPython. It took them years to get where they are.
>
> > Hmm, wxPython is starting to look like the answer to all our problems.
> > WxPython already has an IDE so there is no need to rewrite IDLE
> > completely. What do we have to loose by integrating wx into the
> > stdlib, really?
>
> wxPython is really good. The downside is that is shows (or did show)
> its C++ roots.
>
> Nokia is making a run with PySide (their version of the PyQt framework)
> and since it has a company behind it might go pretty far. Qt can be
> used for a lot of problem domains.
>
> Anyway, I wasn't meaning to be rough with you. Just trying to figure
> out where you were coming from. I am acquianted with Kevin Walzer and
> he is a good guy.
>
> --
> Robert

I thank this thread for putting me onto Pyside +1

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


Re: User input masks - Access Style

2010-12-31 Thread flebber
On Dec 28 2010, 12:21 am, Adam Tauno Williams 
wrote:
> On Sun, 2010-12-26 at 20:37 -0800, flebber wrote:
> > Is there anyay to use input masks in python? Similar to the function
> > found in access where a users input is limited to a type, length and
> > format.
>
> <http://faq.pygtk.org/index.py?file=faq14.022.htp&req=show>
>
> Typically this is handled by a callback on a keypress event.

Can I get some clarification on the re module specifically on matching
string

Line 137 of the Re module

def match(pattern, string, flags=0):
"""Try to apply the pattern at the start of the string, returning
a match object, or None if no match was found."""
return _compile(pattern, flags).match(string)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: User input masks - Access Style

2010-12-31 Thread flebber
On Dec 28 2010, 12:21 am, Adam Tauno Williams 
wrote:
> On Sun, 2010-12-26 at 20:37 -0800, flebber wrote:
> > Is there anyay to use input masks in python? Similar to the function
> > found in access where a users input is limited to a type, length and
> > format.
>
> <http://faq.pygtk.org/index.py?file=faq14.022.htp&req=show>
>
> Typically this is handled by a callback on a keypress event.

Sorry

Regarding 137 of the re module, relating to the code above.

# validate the input is in the correct format (usually this would be
in
# loop that continues until the user enters acceptable data)
if re.match(r'''^[0-9]{2}:[0-9]{2}:[0-9]{2}$''', timeInput) == None:
print("I'm sorry, your input is improperly formated.")
sys.exit(1)

EDIT: I just needed to use raw_input rather than input to stop this
input error.

Please enter time in the format 'MM:SS:HH':
11:12:13
Traceback (most recent call last):
  File "C:\Documents and Settings\renshaw\workspace\Testing\src
\Time.py", line 13, in 
timeInput = input()
  File "C:\Eclipse\plugins\org.python.pydev_1.6.3.2010100422\PySrc
\pydev_sitecustomize\sitecustomize.py", line 176, in input
return eval(raw_input(prompt))
  File "", line 1
11:12:13
  ^
SyntaxError: invalid syntax

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


Re: Python - NAWIT / Community

2010-12-31 Thread flebber
On Jan 1, 9:03 am, Fabio Zadrozny  wrote:
> > My question relates to community contribution. My concern arose when
> > recently installing the pydev.org extensions in Eclipse. Now as far as
> > my understanding goes the licensing on both is open source GPL.
> > However Pydev became open source as part of aptana's acquistion, and
> > for the moment pydev can be installed as part of the Aptana studio 2/3
> > releases individually as a plugin, but moving on if you vist the
> > aptana site there is sweet little about python on their site, their
> > site is dominated by Radrails.
>
> Just a little fix there, Pydev is open source EPL (not GPL).
>
> Also, yes, there's little content about Pydev in the Aptana homepage,
> but it points to the main Pydev homepage (http://pydev.org) which has
> the proper content related to Python (and it's currently being
> actively developed and also integrated in Aptana Studio 3, which is
> where the current efforts are targeted within Aptana now). Sorry if
> this causes the (wrong) perception that Pydev doesn't get as much
> attention.
>
> > Can't help thinking they open sourced Pydev so they could bench it. So
> > I started thinking that the only consistent env each python person has
> > is idle as it ships in the install.
>
> Sorry, but I don't follow your thoughts here... there are many
> consistent environments for python development which are properly
> supported (Pydev being only one of them as you can see 
> athttp://stackoverflow.com/questions/81584/what-ide-to-use-for-python).
>
> > Sometimes we can contribute with money and sometimes with time, if I
> > was to contribute money to ensure that I and all new coming python
> > programmers could have a first class development environment to use
> > what would I donate to? At the moment no particular group seems
> > applicable.
>
> > Is pydev actively being developed and for who? SPE is a great idea but
> > is Stan still developing? Pyscripter is good but not 64 capable. Plus
> > none of these projects seem community centric.
>
> I'm the current Pydev maintainer (since 2005)... and while I cannot
> state that I'll be in that role forever (forever is quite a long
> time), I do think it's well maintained and there are occasional
> patches from the community that uses it (although I still get to
> review all that goes in).
>
> > Maybe its just my wish, maybe something already exists, but to my mind
> > why is there not a central python community ide or plugin setup like
> > pydev or using pydev(since currently it is very good - to me), which I
> > know or at least could confidently donate time or money to further
> > python.
>
> > This could apply to many python area's does python use easy_install or
> > pypm, well if you want camelot or zope (unless you have business
> > edition) its easy_install, but you wont find an ide with built in egg
> > or pypm support?
>
> I think the issue is that only recently (if you compare with the
> others) has easy_install became the de facto standard in python (so,
> it'd be more an issue of interest adding such a feature to the ide).
>
>
>
> > Why every Ruby ide has gems manager, and for that
> > fact look at netbeans, the ide is good but support for python is
> > mentioned on a far flung community page where some developers are
> > trying to maintain good python support. PS they seem to be doing a
> > good job, but a review of the mailing list archives shows little
> > activity.
> > One could say that activestate puts in good support but then they do
> > not provide an ide within the means of the average part time person
> > retailing its main edition at over $300, Pycharm a good ide at $99 but
> > then where is my money going.
>
> > I think a community plugin architecture which contained components
> > like pydev, pyscripter, eclipse and eggs/pypm packages would give a
> > place I can contribute time as my skills grow and confidently donate
> > money knowing I am assisting the development of community tools and
> > packages we all can use. No need to reinvent the wheel most things
> > already exist, for example apt-get & rpm style package management time
> > tested and could be easily used to manage python eggs for example.
> > Anyway I have had my 2 cents, if someone is contributing more than I
> > know, and this wasn't intended to dimnish anyone's effort, just
> > wanting to look to growing and fostering a stronger python community.
>
> Well, I can only comment from the Pydev side here, but do you think
> it'd be worth reinventing all that's already done in it just for
> having it in Python? When I started contributing to Pydev back in 2004
> I didn't go that way because Eclipse itself has a huge community
> that's already in place and is properly maintained, which takes a lot
> of effort, so, I'm not sure it'd be worth reproducing all that just to
> have it 100% Python code -- I say 100% because Pydev does have a
> number of things that are in Python, such as the debugger and Jython
> for 

Re: GUI Tools for Python 3.1

2010-12-31 Thread flebber
On Dec 26 2010, 8:41 pm, "Hans-Peter Jansen"  wrote:
> On Friday 24 December 2010, 03:58:15 Randy Given wrote:
>
> > Lots of stuff for 2.6 and 2.7 -- what GUI tools are there for 3.1?
>
> PyQt4 of course.
>
> http://www.riverbankcomputing.com
>
> Pete

Pyside, Nokia have split with riverbank computing and are quickly
developing pyside. Currently not supported in Py3000 but have already
a roadmap for implementation when they finalise Python 2 support.

Here is what they see as roadblocks(not insurmountble) to python3.

http://developer.qt.nokia.com/wiki/PySide_Python_3_Issues

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


Re: User input masks - Access Style

2011-01-01 Thread flebber
On Jan 1, 11:13 am, Tim Harig  wrote:
> On 2010-12-31, flebber  wrote:
>
> > On Dec 28 2010, 12:21 am, Adam Tauno Williams 
> > wrote:
> >> On Sun, 2010-12-26 at 20:37 -0800, flebber wrote:
> >> > Is there anyay to use input masks in python? Similar to the function
> >> > found in access where a users input is limited to a type, length and
> >> > format.
>
> >> <http://faq.pygtk.org/index.py?file=faq14.022.htp&req=show>
>
> >> Typically this is handled by a callback on a keypress event.
>
> > Regarding 137 of the re module, relating to the code above.
>
> 137? I am not sure what you are referencing?
>
> > EDIT: I just needed to use raw_input rather than input to stop this
> > input error.
>
> Sorry, I used input() because that is what you had used in your example
> and it worked for my system.  Normally, I would have used window.getstr()
> from the curses module, or whatever the platform equivilant is, for
> getting line buffered input.

137 is the line number in the re module which refernces the match
string. In this example the timeinput.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Trying to decide between PHP and Python

2011-01-05 Thread flebber
On Jan 5, 6:48 pm, "Octavian Rasnita"  wrote:
> From: "Tomasz Rola" 
>
> > On Tue, 4 Jan 2011, Dan M wrote:
>
> >> As to choice between Python and PHP, I would say learn anything but PHP.
> >> Even Perl has fewer tentacles than PHP.
>
> > However, the quality of code depends heavily on who writes it. My
> > impression is that more folks of "I did it and it works so it is good,
> > right?" attitude can be found among Perl/PHP crowd (compared to Python or
> > Ruby or...). The reason is probably the "easyness" of those languages
> > (mostly because of tons of readymade code on the net) which - wrongly -
> > suggests they are already "there", no need to learn anymore.
>
> Yes you are right. Perl is much flexible than all other languages and there
> was written a lot of bad code in the past that can now be found on the net,
> beeing very hard for a newbie to find only the good examples and tutorials.
>
> But Perl offers many helpful modules for testing the apps so for good
> programmers there is not true the idea of "it works so it's ok".
>
> Usually we compare the languages although we always think to all aditional
> modules and libraries we can use with them for creating apps.
> Thinking this way, Perl is better than Python for creating web apps, because
> Catalyst framework is more advanced than the frameworks for Python and it is
> more flexible even than Ruby on Rails, DBIx::Class ORM is a very advanced
> ORM and a very clean one and Perl web apps can use strong templating systems
> and form processors, unicode is a native code for Perl for a long time and
> so on.
>
> So how good is the language depends on what you need to use it for.
>
> (But I hope that this won't start a language war, because I have just done
> the same on a Perl mailing list telling about some Perl disadvantages
> towards Python :)
>
> Octavian

My two cents, I am understanding python far better by learning scheme.
Didn't intentionally set out to achieve that as a goal just a by
product. An excelent resource http://htdp.org and using the racket
scheme ide(as much of an ide as idle), simple thorough well explained
concepts via worked examples and a very encouraging and enthusiastic
mail group, much like this list.

I would so love a book like that for python but after i complete htdp
I may not need it.

Regards

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


Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-02-01 Thread flebber
On Feb 1, 4:39 am, rantingrick  wrote:
> IDLE: A cornicopia of mediocrity and obfuscation.
> -- by Rick Johnson
>
> IDLE --which is the Python Integrated Development and Learning
> Environment-- was once the apple of Guido's eye but has since
> degenerated into madness many years ago and remains now as the shining
> jewel "show piece" on the proverbial python wall of shame. A once
> mighty dream of "programming for everyone" that is now nothing more
> than an example of "how NOT to program".
>
> IDLE contains some of the worst code this community has created. Bad
> design patterns, tacked on functionality, blasphemous styling, and
> piss poor packaging. There seems to be no guiding goals or game-plan.
> And year after year if IDLE *does* get any attention it's just more
> haphazard code thrown into the mix by someone who has gone blind from
> reading the source. However we cannot blame the current maintainer (if
> any such even exists!) because NOBODY can maintains such a spaghetti
> mess that this package has become!
>
> If we would have had a proper game plan from day one i believe we
> could have avoided this catastrophe. Follows is an outline of the
> wrongs with some suggestions to right them...
>
>  * First of all the main two modules "PyShell" and "EditorWindow" are
> laid out in such a non sequential way that it is virtually impossible
> to follow along. We should have had a proper app instance from which
> all widgets where combined. The main app should have followed a
> "common sense" sequential mentality of...
>
>  * subclassing the tk.Toplevel
>  * initializing instance variables
>  * creating the main menu
>  * creating the sub widgets
>  * declaring internal methods
>  * declaring event handlers
>  * then interface/generic methods.
>
>  This is the recipe for order AND NOT CHAOS! What we have now is utter
> chaos! When we have order we can read source code in a sequential
> fashion. When we have order we can comprehend what we read. And when
> we have order we can maintain a library/package with ease. However
> sadly we DO NOT have order, we have CHAOS, CHAOS, and more CHAOS!
>
> * The underlying sub widgets should have started with their own proper
> order of "declared" initialization. And all events should be handled
> in the widget at hand NOT outsourced to some other class!
>
>  * One of the biggest design flaws is the fact that outside modules
> manipulate the main editor/pyshells events. This is a terrible way to
> code. For example the AutoCompleteWindow takes over the tab event
>
>   #-- Puesdo Code --#
>   # in editor window __init__
>   self.autocomplete = AutoComplete(blah)
>   # in editor window onKeyPress(blah)
>   if key == 'Tab' and blah:
>       self.autocomplete.show_tip(blah)
>   elif key == 'Escape' and acw.is_visibe():
>       self.autocomplete.hide()
>
>  This is a bad design! The main editor window should handle all its
> own events AND THEN call outside class methods when needed. We don't
> want "Mommy" classes telling the kids what to do, when to eat, when to
> sleep, and when to excrete! We should create our objects with the
> virtue of self reliance and responsibility!. The Colorizer,
> ParenMatch, textView, TreeWidget, CallTips, and many other modules are
> guilty of "event stealing" also. Event functionality must be handled
> in the widget itself, NOT stolen and handled in an outside class. When
> we split up sequential code we get CHAOS!
>
>  * Another bad choice was creating custom reusable widgets
> (Tabbedpages, FindDialog, ReplaceDialog, etc...) and leaving them in
> idlelib. These should have been moved into the lib-tk module where
> they would be more visible to python programmers AND we could reduce
> the cruft in the idlelib! Remember, when we create more files,
> folders, and objects we create CHAOS. And nobody can learn from CHAOS!
>
>  * Another blasphemy is the fact that every module should include some
> sort of test to display its usage. If the module is a GUI widget then
> you MUST show how to use the widget in a window. Sadly like all
> everything else, idlelib is devoid of examples and testing. And the
> very few tests that DO exists just blow chunks!
>
>  * Last but not least idlelib does not follow PEP8 or ANY convention.
> So much so that it seems the developers snubbed their nose at such
> conventions! We are missing doc strings and comments. We have built-
> ins being re-bound! Just code horror after code horror.
>
> These are just the top of the list. The peak of a huge iceberg that
> threatens to sink the community in the arms of chaos never to return.
> I am beginning to believe that this community is either made of
> amateurs due to this lackluster code in the stdlib. However it could
> be that the folks are really professional and refuse to work on such a
> horrible code base (which i understand). I am going with the latter.
>
> When are we going to demand that these abominations be rectified? How
> much longer must we wait? A year? 

Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-02-03 Thread flebber
On Feb 1, 11:38 pm, rantingrick  wrote:
> On Feb 1, 4:20 am, flebber  wrote:
>
> > Sorry Rick too boringtrying to get bored people to bite at your
> > ultra lame post yawn...
>
> Well reality and truth both has a tendency to be boring. Why? Well
> because we bathe in them daily. We have come accustomed, acclimated,
> and sadly complacent of the ill state of our stdlib. Yes, boring.
> However we must be aware of these things.

Yes but fixing idle just gives us another editor, there isn't a
shortage of editors. There is a shortage of a common community code
base for an ide framework, logical, reusable and extensible.

For an example of a brilliant beginners "ide" racket has it covered
with DrRacket http://racket-lang.org/ , it has selectable language
levels beginner, intermediate, advanced that allows the learner to
adjust the level of language features available as they learn,
teachpacks are installable to add extra features or options when
completing the tutorials(could easily be adapted to the python
tutorials). If idle is for teaching people to learn python shouldn't
it have the facility to do that?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-02-04 Thread flebber
On Feb 3, 7:41 am, Corey Richardson  wrote:
> On 2/2/2011 2:44 PM, rantingrick wrote:

>
> Will you be forking IDLE and setting up some sort of tracker for
> improvements?

+1 for this.

Enough talk ratingrick where is your feature and request tracker for
your idle fork? How can people assist you in your new idle fork
project? What are your stated project goals & timeline?

We all suspect you have no answers to basic questions which would
involve you doing anything!!! So come on rick reply with some other
pius full of shit answer that will absolve you of action and will
still leave you the worlds biggest one handed typist.


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


Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-02-05 Thread flebber
On Feb 5, 10:24 am, Stephen Hansen  wrote:
> On 2/4/11 3:01 PM, rantingrick wrote:
>
> >> Put your money where your mouth is.
>
> > ditto!
>
> I thought as much.
>
> My money is where my mouth is: but that is not IDLE, as I have no use
> for it and no interest in it at all. The status quo with regards to IDLE
> is satisfactory to me.
>
> You're the one talking so much about how it needs to improve. So do it.
> Get started. Now.
>
> But you'll just find another excuse to rant on like you always do, and
> be basically useless.
>
> Me, I _have_ contributed patches: I have released actual code that
> actual people have found actually useful. I do run two build slaves and
> proactively try to assist in resolving issues that come up with Python's
> testing (usually: ouch, there's a lot of red at the moment, must get
> cracking) and stability.
>
> So, yeah. You're the hypocrite here, man.
>
> --
>
>    Stephen Hansen
>    ... Also: Ixokai
>    ... Mail: me+list/python (AT) ixokai (DOT) io
>    ... Blog:http://meh.ixokai.io/
>
>  signature.asc
> < 1KViewDownload

Idlefork isn't dead to rick! just pining for the alps!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Call to Update All Tutorials to Python3.x Standards.

2011-02-14 Thread flebber
On Feb 14, 11:35 am, Cameron Simpson  wrote:
> On 13Feb2011 14:47, rantingrick  wrote:
> | On Feb 13, 4:30 pm, Steven D'Aprano  +comp.lang.pyt...@pearwood.info> wrote:
>
> | > The official stance of the Python development team is that 2.7 and 3.x
> | > will co-exist for a long, long time. Removing 2.x tutorials would be
> | > cutting off our nose to spite our face.
> |
> | That is BS Steven and you know it! Of course we are going to support
> | 2.x for a long, long, time. Heck we even have downloads available for
> | Python1.x. I am talking about TUTORIALS steven, TUTORIALS!
>
> Steven is also talking about tutorials. Perhaps my comprehension skiils
> are weak; I am basing my assrtion on his use of the word "tutorials" in
> the sentence:
>
>   Removing 2.x tutorials would be cutting off our nose to spite our
>   face.
>
> I admit my reading here may be superficial and that you may be seeing a
> deeper intent.
>
> [...]
> | [...] Stop spreading lies Steven. [...]
> | PS: The only troll here is YOU! [...]
>
> I confess to finding these two sentences in your message contradictory.
> Again, my poor comprehension skills must be to blame.
>
> Cheers,
> --
> Cameron Simpson  DoD#743http://www.cskk.ezoshosting.com/cs/
>
> That's just the sort of bloody stupid name they would choose.
>         - Reginald Mitchell, designer of the Spitfire

Python 3 Tutorial

http://docs.python.org/py3k/

Python 3 Tutorial

http://diveintopython3.org/

Python 3 Video Tutorials

http://www.youtube.com/results?search_query=python+3+tutorial&aq=f

Python 3 Tutorial

http://www.swaroopch.com/notes/Python_en:Table_of_Contents

Python 3 Book

http://www.amazon.com/Programming-Python-Complete-Introduction-Language/dp/0321680561/ref=sr_1_1?s=books&ie=UTF8&qid=1297682115&sr=1-1

If people want to learn there are already plenty of resources.



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


Re: How to use Python well?

2011-02-17 Thread flebber
On Feb 17, 11:43 am, Steven D'Aprano  wrote:
> On Thu, 17 Feb 2011 10:12:52 +1100, Ben Finney wrote:
> > Terry Reedy  writes:
>
> >> The most import thing is automated tests.
>
> > Steven D'Aprano  writes:
>
> >> The most important thing is structured programming and modularization.
>
> > Steel-cage death match. FIGHT!
>
> To the death? No, to the pain!
>
> http://en.wikiquote.org/wiki/The_Princess_Bride
>
> --
> Steven

I really liked Abstraction Chapter 6 & 7 In Magnus Lie Hetlands book
novice to professional. It really show the how to "think it out" which
seems to be what your after. The first sub heading in Chapter 6 is
"Laziness is a virtue" can't beat that.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Hello

2010-07-10 Thread flebber
On Jul 10, 8:49 pm, Dani Valverde  wrote:
> geremy condra wrote:
> > On Fri, Jul 9, 2010 at 1:08 PM, Dani Valverde  
> > wrote:
>
> >> Sorry, I forgot to mention that I am using Linux. In fact, my first test
> >> have been with gedit. Is there any way to directly run the Python code into
> >> the console?
>
> > Gedit has a plugin that brings up a python intepreter.
> > Edit->Preferences->Plugins->python console I think.
>
> > Geremy Condra
>
> I have this plugin enabled, but I don't know how to send the code to the
> console...
>
> Dani
>
> --
> Daniel Valverde Saubí
> c/Joan Maragall 37 4 2
> 17002 Girona
> Spain
> Telèfon mòbil: +34651987662
> e-mail: 
> dani.valve...@gmail.comhttp://www.acrocephalus.nethttp://natupics.blogspot.com
>
> Si no és del tot necessari, no imprimeixis aquest missatge. Si ho fas 
> utilitza paper 100% reciclat i blanquejat sense clor. D'aquesta manera 
> ajudaràs a estalviar aigua, energia i recursos forestals.  GRÀCIES!
>
> Do not print this message unless it is absolutely necessary. If you must 
> print it, please use 100% recycled paper whitened without chlorine. By doing 
> so, you will save water, energy and forest resources. THANK YOU!
>
>  dani_valverde.vcf
> < 1KViewDownload

A few good options.

Editor: Notepad++
IDE: Pyscripter - Clean clear design easy to use.
Eclipse/Pydev

Cheers

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


Python XML and tables using math

2010-08-15 Thread flebber
I am looking at a project that will import and modify an XML file and
then export it to a table. Currently a flat file table system should
be fine.

I want to export the modified data to the table and then perform a
handful of maths(largely simple statistical functions) to the data and
then print out the resultant modified tables.

I was planning on using Python 2.7 for the project.

Has anyone used a guide to acheive something similar? I would like to
read up on it so I can assess my options and best methods, any hints
or tips?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python XML and tables using math

2010-08-16 Thread flebber
On Aug 16, 4:00 pm, Stefan Behnel  wrote:
> flebber, 16.08.2010 05:30:
>
> > I am looking at a project that will import and modify an XML file and
> > then export it to a table. Currently a flat file table system should
> > be fine.
>
> > I want to export the modified data to the table and then perform a
> > handful of maths(largely simple statistical functions) to the data and
> > then print out the resultant modified tables.
>
> > I was planning on using Python 2.7 for the project.
>
> > Has anyone used a guide to acheive something similar? I would like to
> > read up on it so I can assess my options and best methods, any hints
> > or tips?
>
> That can usually be done in a couple of lines in Python. The approach I
> keep recommending is to use cElementTree (in the stdlib), potentially its
> iterparse() function if the file is too large to easily fit into memory,
> but the code won't change much either way.
>
> You might want to skip through this list a bit, similar questions have been
> coming up every couple of weeks. The responses often include mostly
> complete implementations that you can borrow from.
>
> Stefan

okay I found http://effbot.org/zone/celementtree.htm so I will have a
read through there.

I have been creating an every expanding macro/VBA project in Excel and
due to slightly changin source document - the header order changes -
it causes the project to crash out.

I was hoping python and XML may be a bit more robust.
-- 
http://mail.python.org/mailman/listinfo/python-list


Date using input

2009-09-24 Thread flebber
Sorry to ask a simple question but I am a little confused how to
combine the input function and the date time module.

Simply at the start of the program I want to prompt the user to enter
the date, desirably in the format dd/mm/year.
However I want to make sure that python understands the time format
because first the date will form part of the name of the output file
so dd/mm/year as 1st September 2009, secondly if I have multiple
output files saved in a directory I may need to search later on the
files and contents of files by date range. So can I timestamp the
file?

I know this is a simple question but it eludes me exactly how to do
it.

I have the basics from http://docs.python.org/library/datetime.html

from datetime import date
date = input("type date dd/mm/year: ")
datetime(day,month,year)

# some program blocks

#print to file(name = date) or apphend if it exists

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


Re: Date using input

2009-09-24 Thread flebber
On Sep 24, 10:58 pm, Dave Angel  wrote:
> flebber.c...@gmail.com wrote:
> > I am using python 2.6.2, I haven't updated to 3.0 yet. No I have no
> > class or instructor, I am learning this myself. I have Hetlands book
> > "Beginning Python Novice to Professional and online documentation
> > books so Dive into Python, python.org etc.
>
> > Using the SPE editor.
>
> > I have currently only fully written basic psuedocode to give me a
> > basic framework to guide myself.
>
> > #Basic pseudocode
> > #Purpose to get raw input and calculate a score for a field of options
> > and return that
> > #score in a set in descending order.
> > #Multiple sets sould be written to the doc
>
> > #Obtain date
> > #Check if txt file with same date exists. If yes apphend to results to
> > file.
> > #Obtain location
> > #Set Dictionary
> > #Event number
> > #Obtain set size
> > #Prompt first entry
> > #First Entry Number
> > #First Entry Name
> > #Set Blocks to obtain and calculate data
> > #Block 1 example - Placings Block
> > #Obtain number of events competed in
> > #Obtain how many times finished first
> > #Ensure this value is not greater than Number of Events
> > #Number of Firsts divide by Events * total by 15.
> > #Obtain Second finishes
> > #Ensure this value is not greater than Number of Events
> > #Number of Seconds divide by Events * total by 10.
> > #Continue On with this
> > #Block 2 - Lookup coach Dict and apply value.
> > #Obtain Surname of Coach
> > #Lookup Coach File and Match Name and get value.
> > #Blocks continue gaining and calculating values.
> > #create txt file named using date
> > #Sum Values Block1 + Block2 etc
> > #Print to file event number and field with name number individual
> > Block totals and Sum Total
> > #Arranged in descending Sum Total.
> > #Prompt are there any more events? Yes return to start
> > #Apphend all additional events to same day file seperated by blank line.
>
> How many of these steps have you attempted actually coding?  Seems to me
> your first two steps are just string manipulation, and you only need to
> use the datetime module if you need to validate.  In other words, if the
> user specifies the date as 31/09/2009, you might want to later bounce
> back to him with a complaint that September only has 30 days.
>
> So the first task is to accept input in the form   ab/cd/efgh   and
> produce a string  efgh-cd-ab.log   which you will then create as a text
> file.  And if the file exists, you'll append to it instead of
> overwriting it.   Can you do that much?
>
> DaveA

Trying but haven't got it working, thats why I started to try and use
datetime module.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Date using input

2009-09-24 Thread flebber
On Sep 24, 11:10 pm, flebber  wrote:
> On Sep 24, 10:58 pm, Dave Angel  wrote:
>
>
>
> > flebber.c...@gmail.com wrote:
> > > I am using python 2.6.2, I haven't updated to 3.0 yet. No I have no
> > > class or instructor, I am learning this myself. I have Hetlands book
> > > "Beginning Python Novice to Professional and online documentation
> > > books so Dive into Python, python.org etc.
>
> > > Using the SPE editor.
>
> > > I have currently only fully written basic psuedocode to give me a
> > > basic framework to guide myself.
>
> > > #Basic pseudocode
> > > #Purpose to get raw input and calculate a score for a field of options
> > > and return that
> > > #score in a set in descending order.
> > > #Multiple sets sould be written to the doc
>
> > > #Obtain date
> > > #Check if txt file with same date exists. If yes apphend to results to
> > > file.
> > > #Obtain location
> > > #Set Dictionary
> > > #Event number
> > > #Obtain set size
> > > #Prompt first entry
> > > #First Entry Number
> > > #First Entry Name
> > > #Set Blocks to obtain and calculate data
> > > #Block 1 example - Placings Block
> > > #Obtain number of events competed in
> > > #Obtain how many times finished first
> > > #Ensure this value is not greater than Number of Events
> > > #Number of Firsts divide by Events * total by 15.
> > > #Obtain Second finishes
> > > #Ensure this value is not greater than Number of Events
> > > #Number of Seconds divide by Events * total by 10.
> > > #Continue On with this
> > > #Block 2 - Lookup coach Dict and apply value.
> > > #Obtain Surname of Coach
> > > #Lookup Coach File and Match Name and get value.
> > > #Blocks continue gaining and calculating values.
> > > #create txt file named using date
> > > #Sum Values Block1 + Block2 etc
> > > #Print to file event number and field with name number individual
> > > Block totals and Sum Total
> > > #Arranged in descending Sum Total.
> > > #Prompt are there any more events? Yes return to start
> > > #Apphend all additional events to same day file seperated by blank line.
>
> > How many of these steps have you attempted actually coding?  Seems to me
> > your first two steps are just string manipulation, and you only need to
> > use the datetime module if you need to validate.  In other words, if the
> > user specifies the date as 31/09/2009, you might want to later bounce
> > back to him with a complaint that September only has 30 days.
>
> > So the first task is to accept input in the form   ab/cd/efgh   and
> > produce a string  efgh-cd-ab.log   which you will then create as a text
> > file.  And if the file exists, you'll append to it instead of
> > overwriting it.   Can you do that much?
>
> > DaveA
>
> Trying but haven't got it working, thats why I started to try and use
> datetime module.

Surely getting it tottally mixed up

from datetime import date
def ObtainDate(params):
  date = raw_input("Type Date dd/mm/year: %2.0r%2.0r/%2.0r%2.0r/%4.0r
%4.0r%4.0r%4.0r")
 print date.datetime(year-month-day)
 #Check if txt file with same date exists. If yes apphend to results
to file.
date.append(datetime

and

def ObtainDate(params):
date = raw_input("Type Date dd/mm/year: ")
date.format = (%4.0s%4.0s%4.0s%4.0s-%2.0s%2.0s-%2.0s)
print date.format


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


Python Macros's Not the Power in OOo they should be ?

2010-09-22 Thread flebber
I have recently been looking at openoffice because I saw it had
support to use python Macro's. I thought this would provide OOo with a
great advantage a fully powerful high level language as compared to
VBA in Excel.

I have found few docs on the subject.
http://wiki.services.openoffice.org/wiki/Python_as_a_macro_language
http://development.openoffice.org/
http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/Scripting/Scripting_Framework

Doesn't appear at the moment Python doesn't have the power in OOo it
should. Has anyone had much success with python macro's. Or developing
powerful macro's in an language?

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


Re: Python Macros's Not the Power in OOo they should be ?

2010-09-22 Thread flebber
On Sep 23, 10:41 am, flebber  wrote:
> I have recently been looking at openoffice because I saw it had
> support to use python Macro's. I thought this would provide OOo with a
> great advantage a fully powerful high level language as compared to
> VBA in Excel.
>
> I have found few docs on the 
> subject.http://wiki.services.openoffice.org/wiki/Python_as_a_macro_languagehttp://development.openoffice.org/http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/Scrip...
>
> Doesn't appear at the moment Python doesn't have the power in OOo it
> should. Has anyone had much success with python macro's. Or developing
> powerful macro's in an language?

I sort of expected they might have had jpython or javascript version
of the excel VBA editor.
-- 
http://mail.python.org/mailman/listinfo/python-list


Errors with PyPdf

2010-09-26 Thread flebber
I was trying to use Pypdf following a recipe from the Activestate
cookbooks. However I cannot get it too work. Unsure if it is me or it
is beacuse sets are deprecated.

I have placed a pdf in my C:\ drive. it is called "Components-of-Dot-
NET.pdf" You could use anything I was just testing with it.

I was using the last script on that page that was most recently
updated. I am using python 2.6.

http://code.activestate.com/recipes/511465-pure-python-pdf-to-text-converter/

import pyPdf

def getPDFContent(path):
content = "C:\Components-of-Dot-NET.pdf"
# Load PDF into pyPDF
pdf = pyPdf.PdfFileReader(file(path, "rb"))
# Iterate pages
for i in range(0, pdf.getNumPages()):
# Extract text from page and add to content
content += pdf.getPage(i).extractText() + "\n"
# Collapse whitespace
content = " ".join(content.replace(u"\xa0", " ").strip().split())
return content

print getPDFContent("Components-of-Dot-NET.pdf").encode("ascii",
"ignore")

This is my error.

>>>

Warning (from warnings module):
  File "C:\Documents and Settings\Family\Application Data\Python
\Python26\site-packages\pyPdf\pdf.py", line 52
from sets import ImmutableSet
DeprecationWarning: the sets module is deprecated

Traceback (most recent call last):
  File "C:/Python26/Pdfread", line 15, in 
print getPDFContent("Components-of-Dot-NET.pdf").encode("ascii",
"ignore")
  File "C:/Python26/Pdfread", line 6, in getPDFContent
pdf = pyPdf.PdfFileReader(file(path, "rb"))
IOError: [Errno 2] No such file or directory: 'Components-of-Dot-
NET.pdf'
>>>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Errors with PyPdf

2010-09-26 Thread flebber
On Sep 27, 9:38 am, "w.g.sned...@gmail.com" 
wrote:
> On Sep 26, 7:10 pm, flebber  wrote:
>
> > I was trying to use Pypdf following a recipe from the Activestate
> > cookbooks. However I cannot get it too work. Unsure if it is me or it
> > is beacuse sets are deprecated.
>
> > I have placed a pdf in my C:\ drive. it is called "Components-of-Dot-
> > NET.pdf" You could use anything I was just testing with it.
>
> > I was using the last script on that page that was most recently
> > updated. I am using python 2.6.
>
> >http://code.activestate.com/recipes/511465-pure-python-pdf-to-text-co...
>
> > import pyPdf
>
> > def getPDFContent(path):
> >     content = "C:\Components-of-Dot-NET.pdf"
> >     # Load PDF into pyPDF
> >     pdf = pyPdf.PdfFileReader(file(path, "rb"))
> >     # Iterate pages
> >     for i in range(0, pdf.getNumPages()):
> >         # Extract text from page and add to content
> >         content += pdf.getPage(i).extractText() + "\n"
> >     # Collapse whitespace
> >     content = " ".join(content.replace(u"\xa0", " ").strip().split())
> >     return content
>
> > print getPDFContent("Components-of-Dot-NET.pdf").encode("ascii",
> > "ignore")
>
> > This is my error.
>
> > Warning (from warnings module):
> >   File "C:\Documents and Settings\Family\Application Data\Python
> > \Python26\site-packages\pyPdf\pdf.py", line 52
> >     from sets import ImmutableSet
> > DeprecationWarning: the sets module is deprecated
>
> > Traceback (most recent call last):
> >   File "C:/Python26/Pdfread", line 15, in 
> >     print getPDFContent("Components-of-Dot-NET.pdf").encode("ascii",
> > "ignore")
> >   File "C:/Python26/Pdfread", line 6, in getPDFContent
> >     pdf = pyPdf.PdfFileReader(file(path, "rb"))
>
> ---> IOError: [Errno 2] No such file or directory: 'Components-of-Dot-> 
> NET.pdf'
>
> Looks like a issue with finding the file.
> how do you pass the path?

okay thanks I thought that when I set content here

def getPDFContent(path):
content = "C:\Components-of-Dot-NET.pdf"

that i was defining where it is.

but yeah I updated script to below and it works. That is the contents
are displayed to the interpreter. How do I output to a .txt file?

import pyPdf

def getPDFContent(path):
content = "C:\Components-of-Dot-NET.pdf"
# Load PDF into pyPDF
pdf = pyPdf.PdfFileReader(file(path, "rb"))
# Iterate pages
for i in range(0, pdf.getNumPages()):
# Extract text from page and add to content
content += pdf.getPage(i).extractText() + "\n"
# Collapse whitespace
content = " ".join(content.replace(u"\xa0", " ").strip().split())
return content

print getPDFContent(r"C:\Components-of-Dot-NET.pdf").encode("ascii",
"ignore")




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


Re: Errors with PyPdf

2010-09-26 Thread flebber
On Sep 27, 10:39 am, flebber  wrote:
> On Sep 27, 9:38 am, "w.g.sned...@gmail.com" 
> wrote:
>
>
>
> > On Sep 26, 7:10 pm, flebber  wrote:
>
> > > I was trying to use Pypdf following a recipe from the Activestate
> > > cookbooks. However I cannot get it too work. Unsure if it is me or it
> > > is beacuse sets are deprecated.
>
> > > I have placed a pdf in my C:\ drive. it is called "Components-of-Dot-
> > > NET.pdf" You could use anything I was just testing with it.
>
> > > I was using the last script on that page that was most recently
> > > updated. I am using python 2.6.
>
> > >http://code.activestate.com/recipes/511465-pure-python-pdf-to-text-co...
>
> > > import pyPdf
>
> > > def getPDFContent(path):
> > >     content = "C:\Components-of-Dot-NET.pdf"
> > >     # Load PDF into pyPDF
> > >     pdf = pyPdf.PdfFileReader(file(path, "rb"))
> > >     # Iterate pages
> > >     for i in range(0, pdf.getNumPages()):
> > >         # Extract text from page and add to content
> > >         content += pdf.getPage(i).extractText() + "\n"
> > >     # Collapse whitespace
> > >     content = " ".join(content.replace(u"\xa0", " ").strip().split())
> > >     return content
>
> > > print getPDFContent("Components-of-Dot-NET.pdf").encode("ascii",
> > > "ignore")
>
> > > This is my error.
>
> > > Warning (from warnings module):
> > >   File "C:\Documents and Settings\Family\Application Data\Python
> > > \Python26\site-packages\pyPdf\pdf.py", line 52
> > >     from sets import ImmutableSet
> > > DeprecationWarning: the sets module is deprecated
>
> > > Traceback (most recent call last):
> > >   File "C:/Python26/Pdfread", line 15, in 
> > >     print getPDFContent("Components-of-Dot-NET.pdf").encode("ascii",
> > > "ignore")
> > >   File "C:/Python26/Pdfread", line 6, in getPDFContent
> > >     pdf = pyPdf.PdfFileReader(file(path, "rb"))
>
> > ---> IOError: [Errno 2] No such file or directory: 'Components-of-Dot-> 
> > NET.pdf'
>
> > Looks like a issue with finding the file.
> > how do you pass the path?
>
> okay thanks I thought that when I set content here
>
> def getPDFContent(path):
>     content = "C:\Components-of-Dot-NET.pdf"
>
> that i was defining where it is.
>
> but yeah I updated script to below and it works. That is the contents
> are displayed to the interpreter. How do I output to a .txt file?
>
> import pyPdf
>
> def getPDFContent(path):
>     content = "C:\Components-of-Dot-NET.pdf"
>     # Load PDF into pyPDF
>     pdf = pyPdf.PdfFileReader(file(path, "rb"))
>     # Iterate pages
>     for i in range(0, pdf.getNumPages()):
>         # Extract text from page and add to content
>         content += pdf.getPage(i).extractText() + "\n"
>     # Collapse whitespace
>     content = " ".join(content.replace(u"\xa0", " ").strip().split())
>     return content
>
> print getPDFContent(r"C:\Components-of-Dot-NET.pdf").encode("ascii",
> "ignore")

I have found far more advanced scripts searching around. But will have
to keep trying as I cannot get an output file or specify the path.

Edit very strangely whilst searching for examples I found my own post
just written here ranking number 5 on google within 2 hours. Bizzare.

http://www.eggheadcafe.com/software/aspnet/36237766/errors-with-pypdf.aspx

Replicates our thread as thiers. I was searching ggole with "pypdf
return to txt file"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Errors with PyPdf

2010-09-26 Thread flebber
On Sep 27, 12:08 pm, flebber  wrote:
> On Sep 27, 10:39 am, flebber  wrote:
>
>
>
> > On Sep 27, 9:38 am, "w.g.sned...@gmail.com" 
> > wrote:
>
> > > On Sep 26, 7:10 pm, flebber  wrote:
>
> > > > I was trying to use Pypdf following a recipe from the Activestate
> > > > cookbooks. However I cannot get it too work. Unsure if it is me or it
> > > > is beacuse sets are deprecated.
>
> > > > I have placed a pdf in my C:\ drive. it is called "Components-of-Dot-
> > > > NET.pdf" You could use anything I was just testing with it.
>
> > > > I was using the last script on that page that was most recently
> > > > updated. I am using python 2.6.
>
> > > >http://code.activestate.com/recipes/511465-pure-python-pdf-to-text-co...
>
> > > > import pyPdf
>
> > > > def getPDFContent(path):
> > > >     content = "C:\Components-of-Dot-NET.pdf"
> > > >     # Load PDF into pyPDF
> > > >     pdf = pyPdf.PdfFileReader(file(path, "rb"))
> > > >     # Iterate pages
> > > >     for i in range(0, pdf.getNumPages()):
> > > >         # Extract text from page and add to content
> > > >         content += pdf.getPage(i).extractText() + "\n"
> > > >     # Collapse whitespace
> > > >     content = " ".join(content.replace(u"\xa0", " ").strip().split())
> > > >     return content
>
> > > > print getPDFContent("Components-of-Dot-NET.pdf").encode("ascii",
> > > > "ignore")
>
> > > > This is my error.
>
> > > > Warning (from warnings module):
> > > >   File "C:\Documents and Settings\Family\Application Data\Python
> > > > \Python26\site-packages\pyPdf\pdf.py", line 52
> > > >     from sets import ImmutableSet
> > > > DeprecationWarning: the sets module is deprecated
>
> > > > Traceback (most recent call last):
> > > >   File "C:/Python26/Pdfread", line 15, in 
> > > >     print getPDFContent("Components-of-Dot-NET.pdf").encode("ascii",
> > > > "ignore")
> > > >   File "C:/Python26/Pdfread", line 6, in getPDFContent
> > > >     pdf = pyPdf.PdfFileReader(file(path, "rb"))
>
> > > ---> IOError: [Errno 2] No such file or directory: 'Components-of-Dot-> 
> > > NET.pdf'
>
> > > Looks like a issue with finding the file.
> > > how do you pass the path?
>
> > okay thanks I thought that when I set content here
>
> > def getPDFContent(path):
> >     content = "C:\Components-of-Dot-NET.pdf"
>
> > that i was defining where it is.
>
> > but yeah I updated script to below and it works. That is the contents
> > are displayed to the interpreter. How do I output to a .txt file?
>
> > import pyPdf
>
> > def getPDFContent(path):
> >     content = "C:\Components-of-Dot-NET.pdf"
> >     # Load PDF into pyPDF
> >     pdf = pyPdf.PdfFileReader(file(path, "rb"))
> >     # Iterate pages
> >     for i in range(0, pdf.getNumPages()):
> >         # Extract text from page and add to content
> >         content += pdf.getPage(i).extractText() + "\n"
> >     # Collapse whitespace
> >     content = " ".join(content.replace(u"\xa0", " ").strip().split())
> >     return content
>
> > print getPDFContent(r"C:\Components-of-Dot-NET.pdf").encode("ascii",
> > "ignore")
>
> I have found far more advanced scripts searching around. But will have
> to keep trying as I cannot get an output file or specify the path.
>
> Edit very strangely whilst searching for examples I found my own post
> just written here ranking number 5 on google within 2 hours. Bizzare.
>
> http://www.eggheadcafe.com/software/aspnet/36237766/errors-with-pypdf...
>
> Replicates our thread as thiers. I was searching ggole with "pypdf
> return to txt file"

Traceback (most recent call last):
  File "C:/Python26/Pdfread", line 16, in 
open('x.txt', 'w').write(content)
NameError: name 'content' is not defined
>>>

When i use.

import pyPdf

def getPDFContent(path):
content = "C:\Components-of-Dot-NET.txt"
# Load PDF into pyPDF
pdf = pyPdf.PdfFileReader(file(path, "rb"))
# Iterate pages
for i in range(0, pdf.getNumPages()):
# Extract text from page and add to content
content += pdf.getPage(i).extractText() + "\n"
# Collapse whitespace
content = " ".join(content.replace(u"\xa0", " ").strip().split())
return content

print getPDFContent(r"C:\Components-of-Dot-NET.pdf").encode("ascii",
"ignore")
open('x.txt', 'w').write(content)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Errors with PyPdf

2010-09-26 Thread flebber
On Sep 27, 12:49 pm, MRAB  wrote:
> On 27/09/2010 01:39, flebber wrote:
>
>
>
> > On Sep 27, 9:38 am, "w.g.sned...@gmail.com"
> > wrote:
> >> On Sep 26, 7:10 pm, flebber  wrote:
>
> >>> I was trying to use Pypdf following a recipe from the Activestate
> >>> cookbooks. However I cannot get it too work. Unsure if it is me or it
> >>> is beacuse sets are deprecated.
>
> >>> I have placed a pdf in my C:\ drive. it is called "Components-of-Dot-
> >>> NET.pdf" You could use anything I was just testing with it.
>
> >>> I was using the last script on that page that was most recently
> >>> updated. I am using python 2.6.
>
> >>>http://code.activestate.com/recipes/511465-pure-python-pdf-to-text-co...
>
> >>> import pyPdf
>
> >>> def getPDFContent(path):
> >>>      content = "C:\Components-of-Dot-NET.pdf"
> >>>      # Load PDF into pyPDF
> >>>      pdf = pyPdf.PdfFileReader(file(path, "rb"))
> >>>      # Iterate pages
> >>>      for i in range(0, pdf.getNumPages()):
> >>>          # Extract text from page and add to content
> >>>          content += pdf.getPage(i).extractText() + "\n"
> >>>      # Collapse whitespace
> >>>      content = " ".join(content.replace(u"\xa0", " ").strip().split())
> >>>      return content
>
> >>> print getPDFContent("Components-of-Dot-NET.pdf").encode("ascii",
> >>> "ignore")
>
> >>> This is my error.
>
> >>> Warning (from warnings module):
> >>>    File "C:\Documents and Settings\Family\Application Data\Python
> >>> \Python26\site-packages\pyPdf\pdf.py", line 52
> >>>      from sets import ImmutableSet
> >>> DeprecationWarning: the sets module is deprecated
>
> >>> Traceback (most recent call last):
> >>>    File "C:/Python26/Pdfread", line 15, in
> >>>      print getPDFContent("Components-of-Dot-NET.pdf").encode("ascii",
> >>> "ignore")
> >>>    File "C:/Python26/Pdfread", line 6, in getPDFContent
> >>>      pdf = pyPdf.PdfFileReader(file(path, "rb"))
>
> >> --->  IOError: [Errno 2] No such file or directory: 'Components-of-Dot->  
> >> NET.pdf'
>
> >> Looks like a issue with finding the file.
> >> how do you pass the path?
>
> > okay thanks I thought that when I set content here
>
> > def getPDFContent(path):
> >      content = "C:\Components-of-Dot-NET.pdf"
>
> > that i was defining where it is.
>
> > but yeah I updated script to below and it works. That is the contents
> > are displayed to the interpreter. How do I output to a .txt file?
>
> > import pyPdf
>
> > def getPDFContent(path):
> >      content = "C:\Components-of-Dot-NET.pdf"
>
> That simply binds to a local name; 'content' is a local variable in the
> function 'getPDFContent'.
>
> >      # Load PDF into pyPDF
> >      pdf = pyPdf.PdfFileReader(file(path, "rb"))
>
> You're opening a file whose path is in 'path'.
>
> >      # Iterate pages
> >      for i in range(0, pdf.getNumPages()):
> >          # Extract text from page and add to content
> >          content += pdf.getPage(i).extractText() + "\n"
>
> That appends to 'content'.
>
> >      # Collapse whitespace
>
> 'content' now contains the text of the PDF, starting with
> r"C:\Components-of-Dot-NET.pdf".
>
> >      content = " ".join(content.replace(u"\xa0", " ").strip().split())
> >      return content
>
> > print getPDFContent(r"C:\Components-of-Dot-NET.pdf").encode("ascii",
> > "ignore")
>
> Outputting to a .txt file is simple: open the file for writing using
> 'open', write the string to it, and then close it.

Thats what I was trying to do with

open('x.txt', 'w').write(content)

the rest of the script works it wont output the tect though
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Errors with PyPdf

2010-09-27 Thread flebber
On Sep 27, 2:46 pm, Dave Angel  wrote:
> On 2:59 PM, flebber wrote:
>
> > 
> > Traceback (most recent call last):
> >    File "C:/Python26/Pdfread", line 16, in
> >      open('x.txt', 'w').write(content)
> > NameError: name 'content' is not defined
> > When i use.
>
> > import pyPdf
>
> > def getPDFContent(path):
> >      content =C:\Components-of-Dot-NET.txt"
> >      # Load PDF into pyPDF
> >      pdf =yPdf.PdfFileReader(file(path, "rb"))
> >      # Iterate pages
> >      for i in range(0, pdf.getNumPages()):
> >          # Extract text from page and add to content
> >          content +=df.getPage(i).extractText() + "\n"
> >      # Collapse whitespace
> >      content = ".join(content.replace(u"\xa0", " ").strip().split())
> >      return content
>
> > print getPDFContent(r"C:\Components-of-Dot-NET.pdf").encode("ascii",
> > "ignore")
> > open('x.txt', 'w').write(content)
>
> There's no global variable content, that was local to the function.  So
> it's lost when the function exits.  it does return the value, but you
> give it to print, and don't save it anywhere.
>
> data = getPDFContent(r"C:\Components-of-Dot-NET.pdf").encode("ascii",
> "ignore")
>
> outfile = open('x.txt', 'w')
> outfile.write(data)
>
> close(outfile)
>
> I used a different name to emphasize that this is *not* the same
> variable as content inside the function.  In this case, it happens to
> have the same value.  And if you used the same name, you could be
> confused about which is which.
>
> DaveA

Thank You everyone.
-- 
http://mail.python.org/mailman/listinfo/python-list


Crummy BS Script

2010-10-01 Thread flebber
I have a simple question regarding the Beuatiful soup crummy script.
The last line is f.write('%s, %s, %s, %s, %s \n' % (i, t[0], t[1],
t[2], t[3])), But where is this saving the imported file and under
what name?

#!/usr/bin/env python
# ogm-sampples.py
# Author: Matt Mayes
# March 11, 2008
"""
-- This requires the Beautiful Soup mod: 
http://www.crummy.com/software/BeautifulSoup/
--
Steps:
1. Identify all 's that are preceded with '' (which denotes a header here)
2. Pull that font text, and store as dictionary key
3. Extract all links and link text from the list, generate a link
title and type (pdf/html/404) store as tuples in
appropriate dict key (note that some list items contain more than 1
link, this handles it) If it's a 404, it will
not be added to the list.
4. Identify if it's linking to an HTML page or PDF
5. If it's a local pdf referenced by a root value ("/file.pdf"), it
strips the slash. Modify to suit your needs.
6. Generate a CSV file of results
"""

import urllib2, re
from BeautifulSoup import BeautifulSoup

page = urllib2.urlopen("http://www.givegoodweb.com/examples/ogm-
samples.html")
soup = BeautifulSoup(page)
fontStart = re.compile(r'?')
fontEnd = re.compile(r'')
titleSearch = re.compile(r'title=')
getTitle = re.compile(r'(.*)',re.DOTALL|re.MULTILINE)
emailSearch = re.compile(r'mailto')

def removeNL(x):
"""cleans a string of new lines and spaces"""
s = x.split('\n')
s = [x.strip() for x in s]
x = " ".join(s)
return x.lstrip()

ul_tags = {}

for ul in soup.html.body.findAll('ul'):
links = []
x = ul.findPrevious('font', color="#3C378C").renderContents()
if '\n' in x:
x = removeNL(x)
for li in ul.findAll('li'):
line = []
for a in li.findAll('a'):
c = removeNL(str(a.contents[0]))
c = fontStart.sub('', c)
c = fontEnd.sub('', c)
href = str(a.get('href'))
if href[-3:].lower() == 'pdf':
type = 'pdf'
title = "PDF sample"
elif emailSearch.search(href):
title = 'email'
else:
type = 'html'
try:
f = urllib2.urlopen(href)
# reading in 2000 characters should to 
it
t = getTitle.search(f.read(2000))
if t :
title = t.group(1)
title = removeNL(title)
else : title = "open link"
except urllib2.HTTPError, e:
title = 404
f.close()
if title != 404:
line.append((c, href.lstrip('/'), type, title))
links.append(line)
ul_tags[x] = links

page.close()

f = open('samples.csv', 'w')

for i in ul_tags.iterkeys():
for x in ul_tags[i]:
for t in x:
f.write('%s, %s, %s, %s, %s \n' % (i, t[0], t[1], t[2], 
t[3]))

f.close()

I got it from http://pastie.textmate.org/164503
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Crummy BS Script

2010-10-01 Thread flebber
On Oct 2, 9:27 am, MRAB  wrote:
> On 01/10/2010 23:29, Burton Samograd wrote:> flebber  
> writes:
>
> >> But where is this saving the imported file and under what name?
>
> > Looks like samples.csv:
>
> >> f = open('samples.csv', 'w')
>
> It'll be in the current working directory, which is given by:
>
>      os.getcwd()

So how do I call the output to direct it to file? I can't see which
part to get.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Crummy BS Script

2010-10-02 Thread flebber
On Oct 2, 4:24 pm, Steven D'Aprano  wrote:
> On Fri, 01 Oct 2010 21:05:09 -0700, flebber wrote:
> > On Oct 2, 9:27 am, MRAB  wrote:
> >> On 01/10/2010 23:29, Burton Samograd wrote:>
> >> flebber  writes:
>
> >> >> But where is this saving the imported file and under what name?
>
> >> > Looks like samples.csv:
>
> >> >> f = open('samples.csv', 'w')
>
> >> It'll be in the current working directory, which is given by:
>
> >>      os.getcwd()
>
> > So how do I call the output to direct it to file? I can't see which part
> > to get.
>
> I don't understand your question. What do you mean "call the output" --
> you normally don't call the output, you call a function or program to get
> output. The output is already directed to a file, as you were shown -- it
> is written to the file samples.csv in the current directory.
>
> Perhaps if you explain your question more carefully, we might be able to
> help a little more.
>
> --
> Steven

How do change where output goes and what its called
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Crummy BS Script

2010-10-02 Thread flebber
On Oct 3, 9:58 am, John Bokma  wrote:
> flebber  writes:
> > On Oct 2, 4:24 pm, Steven D'Aprano  > cybersource.com.au> wrote:
> >> On Fri, 01 Oct 2010 21:05:09 -0700, flebber wrote:
> >> > On Oct 2, 9:27 am, MRAB  wrote:
> >> >> On 01/10/2010 23:29, Burton Samograd wrote:>
> >> >> flebber  writes:
>
> >> >> >> But where is this saving the imported file and under what name?
>
> >> >> > Looks like samples.csv:
>
> >> >> >> f = open('samples.csv', 'w')
> > How do change where output goes and what its called
>
>  f = open('samples.csv', 'w')
>
> were else? Maybe read a beginners book on Python before you start on a
> path of Cargo Cult Coding?
>
> --
> John Bokma                                                               j3b
>
> Blog:http://johnbokma.com/   Facebook:http://www.facebook.com/j.j.j.bokma
>     Freelance Perl & Python Development:http://castleamber.com/

Cargo Cult Coding?

Not sure what it is but it sounds good.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Crummy BS Script

2010-10-02 Thread flebber
On Oct 3, 4:15 pm, flebber  wrote:
> On Oct 3, 9:58 am, John Bokma  wrote:
>
>
>
> > flebber  writes:
> > > On Oct 2, 4:24 pm, Steven D'Aprano  > > cybersource.com.au> wrote:
> > >> On Fri, 01 Oct 2010 21:05:09 -0700, flebber wrote:
> > >> > On Oct 2, 9:27 am, MRAB  wrote:
> > >> >> On 01/10/2010 23:29, Burton Samograd wrote:>
> > >> >> flebber  writes:
>
> > >> >> >> But where is this saving the imported file and under what name?
>
> > >> >> > Looks like samples.csv:
>
> > >> >> >> f = open('samples.csv', 'w')
> > > How do change where output goes and what its called
>
> >  f = open('samples.csv', 'w')
>
> > were else? Maybe read a beginners book on Python before you start on a
> > path of Cargo Cult Coding?
>
> > --
> > John Bokma                                                               j3b
>
> > Blog:http://johnbokma.com/  Facebook:http://www.facebook.com/j.j.j.bokma
> >     Freelance Perl & Python Development:http://castleamber.com/
>
> Cargo Cult Coding?
>
> Not sure what it is but it sounds good.

When I get an error from this when using Alan's site as a test this a
result of the script being unable to pass page elements isn't it?

http://www.freenetpages.co.uk/hp/alan.gauld/

Traceback (most recent call last):
 File "C:\Sayth\Scripts\BSScriptCrummy.py", line 38, in 
for ul in soup.html.body.findAll('ul'):
AttributeError: 'NoneType' object has no attribute 'findAll'
Script terminated.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Light on Dark screen for Spe or Pyscripter

2010-10-09 Thread flebber
On Oct 9, 3:54 pm, flebber  wrote:
> I was hoping someone knew how to setup pyscripter or Spe ide's with
> light on dark windows. I start to have trouble reading the nomal dark
> on light screens after any lengthy period.
>
> I have seen several screenshot showing emacs with python setup with
> awesome light on dark terminals but seems you need a degree in itself
> to get emacs and python working on windows with full features.

Pyscripter does have a selectable theme option in its options menu.
However seems to only relate to syntax colours and highlighting,
doesn't seem to allow changing theme to light on dark.

Anyhow still a good ide.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Re: Date using input

2009-09-24 Thread flebber . crue
I am using python 2.6.2, I haven't updated to 3.0 yet. No I have no class  
or instructor, I am learning this myself. I have Hetlands book "Beginning  
Python Novice to Professional and online documentation books so Dive into  
Python, python.org etc.


Using the SPE editor.

I have currently only fully written basic psuedocode to give me a basic  
framework to guide myself.


#Basic pseudocode
#Purpose to get raw input and calculate a score for a field of options and  
return that

#score in a set in descending order.
#Multiple sets sould be written to the doc

#Obtain date
#Check if txt file with same date exists. If yes apphend to results to file.
#Obtain location
#Set Dictionary
#Event number
#Obtain set size
#Prompt first entry
#First Entry Number
#First Entry Name
#Set Blocks to obtain and calculate data
#Block 1 example - Placings Block
#Obtain number of events competed in
#Obtain how many times finished first
#Ensure this value is not greater than Number of Events
#Number of Firsts divide by Events * total by 15.
#Obtain Second finishes
#Ensure this value is not greater than Number of Events
#Number of Seconds divide by Events * total by 10.
#Continue On with this
#Block 2 - Lookup coach Dict and apply value.
#Obtain Surname of Coach
#Lookup Coach File and Match Name and get value.
#Blocks continue gaining and calculating values.
#create txt file named using date
#Sum Values Block1 + Block2 etc
#Print to file event number and field with name number individual Block  
totals and Sum Total

#Arranged in descending Sum Total.
#Prompt are there any more events? Yes return to start
#Apphend all additional events to same day file seperated by blank line.


On Sep 24, 2009 9:59pm, Dave Angel  wrote:

flebber wrote:




Sorry to ask a simple question but I am a little confused how to



combine the input function and the date time module.





Simply at the start of the program I want to prompt the user to enter



the date, desirably in the format dd/mm/year.



However I want to make sure that python understands the time format



because first the date will form part of the name of the output file



so dd/mm/year as 1st September 2009, secondly if I have multiple



output files saved in a directory I may need to search later on the



files and contents of files by date range. So can I timestamp the



file?





I know this is a simple question but it eludes me exactly how to do



it.





I have the basics from http://docs.python.org/library/datetime.html





from datetime import date



date = input("type date dd/mm/year: ")



datetime(day,month,year)





# some program blocks





#print to file(name = date) or apphend if it exists









What version of python is your class, instructor, and text book using? If  
you want to learn fastest, you probably need to be using the same, or  
nearly same environment. The input() function is one place where it  
matters whether it's Python 2.x or Python 3.x. While you're at it, you  
should give the rest of your environment, such as which OS.




The doc page you pointed us to is for Python 2.6.2, but the input  
function on that version returns an integer. Perhaps you want  
raw_input() ?




What code have you written, and what about it doesn't work? Have you  
added print statements before the line that causes the error to see what  
the intermediate values are?






To try to anticipate some of your problems, you should realize that in  
most file systems, the slash is a reserved character, so you can't write  
the date that way. I'd suggest using dashes. I put dates in directory  
names, and I always put year, then month, then day, because then sorting  
the filenames also sorts the dates. I'm not in a country that sorts dates  
that way, but it does make things easier. So directories for the last few  
days would be:



2009-09-22



2009-09-23



2009-09-24




When asking the user for a date, or telling him a date, by all means use  
your country's preferred format, as you say.




You mention timestamping the file. While that can be done (Unix touch,  
for example), I consider it a last resort for keeping track of useful  
information. At best, it should be an extra "reminder" of something  
that's already in the file contents. And since many programs make the  
assumption that if the timestamp doesn't change, the contents haven't  
changed, you can only reasonably do this on a file whose contents are  
fixed when first created.




If you control the internal format of the file, put the date there,  
perhaps right after the header which defines the data type and version.






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


  1   2   >