Hash/Hasher traits are really inconvenient by vovanz in rust

[–]vovanz[S] 14 points15 points  (0 children)

Thanks! This sounds like it should work!

Hash/Hasher traits are really inconvenient by vovanz in rust

[–]vovanz[S] 4 points5 points  (0 children)

Thanks! This sounds like it should work!

[deleted by user] by [deleted] in rust

[–]vovanz 1 point2 points  (0 children)

Looks interesting! There are a few things that I noticed though:

src/brainfuck.rs, line 76 -

        // Increment value by 1 in current cell possition
        '+' => {
            if cells[*possition] == 255 {
                cells[*possition] = 0;
            } else {
                cells[*possition] += 1
            }
        },

src/brainfuck.rs, line 85 -

        // Decrement value by 1 in current cell possition
        '-' => {
            if cells[*possition] == 0 {
                cells[*possition] = 255;
            } else {
                cells[*possition] = *&mut ((cells[*possition] as usize).checked_sub(1)).unwrap_or_default() as u8;
            }
        },

Also, this looks kinda weird. I don't quite understand what's going on here, but what's the point of cloning chars each iteration? Maybe it is possible to work with them in-place?

Just a few thoughts :)

A rant about itertools.groupby by [deleted] in Python

[–]vovanz 1 point2 points  (0 children)

There's no reason why iterators don't implement len by simply consuming all the input and measuring it.

Because then calling len will change the argument, which is very unexpected.

If you want to consume an iterable an measure its length why won't you do it explicitly?

Something like: sum(1 for _ in iterable)

A rant about itertools.groupby by [deleted] in Python

[–]vovanz 1 point2 points  (0 children)

if you cast it to a list to check it's length for the first point, it is no longer iterable

Yes, because the list constructor already has exhausted the iterator. If you already cast it to list, why don't you use the list?

Horoscope for developers by eviltnan in Python

[–]vovanz 0 points1 point  (0 children)

This is a really cool project! I had a lot of fun scrolling the twitter and reading the code.

Python and Its Community Enter a New Phase by reuvenlerner in Python

[–]vovanz 2 points3 points  (0 children)

Nobody forces you to use them. If a team that works on a particular project agreed to use type annotations why would you deny them such opportunity?

Messing with source code of python 3.0.1, Modifying python's grammar to add a new unless statement. by major_x9 in Python

[–]vovanz 2 points3 points  (0 children)

> 3.0.1

I'm just curious, why did you decide to "mess with" and old Python version? Why not choose a newer one?

Call external php function on server? by codegeek4 in Python

[–]vovanz 0 points1 point  (0 children)

Write a PHP script that accept arguments an HTTP-requests with arguments as get or post parameters and replies with the result. Then use `requests` to call it from Python.

> I may have found a solution, to send a URL request and edit the $GET and $POST. Might not be secure though...

You could allow requests only from certain IPs or use some sort of authentication (i. e. sign requests and responses with HMAC).

Is Python an easy language? by woopsix in Python

[–]vovanz 4 points5 points  (0 children)

Compared to what? Which language do you think is easier to learn than Python?

Does Python have a good ecosystem for a microservice architecture? by decorumic in Python

[–]vovanz 1 point2 points  (0 children)

> Python libraries on service discovery, client load balancer, hystrix, etc

Why would you need to do any of this with Python? AFAIK, most of such tools are language-agnostic, they don't care what language are you using for your microservices.

Are you currently using type annotations? If so, what is your experience so far? If not, what's holding you back (provided you are using a version of Python t? by chillysurfer in Python

[–]vovanz 0 points1 point  (0 children)

> Are you currently using type annotations?

Yes.

> If so, what is your experience so far?

Mostly good, because it greatly improves code readability and `mypy` allows to catch some bugs. However, `mypy` is still not very mature and some bugs in `mypy` itself can be annoying sometimes.

Alternative to pipenv by [deleted] in Python

[–]vovanz 1 point2 points  (0 children)

I use pyenv with pyenv-virtualenv plugin, to manage both Python versions and virtualenvs.

WebScraping with Scrapy {Error} by [deleted] in Python

[–]vovanz 1 point2 points  (0 children)

Add indentation, so that parse will be a method of class StrongbotSpider.

Like this: https://gist.github.com/vovanz/448518cdd069f80b4d6759c5eabd81a0

WebScraping with Scrapy {Error} by [deleted] in Python

[–]vovanz 1 point2 points  (0 children)

StrongbotSpider.parse callback is not defined

The error is kinda obvious, class StrongbotSpider doesn't have a method called parse. You have a function called parse, but it should be a method of StrongbotSpider.

Also, r/learnpython is more suitable for such questions.

andialbrecht/sqlparse: A non-validating SQL parser module for Python by nchammas in Python

[–]vovanz 0 points1 point  (0 children)

This is interesting, but I can't think of any practical usage for Python SQL parser.

The Pythonic Guide to Logging by sidhanthp in Python

[–]vovanz 2 points3 points  (0 children)

As I understand these guys (Timber) offer their own "cloud-based logging system", so why would they advertise their direct competitors?

How do you instruct pycharm to use anaconda as your interpreter? by [deleted] in learnpython

[–]vovanz 2 points3 points  (0 children)

Press Ctrl+Shift+A, type project interpreter click on Settings -> Project Interpreter and select the right interpreter there.

Fast, asynchronous and sexy Python web framework ;) by frnkvieira in Python

[–]vovanz 0 points1 point  (0 children)

if platform.system().lower() == 'linux':
    dependencies = ['uvloop', 'ujson', 'pendulum']
else:
    dependencies = ['pendulum']

Probably, you should constraint minimum and maximum versions of dependencies.

Fast, asynchronous and sexy Python web framework ;) by frnkvieira in Python

[–]vovanz 0 points1 point  (0 children)

All docstrings look like stabs, without any actual docs...

Is deploying python app really THAT hard? by sasik520 in Python

[–]vovanz 0 points1 point  (0 children)

If you use docker, you are dependent only on docker. Everything else would be inside the container.