[Tutor] (no subject)

2006-11-24 Thread Gardner, Dean
Hi 

I was wondering if anyone knew how to control the desktop resolution via 
python. I have investigated pygame which seems to allow you acces to video 
settings but it appears to only influence a window rather than the system (I 
may be totally wrong about this though)

What I ideally need is a small app that will swap resolution between 1600*1200 
and 1280*1024

Thanks
Dean Gardner
Test Engineer 
Barco
Bonnington Bond, 2 Anderson Place, Edinburgh EH6 5NP, UK
Tel + 44 (0) 131 472 5731 Fax + 44 (0) 131 472 4799
www.barco.com 
[EMAIL PROTECTED] 




DISCLAIMER:
Unless indicated otherwise, the information contained in this message is 
privileged and confidential, and is intended only for the use of the 
addressee(s) named above and others who have been specifically authorized to 
receive it. If you are not the intended recipient, you are hereby notified that 
any dissemination, distribution or copying of this message and/or attachments 
is strictly prohibited. The company accepts no liability for any damage caused 
by any virus transmitted by this email. Furthermore, the company does not 
warrant a proper and complete transmission of this information, nor does it 
accept liability for any delays. If you have received this message in error, 
please contact the sender and delete the message. Thank you.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] a question about indentation

2006-11-24 Thread arildna
Hi,

I'm fairly new to python, and trying to get used to the indentation. I 
just encountered my first problem with it. I wrote the following code:

 for ord in f_ord:
if not ordliste.has_key(ord) :   
ordliste[ord] = {}
for word in e_ord:
if ordliste[ord].has_key(word) :
ordliste[ord][word] += 1
else :
ordliste[ord][word] = 1

and then later realized I had to put in one more if-test at the 
beginning of the loop. In most languages I've used, this would be simple 
-- I would simply enclose lines 2-8 in curly braces and put the if-test 
in front.

When I try do it in python, however, it seems I have to do the 
indentation all over. If I just put in the if-test, and try to indent 
all of the lines one step inwards, I get the following result:

   for ord in f_ord:
if not ord in tegn:
if not ordliste.has_key(ord) :   
ordliste[ord] = {}
for word in e_ord:
if ordliste[ord].has_key(word) :
ordliste[ord][word] += 1
else :
ordliste[ord][word] = 1

which is of course not what I'm after. I want to preserve the expression 
in the outer for-loop, and just put an if-test in front.

This isn't really a problem in this case, as the expression is quite 
small, and I can quickly check the indentation line by line. But I can't 
begin to imagine what a hassle that would be if my  expression was 70 
lines and not 7.

I suppose there is a good way to do indent whole blocks like this, but I 
haven't found out what it is. Could anybody help me out?

Thanks,

Arild Næss

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] (no subject)

2006-11-24 Thread Tim Golden
[Gardner, Dean]

| I was wondering if anyone knew how to control the desktop 
| resolution via python. I have investigated pygame which seems 
| to allow you acces to video settings but it appears to only 
| influence a window rather than the system (I may be totally 
| wrong about this though)
| 
| What I ideally need is a small app that will swap resolution 
| between 1600*1200 and 1280*1024 

I haven't tried it, but a bit of poking around suggests
that you want to look at the ChangeDisplaySettingsEx
API call, exposed by pywin32 (or via ctypes if you prefer).
That in turn will probably mean learning the all-embracing
DEVMODE structure, and things like Display Devices.

Should be possible with a bit of experimentation, for which
I'm afraid I don't have time at the moment.

With this kind of question, it's almost always worth looking
around the MS newgroups and Delphi forums. Someone's bound
to have asked the question already; it's just a question of
translating the answer into Python!

TJG


This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] cursor.description

2006-11-24 Thread Antonios Katsikadamos
Hi all. I am new to python and i am trying to execute queries from postgres db. 
I have a question.
   
  What is exactly the operation of cursor.description?
   
   
  Kind regards,
   
  Antonios
   
   

 
-
Sponsored Link

Mortgage rates near 39yr lows. $420,000 Mortgage for $1,399/mo - Calculate new 
house payment___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Having trouble with " table % listTable.values() " line

2006-11-24 Thread Mihai Iacob
Hello,

This is my first post so if i make any kind of
mistakes take it easy on me :).

I don't know how to explain clearly what is the
problem but i'll try.
table = """
%s |%s |%s 
---
%s |%s |%s 
---
%s |%s |%s 
"""

listTable is a dictionary.

listTable = {0 :'X', 1 :' ' , 2 :' ', 3 :'O', 4 :' ',
5 :' ', 6 :'O', 7 :' ', 8 :'X',}

I am trying to take the values from the dictionary
listTable.values() and print them in the table.

The problem is that listTable.values() returns a list 
   " ['X', ' ', ' ', 'O', ' ', ' ', 'O', ' ', 'X']  "
and python won't assign the values of the dictionary
in the table. " table %  listTable.values() "

This error message appears:

Traceback (most recent call last):
  File "", line 1, in 
table % listTable.values()
TypeError: not enough arguments for format string


So instead of the list  " ['X', ' ', ' ', 'O', ' ', '
', 'O', ' ', 'X'] " which won't let me assign strings
in the table, i want to get ('X', ' ', ' ', 'O', ' ',
' ', 'O', ' ', 'X') from listTable.values() 

I know i can make it work using:
table % (listTable[0],listTable[1],
listTable[2],listTable[3],listTable[4],
listTable[5],listTable[6],listTable[7],listTable[8])

but it's kinda long.


If somebody can tell me how to convert the []list into
() i'll make him a little shrine and worship him for 5
seconds :P

I'm trying to make a OXO game, so don't give me any
hints even if you spot mistakes (i hope i can make it
alone) 




 

Do you Yahoo!?
Everyone is raving about the all-new Yahoo! Mail beta.
http://new.mail.yahoo.com
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] help with Tkinter, please

2006-11-24 Thread Michael Lange
On Thu, 23 Nov 2006 13:08:40 -0800
Dick Moores <[EMAIL PROTECTED]> wrote:


> >def compute_fact():
> > value = int(entry_get())

Ooops, sorry for the typo, of course it is entry.get() not entry_get()

Michael
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How to make the label left justified in a frame

2006-11-24 Thread Michael Lange
-- Forwarded to tutor list --

On Thu, 23 Nov 2006 16:25:41 +
"Asrarahmed Kadri" <[EMAIL PROTECTED]> wrote:

> Sorry to bother you,
> But can u please explain what does grid_columnconfigure() do..
> 
> 

The best place for questions like this are usually the Tk man pages :)
Once you get used to them it is easy to figure out how to "translate" them into 
Python.

>From the grid manpage:

grid columnconfigure master index ?-option value...?
(...)
 The -weight option (an integer value) sets the relative weight for 
apportioning any extra spaces among
 columns. A weight of zero (0) indicates the column will not deviate from its 
requested size. A column whose
 weight is two will grow at twice the rate as a column of weight one when extra 
space is allocated to the
 layout.
(...)

So if you have a Frame f and do:

f.grid_columnconfigure(0, weight=0)
f.grid_columnconfigure(1, weight=2)
f.grid_columnconfigure(2, weight=1)

column 0 will not expand at all when the frame is stretched horizontally,
column 2 will expand and column 1 will expand even more.

I hope this helps

Michael
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] a question about indentation

2006-11-24 Thread Christopher Arndt
[EMAIL PROTECTED] schrieb:
> I suppose there is a good way to do indent whole blocks like this, but I 
> haven't found out what it is. Could anybody help me out?

Yes, get a good source code editor that has the ability to (de)indent whole
blocks of code with one keystroke. This is a must-have for writing Python code!
But every decent editor or IDE should have this capability.

I, for example, use SciTE (http://scintilla.org/SciTE.html), where you can use
the TAB key to indent and Shift-TAB to de-indent.

Chris
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] a question about indentation

2006-11-24 Thread arildna
Christopher Arndt wrote:
> [EMAIL PROTECTED] schrieb:
>   
>> I suppose there is a good way to do indent whole blocks like this, but I 
>> haven't found out what it is. Could anybody help me out?
>> 
>
> Yes, get a good source code editor that has the ability to (de)indent whole
> blocks of code with one keystroke. This is a must-have for writing Python 
> code!
> But every decent editor or IDE should have this capability.
>   
Thanks. I use emacs, and now I found the ability (it helps knowing what 
to look for). It takes a couple of keystrokes, but it works.

regards,
Arild Næss
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Having trouble with " table % listTable.values() " line

2006-11-24 Thread Jason Massey

So you want to convert a list into a tuple.

Here ya go, using your example of the table setup:


raw_table ="""

%s | %s | %s
--
%s | %s | %s
--
%s | %s | %s
"""

from random import choice
x_o = [choice(['x','o']) for i in range(9)]
x_o

['x', 'x', 'x', 'x', 'o', 'o', 'o', 'x', 'x']

filled_table = raw_table % tuple(x_o)
print filled_table


x | x | x
--
x | o | o
--
o | x | x




On 11/24/06, Mihai Iacob <[EMAIL PROTECTED]> wrote:


Hello,

This is my first post so if i make any kind of
mistakes take it easy on me :).

I don't know how to explain clearly what is the
problem but i'll try.
table = """
%s |%s |%s
---
%s |%s |%s
---
%s |%s |%s
"""

listTable is a dictionary.

listTable = {0 :'X', 1 :' ' , 2 :' ', 3 :'O', 4 :' ',
5 :' ', 6 :'O', 7 :' ', 8 :'X',}

I am trying to take the values from the dictionary
listTable.values() and print them in the table.

The problem is that listTable.values() returns a list
  " ['X', ' ', ' ', 'O', ' ', ' ', 'O', ' ', 'X']  "
and python won't assign the values of the dictionary
in the table. " table %  listTable.values() "

This error message appears:

Traceback (most recent call last):
File "", line 1, in 
   table % listTable.values()
TypeError: not enough arguments for format string


So instead of the list  " ['X', ' ', ' ', 'O', ' ', '
', 'O', ' ', 'X'] " which won't let me assign strings
in the table, i want to get ('X', ' ', ' ', 'O', ' ',
' ', 'O', ' ', 'X') from listTable.values()

I know i can make it work using:
table % (listTable[0],listTable[1],
listTable[2],listTable[3],listTable[4],
listTable[5],listTable[6],listTable[7],listTable[8])

but it's kinda long.


If somebody can tell me how to convert the []list into
() i'll make him a little shrine and worship him for 5
seconds :P

I'm trying to make a OXO game, so don't give me any
hints even if you spot mistakes (i hope i can make it
alone)







Do you Yahoo!?
Everyone is raving about the all-new Yahoo! Mail beta.
http://new.mail.yahoo.com
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] (no subject)

2006-11-24 Thread Tim Golden
[Gardner, Dean]

| I was wondering if anyone knew how to control the desktop 
| resolution via python. 
| 
| What I ideally need is a small app that will swap resolution 
| between 1600*1200 and 1280*1024 

OK. Had a bit of time to look into this. The following code
snippet is (hopefully) fairly self-explanatory, the only
exception being the mild shenanigans one has to go through
to pick a display mode. Let's assume your two "keys" are:

Depth: 32
Freq: 70

Width: 1600 <-> 1280
Height: 1200 <-> 1024

First, find your display modes:



import os, sys

import win32api
import win32con
import pywintypes

display_modes = {}
n = 0
while True:
  try:
devmode = win32api.EnumDisplaySettings (None, n)
  except pywintypes.error:
break
  else:
key = (
  devmode.BitsPerPel, 
  devmode.PelsWidth, 
  devmode.PelsHeight, 
  devmode.DisplayFrequency
)
display_modes[key] = devmode
n += 1



You now have a dictionary [display_modes], keyed on the
height, width and depth needed. All you have to do to
switch is something like this:



mode_required = (32, 1600, 1280, 70)
devmode = display_modes[mode_required]
win32api.ChangeDisplaySettings (devmode, 0)

#
# ... time passes
#

mode_required = (32, 1280, 1024, 70)
devmode = display_modes[mode_required]
win32api.ChangeDisplaySettings (devmode, 0)



and so on. Obviously, this is *very* bare bones, (and untested) 
but it should get you started.

TJG


This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] One question......

2006-11-24 Thread Asrarahmed Kadri

Hi Folks,

I am constructing a bar-chart using Tkinter. The function takes a list
'data' and draws horizontal bar for each value.
Now what I want is  the the canvas widget should be able to handle variable
number of data-items. I cannot figure out how to do that, because I have
hard coded the lengths of X and Y axes. I want to make the entire function a
lot more flexible so that it determines the length of both the axes on the
basis of data supplied to it.
Do you know how can I get around with this issue.  The code for bar-chart is
as under:


from Tkinter import *
import tkFont


def draw_rect(canvas,data,x1,y1,x2,y2):

   f_obj = tkFont.Font(family='Arial',size=7,slant='italic')
   l = len(data)
   for i in data:

   y1 = y1 - 30
   x2 = x1 + (3 * i)
   y2 = y2 - 30
   canvas.create_rectangle(x1,y1,x2,y2)
   canvas.create_text(x2+5,y2,text=i,font=f_obj,anchor=NW)
   canvas.create_text(105,y1,text='[EMAIL PROTECTED]:00:00',font=f_obj)



data = [10,20,100,0,50,40,30,79]
root = Tk()

frame = Frame(root)
frame.pack()

canvas = Canvas(frame,height=500,width=500)

canvas.create_line(150,350,450,350,width=2)   # X-axis
canvas.create_line(150,350,150,50,width=2)# Y-axis
canvas.pack()

draw_rect(canvas,data,x1=150,y1=340,x2=250,y2=330)

root.mainloop()
Thanks a lot.
Best Regards,
Asrarahmed Kadri


--
To HIM you shall return.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] cursor.description

2006-11-24 Thread Tim Golden
[Antonios Katsikadamos]

| Hi all. I am new to python and i am trying to execute queries 
| from postgres db. I have a question.
|  
| What is exactly the operation of cursor.description?

Ultimately, the doc you want to look at is this:

http://www.python.org/dev/peps/pep-0249/

Here's the relevant bit:

"""
.description 
  
This read-only attribute is a sequence of 7-item
sequences.  Each of these sequences contains information
describing one result column: (name, type_code,
display_size, internal_size, precision, scale,
null_ok). The first two items (name and type_code) are
mandatory, the other five are optional and must be set to
None if meaningfull values are not provided.

This attribute will be None for operations that
do not return rows or if the cursor has not had an
operation invoked via the executeXXX() method yet.

The type_code can be interpreted by comparing it to the
Type Objects specified in the section below.
"""

In practise, this means that, once a cursor's executed, you
can read the names/types of columns returned from the description
tuple.

TJG


This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] a question about indentation

2006-11-24 Thread Danny Yoo
> I'm fairly new to python, and trying to get used to the indentation. I
> just encountered my first problem with it. I wrote the following code:
>
> for ord in f_ord:
>if not ordliste.has_key(ord) :
>ordliste[ord] = {}
>for word in e_ord:
>if ordliste[ord].has_key(word) :
>ordliste[ord][word] += 1
>else :
>ordliste[ord][word] = 1
>
> and then later realized I had to put in one more if-test at the
> beginning of the loop. In most languages I've used, this would be simple
> -- I would simply enclose lines 2-8 in curly braces and put the if-test
> in front.


Hi Arild,


Try using functions more.  Well-written functions can help to support the 
kind of rapid changes that you're making to your program, and to reduce 
the nesting that you're seeing.

Concretely, there's a block in the code that updates the dictionary data 
structure.

>if not ordliste.has_key(ord) :
>ordliste[ord] = {}
>for word in e_ord:
>if ordliste[ord].has_key(word) :
>ordliste[ord][word] += 1
>else :
>ordliste[ord][word] = 1


We can turn that block into a full-fledged function:


def update_ordliste(ordliste, ord, words):
 if not ordliste.has_key(ord):
 ordliste[ord] = {}
 for word in words:
 if ordliste[ord].has_key(word) :
 ordliste[ord][word] += 1
 else:
 ordliste[ord][word] = 1


(There is actually a nicer way to write update_ordliste, but I'll leave 
that for another time.)



Once we have this, we can revisit the original code, and turn:

> for ord in f_ord:
>if not ordliste.has_key(ord) :
>ordliste[ord] = {}
>for word in e_ord:
>if ordliste[ord].has_key(word) :
>ordliste[ord][word] += 1
>else :
>ordliste[ord][word] = 1

into:

#
for ord in f_ord:
 update_ordliste(ordliste, ord, e_ord)
#

This code is in a form that should be easier to change more rapidly, since 
the block is itself not too nested or long.

The general idea is that, when we have a for loop on a fairly long and 
substantial block, there's often a name we can give to the concept that 
it's doing.  "update_ordliste" is not such a good, descriptive name, 
though: if you can think of a better name, please feel free to change it. 
*grin*


> When I try do it in python, however, it seems I have to do the 
> indentation all over.

With the refactored code above, we can support this kind of change with 
very little work:

#
for ord in f_ord:
 if not ord in tegn:
 update_ordliste(ordliste, ord, e_ord)
#



> This isn't really a problem in this case, as the expression is quite 
> small, and I can quickly check the indentation line by line. But I can't 
> begin to imagine what a hassle that would be if my expression was 70 
> lines and not 7.

Text editors for Python often support indenting whole blocks.  If you're 
using Emacs, for example, "C-c >" should indent a block forward.  I'm sure 
that other Python-aware text editors provide similar tools.

What IDE are you using?

You bring up a good point that it's a hassle to adjust long blocks of 
code.  One way to attack this problem is to avoid it altogether: it's 
often very possible to refactor the code to make code blocks smaller or 
simpler.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] One question......

2006-11-24 Thread Luke Paireepinart
Asrarahmed Kadri wrote:
>
>  
> Hi Folks,
>  
> I am constructing a bar-chart using Tkinter. The function takes a list 
> 'data' and draws horizontal bar for each value.
> Now what I want is  the the canvas widget should be able to handle 
> variable number of data-items. I cannot figure out how to do that, 
> because I have hard coded the lengths of X and Y axes. I want to make 
> the entire function a lot more flexible so that it determines the 
> length of both the axes on the basis of data supplied to it.
#disclaimer
Note: I didn't realize you said horizontal bar charts.
This does vertical bar charts.
It should be trivial to change this.
Sorry for not reading your post more carefully to begin with.


#for width
 >>> data = [1,5,6,7,8,3,2,9]
 >>>target_width = 600
 >>>padding = 10
 >>>num_of_data_items = len(data)
 >>>individual_width =( 
target_width-(padding*(num_of_data_items-1)))/num_of_data_items
 >>>individual_width
66
 >>>individual_width*num_of_data_items
528
 >>>padding* (len(data)-1)
70
 >>>528 + 70
598

#for height
 >>>target_height = 600
 >>> maxval = max(yvals)
 >>> for item in yvals:
print int((float(item)/maxval) * target_height)

66
333
400
466
533
200
133
600

Did you honestly try to think this through before posting?
It's a very simple concept.
Not trying to be mean, just frank.
I think you could've done this on your own if you had tried.
Good luck with your bar charts. :)

When you ask a question such as this
"I cannot figure out how to do that, because I have hard coded the 
lengths of X and Y axes. I want to make the entire function a lot more 
flexible so that it determines the length of both the axes on the basis 
of data supplied to it."
The way you should be reasoning is this:
I have hardcoded the lengths of the x and y axes.
I need to change this for my function to operate how I want it to.
How do I change it?
1) I have the data set already, so how do i figure out the width? (or 
height, if you're doing horizontal bar graphs)
Well, I can make the following distinctions:
- I have a target width (the width of the canvas) that they must all fit 
within.
- all bars will be the same width
- there should be some distance between each bar.
- this distance should be the same no matter how many data elements 
there are, IE fixed.
- so if I have a fixed width between variable amounts of data, how would 
I design an algorithm to perform this for me on any arbitrary data set?

2) How do I figure out the height of the data sets? (or width, if you're 
doing horizontal bar graphs)
The following distinctions can be made:
- I have a target height that they all must fit within (the height of 
the canvas)
- Only the maximum value should be the full height of the canvas.
- the others should be less than this height, depending NOT on their 
ratio to the height of the maximum bar, but on their ratio to the data 
that generated this.
-- what do we use for ratios? Fractions!

HTH,
-Luke
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] A Million Sevens

2006-11-24 Thread Andreas Kostyrka
* Chris Hengge <[EMAIL PROTECTED]> [061119 00:44]:
> That must be part of Pythons shiny ability of dynamic data types? Must be a
> messy operation to change data-types like that.. I think I'll just do my
> best to work with the right data-types the whole time ;D

Well, huge miss understanding:

a = b + c

=> a gets a reference to a newly created object containing the sum of
b and c.

a += b

=> a again gets a reference to a new object.

So there is not much point in trying to apply performance experiences
from other languages like C++ or Java.

Andreas
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Please suggest a python book

2006-11-24 Thread Narasimha
Hi! Friends,

I am new to python. I have a vacation of 15 days. Please suggest me a python
book (or a website).

I already know C language. I have heard much about Python.

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Please suggest a python book

2006-11-24 Thread hacktavist
you could look into www.diveintopython.com it is an online book for people 
who are already versed in a prior language.
Ray

On Sat, 25 Nov 2006, Narasimha wrote:

> Hi! Friends,
>
> I am new to python. I have a vacation of 15 days. Please suggest me a python
> book (or a website).
>
> I already know C language. I have heard much about Python.
>
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] (no subject)

2006-11-24 Thread Narasimha
Is it possible to create stand-alone programs(like exe files in dos and
a.out files in UNIX) with Python?

If possible please tell me how to make them.

I am planning to distribute my python code to friends.

They don't have python interpreters nor they know how to use them.

Please suggest a solution.

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Please suggest a python book

2006-11-24 Thread Jalil

If you already know C you should be fine with python ref book.

*Python Essential Reference (2nd Edition)*




On 11/24/06, Narasimha <[EMAIL PROTECTED]> wrote:


 Hi! Friends,

I am new to python. I have a vacation of 15 days. Please suggest me a
python book (or a website).

I already know C language. I have heard much about Python.

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor



___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Auto-hyperlinking ignoring html tags

2006-11-24 Thread anil maran
Hey

I m trying to auto-hyperlink urls,
i found libcia.web.Regextransform.py
but the problem is it applies auto hyperlink on html tags
for eg < img src = " http://www.google.com/a.gif " >

becomes
*gta* img src=" < a href= "http://www.google.com/a.gif " *lt

is there any way to auto-hyperlink on text, ignoring whatever is in html tags 
ie within < >

http://www.google.com/codesearch?q=auto-hyperlink+lang%3Apython&hl=en&btnG=Search+Code

http://www.google.com/codesearch?hl=en&q=+lang:python+auto-hyperlink+show:uryY9epTPhc:stWj4z9lV24:urqZ0U7CNig&sa=N&cd=1&ct=rc&cs_p=http://svn.navi.cx/misc/trunk&cs_f=cia/LibCIA/Web/RegexTransform.py#a0




Thanks for pointers







 

Do you Yahoo!?
Everyone is raving about the all-new Yahoo! Mail beta.
http://new.mail.yahoo.com___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] (no subject)

2006-11-24 Thread Luke Paireepinart
Narasimha wrote:
>
> Is it possible to create stand-alone programs(like exe files in dos 
> and a.out files in UNIX) with Python?
>
> If possible please tell me how to make them.
>
> I am planning to distribute my python code to friends.
>
> They don’t have python interpreters nor they know how to use them.
>
> Please suggest a solution.
>
Depends how you want to distribute it.
It's not unreasonable for you to just include the whole python 
interpreter, along with a batch file that will run the script using the 
included interpreter,
on a CD.
IF you're going to make it available for download, though, you want to 
minimize the packages that are included.
A tool like py2exe does this. In addition to reducing the included 
packages to the bare minimum,
it also generates a nice .exe.
But really, you could get the same functionality with a simple batch 
script, and then it would work on Linux too.
Not the batch script, obviously, but the rest of your program.
Although I'm prettty sure most modern linux distros come with Python 
already installed, so you don't need to be concerned about those linux folk.
Except, I find that it's more trouble for linuxers to get packages for 
their python scripts, because they have to make-install etc. whereas 
windows people have a nice friendly,
fuzzy little GUI installer for the majority of python packages.
So including an interpreter on the CD With your program that has all of 
the dependencies built in may not be a bad idea.

On the other hand (assuming we have more than 2 hands by now)
you could also just teach them how to install files, and pat them gently 
on the back and say "congratulations!"

I mean, really, it's not any harder to install a python distribution 
than it is to install, say, Battlefield 2 or Microsoft Office.

Once it's installed, they just double-click the file the same as they 
would with any other program.
So their argument that they 'wouldn't know how to use it' doesn't really 
apply.
If they want to make their own programs, they can learn how to use it.
If they want to run your programs, it doesn't matter whether they 
understand it or not.
Just tell them not to look at the source code and they can go on 
thinking that all programs are made by magical
programming fairies while we sleep, or by little elves.

Oh, and to address your original question:
I don't think it's possible to have a single .exe with all your 
program's functionality contained within.
But you can have a .exe as well as a file directory that has all of your 
materials.
In this case, why not just have a batch and a python installation?
Just remember that very few programs come in completely enclosed .exes. 
Examples include Anim8or, and
Hmm. I can't think of any others.
Anyway, that's enough out of me.
Time for you to get on with your pythoneering!
Hope I helped,
-Luke

> 
>
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>   

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor