[Tutor] Python DB
Dear List, I've been looking for a simple python based DB for a fairly simple app. Only a single user, single access needed, but with a dynamic structure (which needs to be extensible very easily). Having googled and read some stuff, I seem to come down to a choice between KirbyBase (very nice and simple, and has the advantages of text- based files) or ZODB. I have a bit of an allergy to SQL, even if mediated via SQLObject (which looks very nice) These seem to be at the opposite end of the spectrum - so do others have either comments on these options, or other suggestions. Thanks, Matt ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python DB
Matt Williams schrieb: > These seem to be at the opposite end of the spectrum - so do others have > either comments on these options, or other suggestions. Well, I havn't use either yet, but I have some experience with SQL DBs. >From what I read on the website, Kirby seems like a nice idea, if you really need nothing more than table-structured data, made up of simple data types. It only supports basic data types (int, float, string, boolean, date[time]) no objects and it isn't even relational, i.e. you can't express references between tables or columns and when querying for data, you can do so only from one table at a time. This makes it very hard to normalize your data, because you would have to handle all the relations between tables in your code. The nice thing is, it writes flat text files, you can edit by hand or probably even import into a spreadsheet application. ZOBD, on the other hand, is a totally differnt beast. It doesn't store data in tables, but stores (as the name says) objects, which might feel more natural to use in your code. Note, that it is written partly in C and as such, might not be so easy to deploy as a pure-python solution like Kirby. Just my 2 centy, Chris ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python DB
On Thu, 22 Sep 2005, Matt Williams wrote: > I've been looking for a simple python based DB for a fairly simple app. > Only a single user, single access needed, but with a dynamic structure > (which needs to be extensible very easily). Hi Matt, What kind of data are you trying to represent? And how large will that data be? The reason I ask is because I'm going to lead with the silly question: would something like the "shelve" module be sufficent? http://www.python.org/doc/lib/module-shelve.html I'm just making sure we can cross 'shelve' off as not viable for the application. But knowing why 'shelve' would be unsuitable will be helpful in figuring out a good solution. *grin* ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python DB
Matt Williams wrote: > Dear List, > > I've been looking for a simple python based DB for a fairly simple app. > Only a single user, single access needed, but with a dynamic structure > (which needs to be extensible very easily). > > Having googled and read some stuff, I seem to come down to a choice > between KirbyBase (very nice and simple, and has the advantages of text- > based files) or ZODB. I have a bit of an allergy to SQL, even if > mediated via SQLObject (which looks very nice) You should look at pysqlite, it's fairly lightweight. http://initd.org/tracker/pysqlite Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python DB
Dnia czwartek, 22 września 2005 10:43, Matt Williams napisał: > I've been looking for a simple python based DB for a fairly simple app. > Only a single user, single access needed, but with a dynamic structure > (which needs to be extensible very easily). For pure Python implementation you might try SnakeSQL (http://www.pythonweb.org/projects/snakesql/): ---[CITE]--- SnakeSQL is a pure Python SQL database written to remove the dependence of the Python Web Modules on 3rd party drivers for non-Python databases like MySQL but designed to be a useful database in its own right. The database supports the simplest possible subset of ANSI SQL 92 including NULLs (something other pure Python databases such as Gadfly do not currently support) as well as more advanced features such as foreign key constraints and simple joins. The database is fully DB-API 2.0 compliant and is written in layers so that it can easily be extended to support different storage mechanisms. Currently implemented are a fast binary DBM driver (default) and a slower CSV file driver (handy for viewing table contents when designing and developing an application or database structure). ---[/CITE]--- If you don't need pure-Python,take a look at gadfly (http://gadfly.sourceforge.net) If the data isn't too big, you may even try XML storage with DOM access (PyXML http://pyxml.sourceforge.net/) HTH, -- Pawel Kraszewski ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python DB
I love sqlobject.org it this a wrapper between many sql implementation (mysql, postgresql..) and python. get a look. Ced. -- Cedric BRINER Geneva - Switzerland ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python DB
i like MySQLdb - although I said that you hate MySQL. FreeSQL.org has a nice free MySQL server. I also have some example code if you would like from work that I did last week ... -ed On 9/22/05, Cedric BRINER <[EMAIL PROTECTED]> wrote: I love sqlobject.orgit this a wrapper between many sql implementation (mysql, postgresql..) and python. get a look.Ced.--Cedric BRINERGeneva - Switzerland___Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor-- edward hotchkiss ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python Editors (particualrly Vim)
Okay, I've also found this: http://cream.sourceforge.net/features.html Which is amazing! It's an easy-to-use mod for Vim. It's modeless and lots of other doubtless heretical things, but it includes an outstanding auto-complete mode for text files! Ctrl-Space auto completes the word you're typing based on what you've already written in the file. I've also been trying SPE and that looks to be the most pleasing editor so far. It's also written in Python (AFAICT) which will probably have benefits in the future. Ed On 21/09/05, Ed Singleton <[EMAIL PROTECTED]> wrote: > I don't believe there's any kinds of wars on this mailing group. :) > > I found this Python Vim code completion thing in my searches today: > http://freshmeat.net/projects/pydiction/ > > Don't know how good it is, but it looks like it'd do the job. > > Ed > > On 21/09/05, Gabriel Farrell <[EMAIL PROTECTED]> wrote: > > Uh oh, looks like you're begging for an editor war. > > > > That said, I'm in the vim camp. It can do everything you specified > > for all of the languages you mention (well, I'm not sure about > > collapsible code...web search...aha![1]). After using it for four > > years, I'm still learning new tricks (see, for example, this page I > > found today on indentation[2]). > > > > vim's extendable with python scripts, but a lot of what you need for > > coding is already built in. I find most of my info either in the help > > manual that comes with it (:h) or at vim.org. > > > > gsf > > > > [1] http://www.dgp.toronto.edu/~mjmcguff/learn/vim/folding.txt > > [2] http://www.vim.org/tips/tip.php?tip_id=83 > > > > > > On Wed, Sep 21, 2005 at 02:00:20PM +0100, Ed Singleton wrote: > > > I've been trying to decide which editor to use to edit Python (on > > > Windows mostly). > > > > > > My wishlist of features would be: > > > > > > - automatic code formatting (indentation etc) > > > - collapsible code (to collapse def's etc) > > > - automatic code coloring (that's easily changeable) > > > - auto-completion of namespaces > > > - easy to run scripts from the editor (a shortcut key to run them or > > > something) > > > > > > As I also do a lot of html, css and javascript it would be cool to > > > have an editor that could also handle them, in which case I would want > > > the same features for those languages, as well as the ability to write > > > macros, scripts, etc in python. > > > > > > Having looked at loads of editors, I've ended up looking at emacs and vim. > > > > > > Emacs seems too difficult with not enough support for using the mouse. > > > > > > Vim seemed better, and I get the impression that it is possible to use > > > python to script the editor, but I can't find much information on > > > using vim as a python editor on windows. > > > > > > My various questions are: > > > > > > What other features should I be looking for? > > > > > > What would be the best editor for a beginner to start using, with a > > > view to the long term? > > > > > > Where can I find some authoritative information about setting emacs or > > > vim up as a fully featured python editor? > > > > > > Thanks > > > > > > Ed > > > ___ > > > Tutor maillist - Tutor@python.org > > > http://mail.python.org/mailman/listinfo/tutor > > > > > ___ > > 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] Python Editors (particualrly Vim)
jedit is also good. I use that. The only thing is that you can't execute the script from there. It is great for collapsing at indentions. www.jedit.org Johan On Thu, 2005-09-22 at 13:54 +0100, Ed Singleton wrote: Okay, I've also found this: http://cream.sourceforge.net/features.html Which is amazing! It's an easy-to-use mod for Vim. It's modeless and lots of other doubtless heretical things, but it includes an outstanding auto-complete mode for text files! Ctrl-Space auto completes the word you're typing based on what you've already written in the file. I've also been trying SPE and that looks to be the most pleasing editor so far. It's also written in Python (AFAICT) which will probably have benefits in the future. Ed On 21/09/05, Ed Singleton <[EMAIL PROTECTED]> wrote: > I don't believe there's any kinds of wars on this mailing group. :) > > I found this Python Vim code completion thing in my searches today: > http://freshmeat.net/projects/pydiction/ > > Don't know how good it is, but it looks like it'd do the job. > > Ed > > On 21/09/05, Gabriel Farrell <[EMAIL PROTECTED]> wrote: > > Uh oh, looks like you're begging for an editor war. > > > > That said, I'm in the vim camp. It can do everything you specified > > for all of the languages you mention (well, I'm not sure about > > collapsible code...web search...aha![1]). After using it for four > > years, I'm still learning new tricks (see, for example, this page I > > found today on indentation[2]). > > > > vim's extendable with python scripts, but a lot of what you need for > > coding is already built in. I find most of my info either in the help > > manual that comes with it (:h) or at vim.org. > > > > gsf > > > > [1] http://www.dgp.toronto.edu/~mjmcguff/learn/vim/folding.txt > > [2] http://www.vim.org/tips/tip.php?tip_id=83 > > > > > > On Wed, Sep 21, 2005 at 02:00:20PM +0100, Ed Singleton wrote: > > > I've been trying to decide which editor to use to edit Python (on > > > Windows mostly). > > > > > > My wishlist of features would be: > > > > > > - automatic code formatting (indentation etc) > > > - collapsible code (to collapse def's etc) > > > - automatic code coloring (that's easily changeable) > > > - auto-completion of namespaces > > > - easy to run scripts from the editor (a shortcut key to run them or something) > > > > > > As I also do a lot of html, css and _javascript_ it would be cool to > > > have an editor that could also handle them, in which case I would want > > > the same features for those languages, as well as the ability to write > > > macros, scripts, etc in python. > > > > > > Having looked at loads of editors, I've ended up looking at emacs and vim. > > > > > > Emacs seems too difficult with not enough support for using the mouse. > > > > > > Vim seemed better, and I get the impression that it is possible to use > > > python to script the editor, but I can't find much information on > > > using vim as a python editor on windows. > > > > > > My various questions are: > > > > > > What other features should I be looking for? > > > > > > What would be the best editor for a beginner to start using, with a > > > view to the long term? > > > > > > Where can I find some authoritative information about setting emacs or > > > vim up as a fully featured python editor? > > > > > > Thanks > > > > > > Ed > > > ___ > > > Tutor maillist - Tutor@python.org > > > http://mail.python.org/mailman/listinfo/tutor > > > > > ___ > > Tutor maillist - Tutor@python.org > > http://mail.python.org/mailman/listinfo/tutor > > > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] time challange
Hey there, i use mx.DateTime.RelativeDateTimeDiff to get the difference between date_x and date_y. what i need to do divide this amount of time into 20 different times that spaced out between the date_x and the date_y. so if the difference between date_x and date_y is 20 hours, i need 20 DateTimes that are one hour apart from each other. If the difference is 40 minutes, i need the 20 DateTimes to be spaced out 2 minutes from each other.. what would be a way to pull this off? i have looked at the docs for mxDateTime http://www.egenix.com/files/python/mxDateTime.html and there seems to be a divide operation, but i dont quite know what it is talking about with the deltas. anyone have a good start point? thanks shawn ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Using superclass __init__ method
Hi, I just noticed that in the following environment: class Base: def __init__(self): ... class Child(Base): pass the following statement: child = Child() would automatically execute the superclass __init__ method. This is exactly what I was looking for - but in the Cookbook, I found several suggestions on how to actively force the invocation of the superclass __init__. Is this behvaiour documented? Thanks, Jan -- There are 10 kinds of people: those who understand binary, and those who don't ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Python DB
Dear List, Thanks for all the advice! Obviously, I'm still a bit torn, but some of the ideas looked good. In terms of spec, the DB can be fairly simple (single access, etc.). Lower dependency on other libraries is good. Also, it needs to be cross- platform. The problem (I have) with SQL-type DB is that I cannot be sure ahead of time of the exact data structure. The DB will be about patients, who have diseases, and also have treatments.Clearly, I can't specify now the exact structure of the table. The advantage of SQL is that you can (in general) do things like constrain types for fields, and give enumerated options, which makes the data more consistent. The thing I liked about KirbyBase was that it used text files. This is a real advantage, as it means that I can access the data from other application easily, and also makes it easier to back-up (can just copy a few files). The same would seem to be true of the XML-based options. The advantage of ZODB was that the "object" structure seemed to map well to the concept of patients, with diseases, with treatments, etc. (and Shelve would work at least as a trial implementation) The final thing is that I needs to have a simple GUI frontend. The nice thing about ZODB is that I could just map the eventhandlers to functions on objects.. If people have more comments in the light of the bigger spec. above, I'd still love to hear them... Matt ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Using superclass __init__ method
Jan Eden wrote: > Hi, > > I just noticed that in the following environment: > > class Base: > def __init__(self): > ... > > class Child(Base): > pass > > the following statement: > > child = Child() > > would automatically execute the superclass __init__ method. This is exactly > what I was looking for - but in the Cookbook, I found several suggestions on > how to actively force the invocation of the superclass __init__. > > Is this behvaiour documented? This is standard behavior for any class attribute - if it's not defined in the derived class, the base class is checked. It's not special for __init__. I can't find a comprehensive reference for the way attribute lookup works - anyone else? Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] How to install python on to a remote apache server
Hi, I'd like towrite some internet applications but I don't know how to test them unless I have python on my server. However, It's running Apache 1.3.3 and it's a remote one (I'm in the Americas and it's in Europe) so I don't know how to access it. I also would like to know what platform of python to download. Is there a special server edition? Or do I just use a regular Linux edition? Thanks, Joe ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python Editors (particualrly Vim)
Ed Singleton wrote: >Okay, I've also found this: >http://cream.sourceforge.net/features.html > > > It seems to me that all the functionality listed here can easily be done in regular vim. I would still recommend investing time in learning plain old vim or gvim. The payoff for proficiency is high. -- Poor Yorick ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Using superclass __init__ method
There are several areas this seems to touch upon, most of them well covered by Guido himself in http://www.python.org/2.2/descrintro.html firstly to call a super class' methods you get the subclass to refer to the *superclass* then the method (note not to the superclass instance) from newstyle tutorial (comment mine): class B: def m(self): print "B here" class C(B): def m(self): print "C here" B.m(self) #refer to the class definition not the instance of C via self. Secondly to run __init__ as you have described is normal behaviour because the __call__ function that every new instance must go through makes sure that __init__ is called, and as there is not one defined in subclass it uses the one in superclass. This should have the same effect, but is more controllable: class Base: def __init__(self): print "hello" class Child(Base): def __init__(self): Base.__init__(self) produces:: >>> c = Child() hello This might also help make things clearer class Base: def __init__(self): print "hello" class Child(Base): def __init__(self): Base.__init__(self) def foo(self): print "foo" c = Child() b = Base() x = Child() x.foo() Child.foo(x) #1 Child.foo(b) #2 The class defintion of Child is an object (since 2.2) and can be called with parameters. at #1 we see foo printed out because we have called the Child object method foo with an object of type Child (this is essentially self) Of course we can try passing in another object (#2) but it will barf. This issue is frankly just muddy. Not because of bad design or poor documentation but because it is a awkward subject. Read the link above - most of us mortals have had to read it several times. Things also get a little more complex with __new__ but its all in there However I have not found a really good explanation of the whole instance creation thing - perhaps this list could make one? -- Paul Brian m. 07875 074 534 t. 0208 352 1741 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Using superclass __init__ method
Kent Johnson wrote on 22.09.2005: >This is standard behavior for any class attribute - if it's not >defined in the derived class, the base class is checked. It's not >special for __init__. > >I can't find a comprehensive reference for the way attribute lookup >works - anyone else? Well, I did know that any attribute used explicitly with a class instance is looked up in the class, then the base class etc: class Base: variable = 1 class Child(Base): pass child = Child() print child.variable 1 What I did not know was that the __init__ method behaves the same way - i.e. that Python looks for __init__ upon instantiation until it finds one. Thanks, Jan -- A good programmer is someone who looks both ways before crossing a one-way street. - Doug Linder ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Using superclass __init__ method
Hi, paul brian wrote on 22.09.2005: > >class Base: > def __init__(self): > print "hello" > >class Child(Base): > def __init__(self): > Base.__init__(self) > This is how I did it so far. But in my program, I have 10 subclasses with identical __init__ methods, so I can simplify the setup a lot. Thanks for your help, Jan -- Alcohol and calculus don't mix - PLEASE don't drink and derive. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Simultaneous Adobe Reader
Hello, From windows, using a python script how can I open Adobe Reader without displaying a PDF document? Furthermore, using a script is it possible to run two Adobe Reader sessions simulatneously. Thanks in advance. Kind Regards, JR ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python Editors (particualrly Vim)
* Poor Yorick <[EMAIL PROTECTED]> [050922 06:29]: > Ed Singleton wrote: > > >Okay, I've also found this: > >http://cream.sourceforge.net/features.html > > > > > > > It seems to me that all the functionality listed here can easily be done > in regular vim. I would still recommend investing time in learning > plain old vim or gvim. The payoff for proficiency is high. I'd be a poor war-fighter when it came to editors. Personally, I use all of vim, gvim, emacs and Xemacs and I work in a multiple-language environment mainly on Linux. *but* if I were programming only in python and doing so on Windows, I'd probably use pythonwin. I've used it in the past and was very impressed, a real python IDE. MTCW tim -- Tim Johnson <[EMAIL PROTECTED]> http://www.alaska-internet-solutions.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] USB Capture Image WebCAM
Hey Tutors I want to make a program that looks like Conquer Cam For those who doesn't know what is it its a program that captures images from your USB WebCAM and saves them to send via FTP. Anyway, getting to the point I don't know how to get the video from the camara to watch it inside a GUI made in Python. Is this possible? How? One step at the time..First I want to accomplish the online viewer of the camera and then talk about capturing the image I'm using Python 2.3.4 over Windows XP Professional Thanks in advanced Alberto ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] time challange
You are fairly close >>> t1 = today() >>> t1 >>> t2 = today() + RelativeDateTime(hours=20) >>> t2 >>> t3 = t2 - t1 >>> t3.hours 20.0 >>> slice = t3/20 >>> slice t3 is a "Delta" - that is an abstract representation of time - it is not the 20 hours since midnight, just 20 hours at any time in the universe. slice is just 1/20th of that same abstract time. But because of the munificence of Marc we can add that abstract hour to a real fixed time (ignoring Einstein of course) >>> t1 + slice And so that is a "real" datetime 1/20th of the way forward from t1 so a simple loop will get you your 20 evenly spaced time periods, which is what i think you were asking for. cheers On 9/22/05, nephish <[EMAIL PROTECTED]> wrote: > Hey there, > > i use mx.DateTime.RelativeDateTimeDiff to get the difference between > date_x and date_y. > what i need to do divide this amount of time into 20 different times > that spaced out between the date_x and the date_y. > > so if the difference between date_x and date_y is 20 hours, i need 20 > DateTimes that are one hour apart from each other. If the difference is > 40 minutes, i need the 20 DateTimes to be spaced out 2 minutes from each > other.. > > what would be a way to pull this off? i have looked at the docs for > mxDateTime > http://www.egenix.com/files/python/mxDateTime.html > and there seems to be a divide operation, but i dont quite know what it > is talking about > with the deltas. > > anyone have a good start point? > > thanks > shawn > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > -- -- Paul Brian m. 07875 074 534 t. 0208 352 1741 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python DB
I would look quite seriously at SQLObject It is a bit rough round the edges but given a class defintion, it then creates the underlying SQL tables and handles the CRUD (create update delete) for you. I do not like this approach and prefer the other but equally nice ability it has to look at a database and create appropriate classes, which you can then use. It is a class of Object Relational mapper, of which there are a few Java production level ones but I do not know of any "real world" uses of SQL Object. Perhaps others do. Backups and access from other applications imply you want a fairly serious admin load afterwarss - in which case I would think very carefully before using anything other than a "real" RDBMS (Oracle, MySQL, Postgres MSAccess even). Backups and synchronous access are what they are designed to do. However are you quite sure a normal db table will not suffice - I tend to find that the underlying data structure is never as fluid as one suspects. Patient - disease - treatment sounds a fairly striaghtforward domain. Perhaps if you shared a few things that make you worried it will change dramatically someone might be able to suggest workable structures. On 9/22/05, Matt Williams <[EMAIL PROTECTED]> wrote: > Dear List, > > Thanks for all the advice! Obviously, I'm still a bit torn, but some of > the ideas looked good. > > In terms of spec, the DB can be fairly simple (single access, etc.). > Lower dependency on other libraries is good. Also, it needs to be cross- > platform. > > The problem (I have) with SQL-type DB is that I cannot be sure ahead of > time of the exact data structure. The DB will be about patients, who > have diseases, and also have treatments.Clearly, I can't specify now > the exact structure of the table. The advantage of SQL is that you can > (in general) do things like constrain types for fields, and give > enumerated options, which makes the data more consistent. > > The thing I liked about KirbyBase was that it used text files. This is a > real advantage, as it means that I can access the data from other > application easily, and also makes it easier to back-up (can just copy a > few files). The same would seem to be true of the XML-based options. The > advantage of ZODB was that the "object" structure seemed to map well to > the concept of patients, with diseases, with treatments, etc. (and > Shelve would work at least as a trial implementation) > > The final thing is that I needs to have a simple GUI frontend. The nice > thing about ZODB is that I could just map the eventhandlers to functions > on objects.. > > If people have more comments in the light of the bigger spec. above, I'd > still love to hear them... > > Matt > > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > -- -- Paul Brian m. 07875 074 534 t. 0208 352 1741 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] time challange
paul brian wrote: >You are fairly close > > > t1 = today() t1 > > > t2 = today() + RelativeDateTime(hours=20) t2 > > > t3 = t2 - t1 t3.hours >20.0 > > slice = t3/20 slice > > >t3 is a "Delta" - that is an abstract representation >of time - it is not the 20 hours since midnight, just 20 hours >at any time in the universe. >slice is just 1/20th of that same abstract time. But because of the munificence >of Marc we can add that abstract hour to a real fixed time (ignoring >Einstein of course) > > > t1 + slice > > >And so that is a "real" datetime 1/20th of the way forward from t1 > >so a simple loop will get you your 20 evenly spaced time periods, >which is what i think you were asking for. > >cheers > > > >On 9/22/05, nephish <[EMAIL PROTECTED]> wrote: > > >>Hey there, >> >>i use mx.DateTime.RelativeDateTimeDiff to get the difference between >>date_x and date_y. >>what i need to do divide this amount of time into 20 different times >>that spaced out between the date_x and the date_y. >> >>so if the difference between date_x and date_y is 20 hours, i need 20 >>DateTimes that are one hour apart from each other. If the difference is >>40 minutes, i need the 20 DateTimes to be spaced out 2 minutes from each >>other.. >> >>what would be a way to pull this off? i have looked at the docs for >>mxDateTime >>http://www.egenix.com/files/python/mxDateTime.html >>and there seems to be a divide operation, but i dont quite know what it >>is talking about >>with the deltas. >> >>anyone have a good start point? >> >>thanks >>shawn >>___ >>Tutor maillist - Tutor@python.org >>http://mail.python.org/mailman/listinfo/tutor >> >> >> > > >-- >-- >Paul Brian >m. 07875 074 534 >t. 0208 352 1741 > > > YES ! that is what i needed. This is great. i think i understand your steps ok, but you lost me with the munificence of Marc. i never got to take physics. All the same, thanks so much shawn ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] PDF
Hello, I would like to know how to open a pdf document using a python script. thanks ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] USB Capture Image WebCAM
On Thu, 22 Sep 2005, Alberto Troiano wrote: > For those who doesn't know what is it its a program that captures images > from your USB WebCAM and saves them to send via FTP. > > Anyway, getting to the point I don't know how to get the video from the > camara to watch it inside a GUI made in Python. You might be in luck; there's a project that provides USB Webcam access for Windows: http://videocapture.sourceforge.net/ Good luck! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python DB
On Thu, 22 Sep 2005, Matt Williams wrote: > The problem (I have) with SQL-type DB is that I cannot be sure ahead of > time of the exact data structure. The DB will be about patients, who > have diseases, and also have treatments.Clearly, I can't specify now > the exact structure of the table. The advantage of SQL is that you can > (in general) do things like constrain types for fields, and give > enumerated options, which makes the data more consistent. Hi Matt, But another kind of advantage of SQL is that it can accomodate ad-hoc queries. That's a big one, since it means that if the requirements change, the database can usually handle it efficiently. Object databases are tied to a particular structure and access pattern, so they may not be so adaptable to different access patterns. I'm also not quite seeing how an object database like ZODB will allow you to escape planning about how to represent patients, diseases, and treatement data. And SQL databases may be more flexible to structural change than you might expect. SQLite is a lightweight database that you might want to consider: http://www.sqlite.org/ http://initd.org/projects/pysqlite and SQLite does have enough support for ALTER TABLE to let you change the database structure as the problem statement solidifies: http://sqlite.org/faq.html#q13 Best of wishes to you! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Challenge [was Re: Why won't it enter the quiz?]
http://zoffee.tripod.com/purchasecompprogs.htm is the URL. - Original Message - From: Adam To: Nathan Pinno Sent: Thursday, September 22, 2005 5:21 AM Subject: Re: [Tutor] Challenge [was Re: Why won't it enter the quiz?] What's the URL? On 22/09/05, Nathan Pinno <[EMAIL PROTECTED]> wrote: I have a challenge for everyone on the tutor list. Take this serious, anddon't think I'm asking it just because I am mad or something. I'm not, Ijust want to clear the air once and for all. Here is the challenge:Choose any program that I am selling on my site, any one of them, and ask mefor the code. I'll gladly send you a copy. Determine if I have copied mostof it, or wrote most of it myself. Post your analysis to the group. If you determine that I have copied most of it, I'll remove it and post an apology.If not, you must admit that I wrote most of it myself. Fair enough?Farewell for now,Nathan Pinno.- Original Message - From: "Byron" <[EMAIL PROTECTED]>To: "Nathan Pinno" <[EMAIL PROTECTED]>; < Tutor@python.org>Sent: Friday, September 16, 2005 9:25 PMSubject: Re: [Tutor] Why won't it enter the quiz?> Nathan Pinno wrote:>> Brian and all, I am just asking for help - after all I write most each program myself,>> and just ask for help in debugging it whenever I cannot figure it out. If>> this is being sneaky, I apologize, and won't ask for help anymore. >>> No, don't do that... Happy that you are asking questions! I was humored> by the idea that you have a GREAT business model there... :-) FREE> Labor -- wow, should of thought of that one earlier... >> Have a great weekend and hope you keep posting!>> Brian> ---___Tutor maillist - Tutor@python.orghttp://mail.pythonorg/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python DB
> The problem (I have) with SQL-type DB is that I cannot be sure ahead of > time of the exact data structure. The DB will be about patients, who > have diseases, and also have treatments.Clearly, I can't specify now > the exact structure of the table. The advantage of SQL is that you can > (in general) do things like constrain types for fields, and give > enumerated options, which makes the data more consistent. My experience: - keeping in-memory: fast and easy as long as the amounts of data are *very* limited. - kirby: I looked at it almost two years ago and it's nice, easy to use, but needs speedups for large amounts of data. At the time I tweaked some of the code and got very nice improvements (some of them are now in there I think). - bsddb: very comfortable (just treat it like a dictionary), fast lookup, but searching in the values is slow. If you have thousands of records, you'll most likely need to employ some tricks to get fast responses when searching. - sql (my experience is with SQLite): harder to work with (had some issues getting SQLObject to work with it, so I did it the very hard way by writing SQL statements), but insanely fast searches. > The thing I liked about KirbyBase was that it used text files. This is a > real advantage, as it means that I can access the data from other > application easily, and also makes it easier to back-up (can just copy a > few files). The same would seem to be true of the XML-based options. The bsddb and sqlite also have single-file databases. > The final thing is that I needs to have a simple GUI frontend. The nice > thing about ZODB is that I could just map the eventhandlers to functions > on objects.. sqlite has some viewers available (in my experience not quite reliable, but YMMV). bsddb can be inspected and manipulated easily in an interactive python session. > If people have more comments in the light of the bigger spec. above, I'd > still love to hear them... I'd give bsddb a try if the application mainly involves looking up treatments/illnesses for a given patient (with the patient being the key in the database) or if the number of patients is quite low (hundreds). If however an important use is to do other types of searches too (e.g. find all patients with an age above X who use a drug Y) and you have a large database, some SQL DB would be better. -- Yours, Andrei = Mail address in header catches spam. Real contact info (decode with rot13): [EMAIL PROTECTED] Fcnz-serr! Cyrnfr qb abg hfr va choyvp cbfgf. V ernq gur yvfg, fb gurer'f ab arrq gb PP. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] PDF
Jorge Ramirez schrieb: > > Hello, > > I would like to know how to open a pdf document using a python script. - What do you mean by "open"? - start a PDF viewer (e.g acrobar reader) from python? - or read in the file in Python and extract information from it? - What platform are you on? - Windows - Linux/Unix - MAC OS - What kind of PDFs do you have? - only Text - with images - or forms? - with encryption? - What versions of the PDF document format ? You have to be a little more specific, please, if you want us to help you! Chris ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] USB Capture Image WebCAM
Hey Danny I have downloaded videoCapture but I can't make it run. This is the error I get when I try run the example on the Web Page I want to be able to see the reproduction of the WebCAM inside a GUI of Python I didn't find docs for this on the WEB. If somebody have some pointers I would appreciate a lot Thanks in advanced Alberto >From: Danny Yoo <[EMAIL PROTECTED]> >To: Alberto Troiano <[EMAIL PROTECTED]> >CC: tutor@python.org >Subject: Re: [Tutor] USB Capture Image WebCAM >Date: Thu, 22 Sep 2005 11:38:16 -0700 (PDT) > > > >On Thu, 22 Sep 2005, Alberto Troiano wrote: > > > For those who doesn't know what is it its a program that captures images > > from your USB WebCAM and saves them to send via FTP. > > > > Anyway, getting to the point I don't know how to get the video from the > > camara to watch it inside a GUI made in Python. > >You might be in luck; there's a project that provides USB Webcam access >for Windows: > > http://videocapture.sourceforge.net/ > >Good luck! > >___ >Tutor maillist - Tutor@python.org >http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] FW: Re: USB Capture Image WebCAM
Hey Danny I have downloaded videoCapture but I can't make it run. This is the error I get when I try run the example Traceback (most recent call last): File "C:\Documents and Settings\Daron Malakian\Desktop\VideoCapture-0.9\Tools\webcam-uploader\webcam-uploader.py", line 130, in ? cam = VideoCapture.Device(devnum=devnum) File "C:\Python23\lib\VideoCapture.py", line 49, in __init__ self.dev = vidcap.new_Dev(devnum, showVideoWindow) Error: Capture Graph could not be created. I want to be able to see the reproduction of the WebCAM inside a GUI of Python I didn't find docs for this on the WEB. If somebody have some pointers I would appreciate a lot Thanks in advanced Alberto > >From: Danny Yoo <[EMAIL PROTECTED]> > >To: Alberto Troiano <[EMAIL PROTECTED]> > >CC: tutor@python.org > >Subject: Re: [Tutor] USB Capture Image WebCAM > >Date: Thu, 22 Sep 2005 11:38:16 -0700 (PDT) > > > > > > > >On Thu, 22 Sep 2005, Alberto Troiano wrote: > > > > > For those who doesn't know what is it its a program that captures >images > > > from your USB WebCAM and saves them to send via FTP. > > > > > > Anyway, getting to the point I don't know how to get the video from >the > > > camara to watch it inside a GUI made in Python. > > > >You might be in luck; there's a project that provides USB Webcam access > >for Windows: > > > > http://videocapture.sourceforge.net/ > > > >Good luck! > > > >___ > >Tutor maillist - Tutor@python.org > >http://mail.python.org/mailman/listinfo/tutor > > >___ >Tutor maillist - Tutor@python.org >http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Lost Color Lost Mind
Just learning Python Running: Python 2.4.1 (#2, Aug 25 2005, 18:20:57) [GCC 4.0.1 (4.0.1-2mdk for Mandriva Linux release 2006.0)] on linux2 Concerning: IDLE I tried several fonts, and finally changed the font on IDLE to courier size 22 bold, so that it is easier for my old eyes to read, and while the shell window still has color depicting the structure, the program window is now displaying only in black. (I also forgot what font IDLE originally was set on. A mind is such a terrible thing to loose...) Question: How do I get color back in my programming window??? (It's s pretty that way!) Thanks! Terry ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] where to insert?
I would like to insert string.join(msgList,"") into the following program where do I insert it? # numbers2text.py # A program to convert a sequence of ASCII numbers into # a string of text. import string # include string library for the split function. def main(): print "This program converts a sequence of ASCII numbers into" print "the string of text that it represents." print # Get the message to encode inString = raw_input("Please enter the ASCII-encoded message: ") # Loop through each substring and build ASCII message message = "" for numStr in string.split(inString): asciiNum = eval(numStr) # convert digits to a number message = message + chr(asciiNum) # append character to message print "The decoded message is:", message main() ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] FW: Re: USB Capture Image WebCAM
Hey Danny Thanks for the reply and the tip...I will try to reach him/her. In answer to your question, Conquer Cam is a buyable software. What it does is to show the WebCAM an captures Images every x time and sends it via FTP to any server. But it doesn't works so fine, I think its because I cracked and didn't buy it *grin* But I need like 200 licenses so it would be a little expensive. That's why I'm trying to make my own Python Gengis Cam *grin* Thanks again Alberto >From: Danny Yoo <[EMAIL PROTECTED]> >To: Alberto Troiano <[EMAIL PROTECTED]> >CC: Tutor >Subject: Re: [Tutor] FW: Re: USB Capture Image WebCAM >Date: Thu, 22 Sep 2005 15:29:07 -0700 (PDT) > > > > I have downloaded videoCapture but I can't make it run. This is the >error I > > get when I try run the example > > > > Traceback (most recent call last): > > File "C:\Documents and Settings\Daron > > >Malakian\Desktop\VideoCapture-0.9\Tools\webcam-uploader\webcam-uploader.py", > > line 130, in ? > > cam = VideoCapture.Device(devnum=devnum) > > File "C:\Python23\lib\VideoCapture.py", line 49, in __init__ > > self.dev = vidcap.new_Dev(devnum, showVideoWindow) > > Error: Capture Graph could not be created. > >Hi Alberto, > >You may want to talk with the developer of the VideoCapture module >software. I don't know what's going on here. Testing this is also >complicated because I don't have a webcam or Windows. > > >Wait, let's back up a moment. You mentioned earlier that: > > > > > > For those who doesn't know what is it its a program that captures > > > > > images from your USB WebCAM and saves them to send via FTP. > >Does this mean then that you already have a program that saves webcam >images to disk? > > >If so, then if we know what graphical format they are, then perhaps we >might be able to use PIL to convert them into a format that your favorite >GUI toolkit can display. PIL can talk with different graphical formats: > > http://www.pythonware.com/products/pil/ > >Tkinter integrates with this: > > http://effbot.org/zone/tkinter-plot.htm > >And wxpython + PIL also appears to work: > > http://wiki.wxpython.org/index.cgi/WorkingWithImages > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] how to insert a string?
Hello I would like to insert a string into the following program to simplify the program. Any suggestions on how I might do so? # dateconvert2.py #Converts day month and year numbers into two date formats import string def main(): # get the day month and year day, month, year = input("Please enter the day, month and year numbers: ") date1 = str(month)+"/"+str(day)+"/"+str(year) months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"] monthStr = months[month-1] date2 = monthStr+" " + str(day) + ", " + str(year) print "The date is", date1, "or", date2 main() ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Threading in a for loop
Bill Burns wrote: > I've got a few questions regarding Threading. I've never used threads > before and I want to make sure I'm doing it correctly ;-) > > I have a GUI app and it processes Tiff files to PDF (or PostScript). The > GUI has a ListBox which the user populates with files to convert. You > click on a Button and the file conversion starts. When all the files > have been converted, the ListBox items (the files) are cleared. > > Initially, you had no way of knowing what was going on until all the > files where cleared from the ListBox. > > So I thought of creating threads in the 'for loop' and displaying the > name of each file in the statusBar of the GUI (as they are being > processed). You don't necessarily need threads for this. If you just want to provide feedback and don't care about the GUI being responsive, just do the processing in a loop, update the status bar and call root.update_idletasks() to allow the GUI to redraw. (Assuming you are using Tkinter.) If you want the GUI to remain responsive so for example you can have a Cancel button, then I would make a single thread and process all the files in that thread. Don't sleep in the thread; call root.update() to give some time to event handling. Somehow you will have to notify the main thread that the worker thread is done. The only reason I can think of to make a separate thread for each image is if the process is significantly I/O bound. My guess is that Tiff to PDF conversion is CPU-intensive and a single worker thread will be plenty. More notes below... > Here's my method which takes the files in the ListBox and sends them off > to my Convert() class (self.convert = Convert()). > > def convertTiff2PDF(self): > from time import time > #Let's see how long this takes... I saw Kent do this on the > #Python Tutor list before :-) > start = time() > #Grab a tuple which contains width & length > sizes = self.getPaperSize() > width = sizes[0] > length = sizes[1] > #Count the number of files in the ListBox > fileCount = self.fileListBox.count() > for index in range(fileCount): > #Get each filename > filenames = str(self.fileListBox.text(index)) > #Setup the worker thread and send the filenames in > worker = WorkerThread(self, filenames) > #Start threading > worker.start() > #Send each file to be converted > self.convert.tiff2pdf(width, length, filenames) The above line should be in the thread, not in the main loop - you are spawning threads that do nothing but update the status display - and they will compete for that. > #We're done, so clear the ListBox > self.fileListBox.clear() > #Check the time again > end = time() > msg = '%s Files Processed in %0.3f Seconds.' % (fileCount, > (end-start)) > #Grab the statusBar and insert the message > statusBar = self.statusBar() > statusBar.message(msg, 0) > > > And here's what I'm doing in my Thread class: > > class WorkerThread(Thread): > """Thread class.""" > def __init__(self, parent, files): > Thread.__init__(self) > self.parent = parent > self.files = files > > def run(self): > statusBar = self.parent.statusBar() > msg = 'Processing: %s, please wait.' % (self.files) > statusBar.message(msg, 100) > time.sleep(1) > > > Am I doing this threading properly? Is it 'OK' to start multiple threads > like this (in the for loop)? It's possible that a user could put 'many' > files into the ListBox, by 'many' I mean 100-200 files. It's OK to have multiple threads but yours aren't doing any useful work. I hope this helps get you on track, it's a bit brief. Kent > > Thanks for your help. > > Bill > > > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Diamond Equivalent
I am coming to Python from Perl. Does Python have anything like the diamond operator found in Perl? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] FW: Re: USB Capture Image WebCAM
> I have downloaded videoCapture but I can't make it run. This is the error I > get when I try run the example > > Traceback (most recent call last): > File "C:\Documents and Settings\Daron > Malakian\Desktop\VideoCapture-0.9\Tools\webcam-uploader\webcam-uploader.py", > line 130, in ? > cam = VideoCapture.Device(devnum=devnum) > File "C:\Python23\lib\VideoCapture.py", line 49, in __init__ > self.dev = vidcap.new_Dev(devnum, showVideoWindow) > Error: Capture Graph could not be created. Hi Alberto, You may want to talk with the developer of the VideoCapture module software. I don't know what's going on here. Testing this is also complicated because I don't have a webcam or Windows. Wait, let's back up a moment. You mentioned earlier that: > > > > For those who doesn't know what is it its a program that captures > > > > images from your USB WebCAM and saves them to send via FTP. Does this mean then that you already have a program that saves webcam images to disk? If so, then if we know what graphical format they are, then perhaps we might be able to use PIL to convert them into a format that your favorite GUI toolkit can display. PIL can talk with different graphical formats: http://www.pythonware.com/products/pil/ Tkinter integrates with this: http://effbot.org/zone/tkinter-plot.htm And wxpython + PIL also appears to work: http://wiki.wxpython.org/index.cgi/WorkingWithImages ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] how to insert a string?
Hello I would like to insert a string into the following program to simplify the program. Any suggestions on how I might do so? # dateconvert2.py #Converts day month and year numbers into two date formats import string def main(): # get the day month and year day, month, year = input("Please enter the day, month and year numbers: ") date1 = str(month)+"/"+str(day)+"/"+str(year) months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"] monthStr = months[month-1] date2 = monthStr+" " + str(day) + ", " + str(year) print "The date is", date1, "or", date2 main() ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Diamond Equivalent
On Thu, 22 Sep 2005 [EMAIL PROTECTED] wrote: > I am coming to Python from Perl. Does Python have anything like the > diamond operator found in Perl? Hi Kim, According to 'perldoc perlop': """ The null filehandle <> is special: it can be used to emulate the behavior of sed and awk. Input from <> comes either from standard input, or from each file listed on the command line. Here's how it works: the first time <> is evaluated, the @ARGV array is checked, and if it is empty, $ARGV[0] is set to "-", which when opened gives you standard input. The @ARGV array is then processed as a list of filenames. """ Python includes a module called 'fileinput' that does sorta this: http://www.python.org/doc/lib/module-fileinput.html If you have more questions, please feel free to ask. Good luck to you! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] how to insert a string?
On Thu, 22 Sep 2005 [EMAIL PROTECTED] wrote: > I would like to insert a string into the following program to simplify > the program. Any suggestions on how I might do so? Hello, It's a little unclear what you're asking when you mention "insert a string": usually, inserting anything into a program makes it larger, and consequently, slightly less simple. Are you asking, instead, what techniques we can use to simplify the program? If so, one thing you may want to look at is the 'strftime' function in the 'time' module. For example: ## >>> import time >>> time.strftime("%B %d %Y") 'September 22 2005' ## time.strftime() might not be perfect, since I think it only works on range of dates starting from the Epoch (around 1970) to about the year 2038. So if you need larger ranges than this, strftime probably won't be an appropriate tool, although something like: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/306860 might be useful. Anyway, let's take a quick at a line in your program. > date1 = str(month)+"/"+str(day)+"/"+str(year) The construction of 'date1' can be slightly simplified if you use string formatting: http://www.python.org/doc/lib/typesseq-strings.html For example: ## >>> "%s went up the hill" % ("curious george") 'curious george went up the hill' ## Best of wishes! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How to install python on to a remote apache server
> I'd like to write some internet applications but I don't know how to > test them unless I have python on my server. However, It's running > Apache 1.3.3 and it's a remote one (I'm in the Americas and it's in > Europe) so I don't know how to access it. I also would like to know what > platform of python to download. Is there a special server edition? Or do > I just use a regular Linux edition? Hi Joseph, Any version of Python should be fine: the higher, the better, just because of the improvements to the Standard Library. The work though will probably be mostly on the Apache end of things. You'll be better off asking the Apache folks for help in setting up Python as a server language. For Apache 1.3, the documentation in: http://httpd.apache.org/docs/1.3/howto/cgi.html will be useful for whoever needs to configure Apache on your remote server. For testing, you may want explore using Apache locally on your machine, or you can even use CGIHTTPServer: http://www.python.org/doc/lib/module-CGIHTTPServer.html ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Lost Color Lost Mind
--- Terry Kemmerer <[EMAIL PROTECTED]> wrote: > Just learning Python > > Running: > > Python 2.4.1 (#2, Aug 25 2005, 18:20:57) > [GCC 4.0.1 (4.0.1-2mdk for Mandriva Linux > release 2006.0)] on > linux2 > > Concerning: IDLE > > I tried several fonts, and finally changed the font > on IDLE to courier > size 22 bold, so that it is easier for my old eyes > to read, and while > the shell window still has color depicting the > structure, the program > window is now displaying only in black. (I also > forgot what font IDLE > originally was set on. A mind is such a terrible > thing to loose...) > > Question: How do I get color back in my programming > window??? (It's > s pretty that way!) > > Thanks! > > Terry Until you save the program window to a file with a '.py' extension, IDLE doesn't realize it's Python source code so it doesn't do any syntax highlighting. HTH, Don __ Yahoo! for Good Donate to the Hurricane Katrina relief effort. http://store.yahoo.com/redcross-donate3/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Lost Color Lost Mind]
> Just learning Python > > Running: > > Python 2.4.1 (#2, Aug 25 2005, 18:20:57) > [GCC 4.0.1 (4.0.1-2mdk for Mandriva Linux > release 2006.0)] on > linux2 > > Concerning: IDLE > > I tried several fonts, and finally changed the font > on IDLE to courier > size 22 bold, so that it is easier for my old eyes > to read, and while > the shell window still has color depicting the > structure, the program > window is now displaying only in black. (I also > forgot what font IDLE > originally was set on. A mind is such a terrible > thing to loose...) > > Question: How do I get color back in my programming > window??? (It's > s pretty that way!) > > Thanks! > > Terry Until you save the program window to a file with a '.py' extension, IDLE doesn't realize it's Python source code so it doesn't do any syntax highlighting. HTH, Don Ha! Thanks Don! I knew this was a dumb question. But, Tricky! Tricky! No wonder I couldn't find a combo of changes to revert things back. I kept looking at my test programs, and they were all in color because I always type the first word and SAVE to start a file! (a habit) I never noticed the difference. You just saved me a lot of confusion time wondering if I had broken something. Terry __ Yahoo! for Good Donate to the Hurricane Katrina relief effort. http://store.yahoo.com/redcross-donate3/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] FW: Re: USB Capture Image WebCAM
Alberto Troiano wrote: > > But it doesn't works so fine, I think its because I cracked and didn't buy > it *grin* > But I need like 200 licenses so it would be a little expensive. That's why > I'm trying to make my own Python Gengis Cam *grin* > You just admitted on a public forum to committing a crime. Not wise, friend. -- Poor Yorick ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] words in networking I should probably know
Hello, again. I'm back with my instant messenger project. My teacher has assigned us to write our papers, excluding the procedure, results, and conclusion. One of my topics is going to be networks. Does anyone know a list of words relating to networking/networks that I should know for this project? Not the definitions, but just the words; I can look up the definitions on webopedia. It would be appreciated. Thanks! -John __ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Challenge [was Re: Why won't it enter the quiz?]
The URL is http://zoffee.tripod.com/purchasecomprogs.htm, and here is a third alternative: If the group says it is okay, I'll add them to the By: line as The Python Group, and I'll donate half of the sales to a charity of the group's choice. Nathan Pinno - Original Message - From: Adam To: Nathan Pinno Sent: Thursday, September 22, 2005 5:21 AM Subject: Re: [Tutor] Challenge [was Re: Why won't it enter the quiz?] What's the URL? On 22/09/05, Nathan Pinno <[EMAIL PROTECTED]> wrote: I have a challenge for everyone on the tutor list. Take this serious, anddon't think I'm asking it just because I am mad or something. I'm not, Ijust want to clear the air once and for all. Here is the challenge:Choose any program that I am selling on my site, any one of them, and ask mefor the code. I'll gladly send you a copy. Determine if I have copied mostof it, or wrote most of it myself. Post your analysis to the group. If you determine that I have copied most of it, I'll remove it and post an apology.If not, you must admit that I wrote most of it myself. Fair enough?Farewell for now,Nathan Pinno.- Original Message - From: "Byron" <[EMAIL PROTECTED]>To: "Nathan Pinno" <[EMAIL PROTECTED]>; < Tutor@python.org>Sent: Friday, September 16, 2005 9:25 PMSubject: Re: [Tutor] Why won't it enter the quiz?> Nathan Pinno wrote:>> Brian and all, I am just asking for help - after all I write most each program myself,>> and just ask for help in debugging it whenever I cannot figure it out. If>> this is being sneaky, I apologize, and won't ask for help anymore. >>> No, don't do that... Happy that you are asking questions! I was humored> by the idea that you have a GREAT business model there... :-) FREE> Labor -- wow, should of thought of that one earlier... >> Have a great weekend and hope you keep posting!>> Brian> ---___Tutor maillist - Tutor@python.orghttp://mail.pythonorg/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Threading in a for loop
Here are some more resources for you. This cookbook recipe is very similar to what you want to do, just customize workerThread1 to do the actual work. It shows how to use a Queue to communicate back to the GUI thread. http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/82965 Here are a couple of thread pool recipes - these will be useful if you decide you need multiple threads. http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/203871 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/435883 Threading is a complex subject and I don't have time and energy to do it justice right now. I hope these resources help. Kent Kent Johnson wrote: > Bill Burns wrote: > >>I've got a few questions regarding Threading. I've never used threads >>before and I want to make sure I'm doing it correctly ;-) >> >>I have a GUI app and it processes Tiff files to PDF (or PostScript). The >>GUI has a ListBox which the user populates with files to convert. You >>click on a Button and the file conversion starts. When all the files >>have been converted, the ListBox items (the files) are cleared. >> >>Initially, you had no way of knowing what was going on until all the >>files where cleared from the ListBox. >> >>So I thought of creating threads in the 'for loop' and displaying the >>name of each file in the statusBar of the GUI (as they are being >>processed). > > > You don't necessarily need threads for this. If you just want to provide > feedback and don't care about the GUI being responsive, just do the > processing in a loop, update the status bar and call root.update_idletasks() > to allow the GUI to redraw. (Assuming you are using Tkinter.) > > If you want the GUI to remain responsive so for example you can have a Cancel > button, then I would make a single thread and process all the files in that > thread. Don't sleep in the thread; call root.update() to give some time to > event handling. Somehow you will have to notify the main thread that the > worker thread is done. > > The only reason I can think of to make a separate thread for each image is if > the process is significantly I/O bound. My guess is that Tiff to PDF > conversion is CPU-intensive and a single worker thread will be plenty. > > More notes below... > > >>Here's my method which takes the files in the ListBox and sends them off >>to my Convert() class (self.convert = Convert()). >> >>def convertTiff2PDF(self): >> from time import time >> #Let's see how long this takes... I saw Kent do this on the >> #Python Tutor list before :-) >> start = time() >> #Grab a tuple which contains width & length >> sizes = self.getPaperSize() >> width = sizes[0] >> length = sizes[1] >> #Count the number of files in the ListBox >> fileCount = self.fileListBox.count() >> for index in range(fileCount): >> #Get each filename >> filenames = str(self.fileListBox.text(index)) >> #Setup the worker thread and send the filenames in >> worker = WorkerThread(self, filenames) >> #Start threading >> worker.start() >> #Send each file to be converted >> self.convert.tiff2pdf(width, length, filenames) > > > The above line should be in the thread, not in the main loop - you are > spawning threads that do nothing but update the status display - and they > will compete for that. > > >> #We're done, so clear the ListBox >> self.fileListBox.clear() >> #Check the time again >> end = time() >> msg = '%s Files Processed in %0.3f Seconds.' % (fileCount, >>(end-start)) >> #Grab the statusBar and insert the message >> statusBar = self.statusBar() >> statusBar.message(msg, 0) >> >> >>And here's what I'm doing in my Thread class: >> >>class WorkerThread(Thread): >> """Thread class.""" >> def __init__(self, parent, files): >> Thread.__init__(self) >> self.parent = parent >> self.files = files >> >> def run(self): >> statusBar = self.parent.statusBar() >> msg = 'Processing: %s, please wait.' % (self.files) >> statusBar.message(msg, 100) >> time.sleep(1) >> >> >>Am I doing this threading properly? Is it 'OK' to start multiple threads >>like this (in the for loop)? It's possible that a user could put 'many' >>files into the ListBox, by 'many' I mean 100-200 files. > > > It's OK to have multiple threads but yours aren't doing any useful work. > > I hope this helps get you on track, it's a bit brief. > > Kent > >>Thanks for your help. >> >>Bill >> >> >>___ >>Tutor maillist - Tutor@python.org >>http://mail.python.org/mailman/listinfo/tutor >> >> > > > ___ > 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] Challenge [was Re: Why won't it enter the quiz?]
At 06:42 PM 9/22/2005, Nathan Pinno wrote: The URL is http://zoffee.tripod.com/purchasecomprogs.htm [snip] At your invitation I visited the site. I personally would not purchase anything listed there due to insufficient information. I don't know what I'm getting! I suggest you dedicate a page to each program with at least one screenshot and explanation of what the program does. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Diamond Equivalent
At 03:46 PM 9/22/2005, [EMAIL PROTECTED] wrote: >I am coming to Python from Perl. Does Python have anything like the diamond >operator found in Perl? Some of us (who don't know Perl) might help you if you tell us what the diamond operator does. How could we get to first base with it? What are its facets? Does is have a heart counterpart? Ca it sing? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Challenge [was Re: Why won't it enter the quiz?]
bob wrote: > At 06:42 PM 9/22/2005, Nathan Pinno wrote: > >> The URL is http://zoffee.tripod.com/purchasecomprogs.htm > > > [snip] > > At your invitation I visited the site. I personally would not purchase > anything listed there due to insufficient information. I don't know what > I'm getting! > > I suggest you dedicate a page to each program with at least one > screenshot and explanation of what the program does. The shareware system would work best for these little programs. If it were me, I would just use the honor system -- a pop-up window on program startup that says "friendly reminder: This program costs $12.99. Have you paid me for it or contributed to charity in my name yet? (yes/no)" Even though some (or even many, who knows?) people won't pay, it's worth the exposure. Another advantage is if people like what they download, they will come back and look for other things. In effect, your previous programs can advertise your newer programs. Exposure is valuable. -- Poor Yorick ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor