Re: Using sudo with pip3?

2017-01-07 Thread Michiel Overtoom
> On 2017-01-07, at 03:24, Cameron Simpson wrote: > > Having your on virtualenv is good for: [...] having an isolated environment > for packages (you can make more than one virtual environment). Yes, indeed. For example, if you have to maintain two different codebases, one using Django 1.8 an

Re: Parse a Wireshark pcap file

2016-12-28 Thread Michiel Overtoom
> On 2016-12-27, at 20:46, 1991manish.ku...@gmail.com wrote: > > I have a pcap file, I want to parse that file & fetch some information like > Timestamp, Packet Size, Source/Dest IP Address, Source/Dest Port, Source/ > Dest MAC address. pcapy can do this. import pcapy pcap = pcapy.open_offlin

Re: How to you convert list of tuples to string

2016-11-22 Thread Michiel Overtoom
Hi Ganesh, > Any better suggestion to improve this piece of code and make it look more > pythonic? import random # A list of tuples. Note that the L behind a number means that the number is a 'long'. data = [(1, 1, 373891072L, 8192), (1, 3, 390348800L, 8192), (1, 4, 372719616L, 8192), (2

Re: Why searching in a set is much faster than in a list ?

2016-09-28 Thread Michiel Overtoom
Hi, Brandon Rhodes gave a talk about dictionaries (similar to sets), 'The Mighty Dictionary': https://www.youtube.com/watch?v=C4Kc8xzcA68 You also might be interested in his talk about Python data structures, 'All Your Ducks In A Row': https://www.youtube.com/watch?v=fYlnfvK

Re: def __init__(self,cls):

2016-04-29 Thread Michiel Overtoom
> On 2016-04-29, at 11:47, San wrote: > > Dear Group, please explain the following in details. Thanks in Advance. > > def __init__(self,cls): >self.cls = cls Is this homework? Why don't you explain it first in your own words, then let us comment on it? Greetings, -- https://mail.

Re: libre office

2016-01-20 Thread Michiel Overtoom
> On 2016-01-20, at 00:01, jim-pc wrote: > > How do I get data from libre office using python? Could you be a little more specific? What data? From which part of OpenOffice? OpenOffice files are actually ZIP files with XML documents in them, but there are other ways to interface with OpenOffi

Re: Converting py files to .exe and .dmg

2016-01-01 Thread Michiel Overtoom
> On 2016-01-01, at 07:43, Brian Simms wrote: > > when I go into Terminal to run "setup.py install" I keep getting "-bash: > command not found". Try: python setup.py install Greetings, -- https://mail.python.org/mailman/listinfo/python-list

Re: How does one distribute Tkinter or Qt GUI apps Developed in Python

2015-12-17 Thread Michiel Overtoom
> On 2015-12-17, at 01:03, Bruce Whealton > wrote: > > I would want to package in some way so that when launched, it installs > whatever is needed on the end user's computer. How is this done? You might want to watch https://www.youtube.com/watch?v=wsczq6j3_bA (Brandon Rhodes: The Day of th

Re: python domain in China. This showed up on Python list

2015-12-01 Thread Michiel Overtoom
Hi, > On 01 Dec 2015, at 11:10, Laura Creighton wrote: > > I think we have just dodged a bullet, let us now go thank the > nice people who sent us this and figure out how we should > secure the domain. I received exactly the same email a while ago, claiming that someone was registering the na

Re: How can I count word frequency in a web site?

2015-11-29 Thread Michiel Overtoom
> On 30 Nov 2015, at 03:54, ryguy7272 wrote: > > Now, how can I count specific words like 'fraud' and 'lawsuit'? - convert the page to plain text - remove any interpunction - split into words - see what words occur - enumerate all the words and increase a counter for each word Something like t

Re: how do I learn python ?

2015-11-19 Thread Michiel Overtoom
> On 18 Nov 2015, at 05:58, 夏华林 wrote: > (nothing) You might want to start at https://www.python.org/about/gettingstarted/ PS. Leaving the body of an email or usenet article empty is considered bad form. Greetings, -- https://mail.python.org/mailman/listinfo/python-list

Re: write data in Excel using python

2015-11-16 Thread Michiel Overtoom
Hi, > On 16 Nov 2015, at 18:14, syedmwaliul...@gmail.com wrote: > For some reason it doesn't save the file. Did you get an error message? > excel.activeWorkbook.SaveAs ("c:\TurnData.xlsx") When you use backslashes in strings, don't forget to escape them: > excel.activeWorkbook.SaveAs("c:\\Tur

Re: using binary in python

2015-11-09 Thread Michiel Overtoom
> On 08 Nov 2015, at 22:27, kent nyberg wrote: > > Well, lets assume I want to write and read binary. How is it done? With the functions 'open()' and 'read()' and 'write()'. If you're on Windows, don't forget to include a 'b' in the mode string of the open() call, otherwise Python will assum

Re: Puzzled

2015-11-03 Thread Michiel Overtoom
> On 03 Nov 2015, at 05:46, Michael Torrie wrote: > Sometimes on Windows you can double-click a python file and it will run. The first thing I do on Windows after installing Python: edit the registry so that the 'open' key is changed to 'run', and 'edit with IDLE' becomes 'open'. I like to see

Re: installer user interface glitch ?

2015-11-01 Thread Michiel Overtoom
> On 01 Nov 2015, at 16:43, rurpy--- via Python-list > wrote: > > Why, oh why, do the python.org front page and other pages that offer > a Windows download not say a word about it not running on Windows XP? I'm also curious why Python 3.5 won't run on Windows XP. Which features does it use th

Re: UNABLE TO GET IDLE TO RUN

2015-10-31 Thread Michiel Overtoom
> On 31 Oct 2015, at 06:59, Terry Reedy wrote: > This is a different issue than IDLE avoiding clashes. I opened > https://bugs.python.org/issue25522 Terry, thanks for recording this into the issue tracker. I'd go even a step further. I think IDLE should not only warn, but completely prevent s

Re: UNABLE TO GET IDLE TO RUN

2015-10-30 Thread Michiel Overtoom
Hi, Laura wrote: > I think that it would be useful if IDLE spit out a warning An ounce of prevention is worth a pound of cure. Maybe it's an idea that IDLE gives a warning when you're trying to save a file with a name that would shadow an existing module? Greetings, -- https://mail.pyth

Re: Pause and Resuming of a file upload process to AWS S3

2015-10-28 Thread Michiel Overtoom
Hi, > I wanted to know whether it is possible in python to pause and resume the > file upload process to AWS S3 Have a look at s3tools/s3cmd at http://s3tools.org/s3cmd, in http://s3tools.org/usage I read: --continue-put Continue uploading partially uploaded files Greetings, -- https:

Re: Python Version 3.5 required which was not found in the registry

2015-10-27 Thread Michiel Overtoom
> On 27 Oct 2015, at 02:18, luyijie wrote: > > when i install > pop "Python Version 3.5 required which was not found in the registry" > I do not know how to do... Wat version of Windows are you using? Greetings, -- https://mail.python.org/mailman/listinfo/python-list

Re: Pandas' loading a CSV file problem

2015-10-22 Thread Michiel Overtoom
Hi Ek, > On 22 Oct 2015, at 14:44, Ek Esawi wrote: > > f = pd.read_csv('c:/Users/EK Esawi/My Documents/Temp/GOSATemp1.csv') > File "pandas\parser.pyx", line 1382, in pandas.parser._string_box_utf8 > (pandas\parser.c:17655) > UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb1 in position 8

Re: Sets vs lists loop behaviour if size changes

2015-10-14 Thread Michiel Overtoom
> On 14 Oct 2015, at 23:11, candide via Python-list > wrote: > > If set size changes during a for loop, a runtime exception is raised A set is a kind of dictionary (without values). And why it can't be resized, is explained by Brandon Rhodes in his excellent talk 'The Mighty Dictionary', htt

Re: win32com.client .Cells

2015-10-12 Thread Michiel Overtoom
Hi, > excel_book=Excel.Workbooks.Open('D:\WebPython\Config3.xlsx') Shouldn't this be: excel_book=Excel.Workbooks.Open('D:\\WebPython\\Config3.xlsx') or excel_book=Excel.Workbooks.Open(r'D:\WebPython\Config3.xlsx') ? -- https://mail.python.org/mailman/listinfo/python-list

Re: Check if a given value is out of certain range

2015-10-05 Thread Michiel Overtoom
Why not use a function? if outside(x, 0, 10): print("x has wrong value") else: print("x has good value") where 'outside' is defined as: def outside(value, lowerbound, upperbound): return value < lowerbound or value > upperbound Greetings, -- https://ma

Re: datetime.datetime.today()

2015-09-16 Thread Michiel Overtoom
This bit me once. I was comparing a date to a datetime, both representing the same day, so I expected them to be the same, but I was wrong. What I should have done was extracting the date of the datetime with the .date() function, and only then compare it to the other date: >>> import datetime

Re: Immediate Hire: Sr. Java Software Engineer - Oklahoma - GC, US Citizens Onlt

2015-05-11 Thread Michiel Overtoom
On May 11, 2015, at 17:12, nagaraju thoudoju wrote: > Job Description - Sr. Java Software Engineer This is a Python mailinglist, not a Java one. -- "You can't actually make computers run faster, you can only make them do less." - RiderOfGiraffes -- https://mail.python.org/mailman/listinfo/

Re: Messages with a time stamp

2015-05-03 Thread Michiel Overtoom
On May 3, 2015, at 10:22, Cecil Westerhof wrote: > For testing I want my messages time stamped like: For progress reporting, I often use the module below (eta.py), which also gives a projected time of completion: import datetime, time, sys etastart = 0 def eta(done, total, s, reportinterval=1

Re: Using Dictionary

2015-04-14 Thread Michiel Overtoom
On Apr 14, 2015, at 15:34, Pippo wrote: > How can I use dictionary to save the following information? What a curious question. The purpose of a dictionary is not to save information, but to store data as a key -> value mapping: telbook = {} telbook["jan"] = "0627832873" telbook["ma

Re: using DictReader() with .decode('utf-8', 'ignore')

2015-04-14 Thread Michiel Overtoom
> ​How can I ​do accomplish decode('utf-8', 'ignore') when reading with > DictReader() Have you tried using the csv module in conjunction with codecs? There shouldn't be any need to 'ignore' characters. import csv import codecs rs = csv.DictReader(codecs.open(fn, "rbU", "utf8"))

Re: Using Python to put a 27-year-old Macintosh on the web

2015-03-23 Thread Michiel Overtoom
On Mar 23, 2015, at 06:36, Steven D'Aprano wrote: > http://www.keacher.com/1216/how-i-introduced-a-27-year-old-computer-to-the- > web/ I saw it too, on Hacker News ;-) Awesome. I love(d) my Classic Mac but I couldn't stand the slow network connection, I think. Also, creative use of Flask and B

Re: Windows service in production?

2015-03-19 Thread Michiel Overtoom
On Mar 19, 2015, at 08:00, jyothi.n...@gmail.com wrote: > file_path = "D:\Tarang\Project\form1.py" Use either slashes (/), raw strings, or double backslashes: file_path = "D:/Tarang/Project/form1.py" file_path = r"D:\Tarang\Project\form1.py"

Re: Python Worst Practices

2015-02-25 Thread Michiel Overtoom
On Feb 25, 2015, at 21:45, Mark Lawrence wrote: > http://www.slideshare.net/pydanny/python-worst-practices I agree with you that Python lambdas have little use beyond the most trivial use cases. For the non-trivial cases, I like to define a named function which does the job. And also provides

Re: Cairo module

2015-02-04 Thread Michiel Overtoom
Hi Poul, I recently used cairo in a python project (https://github.com/luismqueral/jumpcityrecords). To see the cairo drawing directly on the screen I wrote a minimal Gtk application. It's in the 'src' directory and is called 'randomdraw.py'. Maybe it is of some help to you. Greetings, -- "

Re: The Most Diabolical Python Antipattern

2015-01-29 Thread Michiel Overtoom
would throw without going through all the sources with a fine comb. Thus, I wrote a decorator which will catch any exception (but not KeyboardInterrupt and SystemExit of course): # alwayscatch.py - Software by Michiel Overtoom, mot...@xs4all.nl # # decorator to wrap an entire function in a try..e

Re: What killed Smalltalk could kill Python

2015-01-21 Thread Michiel Overtoom
Hi Steven, you wrote: > In 2009, Robert Martin gave a talk at RailsConf titled "What Killed > Smalltalk Could Kill Ruby". I've yet to watch the video, I'll do that later tonight, but I also remember what DHH said about Smalltalk in his FLOSS interview about Rails, with Randal Schwartz, in July

Re: New to PSF

2014-12-28 Thread Michiel Overtoom
On Dec 28, 2014, at 09:54, prateek pandey wrote: > Yeah, I mean Python Software Foundation. I am a developer and I want to > contribute. So, Can you please help me in getting started ? https://www.python.org/psf/volunteer/ -- "You can't actually make computers run faster, you can only make t

Re: (-1)**1000

2014-10-22 Thread Michiel Overtoom
On Oct 22, 2014, at 12:29, Peter Otten wrote: > That looks like log(a) while a parity check takes constant time: > $ python3 -m timeit -s 'a = 10**10' 'a & 1' Do you mean 'parity' as in http://en.wikipedia.org/wiki/Parity_bit ? Because a parity bit denotes whether the *number* of '1' bits is

Re: Why has python3 been created as a seperate language where there is still python2.7 ?

2012-06-25 Thread Michiel Overtoom
On Jun 24, 2012, at 05:46, gmspro wrote: > Why has python3 been created as a seperate language where there is still > python2.7? It has not. Python2 and Python3 are very similar. It's not like if you learn Python using version 2, you have to relearn the language when you want to switch Python

Re: Looking for video/slides from PyCon 2011...

2012-05-21 Thread Michiel Overtoom
On May 16, 2012, at 08:24, Monte Milanuk wrote: >>> >>> http://us.pycon.org/2011/schedule/presentations/207/ > > Unless its buried in one of the lightning talk vids, I'm not seein' it. Me neither. But that page show that it was a workshop, not necessarily videotaped. That's a pity, it seems i

Re: Why do class methods always need 'self' as the first parameter?

2011-09-01 Thread Michiel Overtoom
> On Aug 31, 5:35 pm, "T. Goodchild" wrote: >> So why is 'self' necessary on class methods? >> >> Just curious about the rationale behind this part of the language. When instance variables are accessed with the 'self.varname' syntax, it is clear to the programmer that an instance variable is

Re: Constructors...BIIIIG PROBLEM!

2011-09-01 Thread Michiel Overtoom
On Sep 1, 2011, at 10:24, Hegedüs Ervin wrote: > On Thu, Sep 01, 2011 at 10:00:27AM +0200, Michiel Overtoom wrote: >> Derive your class from object, > > why's that better than just create a simple class, without > derive? Amongst other things, fixes to the type system an

Re: Constructors...BIIIIG PROBLEM!

2011-09-01 Thread Michiel Overtoom
On Sep 1, 2011, at 09:48, Amogh M S wrote: > Hey guys... > I think we have a problem with my _init_ method and the constructor > When I create a class and its _init_ method and try to create an object of it > outside the class, > Say, something like > > class S: >def _init_(self, name=None

Re: Unspecified problem sending serial data

2011-08-24 Thread Michiel Overtoom
On Aug 24, 2011, at 23:51, Dave Angel wrote: > On 08/24/2011 01:05 PM, Adrián Monkas wrote: >> What I want to do is send around 180KBytes via Serial port. Also have a look at pySerial, http://pyserial.sourceforge.net/ Greetings, -- "If you don't know, the thing to do is not to get scared, but

Re: Announcing a new podcast: Radio Free Python

2011-08-24 Thread Michiel Overtoom
podcasts over a long period of time. Do you need any input/ideas/feedback ? Greetings, Michiel Overtoom http://www.michielovertoom.com -- "Learn to value yourself, which means: fight for your happiness." - Ayn Rand -- http://mail.python.org/mailman/listinfo/python-list

Re: PEP 8 and extraneous whitespace

2011-07-22 Thread Michiel Overtoom
On Jul 22, 2011, at 12:23, Thomas Jollans wrote: > On 22/07/11 10:11, Thomas Rachel wrote: >> Am 22.07.2011 00:45 schrieb Terry Reedy: >> >>> Whether or not they are intended, the rationale is that lining up does >>> not work with proportional fonts. >> >> Who on earth would use proportional fo

Re: SQL Server 2008R2 databases via Python 2.7 and Windows XP and higher

2011-06-17 Thread Michiel Overtoom
On Jun 17, 2011, at 17:01, pyt...@bdurham.com wrote: > Looking for some real-world advice on what is the best way to access MS SQL > Server 2008R2 databases via Python 2.7 running under Windows XP, Vista, and > Windows 7 and Windows Server 2005 and 2008. I use the COM interface to ADO, for a f

Re: regarding session in python

2011-06-07 Thread Michiel Overtoom
On Jun 7, 2011, at 20:09, Kev Dwyer wrote: > vipul jain wrote: > >> hey i am new to python and i want to make a website using python . >> so for that i need a login page. in this login page i want to use the >> sessions... but i am not getting how to do it > > The Python standard library do

Re: best way to extract sentence from txt file

2011-05-17 Thread Michiel Overtoom
On May 17, 2011, at 20:22, Robert Pazur wrote: > my question is maybe quite simple: > What is the best (and shortest) way to extract sentence from .txt file? Well, open("filename.txt").readlines() gives you a list of all the lines in a txt file, which might not be sentences, depending on the te

Re: Do any debuggers support "edit and continue?"

2010-05-13 Thread Michiel Overtoom
On 2010-05-13 00:07, Joel Koltner wrote: Hey, a lot of people would argue that Python's lack of strong typing and data/member protection (from one class to another) encourages sloppy programming too. :-) You're being ironic, aren't you? Python does have strong typing (many people confuse tha

Re: Create a class at run-time

2010-03-25 Thread Michiel Overtoom
On 2010-03-25 23:00, Michel wrote: I'm trying to dynamically create a class. What I need is to define a class, add methods to it and later instantiate this class. Methods need to be bound to the instance though, and that's my problem. Maybe this snippet is of any help? import functools class

Re: Understanding the CPython dict implementation

2010-03-16 Thread Michiel Overtoom
On 16 Mar 2010, at 12:46 , Steven D'Aprano wrote: > On Sun, 14 Mar 2010 19:39:46 -0400, Terry Reedy wrote: > >> I found this PyCon2010 presentation to be excellent: The Mighty >> Dictionary, Branden Craig Rhodes, 30 min. >> http://pycon.blip.tv/file/3264041/ > > > Unfortunately, that clip seem

Re: Handling large datastore search

2009-11-03 Thread Michiel Overtoom
Ahmed Barakat wrote: In case I have a huge datastore (1 entries, each entry has like 6 properties) Can you show some sample entries? That way we can get an idea how your datastore looks like. By the way, 1 doesn't sound that much. At work I create python programs which do data pr

Re: how can i use lxml with win32com?

2009-10-25 Thread Michiel Overtoom
elca wrote: http://news.search.naver.com/search.naver?sm=tab_hty&where=news&query=korea+times&x=0&y=0 that is korea portal site and i was search keyword using 'korea times' and i want to scrap resulted to text name with 'blogscrap_save.txt' Aha, now we're getting somewhere. Getting and parsin

Re: how can i use lxml with win32com?

2009-10-25 Thread Michiel Overtoom
elca wrote: im sorry ,also im not familiar with newsgroup. It's not a newsgroup, but a mailing list. And if you're new to a certain community you're not familiar with, it's best to lurk a few days to see how it is used. so this position is bottom-posting position? It is, but you should

Re: how can i use lxml with win32com?

2009-10-25 Thread Michiel Overtoom
elca wrote: actually what i want to parse website is some different language site. A different website? What website? What text? Please show your actual use case, instead of smokescreens. so i was quote some common english website for easy understand. :) And, did you learn somethin

Re: how can i use lxml with win32com?

2009-10-25 Thread Michiel Overtoom
elca wrote: yes i want to extract this text 'CNN Shop' and linked page 'http://www.turnerstoreonline.com'. Well then. First, we'll get the page using urrlib2: doc=urllib2.urlopen("http://www.cnn.com";) Then we'll feed it into the HTML parser: soup=BeautifulSoup(doc) Next, we'll loo

Re: your favorite debugging tool?

2009-08-30 Thread Michiel Overtoom
Esmail wrote: What is your favorite tool to help you debug your code? import pdb pdb.set_trace() pdb has commands to inspect code, variables, set breakpoints, watches, walk up and down stack frames, single-step through the program, run the rest of the function, run until return, etc... h

Re: An assessment of Tkinter and IDLE

2009-08-28 Thread Michiel Overtoom
r wrote: Whats the use of Tkinter if the docs are in TCL. Just learn TCL and skip the Python middleman. But Mark's tutorial at http://www.tkdocs.com/tutorial/index.html allows you to select 'Python' as one of the languages you want to see the example code in. Too bad that the 'ttk' widget

Re: Help understanding the decisions *behind* python?

2009-07-20 Thread Michiel Overtoom
Phillip wrote: Specifically the "differences" between lists and tuples have us confused and have caused many "discussions" in the office. We understand that lists are mutable and tuples are not, but we're a little lost as to why the two were kept separate from the start. They both perform a very

Re: On out-of-date Python Applications

2009-07-19 Thread Michiel Overtoom
Virgil Stokes wrote: > some of these applications will not install on the latest version of Python. Which version of Python precisely? -- "The ability of the OSS process to collect and harness the collective IQ of thousands of individuals across the Internet is simply amazing." - Vinod Vall

Re: Python graphics / imaging library

2009-07-18 Thread Michiel Overtoom
Peter Chant wrote: what do people generally use now? I can only speak for myself... I use PIL ;-) Greetings, -- http://mail.python.org/mailman/listinfo/python-list

Re: Python graphics / imaging library

2009-07-18 Thread Michiel Overtoom
Peter Chant wrote: what's the most appropriate (maintained) graphics library to use? PIL seems to have last been updated in 2006 http://www.pythonware.com/products/pil/ and GD seems to be even older. Don't want to go down a dead end. Contrary to organic material, software doesn't rot when it

Re: 'del' function for Dictionary

2009-07-17 Thread Michiel Overtoom
mayank gupta wrote: after analyzing the time taken by the code, What code? -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Equivalent for dd & fold

2009-07-16 Thread Michiel Overtoom
seldan24 wrote: I know that Emile suggested that I can slice out the substrings rather than do the gradual trimming of the string variable as is being done by moving around the length. An excellent idea. def fold(s,chunklength): offset=0 while offsethttp://www.catb.org/~esr/halloween

Re: turtle dump

2009-07-16 Thread Michiel Overtoom
I got success with the following code (python 2.6.2): import turtle turtle.reset() for i in range(4): turtle.forward(50) turtle.right(90) can=turtle.getscreen().getcanvas() can.postscript(file="tmp.ps") -- "The ability of the OSS process to collect and harness the collective IQ of thousa

Re: Python Equivalent for dd & fold

2009-07-15 Thread Michiel Overtoom
seldan24 wrote: what can I use as the equivalent for the Unix 'fold' command? def fold(s,len): while s: print s[:len] s=s[len:] s="A very long string indeed. Really that long? Indeed." fold(s,10) Output: A very lon g string i ndeed. Rea lly that l ong? Indee d. Greeting

Re: Problem reading file with umlauts

2009-07-07 Thread Michiel Overtoom
Claus Hausberger wrote: I have a text file with is encoding in Latin1 (ISO-8859-1). I can't change that as I do not create those files myself. I have to read those files and convert the umlauts like ö to stuff like &oumol; as the text files should become html files. umlaut-in.txt: This fi

Re: IDLE / Python 2.5 under Jaunty

2009-06-24 Thread Michiel Overtoom
Duncan Smith wrote: > IDLE now refuses to respond to left click events (for code editing, menus etc. respond as expected). If I right click, then left click I can move the cursor, but that's not ideal. > So, has anybody else had the left click issue with IDLE (and solved it)? Irritating p

Re: OT: Periodic table gets a new element

2009-06-11 Thread Michiel Overtoom
MRAB wrote: Element 112 is to be named. Do you think we could persuade the scientists to name it "Pythonium"? :-) What did Python do to deserve this? I think 'Hofmannium' is a more appropriate name ;-) On the other hand, if the scientists used Python on their equipment with which they dis

Re: GUI Programming

2009-05-28 Thread Michiel Overtoom
On Sunday 12 April 2009 15:07:11 Gabriel wrote: > I'm python newbie and i need to write gui for my school work in python. > I need to write it really quick, because i haven't much time .) Try Tkinter, which is included by default with most Python installations. Writing simple programs is easy li

Re: error in tutorial for 3.0, section 9.3.3

2009-05-23 Thread Michiel Overtoom
Vincent writes: > you kinda expect MyClass to have counter in it. Yeah, that makes sense. These instance variables are often initialized in the __init__ method: class Counter(object): def __init__(self,initialvalue): self.value=initialvalue def inc(self): self.value+

Re: PyFits for Windows?

2009-03-28 Thread Michiel Overtoom
W. eWatson wrote: It looks like PyFits downloads are for Linux. Isn't there anything available for Win (xp)? According to http://www.stsci.edu/resources/software_hardware/pyfits: "PyFITS’s source code is pure Python. It requires Python version 2.3 or newer. PyFITS also requires the numarray

Re: What way is the best to check an empty list?

2009-03-25 Thread Michiel Overtoom
On 25 Mar 2009, at 21:29 , Stef Mientki wrote: Now it would be nice to allow iteration over others too, like None . a = None for item in a : do_something_with_item I saw this technique used in CherryPy: >>> a=None >>> for item in a or []: ...print item ... >>> a=[1,2,3]

Re: Decorators

2009-03-06 Thread Michiel Overtoom
Johnny wrote... >Can anyone explain to me what are decorators for? What are advantages >of using them? A tutorial article about decorators from Bruce Eckel: http://www.artima.com/weblogs/viewpost.jsp?thread=240808 -- "The ability of the OSS process to collect and harness the collective IQ of

Re: How to represent a sequence of raw bytes

2008-12-21 Thread Michiel Overtoom
On Monday 22 December 2008 03:23:03 Steven Woody wrote: > 2. char buf[] = {0x11, 0x22, 0x33, ... } > > What's the equivalent representation for above in Python? >>> buf="\x11\x22\33" >>> for b in buf: print ord(b) ... 17 34 27 >>> Greetings, -- "The ability of the OSS process to collect and

Re: How to make arrays from Lists

2008-11-16 Thread Michiel Overtoom
[EMAIL PROTECTED] wrote: x = [[0] * ncols for i in nrows] That gives an error... small typo corrected: y = [[0] * ncols for i in range(nrows)] Greetings, -- "The ability of the OSS process to collect and harness the collective IQ of thousands of individuals across the Internet is simply ama

Re: Problem with sqlite3 cursor and imbricated for loop

2008-11-11 Thread Michiel Overtoom
Charles V. wrote: It seems the second call to execute modify the first cursor. Is it normal ? How am I suppose to write this ? Maybe introduce a second cursor? import sqlite3 conn = sqlite3.connect(':memory:') c = conn.cursor() d = conn.cursor() # second cursor c.execute('''create table stock

Re: How to know a top directory?

2008-08-23 Thread Michiel Overtoom
Grigory wrote... > I have path "/this/is/path" and I wanna get "/this/is". >Also I want to use it as platform independent. If I want to pass "c: >\that\path" then I need to get "c:\that". import os print os.path.split("/home/user/motoom")[0] print os.path.split("c:\\prj\\techniques\\python")[0]

Re: maximum value in a column of file

2008-07-23 Thread Michiel Overtoom
Maurizio wrote... > the problem is that i don't know how to put the column of the file in an > array. (i'm new in phyton). Give us an example of how your file looks, and what you want to extract from it, so that we don't have to guess. Greetings, -- "The ability of the OSS process to collect

Re: Python Written in C?

2008-07-22 Thread Michiel Overtoom
giveitawhril2008 wrote... > I think someone should write a compiler, "Revenge of BASIC." Your remark made an immediate association with me with the following soundtrack: http://www.empire-of-the-claw.com/files/Empire%20of%20The%20Claw%20-%20Tranc e%20of%20the%2080's%20Arcade.mp3 "A creature for

Re: Python Written in C?

2008-07-20 Thread Michiel Overtoom
Giveitawhril wrote... > REAL WORLD programmers who want to be generally useful go > and learn C#. No: Real programmers first eat a quiche and then return to their Pascal programming. > But the SOURCE is some old, high level language which no one wants to > use anymore! C is alive and kickin

Re: Change PC to Win or Windows

2008-07-19 Thread Michiel Overtoom
On Saturday 19 July 2008 22:30:29 Dennis Lee Bieber wrote: > I still wonder who came up with the Commodore PET -- Personal > Electronic Transactor... yeesh... But the "Personal" was already in play > way back then. Probably Chuck Peddle, Jack Tramiel or Leonard Tramiel. For your amusement:

Re: win32api not found?

2008-07-19 Thread Michiel Overtoom
On Saturday 19 July 2008 21:13:04 Lamonte Harris wrote: > Where can I get the win32api module? I been searching all day on google and > nothing, i installed > https://sourceforge.net/project/showfiles.php?group_id=78018 which requires > win32api and its not found... What are the actions you do an

Re: Python for Kids

2008-07-15 Thread Michiel Overtoom
Sean wrote... > Pretty cool!! Our base will be *much* bigger in about twenty years. > I remember doing Basic on my dads Apple IIe. Gee, I wish Python existed back then. I had to endure Commore Basic on the PET2001. The biggest challenge was how to fit the program in 8K... It didn't take me long

Re: Simplify Code

2008-07-15 Thread Michiel Overtoom
Victor wrote... ># Headers are kept in order to determine nesting of chapters ># They are labeled according to font size I'm not sure what you're trying to achieve (I can't divine it from your example code), but I suspect that a dictionary of sizes and header texts is somewhat more manegable than

Re: Is it legal to rebuild Python.exe to include Version property tab?

2008-07-15 Thread Michiel Overtoom
Ward wrote... > Can we rebuild Python.exe to include the various "version" > information? Why rebuild it? You can use a resource editor tool to add/edit/delete the VERSIONINFO from any Windows executable, including Python.exe ;-) Greetings, -- "The ability of the OSS process to collect and ha

Re: Characters Being Misread

2008-07-15 Thread Michiel Overtoom
Victor wrote... import binascii binascii.unhexlify('\x0c') >TypeError: Odd-length string >What gives here? The function unhexlify() wants an even-length string. From the online help: >>> help(binascii.unhexlify) unhexlify(...) a2b_hex(hexstr) -> s; Binary data of hexadecimal repres

Re: Type Problem

2008-07-15 Thread Michiel Overtoom
Victor wrote... >len = len(dirs) The function 'len' is a built-in function in Python. If you assign an integer to the name 'len', that will replace the function with an int. And you can't call an int. My suggestion: Do not use 'len' as a variable name. Use something else, like: director

Re: Simplify Code

2008-07-15 Thread Michiel Overtoom
Victor wrote... ># del is used to determine if should reset the lower header values to '' >del = 0 Apart from many other things that spring to mind, I already see an obvious flaw: 'del' is a keyword, or a 'reserved word' in Python. It is used to remove variables from the namespace. Tip: Use some

Re: Determining when a file has finished copying

2008-07-14 Thread Michiel Overtoom
Ethan wrote: > One more option may be to attempt to rename > the file -- if it's still open for copying, that will fail; > success indicates the copy is done. Caveat -- this is dependent on the operating system! Windows will indeed not allow you to rename or delete a file that's still open f

Re: Use of index

2008-07-12 Thread Michiel Overtoom
SUBHABRATA wrote... > Now, my q is can we use index like find? Yes, you can. There is only a difference when the string is not found: the 'find()' function will return -1, whereas 'index()' function will raise a ValueError exception. For example: >>> b="A spaghetti monster is always great" >>>

Re: Help with BeautifulSoup

2008-07-12 Thread Michiel Overtoom
Alex wrote... > >Okay, heres the general idea of the html I have to work with: > > > noun > > > > > verb > > > > > >Okay, I left off some stuff. I wish you didn't, or at least provided an URL where I can get the page which you are trying to parse. Now I don't have a vali

Re: Using the Random Module.

2008-07-11 Thread Michiel Overtoom
You wrote... >Is there a better way to do that besides doing this: > random.randint(0, 9) >09657398671238769 Maybe this? random.randint(0, 9e16) -- "The ability of the OSS process to collect and harness the collective IQ of thousands of individuals

Re: Can anyone suggest a date peocedure...

2008-07-10 Thread Michiel Overtoom
Ron wrote: Now all I need to know is how to plug the date into the datetime object from a string. You could use simple string manipulation: >>> import datetime >>> a="20081031" >>> d=datetime.date(int(a[0:4]),int(a[4:6]),int(a[6:8])) >>> d datetime.date(2008, 10, 31) >>> print d 2008-10-31

Re: parsing incoming emails

2008-07-10 Thread Michiel Overtoom
Ahmed wrote... > I am working on a project where I need to parse incoming emails > (Microsoft outlook) I'm not sure if you are able to bypass Outlook (and have Python fetch the mail itself using poplib), but if you are, the following code might be useful. I use this to pry apart emails which mig

Re: Graphics

2008-07-10 Thread Michiel Overtoom
Vanam wrote... > I want to know whether is there anything that has > to be installed in addition to python 2.5 > > from gasp import * You have to install the 'gasp' package too. https://launchpad.net/gasp-code/stable-0.1.x/0.1.1 -- "The ability of the OSS process to collect and harness the

Re: formatting list -> comma separated (slightly different)

2008-07-09 Thread Michiel Overtoom
Paul & Robert wrote... > d = ["soep", "reeds", "ook"] >print ', '.join(d) > soep, reeds, ook I occasionally have a need for printing lists of items too, but in the form: "Butter, Cheese, Nuts and Bolts". The last separator is the word 'and' instead of the comma. The clearest I could come up with