[Tutor] The name of the module
Dear Tutors, there was a thread some weeks ago about how can we find out what is the name of the current module, where the function was loaded from, where the function running from or so, with some magic. I can't find it in the archive. May someone help me with some reference about it ? Yours sincerely, __ János Juhász ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] symbol encoding and processing problem
I tried your advice yesterday evening. > And see if you get a ç. I see this character. from easygui import easygui raw = unicode("121ø 55' 5.55''", 'utf-8') => gets a encoding error raw = unicode("121ø 55' 5.55''", 'cp1250') => this works while coding on windows. How do I make it work really crossplatform: On both Linux and Windows? lines = raw.split(unicode('ø', 'cp1250')) => again work on windows print lines easygui.msgbox(raw) => prints a strange symbol instead of "°" import Tkinker Tkinter._test() => this test test the expected result. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] The name of the module
János Juhász wrote: > Dear Tutors, > > there was a thread some weeks ago about > how can we find out > what is the name of the current module, > where the function was loaded from, > where the function running from or so, > with some magic. > > I can't find it in the archive. > > May someone help me with some reference about it ? > > Yours sincerely, > __ > János Juhász > > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > > I can only find something back in February of this year. http://mail.python.org/pipermail/tutor/2007-February/052914.html Don't know if that's what you're after though. -- _ ASCII ribbon campaign ( ) - against HTML email X & vCards / \ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] symbol encoding and processing problem
Timmie wrote: > I tried your advice yesterday evening. > >> And see if you get a ç. > I see this character. > > from easygui import easygui > raw = unicode("121ø 55' 5.55''", 'utf-8') > => gets a encoding error Then your source file is not really in UTF-8. BTW you can simply say raw = u"121ø 55' 5.55''" > raw = unicode("121ø 55' 5.55''", 'cp1250') > => this works while coding on windows. > How do I make it work really crossplatform: On both Linux and Windows? Get an editor on Windows that can edit UTF-8 text files and file transfer software that doesn't change the text encoding. Work with UTF-8 exclusively. Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] symbol encoding and processing problem
> > from easygui import easygui > > raw = unicode("121ø 55' 5.55''", 'utf-8') > > => gets a encoding error > > Then your source file is not really in UTF-8. This really helped! > Get an editor on Windows that can edit UTF-8 text files and file > transfer software that doesn't change the text encoding. Work with UTF-8 > exclusively. Thanks. This sounds really trivial but the thing is that one cannot define file encoding in PythonWin. I will have to either use a advanced editor like Notepad++ and run the script via console or use Geany as IDE. Since it didn't work in IPython as well I assume that I need to change the encoding of the IPython shell to UTF-8, too. Still need to find out where. The following code works on windows when saved to a UTF-8 encoded file: # -*- coding: utf-8 -*- # the file needs to be set to UTF-8 encoding if working on windows from easygui import easygui raw = unicode("125° 15' 5.55''", 'utf-8') print raw.encode('utf-8') lines = raw.split(unicode('°', 'utf-8')) print lines entertext = easygui.enterbox(message="Enter something.", title="", argDefaultText=raw) print entertext degrees = lines[0] print "degrees: ", str(degrees) Thanks for your support, so far. Timmie ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] symbol encoding and processing problem
Timmie wrote: >>> from easygui import easygui >>> raw = unicode("121ø 55' 5.55''", 'utf-8') >>> => gets a encoding error >> Then your source file is not really in UTF-8. > This really helped! > > >> Get an editor on Windows that can edit UTF-8 text files and file >> transfer software that doesn't change the text encoding. Work with UTF-8 >> exclusively. > Thanks. This sounds really trivial but the thing is that one cannot define > file > encoding in PythonWin. > I will have to either use a advanced editor like Notepad++ and run the script > via console or use Geany as IDE. I'm sure there'll be lots of other suggestions, but the SciTE editor (whose name I'm never sure how to prononunce without blushing) understands the same encoding directive as Python. It's quite lightweight, and also allows you to run Python scripts directly, although there are limitations. Worth looking at, anyhow. http://www.scintilla.org/SciTE.html TJG ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] symbol encoding and processing problem
Timmie wrote: >> Get an editor on Windows that can edit UTF-8 text files and file >> transfer software that doesn't change the text encoding. Work with UTF-8 >> exclusively. > Thanks. This sounds really trivial but the thing is that one cannot define > file > encoding in PythonWin. Really! That is surprising. Anyone else know how to set the file encoding for the PythonWin editor? > Since it didn't work in IPython as well I assume that I need to change the > encoding of the IPython shell to UTF-8, too. Still need to find out where. Was the problem with the print statements? Maybe changing the console encoding would help. I have some notes here: http://personalpages.tds.net/~kent37/stories/00018.html > The following code works on windows when saved to a UTF-8 encoded file: > > # -*- coding: utf-8 -*- > # the file needs to be set to UTF-8 encoding if working on windows > from easygui import easygui > raw = unicode("125° 15' 5.55''", 'utf-8') Again, I think this can be simplified to raw = u"125° 15' 5.55''" Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] symbol encoding and processing problem
OK, I found out. > Since it didn't work in IPython as well I assume that I need to change the > encoding of the IPython shell to UTF-8, too. Still need to find out where. Put a file called 'sitecustomize.py' into any directory on your PYTHONPATH. write the folowing two lines in that file: import sys sys.setdefaultencoding('utf-8') To test, start ipython and type import sys sys.getdefaultencoding() It should be utf-9 now. Again, may sound trivial. for some. But I started my Python adventures on Ubuntu Linux which it set to UTF-8 as default encoding. Due to some software environments I am currently forced to use Windows. After installing Python and some modules with setup.exe I never new that I even have to care for this... ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] symbol encoding and processing problem
Timmie wrote: > OK, I found out. >> Since it didn't work in IPython as well I assume that I need to change the >> encoding of the IPython shell to UTF-8, too. Still need to find out where. > Put a file called 'sitecustomize.py' into any directory on your PYTHONPATH. > > write the folowing two lines in that file: > > import sys > sys.setdefaultencoding('utf-8') Just be aware that this affects portability of your scripts; they will require this same change to run on other systems. For this reason you might want to change the code instead. If you give a specific example of what is failing I will try to help. Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] OT [Re: symbol encoding and processing problem]
> I'm sure there'll be lots of other suggestions, but the SciTE > editor (whose name I'm never sure how to prononunce without > blushing) understands the same encoding directive as Python. > It's quite lightweight, and also allows you to run Python scripts > directly, although there are limitations. Worth looking at, anyhow. > > http://www.scintilla.org/SciTE.html I am using Notepad++ which is based on scintilla, too. http://notepad-plus.sourceforge.net/de/site.htm For a lightweight IDE look at Geany: http://geany.uvena.de/ It can also run your programs and change file encodings. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] OT [Re: symbol encoding and processing problem]
Timmie wrote: >> I'm sure there'll be lots of other suggestions, but the SciTE >> editor (whose name I'm never sure how to prononunce without >> blushing) understands the same encoding directive as Python. >> It's quite lightweight, and also allows you to run Python scripts >> directly, although there are limitations. Worth looking at, anyhow. >> >> http://www.scintilla.org/SciTE.html > I am using Notepad++ which is based on scintilla, too. > http://notepad-plus.sourceforge.net/de/site.htm Well you're obviously well set up, then. > For a lightweight IDE look at Geany: http://geany.uvena.de/ > It can also run your programs and change file encodings. Amazing! No matter how much I think I know the landscape, there's always something which has escaped my attention. I notice it's GTK-based and I'm running on Win32 where GTK seems to be a bit clunky, but thanks for the heads-up nonetheless. TJG ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] aBSOLUTE BEGINNER
Hello all, I am an absolute beginner for python.currently i am working under mainframe technologybut getting kinda bored from it and want to learn a good scripting language...so chose python...please give me link to a pdf which is suitable for beginners. -- take care bye Abhishek Negi ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] aBSOLUTE BEGINNER
Abhishek Negi wrote: > Hello all, > I am an absolute beginner for python.currently i am working under > mainframe technologybut getting kinda bored from it and want to > learn a good scripting language...so chose python...please give me link > to a pdf which is suitable for beginners. I don't know about pdf but many beginner resources here: http://wiki.python.org/moin/BeginnersGuide/NonProgrammers Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] aBSOLUTE BEGINNER
>> Hello all, >> I am an absolute beginner for python.currently i am working under >> mainframe technologybut getting kinda bored from it and want to >> learn a good scripting language...so chose python...please give me link >> to a pdf which is suitable for beginners. This is my favourite all time beginner book http://ibiblio.org/obp/thinkCS/python/english2e/html/index.html. IT is in html, I don't know if you can get it in pdf. > > I don't know about pdf but many beginner resources here: > http://wiki.python.org/moin/BeginnersGuide/NonProgrammers > > Kent > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > > -- Your friend, Scott Sent to you from a Linux computer using Kubuntu Version 7.04 (Feisty Fawn) ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] symbol encoding and processing problem
>> raw = unicode("125° 15' 5.55''", 'utf-8') > > Again, I think this can be simplified to >raw = u"125° 15' 5.55''" It does, but it's getting confusing when I compare the following: >>> raw = u"125° 15' 5.55''" 125° 15' 5.55'' >>> print u"125° 15' 5.55''" UnicodeEncodeError: 'ascii' codec can't encode characters in position 3-4: ordinal not in range(128) >>> print u"125° 15' 5.55''".encode('utf-8') 125° 15' 5.55'' >>> print unicode("125° 15' 5.55''") UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 3: ordinal not in range(128) >>> print unicode("125° 15' 5.55''", 'utf-8') UnicodeEncodeError: 'ascii' codec can't encode character u'\xb0' in position 3: ordinal not in range(128) So apart from the errors all being slightly different, is there perhaps some difference between the str() and repr() functions (looks like repr uses escape backslashes)? Or does it simply have to do with my locale, which is set to the default "C" (terminal = standard Mac OS X terminal, with UTF-8 encoding)? Although that wouldn't explain to me why the third statement works. And checking the default encoding inside the python cmdline, I see that my sys module doesn't actually have a setdefaultencoding() method; was that something that should have been properly configured at compile time? The documentation mentions something about the site module, but I can't find it there either. Any enlightenment on this is welcome. Evert ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] symbol encoding and processing problem
Evert Rol wrote: >>> raw = unicode("125° 15' 5.55''", 'utf-8') >> Again, I think this can be simplified to >>raw = u"125° 15' 5.55''" > > It does, but it's getting confusing when I compare the following: > > >>> raw = u"125° 15' 5.55''" > 125° 15' 5.55'' Where does that output come from? > > >>> print u"125° 15' 5.55''" > UnicodeEncodeError: 'ascii' codec can't encode characters in position > 3-4: ordinal not in range(128) print must encode unicode strings. It tries to encode them using the default encoding which doesnt' work because the source is not ascii. > > >>> print u"125° 15' 5.55''".encode('utf-8') > 125° 15' 5.55'' That is the way to get it to work. > >>> print unicode("125° 15' 5.55''") > UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position > 3: ordinal not in range(128) Here the problem is trying to create the unicode string using the default encoding, again it doesn't work because the source contains non-ascii characters. > >>> print unicode("125° 15' 5.55''", 'utf-8') > UnicodeEncodeError: 'ascii' codec can't encode character u'\xb0' in > position 3: ordinal not in range(128) This is the same as the first encode error. > So apart from the errors all being slightly different, is there > perhaps some difference between the str() and repr() functions (looks > like repr uses escape backslashes)? Right. > And checking the default encoding inside the python cmdline, I see > that my sys module doesn't actually have a setdefaultencoding() > method; was that something that should have been properly configured > at compile time? The documentation mentions something about the site > module, but I can't find it there either. The setdefaultencoding() function (it's not a method, it is a module-level function) is removed from the sys module as part of startup (I think by the site module). That is why you have to call it from sitecustomize.py. You can also reload(sys) to restore it but it's better to write your app so it doesn't require the default encoding to be changed. Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] symbol encoding and processing problem
raw = unicode("125° 15' 5.55''", 'utf-8') >>> Again, I think this can be simplified to >>>raw = u"125° 15' 5.55''" >> It does, but it's getting confusing when I compare the following: >> >>> raw = u"125° 15' 5.55''" >> 125° 15' 5.55'' > > Where does that output come from? sorry, my bad: over-hastily copy of non-existant output. >> >>> print u"125° 15' 5.55''" >> UnicodeEncodeError: 'ascii' codec can't encode characters in >> position 3-4: ordinal not in range(128) > > print must encode unicode strings. It tries to encode them using > the default encoding which doesnt' work because the source is not > ascii. >> >>> print u"125° 15' 5.55''".encode('utf-8') >> 125° 15' 5.55'' > > That is the way to get it to work. > >> >>> print unicode("125° 15' 5.55''") >> UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in >> position 3: ordinal not in range(128) > > Here the problem is trying to create the unicode string using the > default encoding, again it doesn't work because the source contains > non-ascii characters. > >> >>> print unicode("125° 15' 5.55''", 'utf-8') >> UnicodeEncodeError: 'ascii' codec can't encode character u'\xb0' >> in position 3: ordinal not in range(128) > > This is the same as the first encode error. This is the thing I don't get; or only partly: I'm sending a utf-8 encoded string to print. print apparently ignores that, and still tries to print things using ascii encoding. If I'm correct in that assessment, then why would print ignore that? >> So apart from the errors all being slightly different, is there >> perhaps some difference between the str() and repr() functions >> (looks like repr uses escape backslashes)? > > Right. > >> And checking the default encoding inside the python cmdline, I >> see that my sys module doesn't actually have a setdefaultencoding >> () method; was that something that should have been properly >> configured at compile time? The documentation mentions something >> about the site module, but I can't find it there either. > > The setdefaultencoding() function (it's not a method, it is a > module-level function) yes, sorry, got my terminology wrong there. > is removed from the sys module as part of startup (I think by the > site module). That is why you have to call it from > sitecustomize.py. You can also > reload(sys) > to restore it but it's better to write your app so it doesn't > require the default encoding to be changed. Ie, use encode('utf-8') where necessary? But I did see some examples pass by using import sys sys.setdefaultencoding('utf-8') ?? Oh well, in general I tend to play long enough with things like this that 1) I get it (script) working, and 2) I have a decent feeling (90%) that I actually understand what is going on, and why other things failed. Which is roughly where I am now ;-). Evert ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] symbol encoding and processing problem
Evert Rol wrote: >>> >>> print unicode("125° 15' 5.55''", 'utf-8') >>> UnicodeEncodeError: 'ascii' codec can't encode character u'\xb0' in >>> position 3: ordinal not in range(128) >> >> This is the same as the first encode error. > > This is the thing I don't get; or only partly: I'm sending a utf-8 > encoded string to print. No, you are sending a unicode string to print. unicode("125° 15' 5.55''", 'utf-8') means the same as "125° 15' 5.55''".decode('utf-8') which is, "create a unicode string from this utf-8-encoded byte string". Once you have decoded to Unicode it is no longer utf-8. > print apparently ignores that, and still tries > to print things using ascii encoding. If I'm correct in that assessment, > then why would print ignore that? print just knows that you want to print a unicode string. stdout is byte-oriented so the unicode chars have to be converted to a byte stream. This is done by encoding with sys.getdefaultencoding(), i.e. print unicode("125° 15' 5.55''", 'utf-8') is the same as print u"125° 15' 5.55''" which is the same as print u"125° 15' 5.55''".encode(sys.getdefaultencoding()) > Ie, use encode('utf-8') where necessary? Yes. > But I did see some examples pass by using > > import sys > sys.setdefaultencoding('utf-8') Yes, that will make the examples pass, it just isn't the recommended solution. > Oh well, in general I tend to play long enough with things like this > that 1) I get it (script) working, and 2) I have a decent feeling (90%) > that I actually understand what is going on, and why other things > failed. Which is roughly where I am now ;-). The key thing is to realize that there are implicit conversions between str and unicode and they will break if the data is not ascii. The best fix is to make the conversions explicit by providing the correct encoding. Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] aBSOLUTE BEGINNER
"Abhishek Negi" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hello all, > I am an absolute beginner for python.currently i am working > under > mainframe technologybut getting kinda bored from it and want to > learn a > good scripting language...so chose python...please give me link to a > pdf > which is suitable for beginners. There are many beginners tutorials available from the Python web site: http://wiki.python.org/moin/BeginnersGuide/NonProgrammers However if it must be a pdf you use then you can get my tutorial in PDF by navigating to the bottom of the contents frame and clicking the PDF link there. My tutor is very basic, designer for non programmers to get them to the point where they can understand the discussions on internet fora (like this one!) If you are a programmer already then the official tutorial is a better starting point. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.freenetpages.co.uk/hp/alan.gauld ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] String module; Count
I am having trouble getting the string.count function to work. I want it to count the amount of digits (0 or 1) in the string, but I keep getting an error stating the string.count was expecting a character buffer object. CODE: count = string.count(conversion(n),["0","1"]) ERROR: Traceback (most recent call last): File "/Users//Desktop/Project 1.py", line 59, in -toplevel- signed_mag() File "/Users//Desktop/Project 1.py", line 29, in signed_mag count = string.count(conversion(n),["0","1"]) File "/Library/Frameworks/Python.framework/Versions/2.4//lib/python2.4/string.py" , line 348, in count return s.count(*args) TypeError: expected a character buffer object I'm trying to make a decimal to binary converter that has the option to select the amount of bits for Signed Binary. I've thought of a way (not tested yet) on how to implement the bits, but I first need to count the amount of digits in the original conversion. Thanks in advance. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help with packages and namespaces please
Thanks again for your help. I guess I should ask a more basic question about hierarchical directory structures and packages. If I have a bunch of files in a flat (single) directory structure that I want to reorganize into a hierarchical directory structure, do I necessarily have to turn them into package files (i.e. add the __init__.py files, or can I simply place them into a subdirectory structure and do something else so python can find the modules? Or is it better practice whenever a hierarchical directory structure exists to treat it as a package? Thanks! Andrew ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help with packages and namespaces please
Andrew Wu wrote: > Thanks again for your help. > > I guess I should ask a more basic question about hierarchical directory > structures and packages. If I have a bunch of files in a flat (single) > directory structure that I want to reorganize into a hierarchical > directory structure, do I necessarily have to turn them into package > files ( i.e. add the __init__.py files, or can I simply place them into > a subdirectory structure and do something else so python can find the > modules? You can put the subdirectories on the Python search path. > Or is it better practice whenever a hierarchical directory structure > exists to treat it as a package? That is more common. Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] String module; Count
You can only count one at a time. count = conversion(n).count("0") + conversion(n).count("1") count is a string method, so it operates directly on the string - you don't have to call it like you did. import string string.count(mystr, "cheese") is the same as mystr.count("cheese") At least it is in newer versions of python. Let me know if that helped. Cheers, Ben On 10/17/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > I am having trouble getting the string.count function to work. I want it to > count the amount of digits (0 or 1) in the string, but I keep getting an > error stating the string.count was expecting a character buffer object. > CODE: > count = string.count(conversion(n),["0","1"]) > > ERROR: > Traceback (most recent call last): > File "/Users//Desktop/Project 1.py", line 59, in -toplevel- > signed_mag() > File "/Users//Desktop/Project 1.py", line 29, in signed_mag > count = string.count(conversion(n),["0","1"]) > File > "/Library/Frameworks/Python.framework/Versions/2.4//lib/python2.4/string.py" > , line 348, in count > return s.count(*args) > TypeError: expected a character buffer object > > I'm trying to make a decimal to binary converter that has the option to > select the amount of bits for Signed Binary. I've thought of a way (not > tested yet) on how to implement the bits, but I first need to count the > amount of digits in the original conversion. Thanks in advance. > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] String module; Count
[EMAIL PROTECTED] wrote: > I am having trouble getting the string.count function to work. I want it to > count the amount of digits (0 or 1) in the string, but I keep getting an > error stating the string.count was expecting a character buffer object. > CODE: > count = string.count(conversion(n),["0","1"]) If conversion(n) is already a string containing only 0 and 1 you could just use len(conversion(n)) Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] aBSOLUTE BEGINNER
> > This is my favourite all time beginner book > http://ibiblio.org/obp/thinkCS/python/english2e/html/index.html. IT is > in html, I don't know if you can get it in pdf. > You can find an revised PDF version here: http://www.greenteapress.com/thinkpython/ It should be more up to date. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] aBSOLUTE BEGINNER
On 10/17/07, Abhishek Negi <[EMAIL PROTECTED]> wrote: > Hello all, > I am an absolute beginner for python.currently i am working under > mainframe technology What does that mean... "mainframe technology"? Are you a programmer? If so, which programming languages are you 'working' with? If you're already programming, what type of programming are you doing? SysAdmin? Database? Application? Other? > but getting kinda bored from it and want to learn a > good scripting language... I don't understand how you can get 'bored' with your work? Work is work, but how is the 'mainframe technology' you are working under, boring? Why do you think a good scripting language will help the "boredom"? > so chose python...please give me link to a pdf > which is suitable for beginners. Why did you pick on Python? What did Python ever do to you? Lessee now... working under mainframe technology, but 'bored' with it, and looking for a good scripting language to help with the boredom H. Python is anything but boring! I doubt we can help you! > -- > take care > bye > Abhishek Negi Bye! =) -- b h a a l u u at g m a i l dot c o m http://www.geocities.com/ek.bhaaluu/index.html ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] accessing data in a usable format
I have a data file 'data1.dat', *a* *b**c* *d* 1 0.10.110.111 2 0.20.220.222 3 0.30.330.333 9 0.90.990.999 and I want to be able to access the values of *b*, *c*, or *d* depending on a value of *a*. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] accessing data in a usable format
On 18/10/2007, Bryan Fodness <[EMAIL PROTECTED]> wrote: > I have a data file 'data1.dat', > > a bc d > > 1 0.10.110.111 > 2 0.20.220.222 > 3 0.30.330.333 > > 9 0.90.990.999 > > and I want to be able to access the values of b, c, or d depending on a > value of a. Hi Bryan, Hve a look at the tutorial (on python.org) section on reading from files. You'll also need to read about string methods in the standard library (specifically, the split() method) and dictionaries (in the tutorial, again). If you get stuck, show us what you've tried and we'll try to help. -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor