[Tutor] which is faster

2014-06-10 Thread diliup gabadamudalige
Hi All,

This is a Pygame related question and if not answered it's ok and I
apologise for asking. But if someone can answer it is much appreciated.

In Pygame Which is faster?

1. filling the screen with a colour
or
2. blitting an image to screen

Thank you for the time.
May you be well.


-- 
Diliup Gabadamudalige

http://www.diliupg.com
http://soft.diliupg.com/

**
This e-mail is confidential. It may also be legally privileged. If you are
not the intended recipient or have received it in error, please delete it
and all copies from your system and notify the sender immediately by return
e-mail. Any unauthorized reading, reproducing, printing or further
dissemination of this e-mail or its contents is strictly prohibited and may
be unlawful. Internet communications cannot be guaranteed to be timely,
secure, error or virus-free. The sender does not accept liability for any
errors or omissions.
**
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] python sockets

2014-06-10 Thread Jon Engle
I am trying to open ports 1025-65535 with the following code (Mostly found
online with small modifications). I am unable to "bind" anything other than
the one port which is selected as input. What am I missing and how do I
bind all the ports simultaneously?

#!/usr/bin/python   # This is server.py file
from socket import *  #import the socket library
import thread  #import the thread library

startingPort=input("\nPlease enter starting port: ")
startingPort=int(startingPort)

def setup():
##let's set up some constants
HOST = ''#we are the host
PORT = startingPort#arbitrary port not currently in use
ADDR = (HOST,PORT)#we need a tuple for the address
BUFSIZE = 4096#reasonably sized buffer for data

## now we create a new socket object (serv)
## see the python docs for more information on the socket types/flags
serv = socket( AF_INET,SOCK_STREAM)

##bind our socket to the address
serv.bind((ADDR))#the double parens are to create a tuple with one
element
serv.listen(5)#5 is the maximum number of queued connections we'll allow

serv = socket( AF_INET,SOCK_STREAM)

##bind our socket to the address
serv.bind((ADDR))#the double parens are to create a tuple with one
element
serv.listen(5)#5 is the maximum number of queued connections we'll allow
print 'listening...'
PORT=PORT+1
conn,addr = serv.accept() #accept the connection
print '...connected!'
conn.send('TEST')
conn.close()

while startingPort<65535:
thread.start_new_thread(setup())
startingPort=startingPort+1
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] which is faster

2014-06-10 Thread Alan Gauld

On 10/06/14 07:42, diliup gabadamudalige wrote:

Hi All,

This is a Pygame related question and if not answered it's ok and I
apologise for asking. But if someone can answer it is much appreciated.

In Pygame Which is faster?

1. filling the screen with a colour
 or
2. blitting an image to screen


My guess is blitting, but it is only a guess.
You'd be much better off asking the pygame community on
the pygame forum/list

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

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


Re: [Tutor] python sockets

2014-06-10 Thread Lukas Nemec

Hi,

fist - are you really triyng to have open 64 000 ports? ok, i suppose 
you have your reasons, but this is not a good idea - you'll block most 
applications that use these ports ..


The problem is with your main function -
you have PORT defined, but it is not global, it is only local, and when 
you add +1 to it, next spawned process will have PORT with previous value.


either use global PORT, or have it as a parameter for the function:

main(port):
..
PORT = port

while startingPort<65535:
thread.start_new_thread(setup(startingPort))
startingPort=startingPort+1


Lukas

On 06/10/2014 01:33 AM, Jon Engle wrote:
I am trying to open ports 1025-65535 with the following code (Mostly 
found online with small modifications). I am unable to "bind" anything 
other than the one port which is selected as input. What am I missing 
and how do I bind all the ports simultaneously?


#!/usr/bin/python   # This is server.py file
from socket import *  #import the socket library
import thread #import the thread library

startingPort=input("\nPlease enter starting port: ")
startingPort=int(startingPort)

def setup():
##let's set up some constants
HOST = ''#we are the host
PORT = startingPort#arbitrary port not currently in use
ADDR = (HOST,PORT)#we need a tuple for the address
BUFSIZE = 4096#reasonably sized buffer for data

## now we create a new socket object (serv)
## see the python docs for more information on the socket types/flags
serv = socket( AF_INET,SOCK_STREAM)

##bind our socket to the address
serv.bind((ADDR))#the double parens are to create a tuple with one 
element
serv.listen(5)#5 is the maximum number of queued connections we'll 
allow


serv = socket( AF_INET,SOCK_STREAM)

##bind our socket to the address
serv.bind((ADDR))#the double parens are to create a tuple with one 
element
serv.listen(5)#5 is the maximum number of queued connections we'll 
allow

print 'listening...'
PORT=PORT+1
conn,addr = serv.accept() #accept the connection
print '...connected!'
conn.send('TEST')
conn.close()

while startingPort<65535:
thread.start_new_thread(setup())
startingPort=startingPort+1





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


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


Re: [Tutor] python sockets

2014-06-10 Thread Alan Gauld

On 10/06/14 00:33, Jon Engle wrote:

I am trying to open ports 1025-65535 with the following code


Why would you want to do that?
It sounds like a great way to cripple your PC as it runs 64000 threads 
monitoring each of those ports. And it assumes that nothing else is 
using those ports already... And if you did find something trying to 
connect, what port is the server going to allocate? You've already 
grabbed them all?


Can you explain your rationale for trying to do this? Unless you are 
trying a brute force technique to prevent anything from connecting to 
your computer?



found online with small modifications). I am unable to "bind" anything
other than the one port which is selected as input. What am I missing
and how do I bind all the ports simultaneously?


I think you are missing the basic concepts of server computing. You 
should never need to bind all the ports at once.


However as to your code... its hard to critique because you lost the 
indentation - presumably through posting in HTML? Try using plain text 
for posting code.



#!/usr/bin/python   # This is server.py file
from socket import *  #import the socket library
import thread #import the thread library

startingPort=input("\nPlease enter starting port: ")
startingPort=int(startingPort)

def setup():

...

## now we create a new socket object (serv)
## see the python docs for more information on the socket types/flags
serv = socket( AF_INET,SOCK_STREAM)
serv.bind((ADDR))
serv.listen(5)#5 is the maximum number of queued connections we'll allow

serv = socket( AF_INET,SOCK_STREAM)
serv.bind((ADDR))
serv.listen(5)#5 is the maximum number of queued connections we'll allow



Why do you do it twice?


print 'listening...'


Is this Python 2 or 3? Your input lines above suggest its Python 3 but 
this print line suggests its Python 2. Which are you using?



PORT=PORT+1
conn,addr = serv.accept() #accept the connection
print '...connected!'
conn.send('TEST')
conn.close()


You normally put the listening code inside a loop, waiting for a 
connection, processing it and then going back to listen some more



while startingPort<65535:
thread.start_new_thread(setup())
startingPort=startingPort+1


Minor niggle, if you must do this use a for loop. Its tidier.
As a minimum you need some error handling to deal with
unsuccessful attempts to bind. And you need a better way
of processing connections.

But fundamentally, I suspect that whatever you are trying to
do there is a better approach!

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

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


Re: [Tutor] which is faster

2014-06-10 Thread Steven D'Aprano
On Tue, Jun 10, 2014 at 12:12:56PM +0530, diliup gabadamudalige wrote:

> In Pygame Which is faster?
> 
> 1. filling the screen with a colour
> or
> 2. blitting an image to screen


Why don't you time it and find out? Don't forget to come back and report 
what you discover, I'm sure I'm not the only one who would like to know 
the answer to the question.

http://pymotw.com/2/timeit/

More information here:

https://docs.python.org/2/library/timeit.html



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


Re: [Tutor] python sockets

2014-06-10 Thread Peter Otten
Lukas Nemec wrote:

> Hi,
> 
> fist - are you really triyng to have open 64 000 ports? ok, i suppose
> you have your reasons, but this is not a good idea - you'll block most
> applications that use these ports ..
> 
> The problem is with your main function -
> you have PORT defined, but it is not global, it is only local, and when
> you add +1 to it, next spawned process will have PORT with previous value.
> 
> either use global PORT, or have it as a parameter for the function:
> 
> main(port):
>  ..
>  PORT = port
> 
> while startingPort<65535:
> thread.start_new_thread(setup(startingPort))
> startingPort=startingPort+1

setup() is still called in the main thread, likely listens forever which is 
why thread.start_new_thread() is never called and therefore doesn't complain 
about the missing argument...

Try

def setup(PORT):
   ... # don't reassign port inside the function

for port in range(startingPort, 65535):
thread.start_new_thread(setup, (port,))

Note that

some_func(setup(port))

passes the result of the setup() call to some_func while

some_func(setup, (port,))

passes the setup function and a 1-tuple with the port as its only item. The 
comma is necessary to create a tuple, parentheses alone have no effect:

>>> (1)
1
>>> (1,)
(1,)


PS: You should also consider using the (higlevel) threading module instead 
of the thread module.


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


[Tutor] [OT] Long delay until my posts appear

2014-06-10 Thread Peter Otten
I'm posting via gmane. Since last month there is a delay (usually a few 
hours I think) until my posts appear and I seem to be getting a

"Your message to Tutor awaits moderator approval, would you like to 
cancel..."

mail every time I post. I'm trying hard to not get annoyed ;)

Is there something I can do to go back to how it used to work (post appears 
within minutes, no helpful spam)?

Thank you.

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


Re: [Tutor] Tutor Digest, Vol 124, Issue 21

2014-06-10 Thread Jon Engle
Thank you for taking the time to help me understand, here is what I am
trying to accomplish:

Client FW Server
-
1024 | Allow |   1024
1025 | Deny | 1025
1026   | Allow | 1026
65535  |  | 65535

I am trying to test the outbound configuration of a firewall (treat it like
a black box) for purposes of validating current configurations. The client
side of this is pretty straightforward but the server side is where I run
into issues. I am trying to keep this as simple as possible as I am pretty
new to Python. One of the challenges I see is not having a communications
channel between the client and the server. In the example above what
happens when port 1025 is blocked outbound and the client never receives a
response from the server? How would I make the client and the server
synchronize ports? I considered timers but again I am trying to keep this
simple. So that is what lead me to the path of binding all the ports at
once so that the client doesn't have to care what the server did/did not
receive. In my case I felt that binding all the server ports at once,was
the simplest solution but I am certainly open to other/better ways. I am
currently using python 2.7.5





On Tue, Jun 10, 2014 at 6:00 AM,  wrote:

> Send Tutor mailing list submissions to
> tutor@python.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
> https://mail.python.org/mailman/listinfo/tutor
> or, via email, send a message with subject or body 'help' to
> tutor-requ...@python.org
>
> You can reach the person managing the list at
> tutor-ow...@python.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Tutor digest..."
>
>
> Today's Topics:
>
>1. Re: python sockets (Alan Gauld)
>
>
> --
>
> Message: 1
> Date: Tue, 10 Jun 2014 08:35:34 +0100
> From: Alan Gauld 
> To: tutor@python.org
> Subject: Re: [Tutor] python sockets
> Message-ID: 
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> On 10/06/14 00:33, Jon Engle wrote:
> > I am trying to open ports 1025-65535 with the following code
>
> Why would you want to do that?
> It sounds like a great way to cripple your PC as it runs 64000 threads
> monitoring each of those ports. And it assumes that nothing else is
> using those ports already... And if you did find something trying to
> connect, what port is the server going to allocate? You've already
> grabbed them all?
>
> Can you explain your rationale for trying to do this? Unless you are
> trying a brute force technique to prevent anything from connecting to
> your computer?
>
> > found online with small modifications). I am unable to "bind" anything
> > other than the one port which is selected as input. What am I missing
> > and how do I bind all the ports simultaneously?
>
> I think you are missing the basic concepts of server computing. You
> should never need to bind all the ports at once.
>
> However as to your code... its hard to critique because you lost the
> indentation - presumably through posting in HTML? Try using plain text
> for posting code.
>
> > #!/usr/bin/python   # This is server.py file
> > from socket import *  #import the socket library
> > import thread #import the thread library
> >
> > startingPort=input("\nPlease enter starting port: ")
> > startingPort=int(startingPort)
> >
> > def setup():
> ...
> > ## now we create a new socket object (serv)
> > ## see the python docs for more information on the socket types/flags
> > serv = socket( AF_INET,SOCK_STREAM)
> > serv.bind((ADDR))
> > serv.listen(5)#5 is the maximum number of queued connections we'll
> allow
> >
> > serv = socket( AF_INET,SOCK_STREAM)
> > serv.bind((ADDR))
> > serv.listen(5)#5 is the maximum number of queued connections we'll
> allow
>
>
> Why do you do it twice?
>
> > print 'listening...'
>
> Is this Python 2 or 3? Your input lines above suggest its Python 3 but
> this print line suggests its Python 2. Which are you using?
>
> > PORT=PORT+1
> > conn,addr = serv.accept() #accept the connection
> > print '...connected!'
> > conn.send('TEST')
> > conn.close()
>
> You normally put the listening code inside a loop, waiting for a
> connection, processing it and then going back to listen some more
>
> > while startingPort<65535:
> > thread.start_new_thread(setup())
> > startingPort=startingPort+1
>
> Minor niggle, if you must do this use a for loop. Its tidier.
> As a minimum you need some error handling to deal with
> unsuccessful attempts to bind. And you need a better way
> of processing connections.
>
> But fundamentally, I suspect that whatever you are trying to
> do there is a better approach!
>
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> http://www.flickr.com/photos/alangauldphotos
>
>
>
> --
>
> Subject: Digest Footer
>
> _

[Tutor] python ODE and DAE solver

2014-06-10 Thread He Yang
Hi,

I use Maple for my modelling work, and now I am considering switching to 
Python. Lately, I've spend some time on the documentation of python and SciPy( 
python based maths package), but only managed to find a ODE solver, can someone 
familiar with python ODE and DAE solver  send me more information about those 
solvers, thanks in advance. in addition, i am trying to employ cloud computing 
servers to solve equations, i am not sure whether the server would allow me to 
link python and other programming languages like C or Fortran, anyone knows 
this?


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


Re: [Tutor] [OT] Long delay until my posts appear

2014-06-10 Thread Alan Gauld

On 10/06/14 09:43, Peter Otten wrote:

I'm posting via gmane. Since last month there is a delay (usually a few
hours I think) until my posts appear and I seem to be getting a

"Your message to Tutor awaits moderator approval, would you like to
cancel..."


Something has changed on the list server which means that any time 
someone edits their settings it automatically sets up full moderation.

Presumably you changed a setting somewhere...

Anyway I have now gone in and switched off moderation for your account.
Normal service should have resumed.


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

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


Re: [Tutor] python ODE and DAE solver

2014-06-10 Thread Alan Gauld

On 10/06/14 13:07, He Yang wrote:


I use Maple for my modelling work, and now I am considering switching to
Python. Lately, I've spend some time on the documentation of python
and SciPy( python based maths package), but only managed to find a ODE
solver, can someone familiar with python ODE and DAE solver  


There is a dedicated Numpy/Scipy mailing list, you will probabnly
get better results asking there.

This list is really for core Python and the standard library.
There are a few scipy users here though so you may get lucky...

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

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


Re: [Tutor] which is faster

2014-06-10 Thread William Ray Wing
On Jun 10, 2014, at 2:42 AM, diliup gabadamudalige  wrote:

> Hi All,
> 
> This is a Pygame related question and if not answered it's ok and I apologise 
> for asking. But if someone can answer it is much appreciated.
> 
> In Pygame Which is faster?
> 
> 1. filling the screen with a colour
> or
> 2. blitting an image to screen
> 
> Thank you for the time.
> May you be well.
> 
> 
> -- 
> Diliup Gabadamudalige
> 

I don’t use Pygame, but it seems to me the answer is likely to depend on what 
graphics hardware is available on the computer in question.

-Bill



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


[Tutor] code review

2014-06-10 Thread Adam Gold
Hi there.  I've been writing a script that is now finished and working
(thanks, in part, to some helpful input from this board).  What I'd
really like to do now is go through it with an 'expert' who can point
out ways I may have been able to code more efficiently/effectively.  I
don't think it would be appropriate to post the whole script here and
ask "how could I do this better" (!) so I was wondering if anyone knows
of ways for python noobs to connect with python experts for this sort of
exercise.  I understand people can be really busy so I'm happy to pay
for someone's time if necessary.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] python sockets

2014-06-10 Thread Jon Engle
Thank you for your help! This updated code does not "bind" the selected
port to a "listen" state, it simply exits. I feel like part of this has to
do with the creation of a procedure. Any ideas/recommendations on how to
make this loop "bind" to a socket?

#!/usr/bin/python   # This is server.py file
from socket import *  #import the socket library
import thread  #import the thread library

startingPort=input("\nPlease enter starting port: ")
startingPort=int(startingPort)

def setup(PORT):
 ##let's set up some constants
HOST = ''#we are the host
PORT = startingPort#arbitrary port not currently in use
ADDR = (HOST,PORT)#we need a tuple for the address
BUFSIZE = 4096#reasonably sized buffer for data

## now we create a new socket object (serv)
## see the python docs for more information on the socket types/flags
serv = socket( AF_INET,SOCK_STREAM)

##bind our socket to the address
serv.bind((ADDR))#the double parens are to create a tuple with one
element
serv.listen(5)#5 is the maximum number of queued connections we'll allow
print 'listening...'
conn,addr = serv.accept() #accept the connection
print '...connected!'
conn.send('TEST')
conn.close()

for port in range (startingPort, 65535):
thread.start_new_thread(setup, (port,))
startingPort=startingPort+1
#print startingPort
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Simple python help

2014-06-10 Thread Joel Goldstick
On Jun 10, 2014 3:14 PM, "Stephen Brazil"  wrote:
>
> Hello! I am brand new to python and need to know how to make the attached
lines of code work. Should be pretty self-explanatory.
>
>
You need to quote 'Stephen' ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Simple python help

2014-06-10 Thread Mark Lawrence

On 10/06/2014 15:55, Stephen Brazil wrote:

Hello! I am brand new to python and need to know how to make the
attached lines of code work. Should be pretty self-explanatory.



I am not responding to Stephen and his amazing technicolour code, sorry :-(

--
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.


Mark Lawrence

---
This email is free from viruses and malware because avast! Antivirus protection 
is active.
http://www.avast.com


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


Re: [Tutor] python sockets

2014-06-10 Thread Matthew Ngaha
On Tue, Jun 10, 2014 at 5:28 PM, Jon Engle  wrote:
>
> startingPort=input("\nPlease enter starting port: ")
> startingPort=int(startingPort)
>
> def setup(PORT):
>  PORT = startingPort#arbitrary port not currently in use

There's a conflict with this PORT variable.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Simple python help

2014-06-10 Thread Marc Tompkins
On Tue, Jun 10, 2014 at 7:55 AM, Stephen Brazil  wrote:

>  Hello! I am brand new to python and need to know how to make the attached
> lines of code work. Should be pretty
>

You need quotes.

Stephen (without quotes) is an object, which you haven't previously
defined.  'Stephen' is a string, which can be compared to person.

Which version of Python are you using?  If it's 2.x, PLEASE don't use
input() - use raw_input() instead.  In 3.x, input() does what raw_input()
used to, so it's cool.

Finally, you're likely to catch some grief for posting your code as a
picture; in future, post code as plain text.  (Sure, we won't see the nifty
syntax highlighting, but that's OK!)  Every single post to this list that's
anything but plain text generates at least one complaint; it significantly
lowers the signal-to-noise ratio.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Simple python help

2014-06-10 Thread Joel Goldstick
On Jun 10, 2014 3:14 PM, "Stephen Brazil"  wrote:
>
> Hello! I am brand new to python and need to know how to make the attached
lines of code work. Should be pretty self-explanatory.
>
>
Also, copy and paste code. Use text only not rtfm or html to post.  Lose
the curly braces.  Python doesn't need them
___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] python sockets

2014-06-10 Thread Marc Tompkins
On Tue, Jun 10, 2014 at 9:28 AM, Jon Engle  wrote:


> for port in range (startingPort, 65535):
> thread.start_new_thread(setup, (port,))
>  startingPort=startingPort+1
> #print startingPort
>

I think you just need this:

for port in range (startingPort, 65535):
> thread.start_new_thread(setup(port))
> #print port
>

and inside of setup, get rid of this line:
PORT = startingPort#arbitrary port not currently in use
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] python sockets

2014-06-10 Thread Marc Tompkins
On Tue, Jun 10, 2014 at 2:00 PM, Jon Engle  wrote:

> Ok, so after making the changes the code does bind the startingPort
> variable but that is the only port that gets bound. Also when connecting to
> the startingPort I receive the following error:
>
> Please enter starting port: 65520
>
> listening...
>
> ...connected!
>
> Traceback (most recent call last):
>
>   File "response.py", line 31, in 
>
> thread.start_new_thread(setup(port))
>
> TypeError: start_new_thread expected at least 2 arguments, got 1
>

Sorry about that!  I should have read the docs
(https://docs.python.org/2/library/thread.html)
for thread.start_new_thread(); you had it right in the code you posted (it
was the rest of your loop that was a problem.)  So, change it back to:


for port in range (startingPort, 65535):
> thread.start_new_thread(setup, (port,))
> #print port
>

My apologies for the bum steer.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] which is faster

2014-06-10 Thread Steven D'Aprano
On Tue, Jun 10, 2014 at 09:57:51PM +0530, diliup gabadamudalige wrote:
> Thank you very much for the links. I will install this module, time the two
> code snippets and then share the info. Thank you very much!

You're welcome, but there is no need to install the timeit module, it is 
part of the standard library that is pre-installed with every Python 
since version 2.3 (about eleven years ago).



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


Re: [Tutor] code review

2014-06-10 Thread Steven D'Aprano
On Tue, Jun 10, 2014 at 04:51:20PM +0100, Adam Gold wrote:
> Hi there.  I've been writing a script that is now finished and working
> (thanks, in part, to some helpful input from this board).  What I'd
> really like to do now is go through it with an 'expert' who can point
> out ways I may have been able to code more efficiently/effectively.  I
> don't think it would be appropriate to post the whole script here and
> ask "how could I do this better" (!) so I was wondering if anyone knows
> of ways for python noobs to connect with python experts for this sort of
> exercise.  I understand people can be really busy so I'm happy to pay
> for someone's time if necessary.


How big is the script? A single file, or hundreds of files? Fifty lines 
of code? A thousand?

In simple English, what does it do? Does it require specialized 
knowledge to understand?

Is it available somewhere on the Internet? E.g. on Google code, github, 
sourceforge, your own personal website? Are there confidentiality 
restrictions on it?

The answer to these questions will influence the type of code review 
you get.


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


Re: [Tutor] python ODE and DAE solver

2014-06-10 Thread Steven D'Aprano
On Tue, Jun 10, 2014 at 08:07:56PM +0800, He Yang wrote:
> Hi,
> 
> I use Maple for my modelling work, and now I am considering switching 
> to Python. Lately, I've spend some time on the documentation of python 
> and SciPy( python based maths package), but only managed to find a ODE 
> solver, can someone familiar with python ODE and DAE solver send me 
> more information about those solvers, thanks in advance.

This is fairly specialised information, you might try here:

http://www.scipy.org/scipylib/mailing-lists.html

sympy includes a simple ODE solver:

http://docs.sympy.org/dev/modules/mpmath/calculus/odes.html


> in addition, 
> i am trying to employ cloud computing servers to solve equations, i am 
> not sure whether the server would allow me to link python and other 
> programming languages like C or Fortran, anyone knows this?

That will surely depend on what cloud computing servers you have access 
to, and what capabilities they offer. If you have full, unrestricted 
access to a server, then you can do anything you want. If you don't, 
then you'll need to find out what access you actually do have.



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


Re: [Tutor] Simple python help

2014-06-10 Thread Alex Kleider

On 2014-06-10 07:55, Stephen Brazil wrote:

Hello! I am brand new to python and need to know how to make the
attached lines of code work. Should be pretty self-explanatory.
[cid:40C1630E-BBA6-41A6-A641-3B1FBE3CBFB8]

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


I am curious to know if this is interpretable (i.e. does the "cid" in 
square brackets refer to anything meaningful?)
?perhaps the list strips attachments and substitutes some other 
reference?


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


Re: [Tutor] Simple python help

2014-06-10 Thread Alan Gauld

On 10/06/14 15:55, Stephen Brazil wrote:

Hello! I am brand new to python and need to know how to make the
attached lines of code work. Should be pretty self-explanatory.


Not if your mail tool doesn't display images. This is a text based list 
so your code is invisible... But on another mail reader


You have semi colons which are not needed in Python
You have curly braces which are not needed in Python
You have no quotes around your string (stephen) which are needed
You have no colons after the if or else statements, which are needed.

You need to go back to your tutorial and read it more carefully.
And remember that Python is not C/C++/Java/JavaScript/Perl or PHP...

Or try mine, especially the topic on Branching
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos

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


Re: [Tutor] code review

2014-06-10 Thread Lukas Nemec

Post it somewhere on github and I'll try to take a look at it.

Lukas

On 06/10/2014 05:51 PM, Adam Gold wrote:

Hi there.  I've been writing a script that is now finished and working
(thanks, in part, to some helpful input from this board).  What I'd
really like to do now is go through it with an 'expert' who can point
out ways I may have been able to code more efficiently/effectively.  I
don't think it would be appropriate to post the whole script here and
ask "how could I do this better" (!) so I was wondering if anyone knows
of ways for python noobs to connect with python experts for this sort of
exercise.  I understand people can be really busy so I'm happy to pay
for someone's time if necessary.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


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