Search Results

Search found 13693 results on 548 pages for 'python metaprogramming'.

Page 94/548 | < Previous Page | 90 91 92 93 94 95 96 97 98 99 100 101  | Next Page >

  • python `IN` module problem (FreeBSD)

    - by Shamanu4
    I'm trying to work with sockets and I have such problem In code example: setsockopt(socket.SOL_SOCKET,IN.SO_BINDTODEVICE,self.listen_address+'\0') I have error AttributeError: 'module' object has no attribute 'SO_BINDTODEVICE' On Linux machine this attribute is OK but on FreeBSD trere are no any SO_* attributes in module IN. What port should I install to resolve this problem on FreeBDS machine? Python versions on Linux tested: 2.5.4 and 2.6.4; on FreeBSD: 2.5.5 I can't find anything about this module in my book, and googling keyword IN looks like seamless ...

    Read the article

  • Importing Python modules without installing - Sybase ASE

    - by Michael
    I need to use the Sybase Python module but our SA's won't install because it's not in the repo's. I've downloaded it and placed it on the box and would just like to 'import' or 'include' the module without installing it first. - Is this possible? From the looks of it (Sybase ASE) it needs some type of compilation before use. Is it possible for this type of work around?

    Read the article

  • Reading object tree from file into Python

    - by jjkparker
    I have a Python app that contains an object structure that the user can manipulate. What I want to do is allow the user to create a file declaring how the object structure should be created. For example, I would like the user to be able to create the following file: foo.bar.baz = true x.y.z = 12 and for my app to then create that object tree automatically. What's the best way to do something like this?

    Read the article

  • Log into Launchpad from python script

    - by jack
    How can I log into my Launchpad account in a python script? Any sample code would be appreciated. The login url is https://launchpad.net/+login and then redirect to something like https://login.launchpad.net/fJLVSRbxPfKTpVDr/+decide Thanks in advance!

    Read the article

  • Python, invoke super constructor

    - by Mike
    class A: def __init__(self): print "world" class B(A): def __init__(self): print "hello" B() hello In all other languages I've worked with the super constructor is invoked implicitly. How does one invoke it in Python? I would expect super(self) but this doesn't work

    Read the article

  • Documentation String Stub, Python

    - by Andres Orozco
    Well i'm learning Python cuz' i think is an awesome and powerful language like C++, perl or C# but is really really easy at same time. I'm using JetBrains' Pycharm and when i define a function it ask me to add a "Documentation String Stub" when i click yes it adds somethin like this: """ """ so the full code of the function is something like this: def otherFunction(h, w): """ """ hello = h world = w full_word = h + ' ' + w return full_word I would like to know what these (""" """) symbols means, Thanks. Ps.Data: Sorry for my bad english :D

    Read the article

  • Python: inserting double or single quotes around a string

    - by Jessy
    Im using python to access a MySQL database and im getting a unknown column in field due to quotes not being around the variable. code below: cur = x.cnx.cursor() cur.execute('insert into tempPDBcode (PDBcode) values (%s);' % (s)) rows = cur.fetchall() How do i manually insert double or single quotes around the value of s? I've trying using str() and manually concatenating quotes around s but it still doesn't work. The sql statement works fine iv double and triple check my sql query.

    Read the article

  • Make OS open directory in Python

    - by Vidar
    I am writing a program in Python, and want to get it to make the OS open the current working directory, making for instance Windows open explorer.exe and navigating to the wanted directory. Any ideas on how to do this? The directory is already given by os.getcwd. Cross platform methods preferred :)

    Read the article

  • Dynamically loading modules in Python (+ threading question)

    - by morpheous
    I am writing a Python package which reads the list of modules (along with ancillary data) from a configuration file. I then want to iterate through each of the dynamically loaded modules and invoke a do_work() function in it which will spawn a new thread, so that the code runs in a separate thread. At the moment, I am importing the list of all known modules at the beginning of my main script - this is a nasty hack I feel, and is not very flexible, as well as being a maintenance pain. This is the function that spawns the threads. I will like to modify it to dynamically load the module when it is encountered. The key in the dictionary is the name of the module containing the code: def do_work(work_info): for (worker, dataset) in work_info.items(): #import the module defined by variable worker here... t = threading.Thread(target=worker.do_work, args=[dataset]) # I'll NOT dameonize since spawned children need to clean up on shutdown # Since the threads will be holding resources #t.daemon = True t.start() Question 1 When I call the function in my script (as written above), I get the following error: AttributeError: 'str' object has no attribute 'do_work' Which makes sense, since the dictionary key is a string (name of the module to be imported). When I add the statement: import worker before spawning the thread, I get the error: ImportError: No module named worker This is strange, since the variable name rather than the value it holds are being used - when I print the variable, I get the value (as I expect) whats going on? Question 2 As I mentioned in the comments section, I realize that the do_work() function written in the spawned children needs to cleanup after itself. My understanding is to write a clean_up function that is called when do_work() has completed successfully, or an unhandled exception is caught - is there anything more I need to do to ensure resources don't leak or leave the OS in an unstable state? Question 3 If I comment out the t.daemon flag statement, will the code stil run ASYNCHRONOUSLY?. The work carried out by the spawned children are pretty intensive, and I don't want to have to be waiting for one child to finish before spawning another child. BTW, I am aware that threading in Python is in reality, a kind of time sharing/slicing - thats ok Lastly is there a better (more Pythonic) way of doing what I'm trying to do?

    Read the article

  • How to generate all strings with d-mismatches, python

    - by mr.M
    I have a following string - "AACCGGTTT" (alphabet is ["A","G","C","T"]). I would like to generate all strings that differ from the original in any two positions i.e. GAGCGGTTT ^ ^ TATCGGTTT ^ ^ How can I do it in Python? I have only brute force solution (it is working): generate all strings on a given alphabet with the same length append strings that have 2 mismatches with a given string However, could you suggest more efficient way to do so?

    Read the article

  • Python: Split, strip, and join in one line

    - by PandemoniumSyndicate
    I'm curious if their is some python magic I may not know to accomplish a bit of frivolity given the line: csvData.append(','.join([line.split(":").strip() for x in L])) I'm attempting to split a line on :, trim whitespace around it, and join on , problem is, since the array is returned from line.split(":"), the for x in L #<== L doesn't exist! causes issues since I have no name for the array returned by line.split(":") So I'm curious if there is a sexy piece of syntax I could use to accomplish this in one shot? Cheers!

    Read the article

  • detect the most used colour in an image using python

    - by sree01
    Hi, I want to find the most used colour in an image using python. for example detect the colour of the object in the following image http://www.shopcrazy.com.ph/wp-content/images/2007/02/shiny-bags-01.jpg. how to detect the base colour from the RGB codes(example - red in the above image).

    Read the article

< Previous Page | 90 91 92 93 94 95 96 97 98 99 100 101  | Next Page >