Language Selection

English French German Italian Portuguese Spanish

Development

Programming Leftovers: Python, Go, LLVM and More

Filed under
Development
  • Python List Sorting with sorted() and sort()

    In this article, we'll examine multiple ways to sort lists in Python.

    Python ships with two built-in methods for sorting lists and other iterable objects. The method chosen for a particular use-case often depends on whether we want to sort a list in-place or return a new version of the sorted list.

  • ExpressPython: Lightweight, portable Python editor for small scripts

    There are many IDEs for Python, and it’s time for one more. ExpressPython is a lightweight, small code editor for Python 3. Originally built to help teach students how to code, it can be used in programming competitions, or just when you need a fast, small, clean code editor.
    There are a wide variety of Python IDEs and code editors available for programmers. Between PyCharm, VS Code, IDLE, Spyder, just to name a few, programmers have many to choose from depending on their needs and preferences. Add one more editor to the fray.

    ExpressPython is a small, lightweight Python 3 editor that can help with learning and competitive programming, such as coding challenges. Its creator started work on it in 2014 in order to fulfill a few needs, such as the ability to work offline.

    It is not made with the intent of becoming a fully-featured IDE, and does not include debugging features. However, it does have a few noteworthy features, so let’s take a look.

  • Google's Go team decides not to give it a try

    The Go language will not be adding a "try" keyword in the next major version, despite this being a major part of what was proposed for version 1.14.

    Go, an open source language developed by Google, features static typing and native code compilation. It is around the 15th most popular language according to the Redmonk rankings.

    Error handling in Go is currently based on using if statements to compare a returned error value to nil. If it is nil, no error occurred. This requires developers to write a lot of if statements.

    "In general Go programs have too much code-checking errors and not enough code handling them," wrote Google principal engineer Russ Cox in an overview of the error-handling problem in Go.

  • LLVM 9.0 Feature Work Is Over While LLVM 10.0 Enters Development

    Feature work is over on LLVM 9.0 as the next release for this widely-used compiler stack ranging from the AMDGPU shader compiler back-end to the many CPU targets and other innovative use-cases for this open-source compiler infrastructure.

    Ongoing LLVM release manager Hans Wennborg branched the LLVM 9.0 code-base this morning while in turn opening LLVM 10.0 development on trunk/master. This also marks the 9.0 branching for all LLVM sub-projects.

  • Mu at EuroPython

    Mu made a number of appearances at last week’s wonderful EuroPython 2019 conference in Basel, Switzerland.

  • PyCharm 2019.2 Release Candidate

    PyCharm 2019.2 is almost ready to be released, and we’re happy to announce that a release candidate is available for download now.

today's howtos and programming bits

Filed under
Development
HowTos
  • How to fix trailing underscores at the end of URLs in Chrome
  • How to Install Ubuntu Alongside With Windows 10 or 8 in Dual-Boot
  • Beginner’s guide on how to git stash :- A GIT Tutorial
  • Handy snapcraft features: Remote build
  • How to build a lightweight system container cluster
  • Start a new Cryptocurrency project with Python
  • [Mozilla] Celery without a Results Backend
  • Mucking about with microframeworks

    Python does not lack for web frameworks, from all-encompassing frameworks like Django to "nanoframeworks" such as WebCore. A recent "spare time" project caused me to look into options in the middle of this range of choices, which is where the Python "microframeworks" live. In particular, I tried out the Bottle and Flask microframeworks—and learned a lot in the process.

    I have some experience working with Python for the web, starting with the Quixote framework that we use here at LWN. I have also done some playing with Django along the way. Neither of those seemed quite right for this latest toy web application. Plus I had heard some good things about Bottle and Flask at various PyCons over the last few years, so it seemed worth an investigation.

    Web applications have lots of different parts: form handling, HTML template processing, session management, database access, authentication, internationalization, and so on. Frameworks provide solutions for some or all of those parts. The nano-to-micro-to-full-blown spectrum is defined (loosely, at least) based on how much of this functionality a given framework provides or has opinions about. Most frameworks at any level will allow plugging in different parts, based on the needs of the application and its developers, but nanoframeworks provide little beyond request and response handling, while full-blown frameworks provide an entire stack by default. That stack handles most or all of what a web application requires.

    The list of web frameworks on the Python wiki is rather eye-opening. It gives a good idea of the diversity of frameworks, what they provide, what other packages they connect to or use, as well as some idea of how full-blown (or "full-stack" on the wiki page) they are. It seems clear that there is something for everyone out there—and that's just for Python. Other languages undoubtedly have their own sets of frameworks (e.g. Ruby on Rails).

today's howtos and programming bits

Filed under
Development
HowTos

Python Programming Leftovers

Filed under
Development
  • Generate a List of Random Integers in Python

    This tutorial explains several ways to generate random numbers list in Python. Here, we’ll mainly use three Python random number generation functions. These are random.randint(), random.randrange(), and random.sample().

    You can find full details of these methods here: Generate random numbers in Python. All these functions are part of the Random module. It employs a fast pseudorandom number generator which uses the Mersenne Twister algorithm.

    However today, we’ll focus on producing a list of non-repeating integers only. Go through the below bullets to continue.

  • Coverage.py 5.0a6: context reporting

    I’ve released another alpha of coverage.py 5.0: coverage.py 5.0a6. There are some design decisions ahead that I could use feedback on.

    [...]

    I know this is a lot, and the 5.0 alpha series has been going on for a while. The features are shaping up to be powerful and useful. All of your feedback has been very helpful, keep it coming.

  • Gradient Boosting Classifiers in Python with Scikit-Learn

    Gradient boosting classifiers are a group of machine learning algorithms that combine many weak learning models together to create a strong predictive model. Decision trees are usually used when doing gradient boosting. Gradient boosting models are becoming popular because of their effectiveness at classifying complex datasets, and have recently been used to win many Kaggle data science competitions.

    The Python machine learning library, Scikit-Learn, supports different implementations of gradient boosting classifiers, including XGBoost.

  • What are *args and **kwargs and How to use them
  • Create a Flask Application With Google Login

    You’ve probably seen the option for Google Login on various websites. Some sites also have more options like Facebook Login or GitHub Login. All these options allow users to utilize existing accounts to use a new service.

    In this article, you’ll work through the creation of a Flask web application. Your application will allow a user to log in using their Google identity instead of creating a new account. There are tons of benefits with this method of user management. It’s going to be safer and simpler than managing the traditional username and password combinations.

    This article will be more straightforward if you already understand the basics of Python. It would also help to know a bit about web frameworks and HTTP requests, but that’s not strictly necessary.

Programming/Development: Python and C++

Filed under
Development
  • Return the number which is larger than the sum of the remaining numbers in a list with Python

    Given a list of numbers, return a new list consists of the number which is larger than the sum of the remaining numbers in a list or larger than absolute zero. For example, this list [2, 5, 2, 1] will convert to [5, 2, 1] because 5 is greater than 2+1, 2 is greater than 1 and 1 is greater than absolute zero. Another example. [2, 3, -3] will convert to [2, 3] because 2 is greater than 3+(-3) and 3 is greater than -3 but -3 is lesser than 0 which means -3 will not get included into the new list.

  • Jussi Pakkanen: A personal story about 10× development

    During the last few days there has been an ongoing Twitter storm about 10× developers. And like all the ones before it (and all the future ones that will inevitably happen) the debate immediately devolved into name calling and all the other things you'd except from Twitter fights. This blog post is not about that. Instead it is about a personal experience about productivity that I had to experience closer than I would have liked.

    Some years ago I was working for company X on product Y. All in all it was quite a nice experience. We had a small team working on a code base that was pretty good. It had nice tests, not too many bugs, and when issues did arise they were usually easy to fix. Eventually the project was deemed good enough and we were transferred to work on different projects.

    I have no idea what our "industry standard performance multiplier" was when we worked on that project, but for the sake of argument let's call it 1×.

    The project I got transferred to was the thing of nightmares. It was a C++ project and all the bad things that have ever been said about C++ were true about that code base. There was not much code but it was utterly incomprehensible. There were massively deep inheritance hierarchies, , compilation speed was measured in minutes for even the most trivial changes, and so on. It was managed by an architecture astronaut that, as one is wont to do, rewrote existing mature libraries as header only template libraries that were buggy and untested (one could even say untestable).

  • 101 Machine Learning Algorithms for Data Science with Cheat Sheets

    Think of this as the one-stop-shop/dictionary/directory for your machine learning algorithms. The algorithms have been sorted into 9 groups: Anomaly Detection, Association Rule Learning, Classification, Clustering, Dimensional Reduction, Ensemble, Neural Networks, Regression, Regularization. In this post, you'll find 101 machine learning algorithms, including useful infographics to help you know when to use each one (if available).

  • Python for NLP: Developing an Automatic Text Filler using N-Grams

    This is the 15th article in my series of articles on Python for NLP. In my previous article, I explained how to implement TF-IDF approach from scratch in Python. Before that we studied, how to implement bag of words approach from scratch in Python.

    Today, we will study the N-Grams approach and will see how the N-Grams approach can be used to create a simple automatic text filler or suggestion engine. Automatic text filler is a very useful application and is widely used by Google and different smartphones where a user enters some text and the remaining text is automatically populated or suggested by the application.

  • How to Write Pythonic Loops

    One of the easiest ways to spot a developer who has a background in C-style languages and only recently picked up Python is to look at how they loop through a list. In this course, you’ll learn how to take a C-style (Java, PHP, C, C++) loop and turn it into the sort of loop a Python developer would write.

    You can use these techniques to refactor your existing Python for loops and while loops in order to make them easier to read and more maintainable. You’ll learn how to use Python’s range(), xrange(), and enumerate() built-ins to refactor your loops and how to avoid having to keep track of loop indexes manually.

  • Tutorial: Advanced For Loops in Python

    In a previous tutorial, we covered the basics of Python for loops, looking at how to iterate through lists and lists of lists. But there’s a lot more to for loops than looping through lists, and in real-world data science work, you may want to use for loops with other data structures, including numpy arrays and pandas DataFrames.

    This tutorial begins with how to use for loops to iterate through common Python data structures other than lists (like tuples and dictionaries). Then we’ll dig into using for loops in tandem with common Python data science libraries like numpy, pandas, and matplotlib. We’ll also take a closer look at the range() function and how it’s useful when writing for loops.

  • PyCoder’s Weekly: Issue #377 (July 16, 2019)

Programming: Thread Synchronization, Python, C++

Filed under
Development
  • Thread Synchronization in Linux and Windows Systems, Part 1

    In modern operating systems, each process has its own address space and one thread of control. However, in practice we often face situations requiring several concurrent tasks within a single process and with access to the same process components: structures, open file descriptors, etc.

  • Intro to Black – The Uncompromising Python Code Formatter

    There are several Python code checkers available. For example, a lot of developers enjoy using Pylint or Flake8 to check their code for errors. These tools use static code analysis to check your code for bugs or naming issues. Flake8 will also check your code to see if you are adhering to PEP8, Python’s style guide.

  • Report from the February 2019 ISO C++ meeting (Library)

    Back in February, I attended the WG21 C++ standards committee meeting in rainy Kona, Hawaii (yes, it rained most of the week). This report is so late that we’re now preparing for the next meeting, which will take place mid-July in Cologne.

    As usual, I spent the majority of my time in the Library Working Group (for LWG; for details on the various Working Groups and Study Groups see Standard C++: The Committee). The purpose of the LWG is to formalize the specification of the C++ Standard Library, i.e. the second “half” of the C++ standard (although in terms of page count it’s closer to three quarters than half). With a new C++20 standard on the horizon, and lots of new features that people want added to the standard library, the LWG has been very busy trying to process the backlog of new proposals forwarded by the Library Evolution Working Group (LEWG).

    One of the main tasks at the Kona meeting was to review the “Ranges Design Cleanup” proposal. The cleanup involves a number of fixes and improvements to the new Ranges library, addressing issues that came up during the review of the previous (much larger) proposal to add the Ranges library, which is one of the biggest additions to the C++20 library (most of the other significant additions to C++20 affect the core language, without much library impact). In fact, I’d say it’s one of the biggest additions to the C++ standard library since the first standard in 1998. The Ranges library work overhauls the parts of the standard that originated in the Standard Template Library (STL), i.e. iterators, algorithms, and containers, to re-specify them in terms of C++ Concepts. This has been a multi-year effort that has now landed in the C++20 working draft, following multiple proposals and several meetings of wording review by LWG.

  • Save and load Python data with JSON

    JSON stands for JavaScript Object Notation. This format is a popular method of storing data in key-value arrangements so it can be parsed easily later. Don’t let the name fool you, though: You can use JSON in Python—not just JavaScript—as an easy way to store data, and this article demonstrates how to get started.

Programming: Python, Vim, Go and More

Filed under
Development
  • How to integrate jenkins with webhook
  • Serving Gifs With Discord Bot - Reading Time: 12 Mins
  • Python Snippet 1: More Uses For Else
  • Python Celery Guide
  • Python String Find()
  • PyCharm 2019.2 Beta #2

    It hasn’t been long since we published PyCharm 2019.2 Beta, and now we’re ready to share with you the second Beta build! The final release date is getting closer and closer, and while you wait, give PyCharm 2019.2 Beta #2 a go! Get the PyCharm 2019.2 Beta build from our website and try all the latest functionality.

  • Vimrc Tutorial

    In this article, we’re going to dive deep into the vimrc file of Vim. Once you’re inside the vimscript, it’s easy to mess things up. That’s why this rule of thumb will always be helpful in your journey with Vim. Don’t put any line in vimrc that you don’t understand.

  • CPU atomics and orderings explained

    Sometimes the question comes up about how CPU memory orderings work, and what they do. I hope this post explains it in a really accessible way.

  • You can't say Go without Google – specifically, our little logo, Chocolate Factory insists

    Back in 2009, Google chose to name its latest programming language Go, a decision that is still giving it a migraine

    It could have called it "Google Go" to avoid confusion with Frank McCabe's Go! programming language. Despite criticism, it didn't do so. After almost a year of online grumbling, Google software engineer Russ Cox, in 2010, closed GitHub Issue #9, dismissing the complaints as "unfortunate."

    And the headaches over the thing's name still won't go away (no pun intended.) Last week, Google rebuffed a request to remove its logo from the Go website, golang.org, a change supported by some developers who feel Google takes Go developers for granted.

Programming Leftovers

Filed under
Development

Programming: C++, Python, Rust and DocKnot

Filed under
Development
  • Introducing Photon Micro GUI: An open-source, lightweight UI framework with reusable declarative C++ code

    Photon Micro is an open-source, lightweight and modular GUI, which comprises of fine-grained and flyweight ‘elements’. It uses a declarative C++ code with a heavy emphasis on reuse, to form deep element hierarchies.

    Photon has its own HTML5 inspired canvas drawing engine and uses Cairo as a 2D graphics library. Cairo supports the X Window System, Quartz, Win32, image buffers, PostScript, PDF, and SVG file output.

    Joel de Guzman, the creator of Photon Micro GUI, and the main author of the Boost.Spirit Parser library, the Boost.Fusion library and the Boost.Phoenix library says, “One of the main projects I got involved with when I was working in Japan in the 90s, was a lightweight GUI library named Pica. So I went ahead, dusted off the old code and rewrote it from the ground up using modern C++.”

  • Initializing all local variables with Clang-Tidy

    A common source of all kinds of bugs is using variables without properly initializing them. Out of all security problems this one is the simplest to fix, just convert all declarations of type int x; to int x=0;. The main reason for not doing that is laziness, manually going through existing code bases and adding initialization statements is boring and nobody wants to do that.

    Fortunately nowadays we don't have to. Clang-tidy provides a nice toolkit for writing source code refactoring tools for C and C++. As an exercise I wrote a checker to do this. It is submitted upstream and is undergoing code review. Implementing it was fairly straightforward. There were only two major problems. The first one was that existing documentation consists mostly of reference manuals. There is no easy to follow tutorials, only Doxygen pages. But if you dig around on the net and work on it a bit, you can get it working.

    The second, and bigger, obstacle is that doing anything in the LLVM code base is sloooow. Everything in LLVM and Clang is linked to single, huge, monolithic libraries which take forever to link. Because of reasons I started doing this work on my secondary machine, which is a 4 core i5 with 16 gigs of RAM. I had to limit simultaneous linker jobs to 2 because otherwise it would just crash spectacularly to an out of memory error. Presumably it is impossible to compile the code base on a machine that has only 8 gigs of RAM. It seems that if you want to do any real development on LLVM you need a spare data center to run the compilations, which is unfortunate.

  • LibreOffice Appliances project (GSoC 2019)

    What happened lately: the lid hinges of my laptop broke for the second time, so I decided to buy a new (used) laptop. As always I didn’t back up my files properly (installed new OS on same disk), so had some transition issues.

    Apparently I hadn’t saved my username+password for the Wekan board, so I’ve created a new one...

  • Weekly Check-In #6
  • Weekly Check In
  • PSF GSoC students blogs: weeklyCheckIn[7]
  • Weekly check-in #6 (week 7): 08/07 to 14/07
  • Coding Period: Week 7
  • A quarter in review - Halfway to 2020

    My work with Rustup continues, though in the past month or so I've been pretty lax because I've had to travel a lot for work. I continue to be as heavily involved in Rust as I can be -- I've stepped up to the plate to lead the Rustup team, and that puts me into the Rust developer tools team proper. I attended a conference, in part to represent the Rust developer community, and I have some followup work on that which I still need to complete.

    I still hang around on the #wg-rustup Discord channel and other channels on that server, helping where I can, and I've been trying to teach my colleagues about Rust so that they might also contribute to the community.

    Previously I gave myself an 'A' but thought I could manage an 'A+' if I tried harder. Since I've been a little lax recently I'm dropping myself to an 'A-'.

  • DocKnot 3.01

    The last release of DocKnot failed a whole bunch of CPAN tests that didn't fail locally or on Travis-CI, so this release cleans that up and adds a few minor things to the dist command (following my conventions to run cppcheck and Valgrind tests). The test failures are moderately interesting corners of Perl module development that I hadn't thought about, so seem worth blogging about.

    First, the more prosaic one: as part of the tests of docknot dist, the test suite creates a new Git repository because the release process involves git archive and needs a repository to work from. I forgot to use git config to set user.email and user.name, so that broke on systems without Git global configuration. (This would have been caught by the Debian package testing, but sadly I forgot to add git to the build dependencies, so that test was being skipped.) I always get bitten by this each time I write a test suite that uses Git; someday I'll remember the first time.

Syndicate content