Re: We need PIGs :)

2007-09-06 Thread Stefan Arentz
Bruno Desthuilliers <[EMAIL PROTECTED]> writes: ... > The problem with Java is that it makes it very painfull to bridge two > APIs together, while Python usually makes it a breeze (easy > delegation, no dumb-ass psycho-rigid type system). So Java's solution > (hyper-formalization) isn't necessary

Re: Using wild character

2007-09-06 Thread Diez B. Roggisch
Sreeraj schrieb: > hi, > > I am a beginner in Python. I wish to know how can i filter a list of > strings using wild characters.ie > Lets say i have list countries = > ["india","africa","atlanta","artica","nigeria"]. I need only the list > of string starting with 'a'. While the startswith-method

Re: creating really big lists

2007-09-06 Thread Paul McGuire
On Sep 6, 12:47 am, Dr Mephesto <[EMAIL PROTECTED]> wrote: > > I need some real speed! a database is waaay to slow for the algorithm > im using. and because the sublists are of varying size, i dont think I > can use an array...- Hide quoted text - > > - Show quoted text - How about a defaultdict a

Re: Using wild character

2007-09-06 Thread Marc 'BlackJack' Rintsch
On Wed, 05 Sep 2007 22:54:55 -0700, TheFlyingDutchman wrote: > To do a "*string" wildcard filter use the endswith() function instead > of startswith() and to do a *string* type wildcard filter use > the find() function > -1. Maybe better the ``in`` operator for the '*string*' type. `str.find()`

Re: StringIO MySQL data blob Image problem

2007-09-06 Thread Tim Golden
dimitri pater wrote: > Hi, > the following code works when inserting images in reportlab tables: > > (result4 is a query result) > a=0 > for i in result4: >cfoto = StringIO() >cfoto.write(result4[a][9].tostring()) >dfoto = cfoto.getvalue() >fileFoto

Re: concise code (beginner)

2007-09-06 Thread Marc 'BlackJack' Rintsch
On Thu, 06 Sep 2007 15:44:57 +1000, bambam wrote: > def script(self) > def a0010(): global self; self.power_on([self.dev]); > def a0020(): global self; self.dev.addLog([self.name, ' started']); > def a0030(): global self; self.resetMinuteReg([self.dev]); > def a0040(): global self;

Re: We need PIGs :)

2007-09-06 Thread Marc 'BlackJack' Rintsch
On Thu, 06 Sep 2007 09:00:02 +0200, Stefan Arentz wrote: > What I find really frustrating in Python (combined with usually bad > documentation) is that many people have different styles. The most > frustratinng being getFoo() vs .foo, vs get_foo(). `getFoo()` is discouraged by PEP 8. You don't h

Autogenerate functions (array of lambdas)

2007-09-06 Thread Chris Johnson
What I want to do is build an array of lambda functions, like so: a = [lambda: i for i in range(10)] (This is just a demonstrative dummy array. I don't need better ways to achieve the above functionality.) print [f() for f in a] results in: [9, 9, 9, 9, 9, 9, 9, 9, 9, 9] rather than the hoped f

Re: Autogenerate functions (array of lambdas)

2007-09-06 Thread Paul Rubin
Chris Johnson <[EMAIL PROTECTED]> writes: > a = [lambda: i for i in range(10)] > print [f() for f in a] > results in: [9, 9, 9, 9, 9, 9, 9, 9, 9, 9] > rather than the hoped for: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] The usual idiom is a = [lambda i=i: i for i in range(10)] That way i is not a free va

Re: Autogenerate functions (array of lambdas)

2007-09-06 Thread Diez B. Roggisch
Chris Johnson schrieb: > What I want to do is build an array of lambda functions, like so: > > a = [lambda: i for i in range(10)] > > (This is just a demonstrative dummy array. I don't need better ways to > achieve the above functionality.) > > print [f() for f in a] > > results in: [9, 9, 9, 9

Re: We need PIGs :)

2007-09-06 Thread Stefan Arentz
Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> writes: > On Thu, 06 Sep 2007 09:00:02 +0200, Stefan Arentz wrote: > > > What I find really frustrating in Python (combined with usually bad > > documentation) is that many people have different styles. The most > > frustratinng being getFoo() vs .foo,

Re: How to do python and RESTful

2007-09-06 Thread Bruno Desthuilliers
MarkyMarc a écrit : > Hi all, > > I want to make a web service application in python and keywords are > RESTful, python and nice urls(urls mapped to python objects). > > I don't want a big framework but a nice small one, that can just do > the things I want. > > I have be looking at quixote, but

Re: Autogenerate functions (array of lambdas)

2007-09-06 Thread Duncan Booth
Chris Johnson <[EMAIL PROTECTED]> wrote: > 2) Is there a better or preferred method than the one I've found? > Use function default arguments to keep the current value of i at the point where you define the function. a = [(lambda n=i: n) for i in range(10)] -- http://mail.python.org/mailman/

Re: Autogenerate functions (array of lambdas)

2007-09-06 Thread David Stanek
On 9/6/07, Chris Johnson <[EMAIL PROTECTED]> wrote: > > What I want to do is build an array of lambda functions, like so: > > a = [lambda: i for i in range(10)] > > (This is just a demonstrative dummy array. I don't need better ways to > achieve the above functionality.) > > print [f() for f in a]

Re: sqlite3.OperationalError: Could not decode to UTF-8 column

2007-09-06 Thread Filipe Sousa
Carsten Haese wrote: > On Wed, 2007-09-05 at 16:40 +0100, Filipe Sousa wrote: > > Try setting > > conn.text_factory = str > > where conn is the name of your sqlite3 connection object. See > http://docs.python.org/lib/sqlite3-Connection-Objects.html for more > information. > > HTH, > Thanks! I

Re: creating really big lists

2007-09-06 Thread Hrvoje Niksic
Dr Mephesto <[EMAIL PROTECTED]> writes: > I need some real speed! Is the speed with the GC turned off sufficient for your usage? -- http://mail.python.org/mailman/listinfo/python-list

Re: Text processing and file creation

2007-09-06 Thread Alberto Griggio
> Thanks for making me aware of the (UNIX) split command (split -l 5 > inFile.txt), it's short, it's fast, it's beautiful. > > I am still wondering how to do this efficiently in Python (being kind > of new to it... and it's not for homework). Something like this should do the job: def nlines(num

Re: How to do python and RESTful

2007-09-06 Thread Michele Simionato
On Sep 5, 9:54 pm, MarkyMarc <[EMAIL PROTECTED]> wrote: > Hi all, > > I want to make a web service application in python and keywords are > RESTful, python and nice urls(urls mapped to python objects). > > I don't want a big framework but a nice small one, that can just do > the things I want. > >

Re: How to do python and RESTful

2007-09-06 Thread Stefan Arentz
Michele Simionato <[EMAIL PROTECTED]> writes: > On Sep 5, 9:54 pm, MarkyMarc <[EMAIL PROTECTED]> wrote: > > Hi all, > > > > I want to make a web service application in python and keywords are > > RESTful, python and nice urls(urls mapped to python objects). > > > > I don't want a big framework but

Re: So what exactly is a complex number?

2007-09-06 Thread Grzegorz Słodkowicz
>> In fact, a proper vector in physics has 4 features: point of >> application, magnitude, direction and sense. >> > > No -- a vector has the properties "magnitude" and direction. > Although not everything that has magnitude and direction is a > vector. > > It's very unusual to have a fixed p

Re: We need PIGs :)

2007-09-06 Thread Bruno Desthuilliers
Stefan Arentz a écrit : > Bruno Desthuilliers <[EMAIL PROTECTED]> writes: > > ... > >> The problem with Java is that it makes it very painfull to bridge two >> APIs together, while Python usually makes it a breeze (easy >> delegation, no dumb-ass psycho-rigid type system). So Java's solution >> (

how to install python2.5.1 in a amd64 redhat linux?

2007-09-06 Thread Ginger
[EMAIL PROTECTED] make install gcc -pthread -c -fno-strict-aliasing -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -I. -I./Include -DPy_BUILD_CORE -o Modules/python.o ./Modules/python.c In file included from Include/Python.h:57, from Modules/python.c:3: Include/pyport.h:734:2: #erro

interesting puzzle......try this you will be rewarded...

2007-09-06 Thread Renu
Hi, Just click on this link n use ur common sence to navigate. It has 23 pages one after the other, starting from this first Page. The trick is to find a way to go to the next page. If u can really go to the 23rd page ur a genius in ur own respect :) So best of luck n keep clicking, tik tik...

SQLite and coercing to Unicode - please help.

2007-09-06 Thread special_dragonfly
Hello! First, the problem: the program below falls over with the following error: TypeError: coercing to Unicode: need string or buffer, NoneType found. and gives the following line: "' WHERE secBoardId='"+Values[0]+"'" My first thought was that Values[0] was containing nothing at all, that would

Re: Autogenerate functions (array of lambdas)

2007-09-06 Thread Hrvoje Niksic
Chris Johnson <[EMAIL PROTECTED]> writes: > What I want to do is build an array of lambda functions, like so: > > a = [lambda: i for i in range(10)] Use a factory function for creating the lambdas. The explicit function call will force a new variable binding to be created each time, and the lamb

Re: interesting puzzle......try this you will be rewarded...

2007-09-06 Thread Steven D'Aprano
On Thu, 06 Sep 2007 09:56:16 +, Renu wrote: > Hi, > > Just click on this link n use ur common sence to navigate. > > It has 23 pages one after the other, starting from this first > Page. The trick is to find a way to go to the next page. [snip] In case it wasn't obvious, the site is nothin

Re: SQLite and coercing to Unicode - please help.

2007-09-06 Thread Steve Holden
special_dragonfly wrote: > Hello! > First, the problem: the program below falls over with the following error: > TypeError: coercing to Unicode: need string or buffer, NoneType found. > and gives the following line: > "' WHERE secBoardId='"+Values[0]+"'" > My first thought was that Values[0] was co

Re: Any syntactic cleanup likely for Py3? And what about doc standards?

2007-09-06 Thread Paul Boddie
On 5 Sep, 21:02, Kenneth McDonald <[EMAIL PROTECTED]> wrote: > The reading I've done so far on Python 3 (alpha announcement, meta-PEP, > some other PEPs) is generally encouraging, but there doesn't seem to be > much on cleaning up the syntax, which has become uglier over time as > features have bee

Re: reload(sys)

2007-09-06 Thread Sönmez Kartal
On 3 Eylül, 05:40, Steven Bethard <[EMAIL PROTECTED]> wrote: > Sönmez Kartal wrote: > > I was using the XMLBuilder(xmlbuilder.py). I'm writing XML files as > > "f.write(str(xml))". At execution of that line, it gives error with > > description, configure your default encoding... > > [and later] > >

Nudge needed for rst to html

2007-09-06 Thread Tim Golden
I'm a bit embarrassed about this, but I've scoured the docutils docs and I can't seem to work out how to take a block of ReStructuredText and output a raw HTML fragment, ideally without a surrounding document or embedded/linked css etc. (I'm trying to allow rst in our helpdesk system which can rend

Re: SQLite and coercing to Unicode - please help.

2007-09-06 Thread special_dragonfly
That helped immensely Steve thank you. You're right, this is my first really big project ever really, not just in Python. Just to clarify, my UPDATE statement instead of looking like this: longstring="UPDATE SecB SET currencyCode='"+Values[1]+"',issuerName='"+Values[2] "',instrName='"+Values[3]

Re: How to do python and RESTful

2007-09-06 Thread Steve Holden
MarkyMarc wrote: > Hi all, > > I want to make a web service application in python and keywords are > RESTful, python and nice urls(urls mapped to python objects). > > I don't want a big framework but a nice small one, that can just do > the things I want. > Translation: I am only interested in a

Re: Nudge needed for rst to html

2007-09-06 Thread Stefan Rank
on 06.09.2007 13:16 Tim Golden said the following: > I'm a bit embarrassed about this, but I've scoured > the docutils docs and I can't seem to work out how > to take a block of ReStructuredText and output a > raw HTML fragment, ideally without a surrounding > document or embedded/linked css etc. (

Re: Nudge needed for rst to html

2007-09-06 Thread Tim Golden
Stefan Rank wrote: > on 06.09.2007 13:16 Tim Golden said the following: >> I'm a bit embarrassed about this, but I've scoured >> the docutils docs and I can't seem to work out how >> to take a block of ReStructuredText and output a >> raw HTML fragment, ideally without a surrounding >> document or

Re: Text processing and file creation

2007-09-06 Thread Arnau Sanchez
[EMAIL PROTECTED] escribió: > I am still wondering how to do this efficiently in Python (being kind > of new to it... and it's not for homework). You should post some code anyway, it would be easier to give useful advice (it would also demonstrate that you put some effort on it). Anyway, here i

ImportError depending on the calling module

2007-09-06 Thread Samuel
Hi, Given the following directory structure: - |-- Obj.py |-- __init__.py |-- foo | |-- FooTest.py | `-- __init__.py `-- start1.py - With the following content: - $ cat Obj.py class Obj(object): pass $ cat __init__.py import Obj __all__ = ['Obj'] $ cat foo/FooT

Re: SQLite and coercing to Unicode - please help.

2007-09-06 Thread Steve Holden
special_dragonfly wrote: > That helped immensely Steve thank you. You're right, this is my first really > big project ever really, not just in Python. > Just to clarify, my UPDATE statement instead of looking like this: > > longstring="UPDATE SecB SET > currencyCode='"+Values[1]+"',issuerName='"

Re: interesting puzzle......try this you will be rewarded...

2007-09-06 Thread Steve Holden
Steven D'Aprano wrote: > On Thu, 06 Sep 2007 09:56:16 +, Renu wrote: > >> Hi, >> >> Just click on this link n use ur common sence to navigate. >> >> It has 23 pages one after the other, starting from this first >> Page. The trick is to find a way to go to the next page. > > [snip] > > In cas

Re: How to do python and RESTful

2007-09-06 Thread Tim Golden
[MarkyMarc] >> I have be looking at quixote, but is this uptodate? "plain" >> mod_python, can this make url to http put,get,delete and post? [Steve Holden] > Would you care to explain why quixote needs to be "uptodate"? Surely it > either does what you want or it doesn't? If it dies, then it hard

Re: interesting puzzle......try this you will be rewarded...

2007-09-06 Thread Steven D'Aprano
On Thu, 06 Sep 2007 04:52:11 -0700, Steve Holden wrote: >> In case it wasn't obvious, the site is nothing but adware. Banner ads, >> google ads, text ads, blah blah blah. I stopped at page 1. >> >> > I'm surprised you went even that far. It was pretty obviously going to > be a click trap. Why bo

Sip4.7

2007-09-06 Thread luca72
Hello i have python2.5 with sip4.6 installed on a linux machine, i need to install sip4.7 but i get a lot of error like this: sip.h:525: error: expected specifier-qualifier-list before 'PyMethodDef' sip.h:609: error: expected specifier-qualifier-list before 'sipForceConvertToFunc' sip.h:666: error

Re: concise code (beginner)

2007-09-06 Thread Steven D'Aprano
On Thu, 06 Sep 2007 15:44:57 +1000, bambam wrote: > First, thank you. > > All of the suggestions match what we want to do much better than what we > are doing. We have a script, written in python, which is doing testing. > But the python script doesn't look anything like the test script, > becaus

startswith( prefix[, start[, end]]) Query

2007-09-06 Thread cjt22
Hi startswith( prefix[, start[, end]]) States: Return True if string starts with the prefix, otherwise return False. prefix can also be a tuple of suffixes to look for. However when I try and add a tuple of suffixes I get the following error: Type Error: expected a character buffer object For

Re: SSL Issue

2007-09-06 Thread Harry George
Jurian Botha <[EMAIL PROTECTED]> writes: > Sorry if this is a real dumb question, but I'm totally stumped. > > I'm trying to connect to a https url in order to do some xml-rpc method > calls, but I'm getting the following error: > > Error Type: sslerror > Error Value: (6, 'TLS/SSL connection has b

Re: startswith( prefix[, start[, end]]) Query

2007-09-06 Thread Tim Golden
[EMAIL PROTECTED] wrote: > Hi > > startswith( prefix[, start[, end]]) States: > > Return True if string starts with the prefix, otherwise return False. > prefix can also be a tuple of suffixes to look for. That particular aspect of the functionality (the multiple prefixes in a tuple) was only

Re: startswith( prefix[, start[, end]]) Query

2007-09-06 Thread Carsten Haese
On Thu, 2007-09-06 at 07:09 -0700, [EMAIL PROTECTED] wrote: > Hi > > startswith( prefix[, start[, end]]) States: > > Return True if string starts with the prefix, otherwise return False. > prefix can also be a tuple of suffixes to look for. However when I try > and add a tuple of suffixes I get

Re: startswith( prefix[, start[, end]]) Query

2007-09-06 Thread [EMAIL PROTECTED]
On Sep 6, 7:09 am, [EMAIL PROTECTED] wrote: > Hi > > startswith( prefix[, start[, end]]) States: > > Return True if string starts with the prefix, otherwise return False. > prefix can also be a tuple of suffixes to look for. However when I try > and add a tuple of suffixes I get the following erro

Re: startswith( prefix[, start[, end]]) Query

2007-09-06 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > Hi > > startswith( prefix[, start[, end]]) States: > > Return True if string starts with the prefix, otherwise return False. > prefix can also be a tuple of suffixes to look for. However when I try > and add a tuple of suffixes I get the following error: > > Type E

Re: 2 python questions!

2007-09-06 Thread Laszlo Nagy
[EMAIL PROTECTED] wrote: > Hi python community! > First question has to do with threading support. There is the > following simple case: > I have a dictionnary that gets it's values -which are url's-from a > function. Sort of > > dictionnary['1'] = "http://www.google.com"; > dictionnary['2'] = "h

Finding specific date ranges

2007-09-06 Thread kyosohma
Hi, I am working on a timesheet application in which I need to to find the first pay period in a month that is entirely contained in that month to calculate vacation time. Below are some example date ranges: December 31, 2006January 13, 2007 # doesn't earn January 14, 2007January 27,

Getting original working directory

2007-09-06 Thread rave247 rave247
Hi, I' am unable to solve this problem. I've got python program, it is installed in standard location. I run this program from some location X (note that I just type relative "myscript", leaving operating system to look up script itself using PATH variable) and this program somewhere in the cod

Re: startswith( prefix[, start[, end]]) Query

2007-09-06 Thread Tim Williams
On 06/09/07, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > > You may want to try with a regexp, but I'm not sure it's worth it (hint: > the timeit module is great for quick small benchmarks). > > Else, you could as well write your own testing function: > > def str_starts_with(astring, *prefixes)

Re: Getting original working directory

2007-09-06 Thread Gabriel Genellina
On 6 sep, 12:19, rave247 rave247 <[EMAIL PROTECTED]> wrote: > I' am unable to solve this problem. I've got python program, it is installed > in standard location. I run this program from some location X (note that I > just type relative "myscript", leaving operating system to look up script > i

Re: ImportError depending on the calling module

2007-09-06 Thread Gabriel Genellina
On 6 sep, 08:47, Samuel <[EMAIL PROTECTED]> wrote: > Given the following directory structure: > > - > |-- Obj.py > |-- __init__.py > |-- foo > | |-- FooTest.py > | `-- __init__.py > `-- start1.py > - The container looks like a package (you didn't tell us the name). Should be p

Re: Autogenerate functions (array of lambdas)

2007-09-06 Thread Chris Johnson
On Sep 6, 3:44 am, Paul Rubin wrote: > Chris Johnson <[EMAIL PROTECTED]> writes: > > a = [lambda: i for i in range(10)] > > print [f() for f in a] > > results in: [9, 9, 9, 9, 9, 9, 9, 9, 9, 9] > > rather than the hoped for: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] > > The usual id

getting the current function

2007-09-06 Thread Gary Robinson
Alex Martelli has a cookbook recipe, whoami, for retrieving the name of the current function: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66062. It uses sys._getframe(). I'm a little wary about using sys._getframe() because of the underscore prefix and the fact that the python docs

Re: Getting original working directory

2007-09-06 Thread Gary Herron
rave247 rave247 wrote: > Hi, > > I' am unable to solve this problem. I've got python program, it is installed > in standard location. I run this program from some location X (note that I > just type relative "myscript", leaving operating system to look up script > itself using PATH variable) and

Re: Sip4.7

2007-09-06 Thread Harry George
luca72 <[EMAIL PROTECTED]> writes: > Hello > i have python2.5 with sip4.6 installed on a linux machine, i need to > install sip4.7 but i get a lot of error like this: > > sip.h:525: error: expected specifier-qualifier-list before > 'PyMethodDef' > sip.h:609: error: expected specifier-qualifier-lis

Re: Finding specific date ranges

2007-09-06 Thread Tim Golden
[EMAIL PROTECTED] wrote: > Hi, > > I am working on a timesheet application in which I need to to find the > first pay period in a month that is entirely contained in that month > to calculate vacation time. Below are some example date ranges: > > > December 31, 2006January 13, 2007 # doesn't

Re: reload(sys)

2007-09-06 Thread Gabriel Genellina
On 6 sep, 08:13, Sönmez Kartal <[EMAIL PROTECTED]> wrote: > On 3 Eylül, 05:40, Steven Bethard <[EMAIL PROTECTED]> wrote: > > Sönmez Kartal wrote: > > > I was using the XMLBuilder(xmlbuilder.py). I'm writing XML files as > > > "f.write(str(xml))". At execution of that line, it gives error with > > >

initializing cooperative method

2007-09-06 Thread jelle
Hi, I'm writing a bunch of abstract classes and I'd like to delegate the arguments of the concrete class the to abstract one. I was surprised to see that the print statement in the abstract class isn't executed. But moreover, I'd like to find out an idiom that allows one to delegate arguments in t

Changing data in an QAbstractListModel

2007-09-06 Thread exhuma.twn
Hi, I want to create a very simple read-only ListView. As the same data is used on various places in the UI, I decided to create a new ListView with a new Model instead of using the QListWidget. So far, the data displays correctly after setting it with "setModel" on the ListView. But how do I tell

Re: ImportError depending on the calling module

2007-09-06 Thread Samuel
On Sep 6, 5:44 pm, Gabriel Genellina <[EMAIL PROTECTED]> wrote: > On 6 sep, 08:47, Samuel <[EMAIL PROTECTED]> wrote: > > Given the following directory structure: > > > - > > |-- Obj.py > > |-- __init__.py > > |-- foo > > | |-- FooTest.py > > | `-- __init__.py > > `-- start1.py > > -

Re: reload(sys)

2007-09-06 Thread Steven Bethard
Sönmez Kartal wrote: > I was using the XMLBuilder(xmlbuilder.py). I'm writing XML files as > "f.write(str(xml))". At execution of that line, it gives error with > description, configure your default encoding... > [and later] > > http://rafb.net/p/RfaF8215.html > > products in the code is a list of

Re: ImportError depending on the calling module

2007-09-06 Thread Samuel
On Sep 6, 6:13 pm, Samuel <[EMAIL PROTECTED]> wrote: > Why does it matter whether I install it in sys.path or whether > sys.path is modified? What's the difference? > > What I am doing is I ship two modules in one tarball with my software. > The software is only unpacked and ran. It has to work wit

Re: Text processing and file creation

2007-09-06 Thread Shawn Milochik
Here's my solution, for what it's worth: #!/usr/bin/env python import os input = open("test.txt", "r") counter = 0 fileNum = 0 fileName = "" def newFileName(): global fileNum, fileName while os.path.exists(fileName) or fileName == "": fileNum += 1 x = "%0.5d" % fileN

Re: initializing cooperative method

2007-09-06 Thread Steven D'Aprano
On Thu, 06 Sep 2007 16:12:11 +, jelle wrote: > Hi, > > I'm writing a bunch of abstract classes and I'd like to delegate the > arguments of the concrete class the to abstract one. I was surprised to > see that the print statement in the abstract class isn't executed. But > moreover, I'd like t

Re: ImportError depending on the calling module

2007-09-06 Thread Gabriel Genellina
On 6 sep, 13:13, Samuel <[EMAIL PROTECTED]> wrote: > On Sep 6, 5:44 pm, Gabriel Genellina <[EMAIL PROTECTED]> wrote: > > They should import the package as any other > > client code, without doing any import tricks nor playing with > > sys.path. > > Why does it matter whether I install it in sys.pa

Help setting default class attributes

2007-09-06 Thread rh0dium
Hi all, I have the following piece of code and I wanted to set the default attributes based on a dictionary. What I am looking for is a way to take PIPODEFAULTS and assign each one as an attribute for the class pipo. Can someone show me how to do this by iterating over the PIPODEFAULTS and assign

Beginners Query - Simple counter problem

2007-09-06 Thread David Barr
I am brand new to Python (this is my second day), and the only experience I have with programming was with VBA. Anyway, I'm posting this to see if anyone would be kind enough to help me with this (I suspect, very easy to solve) query. The following code is in a file which I am running through

Re: initializing cooperative method

2007-09-06 Thread jelle
Ai, calling super(Abstract) is just getting object, sure... However, I'm still curious to know if there's a good idiom for repeating the argument in __init__ for the super(Concrete, self).__init__ ? Thanks, -jelle -- http://mail.python.org/mailman/listinfo/python-list

Re: Finding specific date ranges

2007-09-06 Thread kyosohma
On Sep 6, 10:57 am, Tim Golden <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > Hi, > > > I am working on a timesheet application in which I need to to find the > > first pay period in a month that is entirely contained in that month > > to calculate vacation time. Below are some example d

Re: Finding specific date ranges

2007-09-06 Thread Tim Golden
> Thanks! I'll try it both ways and see if there's any appreciable > difference in speed, although since it will be packaged into an > executable, that may not be an issue anyway. > > Mike I honestly doubt there's any advantage to my approach, certainly not in terms of speed. It's really only if

Re: ImportError depending on the calling module

2007-09-06 Thread Samuel
On Sep 6, 6:44 pm, Gabriel Genellina <[EMAIL PROTECTED]> wrote: > On 6 sep, 13:13, Samuel <[EMAIL PROTECTED]> wrote: > > > On Sep 6, 5:44 pm, Gabriel Genellina <[EMAIL PROTECTED]> wrote: > > > They should import the package as any other > > > client code, without doing any import tricks nor playing

Re: Help setting default class attributes

2007-09-06 Thread Arnaud Delobelle
On Sep 6, 6:26 pm, rh0dium <[EMAIL PROTECTED]> wrote: > Hi all, > > I have the following piece of code and I wanted to set the default > attributes based on a dictionary. What I am looking for is a way to > take PIPODEFAULTS and assign each one as an attribute for the class > pipo. Can someone sho

Re: Help setting default class attributes

2007-09-06 Thread [EMAIL PROTECTED]
On Sep 6, 10:26 am, rh0dium <[EMAIL PROTECTED]> wrote: > Hi all, > > I have the following piece of code and I wanted to set the default > attributes based on a dictionary. What I am looking for is a way to > take PIPODEFAULTS and assign each one as an attribute for the class > pipo. Can someone sh

Re: Beginners Query - Simple counter problem

2007-09-06 Thread Scott David Daniels
David Barr wrote: > I am brand new to Python (this is my second day), and the only > experience I have with programming was with VBA. Anyway, I'm posting > this to see if anyone would be kind enough to help me with this (I > suspect, very easy to solve) query. > > The following code is in a fi

Re: Finding specific date ranges

2007-09-06 Thread kyosohma
On Sep 6, 12:41 pm, Tim Golden <[EMAIL PROTECTED]> wrote: > > Thanks! I'll try it both ways and see if there's any appreciable > > difference in speed, although since it will be packaged into an > > executable, that may not be an issue anyway. > > > Mike > > I honestly doubt there's any advantage t

Re: Getting original working directory

2007-09-06 Thread kyosohma
On Sep 6, 10:19 am, rave247 rave247 <[EMAIL PROTECTED]> wrote: > Hi, > > I' am unable to solve this problem. I've got python program, it is installed > in standard location. I run this program from some location X (note that I > just type relative "myscript", leaving operating system to look up s

Re: initializing cooperative method

2007-09-06 Thread jelle
Ai, calling super(Abstract) is just getting object, sure... However, I'm still curious to know if there's a good idiom for repeating the argument in __init__ for the super(Concrete, self).__init__ ? Thanks, -jelle -- http://mail.python.org/mailman/listinfo/python-list

Re: Beginners Query - Simple counter problem

2007-09-06 Thread Ian Clark
Carsten Haese wrote: > On Thu, 2007-09-06 at 11:00 -0700, Scott David Daniels wrote: >> def d6(count): >> result = 0 >> for die in range(count): >> result += random.randint(1, 6) >> return result > > This, of course, can be further improved into: > > def d6(count): > r

Re: Getting original working directory

2007-09-06 Thread rave247 rave247
"..the *original* directory location *after* os.chdir() is performed.." os.getcwd() is not helping much as it returns the location that was set up in os.chdir() call Thanks > Původní zpráva > Od: Gabriel Genellina <[EMAIL PROTECTED]> > Předmět: Re: Getting ori

Re: Beginners Query - Simple counter problem

2007-09-06 Thread J Sisson
Silly question, but are you importing random somewhere in that file? It works on both my XP machine and my Linux machine (both from CLI) after importing random...though it runs through this: while count <= i: i + 1 times...(You initialize count to 0, then loop over it until it hits i+1 (at which

Re: Beginners Query - Simple counter problem

2007-09-06 Thread Carsten Haese
On Thu, 2007-09-06 at 11:00 -0700, Scott David Daniels wrote: > def d6(count): > result = 0 > for die in range(count): > result += random.randint(1, 6) > return result This, of course, can be further improved into: def d6(count): return sum(random.randint(1, 6) for die

Re: Getting original working directory

2007-09-06 Thread Ian Clark
rave247 rave247 wrote: > "..the *original* directory location *after* os.chdir() is > performed.." os.getcwd() is not helping much as it returns the location > that was set up in os.chdir() call > > Thanks Your question is akin to having a name X that is bound to some value, setting it

library to launch program in linux

2007-09-06 Thread idzwan . nizam
Hi there, I'm a new user. What library should I use so that I can launch program in linux using python? Thank you in advance. -- http://mail.python.org/mailman/listinfo/python-list

Re: library to launch program in linux

2007-09-06 Thread Daniel Larsson
On 9/6/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > Hi there, > > I'm a new user. What library should I use so that I can launch program > in linux using python? Thank you in advance. os.system or the commands library. -- > http://mail.python.org/mailman/listinfo/python-list > -- http:/

Re: Beginners Query - Simple counter problem

2007-09-06 Thread Carsten Haese
On Thu, 2007-09-06 at 11:24 -0700, Ian Clark wrote: > Carsten Haese wrote: > > def d6(count): > > return sum(random.randint(1, 6) for die in range(count)) > > > > My stab at it: > > >>> def roll(times=1, sides=6): > ... return random.randint(times, times*sides) That produces

Re: reload(sys)

2007-09-06 Thread Sönmez Kartal
On 6 Eylül, 19:19, Steven Bethard <[EMAIL PROTECTED]> wrote: > Sönmez Kartal wrote: > > I was using the XMLBuilder(xmlbuilder.py). I'm writing XML files as > > "f.write(str(xml))". At execution of that line, it gives error with > > description, configure your default encoding... > > [and later] > >

Re: Getting original working directory

2007-09-06 Thread rave247 rave247
If I could use os.getcwd() or save the value to some variable before calling os.chdir() I would do it, believe me. However I can't because it is the part of code where I can't do any changes. Also I do not agree that such thing is not possible because after python script finishes its work, it

Re: library to launch program in linux

2007-09-06 Thread Grant Edwards
On 2007-09-06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > I'm a new user. What library should I use so that I can launch > program in linux using python? Thank you in advance. subprocess -- Grant Edwards grante Yow! Hello, GORRY-O!!

Re: Help setting default class attributes

2007-09-06 Thread Steve Holden
[EMAIL PROTECTED] wrote: > On Sep 6, 10:26 am, rh0dium <[EMAIL PROTECTED]> wrote: >> Hi all, >> >> I have the following piece of code and I wanted to set the default >> attributes based on a dictionary. What I am looking for is a way to >> take PIPODEFAULTS and assign each one as an attribute for t

Re: interesting puzzle......try this you will be rewarded...

2007-09-06 Thread Tobiah
My adblock extension must be doing a great job. I don't see any ads. The puzzle is fun really, but I'm stuck right now at 'eeiigg'. Renu wrote: > Hi, > > Just click on this link n use ur common sence to navigate. > > It has 23 pages one after the other, starting from this first > > Page. > T

Re: Getting original working directory

2007-09-06 Thread rave247 rave247
> One of the best portable ones that I've seen used is this: > > os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]),'.')) This is not working. Please look at this code: import os import sys x = os.getcwd() os.chdir("\whatever") y = #here I don't know. This code is not working: os.pat

Re: Beginners Query - Simple counter problem

2007-09-06 Thread Ian Clark
Carsten Haese wrote: > On Thu, 2007-09-06 at 11:24 -0700, Ian Clark wrote: >> Carsten Haese wrote: >>> def d6(count): >>> return sum(random.randint(1, 6) for die in range(count)) >>> >> My stab at it: >> >> >>> def roll(times=1, sides=6): >> ... return random.randint(times, times

Re: Getting original working directory

2007-09-06 Thread David Stanek
On 9/6/07, rave247 rave247 <[EMAIL PROTECTED]> wrote: > > If I could use os.getcwd() or save the value to some variable before > calling os.chdir() I would do it, believe me. However I can't because it > is the part of code where I can't do any changes. Why is it not possible. If nothing else cre

Re: Getting original working directory

2007-09-06 Thread Gary Herron
rave247 rave247 wrote: > "..the *original* directory location *after* os.chdir() is > performed.." os.getcwd() is not helping much as it returns the location > that was set up in os.chdir() call > That requirement is just to absurd to be taken at face value. Are you saying you *CAN'T*

Re: interesting puzzle......try this you will be rewarded...

2007-09-06 Thread Evil Bert
Tobiah wrote: > My adblock extension must be doing a great job. > I don't see any ads. The puzzle is fun really, > but I'm stuck right now at 'eeiigg'. eight --> eeiigg nine --> nniinn Kinda silly, but it works -- http://mail.python.org/mailman/listinfo/python-list

Re: Getting original working directory

2007-09-06 Thread Steve Holden
rave247 rave247 wrote: > If I could use os.getcwd() or save the value to some variable before calling > os.chdir() > I would do it, believe me. However I can't because it is the part of code where I > can't do any changes. > > Also I do not agree that such thing is not possible because after p

Re: Beginners Query - Simple counter problem

2007-09-06 Thread David Barr
Scott David Daniels wrote: > David Barr wrote: >> I am brand new to Python (this is my second day), and the only >> experience I have with programming was with VBA. Anyway, I'm posting >> this to see if anyone would be kind enough to help me with this (I >> suspect, very easy to solve) query. >

  1   2   >