RE: Twisted or Tornado?

2013-03-05 Thread Andriy Kornatskyy
Jake,

Don't you lock yourself in twisted application server only? I doubt you will be 
able easily migrate to WSGI compatible application server as your needs grow.

Andriy


> From: jake.ang...@gmail.com 
> Date: Mon, 4 Mar 2013 10:35:41 +1100 
> Subject: Re: Twisted or Tornado? 
> To: andriy.kornats...@live.com 
> CC: sven...@gmail.com; python-list@python.org 
> 
> 
> All, 
> 
> Thanks for your reply - I thought I would share the outcome of my choice: 
> 
> I have chosen to use twisted. The API is very decent to learn, though 
> the clincher is theres huge community / docs, and many projects used on 
> production. 
> 
> I was able to make a working project prototype in hours! 
> Thanks to the large twisted library. 
> 
> Our project is an ipad multiplayer game, and we didnt want to use 
> existing servers because we want to do things exactly as we wish. 
> 
> Rgds, 
> 
> Jake 
> 
> On Fri, Mar 1, 2013 at 8:55 PM, Andriy Kornatskyy 
> mailto:andriy.kornats...@live.com>> wrote: 
> 
> The following benchmarks are related to: 
> 
> a) python web frameworks 
> http://mindref.blogspot.com/2012/09/python-fastest-web-framework.html 
> http://mindref.blogspot.com/2012/10/python-web-routing-benchmark.html 
> http://mindref.blogspot.com/2012/10/python-web-reverse-urls-benchmark.html 
> http://mindref.blogspot.com/2012/10/python-web-caching-benchmark.html 
> 
> b) template engines 
> http://mindref.blogspot.com/2012/10/python-templates-benchmark.html 
> http://mindref.blogspot.com/2012/07/python-fastest-template.html 
> 
> With source code: 
> https://bitbucket.org/akorn/helloworld 
> 
> Thanks. 
> 
> Andriy Kornatskyy 
> 
> 
>  
> > Date: Fri, 1 Mar 2013 09:25:43 + 
> > Subject: Re: Twisted or Tornado? 
> > From: sven...@gmail.com 
> > To: jake.ang...@gmail.com 
> > CC: python-list@python.org 
> > 
> > Although these articles are a _little_ old they are probably useful to 
> > help you decide which solution is most suitable for you in terms of 
> > performance 
> > 
> > http://nichol.as/benchmark-of-python-web-servers 
> > http://nichol.as/asynchronous-servers-in-python 
> > 
> > I would also be interested if any one on this list has any idea if the 
> > results above would be any different these days or whether the 
> > benchmarks are still fairly representative. 
> > 
> > 
> > On 1 March 2013 00:28, Jake Angulo 
> > 
> mailto:jake.ang...@gmail.com>>>
>  
> wrote: 
> > I have to say it first: I am not trolling :P 
> > 
> > Im working on a server project (with IOS client) and would like to 
> > create a custom, lean and mean server - real Quick! 
> > 
> > My requirements for this framework in descending order: 
> > 1) Easy to use API 
> > 2) Widely available documentation / Examples / Community contributions 
> > 3) Feature-wise - kinda most that you commonly need is there 
> > 
> > Your opinions will be valuable, if possible cite examples or URL 
> > references, Pls! 
> > 
> > I prefer opinion from those who have programmed real projects in it - 
> > not just read some blog or Slashdot :P 
> > -- 
> > http://mail.python.org/mailman/listinfo/python-list 
> > 
> > 
> > 
> > -- 
> > ./Sven 
> > 
> > -- http://mail.python.org/mailman/listinfo/python-list 
> 
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Python-ideas] string.format() default variable assignment

2013-03-05 Thread James Griffin
[- Tue  5.Mar'13 at  2:42:07 +  Steven D'Aprano :-]

> On Mon, 04 Mar 2013 11:09:10 -0500, David Robinow wrote:
> 
> >   But here's what I don't understand. Why does somebody who posts as
> > much as Steven (and thanks for that. Getting cussed at occasionally is a
> > cheap price for all the free advice) not set up a simple mail filter
> > which trashes all mail from python-list. Wouldn't that solve the
> > problem?  Or am I misunderstanding something?
> 
> When I'm working in my backyard garden, it's a real drag to put garden 
> refuse into the green waste bin for collection. I have to cut it up into 
> manageable-sized pieces, put them in a big carry bag, carry it through 
> the house, then empty the bag into the green waste collection bin the 
> local council supplies. What a drag! Maybe I should have thought of this 
> before moving into my house, but I'm stuck with it now, moving to a new 
> house would be difficult and expensive. Besides, apart from this one 
> little difficulty, I like it here. Since I have all sorts of good excuses 
> why doing the right thing is too much trouble, I just toss any plant 
> trimmings over the fence into my neighbour's yard. It's easy for him to 
> deal with it, all he has to do is get a goat to eat the garden waste I 
> toss over the fence, and his problem is solved.
> 
> I'm actually doing him a favour by tossing my garden trimmings into his 
> yard. If he doesn't get a goat, the trimmings will rot and turn into 
> compost, which improves the soil in his garden. He'll thank me some day.
> 
> I really don't understand why he thinks I'm being rude. He should be 
> grateful, not upset. If anyone is being rude, it's him, expecting me to 
> carry all that garden waste through the house into the collection bin. 
> Doesn't he understand how hard that is for me?

I'm sorry - i just had to reply :-) i've just got up and read this and
it actually made me LOL. Thanks Steven.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Twisted or Tornado?

2013-03-05 Thread Werner Thie

Hi

On 3/1/13 1:39 AM, Michael Torrie wrote:

On 02/28/2013 05:28 PM, Jake Angulo wrote:

My requirements for this framework in descending order: 1) Easy to
use API 2) Widely available documentation / Examples / Community
contributions 3) Feature-wise - kinda most that you commonly need is
there


I'm happy with twisted programming browser based multi-player games for 
several years now. I wouldn't say that the learning curve was steep, 
rather the opposite, but the gain from a clean async programming model 
as it is implemented in twisted really makes the difference for me, not 
only in writing games, but even more in maintaining them long term.


It's also interesting to see, that this clean async model of twisted and 
its host of already provided protocols allowed me to implement solutions 
in notoriously problematic areas like overall stability, fault 
tolerance, load induced behavior, server analysis, 
multicore/multimachine capabilities and hot deployment with ease.


Cheers, Werner




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


Downloading a file form a displayed table

2013-03-05 Thread Νίκος Γκρ33κ
# 
=
# display download button for each file and downlaod it on click
# 
=
if form.getvalue('show') == 'files':

print ( " " )
print ( "" )

path = "/data/files/"

for filename in os.walk(path):
print '''

print( "  %s 
 " ) % filename

'''

sys.exit(0)



I use the above code to tidplay a filenames table so the user cna download a 
displayed button style lookign file but its not printing anything for me just 
an emptry table

'/data/files' has 5 files in it but its not showing any.
I dont see what iam doign wrong
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Downloading a file form a displayed table

2013-03-05 Thread Dave Angel

On 03/05/2013 04:00 AM, Νίκος Γκρ33κ wrote:

# 
=
# display download button for each file and downlaod it on click
# 
=
if form.getvalue('show') == 'files':

print ( " " )
print ( "" )

path = "/data/files/"

for filename in os.walk(path):
print '''

print( "  %s  
" ) % filename

'''

sys.exit(0)



I use the above code to tidplay a filenames table so the user cna download a 
displayed button style lookign file but its not printing anything for me just 
an emptry table

'/data/files' has 5 files in it but its not showing any.
I dont see what iam doign wrong



It would be useful to actually specifying the context of this fragment 
of code.  Presumably it's running on a web server somewhere, and you're 
expecting the filenames to somehow show up on a browser.  Which OS and 
which version of Python for that server, and what brand and version of 
browser?


Have you considered closing the table, and ending the body of the page?

Have you looked at the result with View->Source in your browser?

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


testfixtures 3.0.0 Released!

2013-03-05 Thread Chris Withers

Hi All,

I'm pleased to announce the release of testfixtures 3.0.0. The big 
change for this release is that testfixtures now supports Python 2.6, 
2.7, 3.2 and 3.3!


As a result, some changes have been made to TempDirectory to support 
encoding and decoding. There's also a nice little addition of an 
optional prefix to the message generated when comparisons fail:



from testfixtures import compare
compare(1, 2, prefix='wrong number of orders')

Traceback (most recent call last):
 ...
AssertionError: wrong number of orders: 1 != 2

The means that you still get the rich comparison feedback offered by 
compare, but can also add more information to make any failure more 
easily understandable without having to dig into the source.


Other than that, there have been a couple of minor bug fixes.

If you haven't bumped into it already, testfixtures is a collection of 
helpers for writing succinct unit tests including help for:


- Comparing objects and sequences

Better feedback when the results aren't as you expected along with 
support for comparison of objects that don't normally support comparison.


- Mocking out objects and methods

Easy to use ways of stubbing out objects, classes or individual methods 
for both doc tests and unit tests. Special helpers are provided for 
testing with dates and times.


- Testing logging

Helpers for capturing logging output in both doc tests and unit tests.

- Testing stream output

Helpers for capturing stream output, such as that from print statements, 
and making assertion about it.


- Testing with files and directories

Support for creating and checking files and directories in sandboxes for 
both doc tests and unit tests.


- Testing exceptions

Easy to use ways of checking that a certain exception is raised, even 
down the to the parameters the exception is raised with.


The package is on PyPI and a full list of all the links to docs, issue 
trackers and the like can be found here:


http://www.simplistix.co.uk/software/python/testfixtures

Any questions, please do ask on the Testing in Python list or on the 
Simplistix open source mailing list...


cheers,

Chris

--
Simplistix - Content Management, Batch Processing & Python Consulting
   - http://www.simplistix.co.uk
--
http://mail.python.org/mailman/listinfo/python-list


Re: Downloading a file form a displayed table

2013-03-05 Thread Dave Angel

On 03/05/2013 04:00 AM, Νίκος Γκρ33κ wrote:


   



for filename in os.walk(path):


But os.walk() doesn't return a filename. It returns a tuple.  Have you 
tested any of this code outside of a server?


Also, you're using tabs here.  They don't show up in most email 
programs, so you're better off replacing them with an appropriate number 
of spaces.  After all, indentation matters.




print '''

print( "  %s  
" ) % filename

'''

sys.exit(0)


--
DaveA

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


Re: Downloading a file form a displayed table

2013-03-05 Thread Νίκος Γκρ33κ
Τη Τρίτη, 5 Μαρτίου 2013 11:45:09 π.μ. UTC+2, ο χρήστης Dave Angel έγραψε:

> It would be useful to actually specifying the context of this fragment 
> 
> of code.  Presumably it's running on a web server somewhere, and you're 
> 
> expecting the filenames to somehow show up on a browser.  Which OS and 
> 
> which version of Python for that server, and what brand and version of 
> 
> browser?
> 
> 
> 
> Have you considered closing the table, and ending the body of the page?

The server run Linux and python version is v2.7 and the browser is Chrome v27

The source appears empty.

Frankly i dont see anythign wrong with my code:

path = "/data/files/"

for filename in os.walk(path):
print '''

  %s  


''' % (filename, filename)

sys.exit(0)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Downloading a file form a displayed table

2013-03-05 Thread Dave Angel

On 03/05/2013 04:48 AM, Νίκος Γκρ33κ wrote:

Τη Τρίτη, 5 Μαρτίου 2013 11:45:09 π.μ. UTC+2, ο χρήστης Dave Angel έγραψε:


It would be useful to actually specifying the context of this fragment

of code.  Presumably it's running on a web server somewhere, and you're

expecting the filenames to somehow show up on a browser.  Which OS and

which version of Python for that server, and what brand and version of

browser?



Have you considered closing the table, and ending the body of the page?


The server run Linux and python version is v2.7 and the browser is Chrome v27

The source appears empty.


In that case, there's something wrong far outside of this code fragment. 
 A web page (html) has lots of required elements which were presumably 
in other parts of the script that are not shown here.





Frankly i dont see anythign wrong with my code:

path = "/data/files/"

for filename in os.walk(path):
print '''

  %s  


''' % (filename, filename)

sys.exit(0)




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


Re: Downloading a file form a displayed table

2013-03-05 Thread Νίκος Γκρ33κ
Τη Τρίτη, 5 Μαρτίου 2013 11:51:41 π.μ. UTC+2, ο χρήστης Dave Angel έγραψε:
> On 03/05/2013 04:00 AM, Νίκος Γκρ33κ wrote:
> 
> >
> 
> >
> 
> 
> 
> > for filename in os.walk(path):
> 
> 
> 
> But os.walk() doesn't return a filename. It returns a tuple.  Have you 
> 
> tested any of this code outside of a server?
> 
> 
> 
> Also, you're using tabs here.  They don't show up in most email 
> 
> programs, so you're better off replacing them with an appropriate number 
> 
> of spaces.  After all, indentation matters.
> 
> 
> 
> 
> 
> > print '''
> 
> > 
> 
> > print( "  %s 
> >  " ) % filename
> 
> > 
> 
> > '''
> 
> > 
> 
> > sys.exit(0)
> 
> >
> 
> -- 
> 
> DaveA

How is this lien supposed to be written do to iterate over a list of filenames?

for filename in list( os.walk(path) ):

i tried the above but still it doesn't work out.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Question on for loop

2013-03-05 Thread Bryan Devaney
On Monday, March 4, 2013 4:37:11 PM UTC, Ian wrote:
> On Mon, Mar 4, 2013 at 7:34 AM, Bryan Devaney  wrote:
> 
> >> if character not in lettersGuessed:
> 
> >>
> 
> >> return True
> 
> >>
> 
> >> return False
> 
> >
> 
> > assuming a function is being used to pass each letter of the letters 
> > guessed inside a loop itself that only continues checking if true is 
> > returned, then that could work.
> 
> >
> 
> > It is however more work than is needed.
> 
> >
> 
> > If you made secretword a list,you could just
> 
> >
> 
> > set(secretword)&set(lettersguessed)
> 
> >
> 
> > and check the result is equal to secretword.
> 
> 
> 
> Check the result is equal to set(secretword), I think you mean.
> 
> 
> 
> set(secretword).issubset(set(lettersguessed))
> 
> 
> 
> might be slightly more efficient, since it would not need to build and
> 
> return an intersection set.
> 
> 
> 
> One might also just do:
> 
> 
> 
> all(letter in lettersguessed for letter in secretword)
> 
> 
> 
> Which will be efficient if lettersguessed is already a set.

You are correct. sorry for the misleading answer, was digging through old shell 
scripts all day yesterday and brain was obviously not not the better for it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Downloading a file form a displayed table

2013-03-05 Thread Lele Gaifax
Νίκος Γκρ33κ  writes:

> How is this lien supposed to be written do to iterate over a list of 
> filenames?
>
> for filename in list( os.walk(path) ):
>
> i tried the above but still it doesn't work out.

Please learn how Python itself can help you:

$ python
Python 2.7.3 (default, Jan  2 2013, 13:56:14) 
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> help(os.walk)
Help on function walk in module os:

walk(top, topdown=True, onerror=None, followlinks=False)
Directory tree generator.
...
Example:

import os
from os.path import join, getsize
for root, dirs, files in os.walk('python/Lib/email'):
   ...

In general, the builtin help() function displays the documentation for
either a single function or a whole module.

ciao, lele.
-- 
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
l...@metapensiero.it  | -- Fortunato Depero, 1929.

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


Re: [Python-ideas] string.format() default variable assignment

2013-03-05 Thread Mark Lawrence

On 05/03/2013 02:54, Chris Angelico wrote:

On Tue, Mar 5, 2013 at 1:42 PM, Steven D'Aprano
 wrote:

It's easy for him to
deal with it, all he has to do is get a goat to eat the garden waste I
toss over the fence, and his problem is solved.


Sounds like someone got Steven's goat.

*dives for cover*

ChrisA



It's unlikely to happen but the UK should bring back the death penalty 
when it gets that bad :)


--
Cheers.

Mark Lawrence

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


Re: book advice

2013-03-05 Thread Bryan Devaney
On Friday, March 1, 2013 8:59:12 PM UTC, leonardo selmi wrote:
> hi
> 
> 
> 
> is there anyone can suggest me a good book to learn python? i read many but 
> there is always something unclear or examples which give me errors.
> 
> how can I start building a sound educational background
> 
> 
> 
> thanks for any help 
> 
> 
> 
> best regards

If you have net access and are learning your first programming language, I'd 
say head on over to one of the free web python courses that include an online 
interpreter. It sorts out a great deal of the 'incompatible version' problems 
people have with offline tutorials. I'm not sure what the policy is in regards 
linking to one so I'll just say Google one.  

Once you've found your feet, I do hear good things about 'learn python the hard 
way' but I've not read it myself. 

Generally once you've covered the foundations and understand the terms, 
Python.org's docs are very good.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Python-ideas] string.format() default variable assignment

2013-03-05 Thread Gene Heskett
On Tuesday 05 March 2013 06:54:14 Mark Lawrence did opine:

> On 05/03/2013 02:54, Chris Angelico wrote:
> > On Tue, Mar 5, 2013 at 1:42 PM, Steven D'Aprano
> > 
> >  wrote:
> >> It's easy for him to
> >> deal with it, all he has to do is get a goat to eat the garden waste
> >> I toss over the fence, and his problem is solved.
> > 
> > Sounds like someone got Steven's goat.
> > 
> > *dives for cover*
> > 
> > ChrisA
> 
> It's unlikely to happen but the UK should bring back the death penalty
> when it gets that bad :)

I think another friend of mine had the most cogent observation when he 
said:

You can't fix stupid, but stupid will eventually get fixed.

Cheers, Gene
-- 
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
My web page:  is up!
My views 

People who are funny and smart and return phone calls get much better
press than people who are just funny and smart.
-- Howard Simons, "The Washington Post"
I was taught to respect my elders, but its getting 
harder and harder to find any...
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: book advice

2013-03-05 Thread fjctlzy
I suggest theses( answers from quora: 
https://www.quora.com/Python-programming-language-1/How-can-I-learn-to-program-in-Python):

The Official Python Tutorial - docs.python.org/tutorial/
"Dive Into Python", by Mark Pilgrim - www.diveintopython.net/
"A Byte of Python" - swaroopch.com/notes/Python
Google's Intro to Python Class (online) - 
code.google.com/edu/languages/google-python-class/
"The New Boston" Programming Python Tutorials - 
youtube.com/user/thenewboston#g/c/EA1FEF17E1E5C0DA
"Building Skills in Python", by Steven F. Lott - 
homepage.mac.com/s_lott/books/python/html/index.html
"Think Python: How to Think Like a Computer Scientist" 
-greenteapress.com/thinkpython/thinkpython.html
"Code Like a Pythonista: Idiomatic Python" - 
python.net/~goodger/projects/pycon/2007/idiomatic/handout.html
OpenCourseWare: MIT 6.00 Introduction to Computer Science and Programming - 
ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-00-introduction-to-computer-science-and-programming-fall-2008/video-lectures
"Learn Python the Hard Way" by Zed Shaw - learnpythonthehardway.com
Practice Questions at PySchools - pyschools.com
Begin Python - beginpython.com
More Tutorials - awaretek.com/tutorials.html
New - Udacity.com has many courses that use Python
LearnStreet Python course: http://www.learnstreet.com/lesso...
For beginners: Codecademy
For beginners: Learn Python Programming Through Examples - Decent package with 
good example set.



发自 Windows 邮件


发件人: Bryan Devaney
发送时间: ‎2013‎年‎3‎月‎5‎日 ‎19‎:‎55
收件人: comp.lang.pyt...@googlegroups.com
抄送: python-list@python.org
主题: Re: book advice


On Friday, March 1, 2013 8:59:12 PM UTC, leonardo selmi wrote:
> hi
> 
> 
> 
> is there anyone can suggest me a good book to learn python? i read many but 
> there is always something unclear or examples which give me errors.
> 
> how can I start building a sound educational background
> 
> 
> 
> thanks for any help 
> 
> 
> 
> best regards

If you have net access and are learning your first programming language, I'd 
say head on over to one of the free web python courses that include an online 
interpreter. It sorts out a great deal of the 'incompatible version' problems 
people have with offline tutorials. I'm not sure what the policy is in regards 
linking to one so I'll just say Google one.  

Once you've found your feet, I do hear good things about 'learn python the hard 
way' but I've not read it myself. 

Generally once you've covered the foundations and understand the terms, 
Python.org's docs are very good.
-- 
http://mail.python.org/mailman/listinfo/python-list-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Downloading a file form a displayed table

2013-03-05 Thread Νίκος Γκρ33κ
Please help me correct thois code, iam tryign ti for hours and i cant seem to 
get it workingit irritates me

path = "/home/nikos/public_html/data/files/"
for filename in os.walk(path):
try:
#find the needed counter for the page URL
cur.execute('''SELECT ID FROM files WHERE URL = %s''', 
(filename,) ) 
data = cur.fetchone()#URL is unique, so should only be 
one

if not data:
#first time for page; primary key is automatic, hit is 
defaulted
cur.execute('''INSERT INTO files (URL, lastvisit) 
VALUES (%s, %s)''', (filename, date) )
cID = cur.lastrowid#get the primary key value 
of the new record 
else:
#found the page, save primary key and use it to issue 
hit UPDATE
cID = data[0]
cur.execute('''UPDATE files SET hits = hits + 1, 
lastvisit = %s WHERE ID = %s''', (date, cID)
except MySQLdb.Error, e:
print ( "Query Error: ", sys.exc_info()[1].excepinfo()[2] )
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Downloading a file form a displayed table

2013-03-05 Thread Joel Goldstick
On Tue, Mar 5, 2013 at 8:01 AM, Νίκος Γκρ33κ  wrote:

> Please help me correct thois code, iam tryign ti for hours and i cant seem
> to get it workingit irritates me
>

There is no question here.  No indication of what isn't working as you
like.  No traceback.

>
> path = "/home/nikos/public_html/data/files/"
> for filename in os.walk(path):
> try:
> #find the needed counter for the page URL
> cur.execute('''SELECT ID FROM files WHERE URL = %s''',
> (filename,) )
> data = cur.fetchone()#URL is unique, so should
> only be one
>
> if not data:
> #first time for page; primary key is automatic,
> hit is defaulted
> cur.execute('''INSERT INTO files (URL, lastvisit)
> VALUES (%s, %s)''', (filename, date) )
> cID = cur.lastrowid#get the primary key
> value of the new record
> else:
> #found the page, save primary key and use it to
> issue hit UPDATE
> cID = data[0]
> cur.execute('''UPDATE files SET hits = hits + 1,
> lastvisit = %s WHERE ID = %s''', (date, cID)
> except MySQLdb.Error, e:
> print ( "Query Error: ", sys.exc_info()[1].excepinfo()[2] )
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
Joel Goldstick
http://joelgoldstick.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Downloading a file form a displayed table

2013-03-05 Thread Mark Lawrence

On 05/03/2013 09:00, Νίκος Γκρ33κ wrote:

# 
=
# display download button for each file and downlaod it on click
# 
=
if form.getvalue('show') == 'files':

print ( " " )
print ( "" )

path = "/data/files/"

for filename in os.walk(path):
print '''

print( "  %s  
" ) % filename

'''

sys.exit(0)



I use the above code to tidplay a filenames table so the user cna download a 
displayed button style lookign file but its not printing anything for me just 
an emptry table

'/data/files' has 5 files in it but its not showing any.
I dont see what iam doign wrong



You're doing at least two things wrong.

1) Not reading documentation
2) Not trying the interactive prompt.
3) Not using the print statement/function.
4) Not taking any notice of what people tell you.
5) Not showing what you expect to happen and what actually happens.
6) You're not doing six wrong.

--
Cheers.

Mark Lawrence

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


Re: Downloading a file form a displayed table

2013-03-05 Thread Νίκος Γκρ33κ
Τη Τρίτη, 5 Μαρτίου 2013 3:38:49 μ.μ. UTC+2, ο χρήστης Vytas D. έγραψε:
> Hi,
> 
> It is really complicated to reproduce the errors you get by running your code 
> since it involves database queries.
> 
> Though one thing that really needs your attention is how you handle the 
> results from os.walk(path).
> 
> 
> Dave Angel told you already that: "But os.walk() doesn't return a filename. 
> It returns a tuple.".
> 
> 
> 
> To show where you are wrong I have create the directory structure:
> 
> Folder "folder1" that has files "file4.txt" and "file3.txt" inside.
> 
> 
> 
> 
> In Python 2.6.5:
> >>> import os
> >>> for filename in os.walk('folder1'):
> ...  print(filename)
> ... 
> ('folder1', [], ['file4.txt', 'file3.txt'])
> 
> >>> 
> 
> 
> So your code is treating results from os.walk() incorrectly. You get tuple, 
> so extract data you need from it first. In case you don't know how:
> 
> 
> Print files only (no directories. Adapt code to your needs):
> 
> >>> for result in os.walk('folder1'):
> ...    for filename in result[2]:
> ...  print(filename)
> ... 
> file4.txt
> file3.txt
> 
> 
> 
> In http://docs.python.org/2/library/os.html you will find:
> 
> os.walk(top, topdown=True, onerror=None, followlinks=False)
> Generate the file names in a directory tree by walking the tree either 
> top-down or bottom-up. For each directory in the tree rooted at directory top 
> (including top itself), it yields a 3-tuple (dirpath, dirnames, filenames).
> 
> ...
> 
> 
> 
> Vytas
> 
> 
> 
> 
> On Tue, Mar 5, 2013 at 1:01 PM, Νίκος Γκρ33κ  wrote:
> 
> Please help me correct thois code, iam tryign ti for hours and i cant seem to 
> get it workingit irritates me
> 
> 
> 
> 
> path = "/home/nikos/public_html/data/files/"
> 
> for filename in os.walk(path):
> 
>         try:
> 
>                 #find the needed counter for the page URL
> 
>                 cur.execute('''SELECT ID FROM files WHERE URL = %s''', 
> (filename,) )
> 
>                 data = cur.fetchone()        #URL is unique, so should only 
> be one
> 
> 
> 
>                 if not data:
> 
>                         #first time for page; primary key is automatic, hit 
> is defaulted
> 
>                         cur.execute('''INSERT INTO files (URL, lastvisit) 
> VALUES (%s, %s)''', (filename, date) )
> 
>                         cID = cur.lastrowid        #get the primary key value 
> of the new record
> 
>                 else:
> 
>                         #found the page, save primary key and use it to issue 
> hit UPDATE
> 
>                         cID = data[0]
> 
>                         cur.execute('''UPDATE files SET hits = hits + 1, 
> lastvisit = %s WHERE ID = %s''', (date, cID)
> 
>         except MySQLdb.Error, e:
> 
>                 print ( "Query Error: ", sys.exc_info()[1].excepinfo()[2] )
> 
> --
> 
> http://mail.python.org/mailman/listinfo/python-list

Yes indeed! the problem was at the way os.walk resulted the data.

one would think that os.walk would return the actual filenames ina  tuple but 
it also returned coupel things more before the file themselevrs.

thank you a lot for poitning this out to me.
-- 
http://mail.python.org/mailman/listinfo/python-list


simple GUI environment

2013-03-05 Thread Eric Johansson
I need a simple GUI toolkits like easygui pythoncard. The main reason I 
discount both of those is that they are effectively dead as I can see. 
Last updates in the 2010/2011 range. Has there been some toolkit to 
replace them? And no, the existing wxpython/gtk/qt/... toolkits really 
aren't acceptable. I need to get something done in 12 hours and I don't 
have time to climb the learning curve.


The application I'm building is a tool which gathers and saves 
configuration data for a specific Windows application. It needs to run 
in a Windows batch file for multisystem deployment and also as a GUI 
when the user is mucking about. It also needs to run as a portable app 
because I can't install this on every machine. many corporate IT types 
don't take kindly to utilities leaving little footprints all over the place.


The CLI version works. Simple UI, does what I need for part of the job. 
Now I need to add a relatively simple GUI. The user interface will 
consist of a series of tabs across the top, one for each subsystem and 
the main panel beneath that will contain the UI for the tab related 
task. I could fake the tabs by using a horizontal list of radio buttons 
which have the same semantics as tabs but a very different look.


I could do this relatively easily with twitter bootstrap but I don't 
have a standalone browser that I can embed in Python so I could build 
HTML for user interface.


suggestions?

I appreciate whatever help you can give.
--
http://mail.python.org/mailman/listinfo/python-list


Re: simple GUI environment

2013-03-05 Thread Kevin Walzer

On 3/5/13 9:20 AM, Eric Johansson wrote:

The main reason I discount both of those is that they are effectively
dead as I can see. Last updates in the 2010/2011 range.


Why not give EasyGUI a try? The site is still active, and two years 
isn't without an update doesn't mean a project is dead, especially if 
it's a simple and mature project that doesn't need a lot of maintenance. 
If your needs are basic, then I'd say EasyGUI would be a good fit. By 
contrast, a library undergoing heavy development with a 
constantly-shifting API can cause tons of headaches.


--Kevin

--
Kevin Walzer
Code by Kevin/Mobile Code by Kevin
http://www.codebykevin.com
http://www.wtmobilesoftware.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: simple GUI environment

2013-03-05 Thread Tim Golden
On 05/03/2013 14:55, Kevin Walzer wrote:
> On 3/5/13 9:20 AM, Eric Johansson wrote:
>> The main reason I discount both of those is that they are effectively
>> dead as I can see. Last updates in the 2010/2011 range.
> 
> Why not give EasyGUI a try? 

or PyGUI:

  http://www.cosc.canterbury.ac.nz/greg.ewing/python_gui/


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


Recursive function

2013-03-05 Thread Ana Dionísio
Hello!

I have to make a script that calculates temperature, but one of the
parameters is the temperature in the iteration before, for example:
temp = (temp_-1)+1

it = 0
temp = 3

it = 1
temp = 3+1

it = 2
temp = 4+1

How can I do this in a simple way?

Thanks a lot!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: simple GUI environment

2013-03-05 Thread Vlastimil Brom
2013/3/5 Eric Johansson :
> I need a simple GUI toolkits like easygui pythoncard. The main reason I
> discount both of those is that they are effectively dead as I can see. Last
> updates in the 2010/2011 range. Has there been some toolkit to replace them?
> And no, the existing wxpython/gtk/qt/... toolkits really aren't acceptable.
> I need to get something done in 12 hours and I don't have time to climb the
> learning curve.
...
>
> The CLI version works. Simple UI, does what I need for part of the job. Now
> I need to add a relatively simple GUI. The user interface will consist of a
> series of tabs across the top, one for each subsystem and the main panel
> beneath that will contain the UI for the tab related task. I could fake the
> tabs by using a horizontal list of radio buttons which have the same
> semantics as tabs but a very different look.
>
...
>
> suggestions?
>
> I appreciate whatever help you can give.
> --
> http://mail.python.org/mailman/listinfo/python-list

Hi,
I usually use wxpython for my GUI-needs, but given the considerations
you mention, I'd check, whether the builtin tkinter and ttk might be
appropriate for this task.
I would somehow expect the least portability problems with this gui toolkit.
There is a Notebook widget in ttk:
http://docs.python.org/3.3/library/tkinter.ttk.html#tkinter.ttk.Notebook
or
http://docs.python.org/2/library/ttk.html#ttk.Notebook
for python 2.7

tkinter/ttk can be quite capable and (with some care) nice-looking too;
see, e.g.:

http://code.google.com/p/python-ttk/wiki/Screenshots

hth,
  vbr
-- 
http://mail.python.org/mailman/listinfo/python-list


Psychopath Jack Wesolowski takes another spam dump on the UseNet (was: Gary Sokolich - 3463)

2013-03-05 Thread Mamma Wesolowski
Psychopath Jack Wesolowski trolling and spamming the UseNet as Gary 
Sokolisch  wrote in
news:tv04oi1c11wu.1gv33jqjim98d$.d...@40tude.net: 

> 3463
> 
> W Gary Sokolich
> 801 Kings Road
> Newport Beach, CA 92663-5715
> (949) 650-5379
> Local PD
> 949-644-3681 
> 
> Residence:
> 1029 S Point View St
> Los Angeles CA 90035
> (310) 650-5379
> 
> and
> 5309 Victoria Ave., Los Angeles, CA, 90043
> 
> 
> 
> 
> http://web.archive.org/web/20080821231423/http://www.tbpe.state.tx.us/d
> a/da022808.htm 
> 
> TEXAS BOARD OF PROFESSIONAL ENGINEERS
> February 28, 2008 Board Meeting Disciplinary Actions 
> 
>  W. Gary Sokolich , Newport Beach, California ¡V File B-29812 - It was
> alleged that. Sokolich unlawfully offered or attempted to practice 
> engineering in Texas (...)  Sokolich chose to end the proceedings by  
> signing a Consent Order that was accepted by the Board to cease and
> desist from representing himself as an ¡§Engineer¡¨ in Texas, from any
> and all representations that he can offer or perform engineering
> services and from the actual practice of engineering in Texas (...) 
> Sokolich was also assessed a $1,360.00 administrative penalty.
> 
> ___
> 
> http://articles.latimes.com/1988-04-14/local/me-1922_1_ucla-researcher
> 
> A former UCLA employee has agreed to provide copies of his research to
> the school to settle a lawsuit the university filed against him in
> 1985, lawyers in the case said.
> 
> (...)
> 
> The University of California Board of Regents filed a $620,000 lawsuit
> against Sokolich, accusing him of taking research on the hearing 
> capabilities of animals in June, 1982. Sokolich was dismissed by UCLA 
> (...).
> 
> (...)
> 



That's my boy Jack Wesolowski, a 68-year old,  mentally-ill ,
retired  SSD worker, foul-mouthed  bigot, racist, liar, spammer and
troll who has been spamming the UseNet as Gary Sokolisch since
January of 2011.

A  recent ode to psychopath Jack Wesolowski, from rec.sport.boxing
http://groups.google.com/group/rec.sport.boxing/msg/336baad3954b6f51?...
http://tinyurl.com/7ldhq3b

"Way Back Jack, his mother licks my crack,
Then she sucks my dick until it's yellah.
An' his mother-fuckin' fathah doesn't so much as bother
To use some spittle when he's bung-holin' little
Boys, before they're rollin' in the shower, their 'nads all a'
swollen,
While our perverted faggot Jack laps up all their bloody turds.
He's a real low-life fellah, whose perversion escapes mere words

And one from alt.native, May 4, 2002.
http://groups.google.com/group/alt.native/msg/0f12476019613f13?dmode=...
http://tinyurl.com/6ugweze

Brother Jack is a racist bigot
His mouth is a toxic old spigot
He spews out his hate
He never can wait
To find some more dolts who will dig it!

We know a white jerk named Jack
Who really wants to be black
He calls himself "brother"
Wears clothes from his mother(*)
The truth is he's just a hack

We see his rantings as racist bile
His words typically ugly and vile
The master of hate
Thank God he won't mate
Let us leave him alone for awhile

(*)
Jack Wesolowski, circa 2000
http://tinyurl.com/3dtnmpz

Meet Psychopath Jack Wesolowski, the crass, foul-mouthed, bigot,
racist, liar, spammer and troll.

Jack Wesolowski the spammer
http://tinyurl.com/3o7su5k

Jack Wesolowski the troll.
http://tinyurl.com/6ynlegl
http://tinyurl.com/5vljxag
http://tinyurl.com/3nukkeo

Jack Wesolowsk the liar.
http://tinyurl.com/6hr3lmq
http://tinyurl.com/44x4ceg

Jack Wesolowski the bigot.
http://tinyurl.com/3n5z48d
http://tinyurl.com/3h2sc48

Jack Wesolowski the racist.
http://tinyurl.com/3m3vhjb
http://tinyurl.com/3qoolnh
http://tinyurl.com/3j8gnfm
http://tinyurl.com/3c97kg7

Jack Wesolowski, aka
Bob Cain (resurrected)
joe momma
farting boar
diane roselles
dr jackal
Repeal Obama
Mothzer Roselles
Xavier
Amber Travsky
Vladimir Tschenko Badenovsky
Off the moonbat
A liberal's worst nightmare
Swatting Moonbatz
Ruth Chilton
That  Sleazy Cunt Piglosi
Obama Nation is Abomination
ObamaNation=Abomination
Let it Rock
Nobama
Repeal Obama
Mother Roselles
Swatting Moonbatz
Amber Travsky
Gary Sokolisch
Weary Bruiser 1 reti...@home.net
Vladimir Badenovsky
Mike Gibson's Ghost
Gary Sokolosch
Gary Sakolich
THE REAL GARY
GARY IN ANIMAL RESEARCH
GARY THE "ENGINEER"
Calhoun
Bobby Fuller
Calhoon
Jack (windswept@home.)
JackW (windswept@home)
Windswept@home. (jack)
BroJack
Bro Jack
brojac...@my-deja.com
waybackjack
way back jack
jackweso
JackWesolowski
jackw...@email.msn.com (brojac...@my-deja.com)
Jack Wesolowski (wesolow...@freewwweb.com)
broj...@windswept.net (BroJack)
Windswept@Home (Jack W)
jackw...@email.msn.com (brojac...@my-deja.com)
Jack from wyBack

John F Wesolowski
3045 Old Washington Rd
Westminster, MD 21157
(410) 876-6914
http://tinyurl.com/6cv8t2e


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


Re: Recursive function

2013-03-05 Thread Dave Angel

On 03/05/2013 10:32 AM, Ana Dionísio wrote:

Hello!

I have to make a script that calculates temperature, but one of the
parameters is the temperature in the iteration before, for example:
temp = (temp_-1)+1

it = 0
temp = 3

it = 1
temp = 3+1

it = 2
temp = 4+1

How can I do this in a simple way?

Thanks a lot!



Recursion only works when you have a termination condition.  Otherwise, 
it just loops endlessly (or more specifically until the stack runs out 
of room).  Still, you don't have a problem that even implies recursion, 
just iteration.


For your simple case, there's a simple formula:

def  find_temp(it):
return it+3

Methinks you have simplified the problem too far to make any sense.

import itertools
temp = 3
for it in itertools.count():
temp += 1
print it, temp

Warning:  that loop will never terminate.

Is this what you were looking for?  It uses recursion, and I used <=0 
for the termination condition.


def find_temp2(it):
if it <=0:  return 3
return find_temp(it-1)


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


Re: Recursive function

2013-03-05 Thread Vlastimil Brom
2013/3/5 Ana Dionísio :
> Hello!
>
> I have to make a script that calculates temperature, but one of the
> parameters is the temperature in the iteration before, for example:
> temp = (temp_-1)+1
>
> it = 0
> temp = 3
>
> it = 1
> temp = 3+1
>
> it = 2
> temp = 4+1
>
> How can I do this in a simple way?
>
> Thanks a lot!
> --
> http://mail.python.org/mailman/listinfo/python-list

Hi,
it is not quite clear from the examples, what should be achieved (I
guess, the actual computation is probably mor complex).
I'd probably approach an iterative computation iteratively, rather
than recursively;
e.g. simply:

def compute_iteratively(starting_value, number_of_iterations):
tmp = starting_value
for i in range(number_of_iterations):
tmp = tmp + 1
return tmp

print(compute_iteratively(starting_value=7, number_of_iterations=3))

hth,
 vbr
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Recursive function

2013-03-05 Thread Ana Dionísio
Yes, I simplified it a lot.

I need to run it 24 times. What I don't really understand is how to put the 
final temperature (result) in it = 0 in temp_-1 in it =1
-- 
http://mail.python.org/mailman/listinfo/python-list


comment récupérer les valeurs de canvas dans python

2013-03-05 Thread olsr . kamal
comment récupérer la couleur d'un canvas ou id d'un canvas?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Inserting-embedding some html data at the end of a .py file

2013-03-05 Thread Νίκος Γκρ33κ
Any ideas on hopw to embed some html data at the end of each python script?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Inserting-embedding some html data at the end of a .py file

2013-03-05 Thread Mark Lawrence

On 05/03/2013 17:11, Νίκος Γκρ33κ wrote:

Any ideas on hopw to embed some html data at the end of each python script?



Write some code.

--
Cheers.

Mark Lawrence

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


Re: Embedding a for inside an html template for substitution

2013-03-05 Thread Roland Koebler
Hi,

On Mon, Mar 04, 2013 at 09:22:38AM -0800, Ferrous Cranus wrote:
> can i just put the liens you provided me inside "files.html" and thwy
> will work?
> 
> Thats pure pythjon code!
There are several template-engines where you more or less include
python-code into the template, e.g.: empy, mako, pyratemp

On Mon, Mar 04, 2013 at 08:56:14PM -0700, Michael Torrie wrote:
> Check out that link in my previous e-mail to a list of python templating
> engines.  Choose one and try it.  No I cannot provide any example code.
Here's an example for pyratemp (where I'm the author ;)):

files.html:


@!title!@

@!e!@



files.py:

import pyratemp
t = pyratemp.Template(filename="files.html")
result = t(title="title ...", mylist=["entry 1", "entry 2", "entry 3"])
print result.encode("ascii", 'xmlcharrefreplace')


On Mon, Mar 04, 2013 at 08:56:14PM -0700, Michael Torrie wrote:
> I do recommend you at least take a look at Django.  It may be overkill
> for your needs.  It does contain a templating engine,
Last time I tried, the template-engine of Django did not work on its
own. If you need Django-like templates without Django, you can use Jinja.
And if you need a real sandbox (so that you can use untrusted templates),
I would recommend Jinja.


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


Re: Inserting-embedding some html data at the end of a .py file

2013-03-05 Thread Joel Goldstick
On Tue, Mar 5, 2013 at 12:19 PM, Mark Lawrence wrote:

> On 05/03/2013 17:11, Νίκος Γκρ33κ wrote:
>
>> Any ideas on hopw to embed some html data at the end of each python
>> script?
>>
>
http://redwing.hutman.net/~mreed/warriorshtm/ferouscranus.htm

>
>>
> Write some code.
>
> --
> Cheers.
>
> Mark Lawrence
>
> --
> http://mail.python.org/**mailman/listinfo/python-list
>



-- 
Joel Goldstick
http://joelgoldstick.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: simple GUI environment

2013-03-05 Thread Eric Johansson

On 3/5/2013 10:06 AM, Tim Golden wrote:

On 05/03/2013 14:55, Kevin Walzer wrote:

On 3/5/13 9:20 AM, Eric Johansson wrote:

The main reason I discount both of those is that they are effectively
dead as I can see. Last updates in the 2010/2011 range.

Why not give EasyGUI a try?

or PyGUI:

   http://www.cosc.canterbury.ac.nz/greg.ewing/python_gui/



you guys are great. I'm going to try pygui first and easygui second. My 
reason  for this is that pygui looks like it will let me bundle using 
py2exe without trying hard.the only thing that would make it better is 
if either of these kits used standard Rich text edit controls under 
Windows so I can speech enable these applications.


Thanks a bunch. All the advice was really useful and appreciated.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Inserting-embedding some html data at the end of a .py file

2013-03-05 Thread Joel Goldstick
On Tue, Mar 5, 2013 at 12:39 PM, Νίκος Γκρ33κ  wrote:

> But i did, I just tried this:
>
> # open html template
> if htmlpage.endswith('.html'):
> f = open( "/home/nikos/public_html/" + htmlpage )
>
> htmldata = f.read()
> counter =   '''   
>  cellpadding=2 bgcolor=black>
>  color=lime>Αριθμός Επισκεπτών
> http://superhost.gr/?show=stats";> %d 
> ''' % data[0]
> else:
> f = open( "/home/nikos/public_html/cgi-bin/" + htmlpage )
>
> htmldata = f.read()
> counter =   '''
> print '''  
>  cellpadding=2 bgcolor=black>
>  color=lime>Αριθμός Επισκεπτών
> http://superhost.gr/?show=stats";> %d 
> '''
>

remove the extra triple quote.  But seriously, in 2013 you are writing html
like the above?  That is some awful stuff

> ''' % data[0]
>
> template = htmldata + counter
> print ( template )
> =
>
> But still doens't embed correctly the additional html data at the end of
> the .py files.
>
> Do you have an idea?
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
Joel Goldstick
http://joelgoldstick.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Inserting-embedding some html data at the end of a .py file

2013-03-05 Thread Νίκος Γκρ33κ
What extra triple quote?
There are 2 sets of triple quotes the counter's and the print's !!

in case htmlpage variable is a .py file i must append a print '''html''' in 
order for .py code to absorve that code properly no?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Inserting-embedding some html data at the end of a .py file

2013-03-05 Thread Mark Lawrence

On 05/03/2013 17:39, Νίκος Γκρ33κ wrote:

But i did, I just tried this:

# open html template
if htmlpage.endswith('.html'):
f = open( "/home/nikos/public_html/" + htmlpage )

htmldata = f.read()
counter =   ''' mailto:supp...@superhost.gr";>  

Αριθμός 
Επισκεπτών
http://superhost.gr/?show=stats";> %d 
''' % data[0]
else:
f = open( "/home/nikos/public_html/cgi-bin/" + htmlpage )

htmldata = f.read()
counter =   '''
print '''mailto:supp...@superhost.gr";> 
 

Αριθμός 
Επισκεπτών
http://superhost.gr/?show=stats";> %d 
'''
''' % data[0]   

template = htmldata + counter
print ( template )
=

But still doens't embed correctly the additional html data at the end of the 
.py files.

Do you have an idea?



You're doing something wrong.

--
Cheers.

Mark Lawrence

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


collaborative editing environments

2013-03-05 Thread Eric Johansson
I finally have an intern helping me with my various accessibility 
projects. We need to do pair programming so he can write the code in my 
head that I can't express by broken hand or speech recognition (yet).


The best technique with come up with so far is to use putty sessions 
with the same layout and use dtach into one emacs.  Nonideal but it kind 
of sort of works after fashion. we are constrained that neither of us 
will poke holes in our firewalls to allow a peer-to-peer system to work 
so we will need a third system intermediary.  What would be ideal is 
some sort of cloud-based collaborative editor/IDE with local storage 
capability. Revision control to be handled individually to a common 
repository outside of the IDE/editor.


Super best would be an IDE with an API so I can drive the IDE from 
speech recognition but, I know I'm living in a fantasyland any time I 
look for accessibility.  at the hands one of our projects being adding 
accessibility controls to an existing editor. Haven't decided which one 
yet but the leading contender is sublime.


gobby it's kind of useful but again,  it requires firewall holes or in 
intermediary that appears to have several shortcomings.also, according 
to folks I met on IRC, the developers disappeared from IRC about 18 
months ago and there's been no development  on the project since then.


so, what have your experiences been with collaborative environments?
--
http://mail.python.org/mailman/listinfo/python-list


Re: Inserting-embedding some html data at the end of a .py file

2013-03-05 Thread Dave Angel

On 03/05/2013 12:49 PM, Νίκος Γκρ33κ wrote:

What extra triple quote?
There are 2 sets of triple quotes the counter's and the print's !!


There are 3 pairs of triple-quotes.  But one pair is nested inside the 
other, so the interpreter will not handle it the way you apparently 
want.  If you have to use quotes inside quotes, you must either use a 
different kind, or escape them.  Perhaps you wanted something like:


 counter = """
  print '''  etc
font ...
  '''
  """ % data[0]

But this fragment is unreadable to me, so the syntax error is probably 
the least of your worries.




in case htmlpage variable is a .py file i must append a print '''html''' in 
order for .py code to absorve that code properly no?



No clue what that sentence fragment means.

'absorve' isn't an English word, and neither 'absorb' nor 'observe' make 
any sense.


Perhaps if you posted a complete program, and identified it by name, and 
specified the complete environment it runs in, and used English to 
describe what should be appended to what, we'd be able to help.  As it 
is, you've got mixed clues from which that it's both Python 2 and 3, 
running Linux or equivalent, and probably runs on a server.


Using symbol names that make sense would also help.  'htmlpage' is 
apparently a str representing a filename on disk.  'counter' is not an 
integer, but a long string of html.   'data' is apparently a tuple or 
list, and the zeroth element is an int. ??


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


Re: collaborative editing environments

2013-03-05 Thread Dave Angel

On 03/05/2013 12:56 PM, Eric Johansson wrote:

I finally have an intern helping me with my various accessibility
projects. We need to do pair programming so he can write the code in my
head that I can't express by broken hand or speech recognition (yet).

The best technique with come up with so far is to use putty sessions
with the same layout and use dtach into one emacs.



Nonideal but it kind

of sort of works after fashion. we are constrained that neither of us
will poke holes in our firewalls to allow a peer-to-peer system to work
so we will need a third system intermediary.


Call that intermediary the "host" machine.

If host is running on a Linux box, you could run 'screen' or one of its 
variants (such as tmux).  Screen lets you have multiple consoles run 
through one ssh session, and presents them on your remote as one 
console.  Keystrokes let you switch which console you're connected to at 
the moment.  And another user can be given permissions to see exactly 
the same screen session.  So you can chat on one console, and emacs on 
another, all within the same screen.  Naturally, you can run multiple 
screens, on independent ssh sessions, if that suits you better.


No experience accessing it from Windows, but putty will probably do it.

I've done remote collaboration this way, while using a satellite 
connection that's hopeless for gui environments.




You might also want to check out synergy, which manages remote keyboard, 
mouse and clipboard for Linux.


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


Re: collaborative editing environments

2013-03-05 Thread Eric Johansson

On 3/5/2013 1:38 PM, Dave Angel wrote:

On 03/05/2013 12:56 PM, Eric Johansson wrote:

I finally have an intern helping me with my various accessibility
projects. We need to do pair programming so he can write the code in my
head that I can't express by broken hand or speech recognition (yet).

The best technique with come up with so far is to use putty sessions
with the same layout and use dtach into one emacs.



Nonideal but it kind

of sort of works after fashion. we are constrained that neither of us
will poke holes in our firewalls to allow a peer-to-peer system to work
so we will need a third system intermediary.


Call that intermediary the "host" machine.


I prefer to think of it as a proxy or relay host. :-) In my perfect 
world, it would host no data, only relay traffic between a group of users.


If host is running on a Linux box, you could run 'screen' or one of 
its variants (such as tmux).  Screen lets you have multiple consoles 
run through one ssh session, and presents them on your remote as one 
console.  Keystrokes let you switch which console you're connected to 
at the moment.  And another user can be given permissions to see 
exactly the same screen session.  So you can chat on one console, and 
emacs on another, all within the same screen.  Naturally, you can run 
multiple screens, on independent ssh sessions, if that suits you better.


Been there, done that and I will tell you that if you are see using 
speech recognition, it's the fourth closest definition to hell I can 
possibly think of. in band keystrokes always get in the way because some 
application makes use of them. If they are sufficiently secure to not 
interfere, then they are bitch to remember. ideally, there would be an 
out of band API that I could drive from my speech recognition command 
extension environment and control the connection multiplexer.


This is another reason for a local editor, it's easier to speech enable 
when the environment is nearby.


I will thank you for this because you reminded me that team viewer 
didn't suck too bad and my intern could be the one with the live editor 
and I'm just watching and commenting over Skype


No experience accessing it from Windows, but putty will probably do it.


it could.

I've done remote collaboration this way, while using a satellite 
connection that's hopeless for gui environments.


fortunately, I'm only going as far as Estonia which is reasonably well 
connected


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


Re: Inserting-embedding some html data at the end of a .py file

2013-03-05 Thread Νίκος Γκρ33κ
Let's focus on just the following snipper please:

f = open( some_python_file )

htmldata = f.read()
counter = ''' print( "
  mailto:supp...@superhost.gr";> 
 
  
  Αριθμός 
Επισκεπτών
  http://superhost.gr/?show=stats";> %d 
  " )
  ''' % data[0] 

#render template
template = htmldata + counter
print ( template )
=

What this snippet tries to accomplish is append the following string

=
counter = ''' mailto:supp...@superhost.gr";> 
 
  
  Αριθμός 
Επισκεπτών
  http://superhost.gr/?show=stats";> %d 
  ''' % data[0
=

at the end of the the python script file that it currently opened.
I'am using the print statemnt inside the triple quoted string so to append that 
html data by inserting a print statemnt but although i have changes the type of 
quoting it still fails.

If i try to append that html data to an .html file they are inserted 
beautifully but inside a .py file they dont.

I just need to append that string after the end of a .py file. that's all i 
want to do.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Recursive function

2013-03-05 Thread Neil Cerutti
On 2013-03-05, Ana Dion?sio  wrote:
> Yes, I simplified it a lot.
>
> I need to run it 24 times. What I don't really understand is
> how to put the final temperature (result) in it = 0 in temp_-1
> in it =1

One way to compose a function that recurses by calling itself is
to first write the simplest version of the function you can think
of, the version that solves the most trivial form for the
problem.

For example, lets say I want to write a recursive function to
reverse a string (you would never do this except as an exercise),
I'd first write a version that can successfully reverse an empty
string.

def reverse0(s):
  if len(s) == 0:
return s 

The next most complex problem is a string with one character.
I'll write that next. They key is to write it in terms of the
function I already wrote, reverse0.

def reverse1(s):
  if len(s) == 1:
return s + reverse0('')

At this point it becomes clear that reverse0 is not needed. I'll
just use a new version of reverse1 instead:

def reverse1(s):
  if len(s) <= 1:
return s

The next vesion will be able to handle two characters. I'll write
it to use my previously composed reverse1 function.

def reverse2(s):
  if len(s) == 2:
return s[-1] + reverse1(s[:-1])

And so on:

def reverse3(s):
  if len(s) == 3:
return s[-1] + reverse2(s[:-1])

def reverse4(s):
  if len(s) == 4:
return s[-1] + reverse3(s[:-1])

By this time a pattern has emerged; every version of reverse
after reverse1 is exactly the same. I can now write my recursive
reverse function.

def reverse_any(s):
  if len(s) <= 1:
return s
  else:
return s[-1] + reverse_any(s[:-1])

Try this exercise with your conversion problem and see if you can
make progress.

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


Re: Inserting-embedding some html data at the end of a .py file

2013-03-05 Thread Joel Goldstick
On Tue, Mar 5, 2013 at 1:53 PM, Νίκος Γκρ33κ  wrote:

> Let's focus on just the following snipper please:
>
> f = open( some_python_file )
>
> htmldata = f.read()
> counter = ''' print( "
>   mailto:supp...@superhost.gr";>
>  
>bgcolor=black>
>   Αριθμός
> Επισκεπτών
>   http://superhost.gr/?show=stats";> %d 
>   " )
>   ''' % data[0]
>
> #render template
> template = htmldata + counter
> print ( template )
> =
>
> What this snippet tries to accomplish is append the following string
>
> =
> counter = ''' mailto:supp...@superhost.gr";>
>  
>bgcolor=black>
>   Αριθμός
> Επισκεπτών
>   http://superhost.gr/?show=stats";> %d 
>   ''' % data[0
> =
>
> at the end of the the python script file that it currently opened.
> I'am using the print statemnt inside the triple quoted string so to append
> that html data by inserting a print statemnt but although i have changes
> the type of quoting it still fails.
>
> If i try to append that html data to an .html file they are inserted
> beautifully but inside a .py file they dont.
>
> I just need to append that string after the end of a .py file. that's all
> i want to do.
> --
> http://mail.python.org/mailman/listinfo/python-list
>

print displays to the console.  To write to a file open file in 'append'
mode and write:

with open("test.py", "a") as myfile:
myfile.write("appended text")



-- 
Joel Goldstick
http://joelgoldstick.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Inserting-embedding some html data at the end of a .py file

2013-03-05 Thread Dave Angel

On 03/05/2013 01:53 PM, Νίκος Γκρ33κ wrote:

Let's focus on just the following snipper please:


Once again, I repeat.  Make a fragment that contains enough information 
to actually run.  Explain in what environment it's running, and what you 
hoped would happen.  For example, why on earth would you assume that 
printing to the console below would write to a file instead?  Is some 
part of this running as a cgi inside a web server?  What is your 
environment?


f = open( some_python_file )

htmldata = f.read()
counter = ''' print( "


Syntax error here.  Since the inner string is more than one line, you 
will need to use """.   See my example last message.  This only matters 
if you succeed in writing this to a python file.



  mailto:supp...@superhost.gr";>  
  
  Αριθμός 
Επισκεπτών
  http://superhost.gr/?show=stats";> %d 
  " )
  ''' % data[0] 

#render template
template = htmldata + counter
print ( template )


Why should print write to some python file you have open??  Besides you 
have the file open for readonly access.  So you might use:


f.close()
f = open( some_python_file, "w" )
f.write(template)
f.close()



=

What this snippet tries to accomplish is append the following string

=
counter = ''' mailto:supp...@superhost.gr";>  
  
  Αριθμός 
Επισκεπτών
  http://superhost.gr/?show=stats";> %d 
  ''' % data[0
=

at the end of the the python script file that it currently opened.


But that's not at all what's inside the counter variable.


I'am using the print statemnt inside the triple quoted string so to append that 
html data by inserting a print statemnt but although i have changes the type of 
quoting it still fails.


Don't ever say "it fails".  If you can't be bothered to explain in what 
way it fails, forget it.  Perhaps you're trying to say it prints a 
string to the console instead of writing a different string to the

 /fullpath/to/some_python_file.py

Or perhaps you're saying it crashed the Windows machine, and killed 
power for miles around.  Or perhaps you're saying it got an exception 
but we won't bother telling you which.





If i try to append that html data to an .html file they are inserted beautifully


Untrue, unless your environment is specified, it certainly did not. 
perhaps you were running the program with output redirected to a file, 
in which case it lost the earlier version.  Or perhaps you were running 
it on a web server, and you *think* some file changed because some 
obscure thing happened on your browser.  What's your environment?



 but inside a .py file they dont.

I just need to append that string after the end of a .py file. that's all i 
want to do.



Easy to do in emacs.


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


Re: Inserting-embedding some html data at the end of a .py file

2013-03-05 Thread Νίκος Γκρ33κ
#open html template
if htmlpage.endswith('.html'):
f = open( "/home/nikos/public_html/" + htmlpage )

htmldata = f.read()
counter = ''' mailto:supp...@superhost.gr";> 
 
  
  Αριθμός 
Επισκεπτών
  http://superhost.gr/?show=stats";> %d 
  ''' % data[0]

#render template
template = htmldata + counter
print ( template )

Yes the aboev code does work if we talk about appending html data to an already 
html file!

But if the file is some_python.py file then i cannot just append the data.
Actually by appending i dont want to actually insert the data to the end of the 
.py file, thus altering it but instead run the .py file and print the counter 
html data afterwards!
-- 
http://mail.python.org/mailman/listinfo/python-list


Config & ConfigParser

2013-03-05 Thread Chuck
I'm curious about using configuration files.  Can someone tell me how they are 
used?   I'm writing a podcast catcher and would like to set up some default 
configurations, e.g. directory, etcOther than default directory, what are 
some of the things that are put in a configuration file?   They don't seem to 
teach you this kind of stuff in school.  :(

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


Controlling number of zeros of exponent in scientific notation

2013-03-05 Thread faraz
Instead of:

1.8e-04

I need:

1.8e-004

So two zeros before the 4, instead of the default 1.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Controlling number of zeros of exponent in scientific notation

2013-03-05 Thread Dave Angel

On 03/05/2013 03:09 PM, fa...@squashclub.org wrote:

Instead of:

1.8e-04

I need:

1.8e-004

So two zeros before the 4, instead of the default 1.



You could insert a zero two characters before the end,

num = "1.8e-04"
num = num[:-2] + "0" + num[-2:]

But to get closer to your problem, could you give some background?  What 
version of Python, what type is this "number" before you convert it to a 
string, how are you converting it?


If the type supports variable precision, then what precision range are 
you interested in supporting?


A sample program that produces the wrong output, but going through all 
the appropriate steps would be useful.  Show what values you start with, 
how they get converted, and what you'd like to happen.  What do you want 
to happen if the number is  actually1.8e-178 ?  How about  1.8e-1488 ?




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


Re: Inserting-embedding some html data at the end of a .py file

2013-03-05 Thread Dave Angel

On 03/05/2013 03:04 PM, Νίκος Γκρ33κ wrote:

#open html template
if htmlpage.endswith('.html'):
f = open( "/home/nikos/public_html/" + htmlpage )

htmldata = f.read()
counter = ''' mailto:supp...@superhost.gr";>  
  
  Αριθμός 
Επισκεπτών
  http://superhost.gr/?show=stats";> %d 
  ''' % data[0]

#render template
template = htmldata + counter
print ( template )

Yes the aboev code does work if we talk about appending html data to an already 
html file!

But if the file is some_python.py file then i cannot just append the data.
Actually by appending i dont want to actually insert the data to the end of the 
.py file, thus altering it but instead run the .py file and print the counter 
html data afterwards!



In other words, you're just trying to waste our time.  Thanks for 
telling us.


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


Re: Config & ConfigParser

2013-03-05 Thread Tim Chase
On 2013-03-05 12:09, Chuck wrote:
> I'm curious about using configuration files.  Can someone tell me
> how they are used?   I'm writing a podcast catcher and would like
> to set up some default configurations, e.g. directory, etcOther
> than default directory, what are some of the things that are put in
> a configuration file? 

Just looking at my hpodder config file, you can have all sorts of
things in here.  You might have a root folder, but then each feed
could be configured to a particular sub-folder.  You might have a
cache location you download to, and only move them to the final
destination after they've downloaded completely.  You might have
some check more frequently than others. You might have it execute an
external utility (such as id3v2) to transform various ID3 information
based on information in the feed. If you're downloading in multiple
threads, you might have specify the number of threads it can use.  If
you are using "curl" under the covers, you might limit the
transfer-rate so it doesn't suck up your bandwidth.  If you display
anything, you might allow for suppressing the display, formatting
that display, or controlling whether it uses color.  If you track
download errors, you might specify how many failures constitute a
"don't bother retrying this item" or how many days/hours you need to
wait until you actually retry.

You can even have it act as your data-store for holding the URLs to
the RSS feeds, perhaps a readable name (to override what's in the
feed), along with formatting.  So a more complex .ini might look
something like

  [general]
  root=/home/chuck/Music/Podcasts
  cache=/tmp/podchuck
  threads=4
  rate=50k
  color=auto

  [feed "http://feeds.5by5.tv/webahead";]
  display-name=The Web Ahead"
  location=%(root)s/WebAhead/$FILENAME
  transform=id3v2 -a "WebAhead" -t "$EPTITLE" "$FILENAME"

  [feed "http://www.radiolab.org/feeds/podcast";]
  location=/path/to/someplace/else/$FILENAME
  transform=id3v2 -a "Radio Lab" -t "$EPTITLE" "$FILENAME"

-tkc




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


Re: Inserting-embedding some html data at the end of a .py file

2013-03-05 Thread Michael Ross
On Tue, 05 Mar 2013 21:04:59 +0100, Νίκος Γκρ33κ   
wrote:



#open html template
if htmlpage.endswith('.html'):
f = open( "/home/nikos/public_html/" + htmlpage )

htmldata = f.read()
		counter = ''' mailto:supp...@superhost.gr";> src="/data/images/mail.png"> 

  
  Αριθμός 
Επισκεπτών
	  http://superhost.gr/?show=stats";>  
%d 

  ''' % data[0]

#render template
template = htmldata + counter
print ( template )

Yes the aboev code does work if we talk about appending html data to an  
already html file!


But if the file is some_python.py file then i cannot just append the  
data.
Actually by appending i dont want to actually insert the data to the end  
of the .py file, thus altering it but instead run the .py file and print  
the counter html data afterwards!



subprocess.checkoutput() ?

if htmlpage.endswith('.py'):
htmldata=subprocess.check_output(...)
counter=...
template=htmldata+counter

http://docs.python.org/2/library/subprocess.html?highlight=check_output#subprocess.check_output




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


Re: Inserting-embedding some html data at the end of a .py file

2013-03-05 Thread Νίκος Γκρ33κ
Τη Τρίτη, 5 Μαρτίου 2013 11:02:18 μ.μ. UTC+2, ο χρήστης Dave Angel έγραψε:

> In other words, you're just trying to waste our time.  Thanks for 
> 
> telling us.

Honestly, its not in my intentions to waste your time.
I appreciate all the great help you have provided me in all of my questions, i 
really do.

I'am sorry if i sometimes cannot express myself correctly in english, hence i 
cannot descrive exactly what i want to accomplish.

I'am sorry about that but english its not my native language.
-- 
http://mail.python.org/mailman/listinfo/python-list


comment prendre la valeur de couleur de point dans canvas python tkinter

2013-03-05 Thread olsr . kamal
comment prendre la valeur de couleur de point dans canvas python tkinter
comme :
(x,y).cget('bg')!='white'???

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


Re: Inserting-embedding some html data at the end of a .py file

2013-03-05 Thread Michael Ross
On Tue, 05 Mar 2013 23:47:18 +0100, Νίκος Γκρ33κ   
wrote:


Thank you very much! This is what i was looking for and here is my code  
after receiving your help.
So, with the command you provided to me i can actually run the .py  
script ans save its output and then append from there!! Great!


Here is my code now!

if htmlpage.endswith('.html'):
f = open( "/home/nikos/public_html/" + htmlpage )
htmldata = f.read()
elif htmlpage.endswith('.py'):
		htmldata = subprocess.check_output( open(  
"/home/nikos/public_html/cgi-bin/" + htmlpage ) )



	counter = ''' mailto:supp...@superhost.gr";> src="/data/images/mail.png"> 

  
Αριθμός Επισκεπτών
http://superhost.gr/?show=stats";> %d  


  ''' % data[0]


template = htmldata + counter
print ( template )
===

But i'am getting this error:
: 'module' object has no attribute  
'check_output'


Why does it say it has no attribute?


Python version < 2.7 ?

And it's more along the lines of
subprocess.check_output( '/home/nikos/.../' + htmlpage )
without "open".
Or even
	subprocess.check_output( [ '/your/python/interpreter', '/home/nikos/...'  
] )

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


Re: simple GUI environment

2013-03-05 Thread Gregory Ewing

Eric Johansson wrote:
the only thing that would make it better is 
if either of these kits used standard Rich text edit controls under 
Windows so I can speech enable these applications.


PyGUI's TextEditor is based on the rich edit control in
Windows. It doesn't currently expose all of its capabilities,
but if speech is all you want, it might be sufficient.

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


Input wont work with if statement if it has a space

2013-03-05 Thread eli m
Hi guys, i have a program like this: (A lot of code is not included)
run = 0
while run == 0:
   raw_input("Type in a function:")
   if function == "Example":
  print ("Hello World!")
   else:
  print ("blah blah blah")

The problem is that whenever i type in example with a space after it then it 
prints the else statement.

My question is, how do i get it to except input with spaces?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Input wont work with if statement if it has a space

2013-03-05 Thread eli m
On Tuesday, March 5, 2013 3:31:13 PM UTC-8, eli m wrote:
> Hi guys, i have a program like this: (A lot of code is not included)
> 
> run = 0
> 
> while run == 0:
> 
>raw_input("Type in a function:")
> 
>if function == "Example":
> 
>   print ("Hello World!")
> 
>else:
> 
>   print ("blah blah blah")
> 
> 
> 
> The problem is that whenever i type in example with a space after it then it 
> prints the else statement.
> 
> 
> 
> My question is, how do i get it to except input with spaces?

oops i meant function = raw_input("Type in a function:")
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Inserting-embedding some html data at the end of a .py file

2013-03-05 Thread Νίκος Γκρ33κ
htmldata = subprocess.check_output( '/home/nikos/public_html/cgi-bin/' + 
htmlpage )

htmldata = subprocess.check_output( ['/usr/bin/python', 
'/home/nikos/public_html/cgi-bin/' + htmlpage] )

Both of the above statemnts fail i'am afraid with the same error message.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Input wont work with if statement if it has a space

2013-03-05 Thread emile

On 03/05/2013 03:33 PM, eli m wrote:

On Tuesday, March 5, 2013 3:31:13 PM UTC-8, eli m wrote:

Hi guys, i have a program like this: (A lot of code is not included)

run = 0

while run == 0:

function = raw_input("Type in a function:")

if function == "Example":


whenever function isn't _exactly_ "Example" the else clause executes.

If you want to catch forms of example you might try:

if function.strip().upper() == "EXAMPLE":

Emile






   print ("Hello World!")

else:

   print ("blah blah blah")



The problem is that whenever i type in example with a space after it then it 
prints the else statement.



My question is, how do i get it to except input with spaces?


oops i meant function = raw_input("Type in a function:")




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


Re: Config & ConfigParser

2013-03-05 Thread Chuck
Thanks Tim!  So much stuff I haven't thought of before.  Out of curiosity, 
what's the benefit of caching the download,  instead of downloading to the 
final destination?   So much stuff they never teach you school.So much 
theory & not enough practice.   :(
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Inserting-embedding some html data at the end of a .py file

2013-03-05 Thread Michael Ross
On Wed, 06 Mar 2013 00:39:31 +0100, Νίκος Γκρ33κ   
wrote:


htmldata = subprocess.check_output( '/home/nikos/public_html/cgi-bin/' +  
htmlpage )


htmldata = subprocess.check_output( ['/usr/bin/python',  
'/home/nikos/public_html/cgi-bin/' + htmlpage] )


Both of the above statemnts fail i'am afraid with the same error message.



check_output is available as of Python 2.7

I guess you are still on version 2.6 ?


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


Re: Config & ConfigParser

2013-03-05 Thread Tim Chase
On 2013-03-05 15:58, Chuck wrote:
> Thanks Tim!  So much stuff I haven't thought of before.  Out of
> curiosity, what's the benefit of caching the download,  instead of
> downloading to the final destination? 

If your connection gets interrupted, the server goes down, etc, you
have a partial download.  If you've put it directly in the download
path, your other programs see this partial download.  However
if your program can resume the download where it left off, once
it's completed successfully, it can atomically move the file to your
download location.  Thus your other programs only ever see
all-or-nothing in the download directory.

-tkc



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


listbox binding..what is the current selection?

2013-03-05 Thread Rex Macey
I have a listbox with two strings "Fixed" and "Random". It is bound by the 
following statement: 
lbLengthtype.bind('',set_lengthtype)

Here's the beginning of the set_lengthtype code:

def set_lengthtype(event=None): 
   s=lbLengthtype.get(tk.ACTIVE)
   print(s)  
   .

The print(s) statement is for debugging.  If 'Random' was selected and the user 
clicks 'Fixed',  then Random will print.  I would like to know what the user 
just selected, not what was selected before the user clicked.  How can I 
determine the current selection? Thanks.  


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


Re: listbox binding..what is the current selection?

2013-03-05 Thread Rick Johnson
On Tuesday, March 5, 2013 6:54:45 PM UTC-6, Rex Macey wrote:
> I have a listbox with two strings "Fixed" and "Random".
> [...] Here's the beginning of the set_lengthtype code:
> 
> def set_lengthtype(event=None): 
>s=lbLengthtype.get(tk.ACTIVE)
>print(s)  
>.
> 
> The print(s) statement is for debugging.  If 'Random' was
> selected and the user clicks 'Fixed',  then Random will
> print.  I would like to know what the user just selected,
> not what was selected before the user clicked.  How can I
> determine the current selection? Thanks.

Use "listbox.nearest(event.y)" instead of "get(ACTIVE"). And maybe you should 
spend some time reading the docs eh?

 http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/index.html

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


Re: simple GUI environment

2013-03-05 Thread Eric Johansson

On 3/5/2013 6:18 PM, Gregory Ewing wrote:

Eric Johansson wrote:
the only thing that would make it better is if either of these kits 
used standard Rich text edit controls under Windows so I can speech 
enable these applications.


PyGUI's TextEditor is based on the rich edit control in
Windows. It doesn't currently expose all of its capabilities,
but if speech is all you want, it might be sufficient.


Do you know which one?

http://www.section508.va.gov/docs/Dragon_Naturally_Speaking_Apps.pdf

(copied from the PDF, apologies for the crappy formatting)
Use supported window classes for edit controls. Dragon 10 supports the 
following control classes.
(Borland controls, TE Edit, and TX Text are supported only in 
Professional, Medical, Legal, and SDK

editions of Dragon.)

Vendor Control Class
Microsoft Edit, Rich Edit, Rich Edit20A, RichEdit20W, Rich Edit50W,
Inktextbox, Inkedit, RichTextBox .NET controls
Borland TMemo, TEdit, TRichEdit
Sub Systems TE Edit versions 10, 11, 12, 13, 14, 15 (not TE Edit .NET)
Text Control TX Text versions 10, 11, 12, 13, 14 and TX Text .NET

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


Re: Do you feel bad because of the Python docs?

2013-03-05 Thread Bob Hanson
On Wed, 27 Feb 2013 15:25:25 -0800 (PST), alex23 wrote:

> On Feb 27, 1:13 pm, Rick Johnson  wrote:
>
> > [...] do you /really/ expect that people
> > have the time to open an issue on the bug tracker?
> 
> If someone can write a paragraph on their blog or this list
> complaining about a problem, then yes, they have the time to open an
> issue on the bug tracker.

I've tried twice to register with the bug tracker -- including
just before sending this post. Both times I got something like
this:

Subject: Failed issue tracker submission
From: Python tracker 
Date: Wed, 06 Mar 2013 00:56:44 +

An unexpected error occurred during the processing
of your message. The tracker administrator is being
notified.

So, it's not all that easy to report bugs for me, anyway. I'd
given up, prior, but reading this thread I thought I'd try one
more time.

I had wanted to report doc bugs, too, as I used to do copy and
line editing. I seem to be able to find typos and such rather
easily, but reporting said bugs -- not so easy.

Something seems amiss, I'd say. It may be just me, but the point
still stands.

--Bob Hanson

-- 
Hanson's Heuristic: Ninety-eight percent of what I think I know
is bullshit. The rest is crap.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Input wont work with if statement if it has a space

2013-03-05 Thread eli m
On Tuesday, March 5, 2013 3:47:31 PM UTC-8, emile wrote:
> On 03/05/2013 03:33 PM, eli m wrote:
> 
> > On Tuesday, March 5, 2013 3:31:13 PM UTC-8, eli m wrote:
> 
> >> Hi guys, i have a program like this: (A lot of code is not included)
> 
> >>
> 
> >> run = 0
> 
> >>
> 
> >> while run == 0:
> 
> >>
> 
> >> function = raw_input("Type in a function:")
> 
> >>
> 
> >> if function == "Example":
> 
> 
> 
> whenever function isn't _exactly_ "Example" the else clause executes.
> 
> 
> 
> If you want to catch forms of example you might try:
> 
> 
> 
>  if function.strip().upper() == "EXAMPLE":
> 
> 
> 
> Emile
> 
> 
> 
> 
> 
> 
> 
> 
> 
> >>
> 
> >>print ("Hello World!")
> 
> >>
> 
> >> else:
> 
> >>
> 
> >>print ("blah blah blah")
> 
> >>
> 
> >>
> 
> >>
> 
> >> The problem is that whenever i type in example with a space after it then 
> >> it prints the else statement.
> 
> >>
> 
> >>
> 
> >>
> 
> >> My question is, how do i get it to except input with spaces?
> 
> >
> 
> > oops i meant function = raw_input("Type in a function:")
> 
> >

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


Re: Do you feel bad because of the Python docs?

2013-03-05 Thread Bob Hanson
[Sorry for the double-post -- I somehow had Followup-To set to
poster in the first post.]

On Wed, 27 Feb 2013 15:25:25 -0800 (PST), alex23 wrote:

> On Feb 27, 1:13 pm, Rick Johnson  wrote:
>
> > [...] do you /really/ expect that people
> > have the time to open an issue on the bug tracker?
> 
> If someone can write a paragraph on their blog or this list
> complaining about a problem, then yes, they have the time to open an
> issue on the bug tracker.

I've tried twice to register with the bug tracker -- including
just before sending this post. Both times I got something like
this:

Subject: Failed issue tracker submission
From: Python tracker 
Date: Wed, 06 Mar 2013 00:56:44 +

An unexpected error occurred during the processing
of your message. The tracker administrator is being
notified.

So, it's not all that easy to report bugs for me, anyway. I'd
given up, prior, but reading this thread I thought I'd try one
more time.

I had wanted to report doc bugs, too, as I used to do copy and
line editing. I seem to be able to find typos and such rather
easily, but reporting said bugs -- not so easy.

Something seems amiss, I'd say. It may be just me, but the point
still stands.

--Bob Hanson

-- 
Hanson's Heuristic: Ninety-eight percent of what I think I know
is bullshit. The rest is crap.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Do you feel bad because of the Python docs?

2013-03-05 Thread Bob Hanson
[Sorry for the double-post -- I somehow had Followup-To set to
poster in the first post.]

On Wed, 27 Feb 2013 15:25:25 -0800 (PST), alex23 wrote:

> On Feb 27, 1:13 pm, Rick Johnson  wrote:
>
> > [...] do you /really/ expect that people
> > have the time to open an issue on the bug tracker?
> 
> If someone can write a paragraph on their blog or this list
> complaining about a problem, then yes, they have the time to open an
> issue on the bug tracker.

I've tried twice to register with the bug tracker -- including
just before sending this post. Both times I got something like
this:

Subject: Failed issue tracker submission
From: Python tracker 
Date: Wed, 06 Mar 2013 00:56:44 +

An unexpected error occurred during the processing
of your message. The tracker administrator is being
notified.

So, it's not all that easy to report bugs for me, anyway. I'd
given up, prior, but reading this thread I thought I'd try one
more time.

I had wanted to report doc bugs, too, as I used to do copy and
line editing. I seem to be able to find typos and such rather
easily, but reporting said bugs -- not so easy.

Something seems amiss, I'd say. It may be just me, but the point
still stands.

--Bob Hanson

-- 
Hanson's Heuristic: Ninety-eight percent of what I think I know
is bullshit. The rest is crap.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Do you feel bad because of the Python docs?

2013-03-05 Thread Mark Lawrence

On 06/03/2013 01:43, Bob Hanson wrote:

On Wed, 27 Feb 2013 15:25:25 -0800 (PST), alex23 wrote:


On Feb 27, 1:13 pm, Rick Johnson  wrote:


[...] do you /really/ expect that people
have the time to open an issue on the bug tracker?


If someone can write a paragraph on their blog or this list
complaining about a problem, then yes, they have the time to open an
issue on the bug tracker.


I've tried twice to register with the bug tracker -- including
just before sending this post. Both times I got something like
this:

 Subject: Failed issue tracker submission
 From: Python tracker 
 Date: Wed, 06 Mar 2013 00:56:44 +

 An unexpected error occurred during the processing
 of your message. The tracker administrator is being
 notified.

So, it's not all that easy to report bugs for me, anyway. I'd
given up, prior, but reading this thread I thought I'd try one
more time.

I had wanted to report doc bugs, too, as I used to do copy and
line editing. I seem to be able to find typos and such rather
easily, but reporting said bugs -- not so easy.

Something seems amiss, I'd say. It may be just me, but the point
still stands.

--Bob Hanson



You'll be delighted to know that everybody will have to sign a 
contributor agreement if they're supplying a patch file on the bug 
tracker, see 
http://blog.python.org/2013/03/introducing-electronic-contributor.html 
and http://mail.python.org/pipermail/python-dev/2013-March/124540.html


--
Cheers.

Mark Lawrence

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


Re: Config & ConfigParser

2013-03-05 Thread Steven D'Aprano
On Tue, 05 Mar 2013 12:09:38 -0800, Chuck wrote:

> I'm curious about using configuration files.  Can someone tell me how
> they are used?   I'm writing a podcast catcher and would like to set up
> some default configurations, e.g. directory, etcOther than default
> directory, what are some of the things that are put in a configuration
> file?   They don't seem to teach you this kind of stuff in school.  :(

I think that you are doing this backwards. You shouldn't start with a 
question:

"I want a configuration file! What should I put in it?"

and then try to invent a need for configuration settings to put in the 
file. You start with the need, and end with the conclusion:

"I need these configuration settings. I'll put them in a config file."


What configuration settings does your podcast catcher software need? What 
makes you think it needs any? Don't over-engineer your application from 
the start. Begin with the simplest thing that works, and go from there.



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


Re: Twisted or Tornado?

2013-03-05 Thread system . healer
Second on django.  This'll do.

https://bitbucket.org/jespern/django-piston/

Build whatever data models you want on the back-end and start spitting out JSON 
with a couple lines of code.

Used this to build an IAP server for iOS apps.  This one hasn't gone into 
production yet but I know of at least one high-profile platform developer that 
was using this same setup for years.


On Thursday, February 28, 2013 4:28:52 PM UTC-8, Jake Angulo wrote:
> I have to say it first: I am not trolling :P
> 
> 
> 
> Im working on a server project (with IOS client) and would like to create a 
> custom, lean and mean server - real Quick!
> 
> 
> 
> My requirements for this framework in descending order:
> 
> 1) Easy to use API
> 
> 2) Widely available documentation / Examples / Community contributions
> 
> 3) Feature-wise - kinda most that you commonly need is there
> 
> 
> 
> Your opinions will be valuable, if possible cite examples or URL references, 
> Pls!  
> 
> 
> 
> I prefer opinion from those who have programmed real projects in it - not 
> just read some blog or Slashdot :P

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


Re: Do you feel bad because of the Python docs?

2013-03-05 Thread Steven D'Aprano
On Tue, 05 Mar 2013 17:51:36 -0800, Bob Hanson wrote:


> I've tried twice to register with the bug tracker -- including just
> before sending this post. Both times I got something like this:
> 
> Subject: Failed issue tracker submission From: Python tracker
>  Date: Wed, 06 Mar 2013
> 00:56:44 +
> 
> An unexpected error occurred during the processing of your message.
> The tracker administrator is being notified.

Works for me.


Please try again, and if it still does not work, please email me off-list 
and I will help you either set up an account or report a tracker bug.



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


Re: Config & ConfigParser

2013-03-05 Thread Steven D'Aprano
On Tue, 05 Mar 2013 18:15:20 -0600, Tim Chase wrote:

> On 2013-03-05 15:58, Chuck wrote:
>> Thanks Tim!  So much stuff I haven't thought of before.  Out of
>> curiosity, what's the benefit of caching the download,  instead of
>> downloading to the final destination?
> 
> If your connection gets interrupted, the server goes down, etc, you have
> a partial download.  If you've put it directly in the download path,
> your other programs see this partial download. However if your program
> can resume the download where it left off, once it's completed
> successfully, it can atomically move the file to your download location.
>  Thus your other programs only ever see all-or-nothing in the download
> directory.

That's not really a *cache* though.

Personally, I find programs that do that sort of cleverness annoying 
rather than helpful. More often than not, they are buggy and fail to 
clean up after themselves if the download is interrupted, so the secret 
download directory ends up filled with junk:

cat-video27~
cat-video27-1~
cat-video27-2~
cat-video27-3~

sort of thing.

Another problem with this tactic is that it makes it unnecessarily 
difficult to watch progress of the download, except via the application's 
official user interface. (If it gives you any interface for watching 
download progress, which is may not.) You have to locate the secret 
download directory, work out what file name the app is using for the 
temporary file (many apps obfuscate the file name), then watch that file 
grow until it suddenly disappears, at which point you then have to change 
directories to see if it reappeared where you actually wanted it to be, 
or was just deleted by something else.

A third problem: instead of having to worry about having enough disk 
space in one location, now you have to worry about having enough disk 
space in *two* locations.

I've even see a program download a large file into the temp location, 
*unsuccessfully* try to copy it into the final location, then delete the 
temp version.

Yet another problem: websites sometimes lie about the size of some files. 
So when you download them, the actual file ends (say) one byte short of 
what the webserver claims. There's nothing wrong with the file, it is 
actually complete, or at least recoverable (many formats, like JPEG, are 
remarkably resistant to damage), but your app will think it never 
completes and either never move it to the final destination, or worse, 
keep trying to download it over and over and over again.

Finally, moving from the temp directory to the final location is not 
necessarily an atomic operation. If it crosses file system boundaries, it 
is a two-step process. 

I think that the KISS principle applies here. If the user tells your app 
to download in some location, your app should download in that location.


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


Re: Config & ConfigParser

2013-03-05 Thread Chris Angelico
On Wed, Mar 6, 2013 at 2:31 PM, Steven D'Aprano
 wrote:
> What configuration settings does your podcast catcher software need? What
> makes you think it needs any? Don't over-engineer your application from
> the start. Begin with the simplest thing that works, and go from there.

Agreed. The way I generally do these things is to simply gather the
config entries into a block of literal assignments at the top of the
program:

host = "ftp"
port = 21
proxy = "192.168.0.3:81"
user = "transfers"
password = "secret"

>From there, it's easy to decide whether to make them into command-line
parameters, a parseable config file, an importable Python script
("from config import *" is an easy and simple way to make that one),
or whatever.

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


Re: Config & ConfigParser

2013-03-05 Thread Chuck
I guess my question was more what is a config.file & why/how do I use one.
Thanks
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Config & ConfigParser

2013-03-05 Thread Chris Angelico
On Wed, Mar 6, 2013 at 3:07 PM, Chuck  wrote:
> I guess my question was more what is a config.file & why/how do I use one.
> Thanks

In its simplest form, a config file is one way to change a program's
behaviour without editing the code. They're helpful when you want to
be able to run the same program in different ways, or when you want to
let someone else change what the program does without having to edit
code (and without the changes getting overwritten by a program
update). There are innumerable file formats that can be used.

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


Re: Config & ConfigParser

2013-03-05 Thread Steven D'Aprano
On Wed, 06 Mar 2013 15:19:53 +1100, Chris Angelico wrote:

> On Wed, Mar 6, 2013 at 3:07 PM, Chuck  wrote:
>> I guess my question was more what is a config.file & why/how do I use
>> one. Thanks
> 
> In its simplest form, a config file is one way to change a program's
> behaviour without editing the code.

I don't think that's quite right, because your code has to be changed to 
read the data from the configuration file in the first place. It doesn't 
just happen by magic.

Essentially, a configuration file is a file that holds configuration 
data. That data could be anything that makes sense for your program, but 
you still have to process the data in your program.


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


Re: simple GUI environment

2013-03-05 Thread Gregory Ewing

Eric Johansson wrote:

On 3/5/2013 6:18 PM, Gregory Ewing wrote:


PyGUI's TextEditor is based on the rich edit control in
Windows. It doesn't currently expose all of its capabilities,
but if speech is all you want, it might be sufficient.


Do you know which one?

Vendor Control Class
Microsoft Edit, Rich Edit, Rich Edit20A, RichEdit20W, Rich Edit50W,
Inktextbox, Inkedit, RichTextBox .NET controls
Borland TMemo, TEdit, TRichEdit
Sub Systems TE Edit versions 10, 11, 12, 13, 14, 15 (not TE Edit .NET)
Text Control TX Text versions 10, 11, 12, 13, 14 and TX Text .NET


Whichever one MFC's RichEditView uses. I can't tell you
any more than that, sorry.

--
Greg

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


Re: Controlling number of zeros of exponent in scientific notation

2013-03-05 Thread Terry Reedy

On 3/5/2013 3:09 PM, fa...@squashclub.org wrote:

Instead of:
1.8e-04
I need:
1.8e-004

So two zeros before the 4, instead of the default 1.


The standard e and g float formats do not give you that kind of control 
over the exponent. You have to write code that forms the string you 
want. You can put that in a simple function or make a class with a 
__format__ method to tie into the new format() and str.format system.


>>> class myfloat(float):
def __format__(self, spec): return '3.14'

>>> x = myfloat(1.4)
>>> x
1.4
>>> format(x, '')
'3.14'
>>> '{}'.format(x)
'3.14'

You could write __format__ to use standard format specs and then adjust:

def __format__(self, spec):
  s = float.__format__(self, spec)
  
  return s

or generate the pieces of the string yourself, possibly using a custom 
spec, as opposed to the standard spec. Notice this example from the manual:

'''
Using type-specific formatting:

>>> import datetime
>>> d = datetime.datetime(2010, 7, 4, 12, 15, 58)
>>> '{:%Y-%m-%d %H:%M:%S}'.format(d)
'2010-07-04 12:15:58'
'''
This works because datetime.datetime and a .__format__ that interprets a 
highly customized format spec. You could customize myfloat's spec to add 
a value for the exponent width. Your example above might be '8.1.3e' 
instead of the standard '7.1e'


Standard, real:
>>> format(1.8e-4, '7.1e')
'1.8e-04'

Custom, hypothetical:
>>> format(myfloat(1.8e-4), '8.1.3e')
'1.8e-004'

Dave already suggested how you could write part of .__format__ to make 
the latter be real also.


--
Terry Jan Reedy

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


Re: Config & ConfigParser

2013-03-05 Thread Chris Angelico
On Wed, Mar 6, 2013 at 3:54 PM, Steven D'Aprano
 wrote:
> On Wed, 06 Mar 2013 15:19:53 +1100, Chris Angelico wrote:
>
>> On Wed, Mar 6, 2013 at 3:07 PM, Chuck  wrote:
>>> I guess my question was more what is a config.file & why/how do I use
>>> one. Thanks
>>
>> In its simplest form, a config file is one way to change a program's
>> behaviour without editing the code.
>
> I don't think that's quite right, because your code has to be changed to
> read the data from the configuration file in the first place. It doesn't
> just happen by magic.

Sure, but once you've made your code read from the config file, you
can then edit the file only and it changes the program's actions.

Of course, that's an *incredibly* broad description; amongst its
coverage are such diverse elements as Apache reading an HTML file to
serve, CPython reading a .py file, and the ROM BIOS reading a boot
sector and jumping to it... but based on the OP's question I couldn't
really be any more specific.

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


Re: Inserting-embedding some html data at the end of a .py file

2013-03-05 Thread Νίκος Γκρ33κ
Τη Τετάρτη, 6 Μαρτίου 2013 2:06:33 π.μ. UTC+2, ο χρήστης Michael Ross έγραψε:
> On Wed, 06 Mar 2013 00:39:31 +0100, Νίκος Γκρ33κ   
> 
> wrote:
> 
> 
> 
> > htmldata = subprocess.check_output( '/home/nikos/public_html/cgi-bin/' +  
> 
> > htmlpage )
> 
> >
> 
> > htmldata = subprocess.check_output( ['/usr/bin/python',  
> 
> > '/home/nikos/public_html/cgi-bin/' + htmlpage] )
> 
> >
> 
> > Both of the above statemnts fail i'am afraid with the same error message.

> check_output is available as of Python 2.7 
> I guess you are still on version 2.6 ?

Actually i'am runnign myu cgi script on my hostgator remote web hosting.
How dod i check the version of python the server uses?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Inserting-embedding some html data at the end of a .py file

2013-03-05 Thread Νίκος Γκρ33κ
Τη Τετάρτη, 6 Μαρτίου 2013 2:06:33 π.μ. UTC+2, ο χρήστης Michael Ross έγραψε:

> check_output is available as of Python 2.7
> 
> 
> 
> I guess you are still on version 2.6 ?

Indeed!
i just checked it's Python 2.6.6: /usr/bin/python and i have asked the linxu 
admins @ hostgator.com to update python.

I trust when they update to v2.7 the script will automatically work!
-- 
http://mail.python.org/mailman/listinfo/python-list


sync databse table based on current directory data without losign previous values

2013-03-05 Thread Νίκος Γκρ33κ
I'am using this snipper to read a current directory and insert all filenames 
into a databse and then display them.

But what happens when files are get removed form the directory?
The inserted records into databse remain.
How can i update  the databse to only contain the existing filenames without 
losing the previous stored data?

Here is what i ahve so far:

==
path = "/home/nikos/public_html/data/files/"

#read the containing folder and insert new filenames
for result in os.walk(path):
for filename in result[2]:
try:
#find the needed counter for the page URL
cur.execute('''SELECT URL FROM files WHERE URL = %s''', 
(filename,) ) 
data = cur.fetchone()#URL is unique, so should 
only be one

if not data:
#first time for file; primary key is automatic, 
hit is defaulted
cur.execute('''INSERT INTO files (URL, host, 
lastvisit) VALUES (%s, %s, %s)''', (filename, host, date) )
except MySQLdb.Error, e:
print ( "Query Error: ", 
sys.exc_info()[1].excepinfo()[2] )
==

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