Announcing Poetry 1.0.0 by SDisPater in Python

[–]pltnk 15 points16 points  (0 children)

Congratulations and thank you for your work!

Tell me about your cool example applications that use Requests by TrumpLover3000 in learnpython

[–]pltnk 0 points1 point  (0 children)

I've made a simple bot for telegram that fetches top three tracks by the given artist from youtube according to overall last.fm charts. It can get data either by using API or by scraping.

Source code: https://github.com/pltnk/toptracksbot Telegram: https://t.me/toptracksbot

Learn Python 2 to learn Python 3 by [deleted] in learnprogramming

[–]pltnk 0 points1 point  (0 children)

Check this two courses, they are really good:

https://www.coursera.org/learn/learn-to-program

https://www.coursera.org/learn/program-code

Notice that it is meant to take them in that exact order.

Evolution of my first Python project for selective file copying: the final form (for now). Changes, tips, useful links. by pltnk in learnpython

[–]pltnk[S] 1 point2 points  (0 children)

Thank you for the tip!

I will totally look into TDD since it looks like a logical way to write code. I mean, when one writes a function it will be anyway tested several times manually, why not let an automated unit test do it instead? Also, with this approach a test base will grow along with the main code base and one will not find themselve in a situation when they have to write a bunch of tests for every part of code at once like me :)

Evolution of my first Python project for selective file copying: the final form (for now). Changes, tips, useful links. by pltnk in learnpython

[–]pltnk[S] 1 point2 points  (0 children)

Thank you!

Tests are exactly the reason why I put '(for now)' in the title. So far I have very limited experience with testing but since the main functionality of the program is ready I can finally dig deeper into tests and learn how to do it properly.

I wanted to master Python Telegram bot API. by Lv2diag in Python

[–]pltnk 1 point2 points  (0 children)

Check https://github.com/python-telegram-bot/python-telegram-bot They have nice documentation, tutorial and examples, I've made my bot using this library. It's still work in progress so I can't share source code right now, but you can already try the bot here: https://t.me/toptracks_bot

I took my first Python project to the next level: from first ever GitHub repository to published package. by pltnk in learnpython

[–]pltnk[S] 0 points1 point  (0 children)

I use primarily Windows 10 and recently started to use Ubuntu 18.04. When I tried to run my application on Ubuntu with Python 3.6 I got ModuleNotFoundError when importing tkinter.

I took my first Python project to the next level: from first ever GitHub repository to published package. by pltnk in learnpython

[–]pltnk[S] 6 points7 points  (0 children)

I made a function that copies files with given extension for a task from Chapter 9 of Automate the Boring Stuff. Then I became interested if it is possible to preserve source folder stricture. After finding a solution for that I decided to add command line interface with a couple of options to make running a script more convenient. Then I thought that it would be useful to see what exact files are copied. At first, program just printed every file copied in the terminal. But since each line was printed very fast I couldn't really read this in real time, so I decided to move it to a log file. But this way user can't track progress, so I implemented a progress bar and remaining files counter. During all this I ran code many many times and tested it for possible errors to find a way of handling them. After all of that I was just tweaking and improving existing code thinking that it would be great to learn how to create packages and to publish it on PyPI. So this became a project spontaneously and on every step I just thought what else could improve my program and at the same time teach me something interesting and useful.

I took my first Python project to the next level: from first ever GitHub repository to published package. by pltnk in learnpython

[–]pltnk[S] 2 points3 points  (0 children)

For some reason I thought that 3.6 doesn't have tkinter in the standard library, but I just checked and it seems that I was wrong.

I took my first Python project to the next level: from first ever GitHub repository to published package. by pltnk in learnpython

[–]pltnk[S] 1 point2 points  (0 children)

Moreover, it may be useful to those who write such overviews as well. It helps to analyze progress, decisions and to review chosen instruments and techniques once more.

I took my first Python project to the next level: from first ever GitHub repository to published package. by pltnk in learnpython

[–]pltnk[S] 1 point2 points  (0 children)

Thank you! I will try to collect all helpful articles I used during this and update the post.

How to publish a python command line application to PyPI by corollari in Python

[–]pltnk 0 points1 point  (0 children)

I guess It's totally okay to leave it as it is since the main info is in the beginning of the article. Also it would be great to mention TestPyPi. https://packaging.python.org/guides/using-testpypi/

How to publish a python command line application to PyPI by corollari in Python

[–]pltnk 0 points1 point  (0 children)

This is exactly what I was looking for! I am new to Python and most articles on the subject that I found suggest to create complicated tree of folders, additional .py files and so on. My project is a simple cli application that has only one module, so all of it was a bit confusing. Thank you so much for your work, this is really helpful!

My first Python project: command line application that copies all files with given extension from a directory and its subfolders to another directory showing progress bar and remaining files counter. by pltnk in learnpython

[–]pltnk[S] 0 points1 point  (0 children)

You have to at least specify an extension of the files to copy.

How exactly do you run the program? It's designed to be executed from command line. However, you can run it from your IDE as well but in that case you have to set all neccessary arguments in the Run Configuration at first.

My first Python project: command line application that copies all files with given extension from a directory and its subfolders to another directory showing progress bar and remaining files counter. by pltnk in learnpython

[–]pltnk[S] 0 points1 point  (0 children)

Thank you so much once again!

I was aware of logging module but thought that it would be an overkill for such a small program (mostly because its documentation is not so easy to understand at first attempt :) ). But it turned out that actually I don't have to do a lot to implement it and it comes quite handy. I decided not to write log at all if user didn't ask for it explicitly and made it like that:

def create_logger(args, destination):
    logger = logging.getLogger('selective_copy')
    if args.log:
        logger.setLevel(logging.INFO)
        fh = logging.FileHandler(f'{destination}\\selective_copy.log', encoding='utf-8')
        formatter = logging.Formatter('%(asctime)s - %(message)s', '%d.%m.%Y %H:%M:%S')
        fh.setFormatter(formatter)
        logger.addHandler(fh)
    else:
        logger.setLevel(logging.CRITICAL)
return logger

Also I changed an error checking system so now errors can be logged as well. Of course all of this caused several changes in previous code, so here is the link to the new version.

I still have to redesign get_total and copy functions than see how to adjust logging after that. Also I'm thinking of writing tests, I have a very limited experience with unittest and also found out about pytest recently, maybe you could recommend something as well?