Code Monkey home page Code Monkey logo

pyjokes's Introduction

pyjokes

One line jokes for programmers (jokes as a service)

Installation

Install the pyjokes module with pip:

pip3 install pyjokes

Usage

Command line

Once installed, simply call pyjoke or pyjokes from the command line:

$ pyjoke
Why do Java programmers have to wear glasses? Because they don't see sharp.

Or add it to your .bashrc or .zshrc file to see a joke every time you open a terminal!

See pyjokes --help for more info.

Python

You can also access the jokes in your own project by importing pyjokes and using the function get_joke:

>>> import pyjokes
>>> print(pyjokes.get_joke())
Why do programmers confuse Halloween with Christmas? Because OCT 31 == DEC 25.

We support many languages, and have multiple joke categories:

>>> import pyjokes
>>> print(pyjokes.get_joke("eu"))  # basque joke
Zer dira 8 Bocabits? BocaByte bat
>>> print(pyjokes.get_joke("es", "chuck"))  # spanish chuck norris joke
El teclado de Chuck Norris no tiene tecla F1, es el ordenador el que le pide ayuda a él.

There is also a get_jokes function which returns all the jokes in the given language and category:

import pyjokes

for joke in pyjokes.get_jokes():
    print(joke)

Alternatively, use the pyjokes.forever generator function:

import pyjokes

for joke in pyjokes.forever():
    # This will go on forever... you're welcome.
    print(joke)

Maintainers

The project is maintained by the members of the PyJokes Society:

  • Ben Nuttall
  • Alex Savio
  • Borja Ayerdi
  • Oier Etxaniz (RIP)

Contributing

  • The code is licensed under the BSD Licence
  • Please use GitHub issues to submit bugs and report issues
  • Feel free to contribute to the code
  • Feel free to contribute jokes (via pull request or proposal issue)
  • See the contributing policy

Website and documentation

The pyjokes website and documentation is available at https://pyjok.es/

The story of pyjokes

The story of pyjokes was told by co-founder Ben Nuttall at the PyCon UK conference: https://www.youtube.com/watch?v=nCyquLc47RE

PyJokes logo

The logo was designed by Sam Alder. The PyJokes Society is eternally grateful for his contribution.

pyjokes's People

Contributors

aleale99 avatar alexsavio avatar bennuttall avatar birdsarah avatar borjaayerdi avatar drvinceknight avatar erral avatar gras64 avatar juzraai avatar lachhebo avatar manasovo avatar martinohanlon avatar michjnich avatar musavveer avatar ntoll avatar oiertwo avatar pashok111 avatar peprolinbot avatar piciakk avatar r0d0dendr0n avatar rapolaslt avatar resonantwave avatar roeladriaans avatar scarabeusiv avatar trojjer avatar victorhck avatar vpoulailleau avatar wren6991 avatar yashmehrotra avatar yogeshnile avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyjokes's Issues

Consider removing programmer humour non-jokes

There seem to be a number of items in the jokes list which I wouldn't class as being jokes. They are humorous statements or even amusing pieces of code - but clearly these are not jokes.

Examples:

  • /* no comment */
  • #define _(x) ((x) < score)
  • tr { transform: rotate(180deg); } It seems the tables have been turned.
  • tabs > spaces
  • spaces > tabs

I don't want to be too strict but when using the module the behaviour is expected to be uniform. If there was a separate category for this type of humour that might help?

Any thoughts?

Jokes not funny!!!😡👎💩

There are lot of not funny jokes!😭

My cringe top 8:

  1. If you play a Windows CD backwards, you'll hear satanic chanting ... worse still, if you play it forwards, it installs Windows.👎
  2. How many programmers does it take to kill a cockroach? Two: one holds, the other installs Windows on it.💩
  3. Speed Kills! Use Windows.🤦‍♂️
  4. The box said: 'install on Windows 95, NT 4.0 or better'. So I installed it on Linux.🤡
  5. Windows is NOT a virus. Viruses DO something.🤦‍♀️
  6. WINDOWS stands for Will Install Needless Data On Whole System.☠️
  7. Bugs come in through open Windows.😡
  8. Computers are like air conditioners: they stop working when you open Windows.🤥

Replace this to Chuck Norris please.

Error running pyjoke

The pyjoke command with the 0.6.0 release of pyjokes appears to be broken:

(/tmp/rossi/pyjTestEnv) > pyjoke
Traceback (most recent call last):
  File "/tmp/rossi/pyjTestEnv/bin/pyjoke", line 8, in <module>
    from pyjokescli.pyjoke import main
  File "/tmp/rossi/pyjTestEnv/lib/python2.7/site-packages/pyjokescli/pyjoke.py", line 3, in <module>
    from pyjokes import pyjokes
ImportError: cannot import name pyjokes

Here is the full log, including the creation of a vanilla conda virtual environment:

> conda create python=2.7 --prefix /tmp/rossi/pyjTestEnv
Collecting package metadata (current_repodata.json): done
Solving environment: done


==> WARNING: A newer version of conda exists. <==
  current version: 4.7.10
  latest version: 4.7.11

Please update conda by running

    $ conda update -n base -c defaults conda



## Package Plan ##

  environment location: /tmp/rossi/pyjTestEnv

  added / updated specs:
    - python=2.7


The following NEW packages will be INSTALLED:

  _libgcc_mutex      pkgs/main/linux-64::_libgcc_mutex-0.1-main
  ca-certificates    pkgs/main/linux-64::ca-certificates-2019.5.15-1
  certifi            pkgs/main/linux-64::certifi-2019.6.16-py27_1
  libedit            pkgs/main/linux-64::libedit-3.1.20181209-hc058e9b_0
  libffi             pkgs/main/linux-64::libffi-3.2.1-hd88cf55_4
  libgcc-ng          pkgs/main/linux-64::libgcc-ng-9.1.0-hdf63c60_0
  libstdcxx-ng       pkgs/main/linux-64::libstdcxx-ng-9.1.0-hdf63c60_0
  ncurses            pkgs/main/linux-64::ncurses-6.1-he6710b0_1
  openssl            pkgs/main/linux-64::openssl-1.1.1c-h7b6447c_1
  pip                pkgs/main/linux-64::pip-19.1.1-py27_0
  python             pkgs/main/linux-64::python-2.7.16-h8b3fad2_3
  readline           pkgs/main/linux-64::readline-7.0-h7b6447c_5
  setuptools         pkgs/main/linux-64::setuptools-41.0.1-py27_0
  sqlite             pkgs/main/linux-64::sqlite-3.29.0-h7b6447c_0
  tk                 pkgs/main/linux-64::tk-8.6.8-hbc83047_0
  wheel              pkgs/main/linux-64::wheel-0.33.4-py27_0
  zlib               pkgs/main/linux-64::zlib-1.2.11-h7b6447c_3


Proceed ([y]/n)? y

Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
#     $ conda activate /tmp/rossi/pyjTestEnv
#
# To deactivate an active environment, use
#
#     $ conda deactivate

> conda activate /tmp/rossi/pyjTestEnv
(/tmp/rossi/pyjTestEnv) > conda install pyjokes
Collecting package metadata (current_repodata.json): done
Solving environment: done


==> WARNING: A newer version of conda exists. <==
  current version: 4.7.10
  latest version: 4.7.11

Please update conda by running

    $ conda update -n base -c defaults conda



## Package Plan ##

  environment location: /tmp/rossi/pyjTestEnv

  added / updated specs:
    - pyjokes


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    pyjokes-0.6.0              |             py_0          27 KB  conda-forge
    ------------------------------------------------------------
                                           Total:          27 KB

The following NEW packages will be INSTALLED:

  pyjokes            conda-forge/noarch::pyjokes-0.6.0-py_0


Proceed ([y]/n)?


Downloading and Extracting Packages
pyjokes-0.6.0        | 27 KB     | ######################################################################## | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
(/tmp/rossi/pyjTestEnv) > pyjoke
Traceback (most recent call last):
  File "/tmp/rossi/pyjTestEnv/bin/pyjoke", line 8, in <module>
    from pyjokescli.pyjoke import main
  File "/tmp/rossi/pyjTestEnv/lib/python2.7/site-packages/pyjokescli/pyjoke.py", line 3, in <module>
    from pyjokes import pyjokes
ImportError: cannot import name pyjokes

ModuleNotFoundError for pyjokes Despite Installation

I am encountering a ModuleNotFoundError when trying to use the pyjokes library in my Python script, even though pyjokes is installed in my environment. Here are the details of my setup and the steps I have taken to troubleshoot the issue.

Environment:

Operating System: Windows 11
Screenshot 2024-07-15 100751

Python Version: 3.12
pyjokes Version: 0.7.2
IDE: [Specify if using any, e.g., VS Code, PyCharm]
Steps to Reproduce:

Install pyjokes using pip:

sh
Copy code
pip install pyjokes
Verify installation:

sh
Copy code
pip list
Output shows pyjokes installed:

Copy code
pyjokes 0.7.2
Create a Python script (module.py):

python
Copy code
import pyjokes

def main():
joke = pyjokes.get_joke()
print(joke)

if name == "main":
main()
Run the script:

sh
Copy code
python module.py
Observed Behavior:

I receive the following error message:
arduino
Copy code
Exception has occurred: ModuleNotFoundError
No module named 'pyjokes'
Additional Details:

I have verified that pyjokes is installed in the correct Python environment.
I have tried reinstalling pyjokes using pip uninstall pyjokes followed by pip install pyjokes.
I have ensured that the script is being run in the same environment where pyjokes is installed.
I attempted to activate a virtual environment and install pyjokes within it, but encountered an issue activating the virtual environment with the following error:
csharp
Copy code
.\venv\Scripts\activate : The term '.\venv\Scripts\activate' is not recognized as the name of a cmdlet, function, script file, or operable program.
Expected Behavior:

The script should run without errors and print a joke from the pyjokes library.
Request:

Any guidance or suggestions on resolving this issue would be greatly appreciated. If there are specific environment configurations or additional steps I should take, please let me know.
Thank you for your assistance!
Screenshot 2024-07-15 100751
Screenshot 2024-07-15 101322
Screenshot 2024-07-15 100751
Screenshot 2024-07-15 101322
Screenshot 2024-07-15 101413

problem to import pyjokes

Screenshot (11)
import pyjokes

joke = pyjokes.get_joke()
print(joke)
after this when I try to run its' not running

How about adding Jokes Guidelines to CONTRIBUTING.md

We can add some common stuff like:

  • Jokes should be gender neutral.
  • Racism should be avoided.
  • Jokes that are abusive, hateful, pornographic, unlawful, libelous, or that discriminate against or disrespect people’s ethnicity, gender, sexual orientation, religious belief, age or disability should be avoided.
  • Etc.

v1.0 release

What features do you think we need for a v1.0 release?

A Non-Joke Joke

Just Say People: PHP is Trash
They Just don't Give a Shit, EVEN IF THEY ONLY KNOW PHP AND SQL

I know Its a Bad Joke, but nothing to do, I am Depressed as F***

Version bump

Hello,
I was wondering if you could bump the version of the package. The last version seems to be v0.6.0 5 years ago, and it looks like there was some improvement since then. I'm teaching python to children and would like to use your package in French, but I can't yet because French is not in v0.6.0 ^^

What is needed to get to the next version ?

Non english jokes

Hello I kindly want to ask if its okay to propose no english jokes here for the other languages? For example for the language de (german) the return is always "no jokes found" I would like to fix that. So if it is helpfull I would provide some german jokes for all categorys.

EDIT: I just found a lot german jokes are already implemented. So there is either a problem with getting these or i do use it in the wrong way. If I run pyjoke -l de from command line the output is No jokes found.

How many jokes does this have?

Only if this has a decent amount of jokes will I consider using this. Maybe you should mention or at least give us an approximation in your documentation?

add jokes in swedish

I would like to add some jokes in swedish in pyjokes. So please someone let me if I can start working on that. Thank you.

Tests

@oiertwo where are the tests? They should be runnable locally (i.e. before commit, not after) and stored in a tests directory in the project root.

I have some suggestions for more tests:

  • Test all jokes are 140 characters or less
  • Test error is appropriate for command line near-miss (i.e. pyjokes)
  • Test errors are appropriate for language not available in Python and on command line (e.g. pyjokes -l eu)

(others: please add other wanted test cases here)

'RIGHT SINGLE QUOTATION MARK' (U+2019) in jokes causes traceback on Python 3 in Windows

These two jokes in the neutral category:

'Knock, knock.' 'Who’s there?' ... very long pause ... 'Java.'
3 Database Admins walked into a NoSQL bar. A little while later they walked out because they couldn’t find a table.

contain a U+2019 character for the apostrophe in "Who's" and "couldn't" - when they are printed, the following traceback is produced on Windows:

[py34np19] C:\Program Files\Microsoft SDKs\Windows\v7.0>pyjoke
Traceback (most recent call last):
  File "C:\Users\gmarkall\Miniconda3\envs\py34np19\Scripts\pyjoke-script.py", line 4, in <module>
    __import__('pkg_resources').run_script('pyjokes==0.5.0', 'pyjoke')
  File "C:\Users\gmarkall\Miniconda3\envs\py34np19\lib\site-packages\setuptools-18.1-py3.4.egg\pkg_resources\__init__.py", line 735, in run_script
  File "C:\Users\gmarkall\Miniconda3\envs\py34np19\lib\site-packages\setuptools-18.1-py3.4.egg\pkg_resources\__init__.py", line 1659, in run_script
  File "C:\Users\gmarkall\Miniconda3\envs\py34np19\lib\site-packages\pyjokes-0.5.0-py3.4.egg\EGG-INFO\scripts\pyjoke", line 54, in <module>
  File "C:\Users\gmarkall\Miniconda3\envs\py34np19\lib\site-packages\pyjokes-0.5.0-py3.4.egg\EGG-INFO\scripts\pyjoke", line 51, in main
  File "C:\Users\gmarkall\Miniconda3\envs\py34np19\lib\encodings\cp850.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_map)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u2019' in position 20: character maps to <undefined>

I guess this is because Windows is using a different character encoding to other OSes - I've seen the Java joke get printed out successfully on my Linux machine so it seems not to be a problem there.

`explicit` should be called `adult`

I guess there is no such thing as an explicit joke, all jokes should be explicit, otherwise nobody would be able to transmit them. A sentence could have an implicit joke, but that I guess is called irony.
Shouldn't we call adult instead of explicit?

General Jokes

The Mycroft project has built a skill that uses pyjokes for its joke repository.

I would like to propose that we add general joke support that include a wide range of jokes outside of programming centric. I would be happy to get this started if the pull request will be accepted.

Adding jokes in french

I would like to add some jokes in french in pyjokes. So please someone let me if I can start working on that. Thank you.

Remove dirty jokes from default pyjoke command

Maybe we could add some tags to each joke. For example: allpublic, dirty, mother, geek, python

So in the default 'pyjoke' command run we avoid the jokes with some tags, e.g., 'dirty'.

What do you think?

Haskell/Functional Programming Joke

Hi, I'd like to propose a joke. I opened pull request #85 with the patch.

How many Haskell programmers does it take to change a lightbulb? Haskell programmers don't 'change' lightbulbs, they 'replace' them. And you must also replace the whole house at the same time.

The above quote was taken from the free book F# for Fun and Profit.

pyjokes: command not found

You install a package called pyjokes then you might expect to run pyjokes at the command line. However, currently this returns the error pyjokes: command not found because the correct command is pyjoke.

This usage makes sense as pyjoke yields a single joke. However, this could be confusing.

I propose three options:

  1. We rename the script to pyjokes
  2. We alias pyjokes to pyjoke
  3. We leave pyjoke as is, and add a pyjokes script to say "Did you mean pyjoke?"

Thoughts?

Dad jokes?

I was wondering if it would be worth adding a category specifically for "dad" jokes, which is to say, a marker specifically for pun-based humour. I would add that this would create a bucket of the more difficult-to-translate items, as that sort of thing tends to be vocabulary-specific.

Translate some jokes into Chinese

Hello, I noticed this project long time ago, and I'm glad to translate some jokes into Chinese :)

https://github.com/pi314/pyjokes/tree/zh_tw

I encounter some problems in test_joke_encoding.py, Chinese jokes just can't pass the following test:

#test if joke is windows compatible
def _test_joke_win(joke):
    assert len(joke) <= len(joke.encode('ascii', 'ignore'))

I don't have Windows machines right now, and I'm not sure if it is ok to modify this test case.

Any ideas?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.