log_score
int64
-1
11
ViewCount
int64
8
6.81M
A_Id
int64
1.99k
72.5M
Available Count
int64
1
18
Question
stringlengths
15
29k
AnswerCount
int64
1
51
Q_Score
int64
0
6.79k
is_accepted
bool
2 classes
Tags
stringlengths
6
94
CreationDate
stringlengths
23
23
Q_Id
int64
1.98k
70M
Title
stringlengths
11
150
Answer
stringlengths
6
11.6k
Score
float64
-1
1.2
Users Score
int64
-36
1.15k
0
355
69,696,974
2
I have to use some existing classes. When I run these I always get the error 'IndentationError: expected an indented block'. I discovered it could be resolved by replacing the tab to 4 spaces. Because I have a lott of these classes and the classes that I want to use are not small, I was wondering if there is an easy way to replace all tabs with 4 places in one step. I use Spyder with anaconda.
2
0
false
python,tabs,spyder,space,spaces
2021-10-24T12:47:00.000
69,696,863
How to replace tab with 4 spaces in an existing class in python (spyder)
Ctrl + R Enable Regex (the .* symbol right to the first text input). Put \t in the find text field. Put (4 spaces) in the replace text field. Press "All" to replace all text
0.099668
1
0
23
69,698,850
1
I'm continuosly reading an ADC for a project in Python. I need to create to separate scripts to first: convert the results to an standard format and serving this data through internet over a protocol. The point is I don't want the main program to stop getting data if anything happens to the other two processes and I need at the same time to serve the data gathered by the ADC to the other scripts. What would be the best way to serve the data from the main program to these other two scripts? Creating an intermediate file or anything else? Thanks!
1
0
false
python,process
2021-10-24T16:37:00.000
69,698,781
Multiplexing data output
That sounds like a typical use case for a queue. I would recommend to take a look at rabbitMq
0
0
2
54
69,706,279
1
I have a pandas dataframe containing large volumes of text in each row and it takes up 1.6GB of space when converted to .pkl. Now I want to make a list of words from this dataframe, and I thought that something as simple as [word for text in df.text for word in i.split()] should suffice, however, this expression eats up all 16GB of ram in 10 seconds and that's it. It is really interesting to me how that works, why is it not just above 1.6GB? I know that lists allocate a little more memory to be able to expand, so I have tried tuples - the same result. I even tried writing everything into a file as tuples ('one', 'two', 'three') and then opening the file and doing eval - still the same result. Why does that happen? Does pandas compress data or is python that inefficient? What is a better way to do it?
1
0
true
python,python-3.x,pandas,list,memory
2021-10-25T09:58:00.000
69,706,033
Why do python lists take up so much memory?
You can use a generator. For example map(func, iterable)
1.2
1
0
46
69,706,369
1
Recently, I have downloaded Python 3.10, after installation I opened the console to check the version but what I got is version 2.7.16 !! I have not installed python before and what about the newer version that I installed? OS --> macOS Big Sur IDE--> PyCharm
1
0
false
python
2021-10-25T10:14:00.000
69,706,278
Python version through console is different from downloaded?
macOS Big Sur comes pre-installed with Python 2.7. That is why you have version 2.7.16 installed on your PC. Uninstalling Python on a Mac is rather complicated, you can keep both Python 2 and Python 3. Just make sure to refer to Python 3.1 as python3 in the console. To check what version PyCharm is using, go to Settings > Project Interpreter. If it's using Python 2.7, you can change it to Python 3.1.
0
0
2
292
69,708,414
1
To my understanding, a thread is a unit under a process. So if I use the multi-threading library in python, it would create the threads under the main process (correct me if im wrong since im still learning). But is there a way to create threads under a different process or child process? So is it possible to multithread in a process since a process has its own shared memory. Lets say an example, i have an application which needs to run in parallel with 3 process. In each process, i want it to run concurrently and share the same memory space. If let's say this is possible, does this mean i need to have a threading code inside my function so that when i run the function with a different process, it will create its own thread? P.s: I know the gil locks a thread in a process but what im curious is it even possible for a process to create its own thread. Also its not specifically for python. I just want to know in general about this
1
0
false
python,multithreading,multiprocessing
2021-10-25T12:36:00.000
69,708,188
Creating a thread inside a child process
Try not to confuse threads and processes. In python, a process is effectively a separate program with its own copy of the python interpreter (at least on platforms that use method spawn to create new processes, such as Window). These are created with the multiprocessing library. A process can have one or more threads. These share the same memory and can share global variables. These are created with the threading library. Its perfectly acceptable to create a separate process, and have that process create several threads (although it may be harder to manage as the program grows in size). As you mentioned the GIL, it does not affect process as they each have their own GIL. Threads within a process are affected by the GIL but they do drop the lock at various points which allows your threading.Thread code to effectively run "concurrently". But is there a way to create threads under a different process or child process? Yes In each process, I want it to run concurrently and share the same memory space. If you are using separate processes, they do not share the same memory. You need to use an object like a multiprocessing.Queue to transfer data between the processes or shared memory structures such as multiprocessing.Array. does this mean I need to have a threading code inside my function so that when I run the function with a different process, it will create its own thread? Yes
0.379949
2
1
77
69,713,937
1
if we are have a list lst = [1,2,3,4] and we convert it to a tuple like this tup = tuple(lst), what will be the time complexity of this code?
2
0
true
python,python-3.x,data-structures
2021-10-25T19:44:00.000
69,713,885
Time complexity of converting tuple into a list (vice versa)
It is an O(N) operation, tuple(list) simply copies the objects from the list to the tuple. so, you can still modify the internal objects(if they are mutable) but you can't add new items to the tuple
1.2
0
1
1,391
69,988,718
1
I were using environments for months and they were working perfectly.. suddenly i can not execute any code in pycharm under any virtual environment and i get this error massage: from tensorflow.python.profiler import trace ImportError: cannot import name 'trace' from 'tensorflow.python.profiler' (C:\Users\Nuha\anaconda3\envs\tf_1.15\lib\site-packages\tensorflow_core\python\profiler_init_.py) Any help please!! It seams that it happens because i install more packages and maybe conflict occurs
2
0
true
python,tensorflow,pycharm,environment,anaconda3
2021-10-26T09:00:00.000
69,720,241
ImportError: the 'trace' from 'tensorflow.python.profiler'
it was because environment conflict so i rebuild new environment and it works perfectly
1.2
0
-1
35
69,728,027
1
I am developing a Python package. It occurred to me that as my codebase changes that it would be useful to be able to automatically check what versions of Python are compatible. In general I could see this being a hard problem, but it seems to me like a naive approach that only looks at core syntax (f-formatting of strings, type hints, etc) to give an estimate of the earliest compatible version would still be useful. Is there an automatic way to do this?
1
0
false
python,compatibility
2021-10-26T18:06:00.000
69,727,968
Automatic Python version compatability checker?
write tests that use your code from the package Decide what versions of python you to support set up continuous integration (CI) that runs your tests on the the those versions of python you support.
-0.197375
-1
1
145
69,732,431
1
I am learning odoo development following Greg Moss tutorial. I successfully set up the virtual environment and install all the necessary files. However VS Code doesn't recognizer the python interpreter. I checked into the bin folder in my virtual environment to see if the interpreter was there was installed and sure enough it was. I don't understand why VS Code can't see it. Can someone help me see what I am doing wrong?
1
0
false
python,visual-studio-code,odoo
2021-10-26T22:45:00.000
69,730,773
VS code does not see the interpreter
Did you select the interpreter for VSCode? You can config this way: Open Command Palette (Ctrl+Shift+P) and type Python: Select Interpreter then click Enter interpreter path... and choose your venv python path (example: /opt/openerp/.local/share/virtualenvs/odoo14/bin/python)
0.197375
1
0
54
69,739,649
1
I have import psycopg2 in my code yet I keep getting ImportError: No module named psycopg2when I try to run it. I've tried └─$ pip3 install psycopg2 └─$ pip install psycopg2-binary └─$ sudo apt-get install build-dep python-psycopg2 anyone have a solution to this?
1
0
false
python,pip,psycopg2
2021-10-26T22:50:00.000
69,730,808
Issues with psycopg2
The issue here is: Which Python version do you want to have psycopg2? I am posting 2 solutions, since I'm not sure which one is helpful in your case: If you want to install it for Python 2, python -m pip install psycopg2 should do this. If you want to install the package for Python 3, you can run python3 -m pip or pip3. This should avoid confusions with Python 2 installations.
0
0
0
567
70,113,339
2
I selected my python interpreter to be the one pipenv created with pipenv shell in vscode. Then if I open the terminal/cmd manually or run a script using the play button up on the right, the new terminal/cmd opened will run the activate script which runs the terminal in the virtual environment. My question here is, is it using my pipenv environment or venv environment? Because if i run the pipenv shell or pipenv install, it will say that "Pipenv found itself running within a virtual environment, so it will automatically use that environment...". And also if i type exit, instead of terminating that environment, it closes the terminal.
2
0
false
python,visual-studio-code,pipenv
2021-10-27T08:09:00.000
69,734,988
Is python interpreter in vscode using pipenv or venv
This is the way I usually interact with pipenv: to check if you're on pipenv and not venv you pip graph. If the terminal prints Courtesy Notice: Pipenv found itself running within a virtual environment(...) then it means you're in a regular venv You can then deactivate and pipenv shell if you want to do it clean or just straight pipenv shell (I don't know if there is any difference) and the terminal will load environment variables and activate the pipenv environment for the remainder of it's duration. After this you can reload the interpreters and pick the Python(...):pipenv option. If you exit here, you will return to your regular venv, after which you can exit to close the terminal or deactivate to return to your global environment. venv uses the same folder as pipenv. The installed packages are also the same, you can check by running pip graph and pip list so it's just a matter of running pip shell manually. I'd love to know if there is some way to activate the environment in VS Code automatically from pip shell instead.
0
0
0
567
69,750,429
2
I selected my python interpreter to be the one pipenv created with pipenv shell in vscode. Then if I open the terminal/cmd manually or run a script using the play button up on the right, the new terminal/cmd opened will run the activate script which runs the terminal in the virtual environment. My question here is, is it using my pipenv environment or venv environment? Because if i run the pipenv shell or pipenv install, it will say that "Pipenv found itself running within a virtual environment, so it will automatically use that environment...". And also if i type exit, instead of terminating that environment, it closes the terminal.
2
0
false
python,visual-studio-code,pipenv
2021-10-27T08:09:00.000
69,734,988
Is python interpreter in vscode using pipenv or venv
You are using the python interpreter which is shown at the bottom-left of the VSCode. Even you activate a virtual environment created by pipenv in the terminal, it will have no affection on the new terminal and execute the python code. And if the pipenv found it was in a virtual environment it will not create a new virtual environment with the command pipenv install. And if you execute pipenv shell, it is still in the virtual environment which you activated before. And you can check which python you are using to verify it.
0
0
0
74
69,741,661
1
There is function in azure data explorer i.e. series_decompose() , so I need to use this function in my python program locally with data from sql So can I do it, and if yes then how?
1
0
false
python,azure,azure-functions,azure-data-explorer,azureml-python-sdk
2021-10-27T15:37:00.000
69,741,581
can we use azure data explorer function (for example series_decompose() ) locally or anywhere in python program
You can run KQL functions when using Kusto (a.k.a. ADX or Azure Data Explorer), or another service that runs on top of Kusto, e.g. Azure Monitor, Sentinel etc.
0
0
0
219
69,757,851
1
Basically, I want my variables and numbers to be more visible while I am coding in IDLE.
2
0
false
python-idle
2021-10-27T21:10:00.000
69,745,541
Is there anyway to highlight my variable names and numbers a different color in IDLE for python?
To answer your question, "Not currently." Identifiers constitute the majority of program code outside of comments and strings. It would make no sense to color then specially. It would be difficult to separate 'your' identifiers ('variables') from other identifiers. So I would reject this idea. Number literals are a different story. I just looked at a .py file in Windows Notepad++. It highlights number literals (actually, any sequence of non-blanks beginning with a digits, which is too much). This looks potentially useful and 0 and 1 are clearly different from O and l. I believe this could be added to IDLE's colorizer, and will think about it. But this is the first request I have seen. So no promises.
0
0
1
378
69,747,546
1
I downloaded py and vscode, they were working good yesterday, but today when I open, and I only tried to print something else, it appear this error "Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases." I desinstalled both and install them again, installing py i check de path bottom, and I alredy download the extension of py in vscode, and it is still no working.
3
0
false
python,visual-studio-code,runtime-error
2021-10-28T02:14:00.000
69,747,491
I just downloaded py and vscode, my first time using both, but then this appear "Python was not found; run without arguments to install from the ..."
I use to have it too. You should honestly use Pycharm. Pycharm gives less problems than vscode. You can try: Check your Python version and be sure it is installed on your machine Check the path environment variable Go to -> "start" and type "Manage App Execution Aliases". Go to it and turn off "Python"
0.066568
1
3
48
69,757,501
1
If I run the following code in python 3 1.0 + 1e-16 I get 1.0 as a result. Im wondering why? Assuming the numbers are stored as IEE754 double precision (64 bit) then I have the following representation of these numbers: Number 1: sign: 0 exponent: 01111111111 --> 1023 as decimal number significand: 0...0 Number 1e-16: sign: 0 exponent: 01111001101 --> 973 as decimal number significand: 0010000000111010111110011110111001110101011000010110 In order to add both numbers I have to increase the exponent of the the small number by 50 to fit the exponent of the representation of number 1.0. If I do that the mantissa becomes: 0.0...0100 After adding both mantissas my result should be: sign: 0 exponent: 01111111111 significand: 0000000000000000000000000000000000000000000000000100 and this is not euqal to 1.0. Can someone explain or give me a hint what I'm overlooking?
1
3
true
python,floating-point,precision,ieee-754
2021-10-28T15:56:00.000
69,757,332
Python small floats - arithmetic precision
It seems your conversion of 1e-16 to binary is not correct: float.hex(1e-16) produces 0x1.cd2b297d889bcp-54, meaning the (unbiased) exponent is -54 in decimal, not -50. Then the leading 1 drops off the end of the significand and you end up with zero.
1.2
3
0
68
69,757,723
1
I am currently using Visual Studio Code as my IDE, and I have been trying to figure out how to make it in my scripts where if a certian key -such as "l" for our example- was pressed, the script would trigger a block of code that executed a function - such as the print("Ayy you pressed a key! good job!") function. I was wondering if anyone could tell me how to do that, or how to make the import keyboard work.
2
0
false
python
2021-10-28T16:12:00.000
69,757,549
How do I make a function execute when a certain key is pressed?
As answered in other questions, responding to a key press involves dealing with events. Each key press triggers/ emits an event. There are couple of library that deals with events and in particular keyboard events. modules keyboard and getKey are worth exploring. and to a straightforward answer, refer above answer.(just dont want to repeat, credit to him)
0
0
1
178
69,763,407
1
I have a column with the following format: Original format: mm/dd/YYYY 10/28/2021 10/28/2021 the output after: print(df['mm/dd/YYYY']) 0 2021-10-28 00:00:00 1 2021-10-28 00:00:00 However when I am trying to convert to datetime I get the following error: pd.to_datetime(df['mm/dd/YYYY'], format='%Y-%m-%d %H:%M:%S') time data mm/dd/YYYY doesn't match format specified
1
0
false
python,pandas,datetime
2021-10-28T18:29:00.000
69,759,211
time data mm/dd/YYYY doesn't match format specified
You are passing the wrong format. Try pd.to_datetime(df['mm/dd/YYYY'], format='%m/%d/%Y')
0.197375
1
2
89
69,761,738
1
i have made a program that makes an approximation of the integral with Gaussian Quadrature method. The question I got in my homework is why the integral in the function integr(x) from 0 to 1 is difficult to approximate? The value of approximation is around 156.08. I thought it had something to do with the range, but no matter if I set n to be 25 or 90, the output at the last iteration will always be around 156. Sorry if the question don't belong here.
1
0
false
python,numerical-methods,gaussian,integral
2021-10-28T22:29:00.000
69,761,662
Why is this integral so difficult to approximate?
Probably due to basic floating-point arithmetic. Up to a point, if you set n sufficiently high, you'll end up at something like 156.0796666... A good alternative for numerical stability is to perform your calculations in log-space instead, if/whenever possible.
0.53705
3
0
53
69,764,651
1
I don't use XCode and it takes a lot of space .. wondering if its OK to delete it after downloading it for Homebrew to update the latest Python on the Terminal.
1
0
false
python-3.x,xcode,homebrew
2021-10-29T06:04:00.000
69,764,305
Is it OK to uninstall XCode after using it to update Python version on terminal through Homebrew?
You won't need Xcode to use Homebrew, but some of the software and components you'll want to install using brew will rely on Xcode's Command Line Tools package. You should leave it installed but you can also delete it and download it again when you need it. I would recommend you to leave it installed and maybe get an extension for your storage. LG Merlin
0
0
2
41
69,770,735
1
I am given an integer n, and told to return all the prime numbers from 1 to n. I know this question has been answered many times on here, but my question is around the two methods of keeping track of the non-primes. The two methods are: Create an array of size n, where each index represents the number from 1 to n, and use Boolean (i.e. True or False) to mark each entry if it is not a prime; the array is initially empty, but when we hit a prime, we will mark all multiples of the prime as False (i.e. not a prime) in our array, so that when we get to the number we do not need to 'check' if it is a prime. Otherwise, we will 'check' whether the number is a prime by trying modulos from 0 to that number. Create a set() and iterate from 0 to n as per 1. and each time we run into a prime store all of its multiples in this set, and for every number from 0 to n, we first check if it is in this set, before testing whether it is a prime or not. Is there any difference in terms of Time and Space complexity with the above two methods?
1
0
true
python,time-complexity,primes,space-complexity
2021-10-29T14:09:00.000
69,770,350
What is the difference in space and time complexity between keeping non-primes in a hashset vs. creating an array of Booleans?
TLDR: from the point of big-Oh, they're equivalent both in time and space. In practice, however, there is a dramatic difference. Time complexity: we're processing all numbers, setting all multiples in both cases (N/2 + N/3 + N/5+ ...). In both cases, setting a flag takes O(1) time. In both cases, space complexity is O(n). The difference is, list takes only a few bytes per boolean. Set also takes the same few bytes to store the value, but also has to store key hashes, maintain collision records, and handle resizes. While it all still boils down to asymptotic O(1) complexity, it has a substantial constant multiplier to account for in practice.
1.2
1
0
36
69,772,742
1
I am completely new to pycharm so this might be obvious. But currently every-time I load a project in pycharm I need to re-install the packages. Is there a way to automatically load them, or keep them on the project?
2
0
false
python,pycharm
2021-10-29T17:00:00.000
69,772,458
Auto loading packages to python project in pycharm
where you are installing the packages, to the python system interpreter or to the virtual environment ? If you are creating virtual env for all the projects you need to install packages everytime but if you use system python interpreter one time installation will be enough no need to install the same package again.
0
0
1
74
69,778,537
1
I have an APScheduler application running in the background and wanted to be able to interrupt certain jobs after they started. I want to do this to have more control over the processes and to prevent them from affecting other jobs. I looked up for solutions using APScheduler itself, but what I want seems to be more like interrupting a function that is already running. Is there a way to do this while not turning off my program? I don't want to delete the job or to stop the application as a whole, just to stop the process at specific and unpredictable situations.
1
0
false
python,function,apscheduler
2021-10-29T17:46:00.000
69,772,923
How to interrupt a function that is already running in Python (APScheduler)?
On APScheduler 3, the only way to do this is to set a globally accessible variable or a property thereof to some value that is then explicitly checked by the target function. So your code will have to support the notion of being interrupted. On APScheduler 4 (not released yet, as of this writing), there is going to be better cancellation support, so coroutine-based jobs can be externally cancelled without explicitly supporting this. Regular functions still need to have explicit checks but there will now be a built-in mechanism for that.
0.197375
1
0
53
69,774,168
1
I have a library which returns the timezone of a location in the format: America/New_York. Based on that timezone name, I want to calculate the hours between that time zone and UTC, taking into account daylight savings time and all. I'm using Python. My first idea was to use the Google python library and search for 'America/New_York time' but that only gave me back a list of urls which I could visit to get the info myself. It would be awesome if I could get the current time seen if I were to manually search 'America/New_York time' into google, right into my program. I'm sure this question has been asked before, but I am new to stack overflow and python so help is appreciated. Thanks!
3
0
false
python
2021-10-29T19:31:00.000
69,773,938
Calculate hours difference between timezone and UTC based timezone name in following format: America/New_York
Not a complete answer, but maybe you could implement a dictionary that connects these format to the normal format with three letters. With this you can then use datetime and pytz to make the rest. If you don't have too many possible outputs in the current format this would be feasible, otherwise of course not.
0
0
0
37
69,780,008
1
We have: (set1,set2) why does print(set1 or set2) return set1 instead of (set1 | set2) and print(set1 and set2) return set2 instead of set1.intersection(set2) ?
1
0
false
python,python-3.x,set,operands
2021-10-30T13:19:00.000
69,779,991
Can somebody explain why this is happening
That is how boolean operand works or if left operand is True/Truthy => return it if left operand is False/Falthy => return right operand and if left operand is False/Falthy => return it if left operand is True/Truthy => return right operand
0
0
-1
46
69,780,701
1
I am trying to take a piece of user input: 5+5 or 5*5 but my code receives it as a string. I want to convert it to an expression from which an answer can be deduced. However, I am not sure how to do this.
2
1
false
python
2021-10-30T17:42:00.000
69,780,659
Is there a way for python to take in a string with math operators and convert it to an expression?
Simply use "eval", but unsafe.
-0.099668
-1
0
50
69,830,333
1
How can i add python packages in VScode? I tried with pip install openpyxl but it doesn't find the package. I searched in google, but can't find the solution.
1
0
false
python,package
2021-10-31T13:25:00.000
69,787,340
How can i add python packages in VScode?
I created folders/subfolders and added __init__.py to each.
0
0
1
834
69,791,333
1
I'm trying to set up a conda environment with python 3.6 on a remote server working on CentOS. The installation goes well, but once I try to execute python I get the following message python: /lib64/libc.so.6: version 'GLIBC_2.15' not found. I noticed that for other python version older than 3.4 this doesn't happen. Given this, I tried installing glibc before python, but after installing python 3.6 and trying to run it, now I get Segmentation fault (core dumped). Note that I don't have permissions to update conda and that the version the server is using is 4.4.7, so I haven't tried updating it. However, I had previously set an environment without any problem. After I tried to install a package my jupyter notebooks wouldn't work so I removed the environment.
1
0
false
python-3.x,centos,conda,glibc,remote-server
2021-10-31T17:28:00.000
69,788,984
Can’t make python work in conda environment (GLIBC not found)
What would be the new system and the old one. The old system -- the remove server running CentOS, has GLIBC that is older than 2.15. The new system -- the one on which your Python 3.6 was compiled, used GLIBC-2.15 (or newer). You need to either find a Python 3.6 build which is targeted to your version of CentOS, or you need to compile one yourself on a system with GLIBC matching whatever is installed on your remote server. P.S. Saying "server running CentOS" is like saying "system running Windows" (i.e. not saying much). Which version of CentOS?
0.197375
1
0
136
69,804,488
1
I am working in a python project that interacts both with the cloud and with an USB port. I hardcoded the VM IP in my python code, but I need to migrate the server from my personal account to the company's account. Because I deployed this python project as a .exe I have to build it again (with pyinstaller) in case I change the server IP. Is it possible to keep this IP after migrating?
4
0
false
python,google-cloud-platform,ip,virtual-machine,pyinstaller
2021-11-01T18:58:00.000
69,801,549
Is it possible to migrate a google VM instance from one account to another keeping its external IP?
Best security practice, don't always keep public IP. Internal/external IP identified with DNS server. Understand the objective and decide accordingly.
0
0
1
69
69,802,566
1
Basically user has to input their name like jOhn JhOnson and i have to return it as John Jhonson but if the user has 3 names like jonny jon jony I have to return it like Jonny-Jon Jony and i have no idea how
2
0
true
python,string,input
2021-11-01T20:35:00.000
69,802,521
Can't figure out how to return input
I would use a string tokenizer to count the number of names you have. Then you can easily manipulate each token and then append them altogether for your return value. I can't really help you beyond that without knowing what language you are using.
1.2
0
1
2,958
69,810,293
2
I am getting an error while importing twint. I have tried a virtual environment too. ImportError Traceback (most recent call last) C:\Users\name\AppData\Local\Temp/ipykernel_12356/3064374937.py in ----> 1 import twint D:\NLP\twint\twint_init_.py in 12 from .config import Config 13 from .version import version ---> 14 from . import run 15 16 _levels = { D:\NLP\twint\twint\run.py in 2 from asyncio import get_event_loop, TimeoutError, ensure_future, new_event_loop, set_event_loop 3 ----> 4 from . import datelock, feed, get, output, verbose, storage 5 from .token import TokenExpiryException 6 from . import token D:\NLP\twint\twint\get.py in 10 import random 11 from json import loads, dumps ---> 12 from aiohttp_socks import ProxyConnector, ProxyType 13 from urllib.parse import quote 14 c:\users\name\appdata\local\programs\python\python38\lib\site-packages\aiohttp_socks_init_.py in 3 4 from .proxy import SocksVer, ProxyType ----> 5 from .connector import ( 6 SocksConnector, ProxyConnector, 7 ChainProxyConnector, ProxyInfo c:\users\name\appdata\local\programs\python\python38\lib\site-packages\aiohttp_socks\connector.py in 6 from aiohttp import TCPConnector 7 from aiohttp.abc import AbstractResolver ----> 8 from aiohttp.helpers import CeilTimeout # noqa 9 10 from .proxy import (ProxyType, SocksVer, ChainProxy, ImportError: cannot import name 'CeilTimeout' from 'aiohttp.helpers' (c:\users\name\appdata\local\programs\python\python38\lib\site-packages\aiohttp\helpers.py)
3
3
false
python,jupyter-notebook,twint
2021-11-01T23:15:00.000
69,803,757
ImportError: cannot import name 'CeilTimeout' from 'aiohttp.helpers'
I had the same error I switched building my notebook from localhost to kaggle, fell free to use Google Collab. Best of luck,
0.066568
1
0
2,958
71,178,516
2
I am getting an error while importing twint. I have tried a virtual environment too. ImportError Traceback (most recent call last) C:\Users\name\AppData\Local\Temp/ipykernel_12356/3064374937.py in ----> 1 import twint D:\NLP\twint\twint_init_.py in 12 from .config import Config 13 from .version import version ---> 14 from . import run 15 16 _levels = { D:\NLP\twint\twint\run.py in 2 from asyncio import get_event_loop, TimeoutError, ensure_future, new_event_loop, set_event_loop 3 ----> 4 from . import datelock, feed, get, output, verbose, storage 5 from .token import TokenExpiryException 6 from . import token D:\NLP\twint\twint\get.py in 10 import random 11 from json import loads, dumps ---> 12 from aiohttp_socks import ProxyConnector, ProxyType 13 from urllib.parse import quote 14 c:\users\name\appdata\local\programs\python\python38\lib\site-packages\aiohttp_socks_init_.py in 3 4 from .proxy import SocksVer, ProxyType ----> 5 from .connector import ( 6 SocksConnector, ProxyConnector, 7 ChainProxyConnector, ProxyInfo c:\users\name\appdata\local\programs\python\python38\lib\site-packages\aiohttp_socks\connector.py in 6 from aiohttp import TCPConnector 7 from aiohttp.abc import AbstractResolver ----> 8 from aiohttp.helpers import CeilTimeout # noqa 9 10 from .proxy import (ProxyType, SocksVer, ChainProxy, ImportError: cannot import name 'CeilTimeout' from 'aiohttp.helpers' (c:\users\name\appdata\local\programs\python\python38\lib\site-packages\aiohttp\helpers.py)
3
3
false
python,jupyter-notebook,twint
2021-11-01T23:15:00.000
69,803,757
ImportError: cannot import name 'CeilTimeout' from 'aiohttp.helpers'
you can just ra!pip install aiohttp==3.7.0 or go with @p4W3k answer as well, you have an outdate version or not a stable one
0
0
0
72
69,809,420
1
I'm very new to this. Here's my problem : I want to create a jupyter notebook that use python 3.7 or above. I've try to use virtualenv -p python3 but it's not work for me. Normally, I just use virtualenv myproject and I always got "Python 3.6.8" for that jupyter notebook. PS. when I open my terminal and type python -V it's show "Python 2.7.16" but after I start my current jupyter notebook and check the version again it's say "Python 3.6.8". IDK why it's not the same. May be this is the problem also?
1
0
false
python,jupyter-notebook
2021-11-02T08:52:00.000
69,807,595
How to create jupyter notebook with specific python version?
If you are using Anaconda then you can open the anaconda terminal and run: conda install python=version Version is 3.6.8 or whatever you want.
0
0
0
39
69,819,775
1
Is there a way to change "1 * 2" into a line that would be able to output 2. I couldn't just do int("1 * 2") because the * is not an integer; so I want to find out if there is a way to change * from a string back into its normal form.
3
0
false
python
2021-11-03T04:39:00.000
69,819,759
does the * symbol have a data type in python?
For this case you can use eval. eval("1*2") will return 2 as int
0
0
1
1,452
71,095,440
1
I have installed Python 3.10 from deadsnakes on my Ubuntu 20.04 machine. How to use it? python3 --version returns Python 3.8.10 and python3.10 -m venv venv returns error (I've installed python3-venv as well).
2
1
false
python,python-3.x,ubuntu,python-venv
2021-11-03T19:03:00.000
69,830,431
How to use Python3.10 on Ubuntu?
So I was having the exact same problem. I figured out that I actually had to run "sudo apt-get install python3.10-full" instead of just "sudo apt-get install python3.10". I was then able to create a python3.10 virtual environment by executing "python3.10 -m venv virt".
0.099668
1
2
71
69,830,778
2
While looking for how to allow list append() method to return the new list, I stumbled upon this solution: list.append(val) or list It's really nice and works for my use case, but I want to know how it does that.
3
1
false
python,python-3.x,list,append
2021-11-03T19:32:00.000
69,830,754
how does "list.append(val) or list" work?
list.append(val) returns None, which is Falsy, and so triggers or and returns the list. Nonetheless I consider this not pythonic, just make two separate lines without or
0.26052
4
0
71
69,830,781
2
While looking for how to allow list append() method to return the new list, I stumbled upon this solution: list.append(val) or list It's really nice and works for my use case, but I want to know how it does that.
3
1
false
python,python-3.x,list,append
2021-11-03T19:32:00.000
69,830,754
how does "list.append(val) or list" work?
list.append(val) returns None, which is a falsey value, so the value of the entire expression is list. If list.append returned a truthy value, that would be the value of the or expression.
0
0
1
91
69,834,569
1
I am trying to understand why any class that has the __contains__ method becomes an instance of the Container abstract class. I am getting a little confused because the correct way should be like this class dumb(Container): and define your own __contains__ method. It supposes to be because of duck typing but where is the duck typing there?
2
1
false
python,oop,abstract-class,duck-typing,built-in-types
2021-11-04T04:15:00.000
69,834,472
Abstract class Container - Python
If it walks like a duck and it quacks like a duck, then it must be a duck. Duck typing is the idea that, in some cases, an object can be defined moreso by its functionality than by its class designation. By including a __contains__ method, the implication is that the object functions as a container.
0.099668
1
2
101
69,845,213
1
I have a conda package which is no longer available anywhere online installed in a virtual environment. How can I install this package into a new virtual environment? Ideally I would also like to archive this package somewhere as well.
1
0
true
python,anaconda,package,conda
2021-11-04T19:34:00.000
69,844,884
Install conda package locally from other local environment
If it's in the package cache (i.e., in conda config --show pkgs_dirs), then you can install it with conda install --offline pkg_name. Also check if the tarball is still downloaded - that would be a natural archive, and one can directly install from a tarball (e.g., conda install path/to/pkg_name.tar.bz2).
1.2
1
1
29
69,873,851
1
I created an executable on my Mac that runs Python code. It creates a csv file. When I run the file on its own without freezing it using Pyinstaller, it works fine on both Windows and Mac. Then, when I do freeze it, it works fine, but it won't output the csv file on Mac (it does on Windows). It will only work if I run the exec file in the CLI with --user. I've already tried giving it permissions in the System Preferences, and in the Sharing & Permissions section of the info window. To no avail. Is there anything I may have overlooked that others may know about? Thanks, in advance!
1
0
true
python,command-line-interface,exec,pyinstaller
2021-11-04T21:29:00.000
69,846,042
How can I run an exec file that ouputs a csv without using `--user` in Mac?
It turns out that the file was being output in the user folder and not in the same folder as the exec file. For those of you working on Python scripts and freeze them using Pyinstaller, remember that files that you output are placed in your user folder on Mac.
1.2
0
0
273
69,849,187
1
I am new to VScode and want to run Python in it for my college project. I have seen that in VScode all the programmes are executed in Windows PowerShell Terminal(By default). But the problem is that it also shows the file address which is being executed which I don't want. So, please could you give a suggestion which software should be used in the terminal which only executes code and doesn't show any file address. And How can I change it?
3
0
false
python,powershell,visual-studio-code,vscode-settings
2021-11-05T05:59:00.000
69,849,163
How can I change a PowerShell terminal to a simple one in VScode for Python?
ctrl+shift+ is a Command Used to open terminal in VS code .. You can also Try Extension of python shell or powershell in VSCode ...
0
0
2
172
69,854,676
1
The script should treat 'enter' as sending the users string but instead it just prints '^M' to the terminal. I'm not sure why this is happening suddenly, it wasn't happening yesterday. Something has changed about this particular terminal session because if I open a new terminal window it works as expected in that. Any ideas? I'm using iterm on Mac (xterm?)
1
0
true
python-3.x,terminal,carriage-return,iterm2,xterm
2021-11-05T13:07:00.000
69,853,752
'input' function in python script shows carriage return character (^M) in terminal when user presses enter
TL;DR: just type the reset command on the OS shell whenever the terminal starts acting funny. Terminal emulator programs (as iterm) feature complicated internal states in order to provide literally decades of features to allow prettier programs on the terminal. Terminals started as keyboards that would physically print the typed text into paper, back in mainframe era - and "stdin" and "stdout" concepts: a single stream going forward with all data that is typed and another with all data that is printed out, are up to today, more than 50 years later, the default way to interact with the text terminal. Internal state changes by programs that deal with the terminal in different ways (like being able to read a keypress without waiting for "enter"), should be reverted when the programs terminate. But due to errors and bugs that is not always the case. I don't know which possible state would change "ˆM" to be displayed instead of a CR code being applied to the terminal. There are tens or hundreds of other possible misbehaviors, including completely messing up all characters. The reset command in modern *nixes (MacOS, Linux, BSDs) will fix everything. Although, of course, if "enter" is not being applied, it won't be possible to issue the command at all from the os shell. You will have to start a new terminal session then. From within a Python program, if you happen to make a call to some code that will always break the terminal, you might run "reset" as a subprocess by calling os.system('reset'). In particular, "ˆM" represents "ctrl + M", which is a control character with value "13" (0x0d in hex). It is the value for the "Carriage Return" control code (AKA. "return", "enter", "CR"). If you never did this: try pressing "ctrl+M", and see that it behaves the same as "enter". It is being displayed in "human readable form" instead of acting as a control character in your case. (regarding xterm and iterm: all they have in common is that they are both "terminal emulator" programs, xterm being one of the oldest existing such programs, which probably pioneered a lot of adaptations from text-only video modes to a graphic environment. "iterm" is just a normal modern app which implements terminal functionality)
1.2
1
2
89
69,855,333
1
I personally couldn't think of anything, but I'm wondering if there are some edge cases, where an older method might be somehow better.
3
0
false
python,string-formatting,f-string
2021-11-05T14:51:00.000
69,855,146
Are there cases when the f-string is not better than older string formatting methods?
f-strings aren't an option for anything you want to be localizable. An f-string is hard-coded directly into your program's source code, so you can't dynamically swap it out for a translated template string based on the user's language settings.
0.132549
2
1
345
69,857,414
2
I want to implement a lock free counter, a 4-byte int, in System V shared memory. The writer is a C++ program, the reader is a Python program. Working roughly like this: C++ code updates counter in an atomic operation Python code reads counter and has a consistent view of memory (eventual consistency is perfectly acceptable) No locks are implemented to achieve this Within the C++ language there are atomic get/update operations that allow for this and guarantee memory consistency, I believe the same is true in Python. However, as I understand it, the assumptions in C++ regarding atomic operations do not necessarily apply to code written and compiled in another language and compiler. Is there a way to achieve a consistent view of shared memory across languages that doesn't involve implementing low level locks?
3
1
false
python,c++,linux,shared-memory,lock-free
2021-11-05T15:40:00.000
69,855,772
Can a lock-free atomic write / consistent read operation be achieved on a 4 byte int using System V shared memory across language platforms?
I'm going to take issue with some of Superlokkus' assertions. The mmap primitive is available in both C++ and Python. That primitive gives you memory that is in a physical page shared by both processes. Different virtual addresses, same physical page of memory. Changes by one process are immediately viewable by the other process. That's how it has to work. It operates at a hardware level. Abstractions are irrelevant. Now, that DOESN'T mean you can get notification of those changes. If you are polling in a loop (presumably a friendly loop with sleeping in between checks), then you will see the change the next time you check.
0.066568
1
1
345
69,856,773
2
I want to implement a lock free counter, a 4-byte int, in System V shared memory. The writer is a C++ program, the reader is a Python program. Working roughly like this: C++ code updates counter in an atomic operation Python code reads counter and has a consistent view of memory (eventual consistency is perfectly acceptable) No locks are implemented to achieve this Within the C++ language there are atomic get/update operations that allow for this and guarantee memory consistency, I believe the same is true in Python. However, as I understand it, the assumptions in C++ regarding atomic operations do not necessarily apply to code written and compiled in another language and compiler. Is there a way to achieve a consistent view of shared memory across languages that doesn't involve implementing low level locks?
3
1
false
python,c++,linux,shared-memory,lock-free
2021-11-05T15:40:00.000
69,855,772
Can a lock-free atomic write / consistent read operation be achieved on a 4 byte int using System V shared memory across language platforms?
Is there a way to achieve a consistent view of shared memory across languages that doesn't involve implementing low level locks? No, not in general. First I would say this has nothing to do with languages but more with the actual platforms, architecture, implementation or operating system. Because languages differ quite strongly, take Python for example: It has no language native way of accessing memory directly or lets say in an low level manner. However some of its implementations do offer its own API. Languages intended for such low level use have abstractions for that, as C, C++ or Rust have. But that abstractions are then implemented often quite differently, as they often depend on where the code is run, interpreted or compiled for. An integer for some architectures are big endian, on most, like x86 or arm, its little endian. Operating systems also have a say, as for example memory is used and abstracted. And while many languages have a common abstractions of linear memory, its gets even messier with atomics: The compiler for C++ could generate machine code i.e. assembly that check if the CPU run on does support new fancy atomic integer instructions and use them or fall back on often supported atomic flags plus the integer. It could just rely on operating system, a spin lock, or standardized APIs defined by POSIX, SystemV, Linux, Windows if the code has the luxury of running in an operating system managed environment . For non imperative languages it gets even messier. So in order to exchange data between languages, the implementations of those languages have to use some common exchange. They could try to do that directly via shared memory for instance. This is then called an Application Binary Interface (ABI), as a memory abstraction is at least common to them a priori. Or the operating system or architecture might even standardized such things or even supports APIs. System V would be an API designed for such interchange but since AFAIK it does not have an abstraction for atomics or lock less abstractions, the answer stays no, even with the System V context out of the title.
0.066568
1
0
49
69,856,542
1
I have a pandas Timestamp column that looks like this: 2021.11.04_23.03.33 How do I convert this in a single liner to be able to look like this: 2021-11-04 23:03:33
2
0
false
python,pandas,datetime,timestamp
2021-11-05T16:21:00.000
69,856,278
Pandas Timestamp reformatting
use a regular expression by looking for the hour and minute second pattern (\d{4})-\d{2}-(\d{2})\s+(\d{2})_(\d{2}).(\d{2}).(\d{2}) and use re.findall then get each group part then reassemble the datetime stringthen convert to a datetime
0
0
0
340
69,859,922
2
I have already used pip install pysimplegui, using pip list shows that it is installed in Terminal (I use a mac). I also made sure it was the most recent version of pysimplegui. I'm newer to coding some I'm not sure what other information to put here. Any advice would be enormously helpful. I am using Jupyter Notebook through Anaconda. I should add that before this I tried doing the same thing with easygui and had the exact same error.
3
0
false
python,jupyter-notebook,anaconda,pysimplegui,easygui
2021-11-05T22:09:00.000
69,859,744
When I try to install PySimpleGUI (4.53.0) in jupyter notebook using Python 3.8 the error "no module named 'PySimpleGUI' is returned
Mixing pip install and conda install is not to recommend, although sometimes unavoidable. What has happened in your case is not related to this conflict, though. In this case, the wrong pip was invoked when installing the package, so it was installed for a different python interpreter than the one you're using to run the notebook. You can have several python versions installed globally, both python(2) and python3. Furthermore, you may have even more versions of python in virtual environments, so you need to pay attention to which version you want to install a package for. In case you don't have any specific reason not to, you'll save yourself some future headaches by using the conda package management system over pip to avoid those situations where they don't play nice with each other and you end up with a broken or unpredictable package setup. Note that I'm not saying conda is better than pip in any way, I'm only proposing going with conda since you're using the Anaconda environment and its preinstalled packages already.
0
0
0
340
69,859,790
2
I have already used pip install pysimplegui, using pip list shows that it is installed in Terminal (I use a mac). I also made sure it was the most recent version of pysimplegui. I'm newer to coding some I'm not sure what other information to put here. Any advice would be enormously helpful. I am using Jupyter Notebook through Anaconda. I should add that before this I tried doing the same thing with easygui and had the exact same error.
3
0
false
python,jupyter-notebook,anaconda,pysimplegui,easygui
2021-11-05T22:09:00.000
69,859,744
When I try to install PySimpleGUI (4.53.0) in jupyter notebook using Python 3.8 the error "no module named 'PySimpleGUI' is returned
In the anaconda terminal use python -m pip install PySimpleGUI so you install it in the python being used.
0
0
0
160
69,861,061
2
I located a really weird behavior of Jupyter and caused me to reinstall it but the problem persisted. I have a Windows machine where I have installed anaconda (the latest version). There are two environments: (base) Which contains nothing special maybe seaborn pandas etc. and is on python version 3.8.12. (tf-gpu) Which contains tensorflow-gpu and is on python version 3.9.7. Mind you, these two environments are created directly from a fresh installation of anaconda, and I didn't touch anything except installing tensorflow-gpu. When I launch Jupyter through Anaconda, it launches normally on the home folder "C:\User\user" for both environments i.e. correct packages installed and correct version of python on both. I can also launch an instance of Powershell through Anaconda or Windows, (always in home dir), and launch Jupyter both environments behave as they should (packages, python version). So far so good... The problem starts when I want to launch Jupyter from a directory other than home dir. I keep all my project files in a separate partition (D:), thus I navigate to that directory through a cmd/powershell (launched through Anaconda or Win) and type "jupyter notebook". The notebooks open on that director and: When the base env is selected the notebook reports a correct name "base"(os.environ['CONDA_DEFAULT_ENV']) and python version 3.8.12 (sys.version_info). Everything behave as base env was setup. When the tf-gpu env is selected the notebook reports a correct name "tf-gpu" but I get a python version 3.8.12, which is completely wrong! It should be 3.9.7. I can't import tensorflow since I get an error. Essentially I am in the base env without knowing it. I then check in the same cli window (tf-gpu) that launched jupyter and python --version reports 3.9.7 and of course can import tf run it etc. Jupyter just reports the environment name but in reality it uses the base environment even though it launched from said env. How can this change? Why does Jupyter works normally when launched from the user directory? If this is not solved easily, what is a workaround? Jupyter doesn't recognize symbolic links, and thus I can not navigate to another directory if it is not a subdirectory of home. Finally, I also tried adding the env as kernel through python -m ipykernel install --user --name tf-gpu --display-name "Tensorflow GPU (tf-gpu)", but it doesn't seem to change a thing. Update 1: Of course I activate the tf-gpu through conda activate tf-gpu and check the python version and tensorflow (correct results), the problem is when launching jupyter notebook. The notebook reports the tf-gpu env but wrong python version and tf is missing. Update 2: After some searching around it seems that jupyter notebook has much trouble selecting a python version if multiple versions of python are installed in the system (in my case 2, 1 on each environment environments). Which is ridiculous if you think that that's why we are using environments for...
2
2
false
python,jupyter-notebook,anaconda,jupyter
2021-11-06T00:31:00.000
69,860,582
Jupyter notebook and anaconda environment bug
The reason you are having this problem I’m guessing is because your launched jupyter notebook from your conda base environment. You will see a (base) in your comment prompt. To remedy this, When you use the command prompt to launch, do conda activate tf-gpu before you launch Jupyter notebook, now check if your versions are correct.
0
0
1
160
69,873,562
2
I located a really weird behavior of Jupyter and caused me to reinstall it but the problem persisted. I have a Windows machine where I have installed anaconda (the latest version). There are two environments: (base) Which contains nothing special maybe seaborn pandas etc. and is on python version 3.8.12. (tf-gpu) Which contains tensorflow-gpu and is on python version 3.9.7. Mind you, these two environments are created directly from a fresh installation of anaconda, and I didn't touch anything except installing tensorflow-gpu. When I launch Jupyter through Anaconda, it launches normally on the home folder "C:\User\user" for both environments i.e. correct packages installed and correct version of python on both. I can also launch an instance of Powershell through Anaconda or Windows, (always in home dir), and launch Jupyter both environments behave as they should (packages, python version). So far so good... The problem starts when I want to launch Jupyter from a directory other than home dir. I keep all my project files in a separate partition (D:), thus I navigate to that directory through a cmd/powershell (launched through Anaconda or Win) and type "jupyter notebook". The notebooks open on that director and: When the base env is selected the notebook reports a correct name "base"(os.environ['CONDA_DEFAULT_ENV']) and python version 3.8.12 (sys.version_info). Everything behave as base env was setup. When the tf-gpu env is selected the notebook reports a correct name "tf-gpu" but I get a python version 3.8.12, which is completely wrong! It should be 3.9.7. I can't import tensorflow since I get an error. Essentially I am in the base env without knowing it. I then check in the same cli window (tf-gpu) that launched jupyter and python --version reports 3.9.7 and of course can import tf run it etc. Jupyter just reports the environment name but in reality it uses the base environment even though it launched from said env. How can this change? Why does Jupyter works normally when launched from the user directory? If this is not solved easily, what is a workaround? Jupyter doesn't recognize symbolic links, and thus I can not navigate to another directory if it is not a subdirectory of home. Finally, I also tried adding the env as kernel through python -m ipykernel install --user --name tf-gpu --display-name "Tensorflow GPU (tf-gpu)", but it doesn't seem to change a thing. Update 1: Of course I activate the tf-gpu through conda activate tf-gpu and check the python version and tensorflow (correct results), the problem is when launching jupyter notebook. The notebook reports the tf-gpu env but wrong python version and tf is missing. Update 2: After some searching around it seems that jupyter notebook has much trouble selecting a python version if multiple versions of python are installed in the system (in my case 2, 1 on each environment environments). Which is ridiculous if you think that that's why we are using environments for...
2
2
true
python,jupyter-notebook,anaconda,jupyter
2021-11-06T00:31:00.000
69,860,582
Jupyter notebook and anaconda environment bug
What I did and worked was run ipython3 notebook in the environment which launched the notebook server and everything was working properly correct environment name and correct python version and packages (tensorflow is working as it should). This must have updated some configuration files since I can now run jupyter notebook from a different folder and the gpu-tfu env works correctly. Please remember that these problems were occurring only if I was launching jupyter outside the home directory (C:\User\user) on a different partition. Also keep in mind that this is a Windows installation and more complicated things may be happening with user paths, environments, etc than in linux.
1.2
0
2
87
69,869,829
1
I was creating a threshold with extreme floating point precision. I am in need of a value something like 0.999999999... with 200 9s. Is that possible in python? One solution I thought of was to create it using 1.-1e-200, but that just gives me the value 1.
2
2
false
python,python-3.x,numpy,floating-point,precision
2021-11-07T04:28:00.000
69,869,819
Extreme floating point precision number 1.0-(0.1^200) in python
It is not possible with normal variables. Python uses the processor's double precision floating point numbers, which hold about 17 decimal digits. There are add-on packages like bigfloat that can do arbitrary floating point arithmetic, but you'd need a pretty good reason to use them. Most people overestimate the need for precision in floating point math.
0.379949
4
1
72
70,753,227
1
I am working on an M1 Mac with Python version 3.9.7. I used pip to install pyglet (1.5.21), which worked. However when trying to import pyglet in python scripts, the following error pops up: ModuleNotFoundError: No module named 'pyglet' I also tried installing pyglet version 1.5.16 using conda which results in the same error. Other packages work just fine. Any help is highly appreciated!
1
0
false
python,module,apple-m1,pyglet,modulenotfounderror
2021-11-07T16:41:00.000
69,874,477
Pyglet Module not found despite being installed
I also have M1 mac. Try using pip3 instead of pip to install pyglet. Could be you only have pip installed for python3 (which is pip3) I was having errors with Python not finding the module/attributes - I resolved it by downloading the pyglet zip from github and saving it to the same folder that my .py file is in.
0.197375
1
0
879
71,907,586
2
I want to import transformers in jupyter notebook but I get the following error. What is the reason for this error? My Python version is 3.8 ImportError: cannot import name 'TypeAlias' from 'typing_extensions' I also updated the typing-extensions library version, but the problem was not resolved
3
2
false
python,huggingface-transformers,bert-language-model
2021-11-07T20:42:00.000
69,876,370
Why aren't transformers imported in Python?
maybe the probelm is the version of datasets package: pip install datasets==1.15
0
0
-1
879
71,798,627
2
I want to import transformers in jupyter notebook but I get the following error. What is the reason for this error? My Python version is 3.8 ImportError: cannot import name 'TypeAlias' from 'typing_extensions' I also updated the typing-extensions library version, but the problem was not resolved
3
2
false
python,huggingface-transformers,bert-language-model
2021-11-07T20:42:00.000
69,876,370
Why aren't transformers imported in Python?
TypeAlias is available from python version 3.10. You should upgrade your python version to avoid the error.
-0.066568
-1
0
22
70,251,220
1
I'm wondering what should I do before any preprocessing for audio data with different formats for example, assume you have telephony data with 8kbit/s and also mp3 data with 250kbit/s What is the best way to integrate these two types of formats?
1
0
false
python,deep-learning,lstm,speech-recognition,audio-processing
2021-11-07T21:21:00.000
69,876,616
Different formats (bit rate) of audio data for entering Automatic speech recognition models
You must make sure your ASR model is robust to different audio coding formats, bitrates and other channel noise. If that is the case, you can just load your audio files, resample to a standard sample-rate, and input to the model.
0
0
3
126
69,883,181
1
I am using the libraries http.server and http.client in order to build a server/client structure. The server is always on and the client makes requests. When the server is called, it calls a scraper that returns a dictionary and currently I send it like this: self.wfile.write(str(dictionary).encode("utf-8")) However the client receives a String that I have to parse. Is it possible that the server could send a dictionary? (Or even better, a json)
1
1
true
python,json,dictionary,server,client
2021-11-08T12:02:00.000
69,883,139
How to send a dictionary with python http server/client
You should try to use json.dumps({"a": 1, "b": 2}) and send your JSON object instead of encoding it as utf-8.
1.2
2
1
75
69,892,632
1
First time using StackOverflow, apologies in-case of any issues. In python, list[::-1] returns the reversed list list[0:len(list)+1] returns the complete list So why list[0:len(list)+1:-1] returns an empty list? Further, for a list l= [0,1,2,3,4,5], if I want like [4,3,2]: Trying l[2:5:-1], returns an empty list. But l[2:5][::-1] works. Can anyone explain why this is happening? Or what is python actually doing when we slice a list, with a value for step? Thanks in advance :)
1
0
false
python,list,slice
2021-11-09T03:51:00.000
69,892,608
Why does list[0:len(list)+1:-1] return an empty list?
some_list[start:stop:step] means give me elements starting at start and incrementing by step until you hit stop. Well, if you start at 0 and increment by -1, you never actually reach the stop.
0.197375
1
0
54
69,893,654
1
scores = {1:20, 2:40, 3:0, 4:25} min_score = min(scores, key=scores.get) I don't quite understand the parameters that can be passed into the key. Running the above code gives me 3 which is what I wanted. scores.get return me a dict object at certain memory address. Calling scores.get() raised me an Error. key = scores complained that dict object is not callable. My question why scores cannot be used as arguments into the key?
3
0
false
python,dictionary,min
2021-11-09T06:20:00.000
69,893,612
Problems regarding "key" in the min() function
What's happening is the key argument takes a function. That function gets called for each key in your dictionary, and the value that function returns is used to find the "min" value. In your case, calling scores.get(3) would return 0, which is less than any of the other results, which is why 3 is, indeed, your result. Supplying "scores.get()" as the key raises an error because "get" requires at least 1 argument (the value that you are "getting"). Passing just scores for key gives the error that the dictionary is not callable because you are passing a dictionary rather than a callable function.
0
0
1
88
69,899,532
1
Input Array: 67 96 The array can be re-arranged as: 96 67 Output: 1 Input Array2: 12 34 Elements can't be re-arranged so, Output: 0 I'm new to Data structures and Algo, I'm not able to solve this problem. Please help me out. Thanks in Advance!!
1
1
false
c++,python-3.x,algorithm,data-structures
2021-11-09T13:42:00.000
69,899,237
In an array I have to re-arrange elements such that each element starts with the same character with which the previous element ends
Algorithms classes are hard. It is OK. These problems require you to really think, hard, and it sometimes takes a while to get a handle on the solution. Some hints: You are not dealing with numbers to solve this problem! (The hint is the use of the word ‘character’.) You should have specific algorithms as part of your curriculum that will directly relate to solving this problem, such as a topological sort. The first things you try may not work. Keep looking until you can solve the problem in your own head and on paper. Then invest into writing up code to do it.
0.197375
1
1
142
69,900,809
1
On google colab I installed conda and then cudf through conda. However now i need to reinstall all packages like sklearn etc which I am using in my code. Is there some way to install cudf without conda ? pip no more works with cudf. Also if there is some other similar gpu dataframe which can be installed using pip, it will be of great help.
1
1
false
python,pip,gpu,conda,cudf
2021-11-09T15:07:00.000
69,900,508
Install cudf without conda
No, cudf is not available as a pip package. You don't say why you need cudf, but I would try pandas, dask or vaex, surely one of those will do what you need.
0.197375
1
1
125
69,914,292
1
I make my environments using --prefix rather than --name. This usually works fine, but I've run into a problem: I want to use Jupyter Notebook in my environment, but the command doesn't accept both the --user and --prefix as arguments. Surprisingly, I can't find the solution anywhere online. Here is the command I would be using: python -m ipykernel install --user --name [env_name] Is there any way to get a --prefix environment to show up in Jupyter Notebook?
2
1
true
python,jupyter-notebook,conda,virtual-environment
2021-11-09T15:22:00.000
69,900,725
Enabling Jupyter Notebook with --prefix
For those with the same problem, I was able to figure it out. When adding an environment to Jupyter Notebooks, it seems to me that you are only creating a category that shares a name with the environment in question. If your environment only has a --prefix, just put some recognizable name in the --name argument and it should show up that way in Notebooks.
1.2
0
1
1,097
69,912,092
1
For an assignment I have to write some data to a .csv file. I have an implementation that works using Python's csv module, but apparently I am not supposed to use any imported libraries... So, my question is how I could go about doing so? I am no expert when it comes to these things, so I am finding it difficult to find a solution online; everywhere I look import csv is being used.
3
0
false
python,csv,file-writing
2021-11-10T10:52:00.000
69,911,985
How to write to a .csv file without "import csv"
I guess that the point of your assignment is not to have some else to do it for you online. So a few hints: organise your data per row. iterates through the rows look at concatenating strings do all above while iterating to a text file per line
0.066568
1
1
61
69,916,897
1
I am running a python file in pycharm and there is no problem, but when I want to run it in the terminal, I get the error: tensorflow.python.framework.errors_impl.InternalError: CUDA runtime implicit initialization on GPU:0 failed. Status: out of memory Why does the same script work in pycharm but not in the terminal?
2
0
false
python,terminal,pycharm,out-of-memory
2021-11-10T16:26:00.000
69,916,827
Python file works in Pycharm but not in termial
Actually it works on pycharm is the same as it works on terminal, what I mean is, pycharm indirectly uses their inbuilt terminal as I've noticed, so my guess is that you might have a module error, because all the modules you install in pycharm are just stored in a virtual environment, and not in the actual environment.
0.099668
1
2
99
69,923,990
1
What is the difference in the memory management of Mutable and Immutable Data Structures in Python Programming Language?
2
1
false
python
2021-11-11T00:14:00.000
69,921,741
Memory Management of Mutable and Immutable Data Structures
The Python Language Specification does not say anything about Memory Management at all, so it obviously also doesn't say anything about Memory Management of Mutable Data Structures nor does it say anything about Memory Management of Immutable Data Structures. Every Python Implementation is free to manage their memory however they wish. For example, some use Reference Counting, some use a Tracing Garbage Collector, some use both, some don't have their own Memory Manager at all and rely on the underlying host platform. There is nothing in the Python Language Specification that would force implementors to treat Mutable and Immutable Data Structures the same, there is also nothing in the Python Language Specification that would force implementors to treat Mutable and Immutable Data Structures differently.
0.197375
2
1
22
69,932,235
1
My pip command (On apple m1) is env OPENBLAS=/usr/local/opt/appl/contrib-appleclang/OpenBLAS-0.3.18-ser CC='/usr/bin/clang' CFLAGS='-Wno-error=implicit-function-declaration -Wno-error=strict-prototypes -fvisibility=default -mmacosx-version-min=10.12 -fPIC -pipe' CXX='/usr/bin/clang++' CXXFLAGS='-stdlib=libc++ -Wno-error=implicit-function-declaration -Wno-error=strict-prototypes -fvisibility=default -mmacosx-version-min=10.12 -fPIC -pipe' F90='/usr/local/gfortran/bin/gfortran' /usr/local/opt/appl/contrib-appleclang/Python-3.9.6-sersh/bin/python3 -vvv -m pip install --cache-dir=/Users/home/research/cary/projects/svnpkgs --no-binary :all: --no-use-pep517 scipy==1.7.2 In the output I see cwd: /private/var/folders/zz/zyxvpxvq6csfxvn_n0000yyw0007qq/T/pip-install-xj7c16et/scipy_675d2f67970e4d598db970286e95680a/ Can I set that directory? Then when I try going to that directory, it is gone $ ls /private/var/folders/zz/zyxvpxvq6csfxvn_n0000yyw0007qq/T/p ip-install-xj7c16et/scipy_675d2f67970e4d598db970286e95680a/ ls: /private/var/folders/zz/zyxvpxvq6csfxvn_n0000yyw0007qq/T/pip-install-xj7c16et/scipy_675d2f67970e4d598db970286e95680a/: No such file or directory Is there a way to keep it around?
1
1
false
python,pip,scipy
2021-11-11T17:07:00.000
69,932,225
Is there a way to set where python pip builds a module? And keep that build?
Yes, you can use --no-clean to keep the temporary directories. However, it sounds like you really want pip wheel, which will build a (re)installable .whl of your package. It accepts most same arguments as pip install.
0.197375
1
0
95
69,937,433
1
I defined a class and within that class, created some methods. In one of the methods I wish to call another method. What is the reason that I cannot call the method by placing "self" into the argument? For example, method2(self).
3
1
false
python,class
2021-11-12T02:56:00.000
69,937,416
Passing in "self" as a parameter in function call in a class (Python)
The self parameter is automatically passed in as the object you are calling the method from. So if I said self.method2(), it automatically figures out that it is calling self.method2(self)
0
0
2
64
69,942,503
1
I have a list of different expressions. It looks like this: my_list = [[1 ,2 ,'M' ,2], [1 ,2 ,'A' , 1], [1 ,2 ,'g' ,3], [1 ,2 ,'o' ,4]] I want to sort the list. The key should always be the first entry in the list, in this case the book positions A, M, g, o. However, upper and lower case should be ignored. In python I used: my_list.sort(key = itemgetter (3)) Output is: [[1, 2, 'A', 1], [1, 2, 'M', 2], [1, 2, 'g', 3], [1, 2, 'o', 4]] The problem is that in my result the uppercase letters are sorted first and then the lowercase letters. How can I make lower and upper case letters sort together? The result should look like this: [[1 ,2 ,'A' ,1], [1 ,2 ,'g' ,3], [1 ,2 ,'M' ,2], [1 ,2 ,'o' ,4]]
1
0
true
python
2021-11-12T11:48:00.000
69,942,469
python sort multi-dimensional lists CASE INSENSITIVE
Use key=lambda lst: lst[2].lower().
1.2
1
0
631
70,285,571
1
When I run pipenv run pytest on my Windows machine, I get the following message: Warning: Your Pipfile requires python_version 3.7, but you are using unknown (C:\Users\d.\v\S\python.exe). $ pipenv --rm and rebuilding the virtual environment may resolve the issue. $ pipenv check will surely fail I have tried running pipenv --rm, pipenv install & re-running the tests but I get the same error message. Under Programs and Features, I have Python 3.7.0 (64-bit) & Python Launcher so I'm not sure where it is getting the unkown version from. Can someone please point me in the right direction?
1
1
false
python,pytest
2021-11-12T12:43:00.000
69,943,147
Receiving Your Pipfile requires python_version 3.7, but you are using unknown, when running pytest even though I have Python 3.7.0 installed
I had a similar issue, the following fixed my issue. Updating pip using the 'c:\users...\python.exe -m pip install --upgrade pip' command adding PYTHONPATH (pointing to the directory with the pipfil) to enviroment variables removing the current virtualenv (pipenv --rm) and reinstalling (pipenv install)
0
0
0
151
69,949,968
1
I was working on a jupyter notebook since two days on Brave browser. It was supposed to be saved but It did not. I ran file several times, so its updated version is executed successfully. But after I updated browser and relaunch it, the file has gone. Now I have the version two days ago. Is there any way to recover the last executed file from cache or somewhere else. I found some files in browser's cache folder but I am afraid they are also former versions. It seems, only two days ago it saved a checkpoint and after that it crashed and did not update again.
1
0
false
python,jupyter-notebook,recovery
2021-11-12T22:48:00.000
69,949,827
How to recover Jupyter Notebook file?
I did the following to recover my deleted .ipynb file. The cache is in ~/.cache/chromium/Default/Cache/ (I use chromium) used grep in binary search mode, grep -a 'import math' (replace search string by a keyword specific in your code) Edit the binary file in vim (it doesn't open in gedit) The python ipynb should file start with '{ "cells":' and ends with '"nbformat": 4, "nbformat_minor": 2}' remove everything outside these start and end points Rename the file as .ipynb, open it in your jupyter-notebook, it works. I think the easiest way (until developers handle this issue) to retrieve your Ipython history is to write them all into an empty file. You need to check by the date you created your last script. Obviously, it is going to be the last part of your Ipython history. To write your Ipython history into a file: %history -g -f anyfilename Alternatively (I haven't tested this): You could: Open the Local History view. Select the version you want to roll back to. On the context menu of the selection, choose Revert.
0
0
1
75
69,959,023
1
Let's imagine I download a csv file that includes all the conversations I had with a friend for the past 6 months (WhatsApp chat). I would like to divide that csv file in multiple "blocks" (each block defines a different conversation). Eg: Day 1: U1: Hey, how's going? U2: Fine! Any plan for tomorrow? U1: Nope Day 2: U2: Hello! Day 3: U1: Morning! U2: .... So the idea is to identify that in my WhatsApp Chat, if we follow the example I have provided, there should be 3 blocks of different conversations, two initiated by U1, and one initiated by U2. I cannot split it by time because some of the users could take long enough to reply the previous message. So it seems I should be able to identify if the new sentence that appears in the chat is related to the previous "block" of conversation or if it is actually starting a new block. Any ideas of what steps I need to follow if I want to identify different conversations in one chat, or if a sentence is continuing the previous conversation/starting a new one? Thanks!!
1
0
true
python,split,nlp,chat
2021-11-13T01:50:00.000
69,950,833
How to split a conversation on WhatsApp in multiple blocks based on the context?
I think even though you dont like time as the proxy for one conversation bloc, it might perform just as well as more complicated NLP. If you want to try sth more complicated, you would need some measure of semantic relatedness between texts. A classical method is to embedd your sentences/messages e.g. with sentence-BERT (see sbert.net) and use cosine similarity between sentences. you could say that a bloc ends once the embedding of the last sentence is too dissimilar from the preceeding sentence. Or you could even use BERT for next-sentence-prediction to test which sentences are plausible to follow others. But its unclear if this performs better than a simple time proxy. Sometimes simpler is better :)
1.2
0
0
160
69,951,597
2
After I type in "python3", it shows the python version as "3.8.5" but the version I have currently is python 3.10. What is going on?
2
0
false
python,windows,powershell
2021-11-13T04:15:00.000
69,951,414
Typing in "python3", but not "python", is recognized in powershell
I think you should actively manage your python version. On Linux, you can use some orders to manage them,egs: if you want install python in the whole path.please install in /opt/python/ if you want to add new candidate's python --version, you can use:sudo update-alternatives --install /usr/local/bin/python3 python3 /opt/python/3.8.5/bin/python3 80 thanks for your reading!
0
0
-1
160
69,951,474
2
After I type in "python3", it shows the python version as "3.8.5" but the version I have currently is python 3.10. What is going on?
2
0
false
python,windows,powershell
2021-11-13T04:15:00.000
69,951,414
Typing in "python3", but not "python", is recognized in powershell
I tried "py" instead of "python" or "python3" and its working. I guess I'll stick with "py" then.
-0.197375
-2
0
88
69,955,733
1
I have been dealing with this problem for months and still found no solution. I installed anacond first, and then installed spyder (but not from anaconda interface, but from outside it). I want to use spyder but when I open cmd terminal and type "pip install pyarrow", the cmd shows it is already installed but spyder doesnt load it. Thank you very much/
1
0
false
python,spyder
2021-11-13T15:16:00.000
69,955,579
Spyder doesnt recognize any installed packages, so doesnt load them
Maybe Spyder is running a python interpreter version (say 3.7), but the pyarrow package was only installed for a later version (say 3.8). Try this: Check your Python interpreter version Check for which versions of Python was Pyarrow package installed. Spyder runs a python interpreter by default and you can change which version to run: Go to Spyder --> Preferences --> Python interpreter --> Use the following python interpreter (insert the path of the desired python version).
0
0
0
66
69,957,759
1
I'm trying to learn some basics of Python integration on my Mac. The crux of my question is: When I open my terminal and type python -V, it returns python 2.7.16. If I then type python3 -V, it returns 3.9.7. Assumptions: I understand my Mac comes pre installed with Python 2 I recently completed a beginners python YouTube course in which I downloaded python 3 as well as PyCharm. When I configure a new .py project in PyCharm, I select Python 3.9 as my interpreter. I'm trying to bridge the mental gap and better understand the link between my terminal, PyCharm, and the different versions of Python. If I downloaded Python 3, why isn't that displaying when I type python -V in my terminal, broadly speaking?
1
0
false
python,terminal,pycharm
2021-11-13T19:53:00.000
69,957,733
python -V vs python3 -V: Trying to get a basic/beginners understanding
Yes , Mac comes with python2 preconfigured. And you are not seeing python3's version by default due to reason that your Path is looking for system python first which is python2. To appear python3 in your path you need to add that in your path or you can set alias too. The recommended way not to mess with path is create a venv that is virtual environment and start using that. It will avoid any mess of system settings and will point to desired python version
0
0
0
106
69,962,213
1
I am trying to create a mapping, where we are given an integer n, and also a bunch of intervals that map to random numbers. e.g. n = 55, and say we have intervals: [1:3]->-2,[4:10]->-3,[11:25]->-4,[26:44]->-5,[45:66]->-6, etc. Is it possible/how can I create a mapping that is constant time, so that for any given n, I can find the corresponding interval, then the correct mapping to the negative number? My thoughts are to create a dictionary, with keys as the intervals, and the values as the negative number- however would this be constant time lookup for any given n?
1
1
false
python,mapping,intervals
2021-11-14T10:32:00.000
69,962,172
How can I create a mapping of intervals to a number, with constant look up time? (if this is possible?)
A naive solution would be to create an array of size n, and for each index, initialize it with the target value. This is wasteful (for example if n is really big, and you have just one interval). Constructing the array is done in O(n) time, but accessing an array by index is O(1). EDIT: If the number of given intervals is a constant and not a function of n, then iterating the intervals to find the right one can be done in O(1) time. In this case you don't need any dict or array.
0
0
2
52
69,968,218
1
I have a player class and a weapon class. The weapon class has a reload method that checks the inventory property of the player. The player class has a weapon property that would hold the current weapon object, from which the reload method would be called. Since the player can change weapons, I would like to instantiate the player object without a weapon object, but have access to weapon object intellisense in development. Is this possible? In short, I'd like to be able to see the methods of my weapon class from within my player class, without an instance being created.
2
1
false
python,class,oop,methods,properties
2021-11-15T00:01:00.000
69,968,180
Can you set the property of a Python class equal to an empty class object?
Why not use a dummy weapon object that the player holds when they're not holding a weapon? It can be an invisible weapon and lets you access whatever you want in this context. If it'll mess with the unarmed state, you can make the player use unarmed attack animations if that's needed.
0.197375
2
2
420
69,981,135
1
In Vscode while i working with jupyter notebook, I am trying to run cell + advance to the next below the cell and keep the cursor in that cell. But after I advanced to the next cell, I have to click that cell to start writing my code. Is there any way to do that automatically?
1
3
true
python,visual-studio-code,jupyter
2021-11-15T20:45:00.000
69,980,655
VS Code Jupyter Notebook Run Cell Advance to Next Below
Basically, you are in the Command mode when you run cell + advance. After advancing to the next cell, you need to go back to Edit mode. Instead of clicking the cell, you can just press Enter. You can add your own shortcuts from Help > Edit Keyboard Shortcuts. But you can't create a shortcut where you can advance and also go to edit mode at the same time.
1.2
1
2
191
71,540,289
1
I have created an .exe file by pyinstaller. And I want it to run on background even if I close it and I want to be able to access it taskbar's arrow at the bottom-right corner. For example; when I close Discord, it disappears but I can access it from the taskbar's arrow at the bottom-right corner. I want to exact same thing to happen with my app, how can I do it?
1
0
false
python,windows,exe
2021-11-15T22:03:00.000
69,981,444
How to keep my app running on background?
try this pyinstaller -w --onefile "yourfile" you should be good
0.379949
2
0
377
71,381,326
2
I am trying to access a single COM port connected to an instrument. The COM port is intended to be accessed by a Python program and LabVIEW program who both read data from the instrument. They are each expected to be able to run independently of each other since they each serve different functions, but should also be able to run simultaneously (they will pull data periodically, approx every 10 seconds). I understand that serial ports cannot be connected to more than one program at the same time, but I have been told and have read that using a TCP may make this possible. Does someone have an idea of how this might work or is there a misunderstanding that I have? I have been told about TCP sockets, but do not understand what that would accomplish. I have also looked into software (such as HW VSP3), but they cost money and I do not want to purchase something unless I know that it will work.
3
0
false
python,tcp,serial-port,labview
2021-11-16T21:04:00.000
69,996,011
Accessing Serial Port With Multiple Programs
I have a suggestion but you need to use couple of simple extra hardware. You can try to create usb to wifi converter by using ESP32 and save response in global variables as array or any data type you want and broadcast them on wifi over UDP. There is no limitation of connection over UDP. You can access your variables on phyton, labview or any interface you want.
0
0
0
377
71,381,643
2
I am trying to access a single COM port connected to an instrument. The COM port is intended to be accessed by a Python program and LabVIEW program who both read data from the instrument. They are each expected to be able to run independently of each other since they each serve different functions, but should also be able to run simultaneously (they will pull data periodically, approx every 10 seconds). I understand that serial ports cannot be connected to more than one program at the same time, but I have been told and have read that using a TCP may make this possible. Does someone have an idea of how this might work or is there a misunderstanding that I have? I have been told about TCP sockets, but do not understand what that would accomplish. I have also looked into software (such as HW VSP3), but they cost money and I do not want to purchase something unless I know that it will work.
3
0
false
python,tcp,serial-port,labview
2021-11-16T21:04:00.000
69,996,011
Accessing Serial Port With Multiple Programs
You should create a third application (in python, labview or whatever you want) which is the only program that access to the COM. This program should also acts as a TCP server. The two programs you mentioned will act as TCP client and the will connect to the above mentioned application (the TCP server). The TCP server sends (via TCP/IP) the data read in the COM.
0
0
2
193
69,996,379
1
I need to write a python program that lets me set reminders for specific times, eg 'remember to take bins out at 2pm', but I can only work out setting a reminder for a certain length of time, not for a given time. I also need to be able to set multiple reminders for multiple times. Any help would be much appreciated :)
2
0
false
python,datetime,time
2021-11-16T21:35:00.000
69,996,306
Reminder for a specific time in python
This looks like a homework assignment, so you need to write the code yourself. You know what time it is now. You know when 2pm is. How much time is there between now and 2pm? Sleep for that long. Keep a list of all pending alarms. Find the earliest alarm. Remove it from the list. Sleep until that alarm happens. Repeat You'll probably find Step 2 easier if you use an appropriate data structure like heapq or PriorityQueue. But if the number of alarms is small, a list should do just fine.
0.197375
2
0
19
70,017,195
1
I have created a package in pycharm by the name "Classes in python". How can I use a class of that package in a separate package? I am using the statement "import classes in python.MyDate" and I am getting an error.
1
0
false
python
2021-11-18T09:07:00.000
70,017,136
How to import a class from a different package in the present package in python?
I suppose you are getting a syntax error, to import your class with name 'Point' from a module named 'xx' just type: from xx import Point
0
0
0
27
70,022,500
1
Whats the best method for matching occasionally occurring identifier codes, in two different large data files with millions of rows. I am thinking of creating in inner join via SQL.
1
0
false
python,sql
2021-11-18T15:23:00.000
70,022,449
Matching codes in two different files
Since you're speaking about files with millions of rows, using a database to store the data is a good idea. You can than simply use inner join as you said.
0
0
0
8
70,023,379
1
I'd like to achieve the following without using loops or comprehensions (at least explicitly) as I believe this is more elegant, especially considering the degree of nested attributes I am using. Say I have an object nested like so: a.b.c.d.e, where e is of type NodeList. NodeList holds a list of Node objects internally. You can use a.b.c.d.e.all() to get this list of all objects. Node has a member val that I would like to set on all nodes in e. I want syntax like this to work: a.b.c.d.e.all().val = <val>. Is there a way I can implement the all() method such that this is possible? Thanks.
1
0
false
python-3.x
2021-11-18T16:16:00.000
70,023,257
Elegant application of attribute set/get or method to several objects of same type
I've decided to achieve this by implementing: a.b.c.d.e.all(lambda x: x.val = <val>) where all applies the lambda to each Node. I think this solution is quite nice. Not ideal. If you have any other ideas, please let me know. Thanks.
0
0