Re: Module caching

2009-04-03 Thread Jon Clements
On 3 Apr, 23:58, Aaron Scott aaron.hildebra...@gmail.com wrote: are you an experienced python programmer? Yeah, I'd link to think I'm fairly experienced and not making any stupid mistakes. That said, I'm fairly new to working with mod_python. All I really want is to have mod_python stop

Re: How to add lines to the beginning of a text file?

2009-04-03 Thread Jon Clements
On 4 Apr, 02:21, dean de...@yahoo.com wrote: Hello, As the subject says how would I go about adding the lines to the beginning of a text file? Thanks in advance. I'd create a new file, then write your new lines, then iterate the existing file and write those lines... If no errors occcur,

Re: Best way to extract from regex in if statement

2009-04-03 Thread Jon Clements
On 4 Apr, 02:14, bwgoudey bwgou...@gmail.com wrote: I have a lot of if/elif cases based on regular expressions that I'm using to filter stdin and using print to stdout. Often I want to print something matched within the regular expression and the moment I've got a lot of cases like: ...

Re: Using a decorator to *remove* parameters from a call

2009-04-13 Thread Jon Clements
On 13 Apr, 11:11, Michel Albert exh...@gmail.com wrote: A small foreword: This might look like a cherrypy-oriented post, and should therefore go to the cherrypy group, but if you read to the end, you'll see it's a more basic python problem, with cherrypy only as an example. ;) From the

Re: noob help request - how to make a list of defined class?

2008-09-09 Thread Jon Clements
On Sep 9, 3:11 pm, [EMAIL PROTECTED] wrote: I have defined two classes with one common field (called code) and several different fields. In class A there is only one instance of any given code as all items are individual. In class B, there may be none, one or many instances of each code, as

Re: dict slice in python (translating perl to python)

2008-09-10 Thread Jon Clements
On 10 Sep, 16:28, hofer [EMAIL PROTECTED] wrote: Hi, Let's take following perl code snippet: %myhash=( one  = 1    , two   = 2    , three = 3 ); ($v1,$v2,$v3) = @myhash{qw(one two two)}; # -- line of interest print $v1\n$v2\n$v2\n; How do I translate the second line in a similiar compact

Re: Reading binary data

2008-09-10 Thread Jon Clements
On 10 Sep, 18:14, Aaron Scott [EMAIL PROTECTED] wrote: I've been trying to tackle this all morning, and so far I've been completely unsuccessful. I have a binary file that I have the structure to, and I'd like to read it into Python. It's not a particularly complicated file. For instance:

Re: Reading binary data

2008-09-10 Thread Jon Clements
On 10 Sep, 18:33, Jon Clements [EMAIL PROTECTED] wrote: On 10 Sep, 18:14, Aaron Scott [EMAIL PROTECTED] wrote: I've been trying to tackle this all morning, and so far I've been completely unsuccessful. I have a binary file that I have the structure to, and I'd like to read it into Python

Re: Reading binary data

2008-09-10 Thread Jon Clements
On Sep 10, 6:45 pm, Aaron Scott [EMAIL PROTECTED] wrote: CORRECTION: '3cII' should be '3sII'. Even with the correction, I'm still getting the error. Me being silly... Quick fix: signature = file.read(3) then the rest can stay the same, struct.calcsize('3sII') expects a 12 byte string,

Re: Reading binary data

2008-09-10 Thread Jon Clements
On Sep 10, 7:16 pm, Aaron Scott [EMAIL PROTECTED] wrote: Taking everything into consideration, my code is now: import struct file = open(test.gde, rb) signature = file.read(3) version, attr_count = struct.unpack('II', file.read(8)) print signature, version, attr_count for idx in

Re: del and sets proposal

2008-10-02 Thread Jon Clements
On Oct 2, 11:20 pm, Larry Bates [EMAIL PROTECTED] wrote: You can do the following: a = [1,2,3,4,5] del a[0] and a = {1:'1', 2: '2', 3: '3', 4:'4', 5:'5'} del a[1] why doesn't it work the same for sets (particularly since sets are based on a dictionary)? a = set([1,2,3,4,5]) del a[1]

Re: Understanding mxODBC Insert Error

2007-07-29 Thread Jon Clements
On 29 Jul, 17:41, Greg Corradini [EMAIL PROTECTED] wrote: Hello, I'm trying to perform a simple insert statement into a table called Parcel_Test (see code below). Yet, I get an error message that I've never seen before (see traceback below). I've tried to put a semicolon at the end of the sql

Re: What order does info get returned in by os.listdir()

2007-08-15 Thread Jon Clements
To emulate the order of XP, you might be able to get away with something like:- sorted( myData, key=lambda L: L.replace('~',chr(0)) ) That just forces all '~'s to be before everything else. hth, Jon. On 15 Aug, 14:33, Jeremy C B Nicoll [EMAIL PROTECTED] wrote: Marc 'BlackJack' Rintsch

Re: for x,y in word1, word2 ?

2008-08-11 Thread Jon Clements
On Aug 11, 5:40 am, Mensanator [EMAIL PROTECTED] wrote: On Aug 10, 11:18 pm, ssecorp [EMAIL PROTECTED] wrote: Is there a syntax for looping through 2 iterables at the same time? for x in y: for a in b: is not what I want. I want: for x in y and for a in b: Something like this?

Re: How to stop iteration with __iter__() ?

2008-08-19 Thread Jon Clements
On Aug 19, 12:39 pm, ssecorp [EMAIL PROTECTED] wrote: I want a parse a file of the format: movieId customerid, grade, date customerid, grade, date customerid, grade, date etc. so I could do with open file as reviews and then for line in reviews. but first I want to take out the movie id

Re: finding out the number of rows in a CSV file

2008-08-27 Thread Jon Clements
On Aug 27, 12:16 pm, SimonPalmer [EMAIL PROTECTED] wrote: anyone know how I would find out how many rows are in a csv file? I can't find a method which does this on csv.reader. Thanks in advance You have to iterate each row and count them -- there's no other way without supporting

Re: finding out the number of rows in a CSV file

2008-08-27 Thread Jon Clements
On Aug 27, 12:29 pm, Simon Brunning [EMAIL PROTECTED] wrote: 2008/8/27 SimonPalmer [EMAIL PROTECTED]: anyone know how I would find out how many rows are in a csv file? I can't find a method which does this on csv.reader. len(list(csv.reader(open('my.csv' -- Cheers, Simon B.

Re: finding out the number of rows in a CSV file

2008-08-27 Thread Jon Clements
On Aug 27, 12:48 pm, Simon Brunning [EMAIL PROTECTED] wrote: 2008/8/27 Jon Clements [EMAIL PROTECTED]: len(list(csv.reader(open('my.csv' Not the best of ideas if the row size or number of rows is large! Manufacture a list, then discard to get its length -- ouch! I do try to avoid

Re: finding out the number of rows in a CSV file [Resolved]

2008-08-27 Thread Jon Clements
On Aug 27, 12:54 pm, SimonPalmer [EMAIL PROTECTED] wrote: On Aug 27, 12:50 pm, SimonPalmer [EMAIL PROTECTED] wrote: On Aug 27, 12:41 pm, Jon Clements [EMAIL PROTECTED] wrote: On Aug 27, 12:29 pm, Simon Brunning [EMAIL PROTECTED] wrote: 2008/8/27 SimonPalmer [EMAIL PROTECTED

Re: no string.downer() ?

2008-08-27 Thread Jon Clements
On Aug 27, 3:16 pm, ssecorp [EMAIL PROTECTED] wrote: if i want to make a string downcase, is upper().swapcase() the onyl choice? there is no downer() ? lower() You need to be careful ssecorp, you might be at risk of being considered a troll -- always give the benefit though (probably why I'm

Re: Algorithm used by difflib.get_close_match

2008-09-02 Thread Jon Clements
On Sep 2, 2:17 pm, Guillermo [EMAIL PROTECTED] wrote: Hi all, Does anyone know whether this function uses edit distance? If not, which algorithm is it using? Regards, Guillermo help(difflib.get_close_matches) will give you your first clue... --

psycopg2 large result set

2007-05-25 Thread Jon Clements
Hi All. I'm using psycopg2 to retrieve results from a rather large query (it returns 22m records); unsurprisingly this doesn't fit in memory all at once. What I'd like to achieve is something similar to a .NET data provider I have which allows you to set a 'FetchSize' property; it then retrieves

Re: Using print instead of file.write(str)

2006-06-01 Thread Jon Clements
Didn't know of the syntax: lovely to know about it Bruno - thank you. To the OP - I find the print statement useful for something like: print 'this','is','a','test' 'this is a test' (with implicit newline and implicit spacing between parameters) If you want more control (more flexibility,

Re: Using print instead of file.write(str)

2006-06-01 Thread Jon Clements
I meant 'trailing': not leading. mea culpa. Jon. Jon Clements wrote: Didn't know of the syntax: lovely to know about it Bruno - thank you. To the OP - I find the print statement useful for something like: print 'this','is','a','test' 'this is a test' (with implicit newline

Re: How to generate k+1 length strings from a list of k length strings?

2006-06-08 Thread Jon Clements
Are you asking the question, Which pairs of strings have one character different in each?, or Which pairs of strings have a substring of len(string) - 1 in common?. Jon. Girish Sahani wrote: I have a list of strings all of length k. For every pair of k length strings which have k-1 characters

Re: groupby is brilliant!

2006-06-13 Thread Jon Clements
Not related to itertools.groupby, but the csv.reader object... If for some reason you have malformed CSV files, with embedded newlines or something of that effect, it will raise an exception. To skip those, you will need a construct of something like this: raw_csv_in = file('filenamehere.csv')

Re: __cmp__ method

2006-06-14 Thread Jon Clements
This probably isn't exactly what you want, but, unless you wanted to do something especially with your own string class, I would just pass a function to the sorted algorithm. eg: sorted( [a,b,c], cmp=lambda a,b: cmp(len(a),len(b)) ) gives you the below in the right order... Never tried doing

Re: Iteration over recursion?

2006-06-20 Thread Jon Clements
MTD wrote: Hello all, (snip) I've been told that iteration in python is generally more time-efficient than recursion. Is that true? (snip) AFAIK, in most languages it's a memory thing. Each time a function calls itself, the 'state' of that function has to be stored somewhere so that it

Re: Iteration over recursion?

2006-06-20 Thread Jon Clements
Sudden Disruption wrote: Bruno, It doesn't. Technical possible, but BDFL's decision... Sure. But why bother? I agree. Anything that can be done with recursion can be done with iteration. Turng proved that in 1936. Recursion was just an attempt to unify design approach by

Re: Iteration over recursion?

2006-06-20 Thread Jon Clements
Kay Schluehr wrote: Nick Maclaren wrote: Tail recursion removal can often eliminate the memory drain, but the code has to be written so that will work - and I don't know offhand whether Python does it. http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496691 Regards, Kay

Re: error with string (beginner)

2006-06-25 Thread Jon Clements
Alex Pavluck wrote: Hello. I get the following error with the following code. Is there something wrong with my Python installation? code: import types something = input(Enter something and I will tell you the type: ) if type(something) is types.IntType: print you entered an integer

Extending built-in objects/classes

2006-07-03 Thread Jon Clements
Hi All, I've reached the point in using Python where projects, instead of being like 'batch scripts', are becoming more like 'proper' programs. Therefore, I'm re-designing most of these and have found things in common which I can use classes for. As I'm only just starting to get into classes, I

Re: Extending built-in objects/classes

2006-07-03 Thread Jon Clements
[EMAIL PROTECTED] wrote: My experiance is mostly with old-style classes, but here goes. first off, the what question is actually easier than you think. After all, self is an instance of a string, so self[3:4] would grab the slice of characters between 3 and 4 =) That's kind of funky - I

Re: Extending built-in objects/classes

2006-07-03 Thread Jon Clements
John Machin wrote: (snip) You have already been told: you don't need self.what, you just write self ... self *is* a reference to the instance of the mystr class that is being operated on by the substr method. (snip) I get that; let me clarify why I asked again. As far as I'm aware, the

Re: IRC questions!!

2006-07-07 Thread Jon Clements
bruce wrote: hi... i'm trying to figure out what i have to do to setup mIRC to get the #python channel on IRC!! any pointers. the mIRC docs didn't get me very far. is there an irc.freenode.net that i need to connect to? how do i do it? thanks.. -bruce Assuming you're familiar with

Re: Boost Python properties/getter functions for strings

2007-03-19 Thread Jon Clements
On 19 Mar, 16:40, Shawn McGrath [EMAIL PROTECTED] wrote: On Mar 19, 12:00 pm, Shawn McGrath [EMAIL PROTECTED] wrote: I forgot to mention, getname is defined as: const std::string Entity::getName() const; After more reading I found the copy_const_reference, and replaced:

Re: Writing a nice formatted csv file

2007-05-02 Thread Jon Clements
On 2 May, 15:14, redcic [EMAIL PROTECTED] wrote: Hi all, I use the csv module of Python to write a file. My code is of the form : cw = csv.writer(open(out.txt, wb)) cw.writerow([1,2,3]) cw.writerow([10,20,30]) And i get an out.txt file looking like: 1,2,3 10,20,30 Whereas what I'd

Automatic email checking - best procedures/suggestions

2006-07-27 Thread Jon Clements
Hi All, I'm hoping someone has some experience in this field and could give me a pointer in the right direction - it's not purely python related though. Any modules/links someone has tried and found useful would be greatly appreciated... I want to have an automated process which basically has

Re: How do you implement this Python idiom in C++

2006-07-27 Thread Jon Clements
[EMAIL PROTECTED] wrote: // Curious class definitions class CountedClass : public CountedCountedClass {}; class CountedClass2 : public CountedCountedClass2 {}; It apparently works but in fact it doesn't: If you derive from such a class, you get the count of the parent class, not of the

Re: How do you implement this Python idiom in C++

2006-07-27 Thread Jon Clements
[EMAIL PROTECTED] wrote: You miss the point; i want to derive a class and inherit all properties without worrying about those implementation details. The Python code is much cleaner in that respect. My post is about whether it is possible to get such a clean interface in C++ I was simply

Re: Biased random?

2007-08-27 Thread Jon Clements
How about decorating your list of elements with an additional value, which indicates the weight of that element. A value of 1 will indicate 'as likely as any other', 1 will be 'less likely than' any other and 1 will be 'more likely than any other'. Then create a sorted list based on the combined

Re: Pickling an instance of a class containing a dict doesn't work

2006-10-12 Thread Jon Clements
Marco Lierfeld wrote: The class looks like this: class subproject: configuration = {} build_steps = [] # some functions # ... Now I create an instance of this class, e.g. test = subproject() and try

Re: Pickling an instance of a class containing a dict doesn't work

2006-10-12 Thread Jon Clements
Jon Clements wrote: if you change the above to: class subproject: def __init__(self): configuration = { } build_steps = [ ] Of course, I actually meant to write self.configuration and self.build_steps; d0h! -- http://mail.python.org/mailman/listinfo/python-list

Re: Loops Control with Python

2006-10-13 Thread Jon Clements
Wijaya Edward wrote: Can we make loops control in Python? What I mean is that whether we can control which loops to exit/skip at the given scope. For example in Perl we can do something like: OUT: foreach my $s1 ( 0 ...100) { IN: foreach my $s2 (@array) { if ($s1 ==

Re: jython and toString

2006-10-16 Thread Jon Clements
ivansh wrote: Hello, For one java class (Hello) i use another (HelloPrinter) to build the string representation of the first one. When i've tried to use this from within jython, HelloPrinter.toString(hello) call gives results like Object.toString() of hello has being called. The example

Re: making a valid file name...

2006-10-17 Thread Jon Clements
SpreadTooThin wrote: Hi I'm writing a python script that creates directories from user input. Sometimes the user inputs characters that aren't valid characters for a file or directory name. Here are the characters that I consider to be valid characters... valid =

Re: list comprehension (searching for onliners)

2006-10-20 Thread Jon Clements
Gerardo Herzig wrote: Hi all: I have this list thing as a result of a db.query: (short version) result = [{'service_id' : 1, 'value': 10}, {'service_id': 2, 'value': 5}, {'service_id': 1, 'value': 15}, {'service_id': 2, 'value': 15},

Re: why does this unpacking work

2006-10-20 Thread Jon Clements
John Salerno wrote: I'm a little confused, but I'm sure this is something trivial. I'm confused about why this works: t = (('hello', 'goodbye'), ('more', 'less'), ('something', 'nothing'), ('good', 'bad')) t (('hello', 'goodbye'), ('more', 'less'), ('something',

Re: curious paramstyle qmark behavior

2006-10-20 Thread Jon Clements
BartlebyScrivener wrote: With aColumn = Topics.Topic1' The first statement works in the sense that it finds a number of matching rows. c.execute (SELECT Author, Quote, ID, Topics.Topic1, Topic2 FROM QUOTES7 WHERE + aColumn + LIKE ?, (% + sys.argv[1] + %,)) I've tried about 20

Re: curious paramstyle qmark behavior

2006-10-21 Thread Jon Clements
BartlebyScrivener wrote: Thanks, Jon. I'm moving from Access to MySQL. I can query all I want using Python, but so far haven't found a nifty set of forms (ala Access) for easying entering of data into MySQL. My Python is still amateur level and I'm not ready for Tkinkter or gui

Re: curious paramstyle qmark behavior

2006-10-21 Thread Jon Clements
BartlebyScrivener wrote: Jon Clements wrote: if your load on the data-entry/browsing side isn't too heavy, you can use the 'development server' instead of installing a full-blown server such as Apache (I'm not sure if IIS is supported). What's IIS? It's Internet Information Services

Re: can't open word document after string replacements

2006-10-24 Thread Jon Clements
Antoine De Groote wrote: Hi there, I have a word document containing pictures and text. This documents holds several 'ABCDEF' strings which serve as a placeholder for names. Now I want to replace these occurences with names in a list (members). I open both input and output file in binary

Re: Ctypes Error: Why can't it find the DLL.

2006-10-25 Thread Jon Clements
Mudcat wrote: So then I use the find_library function, and it finds it: find_library('arapi51.dll') 'C:\\WINNT\\system32\\arapi51.dll' Notice it's escaped the '\' character. At that point I try to use the LoadLibrary function, but it still can't find it:

Re: dict problem

2006-10-25 Thread Jon Clements
Alistair King wrote: Hi, ive been trying to update a dictionary containing a molecular formula, but seem to be getting this error: Traceback (most recent call last): File DS1excessH2O.py, line 242, in ? updateDS1v(FCas, C, XDS) NameError: name 'C' is not defined dictionary is:

Re: dict problem

2006-10-25 Thread Jon Clements
Alistair King wrote: Jon Clements wrote: Alistair King wrote: Hi, ive been trying to update a dictionary containing a molecular formula, but seem to be getting this error: Traceback (most recent call last): File DS1excessH2O.py, line 242

Re: newbie class-building question

2006-11-09 Thread Jon Clements
jrpfinch wrote: I am constructing a simple class to make sure I understand how classes work in Python (see below this paragraph). It works as expected, except the __add__ redefinition. I get the following in the Python interpreter: a=myListSub() a [] a+[5] Traceback (most recent

Re: newbie class-building question

2006-11-09 Thread Jon Clements
jrpfinch wrote: Thank you this is very helpful. The only thing I now don't understand is why it is calling __coerce__. self.wrapped and other are both lists. Yes, but in a + [5], *a* is a myListSub object -- it's not a list! So __coerce__ is called to try and get a common type... Try this

Re: extract text from a string

2006-11-09 Thread Jon Clements
[EMAIL PROTECTED] wrote: Hallo all, I have tried for a couple of hours to solve my problem with re but I have no success. I have a string containing: +abc_cde.fgh_jkl\n and what I need to become is abc_cde.fgh_jkl. Could anybody be so kind and write me a code of how to extract this text

Re: generating random passwords ... for a csv file with user details

2006-05-29 Thread Jon Clements
Something like: import csv in_csv=csv.reader( file('your INPUT filenamehere.csv') ) out_csv=csv.writer( file('your OUPUT filenamehere.csv','wb') ) ## If you have a header record on your input file, then out_csv.writerow( in_csv.next() ) ## Iterate over your input file for row in in_csv: # Row

Re: Simple question on indexing

2006-12-01 Thread Jon Clements
Tartifola wrote: Hi, I would like to obtain the position index in a tuple when an IF statement is true. Something like a=['aaa','bbb','ccc'] [ ??? for name in a if name == 'bbb'] 1 but I'm not able to find the name of the function ??? in the python documentation, any help? Thanks

Re: route planning

2006-12-01 Thread Jon Clements
It's not really what you're after, but I hope it might give some ideas (useful or not, I don't know). How about considering a vertex as a point in space (most libraries will allow you to decorate a vertex with additonal information), then creating an edge between vertices, which will be your

Re: How to replace a comma

2006-12-18 Thread Jon Clements
Lad wrote: In a text I need to add a blank(space) after a comma but only if there was no blank(space) after the comman If there was a blank(space), no change is made. I think it could be a task for regular expression but can not figure out the correct regular expression. Can anyone help,

Re: Encoding / decoding strings

2007-01-05 Thread Jon Clements
[EMAIL PROTECTED] wrote: Hey Everyone, Was just wondering if anyone here could help me. I want to encode (and subsequently decode) email addresses to use in URLs. I believe that this can be done using MD5. I can find documentation for encoding the strings, but not decoding them. What

Re: python noob, multiple file i/o

2007-03-16 Thread Jon Clements
On 16 Mar, 03:56, hiro [EMAIL PROTECTED] wrote: Hi there, I'm very new to python, the problem I need to solve is whats the best/ simplest/cleanest way to read in multiple files (ascii), do stuff to them, and write them out(ascii). -- import os filePath = ('O:/spam/eggs/') for file in

Re: python noob, multiple file i/o

2007-03-16 Thread Jon Clements
On 16 Mar, 09:02, Jon Clements [EMAIL PROTECTED] wrote: On 16 Mar, 03:56, hiro [EMAIL PROTECTED] wrote: Hi there, I'm very new to python, the problem I need to solve is whats the best/ simplest/cleanest way to read in multiple files (ascii), do stuff to them, and write them out

CSV module and fileobj

2007-03-16 Thread Jon Clements
Hi Group, If I have a CSV reader that's passed to a function, is it possible for that function to retrieve a reference to the fileobj like object that was passed to the reader's __init__? For instance, if it's using an actual file object, then depending on the current row, I'd like to open the

Re: String formatting with fixed width

2007-03-16 Thread Jon Clements
On 16 Mar, 13:20, Alexander Eisenhuth [EMAIL PROTECTED] wrote: Hello alltogether, is it possible to format stings with fixed width of let's say 7 character. T need a floating point with 3 chars before dot, padded with ' ' and 3 chars after dot, padded with '0'. Followingh is my approach

Re: a regual expression problem

2008-11-30 Thread Jon Clements
On Nov 30, 9:10 am, lookon [EMAIL PROTECTED] wrote: I have a url of image, and I want to get the filename and extension of the image. How to write in python? for example, the url ishttp://a.b.com/aaa.jpg?version=1.1 how can I get aaa and jpg by python? Something like... from urlparse

Re: ctypes with Compaq Visual Fortran 6.6B *.dll (Windows XP), passing of integer and real values

2009-01-27 Thread Jon Clements
On Jan 27, 9:41 pm, alex ale...@bluewin.ch wrote: Hello everybody I am mainly a Fortran programmer and beginning to learn Python(2.5) and OOP programming. I hope in the end to put a GUI on my existing Fortran code. Therefore I am also trying to learn Python's ctypes library. Unfortunately

Re: Why doesn't eval of generator expression work with locals?

2009-01-27 Thread Jon Clements
On Jan 27, 11:31 pm, Fabio Zadrozny fabi...@gmail.com wrote: Hi All, Anyone knows why the code below gives an error? global_vars = {} local_vars = {'ar':[foo, bar], 'y':bar} print eval('all((x == y for x in ar))', global_vars, local_vars) Error: Traceback (most recent call last):  

Re: How to execute a hyperlink?

2009-01-27 Thread Jon Clements
On Jan 28, 12:59 am, Muddy Coder cosmo_gene...@yahoo.com wrote: Hi Folks, Module os provides a means of running shell commands, such as: import os os.system('dir .') will execute command dir I think a hyperlink should also be executed. I tried:

Re: bigint to timestamp

2009-01-28 Thread Jon Clements
On Jan 28, 1:50 pm, Steve Holden st...@holdenweb.com wrote: Shah Sultan Alam wrote: Hi Group, I have file with contents retrieved from mysql DB. which has a time field with type defined bigint(20) I want to parse that field into timestamp format(-MM-DD HH:MM:SS GMT) using python

Number of bits/sizeof int

2009-01-30 Thread Jon Clements
Hi Group, This has a certain amount of irony (as this is what I'm pretty much after):- From http://docs.python.org/dev/3.0/whatsnew/3.1.html: The int() type gained a bit_length method that returns the number of bits necessary to represent its argument in binary: Any tips on how to get this in

Re: Number of bits/sizeof int

2009-01-30 Thread Jon Clements
On Jan 31, 7:29 am, John Machin sjmac...@lexicon.net wrote: On Jan 31, 6:03 pm, Jon Clements jon...@googlemail.com wrote: Hi Group, This has a certain amount of irony (as this is what I'm pretty much after):- Fromhttp://docs.python.org/dev/3.0/whatsnew/3.1.html: The int() type gained

Re: Problems installing PySQLite, SQLite and Trac

2009-02-01 Thread Jon Clements
On 1 Feb, 15:48, kimwlias kimwl...@gmail.com wrote: My initial goal is to finally install Trac. This is the second day I've been trying to make this possible but I can't find, for the life of me, how to do this. OK, here is the story: My system is a VPS with CentOS 5. I found out that I

Re: Source code for csv module

2009-02-02 Thread Jon Clements
On 2 Feb, 20:46, vsoler vicente.so...@gmail.com wrote: Hi you all, I just discovered the csv module here in the comp.lang.python group. I have found its manual, which is publicly available, but since I am still a newby, learning techniques, I was wondering if the source code for this module

Re: Source code for csv module

2009-02-03 Thread Jon Clements
On 3 Feb, 04:27, Tim Roberts t...@probo.com wrote: vsoler vicente.so...@gmail.com wrote: I'm still interested in learning python techniques. Are there any other modules (standard or complementary) that I can use in my education? Are you serious about this?  Are you not aware that virtually

Re: How would you design scalable solution?

2009-10-28 Thread Jon Clements
On 27 Oct, 17:10, Bryan bryanv...@gmail.com wrote: I'm designing a system and wanted to get some feedback on a potential performance problem down the road while it is still cheap to fix. The system is similar to an accounting system where a system tracks Things which move between different

Re: Feedback wanted on programming introduction (Python in Windows)

2009-10-28 Thread Jon Clements
On 28 Oct, 07:31, Steven D'Aprano ste...@remove.this.cybersource.com.au wrote: On Wed, 28 Oct 2009 07:52:17 +0100, Alf P. Steinbach wrote: Unfortunately Google docs doesn't display the nice table of contents in each document, but here's the public view of ch 1 (complete) and ch 2 (about one

Re: Feedback wanted on programming introduction (Python in Windows)

2009-10-28 Thread Jon Clements
On 28 Oct, 07:44, Jon Clements jon...@googlemail.com wrote: On 28 Oct, 07:31, Steven D'Aprano ste...@remove.this.cybersource.com.au wrote: On Wed, 28 Oct 2009 07:52:17 +0100, Alf P. Steinbach wrote: Unfortunately Google docs doesn't display the nice table of contents in each document

Re: Feedback wanted on programming introduction (Python in Windows)

2009-10-28 Thread Jon Clements
Inline reply: On 28 Oct, 11:49, Alf P. Steinbach al...@start.no wrote: * Jon Clements: On 28 Oct, 08:58, Alf P. Steinbach al...@start.no wrote: [snip] Without reference to an OS you can't address any of the issues that a beginner has to grapple with, including most importantly tool

Re: popen function of os and subprocess modules

2009-10-28 Thread Jon Clements
On 28 Oct, 13:39, banu varun.nagp...@gmail.com wrote: Hi, I am a novice in python. I was trying to write a simple script on Linux (python 3.0) that does the following #cd directory #ls -l I use the following code, but it doesn't work: import os directory = '/etc' pr = os.popen('cd %s'

Re: ConfigParser.items sorting

2009-10-28 Thread Jon Clements
On 28 Oct, 21:55, Dean McClure bratpri...@gmail.com wrote: On Oct 28, 4:50 pm, Jon Clements jon...@googlemail.com wrote: On 28 Oct, 06:21, Dean McClure bratpri...@gmail.com wrote: Hi, Just wondering how I can get theitems() command fromConfigParserto not resort all the item pairs

Re: import bug

2009-10-31 Thread Jon Clements
On Oct 31, 3:12 pm, kj no.em...@please.post wrote: I'm running into an ugly bug, which, IMHO, is really a bug in the design of Python's module import scheme.  Consider the following directory structure: ham |-- __init__.py |-- re.py `-- spam.py ...with the following very simple files:

Re: About Object in list expression

2009-11-02 Thread Jon Clements
On Nov 2, 10:41 am, Mirons ilmir...@gmail.com wrote: Hi everybody! I'm having a very annoying problem with Python: I need to check if a (mutable) object is part of a list but the usual expression return True also if the object isn't there. I've implemented both __hash__ and __eq__, but still

Re: exec-function in Python 3.+

2009-11-02 Thread Jon Clements
On 2 Nov, 10:49, Hans Larsen jo...@mail.dk wrote: Help!     I'm begginer in Python 3.+!     If i wih to update a module after an import and chages,     How could I do:     By from imp import reload and then reload(mymodule)     or how to use exec(?), it is mentoined in docs.     In Python

Re: OT: regular expression matching multiple occurrences of one group

2009-11-09 Thread Jon Clements
On Nov 9, 1:53 pm, pinkisntwell pinkisntw...@gmail.com wrote: How can I make a regular expression that will match every occurrence of a group and return each occurrence as a group match? For example, for a string -c-c-c-c-c, how can I make a regex which will return a group match for each

Re: Req. comments on first version ch 2 progr. intro (using Python 3.x in Windows)

2009-11-09 Thread Jon Clements
On Nov 9, 4:10 pm, Alf P. Steinbach al...@start.no wrote: Chapter 2 Basic Concepts is about 0.666 completed and 30 pages so far. It's now Python 3.x, and reworked with lots of graphical examples and more explanatory text, plus limited in scope to Basic Concepts (which I previously just had as

Re: Req. comments on first version ch 2 progr. intro (using Python 3.x in Windows)

2009-11-09 Thread Jon Clements
On Nov 9, 5:22 pm, Alf P. Steinbach al...@start.no wrote: * Jon Clements: On Nov 9, 4:10 pm, Alf P. Steinbach al...@start.no wrote: Chapter 2 Basic Concepts is about 0.666 completed and 30 pages so far. It's now Python 3.x, and reworked with lots of graphical examples and more

Re: Req. comments on first version ch 2 progr. intro (using Python 3.x in Windows)

2009-11-10 Thread Jon Clements
[posts snipped] The only other thing is that line_length is used as a constant in one of the programs. However, it's being mutated in the while loop example. It may still be in the reader's mind that line_length == 10. (Or maybe not) Cheers, Jon. --

Re: Create object from variable indirect reference?

2009-11-10 Thread Jon Clements
On Nov 10, 2:59 pm, NickC reply...@works.fine.invalid wrote: I can't seem to find a way to do something that seems straighforward, so I must have a mental block.  I want to reference an object indirectly through a variable's value. Using a library that returns all sorts of information about

Re: Authentication session with urllib2

2009-11-11 Thread Jon Clements
On 11 Nov, 07:02, Ken Seehart k...@seehart.com wrote: I'm having some difficulty implementing a client that needs to maintain an authenticated https: session. I'd like to avoid the approach of receiving a 401 and resubmit with authentication, for two reasons: 1. I control the server, and it

Re: The ol' [[]] * 500 bug...

2009-11-13 Thread Jon Clements
On 13 Nov, 21:26, kj no.em...@please.post wrote: ...just bit me in the fuzzy posterior.  The best I can come up with is the hideous   lol = [[] for _ in xrange(500)] Is there something better?   That's generally the accepted way of creating a LOL. What did one do before comprehensions

Re: python win32com problem

2009-11-15 Thread Jon Clements
On Nov 15, 1:08 pm, elca high...@gmail.com wrote: hello , these day im very stress of one of some strange thing. i want to enumurate inside list of url, and every enumurated url i want to visit i was uplod incompleted script source in here = http://elca.pastebin.com/m6f911584 if anyone

Re: Slicing history?

2009-11-15 Thread Jon Clements
On Nov 15, 6:50 pm, a...@pythoncraft.com (Aahz) wrote: Anyone remember or know why Python slices function like half-open intervals?  I find it incredibly convenient myself, but an acquaintance familiar with other programming languages thinks it's bizarre and I'm wondering how it happened. --

Re: overriding __getitem__ for a subclass of dict

2009-11-15 Thread Jon Clements
On Nov 15, 7:23 pm, Steve Howell showel...@yahoo.com wrote: On Nov 15, 10:25 am, Steve Howell showel...@yahoo.com wrote: [see original post...] I am most interested in the specific mechanism for changing the __getitem__ method for a subclass on a dictionary.  Thanks in advance! Sorry

Re: getting properly one subprocess output

2009-11-18 Thread Jon Clements
On Nov 18, 11:25 am, Jean-Michel Pichavant jeanmic...@sequans.com wrote: Hi python fellows, I'm currently inspecting my Linux process list, trying to parse it in order to get one particular process (and kill it). I ran into an annoying issue: The stdout display is somehow truncated (maybe a

Re: getting properly one subprocess output

2009-11-18 Thread Jon Clements
On Nov 18, 4:14 pm, Jon Clements jon...@googlemail.com wrote: On Nov 18, 11:25 am, Jean-Michel Pichavant jeanmic...@sequans.com wrote: Hi python fellows, I'm currently inspecting my Linux process list, trying to parse it in order to get one particular process (and kill it). I ran

Re: using struct module on a file

2009-11-18 Thread Jon Clements
On Nov 18, 4:42 pm, Ulrich Eckhardt dooms...@knuut.de wrote: Hia! I need to read a file containing packed binary data. For that, I find the struct module pretty convenient. What I always need to do is reading a chunk of data from the file (either using calcsize() or a struct.Struct instance)

Re: make two tables having same orders in both column and row names

2009-11-20 Thread Jon Clements
On Nov 18, 8:57 pm, Ping-Hsun Hsieh hsi...@ohsu.edu wrote: Hi, I would like to compare values in two table with same column and row names, but with different orders in column and row names. For example, table_A in a file looks like the follows: AA100   AA109   AA101   AA103   AA102 BB1    

  1   2   3   >