Search Results

Search found 15187 results on 608 pages for 'boost python'.

Page 42/608 | < Previous Page | 38 39 40 41 42 43 44 45 46 47 48 49  | Next Page >

  • number of months between two dates - using boost's date

    - by MartinP
    I've used boost::gregorian::date a bit now. I can see that there are the related months & years & weeks duration types. I can see how to use known durations to advance a given date. Qu: But how can I get the difference between two dates in months (or years or weeks) ? I was hoping to find a function like: template<typename DURATION> DURATION date_diff<DURATION>(const date& d1,const date& d2); There would need to be some handling of rounding too.

    Read the article

  • Boost singleton and undefined reference

    - by Ockonal
    Hello, I globally use singleton pattern in my project. To make it easier - boost::singleton. Current project uses Ogre3d library for rendering. Here is some class: class GraphicSystem : public singleton<GraphicSystem> { private: Ogre::RenderWindow *mWindow; public: Ogre::RenderWindow *getWindow() const { return mWindow; } }; In GraphicSystem constructor I fill the mWindow value: mWindow = mRoot->createRenderWindow(...); I cheked it, everything makes normally. So, now I have to use handler for the window in input system (to get window handle). Somewhere else in another class: Ogre::RenderWindow *temp = GraphicSystem::get_mutable_instance().getWindow(); GraphicSystem::get_mutable_instance().getWindow()->getCustomAttribute("WINDOW", &mWindowHandle); temp is 0x00, and there is segfault at last line (getting custon attribute). I can't understand, why does singleton returns undefined pointer for the window. All another singleton-based classes work well.

    Read the article

  • C++ boost ublas + units dimension constraints

    - by aaa
    hello. I am seeking advice on design/general idea on how to force matrix dimension constraints on ublas matrix/vector possibly using boost units. For example, let matrix A have dimensions of time x force (for example) // does not have dimensions, time x force and force x time are not distinguished. matrix<double> A; //something like? dimension<time, force, matrix<double> > A; dimension<force, time, matrix<double> > B = trans(A); have you done something like this or do you have some good idea about how to organize such constraints? Thank you

    Read the article

  • Purpose of boost::checked_delete

    - by Channel72
    I don't understand the purpose of boost::checked_delete. The documentation says: The C++ Standard allows, in 5.3.5/5, pointers to incomplete class types to be deleted with a delete-expression. When the class has a non-trivial destructor, or a class-specific operator delete, the behavior is undefined. Some compilers issue a warning when an incomplete type is deleted, but unfortunately, not all do, and programmers sometimes ignore or disable warnings. The supplied function and class templates can be used to prevent these problems, as they require a complete type, and cause a compilation error otherwise. So the C++ standard allows you to delete incomplete types, which causes undefined behavior if the type has a non-trivial destructor. What? How can an incomplete type have any destructor at all? Isn't an incomplete type just a prototype?

    Read the article

  • [C++] Boost test: catch user defined exceptions

    - by user231536
    If I have user defined exceptions in my code, I can't get Boost test to consider them as failures. For example, BOOST_AUTO_TEST_CASE_EXPECTED_FAILURES(MyTest,1) BOOST_AUTO_TEST_CASE(MyTest) { // code which throws user defined exception, not derived from std::exception. } I get a generic message: Caught exception: .... unknown location(0):.... It does not recognize this error as a failure since it is not a std::exception. So it does not honor the expected_failures clause. How do I enforce that the piece of code should always throw an exception? THis seems to be a useful thing to want. In case future code changes cause the code to pass and the exception is not thrown, I want to know that.

    Read the article

  • Boost singleton trouble

    - by Ockonal
    Hi guys, I have some class which uses boost singleton. It calls some function from own c++ library. This library is written in make file as dependence. Now I have another singleton class and it should call first singleton class. After this code I got linkers error about undefined references for functions which are used in first singleton. When I remove calling first singleton class from second the errors remove. Maybe there is something wrong?

    Read the article

  • Subtracting months/years from boost::posix_time::ptime

    - by Zack
    I have a boost::posix_time::ptime that points to March 31st 2010 like this: ptime p(date(2010, Mar, 31)); I would like to subtract a month (and possibly years) from this date. From the docs I see these two operators: ptime operator-(time_duration) and ptime operator-(days) but none of them can work with months/years. If I try and do: time_duration duration = hours(24 * 30); ptime pp = p - duration; I'm getting March 1st and if I'm trying: ptime pp = p - days(30); I'm still getting March 1st, while I'd like to get February 28th. How can I achieve my desired result? (I would like to get the desired result also when subtracting a month from March 28, 29, 30)

    Read the article

  • Client-server application between two computers in the same network (using boost::asio)

    - by Edwin
    I'm trying to set up a basic communication between my desktop PC and my laptop (latter one using wireless connection) both being in the same network, using the boost::asio tutorials: synchronous client and synchronous server (in c++). When I run both the server and client on the same machine (using the localhost and the datetime port as parameters), it works splendidly. But if I try to set up the laptop as server (tested it with netstat -anb from the command prompt, it is indeed running and listening to port 13 as it's supposed to, and I even deactivated the firewall to make sure it doesn't cause any problems), I cannot connect to it with the client (set up on the PC), no matter what IP I tried (localhost, and basically any IPs that ipconfig -all gave me). So no matter what I tried, I cannot find the correct address that which the client can use to connect to the server. Could anyone help me please?

    Read the article

  • How to use Python to read the physical address(MAC ID) [closed]

    - by getjoefree
    I want to read the physical address of the NIC model, i can get the results that i want to with SED.EXE before, but SED.EXE does not support my environment but Python ok, who have the means to do it. The general situation (not plug the network cable, it is impossible to obtain IP address): Ethernet adapter: Connection-specific DNS Suffix.: Chianet Description ...........: Marvell Yukon 88E8040 PCI-E Fast Ethernet Controller Physical Address .........: A4-BA-DB-9D-1E-8E Dhcp Enabled ...........: Yes Autoconfiguration Enabled ....: Yes Ethernet adapter 3: Media State . . . . . . . . . . . : Media disconnected Description . . . . . . . . . . . : Dell Wireless 1510 Wireless-N WLAN Mini-Card Physical Address. . . . . . . . . : 00-23-4D-D9-C0-28 The description of the NIC different, we can use this to fetch the corresponding physical address, base on Physical Address does not work, because the computer with the WLAN Card, I want to use Python to read my computer the card information and after Python handles an output file, output file format: SET MAC = A4BADB9D1E8E and sed format: ipconfig -all|sed -nrf getmac.sed | sed -e "s/-//g" > WINMAC.BAT getmac.sed: /Marvell Yukon 88E8040/ { n; s/.*: ([-0-9A-F]+)/set winmac=\1/p; }

    Read the article

  • Webserver python update script

    - by ThePyCoder
    So i have made this website on which you can trade stocks based on real stock quotes with virtual money. The stock quotes are in a MySQL database and are updated using a python script which runs every minute or so. Now, this works fine on my local machine with xampp but how about moving the project to a commercial web server? Basically I want my page hosted by a professional company but do those kind of servers support python scripts running in the background? Because a dedicated server would be to expensive and the script does some other sql tasks too so it can't be replaced by PHP or so... So, are there any good web hosting services out there who give me the possibility of running a script in the background and hosting a website in the foreground? For what server specifications do i have to look for? Thnx in advance! PS: I've done some research, and I found a python supporting web host WITH ssh support. Is that what I need? Or is the ssh not allowed to start processes?

    Read the article

  • How would one go about integrated python into a c++ written game for the use of user-made scripts

    - by Spencer Killen
    I'm quite new to game development (not the site) and I'm currently just trying to educate myself about some certain things before I really begin working and a game. anyway, I'd like to know what basic algorithm/outline of how a game would be coded effeciently with the implementation of user coded scripts for gameplay and levels that are written in python, Is this even possible? would all the features of python be avalible? like say "multi-threading"?

    Read the article

  • How can I keep current with Python coding style?

    - by vartec
    I've been using Python since version 2.2. I do pick up new language constructs like for example with statement or dictionary/set comprehensions. However, I've realized that even though I'm being consistent with PEP-8, for existing constructs I'm using old style, rather than new style (for example except Exception, e instead of except Exception as e). Is there a resource which would have either most current style guide, or even better a list of changes in Python's coding style?

    Read the article

  • Fun with Python

    - by dotneteer
    I am taking a class on Coursera recently. My formal education is in physics. Although I have been working as a developer for over 18 years and have learnt a lot of programming on the job, I still would like to gain some systematic knowledge in computer science. Coursera courses taught by Standard professors provided me a wonderful chance. The three languages recommended for assignments are Java, C and Python. I am fluent in Java and have done some projects using C++/MFC/ATL in the past, but I would like to try something different this time. I first started with pure C. Soon I discover that I have to write a lot of code outside the question that I try to solve because the very limited C standard library. For example, to read a list of values from a file, I have to read characters by characters until I hit a delimiter. If I need a list that can grow, I have to create a data structure myself, something that I have taking for granted in .Net or Java. Out of frustration, I switched to Python. I was pleasantly surprised to find that Python is very easy to learn. The tutorial on the official Python site has the exactly the right pace for me, someone with experience in another programming. After a couple of hours on the tutorial and a few more minutes of toying with IDEL, I was in business. I like the “battery supplied” philosophy that gives everything that I need out of box. For someone from C# or Java background, curly braces are replaced by colon(:) and tab spaces. Although I tend to miss colon from time to time, I found that the idea of tab space is actually very nice once I get use to them. I also like to feature of multiple assignment and multiple return parameters. When I need to return a by-product, I just add it to the list of returns. When would use Python? I would use Python if I need to computer anything quick. The language is very easy to use. Python has a good collection of libraries (packages). The REPL of the interpreter allows me test ideas quickly before committing them into script. Lots of computer science work have been ported from Lisp to Python. Some universities are even teaching SICP in Python. When wouldn’t I use Python? I mostly would not use it in a managed environment, such as Ironpython or Jython. Both .Net and Java already have a rich library so one has to make a choice which library to use. If we use the managed runtime library, the code will tie to the particular runtime and thus not portable. If we use the Python library, then we will face the relatively long start-up time. For this reason, I would not recommend to use Ironpython for WP7 development. The only situation that I see merit with managed Python is in a server application where I can preload Python so that the start-up time is not a concern. Using Python as a managed glue language is an over-kill most of the time. A managed Scheme could be a better glue language as it is small enough to start-up very fast.

    Read the article

  • How do I detect when my system wakes up from suspend via DBus or similar in a python app?

    - by con-f-use
    In a background Python script I need to detect, when the system just woke up from suspend. What is a good way that does not rely on a root script but rather on python modules such as DBus? I'm new to dbus so I could really use some example code. From what I read it's related to org.freedesktop.UPower /org/freedesktop/UPower org.freedesktop.UPower.Resuming Can anyone help me out with some code that connects the resuming signal to callback?

    Read the article

  • What should a Python developer know while learning Ruby?

    - by C J
    I have been a Python programmer for about 18 months, consisting of one internship and a few side projects, and I consider myself pretty comfortable in the language. However, there seems to be a lot of attention on Ruby in the programming field, but not a lot on Python anymore. So in learning Ruby, are there going to be Pythonic things that are just bad practices in Ruby? What should I watch out for, and what should I avoid?

    Read the article

  • Python Image Library: How to combine 4 images into a 2 x 2 grid?

    - by Casey
    I have 4 directories with images for an animation. I would like to take the set of images and generate a single image with the 4 images arranged into a 2x2 grid for each frame of the animation. My code so far is: import Image fluid64 = "Fluid64_half_size/00" fluid128 = "Fluid128_half_size/00" fluid512 = "Fluid512_half_size/00" fluid1024 = "Fluid1024_half_size/00" out_image = "Fluid_all/00" for pic in range(1, 26): blank_image = Image.open("blank.jpg") if pic < 10: image_num = "0"+str(pic) else: image_num = str(pic) image64 = Image.open(fluid64+image_num+".jpg") image128 = Image.open(fluid128+image_num+".jpg") image512 = Image.open(fluid512+image_num+".jpg") image1024 = Image.open(fluid1024+image_num+".jpg") out = out_image + image_num + ".jpg" blank_image.paste(image64, (0,0)).paste(fluid128, (400,0)).paste(fluid512, (0,300)).paste(fluid1024, (400,300)).save(out) Not sure why it's not working. I'm getting the error: Traceback (most recent call last): File "C:\Users\Casey\Desktop\Image_composite.py", line 24, in <module> blank_image.paste(image64, (0,0)).paste(fluid128, (400,0)).paste(fluid512, ( ste(fluid1024, (400,300)).save(out) AttributeError: 'NoneType' object has no attribute 'paste' shell returned 1 Any help would be awesome. Thanks!

    Read the article

  • Artificial Inteligence library in python

    - by João Portela
    I was wondering if there are any python AI libraries similar to aima-python but for a more recent version of python... and how they are in comparison to aima-python. I was particularly interested in search algorithms such as hill-climbing, simulated annealing, tabu search and genetic algorithms. edit: made the question more clear.

    Read the article

  • Python: How would i write this 'if' statement for a word of arbitrary length?

    - by ElCarlos
    This is what I currently have: wordlist = [fox, aced, definite, ace] for word in wordlist: a = len(word) if (ord(word[a-(a-1)] - ord(word[(a-a)])) == ord(word[a-(a-2)])-ord(word[a-(a-1)]: print "success", word else: print "fail", word What I'm trying to do is calculate the ASCII values between each of the letters in the word. And check to see if the ord of the letters are increasing by the same value. so for fox, it would check if the difference between the ord of 2nd and 1st letters are equal to the ord difference of the 3rd and 2nd letters. However, with my current 'if' statement, only the first 3 letters of a word are compared. How can I rewrite this statement to cover every letter in a word of length greater than 3? Sorry if I can't present this clearly, thanks for your time.

    Read the article

  • Python Code Introspection and Analysis

    - by oneself
    Hi, I am trying to write a Python code analyzer, and I am trying to avoid having to parse bare Python text files. I was hoping that once the Python compiler/interpreter parses the code there's a way to get to the object code or parse tree from within a running Python program. Is there anyway to do this? Thank you

    Read the article

  • Python 3.1.1 for OS X FSEvents

    - by Kingsley Reuben
    Hi all, Am working on file / folder event capturing of OS X 10.5 and 10.6 versions. My application is developed using Python 3.1.1. Donno whether FSEvents are supported by Python 3.1.1. If FSEvents are not supported by Python 3.x, is there any other way to do this using Python 3.x? regards, Kingsley Reuben

    Read the article

  • How to include only BOOST smart pointer codes into a project?

    - by afriza
    What are best practices to include boost smart pointer library only without adding all boost libraries into the project? I only want boost smart pointer library in my project and I don't want to check in/commit 200 MB source codes (boost 1.42.0) into my project repository just for that. What more, my windows mobile project itself doesn't even reach 10% of that size!

    Read the article

  • How do I copy only the values and not the references from a Python list?

    - by wrongusername
    Specifically, I want to create a backup of a list, then make some changes to that list, append all the changes to a third list, but then reset the first list with the backup before making further changes, etc, until I'm finished making changes and want to copy back all the content in the third list to the first one. Unfortunately, it seems that whenever I make changes to the first list in another function, the backup gets changed also. Using original = backup didn't work too well; nor did using def setEqual(restore, backup): restore = [] for number in backup: restore.append(number) solve my problem; even though I successfully restored the list from the backup, the backup nevertheless changed whenever I changed the original list. How would I go about solving this problem?

    Read the article

  • Can I create object names from a text file in Python 2.7?

    - by user560100
    I'm working on a game project. I've created an object, Star(Object). I want to assign the name of the variables, dynamically, from a text file. If I have a text file with: Sol Centauri Vega I want the program to create the Star(Object) with variable names from the text file. I want the process automated, because I'm looking to create hundreds of stars. I could write the code out by hand: Sol = Star(Sol) Centauri = Star(Centauri) Vega = Star(Vega) But isn't there a way to automate this? Essentially, what I eventually want is a tuple with the list of stars, as their own objects. Then, when I am doing game maintenance, I can just iterate over all the objects in the tuple.

    Read the article

  • Learning python in one weekend

    - by permalac
    Hello, I'm planing to learn python this weekend. I have some programing skills and should not be difficult if I take the good path. I'm a sysadmin and I've been looking at python scripts since long ago, but now I would like to make python my scripting language, so I'll do the effort and next monday I will start using it. Any advice on how to trace my own path to good python skills? thanks. PS: I will use vim, ypython and http://diveintopython.org

    Read the article

< Previous Page | 38 39 40 41 42 43 44 45 46 47 48 49  | Next Page >