Search Results

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

Page 80/548 | < Previous Page | 76 77 78 79 80 81 82 83 84 85 86 87  | Next Page >

  • Selective Inheritance Python

    - by user1682595
    I am making a python program which is using classes, I want one class to only selectively inherit from another e.g: class X(object): def __init__(self): self.hello = 'hello' class Y(object): def __init__(self): self.moo = 'moo' class Z(): def __init__(self, mode): if mode == 'Y': # Class will now Inherit from Y elif mode == 'X': # Class will now Inherit for X How can I do this without making another class?

    Read the article

  • python socket problem

    - by uytg
    I write this python code: import socks import socket socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, "64.83.219.7", 58279) socket.socket = socks.socksocket socket.setdefaulttimeout(19) import urllib2 print urllib2.urlopen('http://www.google.com').read() but when I execute it, I get this error: urllib2.URLError: <urlopen error timed out> What am I doing wrong?

    Read the article

  • warning in python with MySQLdb

    - by juanpablo
    hi, when I use MySQLdb get this message: /var/lib/python-support/python2.6/MySQLdb/init.py:34: DeprecationWarning: the sets module is deprecated from sets import ImmutableSet I try filter the warning with import warnings warnings.filterwarnings("ignore", message="the sets module is deprecated from sets import ImmutableSet") but, I not get changes. any suggestion? Many thanks.

    Read the article

  • Python to MATLAB: exporting list of strings using scipy.io

    - by user292461
    I am trying to export a list of text strings from Python to MATLAB using scipy.io. I would like to use scipy.io because my desired .mat file should include both numerical matrices (which I learned to do here) and text cell arrays. I tried: import scipy.io my_list = ['abc', 'def', 'ghi'] scipy.io.savemat('test.mat', mdict={'my_list': my_list) In MATLAB, I load test.mat and get a character array: my_list = adg beh cfi How do I make scipy.io export a list into a MATLAB cell array?

    Read the article

  • Python iterator question

    - by hdx
    I have this list: names = ['john','Jonh','james','James','Jardel'] I want loop over the list and handle consecutive names with a case insensitive match in the same iteration. So in the first iteration I would do something with'john' and 'John' and I want the next iteration to start at 'james'. I can't think of a way to do this using Python's for loop, any suggestions?

    Read the article

  • Python ttk.Button -command, runs without button being pressed

    - by Markus Kothe
    I'm making a small script in python with ttk and I have a problem where a function runs where it shouldn't. The button code looks as follows: btReload = ttk.Button(treeBottomUI, text="Reload", width=17, command=loadModelTree(treeModel)) btReload.pack(side="left") and the function is as this: def loadModelTree(tree): print ("Loading models...") allModels = os.listdir(confModPath) for chunk in allModels: ... For some reason, the function runs without the button being pressed. Why?

    Read the article

  • how to make python load dylib on osx

    - by navicore
    Hi, Trying to load a shared lib out of the current '.' dir in a unit test on osx. What works on Linux and Netbsd there is a symlink _mymodule.so --> ../.libs/libmymodule.so but on osx, python's import mymodule won't find _mymodule.dylib --> ../.libs/libmymodule.dylib I've tried adding export DYLD_LIBRARY_PATH=.:$DYLD_LIBRARY_PATH to the script env, nogo. Any help appreciated. -Ed

    Read the article

  • Advice on Python/Django and message queues

    - by Andy Hume
    I have an application in Django, that needs to send a large number of emails to users in various use cases. I don't want to handle this synchronously within the application for obvious reasons. Has anyone any recommendations for a message queuing server which integrates well with Python, or they have used on a Django project? The rest of my stack is Apache, mod_python, MySQL.

    Read the article

  • Python most common element in a list

    - by Richard
    What is an efficient way to find the most common element in a Python list? My list items may not be hashable so can't use a dictionary. Also in case of draws the item with the lowest index should be returned. Example: >>> most_common(['duck', 'duck', 'goose']) 'duck' >>> most_common(['goose', 'duck', 'duck', 'goose']) 'goose'

    Read the article

  • Stretch array (Numpy, Python)

    - by Snej
    I have a numpy array [1,2,3,4,5,6,7,8,9,10,11,12,13,14] and want to have an array structured like [[1,2,3,4], [2,3,4,5], [3,4,5,6], ..., [11,12,13,14]]. Sure this is possible by looping over the large array and adding arrays of length four to the new array, but I'm curious if there is some secret 'magic' Python method doing just this :)

    Read the article

  • Generating a list of values a regex COULD match in Python

    - by mlissner
    I'm trying to use a regex as an input, and from there generate all the possible values that the regex would match. So, for example, if the regex is "three-letter words starting with a, and ending in c," then the code would generate a list with the values [aac, abc, acc, adc, a1c....]. Is there an easy way to do this? I'm using python.

    Read the article

  • Force an indent in Python code for organizational purposes

    - by Vine
    Is there a way to force an indent in Python? I kind of want it for the sake of making the code look organized. As an example: # How it looks now class Bro: def __init__(self): self.head = 1 self.head.eye = 2 self.head.nose = 1 self.head.mouth = 1 self.neck = 1 self.torso = 1 # How it'd look ideally (indenting sub-variables of 'head') class Bro: def __init__(self): self.head = 1 self.head.eye = 2 self.head.nose = 1 self.head.mouth = 1 self.neck = 1 self.torso = 1 I imagine this is possible with some sort of workaround, yeah?

    Read the article

  • Getting a Jabber status via Python

    - by Teegijee
    I'm developing a website using the Django framework, and I need to retrieve Jabber (okay, Google Talk) statuses for a user. Most of the Jabber python libraries seem like an incredible amount of overkill (and overhead) for a simple task. Is there any simple way to do this? I know very little about XMPP/Jabber, though of course I'm willing to learn. Do you need to be an authenticated and "friended" user to retrieve another user's status?

    Read the article

  • pip: dealing with multiple Python versions?

    - by David Wolever
    Is there any way to make pip play well with multiple versions of Python? For example, I want to use pip to explicitly install things to either my site 2.5 installation or my site 2.6 installation. For example, with easy_install, I use easy_install-2.{5,6}. And, yes — I know about virtualenv, and no — it's not a solution to this particular problem.

    Read the article

  • Python memory leaks

    - by Fragsworth
    I have a long-running script which, if let to run long enough, will consume all the memory on my system. Without going into details about the script, I have two questions: Are there any "Best Practices" to follow, which will help prevent leaks from occurring? What techniques are there to debug memory leaks in Python?

    Read the article

  • Extracting words between delimiters [] in python

    - by kris
    From the below string, I want to extract the words between delimters [ ] like 'Service Current','Service','9991','1.22': str='mysrv events Generating Event Name [Service Current], Category [Service] Test [9991] Value [1.22]' How can I extract the same in python? Thanks in advance Kris

    Read the article

  • Installing PyGraphViz on Windows, Python 2.7

    - by user574043
    I can't install pygraphviz on Windows XP. I'm using Python27. Before to launch the setup I've changet these two variables of the setup.py file library_path="C:\\Archivos de programa\\Graphviz 2.28\\bin" include_path="C:\\Archivos de programa\\Graphviz 2.28\\include\\graphviz" Then I've launched the setup. I'm using mingw32 as a compiler. I don't know what can I do now. I'm using the following command: C:\Python27\pygraphviz-1.1>c:\python27\python setup.py build -c mingw32 And I've got the folling result library_path=C:\Archivos de programa\Graphviz 2.28\bin include_path=C:\Archivos de programa\Graphviz 2.28\include\graphviz running build running build_py running build_ext building 'pygraphviz._graphviz' extension C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall "-IC:\Archivos de programa\Graphviz 2.28\include\graphviz" -Ic:\python27\include -Ic:\python 27\PC -c pygraphviz/graphviz_wrap.c -o build\temp.win32-2.7\Release\pygraphviz\graphviz_wrap.o pygraphviz/graphviz_wrap.c: In function 'agattr_label': pygraphviz/graphviz_wrap.c:2855:5: warning: return makes integer from pointer without a cast writing build\temp.win32-2.7\Release\pygraphviz\_graphviz.def Traceback (most recent call last): File "setup.py", line 146, in <module> package_data = package_data File "c:\python27\lib\distutils\core.py", line 152, in setup dist.run_commands() File "c:\python27\lib\distutils\dist.py", line 953, in run_commands self.run_command(cmd) File "c:\python27\lib\distutils\dist.py", line 972, in run_command cmd_obj.run() File "c:\python27\lib\distutils\command\build.py", line 127, in run self.run_command(cmd_name) File "c:\python27\lib\distutils\cmd.py", line 326, in run_command self.distribution.run_command(command) File "c:\python27\lib\distutils\dist.py", line 972, in run_command cmd_obj.run() File "c:\python27\lib\distutils\command\build_ext.py", line 340, in run self.build_extensions() File "c:\python27\lib\distutils\command\build_ext.py", line 449, in build_extensions self.build_extension(ext) File "c:\python27\lib\distutils\command\build_ext.py", line 531, in build_extension target_lang=language) File "c:\python27\lib\distutils\ccompiler.py", line 741, in link_shared_object extra_preargs, extra_postargs, build_temp, target_lang) File "c:\python27\lib\distutils\cygwinccompiler.py", line 260, in link target_lang) File "c:\python27\lib\distutils\unixccompiler.py", line 218, in link libraries) File "c:\python27\lib\distutils\ccompiler.py", line 1121, in gen_lib_options opt = compiler.runtime_library_dir_option(dir) File "c:\python27\lib\distutils\unixccompiler.py", line 285, in runtime_library_dir_option compiler = os.path.basename(sysconfig.get_config_var("CC")) File "c:\python27\lib\ntpath.py", line 198, in basename return split(p)[1] File "c:\python27\lib\ntpath.py", line 170, in split d, p = splitdrive(p) File "c:\python27\lib\ntpath.py", line 125, in splitdrive if p[1:2] == ':': TypeError: 'NoneType' object is not subscriptable Any idea on how to solve it over windows? In other computer with Ubuntu I've installed without problems.

    Read the article

  • Python importing

    - by Algorist
    Hi, If I have a file myfile.py, which imports Class1 from file.py and file.py contains imports to different classes in file2.py, file3.py, file4.py. In my myfile.py, can I access these classes or do I need to again import file2.py, file3.py etc... My question is whether python automatically add all the imports included in the file I imported, and can I use them automatically. Thank you. Bala

    Read the article

  • How Do I code this in python with simplejson

    - by Spikie
    how do i code a python program that return a json element that look like this {1:{'name':foo,'age':xl} 2:{'name':vee,'age':xx} .... } What i meant is that i want return nested dictionaries What i hoped to accomplish is something like this var foo = 1.name # to the the value of name in the clientside I hope all this made sense .English is my second language thanks in advance

    Read the article

  • Card game in python

    - by matt1024
    What is the best way to store the cards and suits in python so that I can hold a reference to these values in another variable? For example, if I have a list called hand (cards in players hand), how could I hold values that could refer to the names of suits and values of specific cards, and how would these names and values of suits and cards be stored?

    Read the article

  • Extracting a URL in Python

    - by Kyle Hayes
    In regards to: http://stackoverflow.com/questions/720113/find-hyperlinks-in-text-using-python-twitter-related How can I extract just the url so I can put it into a list/array? Edit Let me clarify, I don't want to parse the URL into pieces. I want to extract the URL from the text of the string to put it into an array. Thanks!

    Read the article

< Previous Page | 76 77 78 79 80 81 82 83 84 85 86 87  | Next Page >