[Tutor] question about a exercise

2012-01-05 Thread daedae11
The exercise is:

Write a function which has 3 parameters. First parameter is a char, second 
parameter is a integer, third parameter is a integer.
The function would create a file which have following requests:
1. the length of the file is in accordance with the third parameter.
2. the content of the file must be random generated.
3. the time first parameter occurred in the content must be in accordance with 
second parameter.

please give me some hints. It would be better if you give me the code.




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


Re: [Tutor] question about a exercise

2012-01-05 Thread Alexander
On Thu, Jan 5, 2012 at 10:22 AM, daedae11  wrote:

> **
> The exercise is:
>
> Write a function which has 3 parameters. First parameter is a char, second
> parameter is a integer, third parameter is a integer.
> The function would create a file which have following requests:
> 1. the length of the file is in accordance with the third parameter.
> 2. the content of the file must be random generated.
> 3. the time first parameter occurred in the content must be in accordance
> with second parameter.
>
> please give me some hints. It would be better if you give me the code.
>
> --
> daedae11
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
> You're likely going to get patronized for asking for the code as if you're
asking for someone to do your homework problem for you.
-- 
Alexander
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] question about a exercise

2012-01-05 Thread Wayne Werner
On Thu, Jan 5, 2012 at 9:22 AM, daedae11  wrote:

> **
> The exercise is:
>
> Write a function which has 3 parameters. First parameter is a char, second
> parameter is a integer, third parameter is a integer.
> The function would create a file which have following requests:
> 1. the length of the file is in accordance with the third parameter.
> 2. the content of the file must be random generated.
> 3. the time first parameter occurred in the content must be in accordance
> with second parameter.
>
> please give me some hints. It would be better if you give me the code.
>

It would be better if /you/ gave us the code that shows what you've tried.
Also, if we give you the solution(s) then you won't learn.

To accomplish this exercise you need a few skills:

1. Write a function that takes parameters - can you do this?
2. Create a file - can you do this?
3. Generate random text - can you do this?
4. Modify text (or generate slightly less-random text) - can you do this?

If you can do those four things then you should be able to easily
accomplish this task (that looks an awful lot like homework)

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


[Tutor] Using Python for a client interactive map application

2012-01-05 Thread Alexander
Dear friends,
I'm emailing regarding a general question about working with Python and a
web-browser based interactive map application. Over the summer I had asked
a similar question and heard some things about the Django framework, does
anybody have any other suggestions? For example there is a server with all
the info about a map, and from a browser a user will be able to view and
interact with the map at high speeds.
And please remember to reply to all.
Thanks,
-- 
Alexander
7D9C597B
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Game lag

2012-01-05 Thread Hugo Arts
On Thu, Jan 5, 2012 at 3:56 PM, Nate Lastname  wrote:
> Hello all,
>
> The attached zip file contains a file called 'cameramovement.py'.  As you
> can see, this file is extremely laggy.  After searching through my code, I
> can't find anything that is slowing it down.  Could someone help me out?  It
> takes a while to load due to a large map.  This is not the problem.
>
> Thanks,
> The Defenestrator
>
> P.S. Yes, I am new here.  Hello, all!
>

1) although posting here is a good idea, you're gonna be better off
asking the pygame mailing list about this as well, they're the experts
2) that's a lot of code for me to read all in my spare time man, isn't
there any way you can simplify it or strip out unnecessary parts?
3) did you profile it? Do this! Now! rather than guess where your code
is slow, this will tell you exactly. Use cProfile:

http://docs.python.org/library/profile.html

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


Re: [Tutor] Using Python for a client interactive map application

2012-01-05 Thread James Reynolds
On Thu, Jan 5, 2012 at 10:58 AM, Alexander  wrote:

> Dear friends,
> I'm emailing regarding a general question about working with Python and a
> web-browser based interactive map application. Over the summer I had asked
> a similar question and heard some things about the Django framework, does
> anybody have any other suggestions? For example there is a server with all
> the info about a map, and from a browser a user will be able to view and
> interact with the map at high speeds.
> And please remember to reply to all.
> Thanks,
> --
> Alexander
> 7D9C597B
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
>

Django will (most likely) do what it is you want it to do, but you will
also need some javascript. For my current project, I'm using JQuery, but I
happen to know that Dojo has an interactive
mapfeature
in their toolset, so I would check that out dojo.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Game lag

2012-01-05 Thread Nate Lastname
Thanks for the profilers - never had hear of 'em. Also, no, I cannot strip
out unnecessary parts, 'cuz I don't know what part is slowing it down.
 Thanks a lot, though Hugo.

On Thu, Jan 5, 2012 at 11:02 AM, Hugo Arts  wrote:

> On Thu, Jan 5, 2012 at 3:56 PM, Nate Lastname  wrote:
> > Hello all,
> >
> > The attached zip file contains a file called 'cameramovement.py'.  As you
> > can see, this file is extremely laggy.  After searching through my code,
> I
> > can't find anything that is slowing it down.  Could someone help me out?
>  It
> > takes a while to load due to a large map.  This is not the problem.
> >
> > Thanks,
> > The Defenestrator
> >
> > P.S. Yes, I am new here.  Hello, all!
> >
>
> 1) although posting here is a good idea, you're gonna be better off
> asking the pygame mailing list about this as well, they're the experts
> 2) that's a lot of code for me to read all in my spare time man, isn't
> there any way you can simplify it or strip out unnecessary parts?
> 3) did you profile it? Do this! Now! rather than guess where your code
> is slow, this will tell you exactly. Use cProfile:
>
> http://docs.python.org/library/profile.html
>
> HTH,
> Hugo
>



-- 
My Blog - Defenestration Coding

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


Re: [Tutor] Using Python for a client interactive map application

2012-01-05 Thread Hugo Arts
On Thu, Jan 5, 2012 at 5:04 PM, James Reynolds  wrote:
>
>
> On Thu, Jan 5, 2012 at 10:58 AM, Alexander  wrote:
>>
>> Dear friends,
>> I'm emailing regarding a general question about working with Python and a
>> web-browser based interactive map application. Over the summer I had asked a
>> similar question and heard some things about the Django framework, does
>> anybody have any other suggestions? For example there is a server with all
>> the info about a map, and from a browser a user will be able to view and
>> interact with the map at high speeds.
>> And please remember to reply to all.
>> Thanks,
>> --
>> Alexander
>> 7D9C597B
>>
>
>
> Django will (most likely) do what it is you want it to do, but you will also
> need some javascript. For my current project, I'm using JQuery, but I happen
> to know that Dojo has an interactive map feature in their toolset, so I
> would check that out dojo.
>

It sounds like the web server should do two jobs in this case:

1. deliver the javascript and assorted code that will draw the map,
along with a little html/css
2. respond to ajax requests from the javascript to deliver map data

any reasonable web framework will be able to do this just fine. Django
might even be a bit heavyweight for such a relatively simple task
(simple on the server side, that is). But there's nothing wrong with
using it anyway, if you're comfortable with it. Performance isn't
going to be an issue. You have a myriad of other options as well:
web2py, web.py, turbogears, pylons, cherrypy, you name it. Any of
these will do the job. If you already know one, I'd say pick that.
Otherwise, find one that looks simple and just go with it.

As for the format you'll be sending the map data in, I'd suggest json.
It's simple, easily read by humans and both python and javascript have
excellent tools for parsing and dumping (check out the json built-in
library for python).

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


[Tutor] question about gzip module

2012-01-05 Thread daedae11
Is there anyone who can give me an example of how to use the gzip module?
I have read the document, but there is no example in the document.
Thank you!!




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


Re: [Tutor] question about gzip module

2012-01-05 Thread lzantal
Good morning,

I learned it (and many other modules) from pymotw.
Here is a direct link to the gzip week.
http://www.doughellmann.com/PyMOTW/gzip/index.html#module-gzip

lzantal



On Jan 5, 2012, at 7:45 AM, daedae11 wrote:

> Is there anyone who can give me an example of how to use the gzip module?
> I have read the document, but there is no example in the document.
> Thank you!!
>  
> daedae11
> ___
> Tutor maillist  -  Tutor@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] question about gzip module

2012-01-05 Thread Walter Prins
Hi,

On 5 January 2012 15:45, daedae11  wrote:
> Is there anyone who can give me an example of how to use the gzip module?
> I have read the document, but there is no example in the document.

Which document are you referring to?   The Official Python
documentation does in fact contain examples also (See 12.2.1):
http://docs.python.org/library/gzip.html


(But +1 for PyMOTW as mentioned by Izantal.)

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


Re: [Tutor] Using Python for a client interactive map application

2012-01-05 Thread Alan Gauld

On 05/01/12 15:58, Alexander wrote:


framework, does anybody have any other suggestions? For example there is
a server with all the info about a map, and from a browser a user will
be able to view and interact with the map at high speeds.


High speeds? On a web application?
That usually means JavaScript and Ajax.

That's a non trivial application. It sounds a lot like Google maps?

Have you ever, just for fun, taken a look at the page source on a Google 
maps web page? You probably won't need all of the features of Google 
Maps but it might give you some idea of the scale of your challenge!


Now, accessing a map and displaying it and even making it mouse aware, 
that's a much easier task, but it may not be "high speed"...


HTH,

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

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


Re: [Tutor] Using Python for a client interactive map application

2012-01-05 Thread Alexander
On Thu, Jan 5, 2012 at 12:16 PM, Alan Gauld wrote:

> On 05/01/12 15:58, Alexander wrote:
>
>  framework, does anybody have any other suggestions? For example there is
>> a server with all the info about a map, and from a browser a user will
>> be able to view and interact with the map at high speeds.
>>
>
> High speeds? On a web application?
> That usually means JavaScript and Ajax.
>
> That's a non trivial application. It sounds a lot like Google maps?
>
> Have you ever, just for fun, taken a look at the page source on a Google
> maps web page? You probably won't need all of the features of Google Maps
> but it might give you some idea of the scale of your challenge!
>
> Now, accessing a map and displaying it and even making it mouse aware,
> that's a much easier task, but it may not be "high speed"...
>
> HTH,
>
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
>
>
> __**_
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/**mailman/listinfo/tutor
>

Yes I'm a little familiar with ajax. My freshman year I did a presentation
on ajax and google maps. Fortunately the scale of this project is far
easier and less complex than Google maps, which I find contain far more
data.

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


[Tutor] Return to my python26.dll & python.dll problems on bootup

2012-01-05 Thread Wayne Watson

  
  
I have two problems upon bootup of my Win7 PC, 64-bit.

1.  This may or may not be related to #2, which is the more
important of the two, I think.
C:\Program Files9x86)\Uniblue\DriverScanner\Python26.dll not
installed. What is Uniblue you ask? I installed a new version of the
video program Winamp back in early Nov, and it had some selections. 
One of which was to include Uniblue Driver Checker.  I thought I'd
give it a try. 

After the install completed, I thought I'd give it a  try. It goes
through all your drivers to find which ones are out of date.
Surprise. You can buy the latest ones through them. I uninstalled
Uniblue, but as it turns out, it was an incomplete uninstall.  I
spent the 30-45 minutes trying to get it uninstalled. Finally, I
sent an e-mail on how to do it to them. Never got an answer. Next is
Winamp. I have no idea how it got entangled with Python 2.6. 

2.

This

  appears too: Specified module could not be found:Module could not
  be found. Load Lib, python.dll







Python works fine.  What's the problem?

-- 
   Wayne Watson (Watson Adventures, Prop., Nevada City, CA)

 (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
  Obz Site:  39° 15' 7" N, 121° 2' 32" W, 2700 feet

 CE 1955 October 20 07:53:32.6 UT 
-- "The Date" The mystery unfolds.

Web Page: 



  

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


Re: [Tutor] Return to my python26.dll & python.dll problems on bootup

2012-01-05 Thread Steven D'Aprano

Wayne Watson wrote:

  I have two problems upon bootup of my Win7 PC, 64-bit.


Wayne, I sympathize with your problems, but they are Windows problems, not 
Python problems, and have absolutely nothing to do with learning to program 
Python. You are spamming this mailing list with off-topic questions about 
fixing your Windows system. This list is about learning Python programming, 
not "we'll fix any problem that has some vague connection to Python, no matter 
how slight". Have you tried asking for help on Windows-related forums or 
mailing lists?


It has been many years since I've used Windows regularly, but I can tell you 
this: you don't do yourself any favours by installing and uninstalling 
programs under Windows. I know it is less than helpful, but my advice is 
*never* install any program you aren't sure you will want to keep, because 
uninstalling always leaves traces of crud behind, eventually leading to 
exactly the sorts of problems you are experiencing.




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


[Tutor] Still the Python Challenge - Conclusion

2012-01-05 Thread Joaquim Santos
Hi List!

I just want to say thank you to all that helped me out!
I've now seen the errors I was doing and how to correct them. Now it
works as it should. I'll be sure to come back with more questions! And
one day help out someone else!

This is my script (I know that I only verify a small range but it
works for what I want for now...)

import string

def decrypt(cypheredText, shiftedCypherNumber):
'''
This function will take two arguments. The first is the cyphered text,
the second
is the number of characters we need to shift the text so we can decrypt it.
This is a Caesar cypher.
'''

textTranslated = list()

for letter in cypheredText:

asciiValue = ord(letter)


if asciiValue in range(97, 123):
asciiValue += shiftedCypherNumber

if asciiValue > 122:
asciiValue -= 26

newLetter = chr(asciiValue)


textTranslated.append(newLetter)

joinedText = ''.join(textTranslated)

return joinedText


text = 'g fmnc wms bgblr rpylqjyrc gr zw fylb'

a = decrypt(text, 2)

print a

and this is the end result:

i hope you didnt translate it by hand
-- 

Joaquim Santos

http://js-vfx.com

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


Re: [Tutor] Still the Python Challenge - Conclusion

2012-01-05 Thread Robert Sjoblom
On 5 January 2012 19:41, Joaquim Santos  wrote:
> Hi List!
[...]
> This is my script (I know that I only verify a small range but it
> works for what I want for now...)
>
> import string
>
> def decrypt(cypheredText, shiftedCypherNumber):
>    '''
> This function will take two arguments. The first is the cyphered text,
> the second
> is the number of characters we need to shift the text so we can decrypt it.
> This is a Caesar cypher.
>    '''
>
>    textTranslated = list()
>
>    for letter in cypheredText:
>
>        asciiValue = ord(letter)
>
>
>        if asciiValue in range(97, 123):
>            asciiValue += shiftedCypherNumber
>
>            if asciiValue > 122:
>                asciiValue -= 26
>
>        newLetter = chr(asciiValue)
>
>
>        textTranslated.append(newLetter)
>
>    joinedText = ''.join(textTranslated)
>
>    return joinedText
>
>
> text = 'g fmnc wms bgblr rpylqjyrc gr zw fylb'
>
> a = decrypt(text, 2)
>
> print a
>
> and this is the end result:

First of all, congratulations on solving it. Second, please don't
include the answer to any python challenges to this list as future
members or people searching for help with the same particular
challenge might not want to know the answer. Thirdly, I think you
should read PEP 8 - Style Guide for Python Code, but I'll quote the
absolutely most relevant part:
>Use blank lines in functions, sparingly, to indicate logical sections.
You don't need a blank line after every line of code; in fact, it
makes it harder to read. Where does one block end and another begin?

>PEP 257 describes good docstring conventions.  Note that most importantly, the 
>""" that ends a multiline docstring should be on a line by itself, and 
>preferably preceded by a blank line,

def decrypt(cypheredText, shiftedCypherNumber):
   '''This function will take two arguments. The first is the cyphered text,
the second is the number of characters we need to shift the text
so we can decrypt it. This is a Caesar cypher.

   '''
   textTranslated = list()
   for letter in cypheredText:
   asciiValue = ord(letter)
   if asciiValue in range(97, 123):
   asciiValue += shiftedCypherNumber
   #and so on

PEP 8 is really worth reading through: http://www.python.org/dev/peps/pep-0008/
there's also a link to PEP 257 in it. If you follow most of the
suggestions in PEP 8 it will be much easier to read your code, and
because of that easier to help you.

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


Re: [Tutor] Still the Python Challenge - Conclusion

2012-01-05 Thread Joaquim Santos
Hi Robert!

Thanks for the heads up on the Style Guide. I'll read out the links
you pointed out to me.
About the script, result and Python Challenge, I  apologize,
however... in previous emails bigger pointers were given speaking
about using  'maketrans' to solve the challenge.
My way was a work around that I was trying to implement since day 1
and that can be (and maybe it will be) used as a base for a
(non-serious) deciphering program.

So, again, I'm sorry for presenting too much information, however more
important parts where said already and if people are willing to find
out by searching a list/web instead of trying out by themselves...
they are going to find it!

Cheers!

2012/1/5 Robert Sjoblom :
> On 5 January 2012 19:41, Joaquim Santos  wrote:
>> Hi List!
> [...]
>> This is my script (I know that I only verify a small range but it
>> works for what I want for now...)
>>
>> import string
>>
>> def decrypt(cypheredText, shiftedCypherNumber):
>>    '''
>> This function will take two arguments. The first is the cyphered text,
>> the second
>> is the number of characters we need to shift the text so we can decrypt it.
>> This is a Caesar cypher.
>>    '''
>>
>>    textTranslated = list()
>>
>>    for letter in cypheredText:
>>
>>        asciiValue = ord(letter)
>>
>>
>>        if asciiValue in range(97, 123):
>>            asciiValue += shiftedCypherNumber
>>
>>            if asciiValue > 122:
>>                asciiValue -= 26
>>
>>        newLetter = chr(asciiValue)
>>
>>
>>        textTranslated.append(newLetter)
>>
>>    joinedText = ''.join(textTranslated)
>>
>>    return joinedText
>>
>>
>> text = 'g fmnc wms bgblr rpylqjyrc gr zw fylb'
>>
>> a = decrypt(text, 2)
>>
>> print a
>>
>> and this is the end result:
>
> First of all, congratulations on solving it. Second, please don't
> include the answer to any python challenges to this list as future
> members or people searching for help with the same particular
> challenge might not want to know the answer. Thirdly, I think you
> should read PEP 8 - Style Guide for Python Code, but I'll quote the
> absolutely most relevant part:
>>Use blank lines in functions, sparingly, to indicate logical sections.
> You don't need a blank line after every line of code; in fact, it
> makes it harder to read. Where does one block end and another begin?
>
>>PEP 257 describes good docstring conventions.  Note that most importantly, 
>>the """ that ends a multiline docstring should be on a line by itself, and 
>>preferably preceded by a blank line,
>
> def decrypt(cypheredText, shiftedCypherNumber):
>   '''This function will take two arguments. The first is the cyphered text,
> the second is the number of characters we need to shift the text
> so we can decrypt it. This is a Caesar cypher.
>
>   '''
>   textTranslated = list()
>   for letter in cypheredText:
>       asciiValue = ord(letter)
>       if asciiValue in range(97, 123):
>           asciiValue += shiftedCypherNumber
>           #and so on
>
> PEP 8 is really worth reading through: 
> http://www.python.org/dev/peps/pep-0008/
> there's also a link to PEP 257 in it. If you follow most of the
> suggestions in PEP 8 it will be much easier to read your code, and
> because of that easier to help you.
>
> --
> best regards,
> Robert S.



-- 

Joaquim Santos

http://js-vfx.com

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


Re: [Tutor] How to Capture a key being pressed?

2012-01-05 Thread Steven D'Aprano

brandon w wrote:
How do I capture a key like the  bar or the  key? 


http://code.activestate.com/recipes/577977-get-single-keypress/



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