[Tutor] Trouble with sys.path.append

2010-08-08 Thread aug dawg
Hey all,

Earlier today, I tried to add a folder to my PYTHONPATH. When I tried
sys.path.app('location/of/folder'), the command successfully executed it,
but then when I did sys.path to check to see if it was now in my PYTHONPATH,
it was not there. Does anyone know what might be causing this?

Thanks!
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] os.urandom()

2010-08-08 Thread Alan Gauld


"Richard D. Moores"  wrote


So if os.urandom() had been written so that it printed only hex,
b'l\xbb\xae\xb7\x0ft' would have been

b'\x6c\xbb\xae\xb7\x0f\x74' , right?


Yes except that its not urandomthat is printing those values.
urandom returns a string of bytes.
Its the Python interpreter calling the repr() function on
those bytes that is deciding to print either hex or character.
Try this:


'\x6c\xbb\xae\xb7\x0f\x74'

'l\xbb\xae\xb7\x0ft'

print '\x6c\xbb\xae\xb7\x0f\x74'

l╗«À☼t




In the first case its the repr() of the string that gets
printed in the second its the str(). Its the conversion
function that determines what gets printed not urandom()

How were we supposed to know that all the hexes have 2 digits? How 
did you?


Simple arithmetic...
Its the hex representation of a byte. A byte is 8 bits long.
A hex digit represents 4 bits (-) so you need 2 hex digits to
represent 8 bits or one byte.

Alan G. 



___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Distributing Python Code for Commercial Porpoises?

2010-08-08 Thread Alan Gauld


"Wayne Watson"  wrote

I find it interesting that any Python book I've seen doesn't deal 
with distributing programs in some form or another.


Yes thats a good point. Most books (including mine) focus on how to
write code. Very few tell you how to distrubute it! And that's not 
just

in Python, most programming books are the same.

Interesting.

Alan G. 



___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] os.urandom()

2010-08-08 Thread Steven D'Aprano
On Sun, 8 Aug 2010 03:57:39 pm Richard D. Moores wrote:

> So if os.urandom() had been written so that it printed only hex,
> b'l\xbb\xae\xb7\x0ft' would have been

os.urandom() doesn't *print* anything. It RETURNS a byte string. What 
you do with it is your business.

In your case, you fail to save the return result in a variable, or put 
it in a list, or do anything else with it, so the interactive 
interpreter prints it. All that the interpreter sees is bytes. They 
could have come from a hard-coded literal:

>>> 'l\xbb\xae\xb7\x0ft'
'l\xbb\xae\xb7\x0ft'

or a list:

>>> L = ['l\xbb\xae\xb7\x0ft', None, None]
>>> L[0]
'l\xbb\xae\xb7\x0ft'

or some function call:

>>> (lambda c: c + '\xbb'[:] + '\xae\xb7' + 1*'\x0ft')('l')
'l\xbb\xae\xb7\x0ft'


(The above examples are from Python 2.5 rather than 3.1, where byte 
strings aren't flagged with a leading b.)



> How were we supposed to know that all the hexes have 2 digits? How
> did you?

Because that's what they do. Numbers between 0 and 255 inclusive can be 
written in two hex digits 00..FF, just like numbers between 0 and 99 
inclusive can be written in two decimal digits.



-- 
Steven D'Aprano
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Trouble with sys.path.append

2010-08-08 Thread Steven D'Aprano
On Sun, 8 Aug 2010 09:35:38 am aug dawg wrote:
> Hey all,
>
> Earlier today, I tried to add a folder to my PYTHONPATH. When I tried
> sys.path.app('location/of/folder'), the command successfully executed
> it, but then when I did sys.path to check to see if it was now in my
> PYTHONPATH, it was not there. Does anyone know what might be causing
> this?

Modifying sys.path doesn't update PYTHONPATH. If you modify sys.path, 
the changes disappear when you exit and re-enter and the unmodified 
PYTHONPATH is read.


-- 
Steven D'Aprano
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Word to Sound

2010-08-08 Thread Lie Ryan
On Sat, 07 Aug 2010 11:43:25 -0400, Chris King  
wrote:

 How do you convert a string into a sound object.


Do you mean as in text-to-speech or playing byte string that contain 
sound data in a certain encoding to the speaker?


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Trouble with sys.path.append

2010-08-08 Thread Lie Ryan
aug dawg  gmail.com> writes:
>
> Earlier today, I tried to add a folder to my PYTHONPATH. When 
> I tried sys.path.app('location/of/folder'), the command successfully
> executed it, but then when I did sys.path to check to see if it was
> now in my PYTHONPATH, it was not there. Does anyone know what might
> be causing this?
> 

Appending to sys.path will only change the module search directory for the
current *python* session. 

If you want to add a directory to the current *terminal* session, then export
PYTHONPATH environment variable into your shell.

If you want to *permanently* add a directory to the module search directory, add
a .pth file to a directory that is already inside a search path (typically in
/site-packages). Alternatively, modify the site.py file. See
here for details: http://docs.python.org/install/#inst-search-path

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] os.urandom()

2010-08-08 Thread Richard D. Moores
On Sun, Aug 8, 2010 at 01:05, Alan Gauld  wrote:
>
> "Richard D. Moores"  wrote
>
>> So if os.urandom() had been written so that it printed only hex,
>> b'l\xbb\xae\xb7\x0ft' would have been
>>
>> b'\x6c\xbb\xae\xb7\x0f\x74' , right?
>
> Yes except that its not urandomthat is printing those values.
> urandom returns a string of bytes.
> Its the Python interpreter calling the repr() function on
> those bytes that is deciding to print either hex or character.
> Try this:
>
 '\x6c\xbb\xae\xb7\x0f\x74'
>
> 'l\xbb\xae\xb7\x0ft'

 print '\x6c\xbb\xae\xb7\x0f\x74'
>
> l╗«À☼t

>
> In the first case its the repr() of the string that gets
> printed in the second its the str(). Its the conversion
> function that determines what gets printed not urandom()

Ah. Here are some more (from Python 2.6):
>>> s = os.urandom(6);s;print s
'Y\xce\x01\xc6\xd3\xe7'
Y╬☺╞╙τ
>>> s = os.urandom(6);s;print s
'\xd2$\xa1\x03B\xba'
╥$í♥B║
>>> s = os.urandom(6);s;print s
'\xc6\x93C\xca\xc3\x18'
╞ôC╩├↑
>>> s = os.urandom(6);s;print s
'`DTzL\x98'
`DTzLÿ

>> How were we supposed to know that all the hexes have 2 digits? How did
>> you?
>
> Simple arithmetic...
> Its the hex representation of a byte. A byte is 8 bits long.
> A hex digit represents 4 bits (-) so you need 2 hex digits to
> represent 8 bits or one byte.

Got it. Thanks again. And to Steven as well.

Dick
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Reading every 5th line

2010-08-08 Thread nitin chandra
Hello Everyone,

I am to make a small programme for a friend of mine
where i am to start reading from 14th (string) from a file and then
read every 5th row.

ie.

in 1st read it reads the 14 row in a File, write to an OUTPUT-1 file
Next reads 19th row, write to the OUTPUT-1 file
then 24th row,... so on.

and the second loop does is

reads the 15th line as the first line from same input file and write
to OUTPUT-2 file
next reads 20th line / row, write to the OUTPUT-2 file


I have tried various ways but some how i am ONLY able to do i simple
read from one file and write to another.

There are 3024 rows / lines PER file and there are 24 such file I need
to run the programme on.

I really need this on an urgent basis. can some one please help me in this.

Thanks in Advance

Nitin
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Reading every 5th line

2010-08-08 Thread davidheiserca


- Original Message - 
From: "nitin chandra" 

To: 
Sent: Sunday, August 08, 2010 5:04 AM
Subject: [Tutor] Reading every 5th line



Hello Everyone,

I am to make a small programme for a friend of mine
where i am to start reading from 14th (string) from a file and then
read every 5th row.

ie.

in 1st read it reads the 14 row in a File, write to an OUTPUT-1 file
Next reads 19th row, write to the OUTPUT-1 file
then 24th row,... so on.

and the second loop does is

reads the 15th line as the first line from same input file and write
to OUTPUT-2 file
next reads 20th line / row, write to the OUTPUT-2 file


I have tried various ways but some how i am ONLY able to do i simple
read from one file and write to another.

There are 3024 rows / lines PER file and there are 24 such file I need
to run the programme on.

I really need this on an urgent basis. can some one please help me in 
this.


Thanks in Advance

Nitin
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor



Try using "range(start, end, step)".

If this is for a class exercise, it would be unfair to say more. If it's not 
for an assignment, I can show you more.


Dave

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Reading every 5th line

2010-08-08 Thread davidheiserca



- Original Message - 
From: "nitin chandra" 

To: 
Sent: Sunday, August 08, 2010 7:29 AM
Subject: Re: [Tutor] Reading every 5th line



Thank you all.

@Dave - Thank you for the tip. No this is not a class exercise, that
is assured.

Will let know how much progress i made.

Truly, I am still foggy, as to how to include it in code.

Thanks

Nitin




Try using "range(start, end, step)".

If this is for a class exercise, it would be unfair to say more. If it's 
not

for an assignment, I can show you more.

Dave




This may help you get started.

FileNames = ["FileName01", "FileName02", ..., "FileName24"]
for File in FileNames:
   List = open(File, 'r').readlines()
   for Start in [[14, "%s-1" % File], [15,"%s-2" % File]]:
   OutList = []
   for Line in range(Start[0]-1, 3024, 5):
   OutList.append(List[Line])
   open(("%s.txt" % Start[1]), 'w').writelines(OutList)

P.S. My code writing style isn't very conventional.

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] os.urandom()

2010-08-08 Thread bob gailer

On 8/8/2010 1:57 AM, Richard D. Moores wrote:

On Sat, Aug 7, 2010 at 17:00, Alan Gauld  wrote:
   

"Richard D. Moores"  wrote

 

Yes, the number of bytes seems to<= 6, or is it?:
   

os.urandom(6)
 

b'\xf1\x1c\x15\x83\x14\x0e'
   

ok

 

os.urandom(6)
 

b'l\xbb\xae\xb7\x0ft'
   

still ok - the l and t at the ends are valid characters so Python
prints the letter
 
   

hex(ord('t'))
 

'0x74'
   

hex(ord('l'))
 

'0x6c'

So if os.urandom() had been written so that it printed only hex,
b'l\xbb\xae\xb7\x0ft' would have been

b'\x6c\xbb\xae\xb7\x0f\x74' , right?

Thanks very much for that, Alan.

How were we supposed to know that all the hexes have 2 digits?


In version 2.6.5 Language Reference 2.4.1 - String literals:
\xhh Character with hex value hh

--
Bob Gailer
919-636-4239
Chapel Hill NC

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Reading every 5th line

2010-08-08 Thread Steven D'Aprano
On Sun, 8 Aug 2010 10:04:21 pm nitin chandra wrote:
> Hello Everyone,
>
> I am to make a small programme for a friend of mine
> where i am to start reading from 14th (string) from a file and then
> read every 5th row.

There are many variations, here's one:

Write a loop that executes 14 times. Inside that loop, read one line 
from the input file, and write it to the output file.

Now write a second loop that executes forever. (Don't worry, you'll 
break out of the loop at some point.) Inside the loop, read one line 
from the input file, and write it to the output file. Then read four 
more lines, and throw them away. If you read a line, and it's empty, 
then you've reached End Of File (EOF) and you can break out of the 
loop.


-- 
Steven D'Aprano
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Reading every 5th line

2010-08-08 Thread bob gailer

On 8/8/2010 8:04 AM, nitin chandra wrote:

Hello Everyone,

I am to make a small programme for a friend of mine
where i am to start reading from 14th (string) from a file and then
read every 5th row.

ie.

in 1st read it reads the 14 row in a File, write to an OUTPUT-1 file
Next reads 19th row, write to the OUTPUT-1 file
then 24th row,... so on.

and the second loop does is

reads the 15th line as the first line from same input file and write
to OUTPUT-2 file
next reads 20th line / row, write to the OUTPUT-2 file


I have tried various ways but some how i am ONLY able to do i simple
read from one file and write to another.
   


Please show us the attempts you have made.

There are 3024 rows / lines PER file


That is irrelevant.


  and there are 24 such file I need to run the programme on.
   


Several unknowns here. Do you process one file at a time? Where does the 
output from the other files go?


--
Bob Gailer
919-636-4239
Chapel Hill NC

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Questions regarding strings

2010-08-08 Thread Daniel
Hello everyone! I would like to ask you two questions regarding strings
which I do not know. Excuse me in advance if the questions may seem a bit
dumb. I'm a beginner. So let's get back to the point, this is my string:

msg= 'Hello world'
If I do, msg[:3] I get the following output, 'Hel'
If I do, msg[6:] I get the following output, 'World'
Ok, so I understand why this is happening. What I do not understand is why I
get the following output in this cases.


1) msg[:-1] which has the output 'Hello Worl'
2) msg[0:6:2]  'Hlo'
3) msg[::-1] 'dlroW olleH'

Can someone please explain this to me? Thank you so much and I wish everyone
a great day!
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Questions regarding strings

2010-08-08 Thread Hugo Arts
On Sun, Aug 8, 2010 at 12:04 PM, Daniel  wrote:
> Hello everyone! I would like to ask you two questions regarding strings
> which I do not know. Excuse me in advance if the questions may seem a bit
> dumb. I'm a beginner. So let's get back to the point, this is my string:
>
> msg= 'Hello world'
> If I do, msg[:3] I get the following output, 'Hel'
> If I do, msg[6:] I get the following output, 'World'
> Ok, so I understand why this is happening. What I do not understand is why I
> get the following output in this cases.
>
>
> 1) msg[:-1] which has the output 'Hello Worl'

negative indexes start from the end of the string. So msg[-1] == 'd',
and the slice there means "start at the first character, and go up to
the last.

> 2) msg[0:6:2]  'Hlo'

This means start at the first, up to the sixth, making steps of 2.
Steps of two means every other letter is skipped, of course.

> 3) msg[::-1] 'dlroW olleH'

This slice catches the whole string, but makes steps of -1, which
essentially means you'll go through the strings backwards.

Hugo
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Distributing Python Code for Commercial Porpoises?

2010-08-08 Thread Eike Welk
Hello Alan!

On Sunday August 8 2010 10:10:20 Alan Gauld wrote:
> Yes thats a good point. Most books (including mine) focus on how to
> write code. Very few tell you how to distrubute it! And that's not
> just
> in Python, most programming books are the same.
> 
> Interesting.
> 
> Alan G.

Yes, I want to endorse that!

Distributing your software is IMHO a worthy subject for any Python website or 
book. Especially because there is this idea, that all important components for 
software development are included in Python.

With Distutils, EasyInstall (*.egg), and Python Package Index there really 
exist an integrated build system with installer, a package manager, and a 
networked software repository. 

Additionally with Virtualenv or Buildout one can build encapsulated 
environments for testing or deployment, without fear for conflicting library 
versions.

Someone however needs to find out how these components fit together, and then 
write a nice introduction on the subject.


Eike.


Links to the mentioned projects for reference:

Distutils:   http://docs.python.org/distutils/
EasyInstall: http://pypi.python.org/pypi/setuptools
 http://pypi.python.org/pypi/distribute
Virtualenv:  http://pypi.python.org/pypi/virtualenv
Buildout:http://www.buildout.org/
Python Package Index: http://pypi.python.org/pypi
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Distributing Python Code for Commercial Porpoises?

2010-08-08 Thread David Hutto
On Sun, Aug 8, 2010 at 2:41 PM, Eike Welk  wrote:
> Hello Alan!
>
> On Sunday August 8 2010 10:10:20 Alan Gauld wrote:
>> Yes thats a good point. Most books (including mine) focus on how to
>> write code. Very few tell you how to distrubute it! And that's not
>> just
>> in Python, most programming books are the same.
>>
>> Interesting.
>>
>> Alan G.
>
> Yes, I want to endorse that!
>
> Distributing your software is IMHO a worthy subject for any Python website or
> book. Especially because there is this idea, that all important components for
> software development are included in Python.

Four words... Software is python's propaganda.

>
> With Distutils, EasyInstall (*.egg), and Python Package Index there really
> exist an integrated build system with installer, a package manager, and a
> networked software repository.
>
> Additionally with Virtualenv or Buildout one can build encapsulated
> environments for testing or deployment, without fear for conflicting library
> versions.
>
> Someone however needs to find out how these components fit together, and then
> write a nice introduction on the subject.
>
>
> Eike.
>
>
> Links to the mentioned projects for reference:
>
> Distutils:   http://docs.python.org/distutils/
> EasyInstall: http://pypi.python.org/pypi/setuptools
>             http://pypi.python.org/pypi/distribute
> Virtualenv:  http://pypi.python.org/pypi/virtualenv
> Buildout:    http://www.buildout.org/
> Python Package Index: http://pypi.python.org/pypi
> ___
> Tutor maillist  -  tu...@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] word_probles.py

2010-08-08 Thread Shurui Liu

Okay. I am using WinXP, Python 3.1 on my workstation. 
And this is the Python version information I got from putty.exe: 
Python 2.5.4 (r254:67916, Apr 13 2009, 18:09:11)
[GCC 4.2.1 20070719  [FreeBSD]] on freebsd7

Thanks! 


##
Never had, never will. 



 
> From: hugo.yo...@gmail.com
> Date: Sat, 7 Aug 2010 20:09:04 -0500
> Subject: Re: [Tutor] word_probles.py
> To: shurui@hotmail.com
> CC: waynejwer...@gmail.com; tutor@python.org
> 
> On Sat, Aug 7, 2010 at 7:12 PM, Shurui Liu  wrote:
> > There is no tracebacks.
> >
> > I can run this program on putty.exe. That means the code is correct, but I
> > cannot run it on IDLE or PyScripter.exe. Both of these two platforms only
> > told me "Syntax Error" without tracebacks or something.
> >
> 
> We'll need to know python versions. The machine you're running it on
> through putty might have 2.x while your local machine has 3.x, that
> would cause a problem like this.
> 
> Hugo
  ___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Reading every 5th line

2010-08-08 Thread Dave Angel

nitin chandra wrote:

Hello Everyone,

I am to make a small programme for a friend of mine
where i am to start reading from 14th (string) from a file and then
read every 5th row.

ie.

in 1st read it reads the 14 row in a File, write to an OUTPUT-1 file
Next reads 19th row, write to the OUTPUT-1 file
then 24th row,... so on.

and the second loop does is

reads the 15th line as the first line from same input file and write
to OUTPUT-2 file
next reads 20th line / row, write to the OUTPUT-2 file


I have tried various ways but some how i am ONLY able to do i simple
read from one file and write to another.

There are 3024 rows / lines PER file and there are 24 such file I need
to run the programme on.

I really need this on an urgent basis. can some one please help me in this.

Thanks in Advance

Nitin

  
Write a function that takes a pair of filenames and the starting line # 
to begin reading.  Then call it in a loop from 14 through 19.  And call 
that loop for each input file.


The loop inside the function body could be as simple as (untested):

   for line in itertools.islice(infile, startnum, 10**6, 5):
 outfile.write(line)


DaveA

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] word_probles.py

2010-08-08 Thread Dave Angel



Shurui Liu wrote:
Okay. I am using WinXP, Python 3.1 on my workstation. 
And this is the Python version information I got from putty.exe: 
Python 2.5.4 (r254:67916, Apr 13 2009, 18:09:11)

[GCC 4.2.1 20070719  [FreeBSD]] on freebsd7


You cannot use the same python source on 2.5 as you do in 3.1, 
regardless of OS platform.  For just about any non-trivial program, the 
differences will get you compile errors on one or the other.


If you're targeting 2.5 on the remote machine, you'd better be 
developing/testing with 2.5 on your own.  You still might have OS 
differences, but they're more likely to be manageable.


For an example of a gross difference, look at print.

In 2.5, print is a statement, and takes particular syntax following the 
word print.


In 3.x, print() is a function, and must have a standard argument list.  
This means that some options that you might have used in 2.5 will just 
be syntax errors.  And conversely, it means the print function may be 
called inside an expression, which would be totally illegal on 2.5.  It 
is possible to build a string ahead of time, and enclose a single string 
in parentheses (effectively ignored on 2.5), and get something that 
works on both platforms.


Alternatively, there's the 2to3 converter, but that's a nuisance at 
best.  Useful for one-time conversion, and for those situations that 
absolutely must run on both platforms, but otherwise a pain to keep both 
versions of the source up to date.  And you'd still have to test with 
2.5 before deploying to an unsuspecting user.


DaveA

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] word_probles.py

2010-08-08 Thread Walter Prins

Hi,

On 08/08/10 20:01, Shurui Liu wrote:

Okay. I am using WinXP, Python 3.1 on my workstation.
And this is the Python version information I got from putty.exe:
Python 2.5.4 (r254:67916, Apr 13 2009, 18:09:11)
[GCC 4.2.1 20070719  [FreeBSD]] on freebsd7


To add a small comment to what Dave's already said, please refer to the 
official documentation here:

http://docs.python.org/release/3.0.1/whatsnew/3.0.html

The net result for you is, I think, that you should be using Python 2.x 
on your Windows XP box, and not Python 3.x.


Regards,

Walter
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Distributing Python Code for Commercial Porpoises?

2010-08-08 Thread Steven D'Aprano
On Mon, 9 Aug 2010 04:44:37 am David Hutto wrote:

> Four words... Software is python's propaganda.

Four more words: please trim unnecessary quoting.


-- 
Steven D'Aprano
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Need a mentor

2010-08-08 Thread Ranjith Kumar
Hi all,
I`m doing a python based project, I need a mentor who can guide me and
help me to complete the project. the idea is fully based upon application
programming. What I want is just suggest me how to implement so that I write
the code and send it back to you. And there you can check the codes and find
the better solution or giving me some other ideas so that we can optimize
the code and bring a better solution. I`m glad to work on python if anyone
interested in this please kindly let me know it. Awaiting for your reply.

-- 
Cheers
Ranjith,

http://ranjith10z.wordpress.com
http://ranjithtenz.wordpress.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] os.urandom()

2010-08-08 Thread Richard D. Moores
On Sun, Aug 8, 2010 at 08:11, bob gailer  wrote:
> On 8/8/2010 1:57 AM, Richard D. Moores wrote:

>> How were we supposed to know that all the hexes have 2 digits?
>
> In version 2.6.5 Language Reference 2.4.1 - String literals:
> \xhh Character with hex value hh

But
>>> os.urandom(6)
b'\x13\xf1\x138a\xcc'

In my Active Python 3.1 docs, Language Ref 2.4.1. String and Bytes
literals, I have

The same as what you quoted, plus a couple of footnotes:
\xhh Character with hex value hh (2,3)

That footnote 2, "Unlike in Standard C, at most two hex digits are
accepted.", seems necessary; otherwise that \x138a could be seen by my
former, byte-ignorant self as a \x, and puzzled about why I got
only 4 bytes, not 6.  :)

But I never would have thought to have looked in the docs where you did.

Dick
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Idea for a 'Weekly Python Tips' mailing list

2010-08-08 Thread Richard D. Moores
On Fri, Aug 6, 2010 at 10:51, Lie Ryan  wrote:

> In the main python list there is Python Weekly URL that summarizes the
> week's most interesting posts in c.l.py

The latest of these I have received is dated June 22. Summer vacation?
Or discontinued?

Dick Moores
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Idea for a 'Weekly Python Tips' mailing list

2010-08-08 Thread Richard D. Moores
On Sun, Aug 8, 2010 at 21:25, Richard D. Moores  wrote:
> On Fri, Aug 6, 2010 at 10:51, Lie Ryan  wrote:
>
>> In the main python list there is Python Weekly URL that summarizes the
>> week's most interesting posts in c.l.py
>
> The latest of these I have received is dated June 22. Summer vacation?
> Or discontinued?

A Gmane search shows that there are frequent gaps.


Dick Moores
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Reading every 5th line

2010-08-08 Thread nitin chandra
Hello Dave,

Thank you very much. This solution worked out very well.

And I liked your style of coding  ' In less DO more '.

Thank You once again.

Nitin

PS :- I tried to use a file pointer with raw_input, but that did not work.


>
> This may help you get started.
>
> FileNames = ["FileName01", "FileName02", ..., "FileName24"]
> for File in FileNames:
>   List = open(File, 'r').readlines()
>   for Start in [[14, "%s-1" % File], [15,"%s-2" % File]]:
>       OutList = []
>       for Line in range(Start[0]-1, 3024, 5):
>           OutList.append(List[Line])
>       open(("%s.txt" % Start[1]), 'w').writelines(OutList)
>
> P.S. My code writing style isn't very conventional.
>
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Fwd: Need mentor

2010-08-08 Thread Ranjith Kumar
Hi all,

I have described the theme of my project here,
When the script is runned a configuring window has to be displayed where
the user has to configure for there desired Web Browser, Audio Player, Video
Player, Text Editor (Each Specified in separate SS Tab). Here the script
should retrieve all installed Web Browser, Audio Player, Video Player and
Text Editor and categorized and displayed in their corresponding tab`s. Here
the user has to choose and set their preferred Web Browser, Video Player,
Audio Player, Text Editor and update the configure file.

note 1: configuring window should run automatically only first if the user
wants to reconfigure the file again they should run configuring module
alone
note 2: This script is to start it on every login and stay running on
background until i shut download the machine.

For an example, this is complete real time behavior of the script.
Let us consider I`m the user I downloaded the script and runned it, It
should check for a configuring file if there is no configure file is created
means it should automatically create a new configure file and displays a
configuring window in that window I will be offered by whatever the web
browsers, audio player, video player, text editor installed on my machine
will has to be shown to me in their corresponding tab`s I have to set my
desired web browser if I choose chrome has my prefered web browser and
whenever I press the key "w" on desktop screen the chrome browser should be
opened, I have to set my desired Audio player if I choose exaile has
my preferred audio player and whenever I press the key "a" on desktop screen
the Exaile audio player should be opened,I have to set my desired video
player if I choose vlc has my prefered video player and whenever I press the
key "v" on desktop screen the vlc player should be opened, I have to set my
desired text editor if I choose gedit has my prefered text editor and
whenever I press the key "t" on desktop screen the Gedit text editor should
be opened, this just like creating hotkeys and all these configured details
should be updated when I click on apply and exits the configuring windows
and runs the script at the desktop background while i`m in desktop when i
just hit "w" chrome browser should opened

-- 
Cheers
Ranjith,

http://ranjith10z.wordpress.com
http://ranjithtenz.wordpress.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Need a mentor

2010-08-08 Thread Steven D'Aprano
On Mon, 9 Aug 2010 12:16:11 pm Ranjith Kumar wrote:
> Hi all,
> I`m doing a python based project, I need a mentor who can guide
> me and help me to complete the project.

Are you offering to pay for professional help for a commercial project, 
looking for volunteers to work on an open-source project with you, or 
just looking for a kind and generous soul who is happy to donate many, 
many hours of work teaching you application development in Python?


-- 
Steven D'Aprano
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor