Re: [Tutor] question about importing threads

2007-02-11 Thread Luke Paireepinart
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

Re: [Tutor] question about importing threads

2007-02-09 Thread shawn bright
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 =

Re: [Tutor] question about importing threads

2007-02-09 Thread ALAN GAULD
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

Re: [Tutor] question about a list of lists

2007-01-29 Thread shawn bright
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

Re: [Tutor] question about a list of lists

2007-01-29 Thread Kent Johnson
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

[Tutor] question about a list of lists

2007-01-28 Thread shawn bright
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]

Re: [Tutor] question about a list of lists

2007-01-28 Thread Alan Gauld
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

Re: [Tutor] question about a list of lists

2007-01-28 Thread Kent Johnson
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

[Tutor] question about *args and functions

2007-01-26 Thread shawn bright
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

Re: [Tutor] question about *args and functions

2007-01-26 Thread Andre Engels
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,

Re: [Tutor] question about *args and functions

2007-01-26 Thread Kent Johnson
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

Re: [Tutor] question about *args and functions

2007-01-26 Thread Wesley Brooks
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

Re: [Tutor] question about *args and functions

2007-01-26 Thread shawn bright
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

[Tutor] Question about structuring my pygtk program

2007-01-23 Thread Tino Dai
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

Re: [Tutor] question about object oriented programming and inheritance using datetime module

2007-01-16 Thread Terry Carroll
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

Re: [Tutor] question about object oriented programming and inheritance using datetime module

2007-01-16 Thread Kent Johnson
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

[Tutor] question about object oriented programming and inheritance using datetime module

2007-01-15 Thread tpc
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

Re: [Tutor] question about object oriented programming and inheritance using datetime module

2007-01-15 Thread Luke Paireepinart
[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

Re: [Tutor] question about object oriented programming and inheritance using datetime module

2007-01-15 Thread Kent Johnson
[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

[Tutor] Question on joining out of order dictionary elements

2007-01-11 Thread raghu raghu
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

Re: [Tutor] Question on joining out of order dictionary elements

2007-01-11 Thread Andre Engels
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

Re: [Tutor] Question on joining out of order dictionary elements

2007-01-11 Thread Andrew Robert
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 %

Re: [Tutor] Question on joining out of order dictionary elements

2007-01-11 Thread Luke Paireepinart
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

[Tutor] Question on joining out of order dictionary elements

2007-01-10 Thread Andrew Robert
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

Re: [Tutor] Question on joining out of order dictionary elements

2007-01-10 Thread John Fouhy
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

Re: [Tutor] Question about __name__ global variable (Was: Tutor Digest, Vol 35, Issue 27)

2007-01-09 Thread Luke Paireepinart
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,

[Tutor] question about pydev

2007-01-09 Thread shawn bright
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

Re: [Tutor] Question about __name__ global variable (Was: Tutor Digest, Vol 35, Issue 27)

2007-01-09 Thread wesley chun
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

Re: [Tutor] Question about ConfigParser

2007-01-07 Thread Jan Erik Moström
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

[Tutor] Question about ConfigParser

2007-01-06 Thread Jan Erik Moström
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',

Re: [Tutor] Question about ConfigParser

2007-01-06 Thread Dave Kuhlman
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',

Re: [Tutor] Question regarding parsing HTML with BeautifulSoup

2007-01-04 Thread Shuai Jiang (Runiteking1)
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.

Re: [Tutor] question about importing threads

2006-12-31 Thread shawn bright
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.

Re: [Tutor] question about importing threads

2006-12-31 Thread Alan Gauld
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

[Tutor] question about importing threads

2006-12-30 Thread shawn bright
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

Re: [Tutor] question about importing threads

2006-12-30 Thread Kent Johnson
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,

Re: [Tutor] question about importing threads

2006-12-30 Thread shawn bright
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

Re: [Tutor] question about importing threads

2006-12-30 Thread Kent Johnson
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

Re: [Tutor] question about importing threads

2006-12-30 Thread shawn bright
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,

Re: [Tutor] question about importing threads

2006-12-30 Thread Alan Gauld
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

[Tutor] Question about exception handling

2006-12-17 Thread Asrarahmed Kadri
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

Re: [Tutor] Question about exception handling

2006-12-17 Thread Adam Bark
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

Re: [Tutor] Question about HORIZONTAL BAR CHART.....

2006-11-26 Thread Luke Paireepinart
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

Re: [Tutor] Question about HORIZONTAL BAR CHART.....

2006-11-25 Thread Asrarahmed Kadri
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,

Re: [Tutor] question about __init__ in a class

2006-11-13 Thread Mike Hansen
-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

Re: [Tutor] question about __init__ in a class

2006-11-13 Thread shawn bright
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

Re: [Tutor] question about __init__ in a class

2006-11-13 Thread Kent Johnson
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

Re: [Tutor] question about __init__ in a class

2006-11-13 Thread Andreas Kostyrka
* 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

Re: [Tutor] question about __init__ in a class

2006-11-13 Thread shawn bright
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

Re: [Tutor] question about __init__ in a class

2006-11-13 Thread Andreas Kostyrka
* 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

[Tutor] question about classes and atributes

2006-11-03 Thread euoar
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 =

Re: [Tutor] question about classes and atributes

2006-11-03 Thread Andreas Kostyrka
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

Re: [Tutor] question about classes and atributes

2006-11-03 Thread euoar
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 #

Re: [Tutor] question about classes and atributes

2006-11-03 Thread Luke Paireepinart
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

Re: [Tutor] question about classes and atributes

2006-11-03 Thread Alan Gauld
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

Re: [Tutor] question about classes and atributes

2006-11-03 Thread Kent Johnson
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

Re: [Tutor] question about classes and atributes

2006-11-03 Thread euoar
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

[Tutor] question

2006-11-03 Thread Doug Potter
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 =

Re: [Tutor] question about classes and atributes

2006-11-03 Thread Alan Gauld
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

Re: [Tutor] question

2006-11-03 Thread Alan Gauld
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')

[Tutor] question

2006-11-03 Thread Jonathon Sisson
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

Re: [Tutor] question about pylab

2006-10-31 Thread Markus Rosenstihl
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

Re: [Tutor] question about pylab

2006-10-31 Thread Kent Johnson
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

Re: [Tutor] question about pylab

2006-10-31 Thread shawn bright
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

[Tutor] question about pylab

2006-10-30 Thread 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 sending datetimes to the charting app for x, and the y is a

[Tutor] Question abt numpy and Numeric...........

2006-10-24 Thread Asrarahmed Kadri
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

Re: [Tutor] Question abt numpy and Numeric...........

2006-10-24 Thread Kent Johnson
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

[Tutor] question about number of threads

2006-10-12 Thread shawn bright
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

Re: [Tutor] question about number of threads

2006-10-12 Thread Kent Johnson
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

Re: [Tutor] question about looping.

2006-10-09 Thread Hugo González Monteverde
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

[Tutor] question about looping.

2006-10-06 Thread Doug Potter
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?

Re: [Tutor] question about looping.

2006-10-06 Thread Carlos Hanson
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

[Tutor] question about sys.path and importing

2006-10-03 Thread Dick Moores
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

Re: [Tutor] question about sys.path and importing

2006-10-03 Thread Kent Johnson
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

Re: [Tutor] question about sys.path and importing

2006-10-03 Thread Dick Moores
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

Re: [Tutor] question about sys.path and importing

2006-10-03 Thread Kent Johnson
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

Re: [Tutor] question about sys.path and importing

2006-10-03 Thread Dick Moores
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

[Tutor] Question about startswith() and endswith() in 2.5

2006-09-25 Thread Dick Moores
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

Re: [Tutor] Question about startswith() and endswith() in 2.5

2006-09-25 Thread Kent Johnson
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

Re: [Tutor] Question about startswith() and endswith() in 2.5

2006-09-25 Thread Andrei
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

Re: [Tutor] Question about startswith() and endswith() in 2.5

2006-09-25 Thread Dick Moores
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)

Re: [Tutor] Question about startswith() and endswith() in 2.5

2006-09-25 Thread Carroll, Barry
-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

Re: [Tutor] Question about startswith() and endswith() in 2.5

2006-09-25 Thread Dick Moores
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.

Re: [Tutor] question about headers and smtplib

2006-08-01 Thread shawn bright
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

[Tutor] question about headers and smtplib

2006-07-31 Thread shawn bright
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

Re: [Tutor] question about headers and smtplib

2006-07-31 Thread Dustin J. Mitchell
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:

Re: [Tutor] question about headers and smtplib

2006-07-31 Thread Justin Ezequiel
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)

[Tutor] question about type str

2006-07-29 Thread shawn bright
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,

Re: [Tutor] question about type str

2006-07-29 Thread Python
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

Re: [Tutor] question about type str

2006-07-29 Thread shawn bright
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,

[Tutor] question about metaclasses

2006-07-12 Thread anil maran
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

Re: [Tutor] question about metaclasses

2006-07-12 Thread Kent Johnson
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,

[Tutor] Question regarding commit/backout of a message using the pymqi module

2006-06-22 Thread Andrew Robert
-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

[Tutor] Question on Logging Module

2006-06-20 Thread kieran flanagan
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

[Tutor] Question about network server in python

2006-06-15 Thread Tino Dai
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

Re: [Tutor] Question about network server in python

2006-06-15 Thread Peter Jessop
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

Re: [Tutor] Question about network server in python

2006-06-15 Thread Peter Jessop
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: #

Re: [Tutor] Question about network server in python

2006-06-15 Thread Kent Johnson
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

Re: [Tutor] Question about network server in python

2006-06-15 Thread Kent Johnson
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

Re: [Tutor] Question on regular expressions

2006-05-25 Thread Andrew Robert
-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:

<    3   4   5   6   7   8   9   10   >