Re: [Tutor] Reqiest Centre - Adding New Call

2006-04-19 Thread Liam Clarke
Hi all, I do apologise for this, This was an email that has nothing to do with Python or the tutor list, so my apologies to all. Somehow I managed to send it to the wrong recepient. (And my thanks to Bob for being brave enough to attempt to answer what would be a hopelessly vague question. :-) )

Re: [Tutor] Version of a .pyc file

2006-04-19 Thread Kent Johnson
Don Taylor wrote: > Finally, are there any other possible file extension types that I should > be looking at? .pyo is like a .pyc but compiled with optimizations on. Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/

Re: [Tutor] Version of a .pyc file

2006-04-19 Thread Don Taylor
Terry Carroll wrote: >>How can I tell if a .pyc file was built with 2.3 or 2.4? > > > There's a "Magic Number" in the first 2 or 4 bytes, (depending on whether > you consider the \r\n part of the MN). > > f = open("pycfile.pyc", "rb") magictable = {'\x3b\xf2\r\n': "2.3", '\x6d\xf2\r\n

Re: [Tutor] Splitting a number into even- and odd- numbered digits

2006-04-19 Thread John Fouhy
On 20/04/06, Carroll, Barry <[EMAIL PROTECTED]> wrote: > The following code fragment does the job but seems sort of brutish and > inelegant to me: > > >>> > >>> s = '987654321' > >>> odd = '' > >>> for c in s[::-2]: > ... odd = c + odd > ... > >>> String slicing will actually produce stri

[Tutor] Splitting a number into even- and odd- numbered digits

2006-04-19 Thread Carroll, Barry
Greetings: I am writing a function that accepts a string of decimal digits, calculates a checksum and returns it as a single character string. The first step in the calculation is to split the input into two strings: the even- and odd- numbered digits, respectively. The least significant digi

Re: [Tutor] Brain In Vice: Why is this so fun to me?

2006-04-19 Thread Alan Gauld
> I cannot for the life of me figure out a pythonic way (read: using the > split() builtin) to scan for instances of these characters in such and > such > order and proximity. I know this is what regex is for, I'm afraid so, it looks like the time has come to import re. > I have obtained a copy

Re: [Tutor] [Linux] open a file in any home "~" ?

2006-04-19 Thread Alan Gauld
> How can I do to access this file whatever the user is ? > > use os.path.expanduser(path) Neat Wesley, I've never noticed that one before. Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] Reqiest Centre - Adding New Call

2006-04-19 Thread Liam Clarke
Hi, The categories of calls under this drop down box, are they going to increase anytime soon, or shall I go with what's there? Regards, Liam Clarke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Brain In Vice: Why is this so fun to me?

2006-04-19 Thread Liam Clarke
Hi Doug, Best tip ever is your_python_dir\tools\scripts\redemo.py Interactive regexes. :) This is pretty good as well - http://www.amk.ca/python/howto/regex/ Good luck, Liam Clarke On 4/20/06, doug shawhan <[EMAIL PROTECTED]> wrote: > I think I'm going to have to suck it up and learn some reg

[Tutor] Brain In Vice: Why is this so fun to me?

2006-04-19 Thread doug shawhan
I think I'm going to have to suck it up and learn some regular expressions. I have finally gotten my script (using the excellent pyserial module) to behave. Most of my troubles as enumerated here before were utterly self-induced. Apparently one cannot watch the execution of one's script through an

Re: [Tutor] GUI

2006-04-19 Thread Liam Clarke
Hmm? How so? I'm using a whole lot of raw wxPython mixed with Pythoncard for a project, and the entire process sits at 7Mb RAM usage idle. WinXP btw. Considering my small command line appns to start/stop Windows services written in C use just over 1Mb, 7Mb isn't overly bad. The other good thing a

Re: [Tutor] GUI

2006-04-19 Thread R. Alan Monroe
>> If I can get it for free, I might as well go with say wxPython. Thanks > Yes, free as in beer, as in speech, and cross platform. Oh, and better > documented. Sadly, you still pay for it in RAM usage :^) Alan ___ Tutor maillist - Tutor@python.org

Re: [Tutor] [Linux] open a file in any home "~" ?

2006-04-19 Thread w chun
we are all happy to help. it is really good that you were able to get it working so fast! also, if you want to do any kind of pattern matching with * or ?, then check out the "glob" module. merci! "le livre" does not look that good from here... it is a mess and i have to clean it up before givi

Re: [Tutor] [Linux] open a file in any home "~" ?

2006-04-19 Thread Alan Gauld
> The ".myapp.conf" is in the home folder of the user. > ... > obviously I won't know the home user folder name then I wanted to use: > How can I do to access this file whatever the user is ? You can get the user name using getpass.getuser() as described in the OS topic of my tutor under the Secu

Re: [Tutor] [Linux] open a file in any home "~" ?

2006-04-19 Thread Paidhi Aiji
Hi, You can use expanduser() from os.path for this: import os.path homedir = os.path.expanduser('~user1') file_to_open = os.path.join(homedir, '.myapp.conf') f = open(file_to_open, 'r') Regards, -Markus- Quoting learner404 <[EMAIL PROTECTED]>: > Hello, > > I want to read a configuration fi

Re: [Tutor] [Linux] open a file in any home "~" ?

2006-04-19 Thread learner404
It works great, thanks very much to the three of you for these light-speed answers ... I love this list ! Wesley, I've just pre-order your new edition "Core Python programming" on amazon France, it looks great. :) Thanks   On 19/04/06, w chun <[EMAIL PROTECTED]> wrote: >  f=open("~/.myapp.conf",

Re: [Tutor] Re-instantiate within __init__

2006-04-19 Thread Danny Yoo
> I tried: > > class Omega: >def Display(self): >print self > > class Alpha(Omega): >def __init__(self): >self = Beta() > > class Beta(Omega): >def __init__(self): >pass > > objectus = Alpha() > objectus.Display() > > which prints > > <__main__.Alpha instance at

Re: [Tutor] [Linux] open a file in any home "~" ?

2006-04-19 Thread w chun
> f=open("~/.myapp.conf","r") # but it returns a IOError: [Errno 2] No such > file or directory: > > How can I do to access this file whatever the user is ? use os.path.expanduser(path) http://www.python.org/doc/2.4.3/lib/module-os.path.html hope this helps! -- wesley - - - - - - - - - - - -

Re: [Tutor] [Linux] open a file in any home "~" ?

2006-04-19 Thread Matthew White
os.getenv('HOME') will return the user's home directory as long as that environment variable is set. you can also use the pwd module: >>> pwd.getpwnam('mtw') ('mtw', 'x', 1000, 1000, ',,,', '/home/mtw', '/bin/bash') -mtw On Wed, Apr 19, 2006 at 07:55:14PM +0200, learner404 ([EMAIL PROTECTED]) w

[Tutor] [Linux] open a file in any home "~" ?

2006-04-19 Thread learner404
Hello, I want to read a configuration file from a small python app (user preferences). The ".myapp.conf" is in the home folder of the user. if I do: f=open("/home/user1/.myapp.conf","r")  #it works obviously I won't know the home user folder name then I wanted to use: f=open("~/.myapp.conf","

Re: [Tutor] GUI

2006-04-19 Thread Hugo González Monteverde
> Ok, > If I can get it for free, I might as well go with say wxPython. Thanks Yes, free as in beer, as in speech, and cross platform. Oh, and better documented. Hugo ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Some help with properties and accessor functions....

2006-04-19 Thread Alan Gauld
class SOFileIndexRecord(object): def __init__(self, so): self._so=so def _get_code(self): return self._so.code def _set_code(self, value): self._so.code=value testCode=property(_get_code, _set_code) # What does this do? It says that testCode is a property o

Re: [Tutor] Re-instantiate within __init__

2006-04-19 Thread Alan Gauld
> is it correct that an object cannot be re-instantiated within it's > __init__ method? There are some tricks you can pull but the object is actually instantiated before the init gets called. Really init is for initialisation of the instance, it's not a true constructor. > Background: I need to

[Tutor] [Summary] Re: unit testing raw_input()

2006-04-19 Thread Andre Roberge
Thank you Michael, Danny and Alan for your suggestions. I've included below my summary of the three very different suggestions, my brief analysis of them, and my conclusion. Anyone is free and welcome to comment! On 4/18/06, Andre Roberge <[EMAIL PROTECTED]> wrote: > Hi all- > > Suppose I had a fu

[Tutor] Some help with properties and accessor functions....

2006-04-19 Thread Mark True
class SOFileIndexRecord(object):    def __init__(self, so):    self._so=so   def _get_code(self):    return self._so.code    def _set_code(self, value):    self._so.code=value     testCode=property(_get_code, _set_code) # What does this do?   def _get_fileName(self):    re

[Tutor] Fw: anybody tried Google calendar?

2006-04-19 Thread Alan Gauld
Contained in a reply about a Google calendar issue... > http://www.google.com/support/calendar/bin/answer.py?answer=37083&query=free+busy&topic=0&type=f > Note the answer.py Looks like Google have expanded their use of Python from test scripts and config/admin to mainstream web pages, albeit the

Re: [Tutor] OOPs Concept

2006-04-19 Thread Matthew White
On Wed, Apr 19, 2006 at 09:10:41PM +0530, Kaushal Shriyan ([EMAIL PROTECTED]) wrote: > Thanks Matthew > Just wanted to know > x.count('l') -> 2 Here 2 means what I didnot understood this > and also does x is a object and capitalize(), swapcase() and > count('l') are methods, is that correct what

Re: [Tutor] OOPs Concept

2006-04-19 Thread Kaushal Shriyan
On 4/19/06, Matthew White <[EMAIL PROTECTED]> wrote: > Even though I am still new to python, I've recently had an insight as > to what makes OOP different from procedural programming. > > Let's take perl for example. A variable in perl is like a bowl. It's an > empty vessel you can put things in.

Re: [Tutor] OOPs Concept

2006-04-19 Thread Matthew White
Even though I am still new to python, I've recently had an insight as to what makes OOP different from procedural programming. Let's take perl for example. A variable in perl is like a bowl. It's an empty vessel you can put things in. You can change the contents of the bowl, you can empty the b

Re: [Tutor] Re-instantiate within __init__

2006-04-19 Thread Kent Johnson
Jan Eden wrote: > Hi, > > is it correct that an object cannot be re-instantiated within it's __init__ > method? > > I tried: > > class Omega: > def Display(self): > print self > > class Alpha(Omega): > def __init__(self): > self = Beta() > > class Beta(

[Tutor] Re-instantiate within __init__

2006-04-19 Thread Jan Eden
Hi, is it correct that an object cannot be re-instantiated within it's __init__ method? I tried: class Omega: def Display(self): print self class Alpha(Omega): def __init__(self): self = Beta() class Beta(Omega): def __init__(self): pass

Re: [Tutor] GUI

2006-04-19 Thread Chris Lasher
It's a dual license. If you use Qt in non-commercial software, the GPL applies and you pay no licensing fees. If you use Qt in commercial software, licensing fees are due to TrollTech. Chris On 4/18/06, Alan Gauld <[EMAIL PROTECTED]> wrote: > [snip] > TrollTech own Qt, their licensing arrangement

[Tutor] OOPs Concept

2006-04-19 Thread Kaushal Shriyan
Hi All I wanted to understand about OOPs Concept in Python in a easy way, Please explain me with an example I have been reading http://www.freenetpages.co.uk/hp/alan.gauld/tutclass.htm but at the moment still the concept is not clear Thanks in Advance Regards Kaushal __

[Tutor] net ettiquette and sentence sorting/homework

2006-04-19 Thread Danny Yoo
>> * > i want to write a function which will sort the sentence by the length of > each word in the sentece, short length first.please help. Hi Nywbon, First: please do not reply to the whole email digest. The point of a reply is to continue a previous conver

Re: [Tutor] pyexpat

2006-04-19 Thread Danny Yoo
On Wed, 19 Apr 2006, Andre Engels wrote: > 2006/4/18, Danny Yoo <[EMAIL PROTECTED]>: > >> H Can you send a link to the text that's causing performance >> issues? It might be possible that someone here might isolate the >> performance problem. (Hey, it happened before with BeautifulSoup

Re: [Tutor] pyexpat

2006-04-19 Thread Andre Engels
2006/4/18, Danny Yoo <[EMAIL PROTECTED]>: > H Can you send a link to the text that's causing performance > issues? It might be possible that someone here might isolate the > performance problem. (Hey, it happened before with BeautifulSoup... > *grin*) I have sent the text (and another t

Re: [Tutor] Tutor Digest, Vol 26, Issue 62

2006-04-19 Thread nywbon001
Quoting [EMAIL PROTECTED]: > Send Tutor mailing list submissions to > tutor@python.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://mail.python.org/mailman/listinfo/tutor > or, via email, send a message with subject or body 'help' to > [EMAIL PROTECTED]