simple pythonpath query
I've downloaded the hypertext module and put it in the c:\python24\lib folder. I would have thought that since the lib directory is in the Pythonpath,I would be able to import python scripts from C:\Python24\Lib\HyperText. I also tried including C:\Python24\Lib\HyperText to HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.4\PythonPath but no joy. Am I missing something very simple here? Thanks, Marc -- http://mail.python.org/mailman/listinfo/python-list
Re: simple pythonpath query
Cheers Tim, that sorted it. I need to re-read the modules section and namespaces. Everydays a schoolday. MW. -- http://mail.python.org/mailman/listinfo/python-list
XML ElementTree Parse.
I'm playing with XML and elementtree and am missing something but I'm not sure what...? I've create an XML file with Elementtree with a root of backup.xml. Attached to the root is a dirob and the dirobj has a fileobj. fileobj has filename and filesize tags. I can open the file in excel and it sets out the columns as I would expect. The problem I'm having is parsing the file. Using.. >>> file = open('c:\\scripts\\backup.xml', "r") >>> tree = parse(file) >>> elem = tree.getroot() >>> elem.findtext('filesize') Doesn't return anything, infact I can't seem to find anything regardless of what I search for. Here is the XML. I've got a list of files and their containing directories and I want my python script to append to the XML file each day. I could have done it with SQL but fancied banging my head on the wall instead. Thanks, MW. - - C:\sysprep - test.txt 10 -- http://mail.python.org/mailman/listinfo/python-list
Re: XML ElementTree Parse.
Thanks Fredrik, thats got me started but just incase anyone looks there is a slight mistype in your code... or you could do something like > > for dir_elem in tree.findall("dirob"): > for file_elem in dirob.findall("fileob"): > print file_elem.findtext("filesize") > > to loop over all directory objects at the top level, and print the sizes for > all files in those directories. should read >>> for delem in tree.findall("dirob"): ... for felem in delem.findall("fileob"): ... print felem.findtext("filesize") ... 933888 9365 -- http://mail.python.org/mailman/listinfo/python-list
batteries included
Could someone confirm that modules like socket don't use libraries/ dlls on a particular OS, they are completly self contained. Thanks, Marc. -- http://mail.python.org/mailman/listinfo/python-list
Re: Slurping All Content of a File into a Variable
myfile_content is an object and you have only opened the file. Python doesn't yet know whether you want to read it, copy it etc. to read it try text = myfile_content.readlines() print text this should be in most tutorials Wijaya Edward wrote: > Hi, > > How can we slurp content of a single file > into one variable? > > I tried this: > > >>> myfile_content = open('somefile.txt') > >>> print myfile_content, > > >>> > > But it doesn't print the content of the file. > > Regards, > -- Edward WIJAYA > SINGAPORE > > > Institute For Infocomm Research - Disclaimer - > This email is confidential and may be privileged. If you are not the > intended recipient, please delete it and notify us immediately. Please do not > copy or use it for any purpose, or disclose its contents to any other person. > Thank you. > -- http://mail.python.org/mailman/listinfo/python-list
Re: sound processing modules in python - anyone?
I've had a brief look at this and there isn't a sound orientated library as such. You can however use numpy to do stuff like FFTs and there are there is a wave module in python that will allow you to create wavs, you can google for importing wav's into numpy arrays. This seemed like a good idea to me as I think Numpy is written in C or C++ (or maybe it was fortran). There seem to be a lot of people using numpy in a similar way to matlab so there is a fair ammount of the standard DSP routines have already been written. [EMAIL PROTECTED] wrote: > Hi everyone, > I'm looking for a module for sound processing (manipulating sound objets, > filters, ffts etc.). > I tried Snack, but when i downloaded the package that was supposed to be > for python, there was only the Tk/Tcl stuff (where's the .py ?). > could anyone help me with that (or with any other sound module for python)? > thanks in advance, > g -- http://mail.python.org/mailman/listinfo/python-list
Re: sound processing modules in python - anyone?
I've had a brief look at this and there isn't a sound orientated library as such. You can however use numpy to do stuff like FFTs and there are there is a wave module in python that will allow you to create wavs, you can google for importing wav's into numpy arrays. This seemed like a good idea to me as I think Numpy is written in C or C++ (or maybe it was fortran). There seem to be a lot of people using numpy in a similar way to matlab so there is a fair ammount of the standard DSP routines have already been written. [EMAIL PROTECTED] wrote: > Hi everyone, > I'm looking for a module for sound processing (manipulating sound objets, > filters, ffts etc.). > I tried Snack, but when i downloaded the package that was supposed to be > for python, there was only the Tk/Tcl stuff (where's the .py ?). > could anyone help me with that (or with any other sound module for python)? > thanks in advance, > g -- http://mail.python.org/mailman/listinfo/python-list
Re: CPU or MB Serial number
Bayazee wrote: > Hi, > How can I get CPU Serial number , or motherboard serial number with > python . I need an idetification of a computer > ThanX > > --- > iranian python community --> www.python.ir If you are on a windows box with WMI (2000 or above) you can use Python, win32com extentions to get it. The WMI stuff is easily accessible with Tim Goldens wrapper http://tgolden.sc.sabren.com/python/wmi.html >>> import wmi >>> c = wmi.WMI() >>> for s in c.Win32_Processor(): ... print s ... instance of Win32_Processor { AddressWidth = 32; Architecture = 0; Availability = 3; Caption = "x86 Family 15 Model 2 Stepping 4"; CpuStatus = 1; CreationClassName = "Win32_Processor"; CurrentClockSpeed = 1794; CurrentVoltage = 15; DataWidth = 32; Description = "x86 Family 15 Model 2 Stepping 4"; DeviceID = "CPU0"; ExtClock = 100; Family = 2; L2CacheSize = 0; Level = 15; LoadPercentage = 7; Manufacturer = "GenuineIntel"; MaxClockSpeed = 1794; Name = " Intel(R) Pentium(R) 4 CPU 1.80GHz"; PowerManagementSupported = FALSE; ProcessorId = "3FEBFBFF0F24"; ProcessorType = 3; Revision = 516; Role = "CPU"; SocketDesignation = "Microprocessor"; Status = "OK"; StatusInfo = 3; Stepping = "4"; SystemCreationClassName = "Win32_ComputerSystem"; SystemName = "LON42"; UpgradeMethod = 4; Version = "Model 2, Stepping 4"; }; -- http://mail.python.org/mailman/listinfo/python-list
ctypes listing dll functions
hi all and before I start I apologise if I have this completely muddled up but here goes. I'm trying to call functions from a dll file in a python script but I can't work out what functions are available. I'm using ctypes. I've tried using dir(ctypes_object) but the resultant output looks like a list of standard functions and not the ones I'm looking for. Also how can I tell if the dll was written in C or C++ as I understand C++ dlls can't be used. I have a header file that starts; #ifndef __DIRAC__ #define __DIRAC__ // Prototypes const char *DiracVersion(void); void *DiracCreate(long lambda, long quality, long numChannels, float sampleRate, long (*readFromChannelsCallback)(float **data, long numFrames, void *userData)); void *DiracCreate(long lambda, long quality, long numChannels, float sampleRate, long (*readFromChannelsCallback)(float *data, long numFrames, void *userData)); long DiracSetProperty(long selector, long double value, void *dirac); long double DiracGetProperty(long selector, void *dirac); void DiracReset(bool clear, void *dirac); long DiracProcess(float **audioOut, long numFrames, void *userData, void *dirac); long DiracProcess(float *audioOut, long numFrames, void *userData, void *dirac); void DiracDestroy(void *dirac); long DiracGetInputBufferSizeInFrames(void *dirac); I would have thought that DiracCreate, DiracSetProperty etc were all callable functions. As you may have guessed I'm don't do much work in C... Thanks, MW. -- http://mail.python.org/mailman/listinfo/python-list
ctypes listing dll functions
hi all and before I start I apologise if I have this completely muddled up but here goes. I'm trying to call functions from a dll file in a python script but I can't work out what functions are available. I'm using ctypes. I've tried using dir(ctypes_object) but the resultant output looks like a list of standard functions and not the ones I'm looking for. Also how can I tell if the dll was written in C or C++ as I understand C++ dlls can't be used. I have a header file that starts; #ifndef __DIRAC__ #define __DIRAC__ // Prototypes const char *DiracVersion(void); void *DiracCreate(long lambda, long quality, long numChannels, float sampleRate, long (*readFromChannelsCallback)(float **data, long numFrames, void *userData)); void *DiracCreate(long lambda, long quality, long numChannels, float sampleRate, long (*readFromChannelsCallback)(float *data, long numFrames, void *userData)); long DiracSetProperty(long selector, long double value, void *dirac); long double DiracGetProperty(long selector, void *dirac); void DiracReset(bool clear, void *dirac); long DiracProcess(float **audioOut, long numFrames, void *userData, void *dirac); long DiracProcess(float *audioOut, long numFrames, void *userData, void *dirac); void DiracDestroy(void *dirac); long DiracGetInputBufferSizeInFrames(void *dirac); I would have thought that DiracCreate, DiracSetProperty etc were all callable functions. As you may have guessed I'm don't do much work in C... Thanks, MW. -- http://mail.python.org/mailman/listinfo/python-list
mod_python, dates, strings and integers
when POSTing a date from an mod_python psp page to another the date is sent as a string. I'm using form.has_key to pull the POST. I can cut the string up,turn the strings into integers and then use datetime.datetime(y,m,d,hr,mn,se) to create a proper datetime. Is there a simpler way of doing this. I ask as I'm working with SQL and want to keep as much possible in datetime format to avoid confusion/ errors. snippet post is; "monday - 01/01/2006" if form.has_key('day'): string_day = form['day'] textday = string_day.split("-",1)[0] pyday = string_day.split("-",1)[1] d,m,y = pyday.split('/',2) d = int(d) m = int(m) y = int(y) today = datetime.datetime(y,m,d) Thanks, Marc. -- http://mail.python.org/mailman/listinfo/python-list
using variables with modules
Hi, I am trying to move away from Windows only scripting to Python. I've written a quick script that will pull the product version from the client registry. I can get the IP addresses from a file into a list and then pull each element in the list using the for loop. I am setting each element to a varuable ClientIP. When I try to use that variable in _winreg values it is not substituting the element from the list. If I type the list value straight into the _winreg command it works fine. The IPaddresses in the list are surrounded by quotes. So 1. can I use variables with modules? (I have assumed that I can!) 2. does putting quotes around the IPaddress in the list create a problem (my list is something like ["192.168.0.1","192.168.0.2"] I've also tried not having the list elements in quotes and using %s substitution in the _winreg command. Any help would be much appreciated, Cheers, MW. #Query ProductName in windows Registry import _winreg import sys readfile = open("c:\scripts\ip.txt", 'r') IPList = readfile.readlines() for ClientIP in IPList: print ClientIP key = _winreg.ConnectRegistry(ClientIP, _winreg.HKEY_LOCAL_MACHINE) hkey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion") OSver=_winreg.QueryValueEx( hkey, "ProductName") print OSver print "Exiting Script" sys.exit() -- http://mail.python.org/mailman/listinfo/python-list
Re: using variables with modules
thanks runes, that makes sense, time for me to go off and read some more about strip and try: Cheers, MW. -- http://mail.python.org/mailman/listinfo/python-list
python create WMI instances
Hi all, I am struggling with a vb - python code conversion. I'm using WMI to create printers on remote machines using (in VB); set oPrinter = oService.Get("Win32_Printer").SpawnInstance_ oPrinter.DriverName = strDriver oPrinter.PortName = strPort oPrinter.DeviceID = strPrinter oPrinter.Put_(kFlagCreateOnly) In python I have logged onto the WMI service on the remote machine and I can run things like c.new.AddPrinterConnection so I know that I am connected and working OK. I don't get any errors when I create a new object with SpawnInstance_ but when I try to set the value of oPrinter.Drivername I get an error saying that the Drivername object doesn't exist. Does anyone know how to set the values of the object using either the method above or with the WMI module? I think the WMI module only allows access to modify methods such ADDPrinterConnection or Create (from Win32_Service). Thanks,MW. -- http://mail.python.org/mailman/listinfo/python-list
Re: NOOOOB
On May 22, 11:29 am, jolly <[EMAIL PROTECTED]> wrote: > Hey guys, > > I want to begin python. Does anyone know where a good starting point > is? > > Thanks, > Jem i went through the tutorials on the main site and then followed up with mark Hammonds book for windows stuff. I got a few other books as well to reference but I've found it easy enough to find info for almost everything on the net. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python for web development ...
On Aug 22, 5:13 pm, [EMAIL PROTECTED] wrote: > Hi everyone, > > I have to do a web based application for my final year project. Since, > i am only familiar with basic HTML and Java Script, i am totally new > to this one. My friends are using LAMP (P->PHP). But i want to use > Python. Is it possible to use Python with Apache and MySQL. Is it > possible ? Any websites/books ? > > Thank you there are a number of ways to do it. I've used mod_python embedded into Apache and it worked well and I found it easy to pick up and advanced enough to do pretty much whatever I wanted. There are in depth docs and tutorials on the mod_python page. You could also look at a preconfigured stacks like Turbogears or Django although they may have many features you don't need. Have a look at http://wiki.python.org/moin/WebFrameworks -- http://mail.python.org/mailman/listinfo/python-list
Re: write whitespace/tab to a text file
On Oct 19, 3:33 pm, dirkheld <[EMAIL PROTECTED]> wrote: > Hi, > > I would l like to write some data to a text file. I want to write the > data with whitespace or tabs in between so that I create tabular > columns like in a spreadsheet. How can I do this in python. > (btw, I'm new to python) > > names = ['John','Steve','asimov','fred','jim'] > ## output I would like in txt file : John Steve > asimov fred jim > > f=open('/User/home/Documents/programming/python/test.txt','w') > for x in range(len(names)): > f.write(tags[x]) > f.close() I'm not sure exactly but you'll probably need to find out what the ASCII code is for a tab. Personally I would just write data straight into Excel using the win32 extensions. I'm sure the same can be achieved with OO on a Linux box. -- http://mail.python.org/mailman/listinfo/python-list
Re: Please Help !!!
On Oct 17, 10:32 am, Heiko Schlierkamp <[EMAIL PROTECTED] africa.com.na> wrote: > I need to update the virus program every day with the new dat file from > mcafee > I would like to us a Bat file to go to the web page and download the dat > file automatically to a specific Directory, that I have created, but my > problem lays in that the bat file will open the file to be downloaded but > the bat file does not confirm the save button so that it start to download > the file, that I still need to do manual. Please advice me with what still > need to be done!! > Your help will be very appreciated!!! > > I have added the file so you can see what it does exactly!! > > > Heiko Schlierkamp > > SENSE OF AFRICA - Namibia > > E-mail: [EMAIL PROTECTED] > > Website:www.sense-of-africa.com > > Tel: +264 61 275300 > > Fax: +264 61 263417 > > PO Box 2058, Windhoek, Namibia > > <> > > Superdat.rar > 1KDownload I'm not going to open that file I'm afraid and I doubt many others will either. You are using Python I assume. Have a look at the urllib module and the urlretrieve function. -- http://mail.python.org/mailman/listinfo/python-list
pymssql text type
Hi, I'm trying to pass a text blob to MS SQL Express 2008 but get the follwoing error. (, OperationalError("SQL Server message 102, severity 15, state 1, line 1:\nIncorrect syntax near 'assigned'.\n",), ) the string it is having an issue with is (\r\n\r\n\tLogon ID:\t\t(0x0,0xE892A8)\r\n\r\n\tLogon Type:\t2\r\n\r \n') It looks like SQL is reading the blob, finding the newline codes and generating an error. Is there anyway I can get it to ignore the text and just enter the whole sentance as a string. I think that some automatic character encodign might be taking place hence the string is being read but I can work out whether I need to character encode in Python, change a table setting in SQL or do something to pymssql. Thanks, Marc. -- http://mail.python.org/mailman/listinfo/python-list
confused about classes and tkinter object design
Hi, I've created my first Tkinter GUI class which consists of some buttons that trigger functions. I have also created a tkFileDialog.askdirectory control to local a root folder for log files. I have several file paths that depend on the value of tkFileDialog.askdirectory should I create an object that inherits this value or can I point functions at the GUI class? I am creating the tkinter GUI instance using; if __name__ == "__main__": GUI = AuditorGUI() GUI.mainloop() class AuditorGUI(Frame): def __init__(self): Frame.__init__(self) self.pack(expand = YES, fill = BOTH) ## Create GUI objects self.currentdir = StringVar() self.currentdir.set(os.getcwd()) self.logdir = Button(self, text="Choose Data directory",command=self.choose_dir) self.logdir.grid(row=1,column=0,sticky='nsew',pady=20,padx=20) self.labeldirpath = Label(self, textvariable=self.currentdir) def choose_dir(self): dirname = tkFileDialog.askdirectory (parent=self,initialdir=self.currentdir.get(),title='Please select a directory') if len(dirname ) > 0: self.currentdir.set(dirname) I think I have created an instance of the AuditorGUI class called GUI so should be able to access the path using GUI.currentdir but this doesn't work. I'm still struggling with classes so not sure whether my problem is tkinter related or not. Thanks, MW -- http://mail.python.org/mailman/listinfo/python-list
Re: confused about classes and tkinter object design
On Nov 26, 12:09 pm, Bruno Desthuilliers wrote: > marc wyburn a écrit : > > > Hi, > > > I've created my firstTkinterGUI class which consists of some buttons > > that trigger functions. I have also created a > > tkFileDialog.askdirectory control to local a root folder for log > > files. > > > I have several file paths that depend on the value of > > tkFileDialog.askdirectory should I create an object that inherits this > > value or can I point functions at the GUI class? > > > I am creating thetkinterGUI instance using; > > > if __name__ == "__main__": > > GUI = AuditorGUI() > > Note that at this point, the AuditorGUI class is not yet defined, so you > should get a NameError. > > > > > GUI.mainloop() > > > class AuditorGUI(Frame): > > I assume you have all necessary imports in your real code... > > > > > > > def __init__(self): > > Frame.__init__(self) > > self.pack(expand = YES, fill = BOTH) > > > ## Create GUI objects > > > self.currentdir = StringVar() > > self.currentdir.set(os.getcwd()) > > > self.logdir = Button(self, text="Choose Data > > directory",command=self.choose_dir) > > self.logdir.grid(row=1,column=0,sticky='nsew',pady=20,padx=20) > > > self.labeldirpath = Label(self, textvariable=self.currentdir) > > > def choose_dir(self): > > dirname = tkFileDialog.askdirectory > > (parent=self,initialdir=self.currentdir.get(),title='Please select a > > directory') > > if len(dirname ) > 0: > > self.currentdir.set(dirname) > > > I think I have created an instance of the AuditorGUI class called GUI > > so should be able to access the path using GUI.currentdir but this > > doesn't work. > > "does not work" is (almost) the less possible usefull description of a > problem. What happens exactly ? Do you have a traceback ? If so, please > post the full traceback and error message. Else, please explain what > result you get. And if possible, post minimal *working* code reproducing > the problem. > > > I'm still struggling with classes so not sure whether my problem is > >tkinterrelated or not. > > Minus the couple problems above (ie: trying to instanciate a > non-yet-existing class, and lack of necessary imports), it seems correct > - at least wrt/ class definition and instanciation.- Hide quoted text - > > - Show quoted text - thanks for your help. I'm not creating the instances properly. Everything works as expected if I merge everything into the class. Time to get the manual out again. Thanks for pointing me in the right direction. MW -- http://mail.python.org/mailman/listinfo/python-list
Re: pymssql text type
On Mar 12, 3:36 pm, a...@pythoncraft.com (Aahz) wrote: > [posted and e-mailed, please reply to group] > > In article <851ed9db-2561-48ad-b54c-95f96a7fa...@q9g2000yqc.googlegroups.com>, > marcwyburn wrote: > > >Hi, I'm trying to pass a text blob to MS SQL Express 2008 but get the > >follwoing error. > > >(, OperationalError("SQL Server > >message 102, severity 15, state 1, line 1:\nIncorrect syntax near > >'assigned'.\n",), ) > > >the string it is having an issue with is > > >(\r\n\r\n\tLogon ID:\t\t(0x0,0xE892A8)\r\n\r\n\tLogon Type:\t2\r\n\r > >\n') > > What is the code you're trying to execute and what is the full traceback? > -- > Aahz (a...@pythoncraft.com) <*> http://www.pythoncraft.com/ > > "All problems in computer science can be solved by another level of > indirection." --Butler Lampson I can't remember what the original code was but will try to recreate it. I ended up using re to remove most of the line breaks and tabs. -- http://mail.python.org/mailman/listinfo/python-list
gethostbyname blocking
Hi, I am writing an asynchronous ping app to check if 1000s of hosts are alive very quickly. Everything works extremely quickly unless the host name doesn't have a DNS record. when calling socket.gethostbyname if there is no record for the host the result seems to block all other threads. As an example I have 6 threads running and if I pass the class below a Queue with about 30 valid addresses with one invalid address in the middle the thread that the exception occurs in seems to block the others. I'm pretty new to threading so am not sure if my threading code is wrong or whether I need to look at how gethostbyname? When there list is made entirely of valid host names I get the responses back very very quickly. class HostThread(threading.Thread): def __init__(self, Host_Queue): threading.Thread.__init__(self) self.Host_Queue = Host_Queue def run(self): while True: # Create a new IP packet and set its source and destination addresses. host = self.Host_Queue.get() try: dest_addr, alias, ipaddrlist = socket.gethostbyname_ex(host) except socket.gaierror, (errorno, details): print '%s: %s' %(host,details) else: print '%s: %s' %(host, ipaddrlist) self.Host_Queue.task_done() Thanks, Marc. -- http://mail.python.org/mailman/listinfo/python-list
Re: gethostbyname blocking
On Apr 22, 5:19 pm, Jean-Paul Calderone wrote: > On Wed, 22 Apr 2009 08:08:51 -0700 (PDT), marc wyburn > wrote: > >Hi, I am writing an asynchronous ping app to check if 1000s of hosts > >are alive very quickly. Everything works extremely quickly unless the > >host name doesn't have a DNS record. > > >when calling socket.gethostbyname if there is no record for the host > >the result seems to block all other threads. As an example I have 6 > >threads running and if I pass the class below a Queue with about 30 > >valid addresses with one invalid address in the middle the thread that > >the exception occurs in seems to block the others. > > If your system doesn't have the gethostbyname_r function, then you can > only make one gethostbyname_ex call at a time - a call to this function > will block any other calls to this function, since it is not safe to > call gethostbyname reentrantly. > > I'm not sure what the easiest way to determine whether Python has found > gethostbyname_r or not on your system is. The configure script used to > build Python will probably tell, but I doubt you have that lying around. > You could just assume this is the case, since you're observing behavior > consistent with it. ;) > > An alternate approach would be to use a DNS library which doesn't have > this restriction. For example, Twisted includes a DNS library which > is not implemented in terms of threads. There are also a couple other > Python DNS client libraries around. > > This isn't /quite/ the same as using gethostbyname, though, since > gethostbyname is controlled by system configuration in various ways, > and may do more than just DNS lookups (in fact, it may even be > configured not to use DNS at all!). But it's pretty close, and may > be close enough for your purposes. > > Jean-Paul Thanks for the quick response. I'm using Win32, I don't think there is a non-blocking gethostbyname avail. I managed to find some info on the net but most of it was old and Nix related and I was hoping it was a bug that had been fixed and I was making a mistake with my threads. I wrote a simlar script that uses multiprocess and that seemed to have less problems but I will look at http://www.dnspython.org/. Thanks, Marc. -- http://mail.python.org/mailman/listinfo/python-list
Re: gethostbyname blocking
On Apr 23, 2:16 pm, Piet van Oostrum wrote: > >>>>> marc wyburn (MW) wrote: > >MW> Hi, I am writing anasynchronousping app to check if 1000s of hosts > >MW> are alive very quickly. Everything works extremely quickly unless the > >MW> host name doesn't have a DNS record. > >MW> when calling socket.gethostbynameif there is no record for the host > >MW> the result seems to block all other threads. As an example I have 6 > >MW> threads running and if I pass the class below a Queue with about 30 > >MW> valid addresses with one invalid address in the middle the thread that > >MW> the exception occurs in seems to block the others. > > What you could do is have two Queues, one with host names, and one with > results fromgethostbyname. And an additional thread which gets from the > first queue, callsgethostbynameand puts the results in the second queue. > The ping threads then should get from the second queue. The lookup > thread could even do caching of the results if you often have to repeat > the pings for thew same host. > -- > Piet van Oostrum > URL:http://pietvanoostrum.com[PGP 8DAE142BE17999C4] > Private email: p...@vanoostrum.org Hi, I did try this but the socket blocked for so long that this was a real bottleneck. It also seemed that whilst the DNS lookup thread was blocking the other threads were also blocked. I guess this may have something to do with the GIL but I'm still fairly new to threading. I ended up using DNSPython which flys along. I have a thread creating the ping packets and pinging them and another performing a select and logging + filtering any ICMP replies. I may put the DNS code into another thread but the whole script runs faster than I need it to as it is, I've got time.sleeps in the ping thread as I'm scared of saturating the local LAN during work hours. -- http://mail.python.org/mailman/listinfo/python-list
boolian logic
HI all, I'm a bit stuck with how to work out boolian logic. I'd like to say if A is not equal to B, C or D: do something. I've tried if not var == A or B or C: and various permutations but can't seem to get my head around it. I'm pretty sure I need to know what is calulated first i.e the not or the 'OR/AND's thanks, Marc. -- http://mail.python.org/mailman/listinfo/python-list
Re: boolian logic
On 13 Jun, 10:34, Aidan <[EMAIL PROTECTED]> wrote: > marc wyburn wrote: > > HI all, I'm a bit stuck with how to work outboolianlogic. > > > I'd like to say if A is not equal to B, C or D: > > do something. > > > I've tried > > > if not var == A or B or C: > > and various permutations but can't seem to get my head around it. I'm > > pretty sure I need to know what is calulated first i.e the not or the > > 'OR/AND's > > > thanks, Marc. > > You mean like a ternary operation? > > >>> True and 1 or 0 > 1 > >>> False and 1 or 0 > 0 > > This of course depends on the 'true' result also being true.. it fails > if it is false... > > if that's not what you mean, then maybe this is what you want > > if not var==A or not var==B or not var==C: > # do something the not var==A or not var==B or not var==C was what I was after. I was being too literal with my script and trying not (A or B or C) which doesn't work. Thanks for the help. -- http://mail.python.org/mailman/listinfo/python-list
CSV variable seems to reset
Hi, I'm using the CSV module to parse a file using whitelistCSV_file = open("\\pathtoCSV\\whitelist.csv",'rb') whitelistCSV = csv.reader(whitelistCSV_file) for uname, dname, nname in whitelistCSV: print uname, dname, nname The first time I run the for loop the contents of the file is displayed. Subsequent attempts to run the for loop I don't get any data back and no exception. The only way I can get the data is to run whitelistCSV_file = open("\ \pathtoCSV\\whitelist.csv",'rb') again. I'm stumped as to how I can get around this or work out what the problem is, I'm assuming that the 'open' command buffers the data somewhere and that data is being wiped out by the CSV module but surely this shouldn't happen. thanks, Marc. -- http://mail.python.org/mailman/listinfo/python-list
variable expansion with sqlite
Hi I'm using SQlite and the CSV module and trying to create a class that converts data from CSV file into a SQLite table. My script curently uses functions for everything and I'm trying to improve my class programming. The problem I'm having is with variable expansion. self.cursor.executemany('INSERT INTO test VALUES (?)', CSVinput) If CSVinput is a tuple with only 1 value, everything is fine. If I want to use a tuple with more than 1 value, I need to add more question marks. As I'm writing a class I don't want to hard code a specific number of ?s into the INSERT statement. The two solutions I can think of are; using python subsitution to create a number of question marks, but this seems very dirty or finding someway to substitue tuples or lists into the statement - I'm not sure if this should be done using Python or SQLite substitution though. Any tips on where to start looking? Thanks, Marc. -- http://mail.python.org/mailman/listinfo/python-list
Re: variable expansion with sqlite
Hi and thanks, I was hoping to avoid having to weld qmarks together but I guess that's why people use things like SQL alchemy instead. It's a good lesson anyway. Thanks, Marc. On Jul 30, 2:24 pm, Tim Golden <[EMAIL PROTECTED]> wrote: > Gerhard Häring wrote: > > My code would probably look very similar. Btw you don't need to use > > list() on an iterable to pass to executemany(). pysqlite's executemany() > > accepts anything iterable (so generators work fine, too). > > Thanks for that. My finger-memory told me to do that, possibly > because some *other* dbapi interface only accepts lists. Can't > quite remember. I'm usually all in favour of non-crystallised > iterators. > > > Also, with SQLite you can just skip data type definitions like > > VARCHAR(200). They're ignored anyway. > > Heh. Once again, finger memory forced me to put *something* > in there. I've been developing Enterprise databases for too > long :) > > TJG -- http://mail.python.org/mailman/listinfo/python-list
C++ and Python
I've been learning to write VST plugins in C++ and would like to switch back to Python. The first step of writing the plugin is to import the C++ header files from the Steinberg SDK. How can I do this in Python. I've tried looking at SWIG but didn't really understand what it was trying to do.Should I be using SWIG to create Python versions of the classes and then go from there or does it create glue code to talk to the classes. -- http://mail.python.org/mailman/listinfo/python-list
Re: C++ and Python
sorry accidentally hit post. has nyone tried this before? Thanks, Marc. -- http://mail.python.org/mailman/listinfo/python-list
Active Directory ADO strange objects returned
Hi, I have a script that returns data from active directory using ADO. Everything works except for any fields that use a time value I get an instance of an object returned called . I know it's a time object because if I do object.HighPart or object.LowPart I get a value back. The bit I don't understand is how I inspect the object to work out what it is programmatically. Do I need to do some sort of makepy trickery so that the object is understood by Python? I have already makepy'd MS ActiveX Data Object 2.8. thanks, Marc. -- http://mail.python.org/mailman/listinfo/python-list