shawn bright wrote:
great, saves me 15 lines.
thanks
You have 15 lines of imports?
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
ok, i have started doing this with my 4000 + line file. So far its been
working out.
i have another question about it.
i have two classes in my program that use a global object that is a socket
connection.
example:
global my_sockobj
serverhost = 'mehost.com'
serverport = 9100
my_sockobj =
i have two classes in my program that use a global object
that is a socket connection.
... code snipped
is there something tricky about passing this as a global object to
different modules that would need to use it?
Whiler its possible to use a global in this way its usually better to
Thanks Kent,
i am going with option A, the helper set, because i also need to count
the occurances and this seems to be the easiest solution.
thanks for your help.
shawn
On 1/28/07, Kent Johnson [EMAIL PROTECTED] wrote:
shawn bright wrote:
lo there all.
i have a list of lists that i
shawn bright wrote:
Thanks Kent,
i am going with option A, the helper set, because i also need to
count the occurances and this seems to be the easiest solution.
If you need the number of unique items that is just the length of the
final list. If you need the number of occurrences of each
lo there all.
i have a list of lists that i want to build, only if an item is not in the
list already.
kinda like this
new_list = []
for item in lists: # item will look something like [var1, var2, var3]
if item[0] in new_list ( only the first element of each list ) like
new_list[0][0]
shawn bright [EMAIL PROTECTED] wrote
new_list = []
for item in lists: # item will look something like [var1, var2,
var3]
if item[0] in new_list
basicly, i want to know if item[0] is one of the items[0] in my
new_list
Your pseudo code is pretty much exactly right.
What more are you
shawn bright wrote:
lo there all.
i have a list of lists that i want to build, only if an item is not in
the list already.
kinda like this
new_list = []
for item in lists: # item will look something like [var1, var2, var3]
if item[0] in new_list ( only the first element of each
lo there all,
if i have a function that sometimes needs a value passed to it and sometimes
not, is this where i use *args ?
like this
def some_function(req_var, req_var2, un_req_var):
do some stuff
return value
how would i use this if sometimes i need to process un_req_var and sometimes
2007/1/26, shawn bright [EMAIL PROTECTED]:
lo there all,
if i have a function that sometimes needs a value passed to it and
sometimes not, is this where i use *args ?
No. *args is used if there are arguments that could occur more than once.
like this
def some_function(req_var, req_var2,
shawn bright wrote:
lo there all,
if i have a function that sometimes needs a value passed to it and
sometimes not, is this where i use *args ?
No, use an optional argument.
like this
def some_function(req_var, req_var2, un_req_var):
do some stuff
return value
how would
Greetings,
You could default it to None and check in your script to see if it has changed.
def some_function(req_var, req_var2, un_req_var=None):
if un_req_var != None:
dosomething
else:
dosomethingelse
Wesley Brooks.
On 26/01/07, shawn bright [EMAIL PROTECTED] wrote:
lo
Great, gents, thanks.
tried it out and is working fine, this will clean up a lot of stuff for me.
thanks for your help !
shawn
On 1/26/07, Wesley Brooks [EMAIL PROTECTED] wrote:
Greetings,
You could default it to None and check in your script to see if it has
changed.
def
Hi Everybody,
I have a question about structuring first pygtk program now that I
have the basics working, I am moving to the next step of organizing my
program so it doesn't turn into spaghetti code. Right now, what I'm doing is
if a component of the GUI is used in more than one spot, I
On Mon, 15 Jan 2007, Kent Johnson wrote:
[EMAIL PROTECTED] wrote:
My class inherits from the date class, but I
have to type 'from datetime import date' before I can initialize the
class definition. Is there some way to avoid this ?
No, and really there is no reason to want to
Terry Carroll wrote:
An example is if you wanted to create a birthdate class, which was just
like a regular date, but also included the birthstone that corresponded to
the date. We could create a birthdate module that included a
Birthdate class:
###
import datetime
hey guys, I've been experimenting with Python's datetime module, and I
created a function that, given a person's birthdate, calculates how old that
person is. Now I want to create a class called age_calculator that does
much the same thing. My class inherits from the date class, but I have to
[EMAIL PROTECTED] wrote:
hey guys, I've been experimenting with Python's datetime module, and I
created a function that, given a person's birthdate, calculates how
old that person is. Now I want to create a class called
age_calculator that does much the same thing. My class inherits from
[EMAIL PROTECTED] wrote:
hey guys, I've been experimenting with Python's datetime module, and I
created a function that, given a person's birthdate, calculates how old
that person is. Now I want to create a class called age_calculator that
does much the same thing.
Why? You have a
Hi everyone,
I have a quick quick question joining out of order dictionary values.
For example:
I created an empty
config={}
Added some key/value pairs
config[test1]=elem1
config[test2]=elem2
config[test3]=elem3
etc
Dumped the values and joined them at the same time.
print
2007/1/11, raghu raghu [EMAIL PROTECTED]:
print \\.join((config[val2],config[val1],config[val3]))
elem2\elem1\elem3
or
print %s\\%s\\%s % (config[val2],config[val1],config[val3])
elem2\elem1\elem3
but this seems somehow uneligent.
Are there a more efficient/compact ways of doing this kind
I like this solution.
Thanks everyone for all of the suggestions.
On 1/11/07, Andre Engels [EMAIL PROTECTED] wrote:
2007/1/11, raghu raghu [EMAIL PROTECTED]:
print \\.join((config[val2]
,config[val1],config[val3]))
elem2\elem1\elem3
or
print %s\\%s\\%s %
raghu raghu wrote:
[snip original message]
To print or to retain individual values from a list,it has to be
written in the form of
config={'test1':'elem1','test2':'elem2','test3':'elem3'}
config['test4'] = 'elem4'
print config.values()
print config['test1']- To get individual values
Hi everyone,
I have a quick quick question joining out of order dictionary values.
For example:
I created an empty
config={}
Added some key/value pairs
config[test1]=elem1
config[test2]=elem2
config[test3]=elem3
etc
Dumped the values and joined them at the same time.
print
On 11/01/07, Andrew Robert [EMAIL PROTECTED] wrote:
Only some of the key/value pairs in the dictionary are needed so a
dump of all values does not work.
Also, the order in which the values are joined is important so walking
through and joining all values does not work either.
Well, a
raghu raghu wrote:
i have a clarification regarding built in function,in some scripts it
is being used and it is give n: if _name_ == '_main_'
why this is being used in the scripts?
The global variable __name__ is equal to '__main__' when the python
script is run.
If the script is imported,
hey there gents, i was wondering if anyone uses pydev ?
its a plugin for eclipse. Has lots of cool stuffs, but i don't like the way
it does code snippets,
when i paste one that is kinda long, it messes up the indentation.
anyone know a way around this ? i have posted this question on the pydev
The global variable __name__ is equal to '__main__' when the python
script is run.
If the script is imported, __name__ is something other than '__main__'
(not sure what.)
it will be the name of your module. so for foo.py, if you execute it
(as a script), __name__ == '__main__', but if you
Reply to Dave Kuhlman [EMAIL PROTECTED] 07-01-06 15:26:
It's sort of hidden, but note the restriction to string values in
the docs on the set method:
set(section, option, value)
If the given section exists, set the given option to the specified
value; otherwise raise NoSectionError. While it is
I'm trying to use ConfigParser for the first time and I'm
missing something. I have this code
import ConfigParser
import datetime
conf = ConfigParser.ConfigParser()
conf.add_section('general')
conf.set( 'general', 'revision', 0 )
conf.set( 'general', 'date',
On Sat, Jan 06, 2007 at 10:40:27PM +0100, Jan Erik Mostr??m wrote:
I'm trying to use ConfigParser for the first time and I'm
missing something. I have this code
import ConfigParser
import datetime
conf = ConfigParser.ConfigParser()
conf.add_section('general')
conf.set( 'general',
Hi,
Wow, thats much more elegant than the idea I thought of.
Thank you very much Kent!
Marshall
On 1/3/07, Kent Johnson [EMAIL PROTECTED] wrote:
Shuai Jiang (Runiteking1) wrote:
Hello,
I'm working on a program that need to parse a financial document on the
internet
using BeautifulSoup.
Thanks, Alan.
Yes, the thing is getting to be a pain to deal with at this size, i am
in-process of splitting out the classes into their own files.
Thanks for your help.
shawn
On 12/30/06, Alan Gauld [EMAIL PROTECTED] wrote:
shawn bright [EMAIL PROTECTED] wrote i
testing this right away.
shawn bright [EMAIL PROTECTED] wrote
Yes, the thing is getting to be a pain to deal with at this size, i
am
in-process of splitting out the classes into their own files.
One thing to watch is that while its easy and tempting to create
one file per class it's often better to keep dependant
Hello there all.
i have an app that has grown to about 4000 lines. It uses 6 threads and a
GTK2 GUI.
i was wondering if i could split it into seperate files that i could import.
Each thread is a class.
i did not think that this would be a problem, but some of the threads pass
information to views
shawn bright wrote:
Hello there all.
i have an app that has grown to about 4000 lines. It uses 6 threads and
a GTK2 GUI.
i was wondering if i could split it into seperate files that i could
import. Each thread is a class.
That should be fine.
i did not think that this would be a problem,
Kent, Thanks.
this is great. Yes, when i start the thread, i also pass the gtk object to
it.
kinda like this.
serial_1 = Serial1(self.serial_1_buffer, self.serial_1_view)
serial_1.start()
so i am wanting to change that, but i do not exactly know how to stop a
thread once i have it running, so
shawn bright wrote:
Kent, Thanks.
this is great. Yes, when i start the thread, i also pass the gtk object
to it.
kinda like this.
serial_1 = Serial1(self.serial_1_buffer, self.serial_1_view)
serial_1.start()
so i am wanting to change that, but i do not exactly know how to stop a
great help, and great link, thanks again.
shawn
On 12/30/06, Kent Johnson [EMAIL PROTECTED] wrote:
shawn bright wrote:
Kent, Thanks.
this is great. Yes, when i start the thread, i also pass the gtk object
to it.
kinda like this.
serial_1 = Serial1(self.serial_1_buffer,
shawn bright [EMAIL PROTECTED] wrote i
testing this right away. This long a .py script is becomming a
headache and
i think it will be easier by far if it is pulled apart somewhat.
As a general rule of thumb, any Python script (or any programming
language file for that matter!) that gets
Hi Folks,
Is it possible to catch exception raised in module A to be caught in module
B.
If yes, then please let me know how to do it.
TIA.
Regards,
Asrarahmed Kadri
--
To HIM you shall return.
___
Tutor maillist - Tutor@python.org
On 17/12/06, Asrarahmed Kadri [EMAIL PROTECTED] wrote:
Hi Folks,
Is it possible to catch exception raised in module A to be caught in
module B.
If yes, then please let me know how to do it.
You can easily test this yourself. First right a quick module, something
like this will do:
def
Asrarahmed Kadri wrote:
As far as I understand, I need to design an algorithm which computes
the padding between each bar (space between each bar) and the length
of each bar ( remember that this is a HORIZONTAL BAR CHART).
I think what you want to design is an algorithm that computes the
As far as I understand, I need to design an algorithm which computes the
padding between each bar (space between each bar) and the length of each bar
( remember that this is a HORIZONTAL BAR CHART).
I am trying to understand your email. ( Please bear with my slow
comprehension )
Regards,
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of shawn bright
Sent: Monday, November 13, 2006 11:45 AM
To: tutor-python
Subject: [Tutor] question about __init__ in a class
Hello there all.
i have a class that i need to load some class
Thats a lot better, thanks, will use it like that.-shawnOn 11/13/06, Mike Hansen [EMAIL PROTECTED]
wrote: -Original Message- From:
[EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of shawn bright Sent: Monday, November 13, 2006 11:45 AM To: tutor-python Subject: [Tutor] question
Mike Hansen wrote:
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of shawn bright
Sent: Monday, November 13, 2006 11:45 AM
To: tutor-python
Subject: [Tutor] question about __init__ in a class
Hello there all.
i have a class that i need to load
* shawn bright [EMAIL PROTECTED] [061113 19:46]:
Hello there all.
i have a class that i need to load some class variables depending on what is
passed to the class, it would either be set up using one variable or
another. The values for the class variables would be loaded from a database.
But
hey thanks, did not think about the possible consequences of the use of a built in as a variable name.-skOn 11/13/06, Andreas Kostyrka
[EMAIL PROTECTED] wrote:* shawn bright
[EMAIL PROTECTED] [061113 19:46]: Hello there all. i have a class that i need to load some class variables depending on
* shawn bright [EMAIL PROTECTED] [061113 23:51]:
hey thanks, did not think about the possible consequences of the use of a
built in as a variable name.
Well, the consequences are minimal:
a) pylint complains by default about that.
b) if you paste code into your function, you might get
I think I don't understand the OOP in python, could anyone explain why
this code works?
class example:
atribute = hello world
print example.atribute
Why you don't have to make an object of the class to access to the
atribute?
( class example:
atribute = hello world
obj =
Because your atribute is a class attribute:
class C:
ca = 123
print C.ca # 123
c1 = C()
print c1.ca# 123
c1.ca = 140
print c1.ca# 140
print C.ca # 123
c2 = C()
print c2.ca# 123
C.ca = 141
print C.ca # 141
print c1.ca# 140
print c2.ca
Andreas Kostyrka escribió:
Because your atribute is a class attribute:
class C:
ca = 123
print C.ca # 123
c1 = C()
print c1.ca# 123
c1.ca = 140
print c1.ca# 140
print C.ca # 123
c2 = C()
print c2.ca# 123
C.ca = 141
print C.ca #
I think I don't understand the OOP in python, could anyone explain why
this code works?
class example:
atribute = hello world
print example.atribute
Why you don't have to make an object of the class to access to the
atribute?
because that attribute is part of the Class
euoar [EMAIL PROTECTED] wrote in
Thank you for your answer and the examples.
So without self it is an instance variable (like static
in java/c#).
Without self it is a class attribute like static etc in C++/Java.
An instance variable is one that is unique to an instance!
Although I think
Alan Gauld wrote:
euoar [EMAIL PROTECTED] wrote in
So, in python, you can add methods at run time to an
object, and even you can add them to a class at run time?
I'm not sure about adding methods at run time, I've never
tried it but I think the magic around the self parameter
might not
Thank you folks, for your excellent answers. This is really a fantastic
place to learn python :-)
__
LLama Gratis a cualquier PC del Mundo.
Llamadas a fijos y móviles desde 1 céntimo por minuto.
http://es.voice.yahoo.com
I don't get the output I would expect from the following.
The variable clean1 gives me an empty string. But if i change the for
loop to print i[26:40] I get all the info.
what do I need to do to capture all the data to clean1?
Thanks.
a = open('arp.txt')
file = a.read()
file =
Kent Johnson [EMAIL PROTECTED] wrote
Alan Gauld wrote:
I'm not sure about adding methods at run time, I've never
Sure it works:
In [1]: class foo(object): pass
...:
In [4]: def show(self): print Hi, I'm a foo
In [5]: foo.show=show
In [6]: f.show()
Hi, I'm a foo
Cool!
I'm
Doug Potter [EMAIL PROTECTED] wrote
I don't get the output I would expect from the following.
a = open('arp.txt')
file = a.read()
file = file.split('\n')
Easier to do
file = open('arp.txt').readlines()
But file is a bad name since its an alias for open...
b = open('arplist.txt','w')
Hi Doug,
I'm not a Python guru, but shouldn't you be putting the output of
file.split('\n') into a list, and not back into a string (for clarity's
sake?).
Also, if you have two trailing newlines on the file, your final string
will be '', so you should be doing clean1.append(i[26:40]) in your
Am 31.10.2006 um 08:35 schrieb shawn bright:
hey there,
i am trying to use a graph and chart app called matplotlib, but i
cannot figgure out how to have it plot a simple chart over time.
the docs say to use the function plot_date() but i cannot seem to get
the values to agree.
I am
shawn bright wrote:
hey there,
i am trying to use a graph and chart app called matplotlib, but i cannot
figgure out how to have it plot a simple chart over time.
the docs say to use the function plot_date() but i cannot seem to get
the values to agree.
I am sending datetimes to the
ok, looks like the date2num() function on a datetime.datetime object is working. So cool.i am very new at this, so i may be back ( read probably be back ). Thanks much for the tips.i appreciate it a lot.sk
On 10/31/06, Kent Johnson [EMAIL PROTECTED] wrote:
shawn bright wrote: hey there, i am
hey there,i am trying to use a graph and chart app called matplotlib, but i cannot figgure out how to have it plot a simple chart over time.the docs say to use the function plot_date() but i cannot seem to get the values to agree.
I am sending datetimes to the charting app for x, and the y is a
Folks,
Is numpy different from Numeric; or are both one and the same ??
Kindly explain the difference ..
Regards,
Asrarahmed-- To HIM you shall return.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
Asrarahmed Kadri wrote:
Folks,
Is numpy different from Numeric; or are both one and the same ??
Kindly explain the difference ..
See
http://numpy.scipy.org/#older_array
___
Tutor maillist - Tutor@python.org
Hey there,
i have an app that runs several processes as threads.
using the threading.Thread()
now, i have another app that does the same thing. Now, pretty soon, we
will be combining all the features of the two packages together into
one app.
My question is, is there a limit on how many threads
shawn bright wrote:
Hey there,
i have an app that runs several processes as threads.
using the threading.Thread()
now, i have another app that does the same thing. Now, pretty soon, we
will be combining all the features of the two packages together into one
app.
My question is, is
Doug Potter wrote:
for i in routers:
os.system('/bin/touch' %s) % i
of course this dosn't work.
Is there a simple way to get this done?
Yep, someone already answered that you can create the file in write mode
and then close it, but I wanted to add a little more in why your
solution
Hi,
I at trying to create a bunch of text files in a single directory on a
Linux system,
something like this.
import os
routers = ['adnc-6321', 'adnp-2341', 'adnw-2632']
for i in routers:
os.system('/bin/touch' %s) % i
of course this dosn't work.
Is there a simple way to get this done?
Doug Potter wrote:
Hi,
I at trying to create a bunch of text files in a single directory on a
Linux system,
something like this.
import os
routers = ['adnc-6321', 'adnp-2341', 'adnw-2632']
for i in routers:
os.system('/bin/touch' %s) % i
of course this dosn't work.
try
This morning I was sternly warned by Wingware support not to leave my
module of useful functions in Python25\Lib. So I put it in a
subfolder in site-packages I named mine. Importing of or from that
module, mycalc.py goes well, to my surprise, because of
import sys
[x for x in sys.path if
Dick Moores wrote:
This morning I was sternly warned by Wingware support not to leave my
module of useful functions in Python25\Lib. So I put it in a
subfolder in site-packages I named mine. Importing of or from that
module, mycalc.py goes well, to my surprise, because of
import sys
At 11:38 AM 10/3/2006, Kent Johnson wrote:
Normally you will need to either
- make 'mine' be a package, by creating an empty file named
site-packages\mine\__init__.py, and changing your imports to include the
package name (from mine import mycalc), or
- add site-packages\mine to sys.path, maybe by
Dick Moores wrote:
At 11:38 AM 10/3/2006, Kent Johnson wrote:
Normally you will need to either
- make 'mine' be a package, by creating an empty file named
site-packages\mine\__init__.py, and changing your imports to include the
package name (from mine import mycalc), or
- add
At 12:30 PM 10/3/2006, you wrote:
Dick Moores wrote:
At 11:38 AM 10/3/2006, Kent Johnson wrote:
Normally you will need to either
- make 'mine' be a package, by creating an empty file named
site-packages\mine\__init__.py, and changing your imports to include the
package name (from mine import
http://www.python.org/doc/lib/string-methods.html has
=
startswith( prefix[, start[, end]])
Return True if string starts with the prefix, otherwise return False.
prefix can also be a tuple of suffixes to look for. With optional
start, test string
Dick Moores wrote:
s.startswith(er,q,ty)
Traceback (most recent call last):
File pyshell#55, line 1, in module
s.startswith(er,q,ty)
TypeError: slice indices must be integers or None or have an __index__ method
On http://docs.python.org/whatsnew/other-lang.html I found
Dick Moores rdm at rcblue.com writes:
snip
endswith( suffix[, start[, end]])
Return True if the string ends with the specified suffix, otherwise
return False. suffix can also be a tuple of suffixes to look for.
snip
s.startswith(er,q,ty)
Traceback (most recent call last):
File
Thanks, Kent and Andrei! I sure did miss those doubled parentheses.
s = qwerty
s.startswith((er,z,ty,qw,98768976,uytruytr))
True
s.startswith((er,z,ty,qe,98768976,uytruytr))
False
s.startswith((er,z,rty,qe,98768976,uytruytr), 2)
True
s.startswith((er,z,rty,qe,98768976,uytruytr), 4)
-Original Message-
Date: Mon, 25 Sep 2006 02:59:45 -0700
From: Dick Moores [EMAIL PROTECTED]
Subject: [Tutor] Question about startswith() and endswith() in 2.5
To: tutor@python.org
Message-ID: [EMAIL PROTECTED]
Content-Type: text/plain; charset=us-ascii; format=flowed
http
At 09:04 AM 9/25/2006, Carroll, Barry wrote:
Hello, Dick.
Let's compare your final startswith method and the endswith method in
is_image_file:
s.startswith(er,q,ty)
filename.endswith(('.gif', '.jpg', '.tiff'))
Notice that, while startswith has THREE parameters, endswith has only
ONE.
OK, this worked, please disregard my last. The online docs at
python.org told me the answer to that one. Between their example and
yours, i am able to make it work.
thanks a whole bunch !
shawnOn 7/31/06, Justin Ezequiel [EMAIL PROTECTED] wrote:
When I first started with Python, I used MimeWriter
Hey there,
me again with another question about headers..
if i use my python script to send an email, it gets rejected by some providers.
but another app that i use can send the same email and it gets thru.
i have sent myself test messages from both apps and looked at the headers.
the only
shawn bright wrote:
the only difference in one from the other is that in the headers of the
other app (not my python script)
there exist the following lines:
MIME-Version: 1.0
X-Mailer: OstroSoft SMTP Control (4.0.20)
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding:
When I first started with Python, I used MimeWriter to create E-mails.
Then some mail servers rejected my E-mails.
Some research (google) indicated (to me) that I needed a MIME-Version header.
(Can't recall now if I also needed a Content-Type header.)
Anyway, more research (Python docs)
Hey there,i have an app with this line.sys.stderr.write(GET DATA %s %d %d\n (sound, time_limit, digit_count))it is failing with the following error.Traceback (most recent call last):
File /usr/share/asterisk/agi-bin/ast_agi_test.agi, line 88, in ? entered_digits = getNumber(welcome,
On Sat, 2006-07-29 at 09:26 -0500, shawn bright wrote:
Hey there,
i have an app with this line.
sys.stderr.write(GET DATA %s %d %d\n (sound, time_limit, digit_count))
sys.stderr.write(GET DATA %s %d %d\n % (sound, time_limit, digit_count))
^
You
gee whiz, i thought i had poured over that line sufficiently.It works now. imagine that.thanks,shawnOn 7/29/06, Python
[EMAIL PROTECTED] wrote:On Sat, 2006-07-29 at 09:26 -0500, shawn bright wrote:
Hey there, i have an app with this line. sys.stderr.write(GET DATA %s %d %d\n (sound,
hi pyguruscan you please tell me why we need metaclasses and how to use themthanks a lotAnil
Do you Yahoo!? Everyone is raving about the all-new Yahoo! Mail Beta.___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
anil maran wrote:
hi pygurus
can you please tell me why we need metaclasses and how to use them
Hmm...metaclasses are an advanced topic, first exposure to them usually
causes one's brain to explode. Fortunately the condition is only
temporary :-)
Basically a metaclass is the type of a class,
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
Hi everyone,
Could someone help explain what I am doing wrong in
this code block?
This code block is an excerpt from a larger file that receives
transmitted files via IBM WebSphere MQSeries an drops it to the local
file system.
Transmission of the
Hi,
I have written a number of scripts which write to a remote log. I am
using the logging module to produce detailed output. Two questions on
this module:
1. One of the scripts loops around for a specified period of time.
Previously it would print a message to the console detailing how long
it
Hi there, I am wondering if somebody to could answer a question about sockets. I have a socket that is listening, and a client program connects to it. The client program transfers a name over, and then disconnects from the socket. Now, how that is done is using a
socket.close() call to shut down
I think the problem here is the 'break' statement.
Does it not put you outside the while loop whereas in order to keep
the server socket open you need it to loop forever.
I also think that the s.accept should be inside the while loop.
___
Tutor maillist
import socket
host = ''
port = 57000
s=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1)
s.bind((host,port))
s.listen(5)
while 1:
client,addr=s.accept()
client.send(Connected to the server\n)
#if someCondition:
#
Peter Jessop wrote:
I think the problem here is the 'break' statement.
Does it not put you outside the while loop whereas in order to keep
the server socket open you need it to loop forever.
I also think that the s.accept should be inside the while loop.
There are two loops, I think you
Tino Dai wrote:
Hi there,
I am wondering if somebody to could answer a question about
sockets. I have a socket that
is listening, and a client program connects to it. The client program
transfers a name over, and then disconnects from the socket. Now, how
that is done is using a
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
Hi Everyone
I did a comparison of the output between the perl and python methodology.
They do basically the same thing but the perl form seems to be more true
The python method inserts extra blank lines after each hex value line.
For example:
701 - 800 of 946 matches
Mail list logo